Search in sources :

Example 1 with MonitorItemScoreVO

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

the class HistoryItemScoreNoticeHandler method createContent.

private void createContent(List<BbMonitorItemScore> monitorItemScoresSrc, StringBuilder out) throws ServiceException, Exception {
    // create mail content
    List<MonitorItemScoreVO> monitorItemScores = HistoryItemScoreReportContentQueryUtils.fill2ValueObjectList(monitorItemScoresSrc);
    BscScoreColorUtils.loadScoreColors();
    for (MonitorItemScoreVO itemScore : monitorItemScores) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("title", itemScore.getName());
        paramMap.put("date", SimpleUtils.getStrYMD(itemScore.getDateVal(), "/"));
        paramMap.put("frequency", BscMeasureDataFrequency.getFrequencyMap(false).get(frequency));
        paramMap.put("score", itemScore.getScore());
        paramMap.put("organization", itemScore.getOrganizationName());
        paramMap.put("employee", itemScore.getEmployeeName());
        paramMap.put("bgColor", BscScoreColorUtils.getBackgroundColor(Float.parseFloat(itemScore.getScore())));
        paramMap.put("fnColor", BscScoreColorUtils.getFontColor(Float.parseFloat(itemScore.getScore())));
        TemplateResultObj result = TemplateUtils.getResult(TemplateCode.TPLMSG0003, paramMap);
        if (result.getContent() != null) {
            out.append(result.getContent());
        }
    }
}
Also used : HashMap(java.util.HashMap) TemplateResultObj(com.netsteadfast.greenstep.model.TemplateResultObj) MonitorItemScoreVO(com.netsteadfast.greenstep.vo.MonitorItemScoreVO)

Example 2 with MonitorItemScoreVO

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

the class MonitorItemScoreServiceImpl method getHistoryDataList.

@Override
public Map<String, List<MonitorItemScoreVO>> getHistoryDataList(String itemType, String frequency, String dateVal, String orgId, String empId, int daysBeforeRange) throws ServiceException, Exception {
    if (StringUtils.isBlank(itemType) || StringUtils.isBlank(frequency) || StringUtils.isBlank(dateVal)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    if (!SimpleUtils.isDate(dateVal)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_INCORRECT));
    }
    if (daysBeforeRange > MAX_DAYS_BEFORE_RANGE || daysBeforeRange < 0) {
        throw new ServiceException("daysBeforeRange error!");
    }
    Date endDate = DateUtils.parseDate(dateVal, new String[] { "yyyyMMdd" });
    Date startDate = DateUtils.addDays(endDate, (daysBeforeRange * -1));
    String startDateStr = DateFormatUtils.format(startDate, "yyyyMMdd");
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("itemType", itemType);
    paramMap.put("frequency", frequency);
    paramMap.put("orgId", orgId);
    paramMap.put("empId", empId);
    Map<String, CustomeOperational> customeMap = new HashMap<String, CustomeOperational>();
    CustomeOperational op1 = new CustomeOperational();
    op1.setField("dateVal");
    op1.setOp(">=");
    op1.setValue(startDateStr);
    CustomeOperational op2 = new CustomeOperational();
    op2.setField("dateVal");
    op2.setOp("<=");
    op2.setValue(dateVal);
    customeMap.put("op1", op1);
    customeMap.put("op2", op2);
    List<BbMonitorItemScore> searchList = this.findListByParams2(paramMap, customeMap);
    if (null == searchList || searchList.size() < 1) {
        return null;
    }
    Map<String, List<MonitorItemScoreVO>> dataMap = new HashMap<String, List<MonitorItemScoreVO>>();
    List<String> idKeyList = new ArrayList<String>();
    for (BbMonitorItemScore data : searchList) {
        if (idKeyList.contains(data.getItemId())) {
            continue;
        }
        idKeyList.add(data.getItemId());
        dataMap.put(data.getItemId(), new LinkedList<MonitorItemScoreVO>());
    }
    for (int i = 0; i <= daysBeforeRange; i++) {
        Date currentDate = DateUtils.addDays(startDate, i);
        String currentDateStr = DateFormatUtils.format(currentDate, "yyyyMMdd");
        for (String id : idKeyList) {
            MonitorItemScoreVO scoreData = new MonitorItemScoreVO();
            scoreData.setItemType(itemType);
            scoreData.setItemId(id);
            scoreData.setFrequency(frequency);
            scoreData.setOrgId(orgId);
            scoreData.setEmpId(empId);
            scoreData.setDateVal(currentDateStr);
            // 如果沒有當天歷史分數資料的話, 預設就是"0"
            scoreData.setScore("0");
            for (BbMonitorItemScore data : searchList) {
                if (data.getItemId().equals(id) && data.getDateVal().equals(currentDateStr)) {
                    scoreData.setScore(data.getScore());
                }
            }
            dataMap.get(id).add(scoreData);
        }
    }
    return dataMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BbMonitorItemScore(com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore) CustomeOperational(com.netsteadfast.greenstep.base.model.CustomeOperational) Date(java.util.Date) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) MonitorItemScoreVO(com.netsteadfast.greenstep.vo.MonitorItemScoreVO)

Example 3 with MonitorItemScoreVO

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

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

Example 5 with MonitorItemScoreVO

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

the class PerformanceScoreChainUtils method getMonitorItemScore.

private static MonitorItemScoreVO getMonitorItemScore(String dateVal, String frequency, String orgId, String empId, String itemType, String itemId) throws ServiceException, Exception {
    MonitorItemScoreVO item = new MonitorItemScoreVO();
    item.setDateVal(dateVal);
    item.setEmpId(empId);
    item.setFrequency(frequency);
    item.setItemId(itemId);
    item.setItemType(itemType);
    item.setOrgId(orgId);
    DefaultResult<MonitorItemScoreVO> result = monitorItemScoreService.findByUK(item);
    if (result.getValue() == null) {
        return item;
    }
    item = result.getValue();
    return item;
}
Also used : MonitorItemScoreVO(com.netsteadfast.greenstep.vo.MonitorItemScoreVO)

Aggregations

MonitorItemScoreVO (com.netsteadfast.greenstep.vo.MonitorItemScoreVO)6 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)3 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)3 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)3 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 BbMonitorItemScore (com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)1 CustomeOperational (com.netsteadfast.greenstep.base.model.CustomeOperational)1 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1 TemplateResultObj (com.netsteadfast.greenstep.model.TemplateResultObj)1 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)1 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)1 Date (java.util.Date)1 Map (java.util.Map)1