Search in sources :

Example 6 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.

the class LoadMeasureDataCommand method execute.

@SuppressWarnings("unchecked")
@Override
public boolean execute(Context context) throws Exception {
    measureDataService = (IMeasureDataService<MeasureDataVO, BbMeasureData, String>) AppContext.getBean("bsc.service.MeasureDataService");
    String frequency = (String) context.get("frequency");
    String startYearDate = StringUtils.defaultString((String) context.get("startYearDate")).trim();
    String endYearDate = StringUtils.defaultString((String) context.get("endYearDate")).trim();
    String startDate = StringUtils.defaultString((String) context.get("startDate")).trim();
    String endDate = StringUtils.defaultString((String) context.get("endDate")).trim();
    startDate = startDate.replaceAll("/", "").replaceAll("-", "");
    endDate = endDate.replaceAll("/", "").replaceAll("-", "");
    String date1 = startDate;
    String date2 = endDate;
    if (BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency)) {
        date1 = startYearDate + "0101";
        date2 = endYearDate + "12" + SimpleUtils.getMaxDayOfMonth(Integer.parseInt(endYearDate), 12);
    }
    String measureDataOrgaId = (String) context.get("orgId");
    String measureDataEmplId = (String) context.get("empId");
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    for (VisionVO vision : treeObj.getVisions()) {
        for (PerspectiveVO perspective : vision.getPerspectives()) {
            for (ObjectiveVO objective : perspective.getObjectives()) {
                for (KpiVO kpi : objective.getKpis()) {
                    this.fillMeasureData(kpi, frequency, date1, date2, measureDataOrgaId, measureDataEmplId);
                }
            }
        }
    }
    return false;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) BbMeasureData(com.netsteadfast.greenstep.po.hbm.BbMeasureData) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) MeasureDataVO(com.netsteadfast.greenstep.vo.MeasureDataVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Example 7 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.

the class PersonalReportExcelCommand 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, context);
    this.createFoot(wb, sh, row, vision, context);
    this.putSignature(wb, sh, row + 2, 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, "personal-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)

Example 8 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.

the class KpiReportPdfCommand method createPdf.

private String createPdf(Context context) throws Exception {
    BscReportPropertyUtils.loadData();
    // 2015-04-18 add
    BscReportSupportUtils.loadExpression();
    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;
        }
    }
    FontFactory.register(BscConstants.PDF_ITEXT_FONT);
    String fileName = UUID.randomUUID().toString() + ".pdf";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    OutputStream os = new FileOutputStream(fileFullPath);
    //Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    Document document = new Document(PageSize.A4, 10, 10, 10, 10);
    document.left(100f);
    document.top(150f);
    PdfWriter writer = PdfWriter.getInstance(document, os);
    document.open();
    int dateRangeRows = 4 + vision.getPerspectives().get(0).getObjectives().get(0).getKpis().get(0).getDateRangeScores().size();
    PdfPTable table = new PdfPTable(MAX_COLSPAN);
    PdfPTable dateRangeTable = new PdfPTable(dateRangeRows);
    PdfPTable chartsTable = new PdfPTable(2);
    PdfPTable signTable = new PdfPTable(1);
    table.setWidthPercentage(100f);
    dateRangeTable.setWidthPercentage(100f);
    chartsTable.setWidthPercentage(100f);
    signTable.setWidthPercentage(100f);
    this.createHead(table, vision);
    this.createBody(table, vision);
    this.createDateRange(dateRangeTable, vision, context, dateRangeRows);
    this.putCharts(chartsTable, context);
    this.putSignature(signTable, context);
    document.add(chartsTable);
    document.add(table);
    document.add(dateRangeTable);
    document.add(signTable);
    document.close();
    writer.close();
    os.flush();
    os.close();
    os = null;
    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "kpi-report.pdf");
    file = null;
    return oid;
}
Also used : PdfWriter(com.itextpdf.text.pdf.PdfWriter) PdfPTable(com.itextpdf.text.pdf.PdfPTable) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) Document(com.itextpdf.text.Document) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) File(java.io.File)

Example 9 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.

the class BscMobileCardUtils method getVisionCard.

public static List<VisionVO> getVisionCard(String frequency, String startDate, String endDate) throws ServiceException, Exception {
    List<VisionVO> visionScores = new ArrayList<VisionVO>();
    Map<String, String> visions = visionService.findForMap(false);
    if (null == visions || visions.size() < 1) {
        return visionScores;
    }
    Context context = new ContextBase();
    context.put("startDate", startDate);
    context.put("endDate", endDate);
    context.put("startYearDate", startDate.substring(0, 4));
    context.put("endYearDate", endDate.substring(0, 4));
    context.put("frequency", frequency);
    context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ALL);
    context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
    context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
    for (Map.Entry<String, String> entry : visions.entrySet()) {
        String visionOid = entry.getKey();
        context.put("visionOid", visionOid);
        SimpleChain chain = new SimpleChain();
        ChainResultObj resultObj = chain.getResultFromResource("performanceScoreChain", context);
        BscStructTreeObj treeObj = (BscStructTreeObj) resultObj.getValue();
        for (int i = 0; treeObj.getVisions() != null && i < treeObj.getVisions().size(); i++) {
            VisionVO vision = treeObj.getVisions().get(i);
            vision.setContent(" ".getBytes());
            DefaultResult<VisionVO> vResult = visionService.findObjectByOid(vision);
            if (vResult.getValue() != null) {
                // 計算分數chain 取出的vision資料沒有放 content 欄位, 但這邊要用到, 所以取出content欄位
                vision.setContent(new String(vResult.getValue().getContent(), Constants.BASE_ENCODING).getBytes());
            }
            for (PerspectiveVO perspective : vision.getPerspectives()) {
                for (ObjectiveVO objective : perspective.getObjectives()) {
                    for (KpiVO kpi : objective.getKpis()) {
                        // 產生報表不需要以下欄位
                        kpi.getAggregationMethod().setDescription(" ");
                        kpi.getAggregationMethod().setExpression1(" ");
                        kpi.getAggregationMethod().setExpression2(" ");
                        kpi.getFormula().setExpression(" ");
                    }
                }
            }
            visionScores.add(vision);
        }
    }
    return visionScores;
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) ArrayList(java.util.ArrayList) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) HashMap(java.util.HashMap) Map(java.util.Map) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 10 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.

the class BscMobileCardUtils method getDashboardScore.

public static VisionVO getDashboardScore(String visionOid, String frequency, String startDate, String endDate) throws ServiceException, Exception {
    String startYear = "";
    String endYear = "";
    if (BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency)) {
        startYear = startDate.substring(0, 4);
        endYear = endDate.substring(0, 4);
    }
    ChainResultObj result = PerformanceScoreChainUtils.getResult(visionOid, startDate, endDate, startYear, endYear, frequency, BscConstants.MEASURE_DATA_FOR_ALL, "", "");
    if (result.getValue() == null || ((BscStructTreeObj) result.getValue()).getVisions() == null || ((BscStructTreeObj) result.getValue()).getVisions().size() == 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    BscStructTreeObj resultObj = (BscStructTreeObj) result.getValue();
    VisionVO visionObj = resultObj.getVisions().get(0);
    return visionObj;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

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