Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

全业务考评 8 mesiacov pred
rodič
commit
2bb703d6f3

+ 31 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/AIIntelligentController.java

@@ -0,0 +1,31 @@
+package com.ims.eval.controller;
+
+import com.ims.eval.entity.dto.result.R;
+import com.ims.eval.service.custom.AIIntelligentService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+public class AIIntelligentController {
+	/**
+	 * 所有考评组织名称
+	 */
+
+	@Resource
+	private AIIntelligentService aiIntelligentService;
+
+
+
+	@GetMapping("/AI")
+	public R getText(@RequestParam(value = "question",required = true)String question) {
+		String s = aiIntelligentService.intelligentGeneration(question);
+		return R.ok().data(s);
+	}
+
+
+}

+ 2 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/NoticeManagementController.java

@@ -15,6 +15,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -205,6 +206,7 @@ public class NoticeManagementController {
 							 @RequestParam(value = "beginDataTime", required = false) String beginDataTime,
 							 @RequestParam(value = "endDataTime", required = false) String endDataTime) {
 		List<EvaluationNotice> list = evaluationNoticeService.circularDisplay(deptId, noticeTitle, beginDataTime, endDataTime);
+		Collections.sort(list);
 		return R.ok().data(list);
 	}
 }

+ 60 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/PerformanceBenchmarkingManageController.java

@@ -5,10 +5,18 @@ import com.ims.eval.config.CustomException;
 import com.ims.eval.entity.PerformanceBenchmarkInfo;
 import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.IPerformanceBenchmarkInfoService;
+import com.ims.eval.util.ExcelUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 业绩对标管理
@@ -69,4 +77,56 @@ public class PerformanceBenchmarkingManageController {
 			return R.customError(e.getMessage()).data("失败!");
 		}
 	}
+
+	/**
+	 * 导出
+	 */
+	@GetMapping(value = "/exportExcel", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
+	public void exportExcel(@RequestParam(value = "toolCategory") String toolCategory,
+							@RequestParam(value = "manageCategory") String manageCategory,
+							@RequestParam(value = "checkCycle") String checkCycle,
+							@RequestParam(value = "degreeYear") Integer degreeYear,
+							@RequestParam(value = "quarterlyMonth", required = false) Integer quarterlyMonth,
+							HttpServletResponse response) throws IOException {
+		performanceBenchmarkInfoService.exportExcel(toolCategory, manageCategory, checkCycle, degreeYear, quarterlyMonth, response);
+	}
+
+	/**
+	 * 导入
+	 */
+	@PostMapping(value = "/importExcel")
+	public R importExcel(@RequestParam("file") MultipartFile file) {
+		if (!file.isEmpty()) {
+			try {
+				//获取原始的文件名
+				String originalFilename = file.getOriginalFilename();
+				//获取文件类型
+				String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
+				//默认从第一行开始读取
+				int startRows = 1;
+				//获取输入流
+				InputStream is = file.getInputStream();
+				List<PerformanceBenchmarkInfo> performanceBenchmarkInfoList = new ArrayList<>();
+				//Excel导入导出的单元类
+				List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
+				//遍历Excel表每一行的数据
+				for (String[] str : strings) {
+					PerformanceBenchmarkInfo performanceBenchmarkInfo = new PerformanceBenchmarkInfo();
+					performanceBenchmarkInfo.setId(str[0]);
+					performanceBenchmarkInfo.setScalingValue(Double.valueOf(str[8]));
+					performanceBenchmarkInfoList.add(performanceBenchmarkInfo);
+				}
+				boolean b = performanceBenchmarkInfoService.updateBatchById(performanceBenchmarkInfoList);
+				if (b) {
+					return R.ok().data(b);
+				} else {
+					return R.error("导入失败!");
+				}
+			} catch (Exception e) {
+				log.error("错误", e);
+				return R.customError(e.getMessage()).data("失败!");
+			}
+		}
+		return R.error("上传文件为空!");
+	}
 }

+ 14 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/PerformanceBenchmarkInfoMapper.java

@@ -24,9 +24,23 @@ public interface PerformanceBenchmarkInfoMapper extends BaseMapper<PerformanceBe
 												   @Param("isDb") Integer isDb,
 												   @Param("isCb") Integer isCb);
 
+	List<PerformanceBenchmarkInfo> getExportExcelData(@Param("manageCategory") String manageCategory,
+													  @Param("checkCycle") String checkCycle,
+													  @Param("degreeYear") Integer degreeYear,
+													  @Param("quarterlyMonth") Integer quarterlyMonth,
+													  @Param("isBg") Integer isBg,
+													  @Param("isDb") Integer isDb,
+													  @Param("isCb") Integer isCb);
+
 	List<PerformanceBenchmarkInfo> selectList(@Param("manageCategory") String manageCategory,
 											  @Param("checkCycle") String checkCycle,
 											  @Param("degreeYear") Integer degreeYear,
 											  @Param("quarterlyMonth") Integer quarterlyMonth);
 
+	List<PerformanceBenchmarkInfo> selectListByIndexName(@Param("manageCategory") String manageCategory,
+														 @Param("checkCycle") String checkCycle,
+														 @Param("degreeYear") Integer degreeYear,
+														 @Param("quarterlyMonth") Integer quarterlyMonth,
+														 @Param("indexName") String indexName);
+
 }

+ 7 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/entity/EvaluationNotice.java

@@ -13,7 +13,7 @@ import java.util.Date;
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
-public class EvaluationNotice extends Model {
+public class EvaluationNotice extends Model implements Comparable<EvaluationNotice> {
 
 	private static final long serialVersionUID = 1L;
 
@@ -61,4 +61,10 @@ public class EvaluationNotice extends Model {
 	private String memo3;
 	//预留字段
 	private String memo4;
+
+	@Override
+	public int compareTo(EvaluationNotice evaluationNotice) {
+		// 按照时间降序排列,所以返回evaluationNotice.createTime - this.createTime的结果
+		return evaluationNotice.getCreateTime().compareTo(this.getCreateTime());
+	}
 }

+ 0 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/entity/OrganizationEvaluationInfo.java

@@ -122,8 +122,6 @@ public class OrganizationEvaluationInfo extends Model {
 	 */
 	private String organizationId;
 
-
-
 	@TableField(exist = false)
 	private String checkCycle;
 	@TableField(exist = false)

+ 7 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/PerformanceBenchmarkInfo.java

@@ -1,6 +1,8 @@
 package com.ims.eval.entity;
 
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.NullSerializer;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -58,6 +60,7 @@ public class PerformanceBenchmarkInfo extends Model {
 	/**
 	 * 装机容量
 	 */
+	@JsonSerialize(nullsUsing = NullSerializer.class)
 	private Double installCapacity;
 
 	/**
@@ -68,21 +71,25 @@ public class PerformanceBenchmarkInfo extends Model {
 	/**
 	 * 计划值
 	 */
+	@JsonSerialize(nullsUsing = NullSerializer.class)
 	private Double plannedValue;
 
 	/**
 	 * 实际完成值
 	 */
+	@JsonSerialize(nullsUsing = NullSerializer.class)
 	private Double completeValue;
 
 	/**
 	 * 推荐值
 	 */
+	@JsonSerialize(nullsUsing = NullSerializer.class)
 	private Double recommendedValue;
 
 	/**
 	 * 定标值
 	 */
+	@JsonSerialize(nullsUsing = NullSerializer.class)
 	private Double scalingValue;
 
 	/**

+ 4 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IPerformanceBenchmarkInfoService.java

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ims.eval.entity.PerformanceBenchmarkInfo;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
 /**
  * @author hlf
  * @date 2024/3/28 14:06
@@ -13,4 +16,5 @@ public interface IPerformanceBenchmarkInfoService extends IService<PerformanceBe
 
 	IPage<PerformanceBenchmarkInfo> listPage(Integer pageNum, Integer pageSize, String toolCategory, String manageCategory, String checkCycle, Integer degreeYear, Integer quarterlyMonth);
 
+	void exportExcel(String toolCategory, String manageCategory, String checkCycle, Integer degreeYear, Integer quarterlyMonth, HttpServletResponse response) throws IOException;
 }

+ 298 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/custom/AIIntelligentService.java

@@ -0,0 +1,298 @@
+package com.ims.eval.service.custom;
+
+import java.time.LocalDate;
+import java.util.*;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import com.ims.eval.dao.EvaluateReportInfoMapper;
+import com.ims.eval.dao.EvaluateReportMapper;
+import com.ims.eval.entity.EvaluateReport;
+import com.ims.eval.entity.EvaluateReportInfo;
+import com.ims.eval.service.custom.enums.AIDateTypeEnum;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+public class AIIntelligentService {
+
+	private Map<String, EvaluateReportInfo> evaluateReportInfoMap = new HashMap<>();
+
+
+	@Value("${AI.scoreType}")
+	private String scoreType;
+
+
+	@Resource
+	private EvaluateReportInfoMapper evaluateReportInfoMapper;
+
+	@Resource
+	private EvaluateReportMapper evaluateReportMapper;
+
+
+	/**
+	 * 智能生成结果
+	 */
+	public String intelligentGeneration(String question) {
+		StringBuilder sb = new StringBuilder();
+		if (question.length() < 5 && (question.contains("你好") || question.contains("您好"))) {
+			sb.append("你好!请问有什么我可以帮助你的吗?");
+			return sb.toString();
+		}
+		Map<String, EvaluateReportInfo> erimap = new HashMap<>();
+		evaluateReportInfoMap = getEvaluateReportInfoMap();
+		erimap = evaluateReportInfoMap.values().stream().filter(eri -> question.contains(eri.getOrganizationName())).collect(Collectors.toMap(EvaluateReportInfo::getEvaluateReportId, Function.identity()));
+		if (erimap.isEmpty()) {
+			sb.append("抱歉,这个知识我还在学习中");
+			return sb.toString();
+		}
+		getConcrete(erimap, question, sb);
+		return sb.toString();
+	}
+
+
+	/**
+	 * 获取具体时间报表
+	 */
+	private void getConcrete(Map<String, EvaluateReportInfo> erimap, String question, StringBuilder sb) {
+		List<EvaluateReport> ler = evaluateReportMapper.selectBatchIds(erimap.keySet());
+		AIDateInfo ad = getDate(question);
+		if (ad.getInfoYear() == null && ad.getInfoQuarter() == null && ad.getInfoMonth() == null) {
+			ad = new AIDateInfo();
+			ad.setType(AIDateTypeEnum.Year);
+			ad.setInfoYear(LocalDate.now().getYear() + "");
+		}
+		switch (ad.getType()) {
+			case Year:
+				getYearData(ler, ad, sb, erimap, question);
+				break;
+			case YearQuarter:
+				getYearQuarterData(ler, ad, sb, erimap, question);
+				break;
+			case YearMonth:
+				getYearMonthData(ler, ad, sb, erimap, question);
+				break;
+			default:
+				break;
+		}
+	}
+
+
+	/**
+	 * 有年和月
+	 */
+	private void getYearMonthData(List<EvaluateReport> ler, AIDateInfo ad, StringBuilder sb, Map<String, EvaluateReportInfo> erimap, String question) {
+		int mark = 0;
+		for (EvaluateReport er : ler) {
+			if (ad.getInfoYear().equals(er.getYear()) && ad.getInfoMonth().equals(er.getMonth())) {
+				getInfoScore(sb, er, erimap, question);
+				mark++;
+			}
+		}
+		if (mark == 0) {
+			sb.append("抱歉,这个知识我还在学习中");
+		}
+	}
+
+
+	/**
+	 * 有年和季度
+	 */
+	private void getYearQuarterData(List<EvaluateReport> ler, AIDateInfo ad, StringBuilder sb, Map<String, EvaluateReportInfo> erimap, String question) {
+		int mark = 0;
+		for (EvaluateReport er : ler) {
+			if (ad.getInfoYear().equals(er.getYear()) && ad.getInfoQuarter().equals(er.getMonth())) {
+				getInfoScore(sb, er, erimap, question);
+				mark++;
+			}
+		}
+		if (mark == 0) {
+			sb.append("抱歉,这个知识我还在学习中");
+		}
+	}
+
+
+	/**
+	 * 只有年份
+	 */
+	private void getYearData(List<EvaluateReport> ler, AIDateInfo ad, StringBuilder sb, Map<String, EvaluateReportInfo> erimap, String question) {
+		int mark = 0;
+		for (EvaluateReport er : ler) {
+			if ("-".equals(er.getMonth()) && ad.getInfoYear().equals(er.getYear())) {
+				getInfoScore(sb, er, erimap, question);
+				mark++;
+			}
+		}
+		if (mark == 0) {
+			sb.append("抱歉,这个知识我还在学习中");
+		}
+	}
+
+
+	/**
+	 * 处理接收到的时间
+	 */
+	public AIDateInfo getDate(String question) {
+		AIDateInfo aii = new AIDateInfo();
+		// 匹配年份
+		Pattern yearPattern = Pattern.compile("(\\d{4}|今年|去年)");
+		Matcher yearMatcher = yearPattern.matcher(question);
+		if (yearMatcher.find()) {
+			String yearStr = yearMatcher.group();
+			int year = 0;
+			if ("今年".equals(yearStr)) {
+				year = LocalDate.now().getYear();
+			} else if ("去年".equals(yearStr)) {
+				year = LocalDate.now().getYear() - 1;
+			} else {
+				year = Integer.parseInt(yearStr);
+			}
+			aii.setType(AIDateTypeEnum.Year);
+			aii.setInfoYear(String.valueOf(year));
+		}
+
+		// 匹配月份
+		Pattern monthPattern = Pattern.compile("(\\d{1,2}月)");
+		Matcher monthMatcher = monthPattern.matcher(question);
+		if (monthMatcher.find()) {
+			String monthStr = monthMatcher.group().replace("月", "");
+			if (aii.getInfoYear() == null) {
+				aii.setInfoYear(LocalDate.now().getYear() + "");
+			}
+			aii.setType(AIDateTypeEnum.YearMonth);
+			aii.setInfoMonth(monthStr);
+		}
+
+		// 匹配季度
+		Pattern quarterPattern = Pattern.compile("(第)?([一-四]|\\d{1,2})季度");
+		Matcher quarterMatcher = quarterPattern.matcher(question);
+		if (quarterMatcher.find()) {
+			String quarterStr = quarterMatcher.group(2);
+			int quarterNum = convertToQuarterNumber(quarterStr);
+			if (quarterNum > 0) {
+				if (aii.getInfoYear() == null) {
+					aii.setInfoMonth(LocalDate.now().getYear() + "");
+				}
+				aii.setType(AIDateTypeEnum.YearQuarter);
+				aii.setInfoQuarter(quarterNum + "");
+			}
+		}
+		return aii;
+	}
+
+
+	private void getInfoScore(StringBuilder sb, EvaluateReport er, Map<String, EvaluateReportInfo> erimap, String question) {
+		int mark=0;
+		EvaluateReportInfo e = erimap.get(er.getId());
+		sb.append(e.getOrganizationName()).append("的");
+		double s3 = 0.0;
+		String[] sType = scoreType.split(",");
+		for (String s2 : sType) {
+			if (question.contains(s2)) {
+				switch (s2) {
+					case "最终得分":
+						s3 = e.getScore();
+						sb.append("最终得分是:").append(s3);
+						break;
+					case "综合得分":
+						s3 = e.getZhScore();
+						sb.append("综合得分是:").append(s3);
+						break;
+					case "生产经营得分":
+						s3 = e.getScjyScore();
+						sb.append("生产经营得分是:").append(s3);
+						break;
+					case "前期得分":
+						s3 = e.getQqScore();
+						sb.append("前期得分是:").append(s3);
+						break;
+					case "基建得分":
+						s3 = e.getJjScore();
+						sb.append("基建得分是:").append(s3);
+						break;
+					case "加分项":
+						s3 = e.getAddScore();
+						sb.append("加分项是:").append(s3);
+						break;
+					case "减分项":
+						s3 = e.getSubScore();
+						sb.append("减分项是:").append(s3);
+						break;
+					case "加减分合计":
+						s3 = e.getAddSubScore();
+						sb.append("加减分合计是:").append(s3);
+						break;
+					case "经营业绩系数":
+						s3 = e.getJyyjXs();
+						sb.append("经营业绩系数是:").append(s3);
+						break;
+					case "关键业绩系数":
+						s3 = e.getGjyjXs();
+						sb.append("关键业绩系数是:").append(s3);
+						break;
+					case "党建考核乘数":
+						s3 = e.getDjkhCs();
+						sb.append("党建考核乘数是:").append(s3);
+						break;
+					case "折算分数":
+						s3 = e.getDiscountScore();
+						sb.append("折算分数是:").append(s3);
+						break;
+				}
+				mark++;
+			}
+		}
+		if (mark == 0) {
+			sb.append("最终得分是:").append(e.getScore()).append(",").append("综合得分是:").append(e.getZhScore()).append(",").append("生产经营得分是:").append(e.getScjyScore()).append(",")
+				.append("前期得分是:").append(e.getQqScore()).append(",").append("基建得分是:").append(e.getJjScore()).append(",").append("加分项是:").append(e.getAddScore()).append(",")
+				.append("减分项是:").append(e.getSubScore()).append("加减分合计是:").append(e.getAddSubScore()).append("经营业绩系数是:").append(e.getJyyjXs())
+				.append("关键业绩系数是:").append(e.getGjyjXs()).append(",").append("党建考核乘数是:").append(e.getDjkhCs()).append(",").append("折算分数是:").append(e.getDiscountScore());
+		}
+	}
+
+
+	private int convertToQuarterNumber(String quarterStr) {
+		switch (quarterStr) {
+			case "一":
+			case "1":
+				return 1;
+			case "二":
+			case "2":
+				return 2;
+			case "三":
+			case "3":
+				return 3;
+			case "四":
+			case "4":
+				return 4;
+			default:
+				// 如果不是有效的季度数字,则返回0或抛出异常
+				return 0;
+		}
+	}
+
+
+	/**
+	 * 考评详情map
+	 */
+	public Map<String, EvaluateReportInfo> getEvaluateReportInfoMap() {
+		List<EvaluateReportInfo> evaluateReportInfos = evaluateReportInfoMapper.selectList(null);
+		return evaluateReportInfoMap = evaluateReportInfos.stream().collect(Collectors.toMap(EvaluateReportInfo::getId, Function.identity()));
+	}
+
+
+	@Data
+	public class AIDateInfo {
+		private String infoYear;
+		private String infoMonth;
+		private String infoQuarter;
+		private AIDateTypeEnum type;
+	}
+
+
+}

+ 8 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/custom/enums/AIDateTypeEnum.java

@@ -0,0 +1,8 @@
+package com.ims.eval.service.custom.enums;
+
+public enum AIDateTypeEnum {
+	Year,
+	YearMonth,
+	YearQuarter,
+	Unknow;
+}

+ 224 - 28
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/PerformanceBenchmarkInfoServiceImpl.java

@@ -8,12 +8,21 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ims.eval.dao.PerformanceBenchmarkInfoMapper;
 import com.ims.eval.entity.*;
 import com.ims.eval.service.*;
+import lombok.Data;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
 
 /**
  * @author hlf
@@ -65,6 +74,89 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 		return baseMapper.selectListPage(page, manageCategory, checkCycle, degreeYear, quarterlyMonth, isBg, isDb, isCb);
 	}
 
+	@Override
+	public void exportExcel(String toolCategory, String manageCategory, String checkCycle, Integer degreeYear, Integer quarterlyMonth, HttpServletResponse response) throws IOException {
+		// 设置响应头信息,以附件形式下载
+		response.setHeader("Content-Disposition", "attachment; filename=performance_benchmark_data.xlsx");
+		response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+
+		// 创建新的Excel工作簿
+		Workbook workbook = new XSSFWorkbook();
+
+		// 创建新的工作表
+		Sheet sheet = workbook.createSheet("Sheet1");
+
+		// 创建表头
+		Row headerRow = sheet.createRow(0);
+		List<String> headers = Arrays.asList("ID", "序号", "单位", "装机容量", "指标", "计划值", "实际完成值", "推荐值", "定标值", "是否标杆");
+		for (int i = 0; i < headers.size(); i++) {
+			Cell cell = headerRow.createCell(i);
+			cell.setCellValue(headers.get(i));
+		}
+
+		//行数据
+		int isBg = 0;
+		int isDb = 0;
+		int isCb = 0;
+		if ("标杆".equals(toolCategory)) {
+			isBg = 1;
+		} else if ("达标".equals(toolCategory)) {
+			isDb = 2;
+		} else if ("超标".equals(toolCategory)) {
+			isCb = 3;
+		}
+		List<PerformanceBenchmarkInfo> performanceBenchmarkInfoList = baseMapper.getExportExcelData(manageCategory, checkCycle, degreeYear, quarterlyMonth, isBg, isDb, isCb);
+
+		// 填充数据到工作表
+		int rowIndex = 1; // 从第二行开始填充数据(第一行是表头)
+		for (PerformanceBenchmarkInfo performanceBenchmarkInfo : performanceBenchmarkInfoList) {
+			Row row = sheet.createRow(rowIndex++);
+
+			// 设置ID
+			row.createCell(0).setCellValue(performanceBenchmarkInfo.getId());
+
+			// 设置序号
+			row.createCell(1).setCellValue(rowIndex - 1);
+
+			// 设置其他数据
+			row.createCell(2).setCellValue(performanceBenchmarkInfo.getCompanyShort());
+			if (null != performanceBenchmarkInfo.getInstallCapacity()) {
+				row.createCell(3).setCellValue(performanceBenchmarkInfo.getInstallCapacity());
+			}
+			row.createCell(4).setCellValue(performanceBenchmarkInfo.getIndexName());
+			if (null != performanceBenchmarkInfo.getPlannedValue()) {
+				row.createCell(5).setCellValue(performanceBenchmarkInfo.getPlannedValue());
+			}
+			if (null != performanceBenchmarkInfo.getCompleteValue()) {
+				row.createCell(6).setCellValue(performanceBenchmarkInfo.getCompleteValue());
+			}
+			if (null != performanceBenchmarkInfo.getRecommendedValue()) {
+				row.createCell(7).setCellValue(performanceBenchmarkInfo.getRecommendedValue());
+			}
+			if (null != performanceBenchmarkInfo.getScalingValue()) {
+				row.createCell(8).setCellValue(performanceBenchmarkInfo.getScalingValue());
+			}
+			if (1 == performanceBenchmarkInfo.getIsBg()) {
+				row.createCell(9).setCellValue("是");
+			} else if (0 == performanceBenchmarkInfo.getIsBg()) {
+				row.createCell(9).setCellValue("否");
+			}
+		}
+
+		// 隐藏第一列(ID列)
+		sheet.setColumnHidden(0, true);
+
+		// 将工作簿写入到输出流
+		try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+			workbook.write(outputStream);
+			response.getOutputStream().write(outputStream.toByteArray());
+			response.getOutputStream().flush();
+		}
+
+		// 关闭工作簿
+		workbook.close();
+	}
+
 	/**
 	 * 寻标
 	 *
@@ -110,8 +202,11 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 									performanceBenchmarkInfo.setPlannedValue(jhzObj.getQuantifiedValue());
 									performanceBenchmarkInfo.setCompleteValue(wczObj.getQuantifiedValue());
 									performanceBenchmarkInfo.setIsBg(0);
+									performanceBenchmarkInfo.setBgVal((double) 0);
 									performanceBenchmarkInfo.setIsDb(0);
+									performanceBenchmarkInfo.setDbVal((double) 0);
 									performanceBenchmarkInfo.setIsCb(0);
+									performanceBenchmarkInfo.setCbVal((double) 0);
 									performanceBenchmarkInfoList.add(performanceBenchmarkInfo);
 								}
 							}
@@ -120,7 +215,9 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 				}
 			}
 			super.saveBatch(performanceBenchmarkInfoList);
-			addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "寻标");
+			if (performanceBenchmarkInfoList.size() > 0) {
+				addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "寻标");
+			}
 		}
 	}
 
@@ -133,25 +230,91 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 	 * @param quarterlyMonth 季/月度
 	 */
 	private void lb(String manageCategory, String checkCycle, Integer degreeYear, Integer quarterlyMonth) {
+		List<PerformanceBenchmarkInfo> updateList = new ArrayList<>();
 		List<BenchmarkingRecord> benchmarkingRecordList = benchmarkingRecordService.selectList(manageCategory, checkCycle, degreeYear, quarterlyMonth, "立标");
 		if (benchmarkingRecordList.size() == 0) {
 			if ("NDKP".equals(checkCycle)) {
 				List<PerformanceBenchmarkInfo> performanceBenchmarkInfoList = baseMapper.selectList(manageCategory, checkCycle, degreeYear, null);
-				double completeValueSum = performanceBenchmarkInfoList.stream().mapToDouble(PerformanceBenchmarkInfo::getCompleteValue).sum();
-				double installCapacitySum = performanceBenchmarkInfoList.stream().mapToDouble(PerformanceBenchmarkInfo::getInstallCapacity).sum();
-				List<PerformanceBenchmarkInfo> updateList = new ArrayList<>();
-				performanceBenchmarkInfoList.forEach(PerformanceBenchmarkInfo -> {
-					PerformanceBenchmarkInfo.setRecommendedValue(yearIndexRecommendedValueA(completeValueSum, installCapacitySum, PerformanceBenchmarkInfo.getInstallCapacity()));
-					updateList.add(PerformanceBenchmarkInfo);
-				});
-				super.updateBatchById(updateList);
+				//Map分组
+				Map<String, List<PerformanceBenchmarkInfo>> grouped = performanceBenchmarkInfoList.stream().collect(Collectors.groupingBy(PerformanceBenchmarkInfo::getIndexName));
+				//Map转List
+				List<PbiGroup> pbiGroupList = grouped.entrySet().stream().map(obj -> new PbiGroup(obj.getKey(), obj.getValue())).collect(Collectors.toList());
+				for (PbiGroup pbiGroup : pbiGroupList) {
+					//指标完成值求和
+					double completeValueSum = pbiGroup.getPbis().stream().filter(obj -> obj.getCompleteValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getCompleteValue).average().orElse(0.0);
+					//装机容量求和
+					double installCapacitySum = pbiGroup.getPbis().stream().filter(obj -> obj.getInstallCapacity() >= 0).mapToDouble(PerformanceBenchmarkInfo::getInstallCapacity).average().orElse(0.0);
+					//去年全年指标数据
+					List<PerformanceBenchmarkInfo> wnData = baseMapper.selectListByIndexName(manageCategory, checkCycle, degreeYear - 1, null, pbiGroup.getIndexName());
+					//前年全年指标数据
+					List<PerformanceBenchmarkInfo> qnData = baseMapper.selectListByIndexName(manageCategory, checkCycle, degreeYear - 2, null, pbiGroup.getIndexName());
+					double plannedValueWnSum;
+					double plannedValueQnSum;
+					double completeValueWnSum;
+					if (qnData.size() > 0 && wnData.size() > 0) {
+						//去年计划值
+						plannedValueWnSum = wnData.stream().filter(obj -> obj.getPlannedValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getPlannedValue).average().orElse(0.0);
+						//前年计划值
+						plannedValueQnSum = qnData.stream().filter(obj -> obj.getPlannedValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getPlannedValue).average().orElse(0.0);
+						//去年实际完成值
+						completeValueWnSum = wnData.stream().filter(obj -> obj.getCompleteValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getCompleteValue).average().orElse(0.0);
+					} else if (wnData.size() > 0) {
+						//去年计划值
+						plannedValueWnSum = wnData.stream().filter(obj -> obj.getPlannedValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getPlannedValue).average().orElse(0.0);
+						plannedValueQnSum = 0;
+						completeValueWnSum = 0;
+					} else {
+						plannedValueWnSum = completeValueSum / pbiGroup.getPbis().size();
+						plannedValueQnSum = -1;
+						completeValueWnSum = -1;
+					}
+					pbiGroup.getPbis().forEach(PerformanceBenchmarkInfo -> {
+						double A = yearIndexRecommendedValueA(completeValueSum, installCapacitySum, PerformanceBenchmarkInfo.getInstallCapacity());
+						double B = yearIndexRecommendedValueB(plannedValueWnSum, plannedValueQnSum, completeValueWnSum);
+						PerformanceBenchmarkInfo.setRecommendedValue(Math.max(A, B));
+						updateList.add(PerformanceBenchmarkInfo);
+					});
+				}
 			} else if ("JDKP".equals(checkCycle) || "YDKP".equals(checkCycle)) {
 				List<PerformanceBenchmarkInfo> performanceBenchmarkInfoList = baseMapper.selectList(manageCategory, checkCycle, degreeYear, quarterlyMonth);
-				List<PerformanceBenchmarkInfo> updateList = new ArrayList<>();
-
-
+				//Map分组
+				Map<String, List<PerformanceBenchmarkInfo>> grouped = performanceBenchmarkInfoList.stream().collect(Collectors.groupingBy(PerformanceBenchmarkInfo::getIndexName));
+				//Map转List
+				List<PbiGroup> pbiGroupList = grouped.entrySet().stream().map(entry -> new PbiGroup(entry.getKey(), entry.getValue())).collect(Collectors.toList());
+				for (PbiGroup pbiGroup : pbiGroupList) {
+					//去年1季/月度指标数据
+					List<PerformanceBenchmarkInfo> wnfData = baseMapper.selectListByIndexName(manageCategory, checkCycle, degreeYear - 1, quarterlyMonth, pbiGroup.getIndexName());
+					double zb;
+					if (wnfData.size() > 0) {
+						//去年全年指标数据
+						List<PerformanceBenchmarkInfo> wnhData = baseMapper.selectListByIndexName(manageCategory, checkCycle, degreeYear - 1, null, pbiGroup.getIndexName());
+						//去年全年发电量总和
+						double wnhCompleteValueSum = wnhData.stream().filter(obj -> obj.getCompleteValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getCompleteValue).sum();
+						//去年1季/月度发电量总和
+						double wnfCompleteValueSum = wnfData.stream().filter(obj -> obj.getCompleteValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getCompleteValue).sum();
+						//每月占比
+						zb = wnfCompleteValueSum / wnhCompleteValueSum;
+					} else {
+						//当年全年指标数据
+						List<PerformanceBenchmarkInfo> dnhData = baseMapper.selectListByIndexName(manageCategory, checkCycle, degreeYear, null, pbiGroup.getIndexName());
+						//当年全年计划值总和
+						double dnhCompleteValueSum = dnhData.stream().filter(obj -> obj.getCompleteValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getCompleteValue).sum();
+						//当年1季/月度计划值总和
+						double dnfCompleteValueSum = pbiGroup.getPbis().stream().filter(obj -> obj.getCompleteValue() >= 0).mapToDouble(PerformanceBenchmarkInfo::getCompleteValue).sum();
+						zb = dnfCompleteValueSum / dnhCompleteValueSum;
+					}
+					performanceBenchmarkInfoList.forEach(PerformanceBenchmarkInfo -> {
+						if (null != PerformanceBenchmarkInfo.getPlannedValue()) {
+							PerformanceBenchmarkInfo.setRecommendedValue(quarterlyMonthIndexRecommendedValue(PerformanceBenchmarkInfo.getPlannedValue(), zb));
+							updateList.add(PerformanceBenchmarkInfo);
+						}
+					});
+				}
+			}
+			super.updateBatchById(updateList);
+			if (updateList.size() > 0) {
+				addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "立标");
 			}
-			addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "立标");
 		}
 	}
 
@@ -168,14 +331,18 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 		if (benchmarkingRecordList.size() == 0) {
 			List<PerformanceBenchmarkInfo> performanceBenchmarkInfoList = baseMapper.selectList(manageCategory, checkCycle, degreeYear, quarterlyMonth);
 			performanceBenchmarkInfoList.forEach(PerformanceBenchmarkInfo -> {
-				PerformanceBenchmarkInfo.setBgVal(PerformanceBenchmarkInfo.getInstallCapacity() / PerformanceBenchmarkInfo.getCompleteValue());
+				if (null != PerformanceBenchmarkInfo.getInstallCapacity() && null != PerformanceBenchmarkInfo.getCompleteValue() && 0 != PerformanceBenchmarkInfo.getCompleteValue()) {
+					PerformanceBenchmarkInfo.setBgVal(PerformanceBenchmarkInfo.getInstallCapacity() / PerformanceBenchmarkInfo.getCompleteValue());
+				}
 			});
 			performanceBenchmarkInfoList.sort(Comparator.comparingDouble(PerformanceBenchmarkInfo::getBgVal).reversed());
 			if (!performanceBenchmarkInfoList.isEmpty() && performanceBenchmarkInfoList.get(0).getBgVal() != 0) {
 				performanceBenchmarkInfoList.get(0).setIsBg(1);
 			}
 			super.updateBatchById(performanceBenchmarkInfoList);
-			addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "标杆");
+			if (performanceBenchmarkInfoList.size() > 0) {
+				addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "标杆");
+			}
 		}
 	}
 
@@ -190,15 +357,23 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 	private void db(String manageCategory, String checkCycle, Integer degreeYear, Integer quarterlyMonth) {
 		List<BenchmarkingRecord> benchmarkingRecordList = benchmarkingRecordService.selectList(manageCategory, checkCycle, degreeYear, quarterlyMonth, "达标");
 		if (benchmarkingRecordList.size() == 0) {
+			boolean flag = false;
 			List<PerformanceBenchmarkInfo> performanceBenchmarkInfoList = baseMapper.selectList(manageCategory, checkCycle, degreeYear, quarterlyMonth);
 			for (PerformanceBenchmarkInfo performanceBenchmarkInfo : performanceBenchmarkInfoList) {
-				if (performanceBenchmarkInfo.getCompleteValue() >= performanceBenchmarkInfo.getScalingValue()) {
-					performanceBenchmarkInfo.setIsDb(1);
-					performanceBenchmarkInfo.setDbVal(performanceBenchmarkInfo.getCompleteValue() - performanceBenchmarkInfo.getScalingValue());
+				if (null != performanceBenchmarkInfo.getCompleteValue() && null != performanceBenchmarkInfo.getScalingValue()) {
+					if (performanceBenchmarkInfo.getCompleteValue() >= performanceBenchmarkInfo.getScalingValue()) {
+						performanceBenchmarkInfo.setIsDb(1);
+						performanceBenchmarkInfo.setDbVal(performanceBenchmarkInfo.getCompleteValue() - performanceBenchmarkInfo.getScalingValue());
+						flag = true;
+					}
+				} else {
+					flag = false;
 				}
 			}
 			super.updateBatchById(performanceBenchmarkInfoList);
-			addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "达标");
+			if (performanceBenchmarkInfoList.size() > 0 && flag) {
+				addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "达标");
+			}
 		}
 	}
 
@@ -214,14 +389,22 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 		List<BenchmarkingRecord> benchmarkingRecordList = benchmarkingRecordService.selectList(manageCategory, checkCycle, degreeYear, quarterlyMonth, "超标");
 		if (benchmarkingRecordList.size() == 0) {
 			List<PerformanceBenchmarkInfo> performanceBenchmarkInfoList = baseMapper.selectList(manageCategory, checkCycle, degreeYear, quarterlyMonth);
+			AtomicBoolean flag = new AtomicBoolean(false);
 			performanceBenchmarkInfoList.stream().filter(p -> p.getIsBg().equals(1)).findFirst().ifPresent(performanceBenchmarkInfo -> performanceBenchmarkInfoList.forEach(PerformanceBenchmarkInfo -> {
-				if (PerformanceBenchmarkInfo.getCompleteValue() > performanceBenchmarkInfo.getScalingValue()) {
-					PerformanceBenchmarkInfo.setIsCb(1);
-					PerformanceBenchmarkInfo.setCbVal(PerformanceBenchmarkInfo.getCompleteValue() - performanceBenchmarkInfo.getScalingValue());
+				if (null != PerformanceBenchmarkInfo.getCompleteValue() && null != performanceBenchmarkInfo.getScalingValue()) {
+					if (PerformanceBenchmarkInfo.getCompleteValue() > performanceBenchmarkInfo.getScalingValue()) {
+						PerformanceBenchmarkInfo.setIsCb(1);
+						PerformanceBenchmarkInfo.setCbVal(PerformanceBenchmarkInfo.getCompleteValue() - performanceBenchmarkInfo.getScalingValue());
+						flag.set(true);
+					}
+				} else {
+					flag.set(false);
 				}
 			}));
 			super.updateBatchById(performanceBenchmarkInfoList);
-			addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "超标");
+			if (performanceBenchmarkInfoList.size() > 0 && flag.get()) {
+				addRecord(manageCategory, checkCycle, degreeYear, quarterlyMonth, "超标");
+			}
 		}
 	}
 
@@ -237,8 +420,10 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 	 */
 	private Double yearIndexRecommendedValueB(double a, double b, double c) {
 		double B;
-		if (b == 0) {
-			B = a * 0.02;
+		if (b == -1) {
+			B = a;
+		} else if (b == 0) {
+			B = a + (a * 0.02);
 		} else {
 			B = (a / b) * c;
 		}
@@ -262,4 +447,15 @@ public class PerformanceBenchmarkInfoServiceImpl extends ServiceImpl<Performance
 		benchmarkingRecord.setTagType(toolCategory);
 		benchmarkingRecordService.save(benchmarkingRecord);
 	}
+
+	@Data
+	private static class PbiGroup {
+		private String indexName;
+		private List<PerformanceBenchmarkInfo> pbis;
+
+		public PbiGroup(String indexName, List<PerformanceBenchmarkInfo> pbis) {
+			this.indexName = indexName;
+			this.pbis = pbis;
+		}
+	}
 }

+ 3 - 1
ims-service/ims-eval/src/main/resources/application.yml

@@ -41,6 +41,8 @@ iam:
     pro: http://10.65.78.65:18082/
 
 
-
+AI:
+  scoreType: 最终得分,生产经营得分,前期得分,基建得分,加分项,减分项,加减分合计,综合得分,经营业绩系数,关键业绩系数,党建考核乘数,折算分数
+  scoreFields: score,scjy_score,qq_score,jj_score,add_score,sub_score,add_sub_score,zh_score,jyyj_xs,gjyj_xs,djkh_cs,discount_score
 
 

+ 52 - 0
ims-service/ims-eval/src/main/resources/mappers/PerformanceBenchmarkInfoMapper.xml

@@ -76,6 +76,7 @@
                 AND is_cb = 1 order by cb_val desc
             </if>
         </where>
+        order by company_id asc, index_name asc
     </select>
 
     <select id="selectList" resultType="com.ims.eval.entity.PerformanceBenchmarkInfo">
@@ -94,6 +95,57 @@
                 AND quarterly_month = #{quarterlyMonth}
             </if>
         </where>
+        order by company_id asc, index_name asc
+    </select>
+
+    <select id="selectListByIndexName" resultType="com.ims.eval.entity.PerformanceBenchmarkInfo">
+        select * from performance_benchmark_info
+        <where>
+            <if test="manageCategory != null and manageCategory != ''">
+                AND manage_category = #{manageCategory}
+            </if>
+            <if test="checkCycle != null and checkCycle != ''">
+                AND check_cycle = #{checkCycle}
+            </if>
+            <if test="degreeYear != null and degreeYear != ''">
+                AND degree_year = #{degreeYear}
+            </if>
+            <if test="quarterlyMonth != null and quarterlyMonth != ''">
+                AND quarterly_month = #{quarterlyMonth}
+            </if>
+            <if test="indexName != null and indexName != ''">
+                AND index_name = #{indexName}
+            </if>
+        </where>
+        order by company_id asc, index_name asc
+    </select>
+
+    <select id="getExportExcelData" resultType="com.ims.eval.entity.PerformanceBenchmarkInfo">
+        select * from performance_benchmark_info
+        <where>
+            <if test="manageCategory != null and manageCategory != ''">
+                AND manage_category = #{manageCategory}
+            </if>
+            <if test="checkCycle != null and checkCycle != ''">
+                AND check_cycle = #{checkCycle}
+            </if>
+            <if test="degreeYear != null and degreeYear != ''">
+                AND degree_year = #{degreeYear}
+            </if>
+            <if test="quarterlyMonth != null and quarterlyMonth != ''">
+                AND quarterly_month = #{quarterlyMonth}
+            </if>
+            <if test="isBg == 1">
+                AND is_bg = 1 order by bg_val desc
+            </if>
+            <if test="isDb == 2">
+                AND is_db = 1 AND is_cb = 1 order by cb_val, db_val desc
+            </if>
+            <if test="isCb == 3">
+                AND is_cb = 1 order by cb_val desc
+            </if>
+        </where>
+        order by company_id asc, index_name asc
     </select>
 
 </mapper>