|
@@ -11,9 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 计算指标项明细 服务实现类
|
|
* 计算指标项明细 服务实现类
|
|
@@ -76,8 +79,17 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
@Transactional
|
|
@Transactional
|
|
public int saveCalculate(List<CalculateIndicatorItemInfo> list) throws Exception {
|
|
public int saveCalculate(List<CalculateIndicatorItemInfo> list) throws Exception {
|
|
|
|
|
|
- //遍历list解析最大值和最小值
|
|
|
|
if (list.size() > 0){
|
|
if (list.size() > 0){
|
|
|
|
+
|
|
|
|
+ //判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
|
|
|
|
+ List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList(list.get(0).getOrganizationType(),list.get(0).getCheckCycle(),list.get(0).getYear(),list.get(0).getMonth());
|
|
|
|
+
|
|
|
|
+ if (calculateIndicatorItemInfo.size() > 0){
|
|
|
|
+ List<String> idList = calculateIndicatorItemInfo.stream().map(CalculateIndicatorItemInfo::getId).collect(Collectors.toList());
|
|
|
|
+ calculateIndicatorItemInfoMapper.deleteBatchIds(idList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //遍历list解析最大值和最小值
|
|
Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
|
|
Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
|
|
for (Map.Entry<String, List<CalculateIndicatorItemInfo>> listEntry : collect.entrySet()){
|
|
for (Map.Entry<String, List<CalculateIndicatorItemInfo>> listEntry : collect.entrySet()){
|
|
|
|
|
|
@@ -86,9 +98,11 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
@Override
|
|
@Override
|
|
public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
|
|
public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
|
|
double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
|
|
double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
|
|
- if (diff > 0) {
|
|
|
|
|
|
+ BigDecimal two = new BigDecimal(diff);
|
|
|
|
+ double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
|
+ if (three > 0) {
|
|
return 1;
|
|
return 1;
|
|
- } else if (diff < 0) {
|
|
|
|
|
|
+ } else if (three < 0) {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
return 0; //相等为0
|
|
return 0; //相等为0
|
|
@@ -101,55 +115,22 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
|
|
CalculateIndicatorItemInfo minNum = listEntry.getValue().get(0);
|
|
CalculateIndicatorItemInfo minNum = listEntry.getValue().get(0);
|
|
minNum.setMark("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")){
|
|
if (listEntry.getKey().equals("CZ")){
|
|
//存储最大值
|
|
//存储最大值
|
|
maxNum.setOptionCode("CZMAX");
|
|
maxNum.setOptionCode("CZMAX");
|
|
|
|
+ minNum.setOptionCode("CZMIN");
|
|
}else if (listEntry.getKey().equals("LRGXL")){
|
|
}else if (listEntry.getKey().equals("LRGXL")){
|
|
maxNum.setOptionCode("LRGXKLMAX");
|
|
maxNum.setOptionCode("LRGXKLMAX");
|
|
|
|
+ minNum.setOptionCode("LRGXKLMIN");
|
|
}else if (listEntry.getKey().equals("DWQWLR")){
|
|
}else if (listEntry.getKey().equals("DWQWLR")){
|
|
maxNum.setOptionCode("DWQWLRMAX");
|
|
maxNum.setOptionCode("DWQWLRMAX");
|
|
|
|
+ minNum.setOptionCode("DWQWLRMIN");
|
|
}
|
|
}
|
|
int insert = calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
int insert = calculateIndicatorItemInfoMapper.insert(maxNum);
|
|
|
|
|
|
- //判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
|
|
|
|
- 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);
|
|
int insert1 = calculateIndicatorItemInfoMapper.insert(minNum);
|
|
|
|
+ System.out.println(insert1);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
throw new Exception("计算指标项明细为空");
|
|
throw new Exception("计算指标项明细为空");
|