diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmHandleConstant.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmHandleConstant.java index 2694dbd..f5fa4b6 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmHandleConstant.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmHandleConstant.java @@ -26,7 +26,7 @@ public interface AlarmHandleConstant { String FAULT = "3"; /**预警**/ - Long EARLY_WARNING = 20L; + Long EARLY_WARNING = 30L; String WEBSOCKET_FAULT = "3"; diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java index 24442c8..a938a80 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java @@ -49,6 +49,12 @@ public class AlarmEntity extends TenantEntity { @ApiModelProperty(value = "告警内容") private String alarmContext; + @ApiModelProperty(value = "初步分析原因") + private String diagReason; + + @ApiModelProperty(value = "建议处置方式") + private String diagSolution; + @ApiModelProperty(value = "告警状态") private Integer alarmStatus; diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpDiagnoseClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpDiagnoseClient.java index 5073e28..49532f3 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpDiagnoseClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IFdpDiagnoseClient.java @@ -34,5 +34,5 @@ public interface IFdpDiagnoseClient { @PostMapping(GET_HISTORY_DATA) List getHistoryData(@RequestBody FDPFaultTableDTO req); @PostMapping(SET_FAULT_STATUS_INFO) - R setFaultStatusInfo(Map map); + R setFaultStatusInfo(@RequestBody Map map); } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/dto/RobotTaskVideoDTO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/dto/RobotTaskVideoDTO.java new file mode 100644 index 0000000..0c3e53e --- /dev/null +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/dto/RobotTaskVideoDTO.java @@ -0,0 +1,31 @@ +package com.hnac.hzinfo.inspect.task.dto; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@Data +@EqualsAndHashCode +public class RobotTaskVideoDTO implements Serializable { + + /** + * 巡检任务ID + */ + @NotNull + private Long taskId; + + /** + * 巡检机器人ID + */ + @NotNull + private Long userId; + + /** + * 视频记录类型 1为开始 2为结束 + */ + @NotNull + private Integer recordType; + +} diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java index 42dd88a..df18dbe 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java @@ -193,4 +193,20 @@ public class TaskEntity extends TenantEntity { @QueryField(condition = SqlCondition.EQUAL) private Boolean pushStatus; + @ApiModelProperty(value = "视频录制开始时间") + private LocalDateTime videoStartTime; + + @ApiModelProperty(value = "视频录制结束时间") + private LocalDateTime videoEndTime; + + @ApiModelProperty(value = "手动录制视频地址") + private String videoUrl; + + @ApiModelProperty(value = "海康录制视频任务ID") + private String hikVideoTaskId; + + @TableField(exist = false) + @ApiModelProperty(value = "机器人第一视角MP4地址") + private String perspectiveUrl; + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpHistoryDataController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpHistoryDataController.java index c29bf40..ce5abfd 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpHistoryDataController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpHistoryDataController.java @@ -10,6 +10,7 @@ import com.hnac.hzims.fdp.dto.FDPFaultTableDTO; import com.hnac.hzims.fdp.dto.FdpTaskDTO; import com.hnac.hzims.fdp.entity.FdpFaultHistoryDataEntity; import com.hnac.hzims.fdp.entity.FdpTaskEntity; +import com.hnac.hzims.fdp.service.IFdpFocusSurveillanceService; import com.hnac.hzims.fdp.service.IFdpHistoryDataService; import com.hnac.hzims.fdp.service.IFdpTaskService; import com.hnac.hzims.fdp.vo.FdpTaskVO; @@ -32,6 +33,8 @@ import org.springblade.core.tool.utils.StringUtil; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.HashMap; +import java.util.Map; /** * 故障诊断任务表 @@ -46,6 +49,8 @@ import javax.validation.Valid; public class FdpHistoryDataController extends BladeController { private final IFdpHistoryDataService service; + + private final IFdpFocusSurveillanceService fdpFocusSurveillanceService; /** * 分页 */ @@ -61,5 +66,18 @@ public class FdpHistoryDataController extends BladeController { } + /** + * 分页 + */ + @ApiLog + @PostMapping("/updateFaultHistory") + @ApiOperationSupport(order = 50) + @ApiOperation(value = "分页 查询参数:name,emId,faultId,reasonId,satisfaction") + @OperationAnnotation(moduleName = "智能诊断",title = "智能诊断任务",operatorType = OperatorType.MOBILE,businessType = + BusinessType.GENCODE, + action = "分页查询智能诊断任务列表") + public R> updateFaultHistory(@RequestBody Map map) { + return fdpFocusSurveillanceService.setFaultStatusInfo(map); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java index 23a796a..9defa4c 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java @@ -194,7 +194,7 @@ public class FdpMonitorController extends BladeController { @ApiOperationSupport(order = 160) @ApiOperation(value = "数据追溯") public R dataBack(@RequestBody DataBackVo vo) { - service.dataBackV2(vo.getFaultId()); +// service.dataBackV2(vo.getFaultId()); return service.dataBackV2(vo.getFaultId()); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpDiagnoseClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpDiagnoseClient.java index 03f1c07..1011563 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpDiagnoseClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/FdpDiagnoseClient.java @@ -11,6 +11,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -42,7 +43,7 @@ public class FdpDiagnoseClient implements IFdpDiagnoseClient { @Override @PostMapping(SET_FAULT_STATUS_INFO) - public R setFaultStatusInfo(Map map) { + public R setFaultStatusInfo(@RequestBody Map map) { return iFdpFocusSurveillanceService.setFaultStatusInfo(map); } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFocusSurveillanceServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFocusSurveillanceServiceImpl.java index 1f0bfd9..44891f0 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFocusSurveillanceServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpFocusSurveillanceServiceImpl.java @@ -33,18 +33,6 @@ import java.util.*; @Service @RequiredArgsConstructor public class FdpFocusSurveillanceServiceImpl implements IFdpFocusSurveillanceService { - private final FdpDeviceMapper fdpDeviceMapper; - private final IEmInfoService emInfoService; - private final IAnalyseInstanceClient deviceInstanceClient; - private final IAnalyseInstanceClient analyseInstanceClient; - private final IRealDataSearchClient realDataSearchClient; - private final IAnalyseDataSearchClient deviceDataSearchClient; - private final IFdpTaskService fdpTaskService; - private final IDiagnoseProxy diagnoseProxy; - private final FdpMonitorNoScopeMapper fdpMonitorNoScopeMapper; - private final IStationClient stationClient; - private final IFdpFaultService fdpFaultService; - private final RedisTemplate redisTemplate; @Value("${url.setFaultStatusInfo}") public String setFaultStatusInfo; @@ -56,6 +44,7 @@ public class FdpFocusSurveillanceServiceImpl implements IFdpFocusSurveillanceSer */ @Override public R setFaultStatusInfo( Map map) { +// map.put("diag_reason",""); String post = HttpRequestUtil.postCallObjectParam(map, setFaultStatusInfo, "POST"); R r = JSONObject.parseObject(post, new TypeReference() {{}}); return r; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpHistoryDataServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpHistoryDataServiceImpl.java index 9859103..3f28c81 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpHistoryDataServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpHistoryDataServiceImpl.java @@ -50,7 +50,7 @@ public class FdpHistoryDataServiceImpl implements IFdpHistoryDataService { @Override public R> getHistoryData(FDPFaultTableDTO req) { IPage page = new Page<>(); - page.setSize(req.getPageSize()); + page.setSize(req.getPageSize()-1); page.setCurrent(req.getPageIndex()); req.setOrderBy("CREATE_TIME"); if (StringUtil.isBlank(req.getSource())){ diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpListTableDataServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpListTableDataServiceImpl.java index 03eb3c1..9ba5b68 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpListTableDataServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpListTableDataServiceImpl.java @@ -73,9 +73,9 @@ public class FdpListTableDataServiceImpl implements IFdpListTableDataService { public R getListByProperty(FDPFaultListInfoDTO req) { IPage page = new Page<>(); page.setSize(req.getPageSize()); - page.setCurrent(req.getPageIndex()); + page.setCurrent(req.getPageIndex()-1); req.setDisplay(1); - req.setIsRoot(1); + req.setIsRoot(0); req.setOrderBy("NAME"); req.setOrderKind("desc"); String result = HttpRequestUtil.postCallObjectParam(req, getNeoFaultTableData, "POST"); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java index 393d0fc..041b7b6 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java @@ -392,12 +392,12 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(FdpFaultEntity::getFdpId, taskDTO.getFaultId()).last("limit 1"); - FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper); - if (ObjectUtil.isEmpty(fdpFaultEntity)) { - throw new ServiceException("获取对应故障对象失败"); - } +// LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq(FdpFaultEntity::getFdpId, taskDTO.getFaultId()).last("limit 1"); +// FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper); +// if (ObjectUtil.isEmpty(fdpFaultEntity)) { +// throw new ServiceException("获取对应故障对象失败"); +// } //拿到最近一次未完成的任务 FdpTaskEntity fdpTaskEntity = fdpTaskService.getOne(new LambdaQueryWrapper() {{ eq(FdpTaskEntity::getFaultId, taskDTO.getFaultId()); @@ -440,7 +440,7 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(FdpFaultEntity::getFdpId, diagnoseFaultReq.getFaultId()).last("limit 1"); - FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper); - if (ObjectUtil.isEmpty(fdpFaultEntity)) { - throw new ServiceException("获取对应故障对象失败"); - } - Boolean hasKey = redisTemplate.hasKey(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId().toString()); - //Redis中不存在,该任务过期 - if (!hasKey) { - return R.fail("该任务已过期,请重新生成任务"); +// /**获取故障对象**/ +// LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq(FdpFaultEntity::getFdpId, diagnoseFaultReq.getFaultId()).last("limit 1"); +// FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper); +// if (ObjectUtil.isEmpty(fdpFaultEntity)) { +// throw new ServiceException("获取对应故障对象失败"); +// } + if(StringUtil.isNotBlank(diagnoseFaultReq.getTaskId())){ + Boolean hasKey = redisTemplate.hasKey(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId().toString()); + //Redis中不存在,该任务过期 + if (!hasKey) { + return R.fail("该任务已过期,请重新生成任务"); + } } + /**更新故障状态**/ DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq(); /**推送数据**/ @@ -608,14 +611,15 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java index f8fe32b..88ccba6 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java @@ -63,6 +63,7 @@ public class AlarmHandleFlowServiceImpl extends BaseServiceImpl map = new HashMap<>(); + map.put("uuid", alarmHandleFlowEntity.getAlarmId()); if (1l == alarmHandleFlowEntity.getHandleWay()) { //如果是误诊,把处理结果复制到误报原因 alarmHandleFlowEntity.setFalseAlarmDesc(alarmHandleFlowEntity.getDealDesc()); @@ -77,6 +80,18 @@ public class AlarmHandleFlowServiceImpl extends BaseServiceImpllambdaUpdate() + .set(AlarmHandleEntity::getHandleWay, alarmHandleFlowEntity.getHandleWay()) + .set(AlarmHandleEntity::getDelayCause, alarmHandleFlowEntity.getDelayCause()) + .set(AlarmHandleEntity::getDelayTime, alarmHandleFlowEntity.getDelayTime()) + .eq(AlarmHandleEntity::getAlarmId, alarmHandleFlowEntity.getAlarmId())); + map.put("result", "延后处理"); + map.put("result_info", alarmHandleFlowEntity.getDealDesc()); + map.put("diag_solution",""); } else { //流程结束把告警状态修改为结束 alarmHandleFlowEntity.setHandleWay(6L); @@ -85,13 +100,12 @@ public class AlarmHandleFlowServiceImpl extends BaseServiceImpl map = new HashMap<>(); - map.put("uuid", alarmHandleFlowEntity.getAlarmId()); - map.put("result", alarmHandleFlowEntity.getHandleWay()); - map.put("result_info", alarmHandleFlowEntity.getDealDesc()); //流程结束后才,调用fdp修改状态的接口 R r = iFdpDiagnoseClient.setFaultStatusInfo(map); if (!r.isSuccess()) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index 23a6ebc..17310fe 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -74,21 +74,6 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl map=new HashMap<>(); - map.put("uuid",param.getAlarmId()); - map.put("result",param.getHandleWay()); - if (1l==way){ - map.put("result_info",param.getFalseAlarmDesc()); - } else if (2l==way){ - map.put("result_info",param.getDelayCause()); - } - R r = iFdpDiagnoseClient.setFaultStatusInfo(map); - if (!r.isSuccess()){ - throw new ServiceException("修改告警状态异常,请稍后重试!"); - } - } // 处理记录 AlarmHandleEntity entity = new AlarmHandleEntity(); entity.setAlarmId(param.getAlarmId()); @@ -112,6 +97,25 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl map=new HashMap<>(); + map.put("uuid",param.getAlarmId()); + if (1l==way){ + map.put("result","误报"); + map.put("diag_solution",param.getFalseAlarmDesc()); + } else if (2l==way){ + map.put("result","延后处理"); + map.put("result_info",param.getDelayCause()); + }else { + map.put("result","处理中"); + } + R r = iFdpDiagnoseClient.setFaultStatusInfo(map); + if (!r.isSuccess()){ + log.error("setFaultStatusInfo接口修改处理状态异常,参数为:"+param); + throw new ServiceException("修改告警状态异常,请稍后重试!"); + } + } //开启流程 if (AlarmHandleConstant.HANDLE.contains(way)) { alarmHandleFlowMapper.insert(param); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java index 9e8d089..ca23e68 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java @@ -93,6 +93,8 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { entity.setAlarmStatus(Integer.valueOf(item.getStatus())); entity.setAlarmValue(item.getInfo()); entity.setStationId(item.getStation()); + entity.setDiagReason(item.getDiagReason()); + entity.setDiagSolution(item.getDiagSolution()); entity.setAlarmSource(EARLY_WARNING); entity.setTenantId("200000"); R stationByCode = stationClient.getStationByCode(item.getStation()); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/constants/HikApiConstants.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/constants/HikApiConstants.java new file mode 100644 index 0000000..e263e76 --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/constants/HikApiConstants.java @@ -0,0 +1,21 @@ +package com.hnac.hzinfo.inspect.hikVideo.constants; + + +public interface HikApiConstants { + + /** + * 开始手动录像 89ca6c11cc0f40bd89b9653bb4398bc1 + */ + String MANUAL_RECORD_START = "/api/video/v1/manualRecord/start"; + + /** + * 停止手动录像 + */ + String MANUAL_RECORD_STOP = "/api/video/v1/manualRecord/stop"; + + /** + * 获取监控点回放取流URL + */ + String PLAY_BACK_URLS = "/api/video/v2/cameras/playbackURLs"; + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/controller/HikVideoController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/controller/HikVideoController.java new file mode 100644 index 0000000..b2805ff --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/controller/HikVideoController.java @@ -0,0 +1,23 @@ +package com.hnac.hzinfo.inspect.hikVideo.controller; + +import com.hnac.hzinfo.inspect.hikVideo.service.IHikApiService; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping("/hik/api") +public class HikVideoController { + + private final IHikApiService hikApiService; + + @GetMapping("/manualCapture") + public R manualCapture(@RequestParam String pointCode) { + return R.data(hikApiService.manualCapture(pointCode)); + } + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/note.md b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/note.md new file mode 100644 index 0000000..bc4778e --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/note.md @@ -0,0 +1 @@ +## 海康威视Api调用 \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/PlaybackRequest.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/PlaybackRequest.java new file mode 100644 index 0000000..f600078 --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/PlaybackRequest.java @@ -0,0 +1,62 @@ +package com.hnac.hzinfo.inspect.hikVideo.request; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode +public class PlaybackRequest implements Serializable { + + /** + * 监控点唯一标识,[分页获取监控点资源]@[软件产品-综合安防管理平台-API列表-视频应用服务-视频资源#分页获取监控点资源]接口获取返回参数cameraIndexCode + */ + private String cameraIndexCode; + + /** + * 存储类型,0:中心存储 1:设备存储 默认为中心存储 + */ + private String recordLocation = "1"; + + /** + * 取流协议(应用层协议), “hik”:HIK私有协议,使用视频SDK进行播放时, + * 传入此类型; “rtsp”:RTSP协议;“rtmp”:RTMP协议;“hls”:HLS协议“hls”:HLS协议(HLS协议只支持海康SDK协议、EHOME协议、ONVIF协议接入的设备;只支持H264视频编码和AAC音频编码;云存储版本要求v2.2.4及以上的2.x版本,或v3.0.5及以上的3.x版本;ISC版本要求v1.2.0版本及以上,需在运管中心-视频联网共享中切换成启动平台外置VOD)。 + * 参数不填,默认为HIK协议 + */ + private String protocol = "httpflv"; + + /** + * 传输协议(传输层协议)0:UDP 1:TCP 默认为tcp,在protocol设置为rtsp或者rtmp时有效 注:EHOME设备回放只支持TCP传输 GB28181 2011及以前版本只支持UDP传输 + */ + private Integer transmode = 1; + + /** + * 开始查询时间(IOS8601格式:yyyy-MM-dd'T'HH:mm:ss.SSSXXX) 例如北京时间: 2017-06-14T00:00:00.000+08:00,参考[附录BISO8601时间格式说明]@[软件产品-综合安防管理平台-附录#附录BISO8601时间格式说明] + */ + private String beginTime; + + /** + * 结束查询时间,开始时间和结束时间相差不超过三天; (IOS8601格式:yyyy-MM-dd'T'HH:mm:ss.SSSXXX)例如北京时间: 2017-06-15T00:00:00.000+08:00,参考[附录BISO8601时间格式说明]@[软件产品-综合安防管理平台-附录#附录BISO8601时间格式说明] + */ + private String endTime; + + /** + * 分页查询id,上一次查询返回的uuid,用于继续查询剩余片段,默认为空字符串。当存储类型为设备存储时,该字段生效,中心存储会一次性返回全部片段。 + */ + private String uuid; + + /** + * 扩展内容,格式:key=value, 调用方根据其播放控件支持的解码格式选择相应的封装类型; 支持的内容详见[附录F expand扩展内容说明]@[软件产品-综合安防管理平台-附录-附录F expand扩展内容说明] + */ + private String expand; + /** + * 输出码流转封装格式,“ps”:PS封装格式、“rtp”:RTP封装协议。当protocol=rtsp时生效,且不传值时默认为RTP封装协议 + */ + private String streamform; + + /** + * 查询录像的锁定类型,0-查询全部录像;1-查询未锁定录像;2-查询已锁定录像,不传默认值为0。通过[录像锁定与解锁]@[软件产品-综合安防管理平台-API列表-视频应用服务-视频能力#查询预置点信息#录像锁定与解锁]接口来进行录像锁定与解锁。 + */ + private Integer lockType; +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/RecordStartRequest.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/RecordStartRequest.java new file mode 100644 index 0000000..7eec0cd --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/RecordStartRequest.java @@ -0,0 +1,32 @@ +package com.hnac.hzinfo.inspect.hikVideo.request; + + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode +public class RecordStartRequest implements Serializable { + + /** + * 监控点唯一标识, + * [分页获取监控点资源]@[软件产品-综合安防管理平台-API列表-视频应用服务-视频资源#分页获取监控点资源] + * 接口获取返回参数cameraIndexCode + */ + private String cameraIndexCode; + + /** + * 录像类型: 范围:0-65535, + * 参考[附录A.31 录像类型]@[软件产品-综合安防管理平台-附录-附录A 数据字典#附录A.31 录像类型], + * 中心存储必填,设备存储不填 + */ + private Integer recordType; + + /** + * 下发的存储类型。0-中心存储 1-设备存储。如果不传入,默认为0-中心存储 + */ + private Integer type = 1; + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/RecordStopRequest.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/RecordStopRequest.java new file mode 100644 index 0000000..6466ef5 --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/request/RecordStopRequest.java @@ -0,0 +1,32 @@ +package com.hnac.hzinfo.inspect.hikVideo.request; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode +public class RecordStopRequest implements Serializable { + + /** + * 监控点唯一标识, + * [分页获取监控点资源]@[软件产品-综合安防管理平台-API列表-视频应用服务-视频资源#分页获取监控点资源]接口 + * 获取返回参数cameraIndexCode + */ + private String cameraIndexCode; + + /** + * 手动录像编号, + * 从[开始手动录像]@[软件产品-综合安防管理平台-API列表-视频应用服务-视频能力#开始手动录像]接口 + * 获取返回参数taskID,由于一个监控点同种存储类型同一时间只能进行一个手动录像任务, + * taskID不传入时,根据监控点编号和存储类型停止手动录像。 + */ + private String taskID; + + /** + * 下发的存储类型,0-中心存储 1-设备存储 如果不传入,默认为0-中心存储 + */ + private Integer type = 1; + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/service/IHikApiService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/service/IHikApiService.java new file mode 100644 index 0000000..80b7238 --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/service/IHikApiService.java @@ -0,0 +1,8 @@ +package com.hnac.hzinfo.inspect.hikVideo.service; + + +public interface IHikApiService { + + String manualCapture(String pointCode); + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/service/impl/HikApiServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/service/impl/HikApiServiceImpl.java new file mode 100644 index 0000000..495c879 --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/hikVideo/service/impl/HikApiServiceImpl.java @@ -0,0 +1,25 @@ +package com.hnac.hzinfo.inspect.hikVideo.service.impl; + +import com.hnac.hzinfo.inspect.hikVideo.service.IHikApiService; +import com.hnac.hzinfo.inspect.utils.HiKUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +@AllArgsConstructor +public class HikApiServiceImpl implements IHikApiService { + + /** + * 从摄像头截图 + * @param pointCode cameraIndexCode + * @return 视频云图片minio地址 + */ + @Override + public String manualCapture(String pointCode) { + String picUrl = HiKUtil.manualCapture(pointCode); + log.info("摄像头截图地址为:{}",picUrl); + return picUrl; + } +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java index c82d332..39617a3 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java @@ -17,11 +17,13 @@ import com.hnac.hzinfo.core.push.model.PushInfo; import com.hnac.hzinfo.core.push.model.PushPlatform; import com.hnac.hzinfo.inspect.plan.PlanContants; import com.hnac.hzinfo.inspect.task.TaskContants.ClaimStatusEnum; +import com.hnac.hzinfo.inspect.task.dto.RobotTaskVideoDTO; import com.hnac.hzinfo.inspect.task.dto.TaskDTO; import com.hnac.hzinfo.inspect.task.entity.EventEntity; import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; import com.hnac.hzinfo.inspect.task.service.IEventService; +import com.hnac.hzinfo.inspect.task.service.IRobotTaskVideoService; import com.hnac.hzinfo.inspect.task.service.ITaskService; import com.hnac.hzinfo.inspect.task.service.ITaskUserService; import com.hnac.hzinfo.inspect.task.vo.InspectTaskExportVO; @@ -49,6 +51,7 @@ import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import java.io.IOException; import java.net.URLEncoder; import java.time.LocalDateTime; @@ -73,6 +76,7 @@ public class TaskController extends BladeController { private final ITaskService taskService; private final ITaskUserService taskUserService; private final IEventService eventService; + private final IRobotTaskVideoService robotTaskVideoService; /** * 根据计划id获取任务列表 @@ -463,4 +467,17 @@ public class TaskController extends BladeController { e.printStackTrace(); } } + + @PostMapping("/recordVideo") + @ApiOperation(value = "任务执行过程中录像功能", notes = "任务执行过程中录像功能") + public R recordVideo(@RequestBody @Valid RobotTaskVideoDTO req) { + robotTaskVideoService.recordVideo(req); + return R.success("调用成功"); + } + + @GetMapping("/recordVideoByPointCode") + @ApiOperation(value = "根据pointCode测试录像功能", notes = "根据pointCode测试录像功能") + public R recordVideoByPointCode(@RequestParam String pointCode){ + return R.data(robotTaskVideoService.recordVideoByPointCode(pointCode)); + } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IRobotTaskVideoService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IRobotTaskVideoService.java new file mode 100644 index 0000000..f75d178 --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IRobotTaskVideoService.java @@ -0,0 +1,11 @@ +package com.hnac.hzinfo.inspect.task.service; + +import com.hnac.hzinfo.inspect.task.dto.RobotTaskVideoDTO; + +public interface IRobotTaskVideoService { + + void recordVideo(RobotTaskVideoDTO req); + + String recordVideoByPointCode(String pointCode); + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/RobotTaskVideoServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/RobotTaskVideoServiceImpl.java new file mode 100644 index 0000000..0f0e11c --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/RobotTaskVideoServiceImpl.java @@ -0,0 +1,136 @@ +package com.hnac.hzinfo.inspect.task.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; +import com.hnac.hzinfo.inspect.ai.entity.RobotEntity; +import com.hnac.hzinfo.inspect.ai.service.ICameraInfoService; +import com.hnac.hzinfo.inspect.ai.service.IRobotService; +import com.hnac.hzinfo.inspect.hikVideo.constants.HikApiConstants; +import com.hnac.hzinfo.inspect.hikVideo.request.PlaybackRequest; +import com.hnac.hzinfo.inspect.hikVideo.request.RecordStartRequest; +import com.hnac.hzinfo.inspect.hikVideo.request.RecordStopRequest; +import com.hnac.hzinfo.inspect.task.dto.RobotTaskVideoDTO; +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; +import com.hnac.hzinfo.inspect.task.service.IRobotTaskVideoService; +import com.hnac.hzinfo.inspect.task.service.ITaskService; +import com.hnac.hzinfo.inspect.utils.HiKUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.Optional; + +@AllArgsConstructor +@Service +@Slf4j +public class RobotTaskVideoServiceImpl implements IRobotTaskVideoService { + + private final IRobotService robotService; + private final ICameraInfoService cameraInfoService; + private final ITaskService taskService; + private final BladeLogger bladeLogger; + + @Override + public void recordVideo(RobotTaskVideoDTO req) { + RobotEntity robot = robotService.getOne(Wrappers.lambdaQuery().eq(RobotEntity::getUserId, req.getUserId())); + TaskEntity task = taskService.getById(req.getTaskId()); + Func.toLongList(",",robot.getCameraId()).forEach(cameraId -> { + CameraInfoEntity cameraInfo = cameraInfoService.getById(cameraId); + // cameraInfo.setPointCode("ceea3ef00de54062aa23583bc6112e98"); + if(Func.isNotEmpty(cameraInfo) && Func.isNotEmpty(cameraInfo.getPointCode())) { + if(req.getRecordType() == 1) { + // 调用海康接口开启录制视频 + RecordStartRequest startRequest = new RecordStartRequest(); + startRequest.setCameraIndexCode(cameraInfo.getPointCode()); + try { + bladeLogger.info("recordVideo:manualRecord:start:param", JSON.toJSONString(startRequest)); + String startResult = HiKUtil.sendApi(HikApiConstants.MANUAL_RECORD_START, startRequest); + bladeLogger.info("recordVideo:manualRecord:start:result", startResult); + task.setHikVideoTaskId(JSONObject.parseObject(startResult).getString("taskID")); + } + catch(ServiceException e) { + log.info("摄像头手动任务已开启需先结束再开启视频录制任务"); + RecordStopRequest stopRequest = new RecordStopRequest(); + stopRequest.setCameraIndexCode(cameraInfo.getPointCode()); + HiKUtil.sendApi(HikApiConstants.MANUAL_RECORD_STOP, stopRequest); + String startResult = HiKUtil.sendApi(HikApiConstants.MANUAL_RECORD_START, startRequest); + task.setHikVideoTaskId(JSONObject.parseObject(startResult).getString("taskID")); + } + // 设置巡检任务视频录制开始时间 + if(Func.isEmpty(task.getVideoStartTime())) { + task.setVideoStartTime(LocalDateTime.now()); + } + } + else if(req.getRecordType() == 2) { + // 调用海康接口结束录制视频 + RecordStopRequest stopRequest = new RecordStopRequest(); + stopRequest.setCameraIndexCode(cameraInfo.getPointCode()); + //request.setTaskID(task.getHikVideoTaskId()); + bladeLogger.info("recordVideo:manualRecord:stop:param", JSON.toJSONString(stopRequest)); + String stopResult = HiKUtil.sendApi(HikApiConstants.MANUAL_RECORD_STOP, stopRequest); + bladeLogger.info("recordVideo:manualRecord:stop:result", stopResult); + task.setVideoEndTime(LocalDateTime.now()); + // 调用视频回放接口获取URL地址 + PlaybackRequest playbackRequest = new PlaybackRequest(); + playbackRequest.setCameraIndexCode(cameraInfo.getPointCode()); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + playbackRequest.setBeginTime(task.getVideoStartTime().atZone(ZoneOffset.ofHours(8)).format(dtf)); + playbackRequest.setEndTime(task.getVideoEndTime().atZone(ZoneOffset.ofHours(8)).format(dtf)); + bladeLogger.info("recordVideo:manualRecord:playBack:param", JSON.toJSONString(playbackRequest)); + String playBackResult = HiKUtil.sendApi(HikApiConstants.PLAY_BACK_URLS, playbackRequest); + bladeLogger.info("recordVideo:manualRecord:playBack:result", playBackResult); + String url = JSONObject.parseObject(playBackResult).getString("url"); + if(StringUtil.isNotBlank(url)) { + task.setVideoUrl(Optional.ofNullable(task.getVideoUrl()).filter(StringUtil::isNotBlank).map(u -> url).orElse(url)); + } + } + taskService.updateById(task); + } + }); + } + + @Override + public String recordVideoByPointCode(String pointCode) { + // 调用海康接口开启录制视频 + RecordStartRequest request = new RecordStartRequest(); + request.setCameraIndexCode(pointCode); + try { + HiKUtil.sendApi(HikApiConstants.MANUAL_RECORD_START, request); + } + catch(ServiceException e) { + RecordStopRequest stopRequest = new RecordStopRequest(); + stopRequest.setCameraIndexCode(pointCode); + HiKUtil.sendApi(HikApiConstants.MANUAL_RECORD_STOP, stopRequest); + HiKUtil.sendApi(HikApiConstants.MANUAL_RECORD_START, request); + } + // 设置巡检任务视频录制开始时间 + LocalDateTime beginTime = LocalDateTime.now(); + try { + Thread.sleep(3*60*1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + // 调用海康接口结束录制视频 + RecordStopRequest stopRequest = new RecordStopRequest(); + stopRequest.setCameraIndexCode(pointCode); + HiKUtil.sendApi(HikApiConstants.MANUAL_RECORD_STOP, stopRequest); + LocalDateTime EndTime = LocalDateTime.now(); + // 调用视频回放接口获取URL地址 + PlaybackRequest playbackRequest = new PlaybackRequest(); + playbackRequest.setCameraIndexCode(pointCode); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + playbackRequest.setBeginTime(beginTime.atZone(ZoneOffset.ofHours(8)).format(dtf)); + playbackRequest.setEndTime(EndTime.atZone(ZoneOffset.ofHours(8)).format(dtf)); + String result = HiKUtil.sendApi(HikApiConstants.PLAY_BACK_URLS, playbackRequest); + return JSONObject.parseObject(result).getString("url"); + } +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java index 0c64d86..dde7a0b 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java @@ -1,6 +1,7 @@ package com.hnac.hzinfo.inspect.utils; import com.alibaba.druid.support.json.JSONUtils; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.JsonNode; import com.hikvision.artemis.sdk.ArtemisHttpUtil; @@ -10,11 +11,15 @@ import okhttp3.MultipartBody; import okhttp3.RequestBody; import org.springblade.core.http.HttpRequest; import org.springblade.core.http.LogLevel; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.jackson.JsonUtil; import org.springblade.core.tool.utils.Func; import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.Assert; + import java.util.HashMap; import java.util.Map; +import java.util.Optional; /** * @Author: liugang @@ -27,7 +32,9 @@ public class HiKUtil { */ @Value("${hzims.inspect.video.minio-url}") private static String minioUrl; - + public static String APP_KEY = "26486442"; + public static String APP_SECRET = "tXBM9jsMqeM9yvEMS8qg"; + public static String HOST = "140.210.208.111:443"; /** * 获取视频流 @@ -57,16 +64,67 @@ public class HiKUtil { * @param pointCode cameraIndexCode * @return 视频云图片地址 */ - private static String manualCapture(String pointCode) { - //请求路径 - String api = "/api/video/v1/manualCapture"; - //STEP5:组装请求参数 - Map map = new HashMap<>(8); - map.put("cameraIndexCode", pointCode); - String result = send(api, map); - JSONObject object = JsonUtil.parse(result, JSONObject.class); - return object.getString("picUrl"); - } +// private static String manualCapture(String pointCode) { +// //请求路径 +// String api = "/api/video/v1/manualCapture"; +// //STEP5:组装请求参数 +// Map map = new HashMap<>(8); +// map.put("cameraIndexCode", pointCode); +// String result = send(api, map); +// JSONObject object = JsonUtil.parse(result, JSONObject.class); +// return object.getString("picUrl"); +// } + + /** + * 从摄像头截图 + * + * @param pointCode cameraIndexCode + * @return 视频云图片地址 + */ + public static String manualCapture(String pointCode) { + ArtemisConfig.host = HOST; + ArtemisConfig.appKey = APP_KEY; + ArtemisConfig.appSecret = APP_SECRET; + final String ARTEMIS_PATH = "/artemis"; + final String manualCaptureURLsApi = ARTEMIS_PATH + "/api/video/v1/manualCapture"; + Map path = new HashMap (2) {{ + //根据现场环境部署确认是http还是https + put("https://", manualCaptureURLsApi); + }}; + String contentType = "application/json"; + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", pointCode); + String body = jsonBody.toJSONString(); + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, + contentType , null);// post请求application/json类型参数 + return Optional.ofNullable(result).map(JSONObject::parseObject).filter(r -> "0".equals(r.getString("code"))).map(r -> r.getString("data")) + .map(JSONObject::parseObject).map(o -> o.getString("picUrl")).orElse(null); + } + + /** + * 海康视频调用API + * @param api 海康API + * @param variable 传参 + * @return + */ + public static String sendApi(String api,Object variable) { + ArtemisConfig.host = HOST; + ArtemisConfig.appKey = APP_KEY; + ArtemisConfig.appSecret = APP_SECRET; + final String ARTEMIS_PATH = "/artemis"; + final String url = ARTEMIS_PATH + api; + Map path = new HashMap (2) {{ + //根据现场环境部署确认是http还是https + put("https://", url); + }}; + final String contentType = "application/json"; + System.out.println("海康调用传参"+ JSON.toJSONString(variable)); + String result = ArtemisHttpUtil.doPostStringArtemis(path, JSON.toJSONString(variable), null, null, contentType , null); + Assert.isTrue("0".equals(JSONObject.parseObject(result).getString("code")),() -> { + throw new ServiceException("调用海康URL失败,报错信息为:" + result); + }); + return JSONObject.parseObject(result).getString("data"); + } /** diff --git a/hzims-service/inspect/src/main/resources/db/1.0.1.sql b/hzims-service/inspect/src/main/resources/db/1.0.1.sql new file mode 100644 index 0000000..8507e7a --- /dev/null +++ b/hzims-service/inspect/src/main/resources/db/1.0.1.sql @@ -0,0 +1,228 @@ +-- 巡检摄像头管理添加设备编号 +alter table `hz_st_camera_info` add column `em_code` varchar(50) default null comment '设备编号'; +-- 巡检情况对象记录异常告警 +alter table `hz_st_ex_event_record` add column `abnormal_condition` varchar(255) default null comment '异常告警'; + +alter table `hz_st_ex_task` add column `video_start_time` datetime default null comment '视频录制开始时间'; +alter table `hz_st_ex_task` add column `video_end_time` datetime default null comment '视频录制开始时间'; +alter table `hz_st_ex_task` add column `video_url` varchar(255) default null comment '手动录制视频地址'; +alter table `hz_st_ex_task` add column `hik_video_task_id` varchar(50) default null comment '海康录制视频任务ID'; + +-- 巡检计划模板表 +CREATE TABLE `hz_st_re_plan_template` ( + `ID` bigint(64) NOT NULL COMMENT 'ID', + `CODE` varchar(18) DEFAULT NULL COMMENT '计划编码', + `NAME` varchar(128) DEFAULT NULL COMMENT '计划名称', + `START_TIME` date DEFAULT NULL COMMENT '计划开始时间', + `END_TIME` date DEFAULT NULL COMMENT '计划结束时间', + `TYPE` char(1) DEFAULT NULL COMMENT '计划模式 0 人员 1岗位 2机构 3自由模式 4 自由人模式', + `METHOD` char(1) DEFAULT '0' COMMENT '派发方式:0 抢占模式 1 并发模式', + `CYCLE` char(1) DEFAULT NULL COMMENT '计划周期 0: 从不 1:每天 2:每月 3:每季度 5:每年 4:每周', + `APPROVER` bigint(20) DEFAULT NULL COMMENT '审批人', + `APPROVE_TIME` datetime DEFAULT NULL COMMENT '审批时间 ', + `FROM_SOURCE` char(2) DEFAULT NULL COMMENT '计划来源 1巡检 2点检', + `CREATE_USER` bigint(64) DEFAULT NULL COMMENT '创建人', + `CREATE_DEPT` bigint(64) DEFAULT NULL COMMENT '创建部门', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(64) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '修改时间', + `STATUS` int(2) DEFAULT '6' COMMENT '计划状态 0:待审核-->1:已审核-->2:派发中-->3:暂停-->4:结束-->5审核不通过-->6待提交', + `IS_DELETED` int(2) NOT NULL DEFAULT '0' COMMENT '是否已删除', + `TENANT_ID` varchar(12) DEFAULT '000000' COMMENT '租户', + `TASK_FLG` tinyint(4) DEFAULT '0' COMMENT '是否立即生产任务 1-是 0-否', + `ROUTE_DATA` text COMMENT '巡检路线数据', + `ROUTE_ID` bigint(20) DEFAULT NULL COMMENT '巡检路线ID字段', + `ROUTE_NAME` varchar(255) DEFAULT NULL COMMENT '路线名称', + `START_REMIND` int(11) DEFAULT NULL COMMENT '开始前提醒(分钟)', + `END_REMIND` int(11) DEFAULT NULL COMMENT '结束前提醒(分钟)', + `TASK_TIMES_A_DAY` int(11) DEFAULT NULL COMMENT '一天任务次数', + `EXEC_TIME_JSON` text COMMENT '任务执行时间json数据', + `AI_CHECK_ITEMS` varchar(255) DEFAULT NULL COMMENT '开始任务时AI检测项 来自数据字段表: beginCheckType 多个检测项直接通过隔开', + `AUTO_VIDEO` varchar(255) DEFAULT '0' COMMENT '巡检类型标识: 0普通巡检 1视频自动巡检 2机器人巡检', + `PLAN_TYPE` varchar(20) DEFAULT 'common' COMMENT '计划类型 common常规任务 temporary临时任务', + `TASK_CONTENT` text COMMENT '临时任务的巡检任务内容', + `message_template_id` bigint(20) DEFAULT NULL COMMENT '消息模板ID', + `ENABLE` tinyint(2) DEFAULT NULL COMMENT '是否启用', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='巡检计划模板表(专供演示数据使用)'; + +-- 巡检任务模板表 +CREATE TABLE `hz_st_ex_task_template` ( + `ID` bigint(20) NOT NULL COMMENT 'ID', + `PLAN_ID` bigint(20) DEFAULT NULL COMMENT '计划ID', + `TYPE` char(1) DEFAULT NULL COMMENT '计划模式 0 人员 1岗位 2机构 3自由模式 4 自由人模式', + `PLAN_NAME` varchar(128) DEFAULT NULL COMMENT '计划名称', + `BATCH_NUMBER` varchar(20) DEFAULT NULL COMMENT '任务批次号', + `CYCLE` char(1) DEFAULT NULL COMMENT '计划周期 0: 从不 1:每天 2:每月 3:每季度 5:每年 4:每周', + `METHOD` char(1) DEFAULT '0' COMMENT '派发方式:0 抢占模式 1 并发模式', + `PLAN_START_TIME` datetime DEFAULT NULL COMMENT '任务计划开始时间', + `PLAN_END_TIME` datetime DEFAULT NULL COMMENT '任务计划结束时间', + `START_TIME` datetime DEFAULT NULL COMMENT '任务实际开始时间', + `END_TIME` datetime DEFAULT NULL COMMENT '任务实际结束时间', + `KEEP_ON_RECORD` char(1) DEFAULT '0' COMMENT '巡检报备 0 未报备 1已报备', + `CREATE_USER` bigint(64) DEFAULT NULL COMMENT '创建人', + `CREATE_DEPT` bigint(64) DEFAULT NULL COMMENT '创建部门', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(64) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '修改时间', + `STATUS` int(2) DEFAULT '0' COMMENT '任务状态 0未开始 1进行中 2暂停 3已完成 4未完成', + `IS_DELETED` int(2) NOT NULL DEFAULT '0' COMMENT '是否已删除', + `TENANT_ID` varchar(12) DEFAULT '000000' COMMENT '租户', + `AUTO_VIDEO` varchar(255) DEFAULT '0' COMMENT '巡检类型标识: 0普通巡检 1 视频自动巡检 2机器人巡检', + `TASK_CONTENT` text COMMENT '临时任务的巡检任务内容', + `PLAN_TYPE` varchar(20) DEFAULT 'common' COMMENT '计划类型common常规任务temporary临时任务', + `START_REMIND_FLAG` tinyint(1) DEFAULT '0' COMMENT '任务开始前 是否发送提醒短信 标识', + `END_REMIND_FLAG` tinyint(1) DEFAULT '0' COMMENT '任务结束前 是否发送提醒短信 标识', + `START_REMIND_TIME` datetime DEFAULT NULL COMMENT '开始前提醒时间', + `END_REMIND_TIME` datetime DEFAULT NULL COMMENT '结束前提醒时间', + `DUTY_ID` bigint(20) DEFAULT NULL COMMENT '值班ID', + `message_template_id` bigint(20) DEFAULT NULL COMMENT '消息模板ID', + `push_status` bigint(1) DEFAULT NULL COMMENT '推送状态', + `ENABLE` tinyint(2) DEFAULT NULL COMMENT '是否启用', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='巡检任务模板表(专供演示数据使用)'; + +-- 巡检任务对象模板表 +CREATE TABLE `hz_st_ex_object_template` ( + `ID` bigint(64) NOT NULL, + `TASK_ID` bigint(20) NOT NULL COMMENT '任务ID', + `OBJECT_ID` bigint(20) NOT NULL COMMENT '对象ID', + `CODE` varchar(18) DEFAULT NULL COMMENT '对象编码', + `NAME` varchar(128) DEFAULT NULL COMMENT '对象名称', + `ADDRESS` varchar(128) DEFAULT NULL COMMENT '地理位置', + `LGTD` decimal(13,10) DEFAULT NULL COMMENT '经度(东经)', + `LTTD` decimal(12,10) DEFAULT NULL COMMENT '纬度(北纬)', + `DUPLICATE_RECORD` char(1) DEFAULT '0' COMMENT '是否重复记录 0 不允许 1允许', + `CREATE_USER` bigint(64) DEFAULT NULL COMMENT '创建人', + `CREATE_DEPT` bigint(64) DEFAULT NULL COMMENT '创建部门', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(64) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '修改时间', + `STATUS` int(2) DEFAULT '0' COMMENT '状态', + `IS_DELETED` int(2) NOT NULL DEFAULT '0' COMMENT '是否已删除', + `TENANT_ID` varchar(12) DEFAULT '000000' COMMENT '租户', + `ENABLE` tinyint(2) DEFAULT NULL COMMENT '是否启用', + PRIMARY KEY (`ID`) USING BTREE, + KEY `idx_task_id` (`TASK_ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='巡检任务对象模板表(专供演示数据使用)'; + +-- 巡检任务对象项目模板表 +CREATE TABLE `hz_st_ex_object_project_template` ( + `ID` bigint(64) NOT NULL, + `TASK_ID` bigint(64) NOT NULL COMMENT '任务ID', + `OBJECT_ID` bigint(64) NOT NULL COMMENT '对象ID', + `PROJECT_ID` bigint(64) NOT NULL COMMENT '项目ID', + `CODE` varchar(18) DEFAULT NULL COMMENT '目标编码', + `NAME` varchar(128) DEFAULT NULL COMMENT '目标名称', + `DESCRIPTION` varchar(512) DEFAULT NULL COMMENT '目标描述', + `CREATE_USER` bigint(64) DEFAULT NULL COMMENT '创建人', + `CREATE_DEPT` bigint(64) DEFAULT NULL COMMENT '创建部门', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(64) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '修改时间', + `STATUS` int(2) DEFAULT '0' COMMENT '状态', + `IS_DELETED` int(2) NOT NULL DEFAULT '0' COMMENT '是否已删除', + `TENANT_ID` varchar(12) DEFAULT '000000' COMMENT '租户', + `ENABLE` tinyint(2) DEFAULT NULL COMMENT '是否启用', + PRIMARY KEY (`ID`) USING BTREE, + KEY `idx_task_id` (`TASK_ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='巡检任务对象项目模板表(专供演示数据使用)'; + +CREATE TABLE `hz_st_ex_object_project_content_template` ( + `ID` bigint(64) NOT NULL, + `TASK_ID` bigint(20) NOT NULL COMMENT '任务ID', + `OBJECT_ID` bigint(20) NOT NULL COMMENT '对象ID', + `PROJECT_ID` bigint(20) NOT NULL COMMENT '项目ID', + `CONTENT_ID` bigint(20) NOT NULL COMMENT '内容ID', + `CODE` varchar(18) DEFAULT NULL COMMENT '内容编码 由系统自动生成自动生成', + `NAME` varchar(128) DEFAULT NULL COMMENT '内容名称', + `AVAILABLE` char(1) DEFAULT '1' COMMENT '完成标识 0 不可用 1 可用', + `DESCRIPTION` varchar(512) DEFAULT NULL COMMENT '内容描述', + `CHECK_TYPE` char(2) DEFAULT NULL COMMENT '检测类型', + `RECORD_TYPE` char(1) DEFAULT NULL COMMENT '记录类型', + `CHECK_TYPE_SON` varchar(256) DEFAULT NULL COMMENT '存字典表key 检测类型子类 子类的子类通过-隔开例如:1-12', + `CREATE_USER` bigint(64) DEFAULT NULL COMMENT '创建人', + `CREATE_DEPT` bigint(64) DEFAULT NULL COMMENT '创建部门', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(64) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '修改时间', + `STATUS` int(2) DEFAULT '0' COMMENT '状态', + `IS_DELETED` int(2) NOT NULL DEFAULT '0' COMMENT '是否已删除', + `TENANT_ID` varchar(12) DEFAULT '000000' COMMENT '租户', + `CLOCK_ID` bigint(20) DEFAULT NULL COMMENT '表针识别 表盘ID', + `CAMERA_ID` bigint(20) DEFAULT NULL COMMENT '视频巡检摄像机ID', + `CAMERA_ADDR` varchar(128) DEFAULT NULL COMMENT '开关/灯/表盘在摄像机可视面二维坐标位置 例如:2 1 表示第三行第二列 行列均从0开始记录 默认 0 0 如果有多张图则:0 0 1( 最后一位表示所在图片 最后一位1表示第二张图) 默认0 0 0', + `OTHER_PARAM` varchar(1024) DEFAULT NULL COMMENT '其他参数 例如多联断路器内断路器的个数', + `CHECK_VAL` varchar(512) DEFAULT NULL COMMENT '校验值 用来判断当前值是否正确:枚举数据通过 “ ”隔开 区间通过~隔开', + `DICT_TYPE` varchar(255) DEFAULT NULL COMMENT '记值方式为选择时选择值', + `ENABLE` tinyint(2) DEFAULT NULL COMMENT '是否启用', + PRIMARY KEY (`ID`) USING BTREE, + KEY `idx_task_id` (`TASK_ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='巡检任务对象项目内容模板表(专供演示数据使用)'; + +-- 巡检情况列模板表 +CREATE TABLE `hz_st_ex_event_template` ( + `ID` bigint(20) NOT NULL COMMENT 'ID', + `TASK_ID` bigint(20) DEFAULT NULL COMMENT '任务ID', + `OBJECT_ID` bigint(20) DEFAULT NULL COMMENT '对象ID', + `PROJECT_ID` bigint(20) DEFAULT NULL COMMENT '项目ID', + `USER_ID` bigint(20) DEFAULT NULL COMMENT '事件登记人', + `CODE` varchar(18) DEFAULT NULL COMMENT '事件编号', + `TITLE` varchar(128) DEFAULT NULL COMMENT '事件标题', + `DESCRIPTION` varchar(1024) DEFAULT NULL COMMENT '事件描述', + `IS_PROBLEM` char(1) DEFAULT '0' COMMENT '是否问题 0:否 1 是 默认0', + `TYPE_BIG` char(10) DEFAULT NULL COMMENT '问题类型(大)', + `TYPE_SMALL` char(10) DEFAULT NULL COMMENT '问题类型(小)', + `LGTD` decimal(13,10) DEFAULT NULL COMMENT '经度(东经)', + `LTTD` decimal(12,10) DEFAULT NULL COMMENT '纬度(北纬)', + `ADDRESS` varchar(256) DEFAULT NULL COMMENT '事件地点', + `PROCESS_DEFINITION_ID` varchar(64) DEFAULT NULL COMMENT '流程定义id', + `PROCESS_INSTANCE_ID` varchar(64) DEFAULT NULL COMMENT '流程实例id', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `CREATE_USER` bigint(64) DEFAULT NULL, + `CREATE_DEPT` bigint(64) DEFAULT NULL COMMENT '创建部门', + `UPDATE_USER` bigint(64) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '修改时间', + `STATUS` int(2) DEFAULT '0' COMMENT '状态', + `IS_DELETED` int(2) NOT NULL DEFAULT '0' COMMENT '是否已删除', + `TENANT_ID` varchar(12) DEFAULT NULL COMMENT '租户', + `ENABLE` tinyint(2) DEFAULT NULL COMMENT '是否启用', + PRIMARY KEY (`ID`) USING BTREE, + KEY `idx_task_id` (`TASK_ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='巡检情况列模板表(专供演示数据使用)'; + +-- 巡检情况记录模板表 +CREATE TABLE `hz_st_ex_event_record_template` ( + `ID` bigint(64) NOT NULL, + `EVENT_ID` bigint(20) NOT NULL COMMENT '事件ID', + `OBJECT_ID` bigint(20) NOT NULL COMMENT '对象ID', + `PROJECT_ID` bigint(20) NOT NULL COMMENT '项目ID', + `CONTENT_ID` bigint(20) NOT NULL COMMENT '内容ID', + `CURRENT_STATUS` char(1) DEFAULT '1' COMMENT '内容当前状态 0 异常 1 正常 ', + `CURRENT_VALUE` varchar(512) DEFAULT NULL COMMENT '内容当前值', + `CURRENT_DESC` varchar(512) DEFAULT NULL COMMENT '内容当前描述', + `CODE` varchar(18) DEFAULT NULL COMMENT '内容编码:由系统自动生成自动生成', + `NAME` varchar(128) DEFAULT NULL COMMENT '内容名称', + `DESCRIPTION` varchar(512) DEFAULT NULL COMMENT '内容描述', + `RECORD_TYPE` char(1) DEFAULT NULL COMMENT '记录类型 0 不记录 1仅选择 2仅记值 3选择并记值', + `CHECK_TYPE` char(2) DEFAULT NULL COMMENT '检测类型 原来数据字典 暂时设计只支持99个类型', + `CREATE_USER` bigint(64) DEFAULT NULL COMMENT '创建人', + `CREATE_DEPT` bigint(64) DEFAULT NULL COMMENT '创建部门', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(64) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '修改时间', + `STATUS` int(2) DEFAULT NULL COMMENT '状态', + `IS_DELETED` int(2) NOT NULL DEFAULT '0' COMMENT '是否已删除', + `TENANT_ID` varchar(12) DEFAULT '000000' COMMENT '租户', + `CHECK_TYPE_SON` varchar(256) DEFAULT NULL COMMENT '存字典表key 检测类型子类 子类的子类通过-隔开例如:1-12', + `FILE_URL` varchar(512) DEFAULT NULL COMMENT '文件地址', + `CAMERA_ADDR` varchar(256) DEFAULT NULL COMMENT '开关/灯/表盘在摄像机可视面二维坐标位置 例如:2 1 表示第三行第二列 行列均从0开始记录 默认 0 0 如果有多张图则:0 0 1( 最后一位表示所在图片 最后一位1表示第二张图) 默认0 0 0', + `OTHER_PARAM` varchar(1024) DEFAULT NULL COMMENT '其他参数 例如多联断路器内断路器的', + `CHECK_VAL` varchar(512) DEFAULT NULL COMMENT '校验值 用来判断当前值是否正确:枚举数据通过 隔开 区间通过 隔开', + `DICT_TYPE` varchar(255) DEFAULT NULL COMMENT '记值方式为选择时选择值', + `ENABLE` tinyint(2) DEFAULT NULL COMMENT '是否启用', + PRIMARY KEY (`ID`) USING BTREE, + KEY `idx_event_id` (`EVENT_ID`) USING BTREE, + KEY `idx_is_deleted_tenant_id` (`IS_DELETED`,`TENANT_ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='巡检情况记录模板表(专供演示数据使用)'; +