Search in sources :

Example 1 with DegreeFeedbackItemVO

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

the class DegreeFeedbackLogicServiceImpl method createItems.

private void createItems(DegreeFeedbackProjectVO project, List<DegreeFeedbackItemVO> items) throws ServiceException, Exception {
    for (DegreeFeedbackItemVO item : items) {
        if (super.isBlank(item.getName())) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
        }
        item.setProjectOid(project.getOid());
        super.setStringValueMaxLength(item, "description", MAX_DESCRIPTION_OR_MEMO_LENGTH);
        this.degreeFeedbackItemService.saveObject(item);
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DegreeFeedbackItemVO(com.netsteadfast.greenstep.vo.DegreeFeedbackItemVO)

Example 2 with DegreeFeedbackItemVO

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

the class DegreeFeedbackProjectSaveOrUpdateAction method fillItems.

private List<DegreeFeedbackItemVO> fillItems() throws Exception {
    List<DegreeFeedbackItemVO> items = new ArrayList<DegreeFeedbackItemVO>();
    Map<String, List<Map<String, Object>>> dataMap = this.fillJsonData(this.getFields().get("itemData"));
    List<Map<String, Object>> nodes = dataMap.get("data");
    for (Map<String, Object> node : nodes) {
        DegreeFeedbackItemVO obj = new DegreeFeedbackItemVO();
        obj.setName(String.valueOf(node.get("name")));
        obj.setDescription(String.valueOf(node.get("description")));
        items.add(obj);
    }
    return items;
}
Also used : DegreeFeedbackItemVO(com.netsteadfast.greenstep.vo.DegreeFeedbackItemVO) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 3 with DegreeFeedbackItemVO

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

the class DegreeFeedbackScoreCalculateUtils method getProjectScore.

public static DegreeFeedbackProjectVO getProjectScore(String projectOid, String ownerEmployeeOid) throws ServiceException, Exception {
    DegreeFeedbackProjectVO project = new DegreeFeedbackProjectVO();
    project.setOid(projectOid);
    DefaultResult<DegreeFeedbackProjectVO> projectResult = degreeFeedbackProjectService.findObjectByOid(project);
    if (projectResult.getValue() == null) {
        throw new ServiceException(projectResult.getSystemMessage().getValue());
    }
    project = projectResult.getValue();
    EmployeeVO employee = new EmployeeVO();
    employee.setOid(ownerEmployeeOid);
    DefaultResult<EmployeeVO> empResult = employeeService.findObjectByOid(employee);
    if (empResult.getValue() == null) {
        throw new ServiceException(empResult.getSystemMessage().getValue());
    }
    employee = empResult.getValue();
    List<DegreeFeedbackItemVO> items = getItemsScore(project, employee);
    if (items != null && items.size() > 0) {
        project.setEmployee(employee);
        project.setItems(items);
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("projectOid", project.getOid());
        Map<String, String> orderMap = new HashMap<String, String>();
        orderMap.put("value", "asc");
        List<BbDegreeFeedbackLevel> levels = degreeFeedbackLevelService.findListByParams(paramMap, null, orderMap);
        project.setLevels(wrapLevels(levels));
    }
    return project;
}
Also used : HashMap(java.util.HashMap) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DegreeFeedbackItemVO(com.netsteadfast.greenstep.vo.DegreeFeedbackItemVO) BbDegreeFeedbackLevel(com.netsteadfast.greenstep.po.hbm.BbDegreeFeedbackLevel) DegreeFeedbackProjectVO(com.netsteadfast.greenstep.vo.DegreeFeedbackProjectVO)

Example 4 with DegreeFeedbackItemVO

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

the class DegreeFeedbackScoreCalculateUtils method setItemScoreCalculate.

private static void setItemScoreCalculate(DegreeFeedbackProjectVO project, List<DegreeFeedbackItemVO> items, List<BbDegreeFeedbackScore> scores) throws ServiceException, Exception {
    // 拿來放真的有評分的評分者數量
    List<String> assigns = new ArrayList<String>();
    for (BbDegreeFeedbackScore scoreData : scores) {
        if (!assigns.contains(scoreData.getAssignOid())) {
            assigns.add(scoreData.getAssignOid());
        }
    }
    for (DegreeFeedbackItemVO item : items) {
        int sumScore = 0;
        float avgScore = 0.0f;
        for (BbDegreeFeedbackScore scoreData : scores) {
            if (scoreData.getItemOid().equals(item.getOid())) {
                sumScore += scoreData.getScore();
            }
        }
        if (sumScore > 0 && assigns.size() > 0) {
            // 得分 = 總計/評分者				
            avgScore = Float.valueOf(sumScore) / Float.valueOf(assigns.size());
            BigDecimal bd = new BigDecimal(avgScore);
            avgScore = bd.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue();
        }
        item.setSumScore(sumScore);
        item.setAvgScore(avgScore);
    }
    assigns.clear();
    assigns = null;
}
Also used : DegreeFeedbackItemVO(com.netsteadfast.greenstep.vo.DegreeFeedbackItemVO) ArrayList(java.util.ArrayList) BbDegreeFeedbackScore(com.netsteadfast.greenstep.po.hbm.BbDegreeFeedbackScore) BigDecimal(java.math.BigDecimal)

Aggregations

DegreeFeedbackItemVO (com.netsteadfast.greenstep.vo.DegreeFeedbackItemVO)4 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 ArrayList (java.util.ArrayList)2 BbDegreeFeedbackLevel (com.netsteadfast.greenstep.po.hbm.BbDegreeFeedbackLevel)1 BbDegreeFeedbackScore (com.netsteadfast.greenstep.po.hbm.BbDegreeFeedbackScore)1 DegreeFeedbackProjectVO (com.netsteadfast.greenstep.vo.DegreeFeedbackProjectVO)1 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)1 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1