Browse Source

修改bug

songwb 6 months ago
parent
commit
3ba12fe4a4

+ 54 - 16
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationPortalServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ims.eval.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ims.common.utils.DateUtils;
@@ -43,8 +44,8 @@ public class EvaluationPortalServiceImpl extends ServiceImpl<EvaluationPortalMap
 	@Autowired
 	private IEvaluationScoreCountService evaluationScoreCountService;
 
-	@Autowired
-	private EvaluationPortalMapper evaluationPortalMapper;
+//	@Autowired
+//	private EvaluationPortalMapper evaluationPortalMapper;
 
 	@Override
 	public Map<String, Object> getPortalData(String binSection, String year, String season,String newyear) {
@@ -149,23 +150,60 @@ public class EvaluationPortalServiceImpl extends ServiceImpl<EvaluationPortalMap
 		EvaluationPortal homeSeason = null;
 		EvaluationPortal homeYear = null;
 		try {
-			homeSeason = evaluationPortalMapper.getHomeSeason();
-			homeYear = evaluationPortalMapper.getHomeYear();
+			LambdaQueryWrapper<OrganizationEvaluation> lqw = new LambdaQueryWrapper<>();
+			LambdaQueryWrapper<OrganizationEvaluation> eq = lqw.eq(OrganizationEvaluation::getStage, "流程已结束");
+			List<OrganizationEvaluation> list = organizationEvaluationService.list(eq);
+			if (list == null || list.isEmpty()) {
+				hs.put("newyear","");
+				hs.put("year","");
+				hs.put("season","");
+				return hs;
+			}
+			Map<String, List<OrganizationEvaluation>> cc = list.stream().collect(Collectors.groupingBy(OrganizationEvaluation::getCheckCycle));
+			List<OrganizationEvaluation> jdkp = cc.get("JDKP");
+			List<OrganizationEvaluation> ndkp = cc.get("NDKP");
+			if ((jdkp == null || jdkp.isEmpty())&&(ndkp == null || ndkp.isEmpty())) {
+				hs.put("newyear","");
+				hs.put("year","");
+				hs.put("season","");
+				return hs;
+			}
+			if (jdkp.size() == 1) {
+				hs.put("year",jdkp.get(0).getYear());
+				hs.put("season",jdkp.get(0).getMonth());
+			}else {
+				Comparator<OrganizationEvaluation> comparator = Comparator.comparing(OrganizationEvaluation::getYear).thenComparing(OrganizationEvaluation::getMonth);
+				Collections.sort(jdkp,comparator.reversed());
+				OrganizationEvaluation latestData = jdkp.get(0);
+				hs.put("year",latestData.getYear());
+				hs.put("season",latestData.getMonth());
+			}
+			if (ndkp.size() == 1) {
+				hs.put("newyear",ndkp.get(0).getYear());
+			}else {
+				Comparator<OrganizationEvaluation> comparator = Comparator.comparing(OrganizationEvaluation::getYear);
+				Collections.sort(ndkp,comparator.reversed());
+				OrganizationEvaluation latestData = ndkp.get(0);
+				hs.put("newyear",latestData.getYear());
+			}
+
+//			homeSeason = evaluationPortalMapper.getHomeSeason();
+//			homeYear = evaluationPortalMapper.getHomeYear();
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
-
-		if(null != homeYear){
-			hs.put("newyear",homeYear.getYear());
-		}
-
-		if(null != homeSeason){
-			hs.put("year",homeSeason.getYear());
-			hs.put("season",homeSeason.getSeason());
-		}else {
-			hs.put("year",DateUtils.getYear(new Date())+"");
-			hs.put("season",DateUtils.getSeason(new Date())+"");
-		}
+//
+//		if(null != homeYear){
+//			hs.put("newyear",homeYear.getYear());
+//		}
+//
+//		if(null != homeSeason){
+//			hs.put("year",homeSeason.getYear());
+//			hs.put("season",homeSeason.getSeason());
+//		}else {
+//			hs.put("year",DateUtils.getYear(new Date())+"");
+//			hs.put("season",DateUtils.getSeason(new Date())+"");
+//		}
 
 		return hs;
 	}