From 562a3737a3cddf87b46a0a87048d3555eb8c9360 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 4 Mar 2024 13:17:46 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E8=A7=86=E9=A2=91=E5=B7=A1=E6=A3=80=20#=20?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20#=20=E6=97=A5=E5=B8=B8=E7=BB=B4=E6=8A=A4=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E8=AE=A1=E5=88=92=E7=94=9F=E6=88=90=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=E5=88=9B=E5=BB=BA=E4=BA=BA=E5=8F=82=E6=95=B0=E6=9C=AA?= =?UTF-8?q?=E5=A1=AB=E5=85=85=E8=BF=9B=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/common/statistics/Charts.java | 28 +++ .../java/com/hnac/hzims/common/utils/DateUtil.java | 6 +- .../hzinfo/inspect/ai/entity/CameraInfoEntity.java | 3 + .../hzims/message/constants/DictKeyConstants.java | 8 + .../equipment/src/main/resources/db/2.0.0.sql.1 | 3 + .../task/controller/TaskObjectController.java | 34 ++++ .../inspect/task/schedule/VideoTaskSchedule.java | 217 +++++++++++++++++++++ .../inspect/task/schedule/XxlJobConstants.java | 3 + .../inspect/task/service/ITaskObjectService.java | 3 + .../task/service/impl/TaskObjectServiceImpl.java | 36 ++++ .../inspect/src/main/resources/db/2.0.0.sql.1 | 9 +- .../message/service/IMessagePushRecordService.java | 1 + .../controller/MsgPushStatisticController.java | 5 + .../service/IMsgPushStatisticService.java | 3 + .../service/impl/MsgPushStatisticServiceImpl.java | 40 ++++ .../scheduled/MaintenanceTaskSchedule.java | 4 + .../safeproduct/controller/AccidentController.java | 30 +-- 17 files changed, 405 insertions(+), 28 deletions(-) create mode 100644 hzims-biz-common/src/main/java/com/hnac/hzims/common/statistics/Charts.java create mode 100644 hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/constants/DictKeyConstants.java create mode 100644 hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskObjectController.java create mode 100644 hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/statistics/Charts.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/statistics/Charts.java new file mode 100644 index 0000000..77a1635 --- /dev/null +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/statistics/Charts.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.common.statistics; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.lang.reflect.Array; +import java.util.List; + + +@ApiModel("统计图表") +@Data +@EqualsAndHashCode +public class Charts implements Serializable { + + @ApiModelProperty("类别") + private List legends; + + @ApiModelProperty("x轴分区") + private List xAxis; + + @ApiModelProperty("展示数据") + private List series; + +} diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java index b68084b..4309a29 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java @@ -6,6 +6,7 @@ import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.util.Assert; import java.time.*; +import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; import java.util.Date; @@ -16,11 +17,14 @@ import java.util.stream.IntStream; /** * @author hx */ -public class DateUtil { +public class DateUtil extends org.springblade.core.tool.utils.DateUtil { public static final String yyyy_MM_dd_HH_MM_SS= "yyyy-MM-dd HH:mm:ss"; public static final String yyyy_MM_dd= "yyyy-MM-dd"; public static final String yyyy_MM= "yyyy-MM"; + + public static final DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM"); + public static final String yyyy= "yyyy"; public static final String YEAR = "year"; diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/CameraInfoEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/CameraInfoEntity.java index ba20dad..08bf9ed 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/CameraInfoEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/CameraInfoEntity.java @@ -132,4 +132,7 @@ public class CameraInfoEntity extends TenantEntity { @ApiModelProperty(value = "是否平台接入") private Integer isHikvideo; + @ApiModelProperty("设备编号") + private String emCode; + } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/constants/DictKeyConstants.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/constants/DictKeyConstants.java new file mode 100644 index 0000000..2ef0f7d --- /dev/null +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/constants/DictKeyConstants.java @@ -0,0 +1,8 @@ +package com.hnac.hzims.message.constants; + +public interface DictKeyConstants { + + /**消息推送类型 [appPush-app推送 smsPush-短信推送 websocketPush-web推送 mailPush-邮件推送]**/ + String MESSAGE_TYPE = "messageType"; + +} diff --git a/hzims-service/equipment/src/main/resources/db/2.0.0.sql.1 b/hzims-service/equipment/src/main/resources/db/2.0.0.sql.1 index 0a632cd..8f62292 100644 --- a/hzims-service/equipment/src/main/resources/db/2.0.0.sql.1 +++ b/hzims-service/equipment/src/main/resources/db/2.0.0.sql.1 @@ -29,4 +29,7 @@ alter table `HZIMS_PARAM_BACKUPS` add column `em_name` varchar(100) COMMENT '设 update HZIMS_PARAM_BACKUPS pb,HZIMS_EM_INFO ei set pb.EM_NAME = ei.`NAME` WHERE pb.EM_CODE = ei.NUMBER; update bladex.blade_dict set dict_key = '2' where id = 1675699613977288706; +update equipment.hzims_em_definition set type = '2' where type = '0'; + +update bladex.blade_dict set dict_key = '2' where id = 1675699613977288706; update equipment.hzims_em_definition set type = '2' where type = '0'; \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskObjectController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskObjectController.java new file mode 100644 index 0000000..a952c51 --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskObjectController.java @@ -0,0 +1,34 @@ +package com.hnac.hzinfo.inspect.task.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzinfo.inspect.task.service.ITaskObjectService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +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; + +import java.util.List; + +@AllArgsConstructor +@Api(value = "任务对象管理",tags = "任务对象管理") +@RestController +@RequestMapping("/task/object") +public class TaskObjectController extends BladeController { + + private final ITaskObjectService taskObjectService; + + @GetMapping("/getVideosByObjId") + @ApiOperation("根据任务对象ID获取摄像头点位信息") + @ApiOperationSupport(order = 1) + public R> getVideosByObjId(@RequestParam @ApiParam("任务ID") Long taskId, @RequestParam @ApiParam("对象ID") Long objId) { + return R.data(taskObjectService.getVideosByObjId(taskId,objId)); + } + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java new file mode 100644 index 0000000..d4f79be --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java @@ -0,0 +1,217 @@ +package com.hnac.hzinfo.inspect.task.schedule; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.hnac.hzinfo.datasearch.soe.ISoeClient; +import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; +import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; +import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity; +import com.hnac.hzinfo.inspect.ai.service.ICameraInfoService; +import com.hnac.hzinfo.inspect.ai.service.IRobotTaskService; +import com.hnac.hzinfo.inspect.areamonthly.vo.TaskObjectVO; +import com.hnac.hzinfo.inspect.hikVideo.service.IHikApiService; +import com.hnac.hzinfo.inspect.plan.PlanContants; +import com.hnac.hzinfo.inspect.task.TaskContants; +import com.hnac.hzinfo.inspect.task.entity.EventEntity; +import com.hnac.hzinfo.inspect.task.entity.EventRecordEntity; +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; +import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; +import com.hnac.hzinfo.inspect.task.service.IEventRecordService; +import com.hnac.hzinfo.inspect.task.service.IEventService; +import com.hnac.hzinfo.inspect.task.service.ITaskService; +import com.hnac.hzinfo.inspect.task.service.ITaskUserService; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import com.xxl.job.core.log.XxlJobLogger; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.stereotype.Component; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +import static com.hnac.hzinfo.inspect.task.schedule.XxlJobConstants.EXECUTE_VIDEO_TASK; + +/** + * 视频巡检任务定时调度 + */ +@Component +@AllArgsConstructor +@Slf4j +public class VideoTaskSchedule { + + private final ITaskService taskService; + private final ITaskUserService taskUserService; + private final IEventService eventService; + private final IEventRecordService eventRecordService; + private final IHikApiService hikApiService; + private final IRobotTaskService robotTaskService; + private final ICameraInfoService cameraInfoService; + private final ISoeClient soeClient; + private final DataSourceTransactionManager dataSourceTransactionManager; + private final TransactionDefinition transactionDefinition; + + /** + * 视频巡检任务执行 + * @param params 任务ID + * @return + */ + @XxlJob(EXECUTE_VIDEO_TASK) + @Transactional + public ReturnT execute(String params) throws InterruptedException { + List taskList = Lists.newArrayList(); + // 获取待执行的任务 + if(StringUtil.isBlank(params)) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() + .eq(TaskEntity::getStatus, TaskContants.TaskStatusEnum.INIT_STATUS.getStatus()) + .le(TaskEntity::getPlanStartTime, LocalDateTime.now()) + .ge(TaskEntity::getPlanEndTime, LocalDateTime.now()) + .eq(TaskEntity::getAutoVideo, PlanContants.InspectTypeEnum.VIDEO.getVal()); + taskList.addAll(taskService.list(queryWrapper)); + } + else { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() + .in(TaskEntity::getId, Func.toLongList(",", params)) + .eq(TaskEntity::getStatus, TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus()) + .eq(TaskEntity::getAutoVideo, PlanContants.InspectTypeEnum.VIDEO.getVal()); + taskList.addAll(taskService.list(queryWrapper)); + } + taskList.forEach(this::executeVideoTask); + return ReturnT.SUCCESS; + } + + /** + * 执行视频巡检任务 + * @param task 视频巡检任务 + */ + private void executeVideoTask(TaskEntity task) { + try { + // 登记任务 + this.registration(task); + // 完善视频巡检执行情况 + this.fillEvent(task); + // 更新视频巡检任务状态 + taskService.update(Wrappers.lambdaUpdate() + .set(TaskEntity::getStatus,TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus()) + .set(TaskEntity::getEndTime,LocalDateTime.now()) + .eq(TaskEntity::getId,task.getId())); + } + catch(Exception e) { + e.printStackTrace(); + XxlJobLogger.log("【taskId:"+task.getId()+"】视频巡检任务执行失败,报错信息为:"+e.getMessage()); + } + try { + Thread.sleep(3*1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + /** + * 填充视频巡检执行情况 + * @param task 视频巡检任务 + */ + private void fillEvent(TaskEntity task) { + List taskObjects = taskService.getTaskById(task.getId()); + List taskObjectList = JSONArray.parseArray(JSON.toJSONString(taskObjects),TaskObjectVO.class); + taskObjectList.forEach(object -> object.getProjects().forEach(project -> { + EventEntity event = new EventEntity(); + event.setTaskId(task.getId()); + event.setObjectId(object.getObjId()); + event.setProjectId(project.getProjectId()); + event.setIsProblem("0"); + event.setTenantId(task.getTenantId()); + event.setCreateUser(task.getCreateUser()); + event.setCreateDept(task.getCreateDept()); + event.setUpdateUser(task.getUpdateUser()); + eventService.save(event); + List recordList = project.getContents().stream().map(content -> { + EventRecordEntity record = new EventRecordEntity(); + record.setEventId(event.getId()); + record.setObjectId(object.getObjId()); + record.setProjectId(project.getProjectId()); + record.setContentId(content.getContentId()); + record.setTenantId(task.getTenantId()); + record.setCreateUser(task.getCreateUser()); + record.setCreateDept(task.getCreateDept()); + record.setUpdateUser(task.getUpdateUser()); + record.setCurrentStatus("1"); + CameraInfoEntity camera = this.getCameraByProIdAndConId(project.getProjectId(), content.getContentId()); + if(Func.isNotEmpty(camera)) { + // 获取计划时间段内视频的告警信息设置是否异常 + if(Func.isNotEmpty(camera.getEmCode())) { + Result> deviceSoeR = soeClient.getDeviceCodeByTaosSoe(DateUtil.formatDateTime(task.getPlanStartTime()), DateUtil.formatDateTime(task.getPlanEndTime()), camera.getEmCode(), 0, String.valueOf(-1)); + if(deviceSoeR.isSuccess() && CollectionUtil.isNotEmpty(deviceSoeR.getData().getRecords())) { + record.setCurrentStatus("0"); + + } + } + // 调用海康威视api实现手动截屏回传至fileUrl + if(Func.isNotEmpty(camera.getPointCode())) { + String picUrl = hikApiService.manualCapture(camera.getPointCode()); + record.setFileUrl(picUrl); + record.setCurrentValue(picUrl); + } + } + return record; + }).collect(Collectors.toList()); + eventRecordService.saveBatch(recordList); + if(recordList.stream().anyMatch(r -> TaskContants.CurrentStatusEnum.abnormal.getType().equals(r.getCurrentStatus()))) { + eventService.update(Wrappers.lambdaUpdate().set(EventEntity::getIsProblem,"1").eq(EventEntity::getId,event.getId())); + } + })); + } + + /** + * 登记任务 + * @param task 视频巡检任务 + */ + private void registration(TaskEntity task) { + // 选择第一个人领用改任务 + LambdaQueryWrapper userQueryWrapper = Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()); + List taskUserList = taskUserService.list(userQueryWrapper); + TaskUserEntity taskUserEntity = taskUserList.get(0); + task.setUserId(taskUserEntity.getUserId()); + taskUserEntity.setClaimStatus(TaskContants.ClaimStatusEnum.COLLECT.getStatus()); + taskUserEntity.setClaimTime(LocalDateTime.now()); + taskUserService.updateById(taskUserEntity); + if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { + taskUserService.removeByIds(taskUserList.stream().map(TaskUserEntity::getId).filter(id -> !taskUserEntity.getId().equals(id)).collect(Collectors.toList())); + } + // 更改任务状态 + task.setStatus(Integer.valueOf(TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus())); + task.setStartTime(LocalDateTime.now()); + taskService.updateById(task); + } + + /** + * 根据项目ID以及内容ID获取摄像头编号 + * @param projectId 项目ID + * @param contentId 内容ID + * @return 摄像头编号 + */ + private CameraInfoEntity getCameraByProIdAndConId(Long projectId,Long contentId) { + RobotTaskEntity robotTaskEntity = robotTaskService.getOne(Wrappers.lambdaQuery() + .eq(RobotTaskEntity::getProjectId, projectId) + .like(RobotTaskEntity::getContentIds, String.valueOf(contentId)) + ); + if(Func.isNotEmpty(robotTaskEntity)) { + return cameraInfoService.getById(robotTaskEntity.getCameraId()); + } + return null; + } + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/XxlJobConstants.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/XxlJobConstants.java index 1a2d194..79faaa8 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/XxlJobConstants.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/XxlJobConstants.java @@ -8,4 +8,7 @@ public interface XxlJobConstants { /**巡检任务结束提醒**/ String TASK_END_REMIND = "taskEndRemind"; + /**视频巡检任务执行**/ + String EXECUTE_VIDEO_TASK = "executeVideoTask"; + } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectService.java index 469e963..e99baeb 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskObjectService.java @@ -1,5 +1,6 @@ package com.hnac.hzinfo.inspect.task.service; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzinfo.inspect.task.vo.TaskObjectOfflineVO; import com.hnac.hzinfo.inspect.task.vo.TaskObjectVO; import org.springblade.core.mp.base.BaseService; @@ -24,4 +25,6 @@ public interface ITaskObjectService extends BaseService { List getTaskObjectsDetail(TaskObjectEntity to); List getExObjectData(List taskIds); + + List getVideosByObjId(Long taskId, Long objId); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java index d421097..0b55999 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java @@ -1,14 +1,24 @@ package com.hnac.hzinfo.inspect.task.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; +import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity; +import com.hnac.hzinfo.inspect.ai.mapper.RobotTaskMapper; +import com.hnac.hzinfo.inspect.ai.service.ICameraInfoService; import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity; import com.hnac.hzinfo.inspect.obj.services.ProjectService; import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity; +import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectEntity; import com.hnac.hzinfo.inspect.task.mapper.TaskObjectMapper; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; +import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectService; import com.hnac.hzinfo.inspect.task.vo.TaskObjectOfflineVO; import com.hnac.hzinfo.inspect.task.vo.TaskObjectProjectContentVO; import com.hnac.hzinfo.inspect.task.vo.TaskObjectVO; +import com.hnac.hzinfo.inspect.utils.HiKUtil; import lombok.AllArgsConstructor; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.CollectionUtil; @@ -16,6 +26,7 @@ import org.springblade.core.tool.utils.Func; import org.springframework.stereotype.Service; import java.util.List; +import java.util.stream.Collectors; /** * 服务实现类 @@ -28,6 +39,9 @@ public class TaskObjectServiceImpl extends BaseServiceImpl getTaskObjectList(TaskObjectEntity taskObjectEntity) { @@ -57,4 +71,26 @@ public class TaskObjectServiceImpl extends BaseServiceImpl getExObjectData(List taskIds) { return this.baseMapper.getExObjectData(taskIds); } + + @Override + public List getVideosByObjId(Long taskId, Long objId) { + LambdaQueryWrapper projectQueryWrapper = Wrappers.lambdaQuery() + .eq(TaskObjectProjectEntity::getTaskId, taskId) + .eq(TaskObjectProjectEntity::getObjectId, objId); + List TaskProjectList = taskObjectProjectService.list(projectQueryWrapper); + List result = TaskProjectList.stream().map(TaskObjectProjectEntity::getProjectId).filter(Func::isNotEmpty).flatMap( + proId -> robotTaskMapper.selectList(Wrappers.lambdaQuery().eq(RobotTaskEntity::getProjectId, proId)).stream().map(r -> cameraInfoService.getById(r.getCameraId())) + ).filter(Func::isNotEmpty).map(this::convert).collect(Collectors.toList()); + return result; + } + + private StationVideoTypeEntity convert(CameraInfoEntity cameraInfoEntity) { + StationVideoTypeEntity result = new StationVideoTypeEntity(); + result.setName(cameraInfoEntity.getName()); + result.setVideoHost(HiKUtil.HOST); + result.setAppKey(HiKUtil.APP_KEY); + result.setAppSecret(HiKUtil.APP_SECRET); + result.setPointCode(cameraInfoEntity.getPointCode()); + return result; + } } diff --git a/hzims-service/inspect/src/main/resources/db/2.0.0.sql.1 b/hzims-service/inspect/src/main/resources/db/2.0.0.sql.1 index ac96636..bedd5d8 100644 --- a/hzims-service/inspect/src/main/resources/db/2.0.0.sql.1 +++ b/hzims-service/inspect/src/main/resources/db/2.0.0.sql.1 @@ -1,3 +1,10 @@ ALTER TABLE `hzims-inspect`.`hz_st_ex_task_user` MODIFY COLUMN `CLAIM_STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '领用状态 0:未领用 1:已领用 每条任务可以存在多个用户,但是只有一个领用人' AFTER `USER_ID`; -ALTER TABLE `hzims-inspect`.`hz_st_ex_task_user` ADD COLUMN `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `TENANT_ID`; \ No newline at end of file +ALTER TABLE `hzims-inspect`.`hz_st_ex_task_user` ADD COLUMN `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `TENANT_ID`; + +alter table `hz_st_ex_task` add column `hik_video_task_id` varchar(50) default null comment '海康录制视频任务ID'; +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_camera_info` add column `em_code` varchar(50) default null comment '设备编号'; \ No newline at end of file diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java index ac8a05a..a19b2b6 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java @@ -12,6 +12,7 @@ import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; +import java.util.Map; public interface IMessagePushRecordService extends BaseService { diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/controller/MsgPushStatisticController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/controller/MsgPushStatisticController.java index d887ec5..57448ff 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/controller/MsgPushStatisticController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/controller/MsgPushStatisticController.java @@ -1,6 +1,7 @@ package com.hnac.hzims.message.statistics.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.common.statistics.Charts; import com.hnac.hzims.message.dto.statistic.MsgPushStatisticDto; import com.hnac.hzims.message.statistics.service.IMsgPushStatisticService; import com.hnac.hzims.message.vo.statistic.MsgPushStatisticVO; @@ -36,4 +37,8 @@ public class MsgPushStatisticController extends BladeController { return R.data(msgPushStatisticService.getMsgPushStatistic(msgPushStatisticDto)); } + public R getMsgPushStat(MsgPushStatisticDto req) { + return R.data(msgPushStatisticService.getMsgPushStat(req)); + } + } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/service/IMsgPushStatisticService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/service/IMsgPushStatisticService.java index 157715b..bd6019f 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/service/IMsgPushStatisticService.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/service/IMsgPushStatisticService.java @@ -1,5 +1,6 @@ package com.hnac.hzims.message.statistics.service; +import com.hnac.hzims.common.statistics.Charts; import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.statistic.MsgPushStatisticDto; @@ -27,6 +28,8 @@ public interface IMsgPushStatisticService { */ List getMsgPushStatistic(MsgPushStatisticDto msgPushStatisticDto); + Charts getMsgPushStat(MsgPushStatisticDto req); + /** * 处理年、月、日查询日期格式 填充开始时间以及结束时间 * @param msgPushStatisticDto diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/service/impl/MsgPushStatisticServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/service/impl/MsgPushStatisticServiceImpl.java index 3280537..26b84d8 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/service/impl/MsgPushStatisticServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/statistics/service/impl/MsgPushStatisticServiceImpl.java @@ -1,19 +1,34 @@ package com.hnac.hzims.message.statistics.service.impl; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; +import com.hnac.hzims.common.statistics.Charts; +import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.constants.DictKeyConstants; import com.hnac.hzims.message.dto.statistic.MsgPushStatisticDto; +import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.log.mapper.AppLogMapper; import com.hnac.hzims.message.log.mapper.MailLogMapper; import com.hnac.hzims.message.log.mapper.SmsLogMapper; +import com.hnac.hzims.message.service.IMessagePushRecordService; import com.hnac.hzims.message.statistics.service.IMsgPushStatisticService; import com.hnac.hzims.message.vo.statistic.MsgPushStatisticVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.cache.DictCache; +import org.springblade.system.entity.Dict; import org.springframework.stereotype.Service; +import java.text.DateFormat; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.IntStream; /** * @author hx @@ -26,6 +41,7 @@ public class MsgPushStatisticServiceImpl implements IMsgPushStatisticService { private final AppLogMapper appLogMapper; private final MailLogMapper mailLogMapper; private final SmsLogMapper smsLogMapper; + private final IMessagePushRecordService messagePushRecordService; @Override public List getMsgPushStatistic(MsgPushStatisticDto msgPushStatisticDto) { @@ -50,4 +66,28 @@ public class MsgPushStatisticServiceImpl implements IMsgPushStatisticService { } return result; } + + @Override + public Charts getMsgPushStat(MsgPushStatisticDto req) { + List types = DictCache.getList(DictKeyConstants.MESSAGE_TYPE); + Charts charts = new Charts(); + if(CollectionUtil.isNotEmpty(types)) { + charts.setLegends(types.stream().map(Dict::getDictValue).collect(Collectors.toList())); + charts.setXAxis(this.getFullMonth()); + Function> getCountByType = messageType -> { + + return Lists.newArrayList(); + }; + charts.setSeries(types.stream().map(Dict::getDictKey).map(getCountByType).collect(Collectors.toList())); + } + return charts; + } + + private List getFullMonth() { + YearMonth now = YearMonth.now(); + return IntStream.iterate(0, index -> index + 1).limit(12) + .mapToObj(index -> now.minusMonths(index)) + .map(yearMonth -> yearMonth.format(DateUtil.monthFormatter)) + .collect(Collectors.toList()); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java index 233d91c..a2c8afa 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java @@ -23,6 +23,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; import org.springblade.flow.core.entity.BladeFlow; @@ -163,6 +164,9 @@ public class MaintenanceTaskSchedule { OperMaintenanceTaskEntityVo vo = BeanUtil.copy(task,OperMaintenanceTaskEntityVo.class); Map params = new HashMap() {{ put("taskId", task.getId()); + if(Func.isEmpty(AuthUtil.getUser())) { + put("startFlowUserId", task.getCreateUser().toString()); + } String userId = task.getDisposer(); List userIds = Stream.of(userId.split(",")).collect(Collectors.toList()); Stream.iterate(0, i -> i + 1).limit(5).forEach(index -> { diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/AccidentController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/AccidentController.java index 51e90c8..79bb618 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/AccidentController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/AccidentController.java @@ -50,9 +50,6 @@ public class AccidentController extends BladeController { private final IAccidentService accidentService; private final IOssClient ossClient; - private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - private static final ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock(); - private static final ReentrantReadWriteLock.ReadLock readLock = lock.readLock(); @PostMapping("/save") @ApiOperation("事故管理保存") @@ -67,19 +64,8 @@ public class AccidentController extends BladeController { @ApiOperation("事故管理查询详情") @ApiOperationSupport(order = 2) public R detail(@PathVariable(value = "id") Long id) { - AccidentVO accidentVO = null; - readLock.lock(); - try { - AccidentEntity accidentEntity = accidentService.getById(id); - if (ObjectUtil.isNotEmpty(accidentEntity)) { - accidentVO = AccidentWrapper.build().entityVO(accidentEntity); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - readLock.unlock(); - } - return R.data(accidentVO); + AccidentEntity accidentEntity = accidentService.getById(id); + return R.data(AccidentWrapper.build().entityVO(accidentEntity)); } @PostMapping("updateById") @@ -87,16 +73,8 @@ public class AccidentController extends BladeController { @ApiOperationSupport(order = 3) @Transactional(rollbackFor = Exception.class) public R updateById(@RequestBody @Valid AccidentDTO req) { - writeLock.lock(); - try { - AccidentEntity accidentEntity = BeanUtil.copy(req, AccidentEntity.class); - accidentService.updateById(accidentEntity); - } catch (Exception e) { - e.printStackTrace(); - } finally { - writeLock.unlock(); - } - return R.success("操作成功"); + AccidentEntity accidentEntity = BeanUtil.copy(req, AccidentEntity.class); + return R.status(accidentService.updateById(accidentEntity)); } @PutMapping("/remove/{ids}")