| | |
| | | package com.ycl.calculate; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ycl.platform.domain.entity.CheckIndexFace; |
| | | import com.ycl.platform.domain.entity.TMonitor; |
| | | import com.ycl.platform.domain.result.HK.FaceDeviceSamplingResult; |
| | | import com.ycl.platform.domain.vo.TMonitorVO; |
| | | import com.ycl.platform.mapper.CheckIndexFaceMapper; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.service.ICheckIndexFaceService; |
| | | import com.ycl.platform.service.ITMonitorService; |
| | | import constant.ApiConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | * 更新或新增 |
| | | */ |
| | | @Component |
| | | public class FaceDeviceSampleCalculation extends IndexCalculationServe implements CalculationStrategy<FaceDeviceSamplingResult> { |
| | | @Slf4j |
| | | public class FaceDeviceSampleCalculation extends IndexCalculationServe<FaceDeviceSamplingResult, FaceDeviceSampleCalculation.AreaStats> implements CalculationStrategy<FaceDeviceSamplingResult> { |
| | | @Autowired |
| | | private CheckIndexFaceMapper checkIndexFaceMapper; |
| | | @Autowired |
| | | private ITMonitorService monitorService; |
| | | private TMonitorMapper monitorMapper; |
| | | @Autowired |
| | | private ICheckIndexFaceService checkIndexFaceService; |
| | | |
| | | //区域车辆抽检指标 |
| | | private static class AreaStats { |
| | | protected static class AreaStats { |
| | | int totalSites = 0; |
| | | //图片合格的点位数 |
| | | int picQualifySites = 0; |
| | |
| | | |
| | | @Override |
| | | public void calculate(List<FaceDeviceSamplingResult> list) { |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return; |
| | | } |
| | | //返回以国标码为key的设备map |
| | | //TODO:monitor去掉了deptId |
| | | Map<String, TMonitor> monitorMap = monitorService.list(new QueryWrapper<TMonitor>() |
| | | .in("serial_number", list.stream().map(FaceDeviceSamplingResult::getExternalIndexCode).collect(Collectors.toList()))) |
| | | .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity())); |
| | | //获取省厅国标码集合 |
| | | List<String> provinceIds = getProvince(); |
| | | Map<String, AreaStats> areaStatsMap = new HashMap<>(); |
| | | for (FaceDeviceSamplingResult result : list) { |
| | | TMonitor monitor = monitorMap.get(result.getExternalIndexCode()); |
| | | if (monitor == null) continue; |
| | | String deptId = monitor.getDeptId().toString(); |
| | | updateAreaStats(areaStatsMap, deptId, result); |
| | | |
| | | // 处理省厅数据 |
| | | if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) { |
| | | String provinceKey = "Province_" + deptId; |
| | | updateAreaStats(areaStatsMap, provinceKey, result); |
| | | } |
| | | } |
| | | //获取分区域的指标数量 |
| | | Map<String, FaceDeviceSampleCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list); |
| | | if (areaStatsMap == null) return; |
| | | |
| | | // 查询是否index表已经存在今日数据 |
| | | List<CheckIndexFace> checkIndexFaceList = checkIndexFaceMapper.selectToday(DateUtils.getDate()); |
| | |
| | | /** |
| | | * 累计抓拍数据准确设备数和设备总数 |
| | | */ |
| | | private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, FaceDeviceSamplingResult result) { |
| | | @Override |
| | | public void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, FaceDeviceSamplingResult result) { |
| | | //返回对象的引用,如果不存在会放入新的key,value |
| | | AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); |
| | | FaceDeviceSamplingResult.BigUsefulness bigUseful = result.getBigUseful(); |
| | | FaceDeviceSamplingResult.FaceEligibility faceElig = result.getFaceElig(); |
| | | FaceDeviceSamplingResult.FaceEligibility faceElig = result.getFaceEligibility(); |
| | | stats.totalSites++; |
| | | //90%及以上数据合格则此人脸设备被视为图片合格 |
| | | if (faceElig.getFaceEligPercent() >= 0.9) { |
| | | stats.picQualifySites++; |
| | | if (faceElig != null) { |
| | | if (faceElig.getFaceEligPercent() >= 0.9) { |
| | | stats.picQualifySites++; |
| | | } |
| | | } |
| | | //大图可用率大于90%视为合格 |
| | | if (bigUseful.getBigUsefulPercent() >= 0.9) { |
| | | stats.picUsabilitySites++; |
| | | if (bigUseful != null) { |
| | | if (bigUseful.getBigUsefulPercent() >= 0.9) { |
| | | stats.picUsabilitySites++; |
| | | } |
| | | } |
| | | } |
| | | |