Przeglądaj źródła

单位考评评级等级同步首页数据

xujuanning 6 miesięcy temu
rodzic
commit
eb8d718357

+ 6 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/controller/OrganizationRatingController.java

@@ -38,9 +38,13 @@ public class OrganizationRatingController {
 	private IOrganizationRatingService organizationRatingService;
 
 
+
+	/**
+	 * 单位考评评级
+	 */
 	@PostMapping(value = "grade")
 	public R grade(@RequestBody List<OrganizationRating> orgRating) {
-		IPage<OrganizationRating> grade = organizationRatingService.grade(orgRating);
+		List<OrganizationRating> grade = organizationRatingService.grade(orgRating);
 		return R.ok().data(grade);
 	}
 
@@ -71,7 +75,7 @@ public class OrganizationRatingController {
 				  @RequestParam(value = "bonusPoint", required = false) String bonusPoint,
 				  @RequestParam(value = "compositeScoreRaking", required = false) String compositeScoreRaking,
 				  @RequestParam(value = "projectLevel", required = false) String projectLevel) {
-		IPage<OrganizationRating> list = organizationRatingService.list(pageNum, pageSize, id, organizationYearRatingId, binSection, year, organizationShortName, organizationId, safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint,compositeScoreRaking,projectLevel);
+		IPage<OrganizationRating> list = organizationRatingService.list(pageNum, pageSize, id, organizationYearRatingId, binSection, year, organizationShortName, organizationId, safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint, compositeScoreRaking, projectLevel);
 		if (list.getRecords().isEmpty()) {
 			return R.ok().data("");
 		}

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

@@ -147,5 +147,9 @@ public class OrganizationRating extends Model {
 	 */
 	private String projectLevel;
 
+	/**
+	 * 总分
+	 */
+	private String score;
 
 }

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

@@ -31,8 +31,7 @@ public interface IOrganizationRatingService extends IService<OrganizationRating>
 
 	List<OrganizationRating> getListSating(String organizationYearRatingId, String year, String organizationId);
 
-	IPage<OrganizationRating> grade(List<OrganizationRating> orgRating);
-
+	List<OrganizationRating> grade(List<OrganizationRating> orgRating);
 
 	void exportExcel(HttpServletResponse response, String binSection, String year) throws IOException;
 

+ 24 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluateReportServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -65,6 +66,11 @@ public class EvaluateReportServiceImpl extends ServiceImpl<EvaluateReportMapper,
 
 	@Autowired
 	private  IPartyBuildingMultiplierService partyBuildingMultiplierService;
+
+
+	@Resource
+	private IOrganizationRatingService iOrganizationRatingService;
+
 	//考评结果报告
 	//按照业务类型生成
 	//业务阶综合展示
@@ -81,7 +87,7 @@ public class EvaluateReportServiceImpl extends ServiceImpl<EvaluateReportMapper,
 
 		OrganizationEvaluation evaluation = organizationEvaluationService.getById(organizationEvaluationId);
 		if (null == evaluation) {
-			throw new CustomException("没有此考评");
+			throw new CustomException("没有此考评");
 		}
 		//获取到对应组织考评规则
 		String evaluationRuleId = evaluation.getOrganizationEvaluationRuleId();
@@ -101,7 +107,7 @@ public class EvaluateReportServiceImpl extends ServiceImpl<EvaluateReportMapper,
 			.collect(Collectors.toMap(OrganizationEvaluationRule::getOrganizationId, rule -> rule));
 
 		for (BinSection bi : sections) {
-
+			IPage<OrganizationRating> orgRatingList = iOrganizationRatingService.list(1, 100000, null, null, bi.getSectionCode(), evaluation.getYear(), null, null, null, null, null, null, null, null, null, null);
 
 			EvaluateReport evaluateReport = new EvaluateReport();
 
@@ -494,6 +500,7 @@ public class EvaluateReportServiceImpl extends ServiceImpl<EvaluateReportMapper,
 					}
 				}else {
 					reportInfo.setScore(DoubleUtils.keepPrecision(zhScore, 2));
+
 					reportInfo.setDiscountScore(1.0);
 					portal.setScore(DoubleUtils.keepPrecision(zhScore, 2));//保存到首页排行
 				}
@@ -501,12 +508,27 @@ public class EvaluateReportServiceImpl extends ServiceImpl<EvaluateReportMapper,
 				evaluateRuleInfoList.add(reportInfo);
 			}
 
+			List<OrganizationRating> orlist = new ArrayList<>();
 			for (EvaluateReportInfo info : evaluateRuleInfoList) {
 				b = evaluateReportInfoService.saveOrUpdate(info);
 				if (!b) {
 					throw new CustomException("综合考核评分汇总明细存储失败");
 				}
+				if ("NDKP".equals(evaluation.getCheckCycle())) {
+					List<OrganizationRating> records = orgRatingList.getRecords();
+					if (records.isEmpty()) {
+						continue;
+					}
+					for (OrganizationRating or : records) {
+						if (info.getOrganizationName().equals(or.getOrganizationShortName()) && info.getOrganizationId().equals(or.getOrganizationId())) {
+							or.setScore(String.valueOf(info.getScore()));
+							orlist.add(or);
+						}
+					}
+				}
 			}
+			boolean orgRat = iOrganizationRatingService.saveOrUpdateBatch(orlist);
+			System.out.println(orgRat);
 
 			if(null !=portalList && portalList.size()>0){
 

+ 39 - 7
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ims.eval.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -164,21 +165,48 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 		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()) {
+			if (list.getRecords().isEmpty()) {
+				QueryWrapper<OrganizationEvaluation> q = new QueryWrapper<>();
+				q.eq("check_cycle", "NDKP");
+				List<OrganizationEvaluation> organizationEvaluations = baseMapper.selectList(q);
+				List<OrganizationEvaluation> ndkp = organizationEvaluations.stream().filter(yy -> "2023".equals(yy.getYear())).collect(Collectors.toList());
+				if (ndkp.isEmpty()) {
+					return null;
+				}
 				orgRating(ndkp.get(0));
+				IPage<OrganizationEvaluation> oeLs =baseMapper.selectPage(page, qw);
+				return filter(oeLs);
 			}
-			return baseMapper.selectPage(page, qw);
+			/*List<OrganizationEvaluation> dwpj = list.getRecords().stream().filter(ll -> "DWPJ".equals(ll.getCheckCycle())).collect(Collectors.toList());
+			if (!dwpj.isEmpty()) {
+				return baseMapper.selectPage(page, qw);
+			}*/
+			return filter(list);
 		}
 
 		return list;
 	}
 
 
+	/**
+	 * 判断年度考评是否“流程已结束”,年度考评结束的单位显示单位考评评级
+	 */
+	private IPage<OrganizationEvaluation> filter(IPage<OrganizationEvaluation> list) {
+		IPage<OrganizationEvaluation> ioe = new Page<>();
+		List<OrganizationEvaluation> ls = new ArrayList<>();
+		for (OrganizationEvaluation oe : list.getRecords()) {
+			LambdaQueryWrapper<OrganizationEvaluation> lqw = new LambdaQueryWrapper<>();
+			lqw.eq(OrganizationEvaluation::getCheckCycle, "NDKP").eq(OrganizationEvaluation::getYear, oe.getYear());
+			List<OrganizationEvaluation> loes = baseMapper.selectList(lqw);
+			if ("流程已结束".equals(loes.get(0).getStage())) {
+				ls.add(oe);
+			}
+		}
+		ioe.setRecords(ls);
+		return ioe;
+	}
+
+
 	@Override
 	public boolean saveOrUpdate(OrganizationEvaluation entity) {
 		//获取指定部门的规则
@@ -249,6 +277,10 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 		return b;
 	}
 
+
+	/**
+	 * 如果年度评级存在,单位评级不存在,则将年度评级的数据复制到单位评级
+	 */
 	private void orgRating(OrganizationEvaluation entity) {
 		if (!entity.getCheckCycle().equals("NDKP")) {
 			return;

+ 32 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationRatingServiceImpl.java

@@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.*;
+import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -57,6 +58,10 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 	@Resource
 	private IOrganizationRatingRuleService iOrganizationRatingRuleService;
 
+	@Resource
+	private IEvaluationPortalService iEvaluationPortalService;
+
+
 
 	/**
 	 * 导入
@@ -82,6 +87,7 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 			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);
+			savePortal(organizationRatings);
 			if (!binSection.equals(organizationRatings.get(0).getBinSection())) {
 				return R.error("请导入" + binSection + "的数据");
 			}
@@ -211,7 +217,7 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 	 * 单位考评评级
 	 */
 	@Override
-	public IPage<OrganizationRating> grade(List<OrganizationRating> orgRating) {
+	public List<OrganizationRating> grade(List<OrganizationRating> orgRating) {
 		XSSFWorkbook xwb = new XSSFWorkbook();
 		Sheet st = xwb.createSheet();
 		List<OrganizationRatingRule> rules = iOrganizationRatingRuleService.list(null);
@@ -228,7 +234,31 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
 		calcQQXMrating(rulesYear, col, st, xwb);
 		calcJJXMrating(rulesYear, col, st, xwb);
 		calcNDrating(rulesYear, orgRating, st, xwb);
-		return null;
+		Map<String, OrganizationRating> map = orgRating.stream().collect(Collectors.toMap(OrganizationRating::getId, Function.identity()));
+		List<OrganizationRating> organizationRatings = baseMapper.selectBatchIds(map.keySet());
+		savePortal(organizationRatings);
+		return organizationRatings;
+	}
+
+
+	/**
+	 * 保存数据到首页
+	 */
+	private void savePortal(List<OrganizationRating> organizationRatings) {
+		List<EvaluationPortal> lep = new ArrayList<>();
+		for (OrganizationRating or : organizationRatings) {
+			if (or.getYearRate() != null && or.getScore() != null) {
+				EvaluationPortal ep = new EvaluationPortal();
+				ep.setBinSection(or.getBinSection());
+				ep.setCompany(or.getOrganizationShortName());
+				ep.setGrade(or.getYearRate());
+				ep.setScore(Double.parseDouble(or.getScore()));
+				ep.setBaseScore(150.00);
+				ep.setYear(or.getYear());
+				lep.add(ep);
+			}
+		}
+		boolean b = iEvaluationPortalService.saveBatch(lep);
 	}