| | |
| | | import com.google.common.base.CaseFormat; |
| | | import com.ycl.platform.base.CheckIndex; |
| | | import com.ycl.platform.domain.entity.*; |
| | | import com.ycl.platform.domain.vo.YwPointVO; |
| | | import com.ycl.platform.mapper.*; |
| | | import com.ycl.platform.service.*; |
| | | import constant.CheckConstants; |
| | |
| | | |
| | | @Slf4j |
| | | @Component("checkScoreTask") |
| | | //TODO:修改score、index默认发布 |
| | | public class CheckScoreTask { |
| | | @Autowired |
| | | private CheckTemplateMapper templateMapper; |
| | |
| | | private CheckIndexFaceMapper faceMapper; |
| | | @Autowired |
| | | private CheckIndexCarMapper carMapper; |
| | | @Autowired |
| | | private YwPointMapper pointMapper; |
| | | //公安部只有视频考核 |
| | | public void executeTemplate(Integer templateId) { |
| | | CheckTemplate checkTemplate = templateMapper.selectCheckTemplateById(templateId); |
| | | if (checkTemplate != null) { |
| | | Short examineCategory = checkTemplate.getExamineCategory(); |
| | | Short examineTag = checkTemplate.getExamineTag(); |
| | | //用于补充数量 |
| | | List<YwPointVO> pointVOS= pointMapper.selectToCount(examineCategory, examineTag); |
| | | //查权重 |
| | | CheckTemplateRule checkTemplateRule = new CheckTemplateRule(); |
| | | checkTemplateRule.setCheckTemplateId(templateId); |
| | |
| | | //根据模板的考核标签查各区县对应省厅或市局或公安部视频数据 |
| | | 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,pointVOS); |
| | | } |
| | | } else if (CheckConstants.Rule_Category_Car.equals(examineCategory)) { |
| | | CheckIndexCar checkIndexCar = new 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,pointVOS); |
| | | } |
| | | } else if (CheckConstants.Rule_Category_Face.equals(examineCategory)) { |
| | | CheckIndexFace checkIndexFace = new CheckIndexFace(); |
| | |
| | | //根据模板的考核标签查各区县对应省厅或市局或公安部人脸数据 |
| | | List<CheckIndexFace> checkIndexFaces = faceMapper.getCheckIndexFaceList(checkIndexFace); |
| | | for (CheckIndexFace indexFace : checkIndexFaces) { |
| | | addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace, CheckConstants.Rule_Category_Face); |
| | | addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace, CheckConstants.Rule_Category_Face,pointVOS); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private <T extends CheckIndex> void addToList(Integer templateId, CheckTemplate checkTemplate, Short examineTag, List<CheckTemplateRule> templateRuleList, List<CheckScore> scoreList, T indexObject, Short checkCategory) { |
| | | private <T extends CheckIndex> void addToList(Integer templateId, CheckTemplate checkTemplate, Short examineTag, List<CheckTemplateRule> templateRuleList, List<CheckScore> scoreList, T indexObject, Short checkCategory, List<YwPointVO> pointVOS) { |
| | | CheckScore checkScore = new CheckScore(); |
| | | checkScore.setIndexId(indexObject.getId()); |
| | | BigDecimal scoreFinal = BigDecimal.ZERO; |
| | |
| | | scoreFinal = getScoreFinal(indexObject, scoreFinal, templateRule); |
| | | } |
| | | //补充checkScore |
| | | fillCheckScore(templateId, checkTemplate, examineTag, indexObject, checkScore, scoreFinal, checkCategory); |
| | | fillCheckScore(templateId, checkTemplate, examineTag, indexObject, checkScore, scoreFinal, checkCategory,pointVOS); |
| | | scoreList.add(checkScore); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //设置checkScore对象 |
| | | private void fillCheckScore(Integer templateId, CheckTemplate checkTemplate, Short examineTag, CheckIndex checkIndex, CheckScore checkScore, BigDecimal scoreFinal, Short checkCategory) { |
| | | private void fillCheckScore(Integer templateId, CheckTemplate checkTemplate, Short examineTag, CheckIndex checkIndex, CheckScore checkScore, BigDecimal scoreFinal, Short checkCategory, List<YwPointVO> pointVOS) { |
| | | //根据调整系数调整最终分数大小 |
| | | String adjustWay = checkTemplate.getAdjustWay(); |
| | | BigDecimal adjustCoefficient = checkTemplate.getAdjustCoefficient(); |
| | | if (CheckConstants.Multiply.equals(adjustWay)) { |
| | | scoreFinal = adjustCoefficient.multiply(scoreFinal).multiply(new BigDecimal(100)); |
| | | // scoreFinal = adjustCoefficient.multiply(scoreFinal).multiply(new BigDecimal(100)); |
| | | scoreFinal = adjustCoefficient.multiply(scoreFinal); |
| | | } else if (CheckConstants.Divided.equals(adjustWay)) { |
| | | //四舍五入保留小数后四位 |
| | | scoreFinal = scoreFinal.divide(adjustCoefficient, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); |
| | | // scoreFinal = scoreFinal.divide(adjustCoefficient, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); |
| | | scoreFinal = scoreFinal.divide(adjustCoefficient, 4, RoundingMode.HALF_UP); |
| | | } |
| | | checkScore.setCreateTime(new Date()); |
| | | checkScore.setExamineTag(Integer.parseInt(examineTag + "")); |
| | |
| | | checkScore.setTemplateId(templateId); |
| | | checkScore.setScore(scoreFinal); |
| | | checkScore.setPublish(PublishType.PUBLISHED.getCode()); |
| | | if(!CollectionUtils.isEmpty(pointVOS)) { |
| | | long count = pointVOS.stream().filter(ywPointVO -> checkIndex.getDeptId().equals(ywPointVO.getDeptId())).count(); |
| | | checkScore.setDeviceCount((int) count); |
| | | } |
| | | } |
| | | } |