Search in sources :

Example 1 with BscStructTreeObj

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;
}
Also used : HashMap(java.util.HashMap) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) HashMap(java.util.HashMap) Map(java.util.Map) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) LinkedList(java.util.LinkedList)

Example 2 with BscStructTreeObj

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);
}
Also used : BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with BscStructTreeObj

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");
    }
// ------------------------------------------------------------------
}
Also used : Context(org.apache.commons.chain.Context) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with BscStructTreeObj

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;
}
Also used : Context(org.apache.commons.chain.Context) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain)

Example 5 with BscStructTreeObj

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;
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) FileOutputStream(java.io.FileOutputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) File(java.io.File)

Aggregations

BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)28 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)17 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)8 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)8 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)8 HashMap (java.util.HashMap)8 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)7 File (java.io.File)6 FileOutputStream (java.io.FileOutputStream)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Document (com.itextpdf.text.Document)3 PdfPTable (com.itextpdf.text.pdf.PdfPTable)3 PdfWriter (com.itextpdf.text.pdf.PdfWriter)3 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)3 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 OutputStream (java.io.OutputStream)3 Context (org.apache.commons.chain.Context)3 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)3 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)3 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)2