Search in sources :

Example 41 with PerspectiveVO

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

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

the class ImportDataLogicServiceImpl method importPerspectivesCsv.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importPerspectivesCsv(String uploadOid) throws ServiceException, Exception {
    List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN002");
    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();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    for (int i = 0; i < csvResults.size(); i++) {
        int row = i + 1;
        Map<String, String> data = csvResults.get(i);
        String perId = data.get("PER_ID");
        String visId = data.get("VIS_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(perId)) {
            msg.append("row: " + row + " perspective-id is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(visId)) {
            msg.append("row: " + row + " vision-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;
        }
        paramMap.clear();
        paramMap.put("visId", visId);
        if (this.visionService.countByParams(paramMap) < 1) {
            throw new ServiceException("row: " + row + " vision is not found " + visId);
        }
        DefaultResult<VisionVO> visionResult = this.visionService.findForSimpleByVisId(visId);
        if (visionResult.getValue() == null) {
            throw new ServiceException(visionResult.getSystemMessage().getValue());
        }
        PerspectiveVO perspective = new PerspectiveVO();
        perspective.setPerId(perId);
        perspective.setVisId(visId);
        perspective.setName(name);
        perspective.setWeight(new BigDecimal(weight));
        perspective.setTarget(Float.valueOf(target));
        perspective.setMin(Float.valueOf(min));
        perspective.setDescription(description);
        paramMap.clear();
        paramMap.put("perId", perId);
        if (this.perspectiveService.countByParams(paramMap) > 0) {
            // update
            DefaultResult<PerspectiveVO> oldResult = this.perspectiveService.findByUK(perspective);
            perspective.setOid(oldResult.getValue().getOid());
            this.perspectiveLogicService.update(perspective, visionResult.getValue().getOid());
        } else {
            // insert
            this.perspectiveLogicService.create(perspective, visionResult.getValue().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) HashMap(java.util.HashMap) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) 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 43 with PerspectiveVO

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

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

Example 45 with PerspectiveVO

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

the class HistoryItemScoreReportContentQueryUtils method getLineChartData.

public static List<Map<String, Object>> getLineChartData(String itemType, String frequency, String dateVal, String orgId, String empId) throws ServiceException, Exception {
    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
    Map<String, List<MonitorItemScoreVO>> itemScoreDataMap = monitorItemScoreService.getHistoryDataList(itemType, frequency, dateVal, orgId, empId);
    if (itemScoreDataMap == null || itemScoreDataMap.size() < 1) {
        return dataList;
    }
    List<VisionVO> basicDataList = getBasicDataList();
    for (Map.Entry<String, List<MonitorItemScoreVO>> entry : itemScoreDataMap.entrySet()) {
        String name = "";
        String id = entry.getKey();
        List<MonitorItemScoreVO> scoreList = entry.getValue();
        if (scoreList == null || scoreList.size() < 1) {
            continue;
        }
        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);
        }
        if (StringUtils.isBlank(name)) {
            throw new ServiceException("Name not found!");
        }
        Map<String, Object> chartDataMap = new HashMap<String, Object>();
        chartDataMap.put("name", name);
        chartDataMap.put("data", new LinkedList<Float>());
        for (MonitorItemScoreVO itemScore : scoreList) {
            ((List<Float>) chartDataMap.get("data")).add(Float.valueOf(itemScore.getScore()));
        }
        dataList.add(chartDataMap);
    }
    return dataList;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) MonitorItemScoreVO(com.netsteadfast.greenstep.vo.MonitorItemScoreVO)

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