Search in sources :

Example 36 with ObjectiveVO

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

the class PersonalAndOrganizationReportDateRangeScoreCommand method execute.

@SuppressWarnings("unchecked")
@Override
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    float total = 0.0f;
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    String year = StringUtils.defaultString((String) context.get("startYearDate")).trim();
    String dateType = StringUtils.defaultString((String) context.get("dateType")).trim();
    for (VisionVO vision : treeObj.getVisions()) {
        for (PerspectiveVO perspective : vision.getPerspectives()) {
            for (ObjectiveVO objective : perspective.getObjectives()) {
                for (KpiVO kpi : objective.getKpis()) {
                    this.setDateRangeScore(kpi, dateType, year);
                    // 只有一筆資料
                    total = total + kpi.getDateRangeScores().get(0).getScore();
                }
            }
        }
    }
    context.put("total", total);
    return false;
}
Also used : 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) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Example 37 with ObjectiveVO

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

the class ImportDataLogicServiceImpl method importKPIsCsv.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importKPIsCsv(String uploadOid) throws ServiceException, Exception {
    List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN004");
    if (csvResults.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST));
    }
    List<String> organizationOids = new ArrayList<String>();
    List<String> employeeOids = new ArrayList<String>();
    boolean success = false;
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    StringBuilder msg = new StringBuilder();
    // import mode cannot update KPI's attachment/documents, because KPI export no attachment/documents data.
    List<String> kpiAttacDocs = new ArrayList<String>();
    for (int i = 0; i < csvResults.size(); i++) {
        int row = i + 1;
        Map<String, String> data = csvResults.get(i);
        String id = data.get("ID");
        String objId = data.get("OBJ_ID");
        String name = data.get("NAME");
        String weight = data.get("WEIGHT");
        String target = data.get("TARGET");
        String min = data.get("MIN");
        String unit = data.get("UNIT");
        String forId = data.get("FOR_ID");
        String management = data.get("MANAGEMENT");
        String compareType = data.get("COMPARE_TYPE");
        String cal = data.get("CAL");
        String dataType = data.get("DATA_TYPE");
        String orgaMeasureSeparate = data.get("ORGA_MEASURE_SEPARATE");
        String userMeasureSeparate = data.get("USER_MEASURE_SEPARATE");
        String quasiRange = data.get("QUASI_RANGE");
        String description = data.get("DESCRIPTION");
        String max = data.get("MAX");
        String trendsForId = data.get("TRENDS_FOR_ID");
        String activate = data.get("ACTIVATE");
        String errMsg = this.checkKPIsDataError(row, id, objId, name, weight, target, min, unit, forId, management, compareType, cal, dataType, orgaMeasureSeparate, userMeasureSeparate, quasiRange, description, max);
        if (!"".equals(errMsg)) {
            msg.append(errMsg);
            continue;
        }
        ObjectiveVO objective = new ObjectiveVO();
        objective.setObjId(objId);
        DefaultResult<ObjectiveVO> objResult = this.objectiveService.findByUK(objective);
        if (objResult.getValue() == null) {
            throw new ServiceException("row: " + row + " strategy-objectives is not found " + objId);
        }
        objective = objResult.getValue();
        /*
			FormulaVO formula = new FormulaVO();
			formula.setForId(forId);
			DefaultResult<FormulaVO> forResult = this.formulaService.findByUK(formula);
			if ( forResult.getValue() == null ) {
				throw new ServiceException( "row: " + row + " formula is not found " + objId );
			}
			formula = forResult.getValue();
			*/
        KpiVO kpi = new KpiVO();
        kpi.setId(id);
        kpi.setName(name);
        kpi.setWeight(new BigDecimal(weight));
        kpi.setMax(Float.valueOf(max));
        kpi.setTarget(Float.valueOf(target));
        kpi.setMin(Float.valueOf(min));
        kpi.setCompareType(compareType);
        kpi.setUnit(unit);
        kpi.setManagement(management);
        kpi.setQuasiRange(Integer.parseInt(quasiRange));
        kpi.setDataType(dataType);
        kpi.setDescription(description);
        kpi.setOrgaMeasureSeparate(YesNo.NO);
        kpi.setUserMeasureSeparate(YesNo.NO);
        kpi.setActivate(YesNo.NO);
        if (YesNo.YES.equals(orgaMeasureSeparate) || YesNo.YES.equals(userMeasureSeparate)) {
            msg.append("row: " + row + " import mode no support organization/personal measure separate data. please manual settings." + Constants.HTML_BR);
        }
        if (YesNo.YES.equals(activate)) {
            kpi.setActivate(YesNo.YES);
        }
        DefaultResult<KpiVO> kResult = this.kpiService.findByUK(kpi);
        if (kResult.getValue() != null) {
            // update
            kpi.setOid(kResult.getValue().getOid());
            this.kpiLogicService.update(kpi, objective.getOid(), BscFormulaUtils.getFormulaById(forId).getOid(), AggregationMethodUtils.findSimpleById(cal).getOid(), organizationOids, employeeOids, BscFormulaUtils.getFormulaById(trendsForId).getOid(), kpiAttacDocs);
        } else {
            // insert
            this.kpiLogicService.create(kpi, objective.getOid(), BscFormulaUtils.getFormulaById(forId).getOid(), AggregationMethodUtils.findSimpleById(cal).getOid(), organizationOids, employeeOids, BscFormulaUtils.getFormulaById(trendsForId).getOid(), kpiAttacDocs);
        }
        success = true;
    }
    if (msg.length() > 0) {
        result.setSystemMessage(new SystemMessage(msg.toString()));
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    }
    result.setValue(success);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) ArrayList(java.util.ArrayList) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) BigDecimal(java.math.BigDecimal) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Map(java.util.Map) HashMap(java.util.HashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 38 with ObjectiveVO

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

the class ImportDataLogicServiceImpl method importObjectivesCsv.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importObjectivesCsv(String uploadOid) throws ServiceException, Exception {
    List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN003");
    if (csvResults.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST));
    }
    boolean success = false;
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    StringBuilder msg = new StringBuilder();
    for (int i = 0; i < csvResults.size(); i++) {
        int row = i + 1;
        Map<String, String> data = csvResults.get(i);
        String objId = data.get("OBJ_ID");
        String perId = data.get("PER_ID");
        String name = data.get("NAME");
        String weight = data.get("WEIGHT");
        String target = data.get("TARGET");
        String min = data.get("MIN");
        String description = data.get("DESCRIPTION");
        if (super.isBlank(objId)) {
            msg.append("row: " + row + " objective-id is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(perId)) {
            msg.append("row: " + row + " perspective-id is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(name)) {
            msg.append("row: " + row + " name is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(weight)) {
            msg.append("row: " + row + " weight is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(target)) {
            msg.append("row: " + row + " target is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(min)) {
            msg.append("row: " + row + " min is blank." + Constants.HTML_BR);
            continue;
        }
        if (!NumberUtils.isNumber(weight)) {
            msg.append("row: " + row + " weight is not number." + Constants.HTML_BR);
            continue;
        }
        if (!NumberUtils.isNumber(target)) {
            msg.append("row: " + row + " target is not number." + Constants.HTML_BR);
            continue;
        }
        if (!NumberUtils.isNumber(min)) {
            msg.append("row: " + row + " min is not number." + Constants.HTML_BR);
            continue;
        }
        PerspectiveVO perspective = new PerspectiveVO();
        perspective.setPerId(perId);
        DefaultResult<PerspectiveVO> perResult = this.perspectiveService.findByUK(perspective);
        if (perResult.getValue() == null) {
            throw new ServiceException("row: " + row + " perspective is not found " + perId);
        }
        perspective = perResult.getValue();
        ObjectiveVO objective = new ObjectiveVO();
        objective.setObjId(objId);
        DefaultResult<ObjectiveVO> oldResult = this.objectiveService.findByUK(objective);
        objective.setObjId(objId);
        objective.setPerId(perId);
        objective.setName(name);
        objective.setWeight(new BigDecimal(weight));
        objective.setTarget(Float.valueOf(target));
        objective.setMin(Float.valueOf(min));
        objective.setDescription(description);
        if (oldResult.getValue() != null) {
            // update
            objective.setOid(oldResult.getValue().getOid());
            this.objectiveLogicService.update(objective, perspective.getOid());
        } else {
            // insert
            this.objectiveLogicService.create(objective, perspective.getOid());
        }
        success = true;
    }
    if (msg.length() > 0) {
        result.setSystemMessage(new SystemMessage(msg.toString()));
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    }
    result.setValue(success);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) BigDecimal(java.math.BigDecimal) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Map(java.util.Map) HashMap(java.util.HashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 39 with ObjectiveVO

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

the class KpiLogicServiceImpl method handlerDataForCreateOrUpdate.

private void handlerDataForCreateOrUpdate(KpiVO kpi, String objectiveOid, String formulaOid, String aggrOid, String trendsFormulaOid) throws ServiceException, Exception {
    ObjectiveVO objective = new ObjectiveVO();
    objective.setOid(objectiveOid);
    DefaultResult<ObjectiveVO> objResult = this.objectiveService.findObjectByOid(objective);
    if (objResult.getValue() == null) {
        throw new ServiceException(objResult.getSystemMessage().getValue());
    }
    objective = objResult.getValue();
    kpi.setObjId(objective.getObjId());
    kpi.setForId(this.fetchFormulaByOid(formulaOid).getForId());
    kpi.setTrendsForId(this.fetchFormulaByOid(trendsFormulaOid).getForId());
    kpi.setCal(AggregationMethodUtils.findSimpleByOid(aggrOid).getAggrId());
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO)

Example 40 with ObjectiveVO

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

the class HistoryItemScoreReportContentQueryUtils method fill2ValueObjectList.

public static List<MonitorItemScoreVO> fill2ValueObjectList(List<BbMonitorItemScore> monitorItemScores) throws ServiceException, Exception {
    List<MonitorItemScoreVO> results = new ArrayList<MonitorItemScoreVO>();
    if (null == monitorItemScores) {
        return results;
    }
    List<VisionVO> basicDataList = getBasicDataList();
    for (BbMonitorItemScore monitorScoreSrc : monitorItemScores) {
        MonitorItemScoreVO monitorScoreDest = new MonitorItemScoreVO();
        monitorItemScoreService.doMapper(monitorScoreSrc, monitorScoreDest, IMonitorItemScoreService.MAPPER_ID_PO2VO);
        String id = monitorScoreSrc.getItemId();
        String name = "";
        String itemType = monitorScoreSrc.getItemType();
        if (MonitorItemType.VISION.equals(itemType)) {
            DefaultResult<VisionVO> visionResult = visionService.findForSimpleByVisId(id);
            if (visionResult.getValue() == null) {
                throw new ServiceException(visionResult.getSystemMessage().getValue());
            }
            VisionVO vision = visionResult.getValue();
            name = getItemNameWithVisionGroup(MonitorItemType.VISION, vision.getVisId(), vision.getTitle(), basicDataList);
        }
        if (MonitorItemType.PERSPECTIVES.equals(itemType)) {
            PerspectiveVO perspective = new PerspectiveVO();
            perspective.setPerId(id);
            DefaultResult<PerspectiveVO> perspectiveResult = perspectiveService.findByUK(perspective);
            if (perspectiveResult.getValue() == null) {
                throw new ServiceException(perspectiveResult.getSystemMessage().getValue());
            }
            perspective = perspectiveResult.getValue();
            name = getItemNameWithVisionGroup(MonitorItemType.PERSPECTIVES, perspective.getPerId(), perspective.getName(), basicDataList);
        }
        if (MonitorItemType.STRATEGY_OF_OBJECTIVES.equals(itemType)) {
            ObjectiveVO objective = new ObjectiveVO();
            objective.setObjId(id);
            DefaultResult<ObjectiveVO> objectiveResult = objectiveService.findByUK(objective);
            if (objectiveResult.getValue() == null) {
                throw new ServiceException(objectiveResult.getSystemMessage().getValue());
            }
            objective = objectiveResult.getValue();
            name = getItemNameWithVisionGroup(MonitorItemType.STRATEGY_OF_OBJECTIVES, objective.getObjId(), objective.getName(), basicDataList);
        }
        if (MonitorItemType.KPI.equals(itemType)) {
            KpiVO kpi = new KpiVO();
            kpi.setId(id);
            DefaultResult<KpiVO> kpiResult = kpiService.findByUK(kpi);
            if (kpiResult.getValue() == null) {
                throw new ServiceException(kpiResult.getSystemMessage().getValue());
            }
            kpi = kpiResult.getValue();
            name = getItemNameWithVisionGroup(MonitorItemType.KPI, kpi.getId(), kpi.getName(), basicDataList);
        }
        monitorScoreDest.setName(name);
        monitorScoreDest.setOrganizationName(monitorScoreSrc.getOrgId());
        monitorScoreDest.setEmployeeName(monitorScoreSrc.getEmpId());
        if (!BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(monitorScoreSrc.getOrgId())) {
            OrganizationVO organization = BscBaseLogicServiceCommonSupport.findOrganizationDataByUK(organizationService, monitorScoreSrc.getOrgId());
            monitorScoreDest.setOrganizationName(monitorScoreSrc.getOrgId() + " - " + organization.getName());
        }
        if (!BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(monitorScoreSrc.getEmpId())) {
            EmployeeVO employee = BscBaseLogicServiceCommonSupport.findEmployeeDataByEmpId(employeeService, monitorScoreSrc.getEmpId());
            monitorScoreDest.setEmployeeName(monitorScoreSrc.getEmpId() + " - " + employee.getFullName());
        }
        results.add(monitorScoreDest);
    }
    return results;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) ArrayList(java.util.ArrayList) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) BbMonitorItemScore(com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) MonitorItemScoreVO(com.netsteadfast.greenstep.vo.MonitorItemScoreVO)

Aggregations

ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)50 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)44 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)34 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)29 HashMap (java.util.HashMap)15 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)13 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)8 DateRangeScoreVO (com.netsteadfast.greenstep.vo.DateRangeScoreVO)8 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 LinkedList (java.util.LinkedList)6 Phrase (com.itextpdf.text.Phrase)4 PdfPCell (com.itextpdf.text.pdf.PdfPCell)4 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)4 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)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 XSSFColor (org.apache.poi.xssf.usermodel.XSSFColor)4