From b14531e3b850fe6d2fa916ba7b88b3e2bd2ff30a Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期三, 11 九月 2024 16:47:48 +0800 Subject: [PATCH] OSD加标签 --- ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java | 52 +++++++++++++++------------------------------------- 1 files changed, 15 insertions(+), 37 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 78cb310..43a2824 100644 --- a/ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java +++ b/ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java @@ -4,15 +4,14 @@ import com.google.common.base.CaseFormat; import com.ycl.platform.base.CheckIndex; import com.ycl.platform.domain.entity.*; -import com.ycl.platform.mapper.CheckScoreMapper; -import com.ycl.platform.mapper.CheckTemplateMapper; -import com.ycl.platform.mapper.CheckTemplateRuleMapper; +import com.ycl.platform.mapper.*; import com.ycl.platform.service.*; import constant.CheckConstants; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.lang.reflect.Field; import java.math.BigDecimal; @@ -33,13 +32,11 @@ @Autowired private CheckScoreMapper scoreMapper; @Autowired - private MongoTemplate mongoTemplate; + private CheckIndexVideoMapper videoMapper; @Autowired - private ICheckIndexVideoService videoService; + private CheckIndexFaceMapper faceMapper; @Autowired - private ICheckIndexFaceService faceService; - @Autowired - private ICheckIndexCarService carService; + private CheckIndexCarMapper carMapper; public void executeTemplate(Integer templateId) { CheckTemplate checkTemplate = templateMapper.selectCheckTemplateById(templateId); @@ -64,9 +61,9 @@ checkIndexVideo.setDay(day); checkIndexVideo.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class)); //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�瑙嗛鏁版嵁 - List<CheckIndexVideo> checkIndexVideos = videoService.selectCheckIndexVideoList(checkIndexVideo); + List<CheckIndexVideo> checkIndexVideos = videoMapper.getCheckIndexVideoList(checkIndexVideo); for (CheckIndexVideo indexVideo : checkIndexVideos) { - addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexVideo,CheckConstants.Rule_Category_Video); + addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexVideo, CheckConstants.Rule_Category_Video); } } else if (CheckConstants.Rule_Category_Car.equals(examineCategory)) { CheckIndexCar checkIndexCar = new CheckIndexCar(); @@ -74,9 +71,9 @@ checkIndexCar.setExamineTag(examineTag); checkIndexCar.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class)); //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�杞﹁締鏁版嵁 - List<CheckIndexCar> checkIndexCars = carService.selectCheckIndexCarList(checkIndexCar); + List<CheckIndexCar> checkIndexCars = carMapper.getCheckIndexCarList(checkIndexCar); for (CheckIndexCar indexCar : checkIndexCars) { - addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexCar,CheckConstants.Rule_Category_Car); + addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexCar, CheckConstants.Rule_Category_Car); } } else if (CheckConstants.Rule_Category_Face.equals(examineCategory)) { CheckIndexFace checkIndexFace = new CheckIndexFace(); @@ -84,44 +81,25 @@ checkIndexFace.setExamineTag(examineTag); checkIndexFace.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class)); //鏍规嵁妯℃澘鐨勮�冩牳鏍囩鏌ュ悇鍖哄幙瀵瑰簲鐪佸巺鎴栧競灞�浜鸿劯鏁版嵁 - List<CheckIndexFace> checkIndexFaces = faceService.selectCheckIndexFaceList(checkIndexFace); + List<CheckIndexFace> checkIndexFaces = faceMapper.getCheckIndexFaceList(checkIndexFace); for (CheckIndexFace indexFace : checkIndexFaces) { addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace, CheckConstants.Rule_Category_Face); } } - //鍌ㄥ瓨鍒嗘暟 - scoreMapper.saveBatch(scoreList); - - - log.info("妯℃澘鎵ц瀹屾垚"); + if(!CollectionUtils.isEmpty(scoreList)) { + scoreMapper.saveBatch(scoreList); + } } - log.info("瀹氭椂浠诲姟鎵ц瀹屾垚"); - } - - - //鏌ongo鏁版嵁褰掓。鍒癿ysql - public void dataArchiving() { - //TODO:褰掓。check_index_car,鍖哄垎鐪佸巺甯傚眬锛屾瘡涓尯鍘夸竴鏉℃暟鎹� - CheckIndexCar checkIndexCar = new CheckIndexCar(); - //TODO:褰掓。check_index_face - CheckIndexFace checkIndexFace = new CheckIndexFace(); - //TODO:褰掓。check_index_video - CheckIndexVideo checkIndexVideo = new CheckIndexVideo(); - } private <T extends CheckIndex> void addToList(Integer templateId, CheckTemplate checkTemplate, Short examineTag, List<CheckTemplateRule> templateRuleList, List<CheckScore> scoreList, T indexObject, Short checkCategory) { CheckScore checkScore = new CheckScore(); + checkScore.setIndexId(indexObject.getId()); BigDecimal scoreFinal = BigDecimal.ZERO; - BigDecimal alarmScore = checkTemplate.getAlarmScore(); for (CheckTemplateRule templateRule : templateRuleList) { //璁$畻鍒嗘暟 scoreFinal = getScoreFinal(indexObject, scoreFinal, templateRule); - //TODO:鏍规嵁鎶ヨ鍒嗘暟闃堝�硷紝娣诲姞鎶ヨ淇℃伅 - if(scoreFinal.compareTo(alarmScore)<0){ - - } } //琛ュ厖checkScore fillCheckScore(templateId, checkTemplate, examineTag, indexObject, checkScore, scoreFinal, checkCategory); @@ -142,7 +120,7 @@ BigDecimal score = index.multiply(templateRule.getWeight()); scoreFinal = scoreFinal.add(score); } catch (Exception e) { - log.info("鍙嶅皠寮傚父", e); + log.info("鍙嶅皠寮傚父", e.getMessage()); } return scoreFinal; } -- Gitblit v1.8.0