浏览代码

单位考评评级新增导入导出功能

xujuanning 11 月之前
父节点
当前提交
3f593e7312

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

@@ -2,7 +2,6 @@ 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;
@@ -20,7 +19,6 @@ public class AIIntelligentController {
 	private AIIntelligentService aiIntelligentService;
 
 
-
 	@GetMapping("/AI")
 	public R getText(@RequestParam(value = "question",required = true)String question) {
 		String s = aiIntelligentService.intelligentGeneration(question);

+ 26 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/OrganizationRatingController.java

@@ -2,6 +2,7 @@ package com.ims.eval.controller;
 
 
 import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.entity.OrganizationRating;
@@ -10,9 +11,12 @@ import com.ims.eval.service.IOrganizationRatingService;
 import com.ims.eval.util.ExcelUtil;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -186,4 +190,26 @@ public class OrganizationRatingController {
 		return R.customError("上传文件为空!");
 	}
 
+
+
+	/**
+	 * 导出文件
+	 */
+	@GetMapping(value = "exportExcel", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
+	public R exportExcel(HttpServletResponse response,
+					   @RequestParam(value = "binSection", required = false) String binSection,
+					   @RequestParam(value = "year", required = false) String year) throws IOException {
+
+		organizationRatingService.exportExcel(response,binSection,year);
+		return R.ok();
+	}
+
+
+	/**
+	 * 导入文件
+	 */
+	@PostMapping(value = "/importExcel")
+	public R importExcel(@RequestParam("file") MultipartFile file) {
+		return organizationRatingService.importExcel(file);
+	}
 }

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/controller/OrganizationRatingIndicatorController.java

@@ -32,7 +32,7 @@ public class OrganizationRatingIndicatorController {
 
 	@GetMapping(value = "list")
 	public R list() {
-		List<OrganizationRatingIndicator> list = iOrganizationRatingIndicatorService.list();
+		List<OrganizationRatingIndicator> list = iOrganizationRatingIndicatorService.selsList();
 		if (list.isEmpty()) {
 			return R.ok().data("");
 		}

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/IOrganizationRatingIndicatorService.java

@@ -15,5 +15,5 @@ import java.util.List;
  * @since 2024-05-29
  */
 public interface IOrganizationRatingIndicatorService extends IService<OrganizationRatingIndicator> {
-	List<OrganizationRatingIndicator> list();
+	List<OrganizationRatingIndicator> selsList();
 }

+ 6 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IOrganizationRatingService.java

@@ -3,7 +3,11 @@ package com.ims.eval.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ims.eval.entity.OrganizationRating;
+import com.ims.eval.entity.dto.result.R;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -30,5 +34,7 @@ public interface IOrganizationRatingService extends IService<OrganizationRating>
 	IPage<OrganizationRating> grade(List<OrganizationRating> orgRating);
 
 
+	void exportExcel(HttpServletResponse response, String binSection, String year) throws IOException;
 
+	R importExcel(MultipartFile file);
 }

+ 165 - 93
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationServiceImpl.java

@@ -100,6 +100,15 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 	@Autowired
 	private RemoteServiceBuilder serviceBuilder;
 
+	@Autowired
+	private IOrganizationRatingService iOrganizationRatingService;
+
+	@Resource
+	private IOrganizationEvaluationRuleService iOrganizationEvaluationRuleService;
+
+	@Resource
+	private IBinSectionService iBinSectionService;
+
 
 	@Override
 	public IPage<OrganizationEvaluation> list(Integer pageNum, Integer pageSize, String id, String organizationEvaluationCode, List<String> checkCycle, String beginDate, String endDate, String stage, String createBy, String year, String month, String des) {
@@ -149,10 +158,22 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 			qw.lambda().like(OrganizationEvaluation::getDes, des);
 		}
 
-		qw.lambda().orderByDesc(OrganizationEvaluation::getYear,OrganizationEvaluation::getMonth);
+		qw.lambda().orderByDesc(OrganizationEvaluation::getYear, OrganizationEvaluation::getMonth);
 
 		IPage<OrganizationEvaluation> list = baseMapper.selectPage(page, qw);
 
+		if (checkCycle.contains("DWPJ")) {
+			List<OrganizationEvaluation> dwpj = list.getRecords().stream().filter(ll -> "DWPJ".equals(ll.getCheckCycle())).collect(Collectors.toList());
+			QueryWrapper<OrganizationEvaluation> q = new QueryWrapper<>();
+			q.eq("check_cycle","NDKP");
+			List<OrganizationEvaluation> organizationEvaluations = baseMapper.selectList(q);
+			List<OrganizationEvaluation> ndkp = organizationEvaluations.stream().filter(yy -> "NDKP".equals(yy.getCheckCycle()) && "2023".equals(yy.getYear())).collect(Collectors.toList());
+			if (dwpj.isEmpty()) {
+				orgRating(ndkp.get(0));
+			}
+			return baseMapper.selectPage(page, qw);
+		}
+
 		return list;
 	}
 
@@ -160,7 +181,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 	@Override
 	public boolean saveOrUpdate(OrganizationEvaluation entity) {
 		//获取指定部门的规则
-		List<OrganizationEvaluationRule> list = organizationEvaluationRuleService.listByIsCheck(entity.getOrganizationType(), entity.getCheckCycle(), "",true, false);
+		List<OrganizationEvaluationRule> list = organizationEvaluationRuleService.listByIsCheck(entity.getOrganizationType(), entity.getCheckCycle(), "", true, false);
 		if (!"JDKP".equals(entity.getCheckCycle()) && (null == list || list.size() <= 0)) {
 			throw new CustomException("不存在单位权重配置");
 		}
@@ -220,15 +241,67 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 			entity.setUpdateTime(new Date());
 		}
 		boolean b = super.saveOrUpdate(entity);
+		if (b) {
+			orgRating(entity);
+			return b;
+		}
 		return b;
 	}
 
+	private void orgRating(OrganizationEvaluation entity) {
+		String uuid = UUID.randomUUID().toString().replace("-", "");
+		entity.setOrganizationEvaluationCode("dwpj_"+entity.getYear());
+		entity.setId(uuid);
+		entity.setCheckCycle("DWPJ");
+		boolean c = super.save(entity);
+		OrganizationEvaluationResDTO orgEva = baseMapper.selectById(uuid);
+
+		List<OrganizationRating> lors = new ArrayList<>();
+		String ruls = orgEva.getOrganizationEvaluationRuleId();
+		String[] ru = ruls.split(",");
+		List<OrganizationEvaluationRule> oers = iOrganizationEvaluationRuleService.listByIds(Arrays.asList(ru));
+		List<BinSection> binList = iBinSectionService.list();
+		for (OrganizationEvaluationRule oer : oers) {
+			if (!oer.getBinSection().contains(",")) {
+				OrganizationRating or = new OrganizationRating();
+				or.setYear(orgEva.getYear());
+				or.setOrganizationShortName(oer.getOrganizationShortName());
+				or.setOrganizationId(oer.getOrganizationId());
+				or.setOrganizationYearRatingId(uuid);
+				for (BinSection bl : binList) {
+					if (bl.getId().equals(oer.getBinSection())) {
+						or.setBinSection(bl.getSectionCode());
+						break;
+					}
+				}
+				lors.add(or);
+				continue;
+			}
+			String[] split = oer.getBinSection().split(",");
+			Set<String> splitSet = new LinkedHashSet<>(Arrays.asList(split));
+			for (String s : splitSet) {
+				OrganizationRating or = new OrganizationRating();
+				or.setYear(orgEva.getYear());
+				or.setOrganizationShortName(oer.getOrganizationShortName());
+				or.setOrganizationId(oer.getOrganizationId());
+				or.setOrganizationYearRatingId(uuid);
+				for (BinSection bl : binList) {
+					if (bl.getId().equals(s)) {
+						or.setBinSection(bl.getSectionCode());
+						break;
+					}
+				}
+				lors.add(or);
+			}
+		}
+		iOrganizationRatingService.saveBatch(lors);
+	}
 
 
 
 	@Transactional
 	@Override
-	public boolean generateUnitEvaluationInfo(List<String> ids,String indicatorId,String organizationId) {
+	public boolean generateUnitEvaluationInfo(List<String> ids, String indicatorId, String organizationId) {
 
 		for (String id : ids) {
 			OrganizationEvaluation organizationEvaluation = baseMapper.selectById(id);
@@ -262,25 +335,24 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 			String year = organizationEvaluation.getYear();//年份
 
 			//查询当前周期下对应的考评权重(需要考评的单位)
-			List<OrganizationEvaluationRule> evaluationRules = organizationEvaluationRuleService.getOrganizationEvaluationRuleByYearAndCycle(organizationType,checkCycle,year,"");
+			List<OrganizationEvaluationRule> evaluationRules = organizationEvaluationRuleService.getOrganizationEvaluationRuleByYearAndCycle(organizationType, checkCycle, year, "");
 
 			//判断组织id 是否有值;不为空只生成当前组织的数据
-			if(StringUtils.isNotEmpty(organizationId)){
+			if (StringUtils.isNotEmpty(organizationId)) {
 				evaluationRules = evaluationRules.stream().filter(rule -> rule.getOrganizationId().equals(organizationId)).collect(Collectors.toList());
 			}
 
 
-
 			//遍历考核的单位
-			for(OrganizationEvaluationRule evaluationRule : evaluationRules){
+			for (OrganizationEvaluationRule evaluationRule : evaluationRules) {
 				//规则集合
 				List<EvaluateRule> evaluateRuleList = new ArrayList<>();
 				//根据权重获取对应的考评规则
 				//生产经营
 				double scjyWeight = evaluationRule.getScjyWeight();
-				if(scjyWeight>0){
-					List<EvaluateRule> scjyevaluateRuleList =  evaluateRuleService.getEvaluateRuleByYear(evaluationRule.getBinSection(),CacheContext.bseCodeObject.get("SCJY").getId(),"NDKP",evaluationRule.getYear());
-					if(null!=scjyevaluateRuleList &&scjyevaluateRuleList.size()>0){
+				if (scjyWeight > 0) {
+					List<EvaluateRule> scjyevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(evaluationRule.getBinSection(), CacheContext.bseCodeObject.get("SCJY").getId(), "NDKP", evaluationRule.getYear());
+					if (null != scjyevaluateRuleList && scjyevaluateRuleList.size() > 0) {
 						evaluateRuleList.addAll(scjyevaluateRuleList);
 					}
 				}
@@ -291,7 +363,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 				List<MultipleBrand> filteredList = dkpz.stream()
 					.filter(multipleBrand -> !"0".equals(multipleBrand.getParentId()))
 					.collect(Collectors.toList());
-				if (null == filteredList ||  filteredList.size() <= 0) {
+				if (null == filteredList || filteredList.size() <= 0) {
 					//重点专项管理事项
 					List<EvaluateRule> zkevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("GLSX").getId() + "," + CacheContext.bsnCodeObject.get("ZDZX").getId(), CacheContext.bseCodeObject.get("ZDZX").getId() + "," + CacheContext.bseCodeObject.get("GLSX").getId(), "NDKP", evaluationRule.getYear());
 
@@ -303,24 +375,24 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 
 				//前期
 				double qqWeight = evaluationRule.getQqWeight();
-				if(qqWeight>0){
-					List<EvaluateRule> qqevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("QQ").getId(),CacheContext.bseCodeObject.get("QQXM").getId(),"NDKP",evaluationRule.getYear());
-					if(null!=qqevaluateRuleList &&qqevaluateRuleList.size()>0){
+				if (qqWeight > 0) {
+					List<EvaluateRule> qqevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("QQ").getId(), CacheContext.bseCodeObject.get("QQXM").getId(), "NDKP", evaluationRule.getYear());
+					if (null != qqevaluateRuleList && qqevaluateRuleList.size() > 0) {
 						evaluateRuleList.addAll(qqevaluateRuleList);
 					}
 				}
 				//基建
 				double jjWeight = evaluationRule.getJjWeight();
-				if(jjWeight>0){
-					List<EvaluateRule> jjevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("JJ").getId(),CacheContext.bseCodeObject.get("JJXM").getId(),"NDKP",evaluationRule.getYear());
-					if(null!=jjevaluateRuleList &&jjevaluateRuleList.size()>0){
+				if (jjWeight > 0) {
+					List<EvaluateRule> jjevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("JJ").getId(), CacheContext.bseCodeObject.get("JJXM").getId(), "NDKP", evaluationRule.getYear());
+					if (null != jjevaluateRuleList && jjevaluateRuleList.size() > 0) {
 						evaluateRuleList.addAll(jjevaluateRuleList);
 					}
 				}
 				//获取考评规则的id
 				List<String> ruleIds = evaluateRuleList.stream().map(EvaluateRule::getId).collect(Collectors.toList());
 				//通过规则id获取对应的规则明细
-				if(ruleIds.size()<=0){
+				if (ruleIds.size() <= 0) {
 					continue;
 				}
 				List<EvaluateRuleInfo> ruleInfos = evaluateRuleInfoService.list(ruleIds);
@@ -334,7 +406,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 				List<EvaluateRuleInfoIndicatorDTO> resDTOS = evaluateRuleInfoService.listByIndicatorInfo(ruleInfoIds);
 
 				//判断指标id和组织id s是否为空
-				if(StringUtils.isNotEmpty(indicatorId)  ) {
+				if (StringUtils.isNotEmpty(indicatorId)) {
 
 					resDTOS = resDTOS.stream().filter(dto -> dto.getIndicatorId().equals(indicatorId)).collect(Collectors.toList());
 					if (resDTOS.size() <= 0) {
@@ -401,7 +473,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 
 	@Transactional
 	@Override
-	public boolean generateUnitMonthEvaluation(List<String> ids,String indicatorId,String organizationId) {
+	public boolean generateUnitMonthEvaluation(List<String> ids, String indicatorId, String organizationId) {
 
 		for (String id : ids) {
 			OrganizationEvaluation organizationEvaluation = baseMapper.selectById(id);
@@ -421,25 +493,25 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 			String year = organizationEvaluation.getYear();//年份
 
 			//查询当前周期下对应的考评权重(需要考评的单位)
-			List<OrganizationEvaluationRule> evaluationRules = organizationEvaluationRuleService.getOrganizationEvaluationRuleByYearAndCycle(organizationType,checkCycle,year,"");
+			List<OrganizationEvaluationRule> evaluationRules = organizationEvaluationRuleService.getOrganizationEvaluationRuleByYearAndCycle(organizationType, checkCycle, year, "");
 
 
 			//判断组织id 是否有值;不为空只生成当前组织的数据
-			if(StringUtils.isNotEmpty(organizationId)){
+			if (StringUtils.isNotEmpty(organizationId)) {
 				evaluationRules = evaluationRules.stream().filter(rule -> rule.getOrganizationId().equals(organizationId)).collect(Collectors.toList());
 			}
 
 
 			//遍历考核的单位
-			for(OrganizationEvaluationRule evaluationRule : evaluationRules){
+			for (OrganizationEvaluationRule evaluationRule : evaluationRules) {
 				//规则集合
 				List<EvaluateRule> evaluateRuleList = new ArrayList<>();
 				//根据权重获取对应的考评规则
 				//生产经营
 				double scjyWeight = evaluationRule.getScjyWeight();
-				if(scjyWeight>0){
-					List<EvaluateRule> scjyevaluateRuleList =  evaluateRuleService.getEvaluateRuleByYear(evaluationRule.getBinSection(),CacheContext.bseCodeObject.get("SCJY").getId(),"JDKP",evaluationRule.getYear());
-					if(null!=scjyevaluateRuleList &&scjyevaluateRuleList.size()>0){
+				if (scjyWeight > 0) {
+					List<EvaluateRule> scjyevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(evaluationRule.getBinSection(), CacheContext.bseCodeObject.get("SCJY").getId(), "JDKP", evaluationRule.getYear());
+					if (null != scjyevaluateRuleList && scjyevaluateRuleList.size() > 0) {
 						evaluateRuleList.addAll(scjyevaluateRuleList);
 					}
 				}
@@ -450,7 +522,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 				List<MultipleBrand> filteredList = dkpz.stream()
 					.filter(multipleBrand -> !"0".equals(multipleBrand.getParentId()))
 					.collect(Collectors.toList());
-				if (null == filteredList ||  filteredList.size() <= 0) {
+				if (null == filteredList || filteredList.size() <= 0) {
 					//重点专项管理事项
 					List<EvaluateRule> zkevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("GLSX").getId() + "," + CacheContext.bsnCodeObject.get("ZDZX").getId(), CacheContext.bseCodeObject.get("ZDZX").getId() + "," + CacheContext.bseCodeObject.get("GLSX").getId(), "JDKP", evaluationRule.getYear());
 
@@ -462,24 +534,24 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 
 				//前期
 				double qqWeight = evaluationRule.getQqWeight();
-				if(qqWeight>0){
-					List<EvaluateRule> qqevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("QQ").getId(),CacheContext.bseCodeObject.get("QQXM").getId(),"JDKP",evaluationRule.getYear());
-					if(null!=qqevaluateRuleList &&qqevaluateRuleList.size()>0){
+				if (qqWeight > 0) {
+					List<EvaluateRule> qqevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("QQ").getId(), CacheContext.bseCodeObject.get("QQXM").getId(), "JDKP", evaluationRule.getYear());
+					if (null != qqevaluateRuleList && qqevaluateRuleList.size() > 0) {
 						evaluateRuleList.addAll(qqevaluateRuleList);
 					}
 				}
 				//基建
 				double jjWeight = evaluationRule.getJjWeight();
-				if(jjWeight>0){
-					List<EvaluateRule> jjevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("JJ").getId(),CacheContext.bseCodeObject.get("JJXM").getId(),"JDKP",evaluationRule.getYear());
-					if(null!=jjevaluateRuleList &&jjevaluateRuleList.size()>0){
+				if (jjWeight > 0) {
+					List<EvaluateRule> jjevaluateRuleList = evaluateRuleService.getEvaluateRuleByYear(CacheContext.bsnCodeObject.get("JJ").getId(), CacheContext.bseCodeObject.get("JJXM").getId(), "JDKP", evaluationRule.getYear());
+					if (null != jjevaluateRuleList && jjevaluateRuleList.size() > 0) {
 						evaluateRuleList.addAll(jjevaluateRuleList);
 					}
 				}
 				//获取考评规则的id
 				List<String> ruleIds = evaluateRuleList.stream().map(EvaluateRule::getId).collect(Collectors.toList());
 				//通过规则id获取对应的规则明细
-				if(ruleIds.size()<=0){
+				if (ruleIds.size() <= 0) {
 					continue;
 				}
 				List<EvaluateRuleInfo> ruleInfos = evaluateRuleInfoService.list(ruleIds);
@@ -493,7 +565,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 				List<EvaluateRuleInfoIndicatorDTO> resDTOS = evaluateRuleInfoService.listByIndicatorInfo(ruleInfoIds);
 
 				//判断指标id和组织id s是否为空
-				if(StringUtils.isNotEmpty(indicatorId)) {
+				if (StringUtils.isNotEmpty(indicatorId)) {
 
 					resDTOS = resDTOS.stream().filter(dto -> dto.getIndicatorId().equals(indicatorId)).collect(Collectors.toList());
 					if (resDTOS.size() <= 0) {
@@ -651,13 +723,13 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 	public boolean editState(String id, String state, String instId) {
 		OrganizationEvaluation evaluation = baseMapper.selectById(id);
 
-		if("人事部审核".equals(state)){
+		if ("人事部审核".equals(state)) {
 			state = "流程已结束";
 
 			//流程结束  计算相应的得分和汇总报告
-			boolean b1 = organizationEvaluationInfoService.calculationByEvaluationId("","",id,"");
-			if(b1){
-				boolean b2 = evaluateReportService.generateEvaluateReport(id,false);
+			boolean b1 = organizationEvaluationInfoService.calculationByEvaluationId("", "", id, "");
+			if (b1) {
+				boolean b2 = evaluateReportService.generateEvaluateReport(id, false);
 			}
 
 		}
@@ -709,7 +781,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 	@Override
 	public Map getEvaluationScoreInfo(String id, String binSection, String indicatorId, String organizationEvaluationRuleId) {
 
-		BinSection section =  CacheContext.bsnIdObject.get(binSection);
+		BinSection section = CacheContext.bsnIdObject.get(binSection);
 
 		Map map = new HashMap();
 		String title1 = "";
@@ -720,7 +792,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 		//获取到数据
 		List<EvaluationScoreInfoResDTO> listdt = baseMapper.selectEvaluationScoreInfoList(id, binSection, indicatorId, organizationEvaluationRuleId);
 
-		if(null == listdt || listdt.size()<=0){
+		if (null == listdt || listdt.size() <= 0) {
 			throw new CustomException("未找到对应的打分记录");
 		}
 
@@ -729,15 +801,15 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 
 
 			IndicatorDTO indicator = iIndicatorService.getById(indicatorId);
-			title1 = indicator.getIndicatorName()+"打分表";
+			title1 = indicator.getIndicatorName() + "打分表";
 
 			List<Object> childlist = new ArrayList<>();
 			List<IndicatorDictionaryDTO> indicatorDictionaryDTOList = indicator.getDtoList();
-			for(IndicatorDictionaryDTO dto:indicatorDictionaryDTOList){
+			for (IndicatorDictionaryDTO dto : indicatorDictionaryDTOList) {
 				Map<String, Object> childName = new LinkedHashMap<>();
 				List<Object> oplist = new ArrayList<>();
-				for(IndicatorDictionary ids : dto.getList()){
-					if(!ids.getIsShow()){
+				for (IndicatorDictionary ids : dto.getList()) {
+					if (!ids.getIsShow()) {
 						continue;
 					}
 					Map<String, Object> opmap = new HashMap<>();
@@ -746,23 +818,23 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 					oplist.add(opmap);
 				}
 				//有子指标和没有子指标区别
-				if(indicatorDictionaryDTOList.size()>1){
-					childName.put(dto.getChildName(),oplist);
+				if (indicatorDictionaryDTOList.size() > 1) {
+					childName.put(dto.getChildName(), oplist);
 					childlist.add(childName);
-				}else {
+				} else {
 					childlist.addAll(oplist);
 				}
 
 			}
 
-			indicatorName.put(indicator.getIndicatorName(),childlist);
+			indicatorName.put(indicator.getIndicatorName(), childlist);
 
 			//按照公司分组
-			Map<String, List<EvaluationScoreInfoResDTO>> organizationScoreMap = listdt.stream().collect(Collectors.groupingBy(score->score.getOrganizationId()+","+score.getOrganizationShortName()));
+			Map<String, List<EvaluationScoreInfoResDTO>> organizationScoreMap = listdt.stream().collect(Collectors.groupingBy(score -> score.getOrganizationId() + "," + score.getOrganizationShortName()));
 			for (Map.Entry<String, List<EvaluationScoreInfoResDTO>> organizationScoreEntry : organizationScoreMap.entrySet()) {
 				Map<String, Object> opmap = new HashMap<>();
 				//公司名
-				opmap.put("organizationShortName",organizationScoreEntry.getKey().split(",")[1]);
+				opmap.put("organizationShortName", organizationScoreEntry.getKey().split(",")[1]);
 				//按照子指标分组
 				Map<String, List<EvaluationScoreInfoResDTO>> childNameMap = organizationScoreEntry.getValue().stream().collect(Collectors.groupingBy(EvaluationScoreInfoResDTO::getChildCode));
 				for (Map.Entry<String, List<EvaluationScoreInfoResDTO>> childNameEntry : childNameMap.entrySet()) {
@@ -770,37 +842,37 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 					Boolean zhdfflg = true;
 					for (EvaluationScoreInfoResDTO dto : listdto) {
 						//综合得分
-						if(zhdfflg && (childNameMap.size()>1 || dto.getChildName().equals("净利润"))){
-							List<EvaluationScoreCount> scoreCounts = evaluationScoreCountService.getEvaluationScoreCountList(id,dto.getOrganizationEvaluationRuleId(),dto.getIndicatorId(),binSection);
-							opmap.put("zhdf",scoreCounts.get(0).getObversionScore());
+						if (zhdfflg && (childNameMap.size() > 1 || dto.getChildName().equals("净利润"))) {
+							List<EvaluationScoreCount> scoreCounts = evaluationScoreCountService.getEvaluationScoreCountList(id, dto.getOrganizationEvaluationRuleId(), dto.getIndicatorId(), binSection);
+							opmap.put("zhdf", scoreCounts.get(0).getObversionScore());
 							zhdfflg = false;
 						}
-						opmap.put(dto.getChildCode()+"_"+dto.getOptionCode(),dto.getQuantifiedValue());
+						opmap.put(dto.getChildCode() + "_" + dto.getOptionCode(), dto.getQuantifiedValue());
 					}
 				}
 				bodylist.add(opmap);
 			}
 
 			Map<String, Object> title = new LinkedHashMap<>();
-			title.put(title1,indicatorName);
-			map.put("title",title);
-			map.put("values",bodylist);
+			title.put(title1, indicatorName);
+			map.put("title", title);
+			map.put("values", bodylist);
 
 		} else {
 			//2.指标id为空(显示所有指标打分)
 
-			if(section.getSectionCode().equals("JJ")){
-				title1 = section.getSectionName()+"项目指标打分表(工程建设部)";
+			if (section.getSectionCode().equals("JJ")) {
+				title1 = section.getSectionName() + "项目指标打分表(工程建设部)";
 
-			}else if(section.getSectionCode().equals("QQ")){
-				title1 = section.getSectionName()+"项目指标打分表(计划发展部)";
-			}else {
-				title1 = section.getSectionName()+"企业生产指标考核打分表";
+			} else if (section.getSectionCode().equals("QQ")) {
+				title1 = section.getSectionName() + "项目指标打分表(计划发展部)";
+			} else {
+				title1 = section.getSectionName() + "企业生产指标考核打分表";
 			}
 
 			List<String> ruleIds = listdt.stream().map(EvaluationScoreInfoResDTO::getEvaluateRuleId).collect(Collectors.toList());
 			ruleIds = ruleIds.stream().distinct().collect(Collectors.toList());
-			if(ruleIds.size()>1){
+			if (ruleIds.size() > 1) {
 				return null;
 			}
 			//规则中配置的指标
@@ -814,7 +886,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 
 			for (String i : indicatorIds) {
 
-				if(!indicatorId2s.contains(i)){
+				if (!indicatorId2s.contains(i)) {
 					continue;
 				}
 				Map<String, Object> indicatorName2 = new LinkedHashMap<>();
@@ -826,7 +898,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 				int count = 0;
 				for (IndicatorDictionaryDTO dto : indicatorDictionaryDTOList) {
 					count++;
-					if(count>1){
+					if (count > 1) {
 						continue;
 					}
 					List<Object> oplist = new ArrayList<>();
@@ -837,14 +909,14 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 						Map<String, Object> opmap = new HashMap<>();
 						opmap.put("key", dto.getChildCode() + "_" + ids.getOptionCode());
 						opmap.put("name", ids.getOptionName());
-						opmap.put("flag", ids.getIsQuantified()?"1":"2");
+						opmap.put("flag", ids.getIsQuantified() ? "1" : "2");
 
 						oplist.add(opmap);
 					}
 					//有子指标和没有子指标区别
 					if (zhdfflg && (dto.getChildCode().endsWith("LRZE"))) {
 						Map<String, Object> zhdf = new HashMap<>();
-						zhdf.put("key", dto.getChildCode()+"_zhdf");
+						zhdf.put("key", dto.getChildCode() + "_zhdf");
 						zhdf.put("name", "综合得分");
 						zhdf.put("flag", "1");
 						zhdfflg = false;
@@ -862,13 +934,13 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 
 			List<Object> bodylist2 = new ArrayList<>();
 			//按照公司分组
-			Map<String, List<EvaluationScoreInfoResDTO>> organizationScoreMap = listdt.stream().collect(Collectors.groupingBy(score->score.getOrganizationId()+","+score.getOrganizationShortName()));
+			Map<String, List<EvaluationScoreInfoResDTO>> organizationScoreMap = listdt.stream().collect(Collectors.groupingBy(score -> score.getOrganizationId() + "," + score.getOrganizationShortName()));
 
 
 			for (Map.Entry<String, List<EvaluationScoreInfoResDTO>> organizationScoreEntry : organizationScoreMap.entrySet()) {
 				Map<String, Object> opmap = new HashMap<>();
 				//公司名
-				opmap.put("organizationShortName",organizationScoreEntry.getKey().split(",")[1]);
+				opmap.put("organizationShortName", organizationScoreEntry.getKey().split(",")[1]);
 				//按照子指标分组
 				Map<String, List<EvaluationScoreInfoResDTO>> indicatorIdMap = organizationScoreEntry.getValue().stream().collect(Collectors.groupingBy(EvaluationScoreInfoResDTO::getIndicatorId));
 
@@ -878,31 +950,31 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 					Map<String, List<EvaluationScoreInfoResDTO>> iChildCodeMap = indicatorIdEntry.getValue().stream().collect(Collectors.groupingBy(EvaluationScoreInfoResDTO::getChildCode));
 
 					for (EvaluationScoreInfoResDTO dto : indicatorIdEntry.getValue()) {
-						if(iChildCodeMap.size()>1 && dto.getOptionCode().equals("DF")){
-							List<EvaluationScoreCount> scoreCounts = evaluationScoreCountService.getEvaluationScoreCountList(id,dto.getOrganizationEvaluationRuleId(),dto.getIndicatorId(),binSection);
-							if(null != scoreCounts && scoreCounts.size()>0){
-								opmap.put(dto.getChildCode()+"_"+dto.getOptionCode(),scoreCounts.get(0).getObversionScore());
-							}else {
-								opmap.put(dto.getChildCode()+"_"+dto.getOptionCode(),0.0);
+						if (iChildCodeMap.size() > 1 && dto.getOptionCode().equals("DF")) {
+							List<EvaluationScoreCount> scoreCounts = evaluationScoreCountService.getEvaluationScoreCountList(id, dto.getOrganizationEvaluationRuleId(), dto.getIndicatorId(), binSection);
+							if (null != scoreCounts && scoreCounts.size() > 0) {
+								opmap.put(dto.getChildCode() + "_" + dto.getOptionCode(), scoreCounts.get(0).getObversionScore());
+							} else {
+								opmap.put(dto.getChildCode() + "_" + dto.getOptionCode(), 0.0);
 							}
-						}else  {
+						} else {
 							//获取每个单元格的数据
-							if(dto.getIsQuantified()){
+							if (dto.getIsQuantified()) {
 
-								opmap.put(dto.getChildCode()+"_"+dto.getOptionCode(),dto.getQuantifiedValue());
-							}else {
-								opmap.put(dto.getChildCode()+"_"+dto.getOptionCode(),dto.getNonQuantifiedValue());
+								opmap.put(dto.getChildCode() + "_" + dto.getOptionCode(), dto.getQuantifiedValue());
+							} else {
+								opmap.put(dto.getChildCode() + "_" + dto.getOptionCode(), dto.getNonQuantifiedValue());
 							}
 
 						}
 
 						//综合得分
-						if(zhdfflg2 && (dto.getChildCode().endsWith("LRZE"))){
-							List<EvaluationScoreCount> scoreCounts = evaluationScoreCountService.getEvaluationScoreCountList(id,dto.getOrganizationEvaluationRuleId(),dto.getIndicatorId(),binSection);
+						if (zhdfflg2 && (dto.getChildCode().endsWith("LRZE"))) {
+							List<EvaluationScoreCount> scoreCounts = evaluationScoreCountService.getEvaluationScoreCountList(id, dto.getOrganizationEvaluationRuleId(), dto.getIndicatorId(), binSection);
 							if (null != scoreCounts && scoreCounts.size() > 0) {
-								opmap.put(dto.getChildCode()+"_zhdf",scoreCounts.get(0).getObversionScore());
-							}else {
-								opmap.put(dto.getChildCode()+"_zhdf",0.00);
+								opmap.put(dto.getChildCode() + "_zhdf", scoreCounts.get(0).getObversionScore());
+							} else {
+								opmap.put(dto.getChildCode() + "_zhdf", 0.00);
 							}
 
 							zhdfflg2 = false;
@@ -923,11 +995,11 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 
 			Map<String, Object> title1map = new LinkedHashMap<>();
 			Map<String, Object> title2map = new LinkedHashMap<>();
-			title2map.put("考核指标名称",indicatorNamelist);
-			title1map.put(title1,title2map);
-			map.put("zhdf",true);
-			map.put("title",title1map);
-			map.put("values",bodylist2);
+			title2map.put("考核指标名称", indicatorNamelist);
+			title1map.put(title1, title2map);
+			map.put("zhdf", true);
+			map.put("title", title1map);
+			map.put("values", bodylist2);
 		}
 		return map;
 	}
@@ -935,7 +1007,7 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 
 	@Override
 	public OrganizationEvaluation getOrganizationEvaluation(String id) {
-		if(StringUtils.isEmpty(id)){
+		if (StringUtils.isEmpty(id)) {
 			return null;
 		}
 		OrganizationEvaluation res = this.getById(id);

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationRatingIndicatorServiceImpl.java

@@ -20,7 +20,7 @@ import java.util.List;
 public class OrganizationRatingIndicatorServiceImpl extends ServiceImpl<OrganizationRatingIndicatorMapper, OrganizationRatingIndicator> implements IOrganizationRatingIndicatorService {
 
 	@Override
-	public List<OrganizationRatingIndicator> list() {
+	public List<OrganizationRatingIndicator> selsList() {
 		return baseMapper.selectList(null);
 	}
 }

+ 272 - 111
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationRatingServiceImpl.java

@@ -7,15 +7,22 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ims.eval.cache.CacheContext;
 import com.ims.eval.dao.OrganizationRatingMapper;
 import com.ims.eval.entity.*;
+import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ims.eval.util.ExcelUtil;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -51,6 +58,158 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 	private IOrganizationRatingRuleService iOrganizationRatingRuleService;
 
 
+	/**
+	 * 导入
+	 * @param file
+	 * @return
+	 */
+	@Override
+	public R importExcel(MultipartFile file) {
+		if (file.isEmpty()) {
+			return R.error("上传文件为空!");
+		}
+		try {
+			//获取原始的文件名
+			String originalFilename = file.getOriginalFilename();
+			//获取文件类型
+			String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
+			//默认从第一行开始读取
+			int startRows = 1;
+			//获取输入流
+			InputStream is = file.getInputStream();
+			List<OrganizationRating> orgList = new ArrayList<>();
+			//Excel导入导出的单元类
+			List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
+			List<String> ids = strings.stream().map(row -> row[row.length - 1]).collect(Collectors.toList());
+			List<OrganizationRating> organizationRatings = baseMapper.selectBatchIds(ids);
+			//遍历Excel表每一行的数据
+			for (String[] str : strings) {
+				for (OrganizationRating or : organizationRatings) {
+					if (str[15].equals(or.getId())) {
+						or.setSafetyEnvProtection(str[3]);
+						or.setVeto(str[4]);
+						or.setNetProfit(str[5]);
+						or.setCompositeScore(str[6]);
+						or.setScjyRate(str[7]);
+						or.setAnnualTarget(str[8]);
+						or.setBonusPoint(str[9]);
+						or.setQqRate(str[10]);
+						or.setCompositeScoreRaking(str[11]);
+						or.setProjectLevel(str[12]);
+						or.setJjRate(str[13]);
+						or.setYearRate(str[14]);
+						orgList.add(or);
+					}
+				}
+			}
+			boolean b = super.saveOrUpdateBatch(orgList);
+			if (b) {
+				return R.ok().data(b);
+			} else {
+				return R.error("导入失败!");
+			}
+		} catch (Exception e) {
+			return R.customError(e.getMessage()).data("失败!");
+		}
+
+	}
+
+
+	/**
+	 * 导出
+	 */
+	@Override
+	public void exportExcel(HttpServletResponse response, String binSection, String year) throws IOException {
+		// 设置响应头信息,以附件形式下载
+		response.setHeader("Content-Disposition", "attachment; filename=organization_rating.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("考评单位", "业务板块", "考评年度", "年度安全环保评级", "否决事项:无0,有1", "净利润", "经营业绩考核综合得分百分比", "生产经营评级", "年度项目进度目标完成率",
+			"先进性指标考核得分有无加分", "前期评级", "基建工程综合得分排名", "基建工程项目等级", "基建评级", "年度评级", "id");
+
+
+		for (int i = 0; i < headers.size(); i++) {
+			Cell cell = headerRow.createCell(i);
+			cell.setCellValue(headers.get(i));
+		}
+
+
+		//行数据
+		Page<OrganizationRating> page = new Page<>(1, 100000);
+		IPage<OrganizationRating> orgRating = baseMapper.selectList(page, null, null, binSection, year, null, null,
+			null, null, null, null, null, null, null, null);
+
+		// 填充数据到工作表
+		int rowIndex = 1; // 从第二行开始填充数据(第一行是表头)
+		for (OrganizationRating or : orgRating.getRecords()) {
+			Row row = sheet.createRow(rowIndex++);
+
+			// 设置数据
+			Cell cell0 = row.createCell(0);
+			cell0.setCellValue(or.getOrganizationShortName());
+			Cell cell1 = row.createCell(1);
+			cell1.setCellValue(or.getBinSectionName());
+			Cell cell2 = row.createCell(2);
+			cell2.setCellValue(or.getYear());
+			Cell cell3 = row.createCell(3);
+			cell3.setCellValue(or.getSafetyEnvProtection());
+			Cell cell4 = row.createCell(4);
+			cell4.setCellValue(or.getVeto());
+			Cell cell5 = row.createCell(5);
+			cell5.setCellValue(or.getNetProfit());
+			Cell cell6 = row.createCell(6);
+			cell6.setCellValue(or.getCompositeScore());
+			Cell cell7 = row.createCell(7);
+			cell7.setCellValue(or.getScjyRate());
+			Cell cell8 = row.createCell(8);
+			cell8.setCellValue(or.getAnnualTarget());
+			Cell cell9 = row.createCell(9);
+			cell9.setCellValue(or.getBonusPoint());
+			Cell cell10 = row.createCell(10);
+			cell10.setCellValue(or.getQqRate());
+			Cell cell11 = row.createCell(11);
+			cell11.setCellValue(or.getCompositeScoreRaking());
+			Cell cell12 = row.createCell(12);
+			cell12.setCellValue(or.getProjectLevel());
+			Cell cell13 = row.createCell(13);
+			cell13.setCellValue(or.getJjRate());
+			Cell cell14 = row.createCell(14);
+			cell14.setCellValue(or.getYearRate());
+			Cell idCell = row.createCell(15);
+			idCell.setCellValue(or.getId());
+		}
+		sheet.setColumnHidden(15, true);
+		// 自动调整列宽
+		for (int i = 0; i < headers.size() - 1; i++) {
+			sheet.autoSizeColumn(i);
+		}
+
+		// 将工作簿写入到输出流
+		try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+			workbook.write(outputStream);
+			response.getOutputStream().write(outputStream.toByteArray());
+			response.getOutputStream().flush();
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		} finally {
+			// 关闭工作簿
+			workbook.close();
+		}
+
+	}
+
+
+	/**
+	 * 单位考评评级
+	 */
 	@Override
 	public IPage<OrganizationRating> grade(List<OrganizationRating> orgRating) {
 		XSSFWorkbook xwb = new XSSFWorkbook();
@@ -61,22 +220,22 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 		Map<String, List<OrganizationRating>> collect = orgRating.stream().collect(Collectors.groupingBy(OrganizationRating::getBinSection));
 		Map<String, List<OrganizationRating>> col = new HashMap<>();
 		collect.forEach((key, value) -> CacheContext.bsnList.stream()
-                .filter(b -> key.equals(b.getSectionCode()))
-                .findFirst()
-                .ifPresent(b -> col.put(b.getId(), value)));
-
-		calcSCJYrating(rulesYear, col,st,xwb);
-		calcQQXMrating(rulesYear, col,st,xwb);
-		calcJJXMrating(rulesYear, col,st,xwb);
-		calcNDrating(rulesYear, orgRating,st,xwb);
+			.filter(b -> key.equals(b.getSectionCode()))
+			.findFirst()
+			.ifPresent(b -> col.put(b.getId(), value)));
+
+		calcSCJYrating(rulesYear, col, st, xwb);
+		calcQQXMrating(rulesYear, col, st, xwb);
+		calcJJXMrating(rulesYear, col, st, xwb);
+		calcNDrating(rulesYear, orgRating, st, xwb);
 		return null;
 	}
 
 
 	/**
-	 *年度评级
+	 * 年度评级
 	 */
-	private void calcNDrating(List<OrganizationRatingRule> list, List<OrganizationRating> orgRating,Sheet st,XSSFWorkbook xwb) {
+	private void calcNDrating(List<OrganizationRatingRule> list, List<OrganizationRating> orgRating, Sheet st, XSSFWorkbook xwb) {
 		List<String> ls = new ArrayList<>();
 		for (OrganizationRating or : orgRating) {
 			ls.add(or.getId());
@@ -96,46 +255,46 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 			if (collect.isEmpty()) {
 				continue;
 			}
-			String formula=collect.get(0).getExpression();
+			String formula = collect.get(0).getExpression();
 
-		for (OrganizationRating or : orgMap.getValue()) {
-			if (or.getScjyRate() == null ||or.getScjyRate().isEmpty()|| or.getQqRate() == null||or.getQqRate().isEmpty()) {
-				continue;
-			}
-			String replace = formula;
-			Pattern pattern = Pattern.compile("\\[([^\\[\\]]+)\\]");//编译成模式
-			Matcher matcher = pattern.matcher(formula);
-			Map<String, String> placeholders = new HashMap<>();
-			String key=null;
-			while (matcher.find()) {
-				String content = matcher.group(1);
-				if ("scjy_rate".equals(content)) {
-					if (or.getScjyRate() == null) {
-						return;
+			for (OrganizationRating or : orgMap.getValue()) {
+				if (or.getScjyRate() == null || or.getScjyRate().isEmpty() || or.getQqRate() == null || or.getQqRate().isEmpty()) {
+					continue;
+				}
+				String replace = formula;
+				Pattern pattern = Pattern.compile("\\[([^\\[\\]]+)\\]");//编译成模式
+				Matcher matcher = pattern.matcher(formula);
+				Map<String, String> placeholders = new HashMap<>();
+				String key = null;
+				while (matcher.find()) {
+					String content = matcher.group(1);
+					if ("scjy_rate".equals(content)) {
+						if (or.getScjyRate() == null) {
+							return;
+						}
+						key = or.getScjyRate();
+					} else if ("qq_rate".equals(content)) {
+						if (or.getQqRate() == null) {
+							return;
+						}
+						key = or.getQqRate();
 					}
-					key= or.getScjyRate();
-				}else if ("qq_rate".equals(content)) {
-					if (or.getQqRate() == null) {
-						return;
+					if (key != null) {
+						replace = replace.replace("[" + content + "]", key);
 					}
-					key = or.getQqRate();
-				}
-				if (key != null) {
-					replace = replace.replace("[" + content + "]", key);
+					placeholders.put(key, content);
 				}
-				placeholders.put(key, content);
+				String form = replace;
+				CellValue cv = setFormula(st, xwb, form);
+				UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
+				uw.eq("id", or.getId()).set("year_rate", cv.formatAsString());
+				iOrganizationRatingService.update(uw);
 			}
-			String form = replace;
-			CellValue cv = setFormula(st, xwb, form);
-			UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
-			uw.eq("id", or.getId()).set("year_rate", cv.formatAsString());
-			iOrganizationRatingService.update(uw);
-	   		}
 		}
 	}
 
 
-	private CellValue setFormula(Sheet st,XSSFWorkbook xwb,String form) {
+	private CellValue setFormula(Sheet st, XSSFWorkbook xwb, String form) {
 		Row rr = st.createRow(0);
 		Cell cc = rr.createCell(0);
 		// 这里要设置为公式类型
@@ -148,28 +307,28 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 	/**
 	 * 基建评级
 	 */
-	private void calcJJXMrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating,Sheet st,XSSFWorkbook xwb) {
+	private void calcJJXMrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
 		List<OrganizationRatingRule> rules = list.stream().filter(orr -> "基建评级".equals(orr.getCheckCycle())).collect(Collectors.toList());
 		for (Map.Entry<String, List<OrganizationRating>> orgMap : orgRating.entrySet()) {
 			List<OrganizationRatingRule> collect = rules.stream().filter(rul -> orgMap.getKey().equals(rul.getBinSection())).collect(Collectors.toList());
 			if (collect.isEmpty()) {
 				continue;
 			}
-			String formula=collect.get(0).getExpression();
+			String formula = collect.get(0).getExpression();
 			for (OrganizationRating or : orgMap.getValue()) {
-				if (or.getCompositeScoreRaking() == null ||or.getCompositeScoreRaking().isEmpty()|| or.getProjectLevel() == null||or.getProjectLevel().isEmpty()) {
+				if (or.getCompositeScoreRaking() == null || or.getCompositeScoreRaking().isEmpty() || or.getProjectLevel() == null || or.getProjectLevel().isEmpty()) {
 					continue;
 				}
 				String replace = formula;
 				Pattern pattern = Pattern.compile("\\[([^\\[\\]]+)\\]");//编译成模式
 				Matcher matcher = pattern.matcher(formula);
 				Map<String, String> placeholders = new HashMap<>();
-				String key=null;
+				String key = null;
 				while (matcher.find()) {
 					String content = matcher.group(1);
 					if ("ZHDEPM".equals(content)) {
-						key= or.getCompositeScoreRaking();
-					}else if ("JJDJ".equals(content)) {
+						key = or.getCompositeScoreRaking();
+					} else if ("JJDJ".equals(content)) {
 						key = or.getProjectLevel();
 					}
 					if (key != null) {
@@ -180,8 +339,8 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 				String form = replace;
 				CellValue cv = setFormula(st, xwb, form);
 				UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
-				uw.eq("id", or.getId()).set("jj_rate", cv.formatAsString()).set("composite_score_raking",or.getCompositeScoreRaking())
-					.set("project_level",or.getProjectLevel());
+				uw.eq("id", or.getId()).set("jj_rate", cv.formatAsString()).set("composite_score_raking", or.getCompositeScoreRaking())
+					.set("project_level", or.getProjectLevel());
 				iOrganizationRatingService.update(uw);
 			}
 		}
@@ -190,102 +349,104 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 	/**
 	 * 生产经营评级
 	 */
-	private void calcSCJYrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating,Sheet st,XSSFWorkbook xwb) {
+	private void calcSCJYrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
 		List<OrganizationRatingRule> rules = list.stream().filter(orr -> "生产经营评级".equals(orr.getCheckCycle())).collect(Collectors.toList());
 		for (Map.Entry<String, List<OrganizationRating>> orgMap : orgRating.entrySet()) {
 			List<OrganizationRatingRule> collect = rules.stream().filter(rul -> orgMap.getKey().equals(rul.getBinSection())).collect(Collectors.toList());
 			for (OrganizationRatingRule ru : rules) {
-				System.out.println("key+"+orgMap.getKey()+"---"+ru.getBinSection());
+				System.out.println("key+" + orgMap.getKey() + "---" + ru.getBinSection());
 			}
 			if (collect.isEmpty()) {
 				continue;
 			}
-			String formula=collect.get(0).getExpression();
-		for (OrganizationRating or : orgMap.getValue()) {
-			if (or.getSafetyEnvProtection() == null|| or.getSafetyEnvProtection().isEmpty() || or.getNetProfit() == null ||or.getNetProfit().isEmpty()|| or.getCompositeScore()==null ||or.getCompositeScore().isEmpty()|| or.getVeto()==null||or.getVeto().isEmpty()) {
-				continue;
-			}
-			String replace = formula;
-			Pattern pattern = Pattern.compile("\\[([^\\[\\]]+)\\]");//编译成模式
-			Matcher matcher = pattern.matcher(formula);
-			Map<String, String> placeholders = new HashMap<>();
-			String key=null;
-			while (matcher.find()) {
-				String content = matcher.group(1);
-				if ("AQHB".equals(content)) {
-					key= or.getSafetyEnvProtection();
-				}else if ("JLR".equals(content)) {
-					key = or.getNetProfit();
-				}else if ("ZHDF".equals(content)) {
-					key = or.getCompositeScore();
-				}else if ("FJSX".equals(content)) {
-					key = or.getVeto();
+			String formula = collect.get(0).getExpression();
+			for (OrganizationRating or : orgMap.getValue()) {
+				if (or.getSafetyEnvProtection() == null || or.getSafetyEnvProtection().isEmpty() || or.getNetProfit() == null || or.getNetProfit().isEmpty() || or.getCompositeScore() == null || or.getCompositeScore().isEmpty() || or.getVeto() == null || or.getVeto().isEmpty()) {
+					continue;
 				}
-				if (key != null) {
-					replace = replace.replace("[" + content + "]", key);
+				String replace = formula;
+				Pattern pattern = Pattern.compile("\\[([^\\[\\]]+)\\]");//编译成模式
+				Matcher matcher = pattern.matcher(formula);
+				Map<String, String> placeholders = new HashMap<>();
+				String key = null;
+				while (matcher.find()) {
+					String content = matcher.group(1);
+					if ("AQHB".equals(content)) {
+						key = or.getSafetyEnvProtection();
+					} else if ("JLR".equals(content)) {
+						key = or.getNetProfit();
+					} else if ("ZHDF".equals(content)) {
+						key = or.getCompositeScore();
+					} else if ("FJSX".equals(content)) {
+						key = or.getVeto();
+					}
+					if (key != null) {
+						replace = replace.replace("[" + content + "]", key);
+					}
+					placeholders.put(key, content);
 				}
-				placeholders.put(key, content);
+				String form = replace;
+				CellValue cv = setFormula(st, xwb, form);
+				UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
+				uw.eq("id", or.getId()).set("scjy_rate", cv.formatAsString()).set("safety_env_protection", or.getSafetyEnvProtection())
+					.set("veto", or.getVeto()).set("net_profit", or.getNetProfit()).set("composite_score", or.getCompositeScore());
+				iOrganizationRatingService.update(uw);
 			}
-			String form = replace;
-			CellValue cv = setFormula(st, xwb, form);
-			UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
-			uw.eq("id", or.getId()).set("scjy_rate", cv.formatAsString()).set("safety_env_protection",or.getSafetyEnvProtection())
-				.set("veto",or.getVeto()).set("net_profit",or.getNetProfit()).set("composite_score",or.getCompositeScore());
-			iOrganizationRatingService.update(uw);
-		}}
+		}
 	}
 
 	/**
 	 * 前期评级
 	 */
-	private void calcQQXMrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating,Sheet st,XSSFWorkbook xwb) {
+	private void calcQQXMrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
 		List<OrganizationRatingRule> rules = list.stream().filter(orr -> "前期评级".equals(orr.getCheckCycle())).collect(Collectors.toList());
 		for (Map.Entry<String, List<OrganizationRating>> orgMap : orgRating.entrySet()) {
 			List<OrganizationRatingRule> collect = rules.stream().filter(rul -> orgMap.getKey().equals(rul.getBinSection())).collect(Collectors.toList());
 			if (collect.isEmpty()) {
 				continue;
 			}
-			String formula=collect.get(0).getExpression();
-		for (OrganizationRating or : orgMap.getValue()) {
-			if (or.getAnnualTarget() == null ||or.getAnnualTarget().isEmpty()|| or.getBonusPoint() == null||or.getBonusPoint().isEmpty()) {
-				continue;
-			}
-			String replace = formula;
-			Pattern pattern = Pattern.compile("\\[([^\\[\\]]+)\\]");
-			Matcher matcher = pattern.matcher(formula);
-			Map<String, String> placeholders = new HashMap<>();
-			String key=null;
-			while (matcher.find()) {
-				String content = matcher.group(1);
-				if ("NDMB".equals(content)) {
-					 key= or.getAnnualTarget();
-				}else if ("XJX".equals(content)) {
-					key = or.getBonusPoint();
+			String formula = collect.get(0).getExpression();
+			for (OrganizationRating or : orgMap.getValue()) {
+				if (or.getAnnualTarget() == null || or.getAnnualTarget().isEmpty() || or.getBonusPoint() == null || or.getBonusPoint().isEmpty()) {
+					continue;
 				}
-				if (key != null) {
-					replace = replace.replace("[" + content + "]", key);
+				String replace = formula;
+				Pattern pattern = Pattern.compile("\\[([^\\[\\]]+)\\]");
+				Matcher matcher = pattern.matcher(formula);
+				Map<String, String> placeholders = new HashMap<>();
+				String key = null;
+				while (matcher.find()) {
+					String content = matcher.group(1);
+					if ("NDMB".equals(content)) {
+						key = or.getAnnualTarget();
+					} else if ("XJX".equals(content)) {
+						key = or.getBonusPoint();
+					}
+					if (key != null) {
+						replace = replace.replace("[" + content + "]", key);
+					}
+					placeholders.put(key, content);
 				}
-				placeholders.put(key, content);
+				String form = replace;
+				CellValue cv = setFormula(st, xwb, form);
+				UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
+				uw.eq("id", or.getId()).set("qq_rate", cv.formatAsString()).set("annual_target", or.getAnnualTarget()).set("bonus_point", or.getBonusPoint());
+				iOrganizationRatingService.update(uw);
 			}
-			String form = replace;
-			CellValue cv = setFormula(st, xwb, form);
-			UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
-			uw.eq("id", or.getId()).set("qq_rate", cv.formatAsString()).set("annual_target",or.getAnnualTarget()).set("bonus_point",or.getBonusPoint());
-			iOrganizationRatingService.update(uw);
-		}}
+		}
 	}
 
 
 	@Override
 	public IPage<OrganizationRating> list(Integer pageNum, Integer pageSize, String id, String
 		organizationYearRatingId, String binSection, String year, String organizationShortName, String organizationId, String safetyEnvProtection,
-										  String veto, String netProfit, String compositeScore, String annualTarget, String bonusPoint,String compositeScoreRaking,String projectLevel) {
-		Page<OrganizationRatingRule> page = new Page<>(pageNum, pageSize);
+										  String veto, String netProfit, String compositeScore, String annualTarget, String bonusPoint, String compositeScoreRaking, String projectLevel) {
+		Page<OrganizationRating> page = new Page<>(pageNum, pageSize);
 		if (null == pageNum || null == pageSize) {
 			throw new RuntimeException("分页参数为空");
 		}
 		IPage<OrganizationRating> list = baseMapper.selectList(page, id, organizationYearRatingId, binSection, year, organizationShortName,
-			organizationId, safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint,compositeScoreRaking,projectLevel);
+			organizationId, safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint, compositeScoreRaking, projectLevel);
 		if (list.getRecords().isEmpty()) {
 			int c = iOrganizationRatingService.count();
 			if (c > 0) {
@@ -293,7 +454,7 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 			}
 			getOrgRatingInfo(organizationYearRatingId);
 			list = baseMapper.selectList(page, id, organizationYearRatingId, binSection, year, organizationShortName, organizationId,
-				safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint,compositeScoreRaking,projectLevel);
+				safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint, compositeScoreRaking, projectLevel);
 		}
 		return list;
 	}