|
@@ -0,0 +1,143 @@
|
|
|
+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.OrganizationEvaluationInfo;
|
|
|
+import com.ims.eval.service.IBinSectionService;
|
|
|
+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 java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+ * <p>
|
|
|
+ * 计算指标项明细 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author xugp
|
|
|
+ * @since 2023-03-26
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<CalculateIndicatorItemInfoMapper, CalculateIndicatorItmeInfo> implements ICalculateIndicatorItemInfoService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrganizationEvaluationInfoMapper organizationEvaluationInfoMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrganizationEvaluationMapper organizationEvaluationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
|
|
|
+
|
|
|
+ @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);
|
|
|
+
|
|
|
+ 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) {
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return saveCalculate(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public int saveCalculate(List<CalculateIndicatorItmeInfo> list) throws Exception {
|
|
|
+
|
|
|
+ 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();
|
|
|
+ CalculateIndicatorItmeInfo minNum = listEntry.getValue().stream().min(Comparator.comparing(CalculateIndicatorItmeInfo::getQuantifiedValue)).get();
|
|
|
+ if (listEntry.getKey().equals("CZ")){
|
|
|
+
|
|
|
+ maxNum.setOptionCode("CZMAX");
|
|
|
+ calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
+
|
|
|
+ maxNum.setOptionCode("CZMIN");
|
|
|
+ calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
+ }else if (listEntry.getKey().equals("LRGXKL")){
|
|
|
+ maxNum.setOptionCode("LRGXKLMAX");
|
|
|
+ calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
+
|
|
|
+ maxNum.setOptionCode("LRGXKLMIN");
|
|
|
+ calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
+ }else if (listEntry.getKey().equals("DWQWLR")){
|
|
|
+ maxNum.setOptionCode("DWQWLRMAX");
|
|
|
+ calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
+
|
|
|
+ maxNum.setOptionCode("DWQWLRMIN");
|
|
|
+ calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ throw new Exception("计算指标项明细为空");
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+}
|