Search in sources :

Example 1 with BbMonitorItemScore

use of com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore in project bamboobsc by billchen198318.

the class HistoryItemScoreNoticeHandler method action.

public void action() throws ServiceException, Exception {
    if (toMail.size() < 1) {
        return;
    }
    if (!MailClientUtils.getEnable()) {
        logger.warn("MailClientUtils no enable.");
        return;
    }
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("frequency", frequency);
    paramMap.put("dateVal", dateStr);
    List<BbMonitorItemScore> monitorItemScores = monitorItemScoreService.findListByParams(paramMap);
    this.clearNoNeedItem(monitorItemScores);
    if (null == monitorItemScores || monitorItemScores.size() < 1) {
        logger.warn("No history monitor item score data.");
        return;
    }
    StringBuilder outContent = new StringBuilder();
    this.createContent(monitorItemScores, outContent);
    if (null == outContent || outContent.length() < 1) {
        logger.warn("No history monitor mail content data.");
        return;
    }
    SysMailHelperVO sysMailHelper = new SysMailHelperVO();
    sysMailHelper.setSubject("bambooBSC monitor item score mail - frequency: " + BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) + " , date: " + SimpleUtils.getStrYMD(dateStr, "/"));
    sysMailHelper.setText(outContent.toString().getBytes("utf-8"));
    sysMailHelper.setMailFrom(MailClientUtils.getDefaultFrom());
    StringBuilder to = new StringBuilder();
    for (String mail : toMail) {
        to.append(mail).append(";");
    }
    sysMailHelper.setMailTo(this.toMail.get(0));
    if (this.toMail.size() > 1) {
        sysMailHelper.setMailCc(to.toString());
    }
    sysMailHelper.setMailId(this.sysMailHelperService.findForMaxMailIdComplete(dateStr));
    sysMailHelper.setRetainFlag(YesNo.NO);
    sysMailHelper.setSuccessFlag(YesNo.NO);
    sysMailHelperService.saveObject(sysMailHelper);
}
Also used : HashMap(java.util.HashMap) BbMonitorItemScore(com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore) SysMailHelperVO(com.netsteadfast.greenstep.vo.SysMailHelperVO)

Example 2 with BbMonitorItemScore

use of com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore in project bamboobsc by billchen198318.

the class HistoryItemScoreNoticeHandler method clearNoNeedItem.

private void clearNoNeedItem(List<BbMonitorItemScore> monitorItemScores) {
    if (null == monitorItemScores) {
        return;
    }
    for (String orgId : organizations) {
        for (Iterator<BbMonitorItemScore> iterator = monitorItemScores.iterator(); iterator.hasNext(); ) {
            BbMonitorItemScore itemScore = iterator.next();
            if (!orgId.equals(itemScore.getOrgId())) {
                iterator.remove();
            }
        }
    }
    for (String empId : employees) {
        for (Iterator<BbMonitorItemScore> iterator = monitorItemScores.iterator(); iterator.hasNext(); ) {
            BbMonitorItemScore itemScore = iterator.next();
            if (!empId.equals(itemScore.getOrgId())) {
                iterator.remove();
            }
        }
    }
    this.clearNoNeedItem(MonitorItemType.VISION, visions, monitorItemScores);
    this.clearNoNeedItem(MonitorItemType.PERSPECTIVES, perspectives, monitorItemScores);
    this.clearNoNeedItem(MonitorItemType.STRATEGY_OF_OBJECTIVES, objectives, monitorItemScores);
    this.clearNoNeedItem(MonitorItemType.KPI, kpis, monitorItemScores);
}
Also used : BbMonitorItemScore(com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore)

Example 3 with BbMonitorItemScore

use of com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore 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 4 with BbMonitorItemScore

use of com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore 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

BbMonitorItemScore (com.netsteadfast.greenstep.po.hbm.BbMonitorItemScore)4 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 MonitorItemScoreVO (com.netsteadfast.greenstep.vo.MonitorItemScoreVO)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CustomeOperational (com.netsteadfast.greenstep.base.model.CustomeOperational)1 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)1 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)1 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)1 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)1 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)1 SysMailHelperVO (com.netsteadfast.greenstep.vo.SysMailHelperVO)1 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1