|
@@ -2,20 +2,15 @@ package com.ims.eval.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.ims.common.utils.StringUtils;
|
|
|
-import com.ims.eval.config.CustomException;
|
|
|
import com.ims.eval.dao.*;
|
|
|
-import com.ims.eval.entity.BinSection;
|
|
|
-import com.ims.eval.entity.CalculateIndicatorItmeInfo;
|
|
|
-import com.ims.eval.entity.OrganizationEvaluation;
|
|
|
+import com.ims.eval.entity.CalculateIndicatorItemInfo;
|
|
|
import com.ims.eval.entity.OrganizationEvaluationInfo;
|
|
|
-import com.ims.eval.service.IBinSectionService;
|
|
|
+import com.ims.eval.entity.dto.response.OrganizationEvaluationResDTO;
|
|
|
import com.ims.eval.service.ICalculateIndicatorItemInfoService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -28,11 +23,9 @@ import java.util.stream.Collectors;
|
|
|
* @since 2023-03-26
|
|
|
*/
|
|
|
@Service
|
|
|
-public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<CalculateIndicatorItemInfoMapper, CalculateIndicatorItmeInfo> implements ICalculateIndicatorItemInfoService {
|
|
|
+public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<CalculateIndicatorItemInfoMapper, CalculateIndicatorItemInfo> implements ICalculateIndicatorItemInfoService {
|
|
|
|
|
|
|
|
|
- @Resource
|
|
|
- private OrganizationEvaluationInfoMapper organizationEvaluationInfoMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private OrganizationEvaluationMapper organizationEvaluationMapper;
|
|
@@ -43,127 +36,120 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
|
@Autowired
|
|
|
private IndicatorMapper indicatorMapper;
|
|
|
|
|
|
- @Override
|
|
|
- public int save(String organizationType,String checkCycle, String year,String month) throws Exception {
|
|
|
-
|
|
|
- List<CalculateIndicatorItmeInfo> list = new ArrayList<>();
|
|
|
- //加载单位/部门考评记录
|
|
|
- QueryWrapper<OrganizationEvaluation> or = new QueryWrapper<>();
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(organizationType)) {
|
|
|
- or.lambda().eq(OrganizationEvaluation::getOrganizationType, organizationType);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(checkCycle)) {
|
|
|
- or.lambda().eq(OrganizationEvaluation::getCheckCycle, checkCycle);
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(year)) {
|
|
|
- or.lambda().eq(OrganizationEvaluation::getYear, year);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(month)) {
|
|
|
- or.lambda().eq(OrganizationEvaluation::getMonth, month);
|
|
|
- }
|
|
|
|
|
|
- List<OrganizationEvaluation> organizationEvaluations = organizationEvaluationMapper.selectList(or);
|
|
|
- if (organizationEvaluations.size() <= 0) {
|
|
|
- throw new Exception("考评记录为空!!!");
|
|
|
- }
|
|
|
-
|
|
|
- for (OrganizationEvaluation organizationEvaluation : organizationEvaluations) {
|
|
|
- //加载该考评记录下的考评指标明细数据
|
|
|
- QueryWrapper<OrganizationEvaluationInfo> qw = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(organizationEvaluation.getOrganizationEvaluationRuleId())) {
|
|
|
- qw.lambda().in(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId, organizationEvaluation.getOrganizationEvaluationRuleId());
|
|
|
- }
|
|
|
- List<OrganizationEvaluationInfo> organizationEvaluationInfos = organizationEvaluationInfoMapper.selectList(qw);
|
|
|
- //对考评规则id进行分组
|
|
|
- Map<String, List<OrganizationEvaluationInfo>> collect = organizationEvaluationInfos.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId));
|
|
|
- for (Map.Entry<String, List<OrganizationEvaluationInfo>> entry : collect.entrySet()) {
|
|
|
- if (entry.getValue().size() > 0) {
|
|
|
- //对指标id进行分组
|
|
|
- Map<String, List<OrganizationEvaluationInfo>> collectIn = entry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getIndicatorId));
|
|
|
- for (Map.Entry<String, List<OrganizationEvaluationInfo>> listEntry : collectIn.entrySet()) {
|
|
|
- List<OrganizationEvaluationInfo> listEntryValue = listEntry.getValue();
|
|
|
- listEntryValue.stream().forEach(r -> {
|
|
|
- if (r.getOptionCode().equals("CZ") || r.getOptionCode().equals("LRGXKL") || r.getOptionCode().equals("DWQWLR")) {
|
|
|
- CalculateIndicatorItmeInfo calculateIndicatorItmeInfo = new CalculateIndicatorItmeInfo();
|
|
|
- calculateIndicatorItmeInfo.setIndicatorId(listEntry.getKey());
|
|
|
- calculateIndicatorItmeInfo.setOptionCode(r.getOptionCode());
|
|
|
- calculateIndicatorItmeInfo.setQuantifiedValue(r.getQuantifiedValue());
|
|
|
- calculateIndicatorItmeInfo.setSectionId(indicatorMapper.selectById(listEntry.getKey()).getBinSection());
|
|
|
- calculateIndicatorItmeInfo.setOrganizationType(organizationEvaluation.getOrganizationType());
|
|
|
- calculateIndicatorItmeInfo.setCheckCycle(organizationEvaluation.getCheckCycle());
|
|
|
- calculateIndicatorItmeInfo.setYear(organizationEvaluation.getYear());
|
|
|
- calculateIndicatorItmeInfo.setMonth(organizationEvaluation.getMonth());
|
|
|
- list.add(calculateIndicatorItmeInfo);
|
|
|
- }
|
|
|
- });
|
|
|
+ @Override
|
|
|
+ public int saveIndicatorInfo(List<OrganizationEvaluationInfo> organizationEvaluationInfos) throws Exception {
|
|
|
+
|
|
|
+ List<CalculateIndicatorItemInfo> list = new ArrayList<>();
|
|
|
+
|
|
|
+ OrganizationEvaluationResDTO organizationEvaluationResDTO = organizationEvaluationMapper.selectById(organizationEvaluationInfos.get(0).getOrganizationEvaluationId());
|
|
|
+ //对考评规则id进行分组
|
|
|
+ Map<String, List<OrganizationEvaluationInfo>> collect = organizationEvaluationInfos.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId));
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfo>> entry : collect.entrySet()) {
|
|
|
+ if (entry.getValue().size() > 0) {
|
|
|
+ //对指标id进行分组
|
|
|
+ Map<String, List<OrganizationEvaluationInfo>> collectIn = entry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getIndicatorId));
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfo>> listEntry : collectIn.entrySet()) {
|
|
|
+ List<OrganizationEvaluationInfo> listEntryValue = listEntry.getValue();
|
|
|
+ for (OrganizationEvaluationInfo r : listEntryValue){
|
|
|
+ if (r.getOptionCode().equals("CZ") || r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
|
|
|
+ CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
|
|
|
+ calculateIndicatorItemInfo.setIndicatorId(listEntry.getKey());
|
|
|
+ calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
|
|
|
+ calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
|
|
|
+ calculateIndicatorItemInfo.setSectionId(indicatorMapper.selectById(listEntry.getKey()).getBinSection());
|
|
|
+ calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
|
|
|
+ calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
|
|
|
+ calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
|
|
|
+ calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
|
|
|
+ list.add(calculateIndicatorItemInfo);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return saveCalculate(list);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public int saveCalculate(List<CalculateIndicatorItmeInfo> list) throws Exception {
|
|
|
+ @Transactional
|
|
|
+ public int saveCalculate(List<CalculateIndicatorItemInfo> list) throws Exception {
|
|
|
|
|
|
//遍历list解析最大值和最小值
|
|
|
if (list.size() > 0){
|
|
|
- Map<String, List<CalculateIndicatorItmeInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItmeInfo::getOptionCode));
|
|
|
- for (Map.Entry<String, List<CalculateIndicatorItmeInfo>> listEntry : collect.entrySet()){
|
|
|
- CalculateIndicatorItmeInfo maxNum = listEntry.getValue().stream().max(Comparator.comparing(CalculateIndicatorItmeInfo::getQuantifiedValue)).get();
|
|
|
- //判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
|
|
|
- QueryWrapper<CalculateIndicatorItmeInfo> qw = new QueryWrapper<>();
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getYear, maxNum.getYear());
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getMonth, maxNum.getMonth());
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getOptionCode, maxNum.getOptionCode());
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getCheckCycle, maxNum.getCheckCycle());
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getOrganizationType, maxNum.getOrganizationType());
|
|
|
- CalculateIndicatorItmeInfo calculateIndicatorItmeInfo = calculateIndicatorItemInfoMapper.selectOne(qw);
|
|
|
- if (calculateIndicatorItmeInfo != null){
|
|
|
- calculateIndicatorItemInfoMapper.deleteById(calculateIndicatorItmeInfo.getId());
|
|
|
- }else {
|
|
|
- if (listEntry.getKey().equals("CZ")){
|
|
|
- //存储最大值
|
|
|
- maxNum.setOptionCode("CZMAX");
|
|
|
- calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
- }else if (listEntry.getKey().equals("LRGXKL")){
|
|
|
- maxNum.setOptionCode("LRGXKLMAX");
|
|
|
- calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
- }else if (listEntry.getKey().equals("DWQWLR")){
|
|
|
- maxNum.setOptionCode("DWQWLRMAX");
|
|
|
- calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
+ Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
|
|
|
+ for (Map.Entry<String, List<CalculateIndicatorItemInfo>> listEntry : collect.entrySet()){
|
|
|
+
|
|
|
+ //从小到大的顺序排序
|
|
|
+ Collections.sort(listEntry.getValue(), new Comparator<CalculateIndicatorItemInfo>() {
|
|
|
+ @Override
|
|
|
+ public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
|
|
|
+ double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
|
|
|
+ if (diff > 0) {
|
|
|
+ return 1;
|
|
|
+ } else if (diff < 0) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ return 0; //相等为0
|
|
|
}
|
|
|
+ });
|
|
|
+
|
|
|
+ CalculateIndicatorItemInfo maxNum = listEntry.getValue().get(listEntry.getValue().size()-1);
|
|
|
+ maxNum.setMark("1");
|
|
|
+
|
|
|
+ CalculateIndicatorItemInfo minNum = listEntry.getValue().get(0);
|
|
|
+ minNum.setMark("0");
|
|
|
+
|
|
|
+ //判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
|
|
|
+ QueryWrapper<CalculateIndicatorItemInfo> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(CalculateIndicatorItemInfo::getYear, maxNum.getYear());
|
|
|
+ qw.lambda().eq(CalculateIndicatorItemInfo::getMonth, maxNum.getMonth());
|
|
|
+ qw.lambda().eq(CalculateIndicatorItemInfo::getOptionCode, maxNum.getOptionCode());
|
|
|
+ qw.lambda().eq(CalculateIndicatorItemInfo::getCheckCycle, maxNum.getCheckCycle());
|
|
|
+ qw.lambda().eq(CalculateIndicatorItemInfo::getOrganizationType, maxNum.getOrganizationType());
|
|
|
+ qw.lambda().eq(CalculateIndicatorItemInfo::getMark, maxNum.getMark());
|
|
|
+ CalculateIndicatorItemInfo calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectOne(qw);
|
|
|
+
|
|
|
+ if (calculateIndicatorItemInfo != null){
|
|
|
+ calculateIndicatorItemInfoMapper.deleteById(calculateIndicatorItemInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (listEntry.getKey().equals("CZ")){
|
|
|
+ //存储最大值
|
|
|
+ maxNum.setOptionCode("CZMAX");
|
|
|
+ }else if (listEntry.getKey().equals("LRGXL")){
|
|
|
+ maxNum.setOptionCode("LRGXKLMAX");
|
|
|
+ }else if (listEntry.getKey().equals("DWQWLR")){
|
|
|
+ maxNum.setOptionCode("DWQWLRMAX");
|
|
|
}
|
|
|
+ int insert = calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
|
|
|
- CalculateIndicatorItmeInfo minNum = listEntry.getValue().stream().min(Comparator.comparing(CalculateIndicatorItmeInfo::getQuantifiedValue)).get();
|
|
|
//判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
|
|
|
- QueryWrapper<CalculateIndicatorItmeInfo> qw1 = new QueryWrapper<>();
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getYear, minNum.getYear());
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getMonth, minNum.getMonth());
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getOptionCode, minNum.getOptionCode());
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getCheckCycle, minNum.getCheckCycle());
|
|
|
- qw.lambda().eq(CalculateIndicatorItmeInfo::getOrganizationType, minNum.getOrganizationType());
|
|
|
- CalculateIndicatorItmeInfo calculateIndicatorItmeInfo1 = calculateIndicatorItemInfoMapper.selectOne(qw1);
|
|
|
- if (calculateIndicatorItmeInfo1 != null){
|
|
|
- calculateIndicatorItemInfoMapper.deleteById(calculateIndicatorItmeInfo1.getId());
|
|
|
- }else {
|
|
|
- if (listEntry.getKey().equals("CZ")){
|
|
|
- //存储最小值
|
|
|
- maxNum.setOptionCode("CZMIN");
|
|
|
- calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
- }else if (listEntry.getKey().equals("LRGXKL")){
|
|
|
- //存储最小值
|
|
|
- maxNum.setOptionCode("LRGXKLMIN");
|
|
|
- calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
- }else if (listEntry.getKey().equals("DWQWLR")){
|
|
|
- //存储最小值
|
|
|
- maxNum.setOptionCode("DWQWLRMIN");
|
|
|
- calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
- }
|
|
|
+ QueryWrapper<CalculateIndicatorItemInfo> qw1 = new QueryWrapper<>();
|
|
|
+ qw1.lambda().eq(CalculateIndicatorItemInfo::getYear, minNum.getYear());
|
|
|
+ qw1.lambda().eq(CalculateIndicatorItemInfo::getMonth, minNum.getMonth());
|
|
|
+ qw1.lambda().eq(CalculateIndicatorItemInfo::getOptionCode, minNum.getOptionCode());
|
|
|
+ qw1.lambda().eq(CalculateIndicatorItemInfo::getCheckCycle, minNum.getCheckCycle());
|
|
|
+ qw1.lambda().eq(CalculateIndicatorItemInfo::getOrganizationType, minNum.getOrganizationType());
|
|
|
+ qw1.lambda().eq(CalculateIndicatorItemInfo::getMark, minNum.getMark());
|
|
|
+ CalculateIndicatorItemInfo calculateIndicatorItemInfo1 = calculateIndicatorItemInfoMapper.selectOne(qw1);
|
|
|
+
|
|
|
+ if (calculateIndicatorItemInfo1 != null){
|
|
|
+ calculateIndicatorItemInfoMapper.deleteById(calculateIndicatorItemInfo1.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (listEntry.getKey().equals("CZ")){
|
|
|
+ //存储最小值
|
|
|
+ minNum.setOptionCode("CZMIN");
|
|
|
+ }else if (listEntry.getKey().equals("LRGXL")){
|
|
|
+ //存储最小值
|
|
|
+ minNum.setOptionCode("LRGXKLMIN");
|
|
|
+ }else if (listEntry.getKey().equals("DWQWLR")){
|
|
|
+ //存储最小值
|
|
|
+ minNum.setOptionCode("DWQWLRMIN");
|
|
|
}
|
|
|
+ int insert1 = calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
}
|
|
|
}else {
|
|
|
throw new Exception("计算指标项明细为空");
|