|
@@ -5,22 +5,27 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.huaxu.client.UserCenterClient;
|
|
import com.huaxu.client.UserCenterClient;
|
|
import com.huaxu.evaluation.dao.EvaluationResultMapper;
|
|
import com.huaxu.evaluation.dao.EvaluationResultMapper;
|
|
|
|
+import com.huaxu.evaluation.dto.EvaluationReportDto;
|
|
|
|
+import com.huaxu.evaluation.dto.EvaluationReportQueryDto;
|
|
import com.huaxu.evaluation.dto.EvaluationResultDto;
|
|
import com.huaxu.evaluation.dto.EvaluationResultDto;
|
|
import com.huaxu.evaluation.dto.EvaluationResultQueryDto;
|
|
import com.huaxu.evaluation.dto.EvaluationResultQueryDto;
|
|
import com.huaxu.evaluation.enums.EvaluationCycleEnums;
|
|
import com.huaxu.evaluation.enums.EvaluationCycleEnums;
|
|
import com.huaxu.evaluation.enums.EvaluationResultStatus;
|
|
import com.huaxu.evaluation.enums.EvaluationResultStatus;
|
|
import com.huaxu.evaluation.service.EvaluationResultService;
|
|
import com.huaxu.evaluation.service.EvaluationResultService;
|
|
-import com.huaxu.evaluation.vo.EvaluationResultVo;
|
|
|
|
|
|
+import com.huaxu.evaluation.vo.*;
|
|
import com.huaxu.exception.ServiceException;
|
|
import com.huaxu.exception.ServiceException;
|
|
import com.huaxu.model.LoginUser;
|
|
import com.huaxu.model.LoginUser;
|
|
import com.huaxu.org.OrgInfoUtil;
|
|
import com.huaxu.org.OrgInfoUtil;
|
|
import com.huaxu.util.UserUtil;
|
|
import com.huaxu.util.UserUtil;
|
|
|
|
+import io.swagger.models.auth.In;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -60,8 +65,10 @@ public class EvaluationResultServiceImpl implements EvaluationResultService {
|
|
queryDto.setProgramItems(currentUser.getProgramItemList());
|
|
queryDto.setProgramItems(currentUser.getProgramItemList());
|
|
queryDto.setUserType("3");
|
|
queryDto.setUserType("3");
|
|
queryDto.setPermissonType(currentUser.getPermissonType());
|
|
queryDto.setPermissonType(currentUser.getPermissonType());
|
|
- // 格式化
|
|
|
|
- format(queryDto);
|
|
|
|
|
|
+ // 季度需要格式化月份
|
|
|
|
+ if (queryDto.getCycle() == EvaluationCycleEnums.QUARTER.getType()){
|
|
|
|
+ queryDto.setMonth(format(queryDto.getCycle(), queryDto.getMonth()));
|
|
|
|
+ }
|
|
Page<EvaluationResultVo> page = evaluationResultMapper.findPage(new Page<>(dto.getPageNum(), dto.getPageSize()), queryDto);
|
|
Page<EvaluationResultVo> page = evaluationResultMapper.findPage(new Page<>(dto.getPageNum(), dto.getPageSize()), queryDto);
|
|
List<EvaluationResultVo> list = page.getRecords();
|
|
List<EvaluationResultVo> list = page.getRecords();
|
|
if (CollectionUtil.isEmpty(list)) {
|
|
if (CollectionUtil.isEmpty(list)) {
|
|
@@ -86,7 +93,96 @@ public class EvaluationResultServiceImpl implements EvaluationResultService {
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<EvaluationReportRankingVo> findRanking(EvaluationReportDto dto) {
|
|
|
|
+ EvaluationReportQueryDto queryDto = getReportQuery(dto);
|
|
|
|
+ if (queryDto == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<EvaluationReportRankingVo> list = evaluationResultMapper.findRanking(queryDto);
|
|
|
|
+ if (CollectionUtil.isEmpty(list)) {
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+ Map<String,String> gradMap = userCenterClient.selectListByPCodes("SC_EVALUATION_GRADE");
|
|
|
|
+ for (EvaluationReportRankingVo evaluationReportRankingVo: list) {
|
|
|
|
+ evaluationReportRankingVo.setEvaluationGrade(gradMap.get(evaluationReportRankingVo.getEvaluationGrade()));
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<EvaluationGradePercentageVo> findGradePercentage(EvaluationReportDto dto) {
|
|
|
|
+ EvaluationReportQueryDto queryDto = getReportQuery(dto);
|
|
|
|
+ if (queryDto == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<EvaluationGradePercentageVo> list = evaluationResultMapper.findGradePercentage(queryDto);
|
|
|
|
+ if (CollectionUtil.isEmpty(list)) {
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+ Map<String,String> gradMap = userCenterClient.selectListByPCodes("SC_EVALUATION_GRADE");
|
|
|
|
+ BigDecimal total = new BigDecimal("0");
|
|
|
|
+ for (EvaluationGradePercentageVo vo: list) {
|
|
|
|
+ total = total.add(new BigDecimal(vo.getPercentage()));
|
|
|
|
+ }
|
|
|
|
+ for (EvaluationGradePercentageVo vo: list) {
|
|
|
|
+ vo.setEvaluationGrade(gradMap.get(vo.getEvaluationGrade()));
|
|
|
|
+ vo.setPercentage(new BigDecimal(vo.getPercentage()).divide(total,2, RoundingMode.UNNECESSARY).multiply(new BigDecimal("100")).setScale(0, RoundingMode.UNNECESSARY ) + "%");
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<EvaluationQualifiedNumberVo> countQualifiedNumber(EvaluationReportDto dto, BigDecimal qualifiedValue) {
|
|
|
|
+ EvaluationReportQueryDto queryDto = getReportQuery(dto);
|
|
|
|
+ if (queryDto == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ if (queryDto.getCycle() == EvaluationCycleEnums.MONTH.getType()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ if (queryDto.getCycle() == EvaluationCycleEnums.QUARTER.getType()) {
|
|
|
|
+ queryDto.setMonths(formatList(queryDto.getCycle(), queryDto.getMonth()));
|
|
|
|
+ }
|
|
|
|
+ queryDto.setCycle(0);
|
|
|
|
+ return evaluationResultMapper.countQualifiedNumber(queryDto, qualifiedValue);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<EvaluationPerformanceAvgVo> countPerformanceAvg(EvaluationReportDto dto) {
|
|
|
|
+ EvaluationReportQueryDto queryDto = getReportQuery(dto);
|
|
|
|
+ if (queryDto == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ if (queryDto.getCycle() == EvaluationCycleEnums.MONTH.getType()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ if (queryDto.getCycle() == EvaluationCycleEnums.QUARTER.getType()) {
|
|
|
|
+ queryDto.setMonths(formatList(queryDto.getCycle(), queryDto.getMonth()));
|
|
|
|
+ }
|
|
|
|
+ queryDto.setCycle(0);
|
|
|
|
+ return evaluationResultMapper.countPerformanceAvg(queryDto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
+ private EvaluationReportQueryDto getReportQuery(EvaluationReportDto dto){
|
|
|
|
+ EvaluationReportQueryDto queryDto = new EvaluationReportQueryDto();
|
|
|
|
+ BeanUtils.copyProperties(dto, queryDto);
|
|
|
|
+ // 季度需要格式化月份
|
|
|
|
+ if (dto.getCycle() == EvaluationCycleEnums.QUARTER.getType()){
|
|
|
|
+ dto.setMonth(format(dto.getCycle(), dto.getMonth()));
|
|
|
|
+ }
|
|
|
|
+ // 获取用户权限
|
|
|
|
+ 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());
|
|
|
|
+ return queryDto;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Author lihui
|
|
* @Author lihui
|
|
@@ -103,31 +199,45 @@ public class EvaluationResultServiceImpl implements EvaluationResultService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private void format(EvaluationResultQueryDto dto){
|
|
|
|
- Integer cycle = dto.getCycle();
|
|
|
|
|
|
+ private Integer format(Integer cycle, Integer month){
|
|
if (cycle == null) {
|
|
if (cycle == null) {
|
|
throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
}
|
|
}
|
|
// 季度需要格式化
|
|
// 季度需要格式化
|
|
- if (cycle == EvaluationCycleEnums.QUARTER.getType()){
|
|
|
|
- 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());
|
|
|
|
- }
|
|
|
|
|
|
+ if (month == null){
|
|
|
|
+ throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
|
|
+ }
|
|
|
|
+ if (month == 1) {
|
|
|
|
+ return 3;
|
|
|
|
+ } else if (month == 2 ){
|
|
|
|
+ return 6;
|
|
|
|
+ } else if (month == 3) {
|
|
|
|
+ return 9;
|
|
|
|
+ } else if (month == 4) {
|
|
|
|
+ return 12;
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
}
|
|
}
|
|
- // dto.setSort(dto.getSort() == null ? 1 : dto.getSort());
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ private List<Integer> formatList(Integer cycle, Integer month){
|
|
|
|
+ if (cycle == null) {
|
|
|
|
+ throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
|
|
+ }
|
|
|
|
+ // 季度需要格式化
|
|
|
|
+ if (month == null){
|
|
|
|
+ throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
|
|
+ }
|
|
|
|
+ if (month == 1) {
|
|
|
|
+ return Arrays.asList(1,2,3);
|
|
|
|
+ } else if (month == 2 ){
|
|
|
|
+ return Arrays.asList(4,5,6);
|
|
|
|
+ } else if (month == 3) {
|
|
|
|
+ return Arrays.asList(7,8,9);
|
|
|
|
+ } else if (month == 4) {
|
|
|
|
+ return Arrays.asList(10,11,12);
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException(EvaluationResultStatus.PARAM_ERROR.getStatus(), EvaluationResultStatus.PARAM_ERROR.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|