|
@@ -4,23 +4,21 @@ import com.ims.common.utils.Constant;
|
|
|
import com.ims.common.utils.FormulaUtils;
|
|
|
import com.ims.common.utils.StringUtils;
|
|
|
import com.ims.eval.config.CustomException;
|
|
|
-import com.ims.eval.entity.IndicatorDictionary;
|
|
|
-import com.ims.eval.entity.Myuser;
|
|
|
-import com.ims.eval.entity.OrganizationEvaluationInfo;
|
|
|
+import com.ims.eval.dao.CalculateIndicatorItemInfoMapper;
|
|
|
+import com.ims.eval.entity.*;
|
|
|
import com.ims.eval.dao.OrganizationEvaluationInfoMapper;
|
|
|
import com.ims.eval.entity.dto.response.MyuserResDTO;
|
|
|
import com.ims.eval.entity.dto.response.OrganizationEvaluationInfoResDTO;
|
|
|
import com.ims.eval.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -34,6 +32,7 @@ import java.util.stream.Collectors;
|
|
|
* @since 2023-03-16
|
|
|
*/
|
|
|
@Service
|
|
|
+@Log4j2
|
|
|
public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<OrganizationEvaluationInfoMapper, OrganizationEvaluationInfo> implements IOrganizationEvaluationInfoService {
|
|
|
|
|
|
@Autowired
|
|
@@ -48,6 +47,11 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
|
|
|
|
|
|
@Autowired
|
|
|
private IEvaluationScoreCountService iEvaluatioinScoreCountService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Map finishValueList(String organizationEvaluationId, String dept, HttpServletRequest request) {
|
|
|
|
|
@@ -207,58 +211,111 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
|
|
|
Map<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropList = binSectionGropEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getIndicatorId));
|
|
|
|
|
|
|
|
|
+ //计算前置属性(差值、利润贡献、单位千瓦利润)的最大最小值
|
|
|
for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropListEntry : indicatorGropList.entrySet()){
|
|
|
- // List<OrganizationEvaluationInfoResDTO> indicator = indicatorGropListEntry.getValue();
|
|
|
|
|
|
+ if (indicatorGropListEntry.getValue().size() > 0){
|
|
|
+ //按照公司规则分组
|
|
|
+ Map<String, List<OrganizationEvaluationInfoResDTO>> ruleIdGropList = indicatorGropListEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getOrganizationEvaluationRuleId));
|
|
|
+
|
|
|
+ //遍历公司指标
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> ruleIdGropListEntry : ruleIdGropList.entrySet()){
|
|
|
+ if (ruleIdGropListEntry.getValue().size() > 0) {
|
|
|
+
|
|
|
+ List<OrganizationEvaluationInfoResDTO> indicator = ruleIdGropListEntry.getValue();
|
|
|
+ Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = indicator.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
|
|
|
+
|
|
|
+ double totalScore = 0.00;
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
|
|
|
+ for (OrganizationEvaluationInfoResDTO dto : childCodeGropListEntry.getValue()) {
|
|
|
+
|
|
|
+ if ((!dto.getOptionCode().equals("CZ") && !dto.getOptionCode().equals("LRGXL") && !dto.getOptionCode().equals("DWQWLR")) || StringUtils.isEmpty(dto.getFormula())) {
|
|
|
+ continue;//当前属性没有配置公式跳过
|
|
|
+ }
|
|
|
+
|
|
|
+ for (OrganizationEvaluationInfoResDTO f : childCodeGropListEntry.getValue()) {
|
|
|
+ dto.setFormula(dto.getFormula().replace("[" + f.getOptionCode() + "]", f.getQuantifiedValue() + ""));
|
|
|
+ }
|
|
|
+ double score = FormulaUtils.caculateFormula(dto.getFormula());
|
|
|
+ if (StringUtils.inStringIgnoreCase("DF", dto.getOptionCode())) {
|
|
|
+ totalScore = totalScore + score;
|
|
|
+ }
|
|
|
+ log.info(dto.getOrganizationShortName() + "|" + dto.getChildName()+"|"+dto.getOptionCode() + "----------" + dto.getFormula() + "=" + score);
|
|
|
+ OrganizationEvaluationInfo info = baseMapper.selectById(dto.getId());
|
|
|
+ //将计算结果保存
|
|
|
+ info.setQuantifiedValue(score);
|
|
|
+ dto.setQuantifiedValue(score);
|
|
|
+ this.saveOrUpdate(info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//计算差值等的最大值最小值
|
|
|
- //iCalculateIndicatorItemInfoService.saveIndicatorInfoDTO(indicatorGropListEntry.getValue());
|
|
|
+ iCalculateIndicatorItemInfoService.saveIndicatorInfoDTO(indicatorGropListEntry.getValue());
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+// //计算前置属性(差值、利润贡献、单位千瓦利润)的最大最小值
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropListEntry : indicatorGropList.entrySet()){
|
|
|
+ for (OrganizationEvaluationInfoResDTO d : indicatorGropListEntry.getValue()){
|
|
|
+ System.out.println(d.getOrganizationShortName()+"|"+d.getIndicatorName()+"|"+d.getOptionName()+"|"+d.getQuantifiedValue());
|
|
|
+ }
|
|
|
|
|
|
if (indicatorGropListEntry.getValue().size() > 0){
|
|
|
//按照公司规则分组
|
|
|
Map<String, List<OrganizationEvaluationInfoResDTO>> ruleIdGropList = indicatorGropListEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getOrganizationEvaluationRuleId));
|
|
|
|
|
|
+
|
|
|
//遍历公司指标
|
|
|
for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> ruleIdGropListEntry : ruleIdGropList.entrySet()){
|
|
|
if (ruleIdGropListEntry.getValue().size() > 0){
|
|
|
|
|
|
List<OrganizationEvaluationInfoResDTO> indicator = ruleIdGropListEntry.getValue();
|
|
|
-// EvaluationScoreCount scoreCount = new EvaluationScoreCount();
|
|
|
+ Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = indicator.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
|
|
|
double totalScore = 0.00;
|
|
|
- for (OrganizationEvaluationInfoResDTO dto: indicator){
|
|
|
- if(!optionCode.equals(dto.getOptionCode()) ||"DF".equals(dto.getOptionCode()) || "DF2".equals(dto.getOptionCode()) || StringUtils.isEmpty(dto.getFormula())){
|
|
|
- continue;//当前属性没有配置公式跳过
|
|
|
- }
|
|
|
-// System.out.println("**************"+dto.getFormula());
|
|
|
- for (OrganizationEvaluationInfoResDTO f : indicator){
|
|
|
- if(f.getOptionCode().endsWith("MIN") || f.getOptionCode().endsWith("MAX")){
|
|
|
- //查询对应的最大值和最小值
|
|
|
- }
|
|
|
+ EvaluationScoreCount scoreCount = new EvaluationScoreCount();
|
|
|
|
|
|
- dto.setFormula(dto.getFormula().replace("["+f.getOptionCode()+"]", f.getQuantifiedValue() + ""));
|
|
|
-// System.out.println("----------"+dto.getFormula());
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
|
|
|
|
|
|
+ List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","","",childCodeGropListEntry.getValue().get(0).getOrganizationEvaluationId(),childCodeGropListEntry.getValue().get(0).getChildCode());
|
|
|
+ Map<String ,Double> map = new HashMap<>();
|
|
|
+ for (CalculateIndicatorItemInfo itemInfo :calculateIndicatorItemInfo){
|
|
|
+ map.put(itemInfo.getOptionCode(),itemInfo.getQuantifiedValue());
|
|
|
}
|
|
|
-// scoreCount.setIndicatorId(dto.getIndicatorId());
|
|
|
-// scoreCount.setOrganizationEvaluationRuleId(dto.getOrganizationEvaluationRuleId());
|
|
|
-// scoreCount.setOrganizationEvaluationId(dto.getOrganizationEvaluationId());
|
|
|
-
|
|
|
- System.out.print(dto.getOrganizationShortName()+"|"+dto.getIndicatorName()+"----------"+dto.getFormula()+"=");
|
|
|
- double score = FormulaUtils.caculateFormula(dto.getFormula());
|
|
|
- if(StringUtils.inStringIgnoreCase("DF",dto.getOptionCode())){
|
|
|
- totalScore = totalScore+score;
|
|
|
+ for (OrganizationEvaluationInfoResDTO dto: childCodeGropListEntry.getValue()){
|
|
|
+ if ((dto.getOptionCode().endsWith("MAX") ||dto.getOptionCode().endsWith("MIN")
|
|
|
+ ||dto.getOptionCode().equals("CZ") || dto.getOptionCode().equals("LRGXL")
|
|
|
+ || dto.getOptionCode().equals("DWQWLR")) || StringUtils.isEmpty(dto.getFormula())){
|
|
|
+ continue;//当前属性没有配置公式跳过或者不需要参与此次计算的属性
|
|
|
+ }
|
|
|
+ scoreCount.setOrganizationEvaluationId(dto.getOrganizationEvaluationId());
|
|
|
+ scoreCount.setOrganizationEvaluationRuleId(dto.getOrganizationEvaluationRuleId());
|
|
|
+ scoreCount.setIndicatorId(dto.getIndicatorId());
|
|
|
+ for (OrganizationEvaluationInfoResDTO f : indicator){
|
|
|
+ if(f.getOptionCode().endsWith("MIN") || f.getOptionCode().endsWith("MAX")){
|
|
|
+ f.setQuantifiedValue(map.get(f.getOptionCode()));
|
|
|
+ }
|
|
|
+ dto.setFormula(dto.getFormula().replace("["+f.getOptionCode()+"]", f.getQuantifiedValue() + ""));
|
|
|
+ }
|
|
|
+ double score = FormulaUtils.caculateFormula(dto.getFormula());
|
|
|
+ if(StringUtils.inStringIgnoreCase("DF",dto.getOptionCode())){
|
|
|
+ totalScore = totalScore+score;
|
|
|
+ }
|
|
|
+ log.info(dto.getOrganizationShortName()+"|"+dto.getIndicatorName()+"----------"+dto.getFormula()+"="+score);
|
|
|
+ OrganizationEvaluationInfo info = baseMapper.selectById(dto.getId());
|
|
|
+ //将计算结果保存
|
|
|
+ info.setQuantifiedValue(score);
|
|
|
+ dto.setQuantifiedValue(score);
|
|
|
+ this.saveOrUpdate(info);
|
|
|
}
|
|
|
- System.out.println(score);
|
|
|
- OrganizationEvaluationInfo info = baseMapper.selectById(dto.getId());
|
|
|
- info.setQuantifiedValue(score);
|
|
|
- this.saveOrUpdate(info);
|
|
|
}
|
|
|
- //得分存入数据库
|
|
|
-// scoreCount.setIsQuantified("1");
|
|
|
-// scoreCount.setScore(totalScore);
|
|
|
-// scoreCount.setObversionScore(totalScore);
|
|
|
-// boolean save = iEvaluatioinScoreCountService.save(scoreCount);
|
|
|
+
|
|
|
+ log.info("综合得分:"+totalScore);
|
|
|
+ scoreCount.setScore(totalScore);
|
|
|
+ scoreCount.setObversionScore(totalScore);
|
|
|
+ scoreCount.setIsQuantified("1");
|
|
|
+ iEvaluatioinScoreCountService.save(scoreCount);
|
|
|
}
|
|
|
}
|
|
|
}
|