New file |
| | |
| | | package com.ycl.platform.domain.param.HK; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class TreeParam extends BaseParam{ |
| | | private String startDate; |
| | | private String endDate; |
| | | } |
New file |
| | |
| | | package com.ycl.platform.domain.result.HK; |
| | | |
| | | import com.ycl.platform.domain.result.BaseResult; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | //考核业务树 |
| | | @Data |
| | | public class HKTreeResult extends BaseResult { |
| | | //业务树类型 face/car |
| | | private String type; |
| | | |
| | | private List<Tree> treeList; |
| | | |
| | | /** |
| | | * 考核业务树 |
| | | */ |
| | | @Data |
| | | public static class Tree { |
| | | //业务树编码 |
| | | private String cTreeCode; |
| | | //业务树名称 |
| | | private String cTreeName; |
| | | private Integer cType; |
| | | private String open; |
| | | private String iSystem; |
| | | private Date dCreateTime; |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.hikvision.artemis.sdk.ArtemisHttpUtil; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | import com.ycl.platform.domain.param.HK.BaseParam; |
| | | import com.ycl.platform.domain.param.HK.FaceDetectParam; |
| | | import com.ycl.utils.DateUtils; |
| | | import com.ycl.utils.bean.BeanUtils; |
| | | import constant.ApiConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Modifier; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | |
| | | |
| | | /** |
| | | * 调用海康接口 |
| | | * 调用海康接口 基础数据平台 Post请求 |
| | | * |
| | | * @param apiUrl 接口地址:/api/dqd/service/rs/v2/data/faceDetect/query |
| | | * @param params 请求参数 |
| | |
| | | return dataList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 调用海康接口 基础数据平台 Get请求 |
| | | * |
| | | * @param apiUrl 接口地址: |
| | | * @param params 请求参数 |
| | | * @param resultType 响应结果接收类 |
| | | * @return 调用结果 |
| | | */ |
| | | public static <T> List<T> sendGetAPI(String host,String appKey,String appSecret,String apiUrl, BaseParam params, Class<T> resultType) { |
| | | // STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数. |
| | | ArtemisConfig.host = host; // 平台的ip端口 |
| | | ArtemisConfig.appKey = appKey; // 密钥appkey |
| | | ArtemisConfig.appSecret = appSecret;// 密钥appSecret |
| | | |
| | | // STEP2:设置OpenAPI接口的上下文 |
| | | final String ARTEMIS_PATH = "/artemis/aaoo"; |
| | | |
| | | // STEP3:设置接口的URI地址 |
| | | final String previewURLsApi = ARTEMIS_PATH + apiUrl; |
| | | Map<String, String> path = new HashMap<String, String>(2) { |
| | | { |
| | | put("https://", previewURLsApi); |
| | | } |
| | | }; |
| | | |
| | | // STEP4:设置参数提交方式 |
| | | // STEP5:组装请求参数 |
| | | Map<String, String> queryMap = object2Map(params); |
| | | log.info("请求参数"+queryMap); |
| | | // STEP6:调用接口 |
| | | String result = null; |
| | | List<T> dataList = new ArrayList<>(); |
| | | for (int i = 0; i < 10; i++) { |
| | | result = ArtemisHttpUtil.doGetArtemis(path, queryMap, null, null , null); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | log.info("请求结果"+jsonObject); |
| | | if(jsonObject.getString("code") == null || !ApiConstants.HKSuccessCode.equals(jsonObject.getString("code"))){ |
| | | log.error("请求失败{}",result); |
| | | dataList = null; |
| | | break; |
| | | } |
| | | List<T> resultList = HkApiUtil.getDataList(JSONObject.parseObject(result), resultType); |
| | | if(CollectionUtils.isEmpty(resultList) || resultList.size()<ApiConstants.HKPageSize) { |
| | | dataList.addAll(resultList); |
| | | break; |
| | | }else { |
| | | dataList.addAll(resultList); |
| | | params.setPageNo(params.getPageNo()+1); |
| | | } |
| | | } |
| | | |
| | | return dataList; |
| | | } |
| | | |
| | | //解析数据 |
| | | private static <T> List<T> getDataList(JSONObject jsonObject, Class<T> resultClass) { |
| | | if (jsonObject != null && ApiConstants.HKSuccessCode.equals(jsonObject.getString("code"))) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 实体对象转成Map |
| | | * @param obj 实体对象 |
| | | * @return |
| | | */ |
| | | public static Map<String, String> object2Map(Object obj) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | if (obj == null) { |
| | | return map; |
| | | } |
| | | Class clazz = obj.getClass(); |
| | | Field[] fields = clazz.getDeclaredFields(); |
| | | try { |
| | | for (Field field : fields) { |
| | | field.setAccessible(true); |
| | | map.put(field.getName(), field.get(obj).toString()); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * Map转成实体对象 |
| | | * @param map map实体对象包含属性 |
| | | * @param clazz 实体对象类型 |
| | | * @return |
| | | */ |
| | | public static Object map2Object(Map<String, Object> map, Class<?> clazz) { |
| | | if (map == null) { |
| | | return null; |
| | | } |
| | | Object obj = null; |
| | | try { |
| | | obj = clazz.newInstance(); |
| | | |
| | | Field[] fields = obj.getClass().getDeclaredFields(); |
| | | for (Field field : fields) { |
| | | int mod = field.getModifiers(); |
| | | if (Modifier.isStatic(mod) || Modifier.isFinal(mod)) { |
| | | continue; |
| | | } |
| | | field.setAccessible(true); |
| | | field.set(obj, map.get(field.getName())); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return obj; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | private final WorkOrderService workOrderService; |
| | | private final IYwThresholdService ywThresholdService; |
| | | |
| | | /** |
| | | * 图像检测生成工单 |
| | | * |
| | |
| | | public void monitorQualifyCheck(List<MonitorQualifyResult> dataList) { |
| | | List<WorkOrder> workOrderList = dataList.stream().map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | if (item.getSerialNumber().getError() |
| | | || item.getCivilCode().getError() |
| | | || item.getIntegrated_device().getError() |
| | | || item.getIp().getError() |
| | | || item.getJkdwlx().getError() |
| | | || item.getLatitude().getError() |
| | | || item.getLongitude().getError() |
| | | || item.getMacdz().getError() |
| | | || item.getSbzt().getError() |
| | | || item.getName().getError() |
| | | || item.getSxjcjqy().getError() |
| | | || item.getSxjgnlx().getError()) { |
| | | //TODO:待优云修复,避免工单 |
| | | MonitorQualifyResult.QualifyResult qualifyResult = new MonitorQualifyResult.QualifyResult(); |
| | | qualifyResult.setError(false); |
| | | item.setIntegrated_device(qualifyResult); |
| | | if (item.getSerialNumber() == null || item.getSerialNumber().getError() || |
| | | item.getCivilCode() == null || item.getCivilCode().getError() || |
| | | item.getIntegrated_device() == null || item.getIntegrated_device().getError() || |
| | | item.getIp() == null || item.getIp().getError() || |
| | | item.getJkdwlx() == null || item.getJkdwlx().getError() || |
| | | item.getLatitude() == null || item.getLatitude().getError() || |
| | | item.getLongitude() == null || item.getLongitude().getError() || |
| | | item.getMacdz() == null || item.getMacdz().getError() || |
| | | item.getSbzt() == null || item.getSbzt().getError() || |
| | | item.getName() == null || item.getName().getError() || |
| | | item.getSxjcjqy() == null || item.getSxjcjqy().getError() || |
| | | item.getSxjgnlx() == null || item.getSxjgnlx().getError()) { |
| | | this.genWorkOrder(workOrder, ErrorType.POINT_INFO_ERROR, item.getSerialNumber().getValue()); |
| | | } |
| | | return workOrder; |
| | |
| | | |
| | | @Autowired |
| | | private WorkOrderWhiteMapper workOrderWhiteMapper; |
| | | |
| | | /** |
| | | * 查询运维阈值 |
| | | * |
| | |
| | | } |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | //检查时钟准确率 |
| | | if (result.getSnapClock() != null) { |
| | | Float clockPercent = result.getSnapClock().getClockPercent(); |
| | | check(YwThreadConstants.Face_ClockPercent, clockPercent, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.LESS_THAN_EQ, ErrorType.CLOCK_RIGHT.getValue()); |
| | | } |
| | | //检查数据及时率 |
| | | if (result.getSnapTimely() != null) { |
| | | Float timelyPercent = result.getSnapTimely().getTimelyPercent(); |
| | | check(YwThreadConstants.Face_TimelyPercent, timelyPercent, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.LESS_THAN_EQ, ErrorType.DATA_TIMELY_ERROR.getValue()); |
| | | } |
| | | //检查持续无数据天数 |
| | | if (result.getContinueNoDataCount() != null) { |
| | | Integer continueNoDataCount = result.getContinueNoDataCount(); |
| | | check(YwThreadConstants.Face_ContinueNoDataCount, continueNoDataCount, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.MORE_THAN_EQ, ErrorType.LONG_DAY_NO_DATA.getValue()); |
| | | } |
| | | //检查不唯一数据量 |
| | | if (result.getSnapUnique() != null) { |
| | | Integer nouniqueCount = result.getSnapUnique().getNouniqueCount(); |
| | | check(YwThreadConstants.Face_NouniqueCount, nouniqueCount, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.MORE_THAN_EQ, ErrorType.NOT_UNIQUE_DATA_VOLUME.getValue()); |
| | | } |
| | | //检查人脸低评分率 |
| | | if (result.getSnapValidity() != null) { |
| | | Float lowScorePercent = result.getSnapValidity().getLowScorePercent(); |
| | | check(YwThreadConstants.Face_LowScorePercent, lowScorePercent, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.MORE_THAN_EQ, ErrorType.FACE_LOW.getValue()); |
| | | } |
| | | //检查建模失败率 |
| | | if (result.getSnapValidity() != null) { |
| | | Float failPercent = result.getSnapValidity().getFailPercent(); |
| | | check(YwThreadConstants.Face_FailPercent, failPercent, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.MORE_THAN_EQ, ErrorType.MODELING_FAIL.getValue()); |
| | | } |
| | | // 点位在线率 |
| | | if (2 == result.getSnapResult()) { |
| | | workOrder.setSerialNumber(result.getExternalIndexCode()); |
| | |
| | | Integer continueNoDataCount = result.getContinueNoDataCount(); |
| | | check(YwThreadConstants.Car_ContinueNoDataCount, continueNoDataCount, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.MORE_THAN_EQ, ErrorType.LONG_DAY_NO_DATA.getValue()); |
| | | //检查时钟准确率 |
| | | if (result.getSnapClock() != null) { |
| | | Float clockPercent = result.getSnapClock().getClockPercent(); |
| | | check(YwThreadConstants.Car_ClockPercent, clockPercent, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.LESS_THAN_EQ, ErrorType.CLOCK_RIGHT.getValue()); |
| | | } |
| | | //检查数据及时率 |
| | | if (result.getSnapTimely() != null) { |
| | | Float timelyPercentResult = result.getSnapTimely().getTimelyPercent(); |
| | | check(YwThreadConstants.Car_TimelyPercent, timelyPercentResult, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.LESS_THAN_EQ, ErrorType.DATA_TIMELY_ERROR.getValue()); |
| | | } |
| | | //检查不唯一数据量 |
| | | if (result.getSnapUnique() != null) { |
| | | Integer nouniqueCountResult = result.getSnapUnique().getNouniqueCount(); |
| | | check(YwThreadConstants.Car_NouniqueCount, nouniqueCountResult, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.MORE_THAN_EQ, ErrorType.NOT_UNIQUE_DATA_VOLUME.getValue()); |
| | | } |
| | | //检查白天未识别量 |
| | | if (result.getSnapPlate() != null) { |
| | | Integer dayNoNumberCountResult = result.getSnapPlate().getDayNoNumberCount(); |
| | | check(YwThreadConstants.Car_DayNoNumberCount, dayNoNumberCountResult, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.MORE_THAN_EQ, ErrorType.UNRECOGNIZED_DAY_VOLUME.getValue()); |
| | | } |
| | | //车辆主要属性一致率 |
| | | if (result.getIntegrity() != null) { |
| | | Integer noIntegrityCountResult = result.getIntegrity().getMainNoIntegrityCount(); |
| | | Integer dataCount = result.getDataCount(); |
| | | Double integrityRate = ((double)dataCount-noIntegrityCountResult)/dataCount; |
| | | check(YwThreadConstants.Car_NoIntegrityCount, integrityRate, result.getExternalIndexCode(), thresholdMap, workOrder, CompareType.LESS_THAN_EQ, ErrorType.CAR_SIX.getValue()); |
| | | } |
| | | // 点位在线率 |
| | | if (2 == result.getSnapResult()) { |
| | | workOrder.setSerialNumber(result.getExternalIndexCode()); |
| | |
| | | |
| | | /** |
| | | * 白名单详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | workOrderWhite.setErrorTypeList(errorTypeList); |
| | | return Result.ok().data(workOrderWhite); |
| | | } |
| | | |
| | | /** |
| | | * 工单白名单列表 |
| | | * |
| | |
| | | return Result.ok(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改工单白名单 |
| | | * |
| | |
| | | workOrderWhiteMapper.batchDelete(ids); |
| | | return Result.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 白名单导出 |
| | | * |
| | | * @param response |
| | | * @throws IOException |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 导入工单白名单 |
| | | * |
| | | * @param file |
| | | * @return |
| | | */ |
| | |
| | | // 将读取到的每一行存入reportDetails集合中 |
| | | dataList.add(excel); |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) {} |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | } |
| | | }).sheet().doRead(); |
| | | |
| | | if (CollectionUtils.isEmpty(dataList)) { |
| | |
| | | //把中文转换为数据库存储格式 |
| | | String errorText = ErrorType.getValueByDescription(desc); |
| | | //找不到抛出异常 |
| | | if(errorText == null) throw new RuntimeException("国标码为"+item.getSerialNumber()+"的设备故障类型有误"); |
| | | if (errorText == null) |
| | | throw new RuntimeException("国标码为" + item.getSerialNumber() + "的设备故障类型有误"); |
| | | errorDataList.add(errorText); |
| | | }); |
| | | white.setErrorType(String.join(",", errorDataList)); |
| | |
| | | } |
| | | return Result.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改白名单 |
| | | * |
| | |
| | | //把中文转换为数据库存储格式 |
| | | String errorText = ErrorType.getValueByDescription(desc); |
| | | //找不到抛出异常 |
| | | if(errorText == null) throw new RuntimeException("国标码为"+item.getSerialNumber()+"的设备故障类型有误"); |
| | | if (errorText == null) |
| | | throw new RuntimeException("国标码为" + item.getSerialNumber() + "的设备故障类型有误"); |
| | | errorDataList.add(errorText); |
| | | }); |
| | | white.setErrorType(String.join(",", errorDataList)); |
| | |
| | | * @param <T> |
| | | */ |
| | | @Override |
| | | public <T extends Comparable<T>> void check(String key, T value, String serialNumber, Map<String, YwThreshold> thresholds, WorkOrder workOrder, CompareType compareType,String errorType) { |
| | | public <T extends Comparable<T>> void check(String key, T value, String |
| | | serialNumber, Map<String, YwThreshold> thresholds, WorkOrder workOrder, CompareType compareType, String |
| | | errorType) { |
| | | Optional.ofNullable(value).ifPresentOrElse( |
| | | v -> { |
| | | YwThreshold ywThreshold = thresholds.get(key); |
| | |
| | | log.info("结束人脸设备抽检指标监测结果数据同步"); |
| | | } |
| | | |
| | | //业务树 |
| | | public void TreeTask() { |
| | | log.info("开始执行业务树数据"); |
| | | TreeParam param = new TreeParam(); |
| | | param.setStartDate("2024-12-06"); |
| | | param.setEndDate("2024-12-06"); |
| | | List<HKTreeResult> faceList = HkApiUtil.sendGetAPI(host,appKey,appSecret,"/api/third/timeTree", param, HKTreeResult.class); |
| | | // if (!CollectionUtils.isEmpty(faceList)) { |
| | | // //如果今天存在之前的数据先删除 |
| | | // Query query = new Query(Criteria |
| | | // .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | // DeleteResult result = mongoTemplate.remove(query, FaceDeviceSamplingResult.class); |
| | | // faceList.stream().forEach(item -> { |
| | | // if (Objects.nonNull(item.getExternalIndexCode())) { |
| | | // item.setNo(item.getExternalIndexCode()); |
| | | // } |
| | | // }); |
| | | // pointService.setDeviceTagByGB(faceList,CheckConstants.Rule_Category_Face); |
| | | // //存放在mongo中 |
| | | // mongoTemplate.insertAll(faceList); |
| | | // } |
| | | log.info("结束业务树数据"); |
| | | } |
| | | |
| | | //解析数据 |
| | | private <T> List<T> getDataList(JSONObject jsonObject, Class<T> resultClass, String message) { |
| | | if (jsonObject != null && ApiConstants.HKSuccessCode.equals(jsonObject.getString("code"))) { |
| | |
| | | List<TMonitorResult> monitorList = monitorMapper.getDistinctIP(); |
| | | //补充错误时间点 |
| | | Query onlineQuery = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | Map<String, TMonitorResult> mongoMap = mongoTemplate.find(onlineQuery, TMonitorResult.class).stream().collect(Collectors.toMap(TMonitorResult::getNo, Function.identity())); |
| | | Map<String, TMonitorResult> mongoMap = mongoTemplate.find(onlineQuery, TMonitorResult.class) |
| | | .stream() |
| | | .collect(Collectors.toMap(TMonitorResult::getNo, Function.identity(), (existing, replacement) -> replacement)); |
| | | for (TMonitorResult result : monitorList) { |
| | | TMonitorResult mongoData = mongoMap.get(result.getNo()); |
| | | if(mongoData!=null){ |
| | |
| | | package com.ycl.utils.bean; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.Modifier; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | |
| | | { |
| | | return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | deleted = 0 AND serial_number in |
| | | <foreach collection="gbList" open="(" separator="," close=")" item="no">#{no}</foreach> |
| | | GROUP BY |
| | | serial_number, province_tag_face,province_tag_car,province_tag_videogetTagsByGB, important_tag, important_command_image_tag, dept_tag |
| | | serial_number, province_tag_face,province_tag_car,province_tag_video, important_tag, important_command_image_tag, dept_tag |
| | | </select> |
| | | |
| | | <select id="selectToCount" resultType="com.ycl.platform.domain.vo.YwPointVO"> |