| | |
| | | private Long deptId; |
| | | @TableField(exist = false) |
| | | private String deptName; |
| | | //设备数量 |
| | | private Integer deviceCount; |
| | | /** 考核模板id */ |
| | | @Excel(name = "考核模板id") |
| | | private Integer templateId; |
| | |
| | | package com.ycl.calculate; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ycl.platform.domain.entity.CheckIndexCar; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.result.HK.VehicleDeviceInspectionResult; |
| | | import com.ycl.platform.mapper.CheckIndexCarMapper; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.mapper.YwPointMapper; |
| | | import com.ycl.platform.service.ICheckIndexCarService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 计算车辆时钟准确性 |
| | |
| | | package com.ycl.calculate; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ycl.platform.domain.entity.CheckIndexCar; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.result.UY.MonitorQualifyResult; |
| | | import com.ycl.platform.mapper.CheckIndexCarMapper; |
| | | import com.ycl.platform.mapper.YwPointMapper; |
| | | import com.ycl.platform.service.ICheckIndexCarService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private CheckIndexCarMapper checkIndexCarMapper; |
| | | @Autowired |
| | | private ICheckIndexCarService checkIndexCarService; |
| | | |
| | | //区域车辆目录一致率的内部类 |
| | | protected static class AreaStats { |
| | | int totalSites = 0; |
| | |
| | | |
| | | // 查询是否index表已经存在今日数据 |
| | | List<CheckIndexCar> checkIndexCarList = checkIndexCarMapper.selectToday(DateUtils.getDate()); |
| | | |
| | | List<CheckIndexCar> checkIndexCars = new ArrayList<>(); |
| | | areaStatsMap.forEach((deptId, stats) -> { |
| | | if (stats.totalSites > 0) { |
| | |
| | | package com.ycl.calculate; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ycl.platform.base.CheckIndex; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.mapper.YwPointMapper; |
| | | import constant.ApiConstants; |
| | | import constant.CheckConstants; |
| | | import enumeration.general.PublishType; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Slf4j |
| | | public class IndexCalculationUtils { |
| | | |
| | | //检查是否存在当日数据 |
| | | public <T extends CheckIndex> T getCheckIndex(String key, List<T> checkIndexList, Class<T> clazz) { |
| | | T checkIndex; |
| | | |
| | | // 检查是否已存在今日数据 |
| | | Optional<T> existingIndex = checkIndexList.stream() |
| | | .filter(index -> key.startsWith(ApiConstants.Province) ? |
| | |
| | | return checkIndex; |
| | | } |
| | | |
| | | /** --------指标算法---------*/ |
| | | /** |
| | | * --------指标算法--------- |
| | | */ |
| | | |
| | | //一机一档合格率 |
| | | public BigDecimal monitorQualify(Map<String, Object> param) { |
| | |
| | | public BigDecimal viewConnectStability(Map<String, Object> param) { |
| | | BigDecimal totalDataSum = new BigDecimal((Integer) param.get("totalDataSum")); |
| | | BigDecimal lastCount = (BigDecimal) param.get("lastCount"); |
| | | log.info("视图库对接稳定性,totalDataSum:{},lastCount:{}",totalDataSum,lastCount); |
| | | log.info("视图库对接稳定性,totalDataSum:{},lastCount:{}", totalDataSum, lastCount); |
| | | return totalDataSum.divide(lastCount, 4, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | Integer distinctCount(@Param("query") DataCenterQuery query); |
| | | |
| | | /** |
| | | * 设备数量 |
| | | * @param examineCategory |
| | | * @param examineTag |
| | | * @return |
| | | */ |
| | | List<YwPointVO> selectToCount(Short examineCategory, Short examineTag); |
| | | |
| | | } |
| | |
| | | //权限控制 只能查看已发布 |
| | | roleControl(checkIndexCar); |
| | | checkIndexCar.setExamineTag(Short.valueOf(examineTag + "")); |
| | | if (examineTag == 0) { |
| | | checkIndexCar.setProvinceTag(Boolean.TRUE); |
| | | } |
| | | |
| | | checkIndexCars.addAll(indexCarService.selectCheckIndexCarList(checkIndexCar)); |
| | | } |
| | | //计算平均值放在excel最后 |
| | |
| | | //权限控制 只能查看已发布 |
| | | roleControl(checkIndexFace); |
| | | checkIndexFace.setExamineTag(Short.valueOf(examineTag + "")); |
| | | if (examineTag == 0) { |
| | | checkIndexFace.setProvinceTag(Boolean.TRUE); |
| | | } |
| | | checkIndexFaces.addAll(indexFaceService.selectCheckIndexFaceList(checkIndexFace)); |
| | | } |
| | | //计算平均值放在excel最后 |
| | |
| | | //权限控制 只能查看已发布 |
| | | roleControl(checkIndexVideo); |
| | | checkIndexVideo.setExamineTag(Short.valueOf(examineTag + "")); |
| | | if (examineTag == 0) { |
| | | checkIndexVideo.setProvinceTag(Boolean.TRUE); |
| | | }else if(examineTag ==2){ |
| | | //只有视频有公安部数据 |
| | | checkIndexVideo.setDeptTag(Boolean.TRUE); |
| | | } |
| | | checkIndexVideos.addAll(indexVideoService.selectCheckIndexVideoList(checkIndexVideo)); |
| | | } |
| | | //计算平均值放在excel最后 |
| | |
| | | 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; |
| | |
| | | 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(); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | </sql> |
| | | |
| | | <select id="selectCheckIndexCarList" resultMap="CheckIndexCarResult"> |
| | | select tcic.*,sd.dept_name,tcs.score,count(m.serial_number) as num |
| | | select tcic.*,sd.dept_name,tcs.score,IFNULL(tcs.device_count,0) as num |
| | | from t_check_index_car tcic left join sys_dept sd on tcic.dept_id = sd.dept_id |
| | | left join t_check_score tcs on tcic.id = tcs.index_id |
| | | left join t_yw_point p on p.dept_id = tcic.dept_id and p.examine_status = 1 |
| | | left join t_monitor m on p.serial_number = m.serial_number |
| | | <where> |
| | | tcs.examine_category = 2 and m.camera_fun_type like concat('%',2,'%') |
| | | tcs.examine_category = 2 |
| | | <if test="deptId != null "> and tcic.dept_id = #{deptId}</if> |
| | | <if test="examineTag != null "> and tcic.examine_tag = #{examineTag}</if> |
| | | <if test="provinceTag != null "> and p.province_tag = #{provinceTag}</if> |
| | | <if test="deptTag != null "> and p.dept_tag = #{deptTag}</if> |
| | | <if test="quarter != null and quarter.size > 0"> |
| | | and date_format(tcs.create_time, '%Y-%m') between #{quarter[0]} and #{quarter[1]} |
| | | </if> |
| | |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | group by tcic.id |
| | | order by tcic.examine_tag desc,sd.area_code,tcic.create_time |
| | | </select> |
| | | |
| | |
| | | </sql> |
| | | |
| | | <select id="selectCheckIndexFaceList" resultMap="CheckIndexFaceResult"> |
| | | select tcif.*,sd.dept_name,tcs.score,count(m.serial_number) as num |
| | | select tcif.*,sd.dept_name,tcs.score,IFNULL(tcs.device_count,0) as num |
| | | from t_check_index_face tcif left join sys_dept sd on tcif.dept_id = sd.dept_id |
| | | left join t_check_score tcs on tcif.id = tcs.index_id |
| | | left join t_yw_point p on p.dept_id = tcif.dept_id and p.examine_status = 1 |
| | | left join t_monitor m on p.serial_number = m.serial_number |
| | | <where> |
| | | tcs.examine_category = 3 and m.camera_fun_type like concat('%',3,'%') |
| | | tcs.examine_category = 3 |
| | | <if test="deptId != null "> and tcif.dept_id = #{deptId}</if> |
| | | <if test="examineTag != null "> and tcif.examine_tag = #{examineTag}</if> |
| | | <if test="provinceTag != null "> and p.province_tag = #{provinceTag}</if> |
| | | <if test="deptTag != null "> and p.dept_tag = #{deptTag}</if> |
| | | <if test="quarter != null and quarter.size > 0"> |
| | | and date_format(tcs.create_time, '%Y-%m') between #{quarter[0]} and #{quarter[1]} |
| | | </if> |
| | |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | group by tcif.id |
| | | order by tcif.examine_tag desc,sd.area_code,tcif.create_time |
| | | </select> |
| | | |
| | |
| | | </sql> |
| | | |
| | | <select id="selectCheckIndexVideoList" parameterType="CheckIndexVideo" resultMap="CheckIndexVideoResult"> |
| | | select tciv.*,sd.dept_name,tcs.score,count(m.serial_number) as num |
| | | select tciv.*,sd.dept_name,tcs.score,IFNULL(tcs.device_count,0) as num |
| | | from t_check_index_video tciv left join sys_dept sd on tciv.dept_id = sd.dept_id |
| | | left join t_check_score tcs on tciv.id = tcs.index_id |
| | | left join t_yw_point p on p.dept_id = tciv.dept_id and p.examine_status = 1 |
| | | left join t_monitor m on p.serial_number = m.serial_number |
| | | <where> |
| | | tcs.examine_category = 1 and m.camera_fun_type like concat('%',1,'%') |
| | | tcs.examine_category = 1 |
| | | <if test="deptId != null "> and tciv.dept_id = #{deptId}</if> |
| | | <if test="examineTag != null "> and tciv.examine_tag = #{examineTag}</if> |
| | | <if test="provinceTag != null "> and p.province_tag = #{provinceTag}</if> |
| | | <if test="deptTag != null "> and p.dept_tag = #{deptTag}</if> |
| | | <if test="quarter != null and quarter.size > 0"> |
| | | and date_format(tcs.create_time, '%Y-%m') between #{quarter[0]} and #{quarter[1]} |
| | | </if> |
| | |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | group by tciv.id |
| | | order by tciv.examine_tag desc,sd.area_code,tciv.create_time |
| | | </select> |
| | | <select id="getCheckIndexVideoList" parameterType="CheckIndexVideo" resultMap="CheckIndexVideoResult"> |
| | |
| | | </delete> |
| | | <select id="getLatest" resultType="com.ycl.platform.domain.entity.ImageResourceSecurity"> |
| | | select * from t_image_resource_security where dept_id = #{deptId} |
| | | where date_format(create_time,'%Y-%m') = DATE_FORMAT(#{date}, '%Y-%m') |
| | | where date_format(create_time,'%Y-%m') = date_format(#{date}, '%Y-%m') |
| | | order by create_time desc |
| | | limit 1 |
| | | </select> |
| | |
| | | camera_dept, hybm, lxbm,d.dept_id, d.dept_name from t_monitor m |
| | | left join t_yw_point p on m.serial_number = p.serial_number |
| | | left join sys_dept d on p.dept_id = d.dept_id |
| | | where m.serial_number in |
| | | where p.examine_status = 1 and m.serial_number in |
| | | <foreach collection="list" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | |
| | | serial_number, province_tag, important_tag, important_command_image_tag, dept_tag |
| | | </select> |
| | | |
| | | |
| | | <select id="selectToCount" resultType="com.ycl.platform.domain.vo.YwPointVO"> |
| | | select p.* from t_yw_point p |
| | | left join t_monitor m on p.serial_number = m.serial_number |
| | | <where> |
| | | p.examine_status = 1 and m.camera_fun_type like concat('%',#{examineCategory},'%') |
| | | <if test="examineTag == 0"> |
| | | and p.province_tag = 1 |
| | | </if> |
| | | <if test="examineTag == 2"> |
| | | and p.dept_tag = 1 |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |