Search in sources :

Example 16 with PerspectiveVO

use of com.netsteadfast.greenstep.vo.PerspectiveVO in project bamboobsc by billchen198318.

the class PersonalReportExcelCommand method createMainBody.

private int createMainBody(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision, Context context) throws Exception {
    int mrRow = row;
    XSSFCellStyle cellStyle = wb.createCellStyle();
    cellStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#ffffff")));
    cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    XSSFFont cellFont = wb.createFont();
    cellFont.setBold(false);
    cellFont.setColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#000000")));
    cellStyle.setFont(cellFont);
    cellStyle.setWrapText(true);
    cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellStyle.setBorderBottom(BorderStyle.THIN);
    cellStyle.setBorderTop(BorderStyle.THIN);
    cellStyle.setBorderRight(BorderStyle.THIN);
    cellStyle.setBorderLeft(BorderStyle.THIN);
    cellStyle.setWrapText(true);
    for (PerspectiveVO perspective : vision.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            for (KpiVO kpi : objective.getKpis()) {
                int kCol = 0;
                Row contentRow = sh.createRow(row++);
                contentRow.setHeight((short) 1000);
                Cell contentCell1 = contentRow.createCell(kCol++);
                contentCell1.setCellValue(objective.getName());
                contentCell1.setCellStyle(cellStyle);
                Cell contentCell2 = contentRow.createCell(kCol++);
                contentCell2.setCellValue(kpi.getName());
                contentCell2.setCellStyle(cellStyle);
                Cell contentCell3 = contentRow.createCell(kCol++);
                contentCell3.setCellValue("max: " + kpi.getMax() + "\n" + "target: " + kpi.getTarget() + "\n" + "min: " + kpi.getMin() + "\n" + "unit: " + kpi.getUnit());
                contentCell3.setCellStyle(cellStyle);
                Cell contentCell4 = contentRow.createCell(kCol++);
                contentCell4.setCellValue(kpi.getWeight() + "%");
                contentCell4.setCellStyle(cellStyle);
                Cell contentCell5 = contentRow.createCell(kCol++);
                contentCell5.setCellValue(kpi.getFormula().getName());
                contentCell5.setCellStyle(cellStyle);
                // 只顯示一筆日期分數資料
                DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(0);
                XSSFCellStyle cellStyleScore = wb.createCellStyle();
                cellStyleScore.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getBgColor())));
                cellStyleScore.setFillPattern(FillPatternType.SOLID_FOREGROUND);
                XSSFFont cellScoreFont = wb.createFont();
                cellScoreFont.setBold(false);
                cellScoreFont.setColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getFontColor())));
                cellStyleScore.setFont(cellScoreFont);
                cellStyleScore.setWrapText(true);
                cellStyleScore.setVerticalAlignment(VerticalAlignment.CENTER);
                cellStyleScore.setBorderBottom(BorderStyle.THIN);
                cellStyleScore.setBorderTop(BorderStyle.THIN);
                cellStyleScore.setBorderRight(BorderStyle.THIN);
                cellStyleScore.setBorderLeft(BorderStyle.THIN);
                Cell contentCell6 = contentRow.createCell(kCol++);
                contentCell6.setCellValue(BscReportSupportUtils.parse2(dateRangeScore.getScore()));
                contentCell6.setCellStyle(cellStyleScore);
            }
        }
    }
    for (PerspectiveVO perspective : vision.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            int rowspan = objective.getRow();
            if (objective.getRow() > 1) {
                // 2016-12-13 old work with POI 3.12
                //sh.addMergedRegion(new CellRangeAddress(mrRow, mrRow+rowspan-1, 0, 0));
                // 2016-12-13 new work with POI 3.15
                int mrRow1 = mrRow + rowspan - 1;
                if (mrRow1 > mrRow) {
                    sh.addMergedRegion(new CellRangeAddress(mrRow, mrRow1, 0, 0));
                }
            }
            mrRow += rowspan;
        }
    }
    return row;
}
Also used : XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor) XSSFCellStyle(org.apache.poi.xssf.usermodel.XSSFCellStyle) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) XSSFFont(org.apache.poi.xssf.usermodel.XSSFFont) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) DateRangeScoreVO(com.netsteadfast.greenstep.vo.DateRangeScoreVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) Row(org.apache.poi.ss.usermodel.Row) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) Cell(org.apache.poi.ss.usermodel.Cell)

Example 17 with PerspectiveVO

use of com.netsteadfast.greenstep.vo.PerspectiveVO in project bamboobsc by billchen198318.

the class KpiReportPdfCommand method createDateRange.

private void createDateRange(PdfPTable table, VisionVO vision, Context context, int maxRows) throws Exception {
    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();
    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 + "/01/01";
        date2 = endYearDate + "/12/" + SimpleUtils.getMaxDayOfMonth(Integer.parseInt(endYearDate), 12);
    }
    Map<String, Object> headContentMap = new HashMap<String, Object>();
    this.fillHeadContent(context, headContentMap);
    String content = "Frequency: " + BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) + " Date range: " + date1 + " ~ " + date2 + "\n" + StringUtils.defaultString((String) headContentMap.get("headContent"));
    PdfPCell cell = null;
    cell = new PdfPCell();
    cell.addElement(new Phrase(content, this.getFont(BscReportPropertyUtils.getFontColor(), false)));
    this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor());
    cell.setColspan(maxRows);
    table.addCell(cell);
    for (PerspectiveVO perspective : vision.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            for (KpiVO kpi : objective.getKpis()) {
                cell = new PdfPCell();
                cell.addElement(new Phrase(kpi.getName(), this.getFont(kpi.getFontColor(), false)));
                this.setCellBackgroundColor(cell, kpi.getBgColor());
                cell.setColspan(4);
                cell.setRowspan(2);
                table.addCell(cell);
                for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) {
                    cell = new PdfPCell();
                    cell.addElement(new Phrase(dateScore.getDate(), this.getFont(dateScore.getFontColor(), false)));
                    this.setCellBackgroundColor(cell, dateScore.getBgColor());
                    table.addCell(cell);
                }
                for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) {
                    Image image = Image.getInstance(BscReportSupportUtils.getByteIcon(kpi, dateScore.getScore()));
                    image.setWidthPercentage(20f);
                    cell = new PdfPCell();
                    cell.addElement(new Phrase(BscReportSupportUtils.parse2(dateScore.getScore()), this.getFont(dateScore.getFontColor(), false)));
                    cell.addElement(image);
                    this.setCellBackgroundColor(cell, dateScore.getBgColor());
                    table.addCell(cell);
                }
            }
        }
    }
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) HashMap(java.util.HashMap) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) DateRangeScoreVO(com.netsteadfast.greenstep.vo.DateRangeScoreVO) Phrase(com.itextpdf.text.Phrase) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) BufferedImage(java.awt.image.BufferedImage) Image(com.itextpdf.text.Image)

Example 18 with PerspectiveVO

use of com.netsteadfast.greenstep.vo.PerspectiveVO in project bamboobsc by billchen198318.

the class LoadStrategyMapItemsForNewCommand method fillStrategyMapItems.

private StrategyMapItemsVO fillStrategyMapItems(VisionVO vision) throws Exception {
    StrategyMapItemsVO mapItems = new StrategyMapItemsVO();
    int w = 190;
    int top = 10;
    for (PerspectiveVO perspective : vision.getPerspectives()) {
        int left = 10;
        for (ObjectiveVO objective : perspective.getObjectives()) {
            String idName = objective.getObjId();
            /**
				 * 1em = 16px
				 * 
				 * <div class="w" id="phone1">PHONE INTERVIEW 1<div class="ep"></div></div>
				 * #phone1 { left:35em; top:12em; width:7em; }
				 * 
				 */
            String div = "<div class=\"w\" id=\"" + idName + "\">" + objective.getName() + "<div class=\"ep\"></div></div>";
            String css = "#" + idName + " { left:" + left + "px; top:" + top + "px; width:" + w + "px; }";
            mapItems.getDiv().add(div);
            mapItems.getCss().add(css);
            left += (w + 80);
        }
        top += 120;
    }
    return mapItems;
}
Also used : StrategyMapItemsVO(com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO)

Example 19 with PerspectiveVO

use of com.netsteadfast.greenstep.vo.PerspectiveVO in project bamboobsc by billchen198318.

the class WeightLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> update(List<PerspectiveVO> perspectives, List<ObjectiveVO> objectives, List<KpiVO> kpis) throws ServiceException, Exception {
    if (perspectives == null || perspectives.size() < 1 || objectives == null || objectives.size() < 1 || kpis == null || kpis.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    for (PerspectiveVO perspective : perspectives) {
        BbPerspective entity = this.perspectiveService.findByPKng(perspective.getOid());
        entity.setWeight(perspective.getWeight());
        this.perspectiveService.update(entity);
    }
    for (ObjectiveVO objective : objectives) {
        BbObjective entity = this.objectiveService.findByPKng(objective.getOid());
        entity.setWeight(objective.getWeight());
        this.objectiveService.update(entity);
    }
    for (KpiVO kpi : kpis) {
        BbKpi entity = this.kpiService.findByPKng(kpi.getOid());
        entity.setWeight(kpi.getWeight());
        this.kpiService.update(entity);
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    result.setValue(Boolean.TRUE);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) BbObjective(com.netsteadfast.greenstep.po.hbm.BbObjective) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) BbPerspective(com.netsteadfast.greenstep.po.hbm.BbPerspective) BbKpi(com.netsteadfast.greenstep.po.hbm.BbKpi) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 20 with PerspectiveVO

use of com.netsteadfast.greenstep.vo.PerspectiveVO 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)

Aggregations

PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)58 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)44 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)38 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)33 HashMap (java.util.HashMap)17 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)15 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)8 DateRangeScoreVO (com.netsteadfast.greenstep.vo.DateRangeScoreVO)8 LinkedList (java.util.LinkedList)8 Map (java.util.Map)8 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)6 ArrayList (java.util.ArrayList)6 Transactional (org.springframework.transaction.annotation.Transactional)6 Phrase (com.itextpdf.text.Phrase)4 PdfPCell (com.itextpdf.text.pdf.PdfPCell)4 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)4 Cell (org.apache.poi.ss.usermodel.Cell)4 Row (org.apache.poi.ss.usermodel.Row)4 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)4 XSSFCellStyle (org.apache.poi.xssf.usermodel.XSSFCellStyle)4