use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.
the class ProcessBscTreeItemsCommand method execute.
@Override
public boolean execute(Context context) throws Exception {
if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
return false;
}
String host = StringUtils.defaultString((String) context.get("http")) + ApplicationSiteUtils.getHost(Constants.getMainSystem()) + "/" + ApplicationSiteUtils.getContextPathFromMap(Constants.getMainSystem()) + "/";
String iconImg = IconUtils.getMenuIcon(host, "STAR");
BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
List<Map<String, Object>> items = new LinkedList<Map<String, Object>>();
for (VisionVO vision : treeObj.getVisions()) {
Map<String, Object> visionDataMap = new HashMap<String, Object>();
visionDataMap.put("type", "parent");
visionDataMap.put("name", vision.getTitle());
visionDataMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + vision.getOid());
items.add(visionDataMap);
List<Map<String, Object>> perspectiveItems = new LinkedList<Map<String, Object>>();
for (PerspectiveVO perspective : vision.getPerspectives()) {
Map<String, Object> perspectiveDataMap = new HashMap<String, Object>();
perspectiveDataMap.put("type", "parent");
perspectiveDataMap.put("name", perspective.getName());
perspectiveDataMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + perspective.getOid());
perspectiveItems.add(perspectiveDataMap);
visionDataMap.put("children", perspectiveItems);
List<Map<String, Object>> objectivesStrategyList = new LinkedList<Map<String, Object>>();
for (ObjectiveVO objective : perspective.getObjectives()) {
Map<String, Object> objectiveMap = new HashMap<String, Object>();
objectiveMap.put("type", "parent");
objectiveMap.put("name", objective.getName());
objectiveMap.put("id", BscConstants.KPI_TREE_NOT_ITEM + objective.getOid());
objectivesStrategyList.add(objectiveMap);
perspectiveDataMap.put("children", objectivesStrategyList);
List<Map<String, Object>> kpiList = new LinkedList<Map<String, Object>>();
for (KpiVO kpi : objective.getKpis()) {
Map<String, Object> kpiMap = new HashMap<String, Object>();
kpiMap.put("type", "Leaf");
kpiMap.put("name", iconImg + kpi.getName());
kpiMap.put("id", kpi.getOid());
kpiList.add(kpiMap);
objectiveMap.put("children", kpiList);
}
}
}
}
this.setResult(context, items);
if (null == items || items.size() < 1) {
this.setMessage(context, SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
}
return false;
}
use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.
the class KpiReportContentQueryAction method loadContentFromUpload.
// public static void main(String args[]) throws Exception {
// //CONTENT.txt
// String jsonStr = FSUtils.readStr("/tmp/CONTENT.txt");
// Map<String, Object> dataMap = new ObjectMapper().readValue(jsonStr, Map.class);
// BscStructTreeObj treeObj = new ObjectMapper().readValue( SimpleUtils.deB64((String)dataMap.get("treeObjJsonStr")), BscStructTreeObj.class);
// ChainResultObj resultObj = new ObjectMapper().readValue( SimpleUtils.deB64((String)dataMap.get("resultObjJsonStr")), ChainResultObj.class);
//
// }
/**
* 2016-11-01
* 主要給 workspace 圖表元件載入用的
*
* @throws ControllerException
* @throws AuthorityException
* @throws ServiceException
* @throws Exception
*/
private void loadContentFromUpload() throws ControllerException, AuthorityException, ServiceException, Exception {
String uploadOid = this.getFields().get("uploadOid");
byte[] content = UploadSupportUtils.getDataBytes(uploadOid);
String jsonStr = new String(content, Constants.BASE_ENCODING);
if (StringUtils.isBlank(jsonStr)) {
throw new Exception("Report json data error.");
}
@SuppressWarnings("unchecked") Map<String, Object> dataMap = new ObjectMapper().readValue(jsonStr, Map.class);
BscStructTreeObj treeObj = new ObjectMapper().readValue(SimpleUtils.deB64((String) dataMap.get("treeObjJsonStr")), BscStructTreeObj.class);
ChainResultObj resultObj = new ObjectMapper().readValue(SimpleUtils.deB64((String) dataMap.get("resultObjJsonStr")), ChainResultObj.class);
this.body = String.valueOf(resultObj.getValue());
this.message = resultObj.getMessage();
if (!StringUtils.isBlank(this.body) && this.body.startsWith("<!-- BSC_PROG003D0001Q -->")) {
this.success = IS_YES;
}
this.fillPerspectivesPieChartData(treeObj);
this.fillPerspectivesBarChartData(treeObj);
this.fillLineChartData(treeObj);
}
use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.
the class KpiReportContentQueryAction method getContent.
private void getContent() throws ControllerException, AuthorityException, ServiceException, Exception {
this.checkFields();
this.setDateValue();
this.checkDateRange();
Context context = this.getChainContext();
SimpleChain chain = new SimpleChain();
ChainResultObj resultObj = chain.getResultFromResource("kpiReportHtmlContentChain", context);
this.body = String.valueOf(resultObj.getValue());
this.message = resultObj.getMessage();
if (!StringUtils.isBlank(this.body) && this.body.startsWith("<!-- BSC_PROG003D0001Q -->")) {
this.success = IS_YES;
}
if (context.get("treeObj") == null) {
return;
}
BscStructTreeObj treeObj = (BscStructTreeObj) context.get("treeObj");
this.fillPerspectivesPieChartData(treeObj);
this.fillPerspectivesBarChartData(treeObj);
this.fillLineChartData(treeObj);
if (YesNo.YES.equals(this.getFields().get("nobody"))) {
// 不要有 HTML版本的輸出, 通常是給 dashboard 用的
this.body = "";
}
// ------------------------------------------------------------------
if (YesNo.YES.equals(this.getFields().get("saveResultJson")) && treeObj.getVisions() != null && treeObj.getVisions().size() == 1) {
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("treeObjJsonStr", SimpleUtils.toB64(objectMapper.writeValueAsString(treeObj)));
dataMap.put("resultObjJsonStr", SimpleUtils.toB64(objectMapper.writeValueAsString(resultObj)));
String jsonData = objectMapper.writeValueAsString(dataMap);
this.uploadOid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, jsonData.getBytes(), SimpleUtils.getUUIDStr() + ".json");
}
// ------------------------------------------------------------------
}
use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.
the class RegionMapRelationKpisAction method renderTableContent.
private void renderTableContent() throws ControllerException, AuthorityException, ServiceException, Exception {
String year = this.getFields().get("year");
String orgId = this.getFields().get("orgId");
List<String> visionOids = this.visionService.findForOidByKpiOrga(orgId);
if (visionOids == null || visionOids.size() < 1) {
this.message = SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA) + " , for KPIs.";
return;
}
for (String visionOid : visionOids) {
Context context = this.getChainContext(visionOid, year);
SimpleChain chain = new SimpleChain();
chain.getResultFromResource("performanceScoreChain", context);
if (context.get("treeObj") == null) {
continue;
}
BscStructTreeObj treeObj = (BscStructTreeObj) context.get("treeObj");
this.fillRelationKpis(treeObj);
this.fillCharts(treeObj);
}
this.success = IS_YES;
}
use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.
the class OrganizationReportExcelCommand method createExcel.
private String createExcel(Context context) throws Exception {
String visionOid = (String) context.get("visionOid");
VisionVO vision = null;
BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
for (VisionVO visionObj : treeObj.getVisions()) {
if (visionObj.getOid().equals(visionOid)) {
vision = visionObj;
}
}
BscReportPropertyUtils.loadData();
String fileName = SimpleUtils.getUUIDStr() + ".xlsx";
String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
int row = 0;
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sh = wb.createSheet();
row += this.createHead(wb, sh, row, vision, context);
row = this.createMainBody(wb, sh, row, vision);
this.putSignature(wb, sh, row + 1, context);
FileOutputStream out = new FileOutputStream(fileFullPath);
wb.write(out);
out.close();
wb = null;
File file = new File(fileFullPath);
String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "department-report.xlsx");
file = null;
return oid;
}
Aggregations