|
@@ -41,42 +41,6 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
|
private IndicatorMapper indicatorMapper;
|
|
|
|
|
|
|
|
|
- @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());
|
|
|
-// calculateIndicatorItemInfo.setOrganizationEvaluationId(organizationEvaluationResDTO.getId());
|
|
|
- list.add(calculateIndicatorItemInfo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return saveCalculate(list);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public int saveIndicatorInfoDTO(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
|
|
@@ -93,10 +57,10 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
|
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.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);
|
|
@@ -108,6 +72,29 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @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 {
|
|
|
|
|
@@ -180,4 +167,137 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public int saveCalculate2(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();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ////---------------------------------------------------------------------
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ return 0; //相等为0
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ 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 1;
|
|
|
+ }
|
|
|
}
|