From ec809f0f35973f5b86c8b5e7cccec8af0bc9803f Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期四, 31 十月 2024 15:09:12 +0800
Subject: [PATCH] 车辆属性一致率阈值bug

---
 ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java |   35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java b/ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java
index 43a2824..060b61a 100644
--- a/ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java
+++ b/ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java
@@ -7,6 +7,7 @@
 import com.ycl.platform.mapper.*;
 import com.ycl.platform.service.*;
 import constant.CheckConstants;
+import enumeration.general.PublishType;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
@@ -24,6 +25,7 @@
 
 @Slf4j
 @Component("checkScoreTask")
+//TODO锛氫慨鏀箂core銆乮ndex榛樿鍙戝竷
 public class CheckScoreTask {
     @Autowired
     private CheckTemplateMapper templateMapper;
@@ -32,16 +34,17 @@
     @Autowired
     private CheckScoreMapper scoreMapper;
     @Autowired
+    private ICheckScoreService checkScoreService;
+    @Autowired
     private CheckIndexVideoMapper videoMapper;
     @Autowired
     private CheckIndexFaceMapper faceMapper;
     @Autowired
     private CheckIndexCarMapper carMapper;
-
+    //鍏畨閮ㄥ彧鏈夎棰戣�冩牳
     public void executeTemplate(Integer templateId) {
         CheckTemplate checkTemplate = templateMapper.selectCheckTemplateById(templateId);
         if (checkTemplate != null) {
-            log.info("鎵ц鑰冩牳妯℃澘---------->{}", checkTemplate.getTemplateName());
             Short examineCategory = checkTemplate.getExamineCategory();
             Short examineTag = checkTemplate.getExamineTag();
             //鏌ユ潈閲�
@@ -51,7 +54,6 @@
             //鏌ヤ粖澶╃殑index鎸囨爣
             SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
             String day = dateFormat.format(new Date());
-
             //鍒涘缓score闆嗗悎鏂逛究鏈�鍚庢壒閲忓瓨鍌�
             List<CheckScore> scoreList = new ArrayList<>();
             //鏍规嵁鑰冩牳绫诲埆鍜岃�冩牳鏍囩锛屾煡涓嶅悓index琛紙鍖哄垎鐪佸巺鍖哄幙锛�
@@ -60,7 +62,7 @@
                 checkIndexVideo.setExamineTag(examineTag);
                 checkIndexVideo.setDay(day);
                 checkIndexVideo.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class));
-                //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�瑙嗛鏁版嵁
+                //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�鎴栧叕瀹夐儴瑙嗛鏁版嵁
                 List<CheckIndexVideo> checkIndexVideos = videoMapper.getCheckIndexVideoList(checkIndexVideo);
                 for (CheckIndexVideo indexVideo : checkIndexVideos) {
                     addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexVideo, CheckConstants.Rule_Category_Video);
@@ -70,7 +72,7 @@
                 checkIndexCar.setDay(day);
                 checkIndexCar.setExamineTag(examineTag);
                 checkIndexCar.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class));
-                //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�杞﹁締鏁版嵁
+                //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�鎴栧叕瀹夐儴杞﹁締鏁版嵁
                 List<CheckIndexCar> checkIndexCars = carMapper.getCheckIndexCarList(checkIndexCar);
                 for (CheckIndexCar indexCar : checkIndexCars) {
                     addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexCar, CheckConstants.Rule_Category_Car);
@@ -80,15 +82,29 @@
                 checkIndexFace.setDay(day);
                 checkIndexFace.setExamineTag(examineTag);
                 checkIndexFace.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class));
-                //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�浜鸿劯鏁版嵁
+                //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�鎴栧叕瀹夐儴浜鸿劯鏁版嵁
                 List<CheckIndexFace> checkIndexFaces = faceMapper.getCheckIndexFaceList(checkIndexFace);
                 for (CheckIndexFace indexFace : checkIndexFaces) {
                     addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace, CheckConstants.Rule_Category_Face);
                 }
             }
+
+            //鏌ュ嚭浠婂ぉ鐢熸垚score
+            List<CheckScore> todays = scoreMapper.selectToday(day);
+            //閬嶅巻scoreList闆嗗悎锛屽鏋滀粖澶╃敓鎴愯繃琛ュ厖id
+            for (CheckScore result : scoreList) {
+                for (CheckScore today : todays) {
+                    //鏍规嵁鑰冩牳鏍囩銆佽�冩牳绉嶇被銆侀儴闂╥d鏌ヨ鏄惁瀛樺湪浠婃棩鏁版嵁
+                    if(result.getExamineTag().equals(today.getExamineTag()) && result.getExamineCategory().equals(today.getExamineCategory()) && result.getDeptId().equals(today.getDeptId())){
+                        //琛ュ厖id锛屽悗缁牴鎹甶d saveOrUpdate
+                        result.setId(today.getId());
+                        result.setPublish(today.getPublish());
+                    }
+                }
+            }
             //鍌ㄥ瓨鍒嗘暟
-            if(!CollectionUtils.isEmpty(scoreList)) {
-                scoreMapper.saveBatch(scoreList);
+            if (!CollectionUtils.isEmpty(scoreList)) {
+                checkScoreService.saveOrUpdateBatch(scoreList);
             }
         }
     }
@@ -120,7 +136,7 @@
             BigDecimal score = index.multiply(templateRule.getWeight());
             scoreFinal = scoreFinal.add(score);
         } catch (Exception e) {
-            log.info("鍙嶅皠寮傚父", e.getMessage());
+            log.error("鍙嶅皠寮傚父", e.getMessage());
         }
         return scoreFinal;
     }
@@ -142,5 +158,6 @@
         checkScore.setDeptId(checkIndex.getDeptId());
         checkScore.setTemplateId(templateId);
         checkScore.setScore(scoreFinal);
+        checkScore.setPublish(PublishType.PUBLISHED.getCode());
     }
 }

--
Gitblit v1.8.0