|
@@ -1,20 +1,30 @@
|
|
|
package com.huaxu.evaluation.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.huaxu.client.UserCenterClient;
|
|
|
import com.huaxu.evaluation.dao.EvaluationResultMapper;
|
|
|
import com.huaxu.evaluation.dto.EvaluationResultDto;
|
|
|
import com.huaxu.evaluation.dto.EvaluationResultQueryDto;
|
|
|
+import com.huaxu.evaluation.enums.EvaluationResultStatus;
|
|
|
import com.huaxu.evaluation.service.EvaluationResultService;
|
|
|
import com.huaxu.evaluation.vo.EvaluationResultVo;
|
|
|
+import com.huaxu.exception.ServiceException;
|
|
|
import com.huaxu.model.LoginUser;
|
|
|
import com.huaxu.org.OrgInfoUtil;
|
|
|
import com.huaxu.util.UserUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* @ClassName EvaluationResultServiceImpl
|
|
|
* @Description: 考评结果业务处理
|
|
@@ -32,18 +42,91 @@ public class EvaluationResultServiceImpl implements EvaluationResultService {
|
|
|
@Autowired
|
|
|
private OrgInfoUtil orgInfoUtil;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserCenterClient userCenterClient;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<EvaluationResultVo> findPage(EvaluationResultDto dto) {
|
|
|
EvaluationResultQueryDto queryDto = new EvaluationResultQueryDto();
|
|
|
BeanUtils.copyProperties(dto, queryDto);
|
|
|
// 获取用户权限
|
|
|
LoginUser currentUser = UserUtil.getCurrentUser();
|
|
|
+ if (StringUtils.isEmpty(currentUser.getTenantId())){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
queryDto.setTenantId(currentUser.getTenantId());
|
|
|
queryDto.setProgramItems(currentUser.getProgramItemList());
|
|
|
queryDto.setUserType("3");
|
|
|
queryDto.setPermissonType(currentUser.getPermissonType());
|
|
|
- System.out.println(orgInfoUtil.getOrgName(266));
|
|
|
- return evaluationResultMapper.findPage(new Page<>(dto.getPageNum(), dto.getPageSize()), queryDto);
|
|
|
+ // 格式化
|
|
|
+ format(queryDto);
|
|
|
+ Page<EvaluationResultVo> page = evaluationResultMapper.findPage(new Page<>(dto.getPageNum(), dto.getPageSize()), queryDto);
|
|
|
+ List<EvaluationResultVo> list = page.getRecords();
|
|
|
+ if (CollectionUtil.isEmpty(list)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ Map<String,String> stateMap = userCenterClient.selectListByPCodes("SC_EVALUATION_STATE");
|
|
|
+ Map<String,String> gradMap = userCenterClient.selectListByPCodes("SC_EVALUATION_GRADE");
|
|
|
+ // 避免相同的id去缓存取
|
|
|
+ Map<String, String> companyOrgNameMap = new HashMap<>();
|
|
|
+ Map<String, String> deptOrgNameMap = new HashMap<>();
|
|
|
+ for (EvaluationResultVo vo : list) {
|
|
|
+ if (StringUtils.isNotEmpty(vo.getCompanyOrgId())){
|
|
|
+ vo.setCompanyOrgName(getOrgName(companyOrgNameMap, vo.getCompanyOrgId()));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(vo.getDeptOrgId())) {
|
|
|
+ vo.setDeptOrgName(getOrgName(deptOrgNameMap, vo.getDeptOrgId()));
|
|
|
+ }
|
|
|
+ vo.setState(stateMap.get(vo.getState()));
|
|
|
+ vo.setEvaluationGrade(gradMap.get(vo.getEvaluationGrade()));
|
|
|
+ vo.setCycle(vo.getYear() + "年" + vo.getMonth() + "月");
|
|
|
+ }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author lihui
|
|
|
+ * @Description 避免相同的id去缓存取
|
|
|
+ * @Date 14:39 2021/5/8
|
|
|
+ * @Param [map, id]
|
|
|
+ * @return java.lang.String
|
|
|
+ **/
|
|
|
+ private String getOrgName(Map<String, String> map, String id){
|
|
|
+ String value = map.get(id);
|
|
|
+ value = value != null ? value : orgInfoUtil.getOrgName(Integer.parseInt(id));
|
|
|
+ map.put(id, value);
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void format(EvaluationResultQueryDto dto){
|
|
|
+ Integer cycle = dto.getCycle();
|
|
|
+ if (cycle == null) {
|
|
|
+ throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
|
+ }
|
|
|
+ // 季度需要格式化
|
|
|
+ if (cycle == 2){
|
|
|
+ Integer month = dto.getMonth();
|
|
|
+ if (month == null){
|
|
|
+ throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
|
+ }
|
|
|
+ if (month == 1) {
|
|
|
+ dto.setMonth(3);
|
|
|
+ } else if (month == 2 ){
|
|
|
+ dto.setMonth(6);
|
|
|
+ } else if (month == 3) {
|
|
|
+ dto.setMonth(9);
|
|
|
+ } else if (month == 4) {
|
|
|
+ dto.setMonth(12);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // dto.setSort(dto.getSort() == null ? 1 : dto.getSort());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|