|
@@ -1,13 +1,13 @@
|
|
|
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.eval.dao.*;
|
|
|
import com.ims.eval.entity.CalculateIndicatorItemInfo;
|
|
|
-import com.ims.eval.entity.OrganizationEvaluationInfo;
|
|
|
+import com.ims.eval.entity.CiteCalculationIndicator;
|
|
|
import com.ims.eval.entity.dto.response.OrganizationEvaluationInfoResDTO;
|
|
|
import com.ims.eval.entity.dto.response.OrganizationEvaluationResDTO;
|
|
|
import com.ims.eval.service.ICalculateIndicatorItemInfoService;
|
|
|
+import com.ims.eval.service.ICiteCalculationIndicatorService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -17,7 +17,6 @@ import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -38,207 +37,105 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
|
@Resource
|
|
|
private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICalculateIndicatorItemInfoService calculateIndicatorItemInfoService;
|
|
|
+
|
|
|
+
|
|
|
@Resource
|
|
|
private IndicatorMapper indicatorMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICiteCalculationIndicatorService citeCalculationIndicatorService;
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
- public int saveIndicatorInfoDTO(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
|
|
|
- List<CalculateIndicatorItemInfo> list = new ArrayList<>();
|
|
|
- OrganizationEvaluationResDTO organizationEvaluationResDTO = organizationEvaluationMapper.selectById(infoResDTOS.get(0).getOrganizationEvaluationId());
|
|
|
- Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = infoResDTOS.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
|
|
|
-
|
|
|
- for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
|
|
|
- //对指标id进行分组
|
|
|
- for (OrganizationEvaluationInfoResDTO r : childCodeGropListEntry.getValue()){
|
|
|
- if (r.getOptionCode().equals("LRZE") || r.getOptionCode().equals("CZ") || r.getOptionCode().equals("LRGXKH")|| r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
|
|
|
- CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
|
|
|
- calculateIndicatorItemInfo.setIndicatorId(r.getIndicatorId());
|
|
|
- calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
|
|
|
- calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
|
|
|
- calculateIndicatorItemInfo.setSectionId(r.getBinSection());
|
|
|
- calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
|
|
|
- calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
|
|
|
- calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
|
|
|
- calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
|
|
|
- calculateIndicatorItemInfo.setOrganizationEvaluationId(r.getOrganizationEvaluationId());
|
|
|
- calculateIndicatorItemInfo.setChildCode(r.getChildCode());
|
|
|
- list.add(calculateIndicatorItemInfo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return saveCalculate(list);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
- public int saveIndicatorInfoDTO2(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
|
|
|
- List<CalculateIndicatorItemInfo> list = new ArrayList<>();
|
|
|
- for (OrganizationEvaluationInfoResDTO r : infoResDTOS){
|
|
|
- if (r.getOptionCode().equals("LRZE") || r.getOptionCode().equals("CZ") || r.getOptionCode().equals("LRGXKH")|| r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
|
|
|
- CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
|
|
|
- calculateIndicatorItemInfo.setIndicatorId(r.getIndicatorId());
|
|
|
- calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
|
|
|
- calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
|
|
|
- calculateIndicatorItemInfo.setSectionId(r.getBinSection());
|
|
|
-// calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
|
|
|
-// calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
|
|
|
-// calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
|
|
|
-// calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
|
|
|
- calculateIndicatorItemInfo.setOrganizationEvaluationId(r.getOrganizationEvaluationId());
|
|
|
- calculateIndicatorItemInfo.setChildCode(r.getChildCode());
|
|
|
- list.add(calculateIndicatorItemInfo);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional
|
|
|
- public int saveCalculate(List<CalculateIndicatorItemInfo> listall) throws Exception {
|
|
|
-
|
|
|
- if (listall.size() > 0){
|
|
|
-
|
|
|
-
|
|
|
- Map<String, List<CalculateIndicatorItemInfo>> childCodeGropList = listall.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getChildCode));
|
|
|
- for (Map.Entry<String, List<CalculateIndicatorItemInfo>> childCodeGropListEntry : childCodeGropList.entrySet()){
|
|
|
-
|
|
|
- List<CalculateIndicatorItemInfo> list = childCodeGropListEntry.getValue();
|
|
|
- //遍历list解析最大值和最小值
|
|
|
- Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
|
|
|
- //判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
|
|
|
- List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","","",list.get(0).getOrganizationEvaluationId(),list.get(0).getChildCode());
|
|
|
-
|
|
|
- if (calculateIndicatorItemInfo.size() > 0){
|
|
|
- List<String> idList = calculateIndicatorItemInfo.stream().map(CalculateIndicatorItemInfo::getId).collect(Collectors.toList());
|
|
|
- calculateIndicatorItemInfoMapper.deleteBatchIds(idList);
|
|
|
+ public int saveIndicatorInfoDTO(String organizationEvaluationId,List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
|
|
|
+ try {
|
|
|
+ List<CalculateIndicatorItemInfo> list = new ArrayList<>();
|
|
|
+ OrganizationEvaluationResDTO organizationEvaluationResDTO = organizationEvaluationMapper.selectById(infoResDTOS.get(0).getOrganizationEvaluationId());
|
|
|
+ Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = infoResDTOS.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
|
|
|
+ //对指标id进行分组
|
|
|
+ for (OrganizationEvaluationInfoResDTO r : childCodeGropListEntry.getValue()){
|
|
|
+ if (r.getOptionCode().equals("LRZE") || r.getOptionCode().equals("CZ") || r.getOptionCode().equals("LRGXKH")|| r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
|
|
|
+ CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
|
|
|
+ calculateIndicatorItemInfo.setIndicatorId(r.getIndicatorId());
|
|
|
+ calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
|
|
|
+ calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
|
|
|
+ calculateIndicatorItemInfo.setSectionId(r.getBinSection());
|
|
|
+ calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
|
|
|
+ calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
|
|
|
+ calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
|
|
|
+ calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
|
|
|
+ calculateIndicatorItemInfo.setOrganizationEvaluationId(r.getOrganizationEvaluationId());
|
|
|
+ calculateIndicatorItemInfo.setChildCode(r.getChildCode());
|
|
|
+ list.add(calculateIndicatorItemInfo);
|
|
|
+ }
|
|
|
}
|
|
|
- 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();
|
|
|
- BigDecimal two = new BigDecimal(diff);
|
|
|
- double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
- if (three > 0) {
|
|
|
- return 1;
|
|
|
- } else if (three < 0) {
|
|
|
- return -1;
|
|
|
+ int code = saveCalculate(list);
|
|
|
+ if(code>0) {
|
|
|
+
|
|
|
+ List<CiteCalculationIndicator> cciList = citeCalculationIndicatorService.getListLikeIndicatorIds("", "");
|
|
|
+ if (null != cciList && cciList.size() > 0) {
|
|
|
+ for (CiteCalculationIndicator cci : cciList) {
|
|
|
+ List<String> indicatorIds = Arrays.asList(cci.getIndicatorIds().split(","));
|
|
|
+ List<CalculateIndicatorItemInfo> ciiList = calculateIndicatorItemInfoMapper.selectItemInfoByIndicatorIdList("",organizationEvaluationId,indicatorIds);
|
|
|
+ Map<String, List<CalculateIndicatorItemInfo>> optionCodeGropList = ciiList.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
|
|
|
+ for (Map.Entry<String, List<CalculateIndicatorItemInfo>> optionCodeGropListEntry : optionCodeGropList.entrySet()){
|
|
|
+
|
|
|
+ //从小到大的顺序排序
|
|
|
+ Collections.sort(optionCodeGropListEntry.getValue(), new Comparator<CalculateIndicatorItemInfo>() {
|
|
|
+ @Override
|
|
|
+ public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
|
|
|
+ double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
|
|
|
+ BigDecimal two = new BigDecimal(diff);
|
|
|
+ double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ if (three > 0) {
|
|
|
+ return 1;
|
|
|
+ } else if (three < 0) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ return 0; //相等为0
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ double value = 0.0;
|
|
|
+ if (optionCodeGropListEntry.getKey().endsWith("MAX")){
|
|
|
+ CalculateIndicatorItemInfo maxNum = (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(optionCodeGropListEntry.getValue().size()-1).clone();
|
|
|
+ value = maxNum.getQuantifiedValue();
|
|
|
+ }else if (optionCodeGropListEntry.getKey().endsWith("MIN")){
|
|
|
+ CalculateIndicatorItemInfo minNum = (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(0).clone();
|
|
|
+ value = minNum.getQuantifiedValue();
|
|
|
+ }else {
|
|
|
+ continue;
|
|
|
}
|
|
|
- return 0; //相等为0
|
|
|
+ for(CalculateIndicatorItemInfo cii : optionCodeGropListEntry.getValue()){
|
|
|
+ cii.setQuantifiedValue(value);
|
|
|
+ }
|
|
|
+ calculateIndicatorItemInfoService.saveOrUpdateBatch(optionCodeGropListEntry.getValue());
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- CalculateIndicatorItemInfo maxNum = (CalculateIndicatorItemInfo)listEntry.getValue().get(listEntry.getValue().size()-1).clone();
|
|
|
- maxNum.setMark("1");
|
|
|
-
|
|
|
- CalculateIndicatorItemInfo minNum = (CalculateIndicatorItemInfo)listEntry.getValue().get(0).clone();
|
|
|
-
|
|
|
- minNum.setMark("0");
|
|
|
-
|
|
|
-
|
|
|
- if (listEntry.getKey().equals("CZ")){
|
|
|
- //存储最大值
|
|
|
- maxNum.setOptionCode("CZMAX");
|
|
|
- minNum.setOptionCode("CZMIN");
|
|
|
- }else if (listEntry.getKey().equals("LRGXL")){
|
|
|
- //利润贡献
|
|
|
- maxNum.setOptionCode("LRGXLMAX");
|
|
|
- minNum.setOptionCode("LRGXLMIN");
|
|
|
- }else if (listEntry.getKey().equals("DWQWLR")){
|
|
|
- maxNum.setOptionCode("DWQWLRMAX");
|
|
|
- minNum.setOptionCode("DWQWLRMIN");
|
|
|
- }else if (listEntry.getKey().equals("LRGXKH")){
|
|
|
- maxNum.setOptionCode("LRGXKHMAX");
|
|
|
- minNum.setOptionCode("LRGXKHMIN");
|
|
|
- }else if (listEntry.getKey().equals("LRZE")){
|
|
|
- maxNum.setOptionCode("LRZEMAX");
|
|
|
- minNum.setOptionCode("LRZEMIN");
|
|
|
}
|
|
|
-
|
|
|
- calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
- calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ return code;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return -1;
|
|
|
}
|
|
|
- return 1;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
- public int saveCalculate2(List<CalculateIndicatorItemInfo> listall) throws Exception {
|
|
|
+ public int saveCalculate(List<CalculateIndicatorItemInfo> listall) throws Exception {
|
|
|
|
|
|
if (listall.size() > 0){
|
|
|
|
|
|
- //集合是包含所有需要求最大值和最小值的对象(先使用属性分组)
|
|
|
-
|
|
|
-
|
|
|
- Map<String, List<CalculateIndicatorItemInfo>> optionCodeGropList = listall.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
|
|
|
-
|
|
|
- for (Map.Entry<String, List<CalculateIndicatorItemInfo>> optionCodeGropListEntry : optionCodeGropList.entrySet()){
|
|
|
-
|
|
|
- //从小到大的顺序排序
|
|
|
- Collections.sort(optionCodeGropListEntry.getValue(), new Comparator<CalculateIndicatorItemInfo>() {
|
|
|
- @Override
|
|
|
- public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
|
|
|
- double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
|
|
|
- BigDecimal two = new BigDecimal(diff);
|
|
|
- double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
- if (three > 0) {
|
|
|
- return 1;
|
|
|
- } else if (three < 0) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
- return 0; //相等为0
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- CalculateIndicatorItemInfo maxNum = (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(optionCodeGropListEntry.getValue().size()-1).clone();
|
|
|
- maxNum.setMark("1");
|
|
|
-
|
|
|
- CalculateIndicatorItemInfo minNum = (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(0).clone();
|
|
|
- minNum.setMark("0");
|
|
|
-
|
|
|
-
|
|
|
- Map<String, List<CalculateIndicatorItemInfo>> childCodeGropList = optionCodeGropListEntry.getValue().stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getChildCode));
|
|
|
- for (Map.Entry<String, List<CalculateIndicatorItemInfo>> childCodeGropListEntry : childCodeGropList.entrySet()){
|
|
|
- String childCode = childCodeGropListEntry.getKey();
|
|
|
-
|
|
|
- CalculateIndicatorItemInfo childinfo= childCodeGropListEntry.getValue().get(0);
|
|
|
- //id置空
|
|
|
- maxNum.setId(null);
|
|
|
- minNum.setId(null);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ////---------------------------------------------------------------------
|
|
|
Map<String, List<CalculateIndicatorItemInfo>> childCodeGropList = listall.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getChildCode));
|
|
|
for (Map.Entry<String, List<CalculateIndicatorItemInfo>> childCodeGropListEntry : childCodeGropList.entrySet()){
|
|
|
|
|
@@ -246,7 +143,7 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
|
//遍历list解析最大值和最小值
|
|
|
Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
|
|
|
//判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
|
|
|
- List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","","",list.get(0).getOrganizationEvaluationId(),list.get(0).getChildCode());
|
|
|
+ List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","",list.get(0).getIndicatorId(),list.get(0).getOrganizationEvaluationId(),list.get(0).getChildCode());
|
|
|
|
|
|
if (calculateIndicatorItemInfo.size() > 0){
|
|
|
List<String> idList = calculateIndicatorItemInfo.stream().map(CalculateIndicatorItemInfo::getId).collect(Collectors.toList());
|
|
@@ -305,4 +202,5 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
+
|
|
|
}
|