| | |
| | | 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; |
| | |
| | | @Autowired |
| | | private CheckScoreMapper scoreMapper; |
| | | @Autowired |
| | | private ICheckIndexVideoService videoService; |
| | | private CheckIndexVideoMapper videoMapper; |
| | | @Autowired |
| | | private ICheckIndexFaceService faceService; |
| | | private CheckIndexFaceMapper faceMapper; |
| | | @Autowired |
| | | private ICheckIndexCarService carService; |
| | | private CheckIndexCarMapper carMapper; |
| | | |
| | | //TODO:统一任务时间 |
| | | public void executeTemplate(Integer templateId) { |
| | | CheckTemplate checkTemplate = templateMapper.selectCheckTemplateById(templateId); |
| | | if (checkTemplate != null) { |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | if(!CollectionUtils.isEmpty(scoreList)) { |
| | | scoreMapper.saveBatch(scoreList); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | for (CheckTemplateRule templateRule : templateRuleList) { |
| | | //计算分数 |
| | |
| | | BigDecimal score = index.multiply(templateRule.getWeight()); |
| | | scoreFinal = scoreFinal.add(score); |
| | | } catch (Exception e) { |
| | | log.info("反射异常", e); |
| | | log.info("反射异常", e.getMessage()); |
| | | } |
| | | return scoreFinal; |
| | | } |