From 096099b9cf1ab08c34db145f46df4d0e940b0646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Tue, 18 Apr 2023 20:33:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B0=B4=E7=94=B5=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=8A=A5=E5=91=8A=E8=AF=A6=E6=83=85=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../access/entity/OperAccessTaskEntity.java | 13 + .../defect/entity/OperPhenomenonEntity.java | 22 + .../inspect/areamonthly/feign/TaskFeignClient.java | 17 +- .../feign/fallback/TaskFeignClientFallback.java | 13 + .../inspect/areamonthly/vo/TaskListQuery.java | 2 +- .../areamonthly/feign/CheckCompanyFeignClient.java | 3 +- .../areamonthly/feign/SafeproductFeignClient.java | 4 +- .../hzims/safeproduct/entity/CheckMonthEntity.java | 2 +- .../inspect/task/controller/TaskController.java | 17 + .../hnac/hzinfo/inspect/task/mapper/TaskMapper.xml | 8 +- .../hzinfo/inspect/task/service/ITaskService.java | 11 + .../inspect/task/service/impl/TaskServiceImpl.java | 1812 ++++++++++---------- .../hnac/hzinfo/inspect/task/vo/TaskListQuery.java | 2 +- .../access/dto/OperAccessStatisticsDTO.java | 2 +- .../access/mapper/OperAccessStatisticsMapper.xml | 4 +- .../access/service/IOperAccessTaskService.java | 10 + .../service/impl/OperAccessTaskServiceImpl.java | 801 ++++----- .../controller/OperPhenomenonController.java | 226 +-- .../defect/service/impl/OperDefectServiceImpl.java | 2 +- .../web/AreaMonthlyDetailsController.java | 81 +- .../main/service/AreaMonthlyDetailsService.java | 3 +- .../impl/AreaMonthlyDetailsServiceImpl.java | 5 +- .../impl/OperMaintenanceTaskServiceImpl.java | 6 +- .../src/main/resources/application-dev.yml | 2 + .../hzims/safeproduct/mapper/CheckMonthMapper.java | 6 - .../hzims/safeproduct/mapper/CheckMonthMapper.xml | 5 +- .../serviceimpl/MaintenanceTempleServiceImpl.java | 3 +- 27 files changed, 1632 insertions(+), 1450 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java index 74a99b7..374114b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java @@ -13,6 +13,7 @@ import org.springblade.core.tenant.mp.TenantEntity; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; +import java.time.YearMonth; import java.util.Date; /** @@ -147,4 +148,16 @@ public class OperAccessTaskEntity extends TenantEntity { @ApiModelProperty("票据是否作废,仅当两票作废更新状态时使用") @TableField(exist = false) private boolean isInvalid; + + + @ApiModelProperty("区域Id") + @TableField(exist = false) + private String areaId; + + + @ApiModelProperty("年月") + @TableField(exist = false) + private YearMonth yearMonth; + + } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java index d63c97f..c61c6cc 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java @@ -1,6 +1,7 @@ package com.hnac.hzims.operational.defect.entity; import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -14,6 +15,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.springframework.format.annotation.DateTimeFormat; +import java.time.YearMonth; import java.util.Date; import java.time.LocalDateTime; @@ -286,4 +288,24 @@ public class OperPhenomenonEntity extends TenantEntity { @ApiModelProperty(value = "核算工时") private Integer checkHours; + + @ApiModelProperty(value = "年月") + @TableField(exist = false) + private YearMonth yearMonth; + + + @ApiModelProperty(value = "年月") + @TableField(exist = false) + private String areaId; + + + @ApiModelProperty(value = "是否为缺陷 直接传0") + @TableField(exist = false) + private Integer defect; + + + @ApiModelProperty(value = "已定论1") + @TableField(exist = false) + private Integer conclusionStatusNum; + } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/TaskFeignClient.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/TaskFeignClient.java index ba56f8c..3f4803c 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/TaskFeignClient.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/TaskFeignClient.java @@ -5,11 +5,14 @@ import com.hnac.hzinfo.inspect.areamonthly.vo.TaskListQuery; import com.hnac.hzinfo.inspect.areamonthly.vo.TaskVo; import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import static com.hnac.hzinfo.inspect.Constants.APP_NAME; @@ -26,9 +29,21 @@ public interface TaskFeignClient { @GetMapping("/task/list") @ApiOperation(value = "分页显示任务列表", notes = "传入task") - public R> list(TaskListQuery task, Query query); + public R> list(@SpringQueryMap TaskListQuery task,@SpringQueryMap Query query); @GetMapping(value = "/task/detail") @ApiOperation(value = "查看,下面列表再调用eventController.list", notes = "传入taskid") public R detail(@RequestParam Long id); + + + + /** + * 巡检任务分页 + */ + @GetMapping("/task/pageList/{page}/{size}") + @ApiOperation(value = "分页显示任务列表", notes = "传入task") + public R> pageList( + @ApiParam(name = "page", value = "当前页", required = true) @PathVariable("page") Long page, + @ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size, + @SpringQueryMap TaskListQuery task); } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/fallback/TaskFeignClientFallback.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/fallback/TaskFeignClientFallback.java index adbbad2..6acac03 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/fallback/TaskFeignClientFallback.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/feign/fallback/TaskFeignClientFallback.java @@ -30,4 +30,17 @@ public class TaskFeignClientFallback implements TaskFeignClient { public R detail(Long id) { return R.fail("远程调用失败"); } + + /** + * 巡检任务分页 + * + * @param page + * @param size + * @param task + */ + @Override + public R> pageList(Long page, Long size, TaskListQuery task) { + return R.fail("远程调用失败"); + } + } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/vo/TaskListQuery.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/vo/TaskListQuery.java index a8e08e5..0776caa 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/vo/TaskListQuery.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/areamonthly/vo/TaskListQuery.java @@ -127,7 +127,7 @@ public class TaskListQuery implements Serializable { * 月份 */ @ApiModelProperty("月份") - private YearMonth yearmonth; + private YearMonth yearMonth; /** * 区域Id diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/CheckCompanyFeignClient.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/CheckCompanyFeignClient.java index 9e7f665..8a8bc0c 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/CheckCompanyFeignClient.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/CheckCompanyFeignClient.java @@ -11,6 +11,7 @@ import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -33,7 +34,7 @@ public interface CheckCompanyFeignClient { @GetMapping("/CheckCompany/list") @ApiOperationSupport(order = 50) @ApiOperation(value = "分页", notes = "查询条件:startDate,endDate,status") - R> list(CheckCompanyEntity req, Query query); + R> list(@SpringQueryMap CheckCompanyEntity req,@SpringQueryMap Query query); /** diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeproductFeignClient.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeproductFeignClient.java index a12b162..ca82045 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeproductFeignClient.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeproductFeignClient.java @@ -13,6 +13,7 @@ import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; @@ -32,7 +33,8 @@ public interface SafeproductFeignClient { @GetMapping("/checkMonth/listconferenceScope/{page}/{size}") @ApiOperationSupport(order = 50) @ApiOperation(value = "分页", notes = "查询条件:month,status,createDept") - public R> listconferenceScope(@PathVariable Long page, @PathVariable Long size, CheckMonthEntity req); + public R> listconferenceScope(@PathVariable Long page, @PathVariable Long size, + @SpringQueryMap CheckMonthEntity req); /** diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckMonthEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckMonthEntity.java index de8ae87..c0ba2f7 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckMonthEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckMonthEntity.java @@ -48,7 +48,7 @@ public class CheckMonthEntity extends TenantEntity implements Serializable { */ @TableField(exist = false) @ApiModelProperty("月份") - private YearMonth yearMonth; + private String yearMonth; 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 7273e46..3f4ac5d 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 @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fasterxml.jackson.annotation.JsonRawValue; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.google.common.collect.Lists; import com.hnac.hzinfo.core.push.enums.PushAudienceType; @@ -331,4 +332,20 @@ public class TaskController extends BladeController { } + + /** + * 巡检任务分页 + */ + @GetMapping("/pageList/{page}/{size}") + @ApiOperation(value = "分页显示任务列表", notes = "传入task") + public R> pageList( + @ApiParam(name = "page", value = "当前页", required = true) @PathVariable("page") Long page, + @ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size, + TaskListQuery task){ + Page pageInfo = new Page<>(); + BladePage pageList = taskService.selectPage(pageInfo,task); + return R.data(pageList); + } + + } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml index 7862d45..e441257 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml @@ -162,11 +162,11 @@ and FIND_IN_SET(t.ID,#{task.taskIds}) - - and t.CREATE_DEPT = #{task.areaId}) + + and t.CREATE_DEPT = #{task.areaId} - - and date_format(t.PLAN_START_TIME,'%Y-%m')= #{task.yearmonth}) + + and date_format(t.PLAN_START_TIME,'%Y-%m')= #{task.yearMonth} order by t.UPDATE_TIME desc diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java index 8d8f706..9a4186f 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java @@ -1,11 +1,13 @@ package com.hnac.hzinfo.inspect.task.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.vo.SafeCheckStatisticVO; import com.hnac.hzinfo.inspect.task.entity.InspectionTaskSMS; import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import com.hnac.hzinfo.inspect.task.vo.*; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.BladePage; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.RequestParam; @@ -174,4 +176,13 @@ public interface ITaskService extends BaseService { * @return */ boolean collectingTask(List taskIds); + + + /** + * 巡检任务分页 + * @param pageInfo + * @param task + * @return + */ + BladePage selectPage(Page pageInfo, TaskListQuery task); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index 219bfd4..8c75bef 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -1,8 +1,12 @@ package com.hnac.hzinfo.inspect.task.service.impl; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.entity.ImsMonCameraInfoEntity; @@ -26,8 +30,10 @@ import com.hnac.hzinfo.inspect.task.vo.*; import com.hnac.hzinfo.inspect.utils.HiKUtil; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.mp.support.BladePage; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tool.api.R; @@ -37,6 +43,7 @@ import org.springblade.system.cache.DictCache; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -57,918 +64,919 @@ import java.util.stream.Collectors; @AllArgsConstructor public class TaskServiceImpl extends BaseServiceImpl implements ITaskService { - @Autowired - private ITaskObjectService taskObjectService; - @Autowired - private IEventService eventService; - @Autowired - private ITaskUserService taskUserService; - @Autowired - private ITaskObjectProjectService taskObjectProjectService; - @Autowired - private ITaskObjectProjectContentService taskObjectProjectContentService; - @Autowired - private ISysClient sysClient; - @Autowired - private IEventRecordService eventRecordService; - - private IImsMonCameraInfoClient cameraInfoClient; - @Autowired - private IRobotService robotService; - @Autowired - private ITaskResultService taskResultService; - @Autowired - private IObjectDangerService objectDangerService; - @Autowired - private PlanMapper planMapper; - - @Autowired - private TaskNoUserDataScopeMapper taskNoUserDataScopeMapper; - - /** - * 正在调用开始任务的id集合 - */ - static Set startTaskIds = new HashSet<>(); - - /** - * startTaskIds 已经存在该id - * - * @param id - * @return - */ - public static boolean hasExistStartId(Long id) { - return startTaskIds.contains(id); - } - - public static synchronized boolean addStartTaskId(Long id) { - return startTaskIds.add(id); - } - - public static boolean removeStartTaskId(Long id) { - return startTaskIds.remove(id); - } - - /** - * 删除任务,任务的所有关联表 - * - * @param planId - * @return - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean deleteTaskByPlanId(Long planId) { - eventService.deleteEventByPlanId(planId); - taskResultService.remove(Wrappers.lambdaQuery().eq(TaskResultEntity::getPlanId, planId)); - taskUserService.deleteByPlanId(planId); - return remove(Wrappers.lambdaQuery().eq(TaskEntity::getPlanId, planId)); - } - - /** - * 如果项目下面的任务都完成了,则变更项目状态为已完成 - * - * @param eventAddVO - */ - @Override - public void checkProjectFinish(EventAddVO eventAddVO) { - List topcList = taskObjectProjectContentService.list(Wrappers.lambdaQuery() - .eq(TaskObjectProjectContentEntity::getTaskId, eventAddVO.getTaskId()) - .eq(TaskObjectProjectContentEntity::getObjectId, eventAddVO.getObjId()) - .eq(TaskObjectProjectContentEntity::getProjectId, eventAddVO.getProjectId())); - - if (Func.isNotEmpty(topcList)) { - for (TaskObjectProjectContentEntity content : topcList) { - if (content.getAvailable().equals(TaskContants.AvailableEnum.yes.getType())) { - return; - } - } - } - - /** 任务项目状态设置为已完成*/ - taskObjectProjectService.update(Wrappers.lambdaUpdate() - .set(TaskObjectProjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()) - .eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()) - .eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId()) - .eq(TaskObjectProjectEntity::getProjectId, eventAddVO.getProjectId())); - - checkObjFinish(eventAddVO); - } - - /** - * 如果对象下面的任务都完成了,则变更对象状态为已完成 - * - * @param eventAddVO - */ - private void checkObjFinish(EventAddVO eventAddVO) { - List topList = taskObjectProjectService.list(Wrappers.lambdaQuery() - .eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()) - .eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId())); - - - if (Func.isNotEmpty(topList)) { - for (TaskObjectProjectEntity project : topList) { - if (project.getStatus().equals(TaskContants.StatusEnum.INIT_STATUS.getStatus())) { - return; - } - } - } - - /** 任务项目状态设置为已完成*/ - taskObjectService.update(Wrappers.lambdaUpdate() - .set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()) - .eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId()) - .eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId())); - - checkTaskFinish(eventAddVO); - } - - /** - * 如果任务下面的对象都完成了,则变更任务状态为已完成 - * - * @param eventAddVO - */ - @Override - public void checkTaskFinish(EventAddVO eventAddVO) { - List topList = taskObjectService.list(Wrappers.lambdaQuery() - .eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId())); - - if (Func.isNotEmpty(topList)) { - for (TaskObjectEntity obj : topList) { - if (obj.getStatus().equals(TaskContants.StatusEnum.INIT_STATUS.getStatus())) { - return; - } - } - } - /** 任务更新为完成状态 */ - modifyTaskStatus(eventAddVO.getTaskId(), Integer.valueOf(TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus())); - } - - @Override - public Boolean modifyTaskStatus(Long id, Integer status) { - TaskEntity task = this.getById(id); - task.setStatus(status); - if (TaskStatusEnum.UNDERWAY_STATUS.getStatus().equals(status.toString())) {//恢复任务 - //处理同时开启几个任务的情况 - checkOpenMutipleTask(AuthUtil.getUserId()); - } - if (TaskStatusEnum.FINISH_STATUS.getStatus().equals(status.toString())) {//任务完成 - task.setEndTime(LocalDateTime.now()); - List taskObjs = taskObjectService.list(Wrappers.query().lambda().eq(TaskObjectEntity::getTaskId, task.getId())); - for (TaskObjectEntity taskObj : taskObjs) { - if (taskObj.getStatus().equals(TaskContants.StatusEnum.INIT_STATUS.getStatus())) { - log.error("该任务未登记完成,不可结束。"); - throw new ServiceException("该任务未登记完成,不可结束。"); - } - } - } - return this.updateById(task); - } - - /** - * 开始任务 - */ - @Override - @Transactional - public Boolean startTask(Long id) { - TaskEntity task = this.getById(id); - - if (hasExistStartId(id) || !addStartTaskId(id)) { - throw new ServiceException("该任务有人在领用,请稍后重试"); - } - //检查任务 - checkOpenMutipleTask(AuthUtil.getUserId()); - TaskUserEntity userEntity = taskUserService.getOne(Wrappers.lambdaQuery() - .eq(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) - .eq(TaskUserEntity::getTaskId, task.getId())); - if (Func.isNotEmpty(userEntity)) { - removeStartTaskId(id); - throw new ServiceException("该任务已被领用,请刷新页面"); - } - - //给当前人领取任务 - taskUserService.update(Wrappers.lambdaUpdate() - .set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) - .set(TaskUserEntity::getClaimTime, LocalDateTime.now()) - .eq(TaskUserEntity::getTaskId, task.getId()) - .eq(TaskUserEntity::getUserId, AuthUtil.getUserId())); - //如果是抢占任务,删除能够抢占此任务的其他人 - if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { - taskUserService.remove(Wrappers.lambdaQuery() - .eq(TaskUserEntity::getTaskId, task.getId()) - .ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) - .ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); - } - task.setStatus(Integer.valueOf(TaskStatusEnum.UNDERWAY_STATUS.getStatus())); - task.setStartTime(LocalDateTime.now()); - boolean re = this.updateById(task); - removeStartTaskId(id); - return re; - } - - /** - * 检查任务 - */ - public void checkOpenMutipleTask(Long userId) { - R r = sysClient.getParamValue(TaskContants.OPEN_MULTIPLE_TASK); - if (r.isSuccess() && "0".equals(r.getData())) {//处理同时开启几个任务的情况 - int count = taskUserService.count(Wrappers.query().lambda().eq(TaskUserEntity::getUserId, userId).eq(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus())); - if (count > 0) { - log.error("不能同时开启两个巡检任务"); - throw new ServiceException("不能同时开启两个巡检任务"); - } - } - } - - /** - * 机器人 - * 开始任务 - */ - @Override - public Boolean startTaskForRobot(Long id, Long userId) { - TaskEntity task = this.getById(id); - //检查任务 - checkOpenMutipleTask(userId); - //给当前人领取任务 - taskUserService.update(Wrappers.lambdaUpdate() - .set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) - .set(TaskUserEntity::getClaimTime, LocalDateTime.now()) - .eq(TaskUserEntity::getTaskId, task.getId()) - .eq(TaskUserEntity::getUserId, userId)); - //如果是抢占任务,删除能够抢占此任务的其他人 - if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { - taskUserService.remove(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getId, userId)); - } - task.setStatus(Integer.valueOf(TaskStatusEnum.UNDERWAY_STATUS.getStatus())); - task.setStartTime(LocalDateTime.now()); - return this.updateById(task); - } - - /** - * 获取任务 项目list - * - * @param taskId - * @return - */ - @Override - public List getObjPrj(Long taskId) { - List list = taskObjectService.list(Wrappers.lambdaQuery().eq(TaskObjectEntity::getTaskId, taskId)); - List result = Lists.newArrayList(); - for (TaskObjectEntity taskObject : list) { - TaskObjectVO vo = TaskObjectVO.builder().objId(taskObject.getObjectId()).taskId(taskObject.getTaskId()).objName(taskObject.getName()).build(); - List taskObjectProjectList = taskObjectProjectService.list(Wrappers.lambdaQuery() - .eq(TaskObjectProjectEntity::getTaskId, taskObject.getTaskId()) - .eq(TaskObjectProjectEntity::getObjectId, taskObject.getObjectId())); - List projectVOList = Lists.newArrayList(); - for (TaskObjectProjectEntity taskObjectProject : taskObjectProjectList) { - TaskObjectProjectVO projectVO = TaskObjectProjectVO.builder().projectId(taskObjectProject.getProjectId()).projectName(taskObjectProject.getName()).build(); - List taskObjectProjectContentList = taskObjectProjectContentService.list(Wrappers.lambdaQuery() - .eq(TaskObjectProjectContentEntity::getTaskId, taskObjectProject.getTaskId()) - .eq(TaskObjectProjectContentEntity::getObjectId, taskObjectProject.getObjectId()) - .eq(TaskObjectProjectContentEntity::getProjectId, taskObjectProject.getProjectId())); - List eventIds = eventService.list(Wrappers.lambdaQuery() - .eq(EventEntity::getTaskId, taskId) - .eq(EventEntity::getObjectId, taskObject.getObjectId()) - .eq(EventEntity::getProjectId, taskObjectProject.getProjectId())).stream().map(entity -> entity.getId()).collect(Collectors.toList()); - List contentVOList = Lists.newArrayList(); - for (TaskObjectProjectContentEntity entity : taskObjectProjectContentList) { - TaskObjectProjectContentVO contentVO = BeanUtil.copy(entity, TaskObjectProjectContentVO.class); - if ("0".equals(contentVO.getAvailable()) && eventIds.size() > 0) {//不可重复记录时,需要显示之前记录的值 - EventRecordEntity ere = eventRecordService.getOne(Wrappers.lambdaQuery() - .in(EventRecordEntity::getEventId, eventIds) - .eq(EventRecordEntity::getObjectId, taskObject.getObjectId()) - .eq(EventRecordEntity::getProjectId, taskObjectProject.getProjectId()) - .eq(EventRecordEntity::getContentId, contentVO.getContentId()).last("LIMIT 1")); - contentVO.setCurrentStatus(ere.getCurrentStatus()); - contentVO.setCurrentValue(ere.getCurrentValue()); - contentVO.setFileUrl(ere.getFileUrl()); - } - contentVOList.add(contentVO); - } - projectVO.setContents(contentVOList); - projectVOList.add(projectVO); - } - vo.setProjects(projectVOList); - result.add(vo); - } - return result; - } - - /** - * 根据计划开始时间结束时间及创建部门查询任务 - * - * @param startTime - * @param endTime - * @param depts - * @return - */ - @Override - public List queryByPlanStartTime(String startTime, String endTime, List depts) { - return this.baseMapper.selectByPlanStartTime(startTime, endTime, depts); - } - - @Override - public List getInspectTaskReport(String startDate, String endDate, List deptIdList) { - List result = new ArrayList<>(); - List taskCountVOList = getTaskCountByTime(startDate, endDate, deptIdList); - Map> userMap = taskCountVOList.stream().collect(Collectors.groupingBy(TaskCountVO::getUserId)); - userMap.forEach((userId, list) -> { - User user = UserCache.getUser(userId); - if (ObjectUtil.isEmpty(user)) { - return; - } - if (CollectionUtil.isNotEmpty(list)) { - TaskReportVO taskReportVO = new TaskReportVO(); - taskReportVO.setUserId(userId); - taskReportVO.setHours(list.stream().mapToLong(TaskCountVO::getHours).sum()); - //巡检任务完成情况 - String finishSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))) - .map(vo -> DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()).concat(":").concat(String.valueOf(Optional.ofNullable(vo.getFinishTask()).orElse(0)))).collect(Collectors.joining("\r\n")); - //巡检任务未完成情况 - String undoSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))) - .map(vo -> DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()).concat(":").concat(String.valueOf(Optional.ofNullable(vo.getUndoneTask()).orElse(0)))).collect(Collectors.joining("\r\n")); - taskReportVO.setCompleteNum(list.stream().filter(taskCountVO -> Func.isNotEmpty(taskCountVO.getFinishTask())).collect(Collectors.summingInt(TaskCountVO::getFinishTask))); - taskReportVO.setCompleteSituation(finishSituation); - taskReportVO.setIncompleteNum(list.stream().filter(taskCountVO -> Func.isNotEmpty(taskCountVO.getUndoneTask())).collect(Collectors.summingInt(TaskCountVO::getUndoneTask))); - taskReportVO.setIncompleteSituation(undoSituation); - taskReportVO.setUserName(user.getName()); - result.add(taskReportVO); - } - }); - return result; - } - - @Override - public Map getReportConclusion(String startDate, String endDate, List deptIdList) { - Map result = new HashMap<>(); - List taskCountVOList = getTaskCountByTime(startDate, endDate, deptIdList); - taskCountVOList = taskCountVOList.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(taskCountVOList)) { - result.put("INSPECT_TASK_COUNT", taskCountVOList.stream().mapToInt(vo -> Optional.ofNullable(vo.getFinishTask()).orElse(0) + Optional.ofNullable(vo.getUndoneTask()).orElse(0)).sum()); - result.put("INSPECT_COMPLETE_TASK_COUNT", taskCountVOList.stream().filter(t -> Func.isNotEmpty(t.getFinishTask())).mapToInt(TaskCountVO::getFinishTask).sum()); - result.put("PROBLEM_NUM", null); - } - return result; - } - - @Override - public List getTaskCountByTime(String startDate, String endDate, List deptIdList) { - return this.baseMapper.selectReportByTime(startDate, endDate, deptIdList); - } - - @Override - public R getInspectTaskCheck(String startDate, String endDate, Long dept, String inspectType) { - log.info("进入getInspectTaskCheck方法"); - SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); - //获取已完成任务 - List taskEntityList = this.baseMapper.getInspectTaskCheck(startDate, endDate, dept); - //获取运行人员角色ID - //log.info("Auth:{};tenantId:{}", JSON.toJSONString(AuthUtil.getUser()),AuthUtil.getTenantId()); - R roleIdR = sysClient.getRoleIds("200000", "运行人员"); - if (!roleIdR.isSuccess() || Func.isEmpty(roleIdR.getData())) { - throw new ServiceException("获取运行人员角色失败"); - } - if (CollectionUtil.isNotEmpty(taskEntityList)) { - List operators = taskEntityList.stream().filter(task -> { - //筛选出运行人员的记录 - User user = UserCache.getUser(task.getUserId()); - //log.info("{}角色ID为:{}",user.getName(),user.getRoleId()); - if (ObjectUtil.isEmpty(user)) { - return false; - } - return Arrays.asList(user.getRoleId().split(",")).contains(roleIdR.getData()) ? true : false; - }).collect(Collectors.toList()); - //根据传参分类型获取巡检任务统计情况 - if ("1".equals(inspectType)) { - vo.setProjectType(Constants.SafeCheckProjectEnum.OPERATE_INSPECT_TASK.getType()); - vo.setProjectTypeName(Constants.SafeCheckProjectEnum.OPERATE_INSPECT_TASK.getName()); - vo.setTotal(operators.size()); - } else if ("2".equals(inspectType)) { - vo.setProjectType(Constants.SafeCheckProjectEnum.OTHER_INSPECT_TASK.getType()); - vo.setProjectTypeName(Constants.SafeCheckProjectEnum.OTHER_INSPECT_TASK.getName()); - vo.setTotal(taskEntityList.size() - operators.size()); - } - } - return R.data(vo); - } - - @Override - public List getTaskData(List userIds, String currentDate) { - return this.baseMapper.getTaskData(userIds, currentDate); - } - - public List getTaskById0(Long id) { - TaskEntity task = this.getById(id); - PlanEntity plan = planMapper.selectById(task.getPlanId()); - - List routObjects = new ArrayList<>(); - if (Func.isNotEmpty(plan.getRouteData())) { - routObjects = JsonUtil.parseArray(plan.getRouteData(), RoutObject.class); - } - Map routMap = new HashMap<>(); - for (RoutObject rout : routObjects) { - routMap.put(rout.getObjectId(), rout.getSort()); - } - - TaskObjectEntity toQuery = new TaskObjectEntity(); - toQuery.setTaskId(id); - List list = taskObjectService.getTaskObjectList(toQuery); - - List result = Lists.newArrayList(); - for (TaskObjectEntity taskObject : list) { - TaskObjectVO vo = TaskObjectVO.builder().objId(taskObject.getObjectId()).taskId(taskObject.getTaskId()).objName(taskObject.getName()).status(taskObject.getStatus()).build(); - - TaskObjectProjectEntity topQuery = new TaskObjectProjectEntity(); - topQuery.setTaskId(taskObject.getTaskId()); - topQuery.setObjectId(taskObject.getObjectId()); - List taskObjectProjectList = taskObjectProjectService.getTaskObjectProjectList(topQuery); - List projectVOList = Lists.newArrayList(); - for (TaskObjectProjectEntity taskObjectProject : taskObjectProjectList) { - TaskObjectProjectVO projectVO = TaskObjectProjectVO.builder().projectId(taskObjectProject.getProjectId()).projectName(taskObjectProject.getName()).status(taskObjectProject.getStatus()).build(); - - TaskObjectProjectContentEntity topcQuery = new TaskObjectProjectContentEntity(); - topcQuery.setTaskId(taskObjectProject.getTaskId()); - topcQuery.setObjectId(taskObjectProject.getObjectId()); - topcQuery.setProjectId(taskObjectProject.getProjectId()); - List taskObjectProjectContentList = taskObjectProjectContentService.getTaskObjectProjectContentList(topcQuery); - - EventEntity eventQuery = new EventEntity(); - eventQuery.setTaskId(id); - eventQuery.setObjectId(taskObject.getObjectId()); - eventQuery.setProjectId(taskObjectProject.getProjectId()); - List eventIds = eventService.getEventList(eventQuery) - .stream().map(entity -> entity.getId()).collect(Collectors.toList()); - List contentVOList = Lists.newArrayList(); - - for (TaskObjectProjectContentEntity entity : taskObjectProjectContentList) { - TaskObjectProjectContentVO contentVO = BeanUtil.copy(entity, TaskObjectProjectContentVO.class); - if ("0".equals(contentVO.getAvailable()) && eventIds.size() > 0) {//不可重复记录时,需要显示之前记录的值 - EventRecordEntity ere = eventRecordService.getOne(Wrappers.lambdaQuery() - .in(EventRecordEntity::getEventId, eventIds) - .eq(EventRecordEntity::getObjectId, taskObject.getObjectId()) - .eq(EventRecordEntity::getProjectId, taskObjectProject.getProjectId()) - .eq(EventRecordEntity::getContentId, contentVO.getContentId()).last("LIMIT 1")); - contentVO.setCurrentStatus(ere.getCurrentStatus()); - contentVO.setCurrentValue(ere.getCurrentValue()); - contentVO.setFileUrl(ere.getFileUrl()); - } - contentVOList.add(contentVO); - } - projectVO.setContents(contentVOList); - projectVOList.add(projectVO); - } - vo.setProjects(projectVOList); - vo.setDangers(objectDangerService.getDangerDetailByObjectId(taskObject.getObjectId())); - vo.setOrder(routMap.get(taskObject.getObjectId())); - result.add(vo); - } - return result; - } - - @Override - public List getTaskById(Long id) { - TaskEntity task = this.getById(id); - PlanEntity plan = planMapper.selectById(task.getPlanId()); - - List routObjects = new ArrayList<>(); - if (Func.isNotEmpty(plan.getRouteData())) { - routObjects = JsonUtil.parseArray(plan.getRouteData(), RoutObject.class); - } - Map routMap = new HashMap<>(); - for (RoutObject rout : routObjects) { - routMap.put(rout.getObjectId(), rout.getSort()); - } - - TaskObjectEntity toQuery = new TaskObjectEntity(); - toQuery.setTaskId(id); - List result = taskObjectService.getTaskObjectsDetail(toQuery); - result.forEach(vo -> { - vo.setDangers(objectDangerService.getDangerDetailByObjectId(vo.getObjId())); - vo.setOrder(routMap.get(vo.getObjId())); - log.info("---routMap:{};objId:{}---", JSONObject.toJSONString(routMap), vo.getObjId()); - }); - - return result.stream().sorted(Comparator.comparing(TaskObjectVO::getOrder)).collect(Collectors.toList()); - } - - @Override - public List getListPageOfTaskRecord(IPage page, TaskListQuery task) { - return this.baseMapper.getListPageOfTaskRecord(page, task); - } - - @Override - public List getListPage(IPage page, TaskListQuery task) { - List re = this.baseMapper.getListPage(page, task); - setVoInfo(re); - return re; - } - - @Override - public List mainQueryPage(IPage page, TaskListQuery task) { - List re = this.baseMapper.mainQueryPage(page, task); - return re; - } - - @Override - public List getListPageAuth(IPage page, TaskListQuery task) { - List re = this.baseMapper.getListPageAuth(page, task); - setVoInfo(re); - return re; - } - - /** - * phone端任务列表 - * - * @return - */ - @Override - public List getListPageOfPhone(IPage page, TaskListQuery task) { - List re = this.baseMapper.getListPageOfPhone(page, task); - for (TaskVo vo : re) { - vo.setCanCancel(false); - if ("0".equals(vo.getMethod())) { - if (vo.getStatus().equals(1) || vo.getStatus().equals(2)) { - EventEntity entity = eventService.getOne(Wrappers.lambdaQuery(EventEntity.class).eq(EventEntity::getTaskId, vo.getId()).last("LIMIT 1")); - if (entity == null) { - vo.setCanCancel(true); - } - } - } - } - setVoInfo(re); - return re; - } - - @Override - public List getFinishTaskList(IPage page, TaskListQuery task) { - List re = this.baseMapper.getFinishTaskList(page, task); - setVoInfo(re); - return re; - } - - @Transactional(rollbackFor = Exception.class) - @Override - public Boolean cancelStart(Long taskId) { - EventEntity entity = eventService.getOne(Wrappers.lambdaQuery(EventEntity.class).eq(EventEntity::getTaskId, taskId).last("LIMIT 1")); - if (entity != null) { - throw new ServiceException("该任务已有历史记录,不能撤销领用"); - } - taskUserService.update(Wrappers.lambdaUpdate(TaskUserEntity.class) - .eq(TaskUserEntity::getUserId, AuthUtil.getUserId()) - .eq(TaskUserEntity::getTaskId, taskId) - .set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.UN_COLLECT.getStatus()) - .set(TaskUserEntity::getClaimTime, null)); - taskUserService.updateDeleteStatus(taskId); - this.update(Wrappers.lambdaUpdate(TaskEntity.class) - .eq(TaskEntity::getId, taskId) - .set(TenantEntity::getStatus, TaskStatusEnum.INIT_STATUS.ordinal())); - return true; - } - - /** - * 机器人 - * 机器人获取当天任务列表 - * 只取第一条 - * - * @param - * @return - */ - @Override - public List getListOfPhone(String tenantId, Long userId) { - LocalDate now = LocalDate.now(); - DateTimeFormatter dfShort = DateTimeFormatter.ofPattern("yyyy-MM-dd "); - DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - TaskListQuery task = new TaskListQuery(); - task.setCurUserId(userId); - task.setTenantId(tenantId); - task.setPlanStartTimeEnd(LocalDateTime.now()); - task.setStartTime(LocalDateTime.now()); - /*task.setPlanStartTime(LocalDateTime.parse(dfShort.format(now) + "00:00:00", df)); - task.setPlanStartTimeEnd(LocalDateTime.now());*/ - task.setAutoVideo(PlanContants.InspectTypeEnum.ROBOT.getVal()); - List tasks = this.baseMapper.getListOfPhone(task); - setVoInfo(tasks); - return Func.isEmpty(tasks) ? new ArrayList<>() : Arrays.asList(tasks.get(0)); - } - - /** - * 设置机器人信息等 - * - * @param re - */ - private void setVoInfo(List re) { - if (Func.isNotEmpty(re)) { - for (TaskVo vo : re) { - if (Func.isNotEmpty(vo.getUserId())) { - vo.setUserName(UserCache.getUser(vo.getUserId()) == null ? "" : UserCache.getUser(vo.getUserId()).getName()); - } - if (vo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal())) { - //任务执行人 - TaskUserEntity query = taskUserService.getOne(Wrappers.lambdaQuery() - .eq(TaskUserEntity::getTaskId, vo.getId())); - if (Func.isNotEmpty(query)) { - vo.setRobot(robotService.getDetailByUserId(query.getUserId())); - } - } - } - } - } - - /** - * 海康sdk url :https://open.hikvision.com/docs/8530061f19534a9993e2afeb70e7c96a#d82bbc55 - * 摄像头截图方式:从视频云获取 - * 视频巡检没有执行人 - * TODO - * 执行视频自动巡检 - */ - public void execAutoVideoTask(Long taskId) { - //任务对象 - List taskObjectVOS = getTaskById(taskId); - for (TaskObjectVO objectVo : taskObjectVOS) { - // 对象项目 - List objectProjectVOs = objectVo.getProjects(); - for (TaskObjectProjectVO projectVo : objectProjectVOs) { - //对象项目内容 - List contentVOS = projectVo.getContents(); - //提交事件 - EventAddVO submitEventVo = new EventAddVO(); - //提交事件记录list - List submitRecords = new ArrayList<>(); - submitEventVo.setRecords(submitRecords); - - for (TaskObjectProjectContentVO content : contentVOS) { - //提交事件记录 - EventRecordAddVO submitRecord = new EventRecordAddVO(); - submitRecord.setContentId(content.getContentId()); - //当前值 - String currentVal = ""; - if (content.getCheckType().equals(ObjContants.CheckTypeEnum.AUTO_VIDEO.getType())) { - //视频巡检 存图 - if (content.getRecordType().equals(ObjContants.VideoCheckTypeEnum.PICTURE.getType())) { - submitRecord.setCurrentStatus(TaskContants.CurrentStatusEnum.normal.getType()); - ImsMonCameraInfoEntity query = new ImsMonCameraInfoEntity(); - query.setId(content.getCameraId()); - query = cameraInfoClient.detail(query).getData(); - if (Func.isNotEmpty(query)) { - //从摄像机取一张图片,存到iso - currentVal = HiKUtil.getIOSPicUrl(query.getPointCode()); - } else { - log.error("content id = " + content.getContentId() + ", cameraId = " + content.getCameraId() + " 摄像头信息为空"); - } - } - // TODO 识别 存值 - else if (content.getRecordType().equals(ObjContants.VideoCheckTypeEnum.IDENTIFY.getType())) { - - } - submitRecord.setCurrentValue(currentVal); - } - submitRecords.add(submitRecord); - } - //提交事件 - eventService.addTaskEvent(submitEventVo); - } - //TODO 提交对象 - - } - } - - - /** - * hld - * 获取当前有效的任务 (状态不为3:完成,4:未完成以及计划结束时间未超过当前时间,并且为发开始前提醒短信) - * - * @param it - * @return - */ - @Override - public List selectTodayStartRemindTaskSMSListByPlanId(TaskEntity it) { - List result = this.baseMapper.selectTodayStartRemindTaskSMSListByPlanId(it); - if (Func.isNotEmpty(result)) { - for (InspectionTaskSMS sms : result) { - sms.setSmsDetail(); - } - } - return result; - } - - /** - * hld - * 获取当前有效的任务 (状态不为3:完成,4:未完成以及计划结束时间未超过当前时间,并且为发结束前提醒短信) - * - * @param it - * @return - */ - @Override - public List selectTodayEndRemindTaskSMSListByPlanId(TaskEntity it) { - List result = this.baseMapper.selectTodayEndRemindTaskSMSListByPlanId(it); - if (Func.isNotEmpty(result)) { - for (InspectionTaskSMS sms : result) { - sms.setSmsDetail(); - } - } - return result; - } - - /* - - */ + @Autowired + private ITaskObjectService taskObjectService; + @Autowired + private IEventService eventService; + @Autowired + private ITaskUserService taskUserService; + @Autowired + private ITaskObjectProjectService taskObjectProjectService; + @Autowired + private ITaskObjectProjectContentService taskObjectProjectContentService; + @Autowired + private ISysClient sysClient; + @Autowired + private IEventRecordService eventRecordService; + + private IImsMonCameraInfoClient cameraInfoClient; + @Autowired + private IRobotService robotService; + @Autowired + private ITaskResultService taskResultService; + @Autowired + private IObjectDangerService objectDangerService; + @Autowired + private PlanMapper planMapper; + + @Autowired + private TaskNoUserDataScopeMapper taskNoUserDataScopeMapper; + + /** + * 正在调用开始任务的id集合 + */ + static Set startTaskIds = new HashSet<>(); + + /** + * startTaskIds 已经存在该id + * + * @param id + * @return + */ + public static boolean hasExistStartId(Long id) { + return startTaskIds.contains(id); + } + + public static synchronized boolean addStartTaskId(Long id) { + return startTaskIds.add(id); + } + + public static boolean removeStartTaskId(Long id) { + return startTaskIds.remove(id); + } + + /** + * 删除任务,任务的所有关联表 + * + * @param planId + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean deleteTaskByPlanId(Long planId) { + eventService.deleteEventByPlanId(planId); + taskResultService.remove(Wrappers.lambdaQuery().eq(TaskResultEntity::getPlanId, planId)); + taskUserService.deleteByPlanId(planId); + return remove(Wrappers.lambdaQuery().eq(TaskEntity::getPlanId, planId)); + } + + /** + * 如果项目下面的任务都完成了,则变更项目状态为已完成 + * + * @param eventAddVO + */ + @Override + public void checkProjectFinish(EventAddVO eventAddVO) { + List topcList = taskObjectProjectContentService.list(Wrappers.lambdaQuery().eq(TaskObjectProjectContentEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectProjectContentEntity::getObjectId, eventAddVO.getObjId()).eq(TaskObjectProjectContentEntity::getProjectId, eventAddVO.getProjectId())); + + if (Func.isNotEmpty(topcList)) { + for (TaskObjectProjectContentEntity content : topcList) { + if (content.getAvailable().equals(TaskContants.AvailableEnum.yes.getType())) { + return; + } + } + } + + /** 任务项目状态设置为已完成*/ + taskObjectProjectService.update(Wrappers.lambdaUpdate().set(TaskObjectProjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()).eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId()).eq(TaskObjectProjectEntity::getProjectId, eventAddVO.getProjectId())); + + checkObjFinish(eventAddVO); + } + + /** + * 如果对象下面的任务都完成了,则变更对象状态为已完成 + * + * @param eventAddVO + */ + private void checkObjFinish(EventAddVO eventAddVO) { + List topList = taskObjectProjectService.list(Wrappers.lambdaQuery().eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId())); + + + if (Func.isNotEmpty(topList)) { + for (TaskObjectProjectEntity project : topList) { + if (project.getStatus().equals(TaskContants.StatusEnum.INIT_STATUS.getStatus())) { + return; + } + } + } + + /** 任务项目状态设置为已完成*/ + taskObjectService.update(Wrappers.lambdaUpdate().set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()).eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId())); + + checkTaskFinish(eventAddVO); + } + + /** + * 如果任务下面的对象都完成了,则变更任务状态为已完成 + * + * @param eventAddVO + */ + @Override + public void checkTaskFinish(EventAddVO eventAddVO) { + List topList = taskObjectService.list(Wrappers.lambdaQuery().eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId())); + + if (Func.isNotEmpty(topList)) { + for (TaskObjectEntity obj : topList) { + if (obj.getStatus().equals(TaskContants.StatusEnum.INIT_STATUS.getStatus())) { + return; + } + } + } + /** 任务更新为完成状态 */ + modifyTaskStatus(eventAddVO.getTaskId(), Integer.valueOf(TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus())); + } + + @Override + public Boolean modifyTaskStatus(Long id, Integer status) { + TaskEntity task = this.getById(id); + task.setStatus(status); + if (TaskStatusEnum.UNDERWAY_STATUS.getStatus().equals(status.toString())) {//恢复任务 + //处理同时开启几个任务的情况 + checkOpenMutipleTask(AuthUtil.getUserId()); + } + if (TaskStatusEnum.FINISH_STATUS.getStatus().equals(status.toString())) {//任务完成 + task.setEndTime(LocalDateTime.now()); + List taskObjs = taskObjectService.list(Wrappers.query().lambda().eq(TaskObjectEntity::getTaskId, task.getId())); + for (TaskObjectEntity taskObj : taskObjs) { + if (taskObj.getStatus().equals(TaskContants.StatusEnum.INIT_STATUS.getStatus())) { + log.error("该任务未登记完成,不可结束。"); + throw new ServiceException("该任务未登记完成,不可结束。"); + } + } + } + return this.updateById(task); + } + + /** + * 开始任务 + */ + @Override + @Transactional + public Boolean startTask(Long id) { + TaskEntity task = this.getById(id); + + if (hasExistStartId(id) || !addStartTaskId(id)) { + throw new ServiceException("该任务有人在领用,请稍后重试"); + } + //检查任务 + checkOpenMutipleTask(AuthUtil.getUserId()); + TaskUserEntity userEntity = taskUserService.getOne(Wrappers.lambdaQuery().eq(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).eq(TaskUserEntity::getTaskId, task.getId())); + if (Func.isNotEmpty(userEntity)) { + removeStartTaskId(id); + throw new ServiceException("该任务已被领用,请刷新页面"); + } + + //给当前人领取任务 + taskUserService.update(Wrappers.lambdaUpdate().set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).set(TaskUserEntity::getClaimTime, LocalDateTime.now()).eq(TaskUserEntity::getTaskId, task.getId()).eq(TaskUserEntity::getUserId, AuthUtil.getUserId())); + //如果是抢占任务,删除能够抢占此任务的其他人 + if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { + taskUserService.remove(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); + } + task.setStatus(Integer.valueOf(TaskStatusEnum.UNDERWAY_STATUS.getStatus())); + task.setStartTime(LocalDateTime.now()); + boolean re = this.updateById(task); + removeStartTaskId(id); + return re; + } + + /** + * 检查任务 + */ + public void checkOpenMutipleTask(Long userId) { + R r = sysClient.getParamValue(TaskContants.OPEN_MULTIPLE_TASK); + if (r.isSuccess() && "0".equals(r.getData())) {//处理同时开启几个任务的情况 + int count = taskUserService.count(Wrappers.query().lambda().eq(TaskUserEntity::getUserId, userId).eq(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus())); + if (count > 0) { + log.error("不能同时开启两个巡检任务"); + throw new ServiceException("不能同时开启两个巡检任务"); + } + } + } + + /** + * 机器人 + * 开始任务 + */ + @Override + public Boolean startTaskForRobot(Long id, Long userId) { + TaskEntity task = this.getById(id); + //检查任务 + checkOpenMutipleTask(userId); + //给当前人领取任务 + taskUserService.update(Wrappers.lambdaUpdate().set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).set(TaskUserEntity::getClaimTime, LocalDateTime.now()).eq(TaskUserEntity::getTaskId, task.getId()).eq(TaskUserEntity::getUserId, userId)); + //如果是抢占任务,删除能够抢占此任务的其他人 + if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { + taskUserService.remove(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getId, userId)); + } + task.setStatus(Integer.valueOf(TaskStatusEnum.UNDERWAY_STATUS.getStatus())); + task.setStartTime(LocalDateTime.now()); + return this.updateById(task); + } + + /** + * 获取任务 项目list + * + * @param taskId + * @return + */ + @Override + public List getObjPrj(Long taskId) { + List list = taskObjectService.list(Wrappers.lambdaQuery().eq(TaskObjectEntity::getTaskId, taskId)); + List result = Lists.newArrayList(); + for (TaskObjectEntity taskObject : list) { + TaskObjectVO vo = TaskObjectVO.builder().objId(taskObject.getObjectId()).taskId(taskObject.getTaskId()).objName(taskObject.getName()).build(); + List taskObjectProjectList = taskObjectProjectService.list(Wrappers.lambdaQuery().eq(TaskObjectProjectEntity::getTaskId, taskObject.getTaskId()).eq(TaskObjectProjectEntity::getObjectId, taskObject.getObjectId())); + List projectVOList = Lists.newArrayList(); + for (TaskObjectProjectEntity taskObjectProject : taskObjectProjectList) { + TaskObjectProjectVO projectVO = TaskObjectProjectVO.builder().projectId(taskObjectProject.getProjectId()).projectName(taskObjectProject.getName()).build(); + List taskObjectProjectContentList = taskObjectProjectContentService.list(Wrappers.lambdaQuery().eq(TaskObjectProjectContentEntity::getTaskId, taskObjectProject.getTaskId()).eq(TaskObjectProjectContentEntity::getObjectId, taskObjectProject.getObjectId()).eq(TaskObjectProjectContentEntity::getProjectId, taskObjectProject.getProjectId())); + List eventIds = eventService.list(Wrappers.lambdaQuery().eq(EventEntity::getTaskId, taskId).eq(EventEntity::getObjectId, taskObject.getObjectId()).eq(EventEntity::getProjectId, taskObjectProject.getProjectId())).stream().map(entity -> entity.getId()).collect(Collectors.toList()); + List contentVOList = Lists.newArrayList(); + for (TaskObjectProjectContentEntity entity : taskObjectProjectContentList) { + TaskObjectProjectContentVO contentVO = BeanUtil.copy(entity, TaskObjectProjectContentVO.class); + if ("0".equals(contentVO.getAvailable()) && eventIds.size() > 0) {//不可重复记录时,需要显示之前记录的值 + EventRecordEntity ere = eventRecordService.getOne(Wrappers.lambdaQuery().in(EventRecordEntity::getEventId, eventIds).eq(EventRecordEntity::getObjectId, taskObject.getObjectId()).eq(EventRecordEntity::getProjectId, taskObjectProject.getProjectId()).eq(EventRecordEntity::getContentId, contentVO.getContentId()).last("LIMIT 1")); + contentVO.setCurrentStatus(ere.getCurrentStatus()); + contentVO.setCurrentValue(ere.getCurrentValue()); + contentVO.setFileUrl(ere.getFileUrl()); + } + contentVOList.add(contentVO); + } + projectVO.setContents(contentVOList); + projectVOList.add(projectVO); + } + vo.setProjects(projectVOList); + result.add(vo); + } + return result; + } + + /** + * 根据计划开始时间结束时间及创建部门查询任务 + * + * @param startTime + * @param endTime + * @param depts + * @return + */ + @Override + public List queryByPlanStartTime(String startTime, String endTime, List depts) { + return this.baseMapper.selectByPlanStartTime(startTime, endTime, depts); + } + + @Override + public List getInspectTaskReport(String startDate, String endDate, List deptIdList) { + List result = new ArrayList<>(); + List taskCountVOList = getTaskCountByTime(startDate, endDate, deptIdList); + Map> userMap = taskCountVOList.stream().collect(Collectors.groupingBy(TaskCountVO::getUserId)); + userMap.forEach((userId, list) -> { + User user = UserCache.getUser(userId); + if (ObjectUtil.isEmpty(user)) { + return; + } + if (CollectionUtil.isNotEmpty(list)) { + TaskReportVO taskReportVO = new TaskReportVO(); + taskReportVO.setUserId(userId); + taskReportVO.setHours(list.stream().mapToLong(TaskCountVO::getHours).sum()); + //巡检任务完成情况 + String finishSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))).map(vo -> DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()).concat(":").concat(String.valueOf(Optional.ofNullable(vo.getFinishTask()).orElse(0)))).collect(Collectors.joining("\r\n")); + //巡检任务未完成情况 + String undoSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))).map(vo -> DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()).concat(":").concat(String.valueOf(Optional.ofNullable(vo.getUndoneTask()).orElse(0)))).collect(Collectors.joining("\r\n")); + taskReportVO.setCompleteNum(list.stream().filter(taskCountVO -> Func.isNotEmpty(taskCountVO.getFinishTask())).collect(Collectors.summingInt(TaskCountVO::getFinishTask))); + taskReportVO.setCompleteSituation(finishSituation); + taskReportVO.setIncompleteNum(list.stream().filter(taskCountVO -> Func.isNotEmpty(taskCountVO.getUndoneTask())).collect(Collectors.summingInt(TaskCountVO::getUndoneTask))); + taskReportVO.setIncompleteSituation(undoSituation); + taskReportVO.setUserName(user.getName()); + result.add(taskReportVO); + } + }); + return result; + } + + @Override + public Map getReportConclusion(String startDate, String endDate, List deptIdList) { + Map result = new HashMap<>(); + List taskCountVOList = getTaskCountByTime(startDate, endDate, deptIdList); + taskCountVOList = taskCountVOList.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(taskCountVOList)) { + result.put("INSPECT_TASK_COUNT", taskCountVOList.stream().mapToInt(vo -> Optional.ofNullable(vo.getFinishTask()).orElse(0) + Optional.ofNullable(vo.getUndoneTask()).orElse(0)).sum()); + result.put("INSPECT_COMPLETE_TASK_COUNT", taskCountVOList.stream().filter(t -> Func.isNotEmpty(t.getFinishTask())).mapToInt(TaskCountVO::getFinishTask).sum()); + result.put("PROBLEM_NUM", null); + } + return result; + } + + @Override + public List getTaskCountByTime(String startDate, String endDate, List deptIdList) { + return this.baseMapper.selectReportByTime(startDate, endDate, deptIdList); + } + + @Override + public R getInspectTaskCheck(String startDate, String endDate, Long dept, String inspectType) { + log.info("进入getInspectTaskCheck方法"); + SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); + //获取已完成任务 + List taskEntityList = this.baseMapper.getInspectTaskCheck(startDate, endDate, dept); + //获取运行人员角色ID + //log.info("Auth:{};tenantId:{}", JSON.toJSONString(AuthUtil.getUser()),AuthUtil.getTenantId()); + R roleIdR = sysClient.getRoleIds("200000", "运行人员"); + if (!roleIdR.isSuccess() || Func.isEmpty(roleIdR.getData())) { + throw new ServiceException("获取运行人员角色失败"); + } + if (CollectionUtil.isNotEmpty(taskEntityList)) { + List operators = taskEntityList.stream().filter(task -> { + //筛选出运行人员的记录 + User user = UserCache.getUser(task.getUserId()); + //log.info("{}角色ID为:{}",user.getName(),user.getRoleId()); + if (ObjectUtil.isEmpty(user)) { + return false; + } + return Arrays.asList(user.getRoleId().split(",")).contains(roleIdR.getData()) ? true : false; + }).collect(Collectors.toList()); + //根据传参分类型获取巡检任务统计情况 + if ("1".equals(inspectType)) { + vo.setProjectType(Constants.SafeCheckProjectEnum.OPERATE_INSPECT_TASK.getType()); + vo.setProjectTypeName(Constants.SafeCheckProjectEnum.OPERATE_INSPECT_TASK.getName()); + vo.setTotal(operators.size()); + } else if ("2".equals(inspectType)) { + vo.setProjectType(Constants.SafeCheckProjectEnum.OTHER_INSPECT_TASK.getType()); + vo.setProjectTypeName(Constants.SafeCheckProjectEnum.OTHER_INSPECT_TASK.getName()); + vo.setTotal(taskEntityList.size() - operators.size()); + } + } + return R.data(vo); + } + + @Override + public List getTaskData(List userIds, String currentDate) { + return this.baseMapper.getTaskData(userIds, currentDate); + } + + public List getTaskById0(Long id) { + TaskEntity task = this.getById(id); + PlanEntity plan = planMapper.selectById(task.getPlanId()); + + List routObjects = new ArrayList<>(); + if (Func.isNotEmpty(plan.getRouteData())) { + routObjects = JsonUtil.parseArray(plan.getRouteData(), RoutObject.class); + } + Map routMap = new HashMap<>(); + for (RoutObject rout : routObjects) { + routMap.put(rout.getObjectId(), rout.getSort()); + } + + TaskObjectEntity toQuery = new TaskObjectEntity(); + toQuery.setTaskId(id); + List list = taskObjectService.getTaskObjectList(toQuery); + + List result = Lists.newArrayList(); + for (TaskObjectEntity taskObject : list) { + TaskObjectVO vo = TaskObjectVO.builder().objId(taskObject.getObjectId()).taskId(taskObject.getTaskId()).objName(taskObject.getName()).status(taskObject.getStatus()).build(); + + TaskObjectProjectEntity topQuery = new TaskObjectProjectEntity(); + topQuery.setTaskId(taskObject.getTaskId()); + topQuery.setObjectId(taskObject.getObjectId()); + List taskObjectProjectList = taskObjectProjectService.getTaskObjectProjectList(topQuery); + List projectVOList = Lists.newArrayList(); + for (TaskObjectProjectEntity taskObjectProject : taskObjectProjectList) { + TaskObjectProjectVO projectVO = TaskObjectProjectVO.builder().projectId(taskObjectProject.getProjectId()).projectName(taskObjectProject.getName()).status(taskObjectProject.getStatus()).build(); + + TaskObjectProjectContentEntity topcQuery = new TaskObjectProjectContentEntity(); + topcQuery.setTaskId(taskObjectProject.getTaskId()); + topcQuery.setObjectId(taskObjectProject.getObjectId()); + topcQuery.setProjectId(taskObjectProject.getProjectId()); + List taskObjectProjectContentList = taskObjectProjectContentService.getTaskObjectProjectContentList(topcQuery); + + EventEntity eventQuery = new EventEntity(); + eventQuery.setTaskId(id); + eventQuery.setObjectId(taskObject.getObjectId()); + eventQuery.setProjectId(taskObjectProject.getProjectId()); + List eventIds = eventService.getEventList(eventQuery).stream().map(entity -> entity.getId()).collect(Collectors.toList()); + List contentVOList = Lists.newArrayList(); + + for (TaskObjectProjectContentEntity entity : taskObjectProjectContentList) { + TaskObjectProjectContentVO contentVO = BeanUtil.copy(entity, TaskObjectProjectContentVO.class); + if ("0".equals(contentVO.getAvailable()) && eventIds.size() > 0) {//不可重复记录时,需要显示之前记录的值 + EventRecordEntity ere = eventRecordService.getOne(Wrappers.lambdaQuery().in(EventRecordEntity::getEventId, eventIds).eq(EventRecordEntity::getObjectId, taskObject.getObjectId()).eq(EventRecordEntity::getProjectId, taskObjectProject.getProjectId()).eq(EventRecordEntity::getContentId, contentVO.getContentId()).last("LIMIT 1")); + contentVO.setCurrentStatus(ere.getCurrentStatus()); + contentVO.setCurrentValue(ere.getCurrentValue()); + contentVO.setFileUrl(ere.getFileUrl()); + } + contentVOList.add(contentVO); + } + projectVO.setContents(contentVOList); + projectVOList.add(projectVO); + } + vo.setProjects(projectVOList); + vo.setDangers(objectDangerService.getDangerDetailByObjectId(taskObject.getObjectId())); + vo.setOrder(routMap.get(taskObject.getObjectId())); + result.add(vo); + } + return result; + } + + @Override + public List getTaskById(Long id) { + TaskEntity task = this.getById(id); + PlanEntity plan = planMapper.selectById(task.getPlanId()); + + List routObjects = new ArrayList<>(); + if (Func.isNotEmpty(plan.getRouteData())) { + routObjects = JsonUtil.parseArray(plan.getRouteData(), RoutObject.class); + } + Map routMap = new HashMap<>(); + for (RoutObject rout : routObjects) { + routMap.put(rout.getObjectId(), rout.getSort()); + } + + TaskObjectEntity toQuery = new TaskObjectEntity(); + toQuery.setTaskId(id); + List result = taskObjectService.getTaskObjectsDetail(toQuery); + result.forEach(vo -> { + vo.setDangers(objectDangerService.getDangerDetailByObjectId(vo.getObjId())); + vo.setOrder(routMap.get(vo.getObjId())); + log.info("---routMap:{};objId:{}---", JSONObject.toJSONString(routMap), vo.getObjId()); + }); + + return result.stream().sorted(Comparator.comparing(TaskObjectVO::getOrder)).collect(Collectors.toList()); + } + + @Override + public List getListPageOfTaskRecord(IPage page, TaskListQuery task) { + return this.baseMapper.getListPageOfTaskRecord(page, task); + } + + @Override + public List getListPage(IPage page, TaskListQuery task) { + List re = this.baseMapper.getListPage(page, task); + setVoInfo(re); + return re; + } + + @Override + public List mainQueryPage(IPage page, TaskListQuery task) { + List re = this.baseMapper.mainQueryPage(page, task); + return re; + } + + @Override + public List getListPageAuth(IPage page, TaskListQuery task) { + List re = this.baseMapper.getListPageAuth(page, task); + setVoInfo(re); + return re; + } + + /** + * phone端任务列表 + * + * @return + */ + @Override + public List getListPageOfPhone(IPage page, TaskListQuery task) { + List re = this.baseMapper.getListPageOfPhone(page, task); + for (TaskVo vo : re) { + vo.setCanCancel(false); + if ("0".equals(vo.getMethod())) { + if (vo.getStatus().equals(1) || vo.getStatus().equals(2)) { + EventEntity entity = eventService.getOne(Wrappers.lambdaQuery(EventEntity.class).eq(EventEntity::getTaskId, vo.getId()).last("LIMIT 1")); + if (entity == null) { + vo.setCanCancel(true); + } + } + } + } + setVoInfo(re); + return re; + } + + @Override + public List getFinishTaskList(IPage page, TaskListQuery task) { + List re = this.baseMapper.getFinishTaskList(page, task); + setVoInfo(re); + return re; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public Boolean cancelStart(Long taskId) { + EventEntity entity = eventService.getOne(Wrappers.lambdaQuery(EventEntity.class).eq(EventEntity::getTaskId, taskId).last("LIMIT 1")); + if (entity != null) { + throw new ServiceException("该任务已有历史记录,不能撤销领用"); + } + taskUserService.update(Wrappers.lambdaUpdate(TaskUserEntity.class).eq(TaskUserEntity::getUserId, AuthUtil.getUserId()).eq(TaskUserEntity::getTaskId, taskId).set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.UN_COLLECT.getStatus()).set(TaskUserEntity::getClaimTime, null)); + taskUserService.updateDeleteStatus(taskId); + this.update(Wrappers.lambdaUpdate(TaskEntity.class).eq(TaskEntity::getId, taskId).set(TenantEntity::getStatus, TaskStatusEnum.INIT_STATUS.ordinal())); + return true; + } + + /** + * 机器人 + * 机器人获取当天任务列表 + * 只取第一条 + * + * @param + * @return + */ + @Override + public List getListOfPhone(String tenantId, Long userId) { + LocalDate now = LocalDate.now(); + DateTimeFormatter dfShort = DateTimeFormatter.ofPattern("yyyy-MM-dd "); + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + TaskListQuery task = new TaskListQuery(); + task.setCurUserId(userId); + task.setTenantId(tenantId); + task.setPlanStartTimeEnd(LocalDateTime.now()); + task.setStartTime(LocalDateTime.now()); + /*task.setPlanStartTime(LocalDateTime.parse(dfShort.format(now) + "00:00:00", df)); + task.setPlanStartTimeEnd(LocalDateTime.now());*/ + task.setAutoVideo(PlanContants.InspectTypeEnum.ROBOT.getVal()); + List tasks = this.baseMapper.getListOfPhone(task); + setVoInfo(tasks); + return Func.isEmpty(tasks) ? new ArrayList<>() : Arrays.asList(tasks.get(0)); + } + + /** + * 设置机器人信息等 + * + * @param re + */ + private void setVoInfo(List re) { + if (Func.isNotEmpty(re)) { + for (TaskVo vo : re) { + if (Func.isNotEmpty(vo.getUserId())) { + vo.setUserName(UserCache.getUser(vo.getUserId()) == null ? "" : UserCache.getUser(vo.getUserId()).getName()); + } + if (vo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal())) { + //任务执行人 + TaskUserEntity query = taskUserService.getOne(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, vo.getId())); + if (Func.isNotEmpty(query)) { + vo.setRobot(robotService.getDetailByUserId(query.getUserId())); + } + } + } + } + } + + /** + * 海康sdk url :https://open.hikvision.com/docs/8530061f19534a9993e2afeb70e7c96a#d82bbc55 + * 摄像头截图方式:从视频云获取 + * 视频巡检没有执行人 + * TODO + * 执行视频自动巡检 + */ + public void execAutoVideoTask(Long taskId) { + //任务对象 + List taskObjectVOS = getTaskById(taskId); + for (TaskObjectVO objectVo : taskObjectVOS) { + // 对象项目 + List objectProjectVOs = objectVo.getProjects(); + for (TaskObjectProjectVO projectVo : objectProjectVOs) { + //对象项目内容 + List contentVOS = projectVo.getContents(); + //提交事件 + EventAddVO submitEventVo = new EventAddVO(); + //提交事件记录list + List submitRecords = new ArrayList<>(); + submitEventVo.setRecords(submitRecords); + + for (TaskObjectProjectContentVO content : contentVOS) { + //提交事件记录 + EventRecordAddVO submitRecord = new EventRecordAddVO(); + submitRecord.setContentId(content.getContentId()); + //当前值 + String currentVal = ""; + if (content.getCheckType().equals(ObjContants.CheckTypeEnum.AUTO_VIDEO.getType())) { + //视频巡检 存图 + if (content.getRecordType().equals(ObjContants.VideoCheckTypeEnum.PICTURE.getType())) { + submitRecord.setCurrentStatus(TaskContants.CurrentStatusEnum.normal.getType()); + ImsMonCameraInfoEntity query = new ImsMonCameraInfoEntity(); + query.setId(content.getCameraId()); + query = cameraInfoClient.detail(query).getData(); + if (Func.isNotEmpty(query)) { + //从摄像机取一张图片,存到iso + currentVal = HiKUtil.getIOSPicUrl(query.getPointCode()); + } else { + log.error("content id = " + content.getContentId() + ", cameraId = " + content.getCameraId() + " 摄像头信息为空"); + } + } + // TODO 识别 存值 + else if (content.getRecordType().equals(ObjContants.VideoCheckTypeEnum.IDENTIFY.getType())) { + + } + submitRecord.setCurrentValue(currentVal); + } + submitRecords.add(submitRecord); + } + //提交事件 + eventService.addTaskEvent(submitEventVo); + } + //TODO 提交对象 + + } + } + + + /** + * hld + * 获取当前有效的任务 (状态不为3:完成,4:未完成以及计划结束时间未超过当前时间,并且为发开始前提醒短信) + * + * @param it + * @return + */ + @Override + public List selectTodayStartRemindTaskSMSListByPlanId(TaskEntity it) { + List result = this.baseMapper.selectTodayStartRemindTaskSMSListByPlanId(it); + if (Func.isNotEmpty(result)) { + for (InspectionTaskSMS sms : result) { + sms.setSmsDetail(); + } + } + return result; + } + + /** + * hld + * 获取当前有效的任务 (状态不为3:完成,4:未完成以及计划结束时间未超过当前时间,并且为发结束前提醒短信) + * + * @param it + * @return + */ + @Override + public List selectTodayEndRemindTaskSMSListByPlanId(TaskEntity it) { + List result = this.baseMapper.selectTodayEndRemindTaskSMSListByPlanId(it); + if (Func.isNotEmpty(result)) { + for (InspectionTaskSMS sms : result) { + sms.setSmsDetail(); + } + } + return result; + } + + /* + + */ /** * 立即生成任务 发送短信通知提醒 * @param it - *//* - - @Override - public void taskGenerateSMSNoticeNew(TaskEntity it){ - List taskSMSs = itdao.selectInspectionTaskSMSListByPlan(it) ; - Map> planIdAndUserIdMap = taskSMSs.stream().collect(Collectors.groupingBy(TaskSMS -> TaskSMS.getPlanId().toString()+"_"+TaskSMS.getUserId().toString())) ; - if(planIdAndUserIdMap==null || planIdAndUserIdMap.size()<=0){ - logger.error("根据planId获取任务信息为空,任务生成短信发送结束 !"); - return; - } - Set>> planIdTaskSMSSet = planIdAndUserIdMap.entrySet(); - Iterator>> planIdTaskSMSSetIterator = planIdTaskSMSSet.iterator(); - while(planIdTaskSMSSetIterator.hasNext()) { - Map.Entry entry = planIdTaskSMSSetIterator.next(); - List taskSMSList = (List) entry.getValue(); - if(taskSMSList==null || taskSMSList.size()<=0){ - continue; - } - InspectionTaskSMS taskSMS = taskSMSList.get(0); - - //TODO 巡检通知 - addNotice(taskSMS,"generate"); - taskSMS.setSendMsg(true); - itdao.updateTaskSendStatus(taskSMS); - otherThreadSendSMS(taskSMS,taskGenerateTemplateCode); - } - } - - */ + */ /* + + @Override + public void taskGenerateSMSNoticeNew(TaskEntity it){ + List taskSMSs = itdao.selectInspectionTaskSMSListByPlan(it) ; + Map> planIdAndUserIdMap = taskSMSs.stream().collect(Collectors.groupingBy(TaskSMS -> TaskSMS.getPlanId().toString()+"_"+TaskSMS.getUserId().toString())) ; + if(planIdAndUserIdMap==null || planIdAndUserIdMap.size()<=0){ + logger.error("根据planId获取任务信息为空,任务生成短信发送结束 !"); + return; + } + Set>> planIdTaskSMSSet = planIdAndUserIdMap.entrySet(); + Iterator>> planIdTaskSMSSetIterator = planIdTaskSMSSet.iterator(); + while(planIdTaskSMSSetIterator.hasNext()) { + Map.Entry entry = planIdTaskSMSSetIterator.next(); + List taskSMSList = (List) entry.getValue(); + if(taskSMSList==null || taskSMSList.size()<=0){ + continue; + } + InspectionTaskSMS taskSMS = taskSMSList.get(0); + + //TODO 巡检通知 + addNotice(taskSMS,"generate"); + taskSMS.setSendMsg(true); + itdao.updateTaskSendStatus(taskSMS); + otherThreadSendSMS(taskSMS,taskGenerateTemplateCode); + } + } + + */ /** * TODO 巡检通知 * 向通知表添加任务结束记录 * @param taskSMS - *//* - - private void addNotice (InspectionTaskSMS taskSMS,String type){ - Notify notify = new Notify(); - notify.setNoticeTypeId(OldDictUitls.getDictId("INSPECT", "notifyType")); - notify.setReallyId(taskSMS.getId().toString()); - notify.setCreateTime(new Date()); - notify.setReceiveUserId(taskSMS.getLoginName()); - String detail = ""; - if(!StringUtils.isEmpty(type)){ - if(type.equalsIgnoreCase("start")){ - detail = String.format("您有巡检工作任务(%s)需要在%s开始执行,请及时处理。", - taskSMS.getPlanName(), DateUtils.formatDate(taskSMS.getPlanStartTime(),"yyyy-MM-dd HH:mm:ss")); - }else if(type.equalsIgnoreCase("end")){ - detail = String.format("您有巡检工作任务(%s)即将在%s 结束,请及时处理。", - taskSMS.getPlanName(), DateUtils.formatDate(taskSMS.getPlanEndTime(),"yyyy-MM-dd HH:mm:ss")); - }else if(type.equalsIgnoreCase("generate")){ - String two = DateUtils.formatDate(taskSMS.getPlanStartTime(),"yyyy-MM-dd HH:mm:ss"); - two += " - "+DateUtils.formatDate(taskSMS.getPlanEndTime(),"yyyy-MM-dd HH:mm:ss"); - detail = String.format("您已被派发巡检工作任务(%s),任务周期为 %s ,请及时处理。", - taskSMS.getPlanName(), two); - } - } - notify.setReallyDetail(detail); - notify.setNoticeTypesonId(OldDictUitls.getDictId("TASK", "inspectNoticeType")); - notifyService.insertNotifys(notify); - } - - */ + */ /* + + private void addNotice (InspectionTaskSMS taskSMS,String type){ + Notify notify = new Notify(); + notify.setNoticeTypeId(OldDictUitls.getDictId("INSPECT", "notifyType")); + notify.setReallyId(taskSMS.getId().toString()); + notify.setCreateTime(new Date()); + notify.setReceiveUserId(taskSMS.getLoginName()); + String detail = ""; + if(!StringUtils.isEmpty(type)){ + if(type.equalsIgnoreCase("start")){ + detail = String.format("您有巡检工作任务(%s)需要在%s开始执行,请及时处理。", + taskSMS.getPlanName(), DateUtils.formatDate(taskSMS.getPlanStartTime(),"yyyy-MM-dd HH:mm:ss")); + }else if(type.equalsIgnoreCase("end")){ + detail = String.format("您有巡检工作任务(%s)即将在%s 结束,请及时处理。", + taskSMS.getPlanName(), DateUtils.formatDate(taskSMS.getPlanEndTime(),"yyyy-MM-dd HH:mm:ss")); + }else if(type.equalsIgnoreCase("generate")){ + String two = DateUtils.formatDate(taskSMS.getPlanStartTime(),"yyyy-MM-dd HH:mm:ss"); + two += " - "+DateUtils.formatDate(taskSMS.getPlanEndTime(),"yyyy-MM-dd HH:mm:ss"); + detail = String.format("您已被派发巡检工作任务(%s),任务周期为 %s ,请及时处理。", + taskSMS.getPlanName(), two); + } + } + notify.setReallyDetail(detail); + notify.setNoticeTypesonId(OldDictUitls.getDictId("TASK", "inspectNoticeType")); + notifyService.insertNotifys(notify); + } + + */ /** * 另开线程发送短信 - *//* - - private void otherThreadSendSMS(InspectionTaskSMS taskSMS,String templateCode){ - HzimsThreadPool.getFixedThreadExecutor().execute(new Runnable() { - @Override - public void run() { - sendSMS(taskSMS,templateCode); - } - }); - } - - */ - - /** - * TODO - * 发送短信 - *//* - - private int sendSMS(InspectionTaskSMS taskSMS,String templateCode){ - int re = 0; - try { - Map map = new HashMap<>(); - map.put("one", taskSMS.getPlanName()); - String two = DateUtils.formatDate(taskSMS.getPlanStartTime(),"yyyy-MM-dd HH:mm:ss"); - if(!StringUtils.isEmpty(templateCode)&&templateCode.equals(this.taskEndTemplateCode)){ - two = DateUtils.formatDate(taskSMS.getPlanEndTime(),"yyyy-MM-dd HH:mm:ss"); - }else if(!StringUtils.isEmpty(templateCode)&&templateCode.equals(this.taskGenerateTemplateCode)){ - String three = DateUtils.formatDate(taskSMS.getPlanEndTime(),"yyyy-MM-dd HH:mm:ss"); - map.put("three", three); - } - map.put("two", two); - String phoneNumber = taskSMS.getPhone(); - if(!isBlank(phoneNumber)){ - String jsonParam = JSON.toJSONString(map); - HZSendContent content = - HZSendContent.getTemplateContent(phoneNumber, templateCode, jsonParam); - HZSendStatu sendStatu = hzSendSms.sendMsg(content); - if (!HZSendStatu.SEND_SUCCESS.equals(sendStatu)) { - logger.warn("发送短信失败 : ", "HZSendStatu.SEND_SUCCESS = " + HZSendStatu.SEND_SUCCESS); - } else { - re = 1; - } - } else { - logger.warn("发送短信失败 : ", "用户:" + taskSMS.getCnName() + "未填写手机号码"); - } - - } catch (Exception e) { - logger.error("发送短信失败 : ", e.toString()); - } - return re; - } - - public boolean isBlank(String paramString) { - int i; - if (paramString != null && (i = paramString.length()) != 0) { - for(int j = 0; j < i; ++j) { - if (!Character.isWhitespace(paramString.charAt(j))) { - return false; - } - } - return true; - } else { - return true; - } - } + */ /* + + private void otherThreadSendSMS(InspectionTaskSMS taskSMS,String templateCode){ + HzimsThreadPool.getFixedThreadExecutor().execute(new Runnable() { + @Override + public void run() { + sendSMS(taskSMS,templateCode); + } + }); + } + + */ + + /** + * TODO + * 发送短信 + */ /* + + private int sendSMS(InspectionTaskSMS taskSMS,String templateCode){ + int re = 0; + try { + Map map = new HashMap<>(); + map.put("one", taskSMS.getPlanName()); + String two = DateUtils.formatDate(taskSMS.getPlanStartTime(),"yyyy-MM-dd HH:mm:ss"); + if(!StringUtils.isEmpty(templateCode)&&templateCode.equals(this.taskEndTemplateCode)){ + two = DateUtils.formatDate(taskSMS.getPlanEndTime(),"yyyy-MM-dd HH:mm:ss"); + }else if(!StringUtils.isEmpty(templateCode)&&templateCode.equals(this.taskGenerateTemplateCode)){ + String three = DateUtils.formatDate(taskSMS.getPlanEndTime(),"yyyy-MM-dd HH:mm:ss"); + map.put("three", three); + } + map.put("two", two); + String phoneNumber = taskSMS.getPhone(); + if(!isBlank(phoneNumber)){ + String jsonParam = JSON.toJSONString(map); + HZSendContent content = + HZSendContent.getTemplateContent(phoneNumber, templateCode, jsonParam); + HZSendStatu sendStatu = hzSendSms.sendMsg(content); + if (!HZSendStatu.SEND_SUCCESS.equals(sendStatu)) { + logger.warn("发送短信失败 : ", "HZSendStatu.SEND_SUCCESS = " + HZSendStatu.SEND_SUCCESS); + } else { + re = 1; + } + } else { + logger.warn("发送短信失败 : ", "用户:" + taskSMS.getCnName() + "未填写手机号码"); + } + + } catch (Exception e) { + logger.error("发送短信失败 : ", e.toString()); + } + return re; + } + + public boolean isBlank(String paramString) { + int i; + if (paramString != null && (i = paramString.length()) != 0) { + for(int j = 0; j < i; ++j) { + if (!Character.isWhitespace(paramString.charAt(j))) { + return false; + } + } + return true; + } else { + return true; + } + } */ - /** - * 离线前置-领取任务 - * - * @param taskIds - * @return - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean collectingTask(List taskIds) { - Date currentDate = DateUtil.parse(DateUtil.formatDate(DateUtil.now()), DateUtil.PATTERN_DATE); - String startDate = DateUtil.formatDate(currentDate); - String endDate = DateUtil.formatDate(DateUtil.plusDays(currentDate, 1)); - if(CollectionUtil.isEmpty(taskIds)){ - // 查询当天可操作任务 - List sameDayTasks = this.getSameDayTask(null,TaskStatusEnum.UNDERWAY_STATUS.getStatus(),startDate,endDate); - if(CollectionUtil.isNotEmpty(sameDayTasks)){ - return true; - } - throw new ServiceException("当前没有可领用的巡检任务!"); - } - // 查询可领用任务 - List tasks = this.getSameDayTask(taskIds,TaskStatusEnum.INIT_STATUS.getStatus(),startDate,endDate); - if(CollectionUtil.isEmpty(tasks)){ - throw new ServiceException("选择巡检任务已被领用完成!"); - } - if(taskIds.size() != taskIds.size()){ - throw new ServiceException("选择巡检任务中存在已被领用任务,请重新选择!"); - } - tasks.forEach(task -> { - if (hasExistStartId(task.getId()) || !addStartTaskId(task.getId())) { - throw new ServiceException("任务"+ task.getPlanName() +"["+ task.getPlanId() +"]有人在领用,请稍后重试!"); - } - // 任务归属人设置 - taskUserService.update(Wrappers.lambdaUpdate() - .set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) - .set(TaskUserEntity::getClaimTime, LocalDateTime.now()) - .eq(TaskUserEntity::getTaskId, task.getId()) - .eq(TaskUserEntity::getUserId, AuthUtil.getUserId())); - - // 其他候选任务抢占人移除(抢占模式) - if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { - taskUserService.remove(Wrappers.lambdaQuery() - .eq(TaskUserEntity::getTaskId, task.getId()) - .ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) - .ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); - } - boolean flag = this.update(Wrappers.lambdaUpdate() - .set(TaskEntity::getStatus, TaskStatusEnum.UNDERWAY_STATUS.getStatus()) - .set(TaskEntity::getStartTime, LocalDateTime.now()) - .eq(TaskEntity::getId, task.getId()) - ); - if(!flag){ - throw new ServiceException("任务领取异常,请稍后重试!"); - } - // 任务开始列表中移除已进行领用任务 - startTaskIds.remove(task.getId()); - }); - return true; - } - - private List getSameDayTask(List taskIds, String status, String startDate, String endDate) { - return this.baseMapper.getSameDayTask(taskIds,status,startDate,endDate); - } - - + /** + * 离线前置-领取任务 + * + * @param taskIds + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean collectingTask(List taskIds) { + Date currentDate = DateUtil.parse(DateUtil.formatDate(DateUtil.now()), DateUtil.PATTERN_DATE); + String startDate = DateUtil.formatDate(currentDate); + String endDate = DateUtil.formatDate(DateUtil.plusDays(currentDate, 1)); + if (CollectionUtil.isEmpty(taskIds)) { + // 查询当天可操作任务 + List sameDayTasks = this.getSameDayTask(null, TaskStatusEnum.UNDERWAY_STATUS.getStatus(), startDate, endDate); + if (CollectionUtil.isNotEmpty(sameDayTasks)) { + return true; + } + throw new ServiceException("当前没有可领用的巡检任务!"); + } + // 查询可领用任务 + List tasks = this.getSameDayTask(taskIds, TaskStatusEnum.INIT_STATUS.getStatus(), startDate, endDate); + if (CollectionUtil.isEmpty(tasks)) { + throw new ServiceException("选择巡检任务已被领用完成!"); + } + if (taskIds.size() != taskIds.size()) { + throw new ServiceException("选择巡检任务中存在已被领用任务,请重新选择!"); + } + tasks.forEach(task -> { + if (hasExistStartId(task.getId()) || !addStartTaskId(task.getId())) { + throw new ServiceException("任务" + task.getPlanName() + "[" + task.getPlanId() + "]有人在领用,请稍后重试!"); + } + // 任务归属人设置 + taskUserService.update(Wrappers.lambdaUpdate().set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).set(TaskUserEntity::getClaimTime, LocalDateTime.now()).eq(TaskUserEntity::getTaskId, task.getId()).eq(TaskUserEntity::getUserId, AuthUtil.getUserId())); + + // 其他候选任务抢占人移除(抢占模式) + if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { + taskUserService.remove(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); + } + boolean flag = this.update(Wrappers.lambdaUpdate().set(TaskEntity::getStatus, TaskStatusEnum.UNDERWAY_STATUS.getStatus()).set(TaskEntity::getStartTime, LocalDateTime.now()).eq(TaskEntity::getId, task.getId())); + if (!flag) { + throw new ServiceException("任务领取异常,请稍后重试!"); + } + // 任务开始列表中移除已进行领用任务 + startTaskIds.remove(task.getId()); + }); + return true; + } + + private List getSameDayTask(List taskIds, String status, String startDate, String endDate) { + return this.baseMapper.getSameDayTask(taskIds, status, startDate, endDate); + } + + + /** + * 巡检任务分页 + * + * @param pageInfo + * @param task + * @return + */ + @Override + public BladePage selectPage(Page pageInfo, TaskListQuery task) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //值班id + queryWrapper.eq(ObjectUtils.isNotNull(task.getDutyId()), "DUTY_ID", task.getDutyId()); + //当前登录的用户 + queryWrapper.eq(ObjectUtils.isNotNull(task.getCurUserId()), "USER_ID", task.getCurUserId()); + //计划名称 + queryWrapper.like(StringUtils.isNotBlank(task.getPlanName()), "PLAN_NAME", task.getPlanName()); + //任务批次号 + queryWrapper.like(StringUtils.isNotBlank(task.getBatchNumber()), "BATCH_NUMBER", task.getBatchNumber()); + //任务计划开始时间 + queryWrapper.lt(ObjectUtils.isNotNull(task.getPlanStartTime()), "PLAN_START_TIME", task.getBatchNumber()); + //任务计划结束时间 + queryWrapper.le(ObjectUtils.isNotNull(task.getPlanEndTime()), "PLAN_END_TIME", task.getPlanEndTime()); + //任务实际开始时间 + queryWrapper.le(ObjectUtils.isNotNull(task.getStartTime()), "PLAN_END_TIME", task.getStartTime()); + //巡检周期 0: 每次 1:每天 2:每月 3:每季度 4:每年 5:每周 + queryWrapper.eq(StringUtils.isNotBlank(task.getCycle()), "CYCLE", task.getCycle()); + + //任务状态 0未开始 1进行中 2暂停 3已完成 4未完成 + queryWrapper.eq(ObjectUtils.isNotNull(task.getStatus()), "STATUS", task.getStatus()); + // 任务报备 0 未报备 1已报备 + queryWrapper.eq(ObjectUtils.isNotNull(task.getKeepOnRecord()), "KEEP_ON_RECORD", task.getKeepOnRecord()); + //租户id + queryWrapper.eq(StringUtils.isNotBlank(task.getTenantId()), "TENANT_ID", task.getTenantId()); + //巡检类型标识: 0普通巡检,1视频自动巡检,2机器人巡检 + queryWrapper.eq(StringUtils.isNotBlank(task.getAutoVideo()), "AUTO_VIDEO", task.getAutoVideo()); + //巡检任务 按逗号分隔 + queryWrapper.apply(StringUtils.isNotBlank(task.getTaskIds()), "FIND_IN_SET(t.ID,'" + task.getTaskIds() + "'"); + //区域Id + queryWrapper.eq(StringUtils.isNotBlank(task.getAreaId()), "CREATE_DEPT", task.getAreaId()); + //月份 + queryWrapper.eq(ObjectUtils.isNotNull(task.getYearMonth()), "date_format(PLAN_START_TIME, '%Y-%m')", task.getYearMonth()); + + + Page taskEntityPage = baseMapper.selectPage(pageInfo, queryWrapper); + + List records = taskEntityPage.getRecords(); + if (CollectionUtils.isNotEmpty(records)) { + List collect = records.stream().map(item -> { + TaskVo taskVo = new TaskVo(); + BeanUtils.copyProperties(item, taskVo); + return taskVo; + }).collect(Collectors.toList()); + + Page taskVoList = new Page<>(); + taskVoList.setRecords(collect); + taskVoList.setPages(taskEntityPage.getPages()); + taskVoList.setSize(taskEntityPage.getSize()); + taskVoList.setTotal(taskEntityPage.getTotal()); + taskVoList.setCurrent(taskEntityPage.getCurrent()); + BladePage bladePage = BladePage.of(taskVoList); + return bladePage; + } + return null; + } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskListQuery.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskListQuery.java index 4cd012b..ef51dd3 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskListQuery.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskListQuery.java @@ -119,7 +119,7 @@ public class TaskListQuery implements Serializable { /** * 月份 */ - private YearMonth yearmonth; + private YearMonth yearMonth; /** * 区域Id diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java index 0d1dd0c..62db8b3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java @@ -30,7 +30,7 @@ public class OperAccessStatisticsDTO extends OperAccessStatisticsEntity { * 月份 */ @ApiModelProperty("月份") - private YearMonth yearmonth; + private YearMonth yearMonth; /** * 区域Id diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml index e63515d..a9703bd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml @@ -38,10 +38,10 @@ and OS.PLAN_END_TIME <= #{dto.planEndTime} - and OS.CREATE_DEPT = #{dto.areaId} + and OT.CREATE_DEPT = #{dto.areaId} - and date_format(os.CREATE_TIME,'%Y-%m') = #{dto.yearMonth} + and date_format(OT.PLAN_START_TIME,'%Y-%m') = #{dto.yearMonth} ORDER BY OS.CREATE_TIME DESC diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java index 668a010..e4f8212 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java @@ -1,8 +1,11 @@ package com.hnac.hzims.operational.access.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.report.vo.AccessReportVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; @@ -64,4 +67,11 @@ public interface IOperAccessTaskService extends BaseService selectPage(Page dbPage, OperAccessTaskEntity result); + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java index 7d1a50a..88cde48 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java @@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.message.fegin.IMessagePushClient; import com.hnac.hzims.message.req.PushExtrasReq; import com.hnac.hzims.operational.OperationalConstants; @@ -37,6 +39,7 @@ import com.hnac.hzims.vo.SafeCheckStatisticVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomUtils; +import org.apache.commons.lang3.StringUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; @@ -71,427 +74,433 @@ import java.util.stream.Collectors; @Slf4j @AllArgsConstructor public class OperAccessTaskServiceImpl extends BaseServiceImpl implements IOperAccessTaskService { - private final IFlowClient flowClient; - private final IDangerSourceClient dangerSourceClient; - private final IOperAccessTaskDetailService detailService; - private final IOperAccessStatisticsService statisticsService; - private final IOperAccessContentService contentService; - private final OperAccessTaskMapper mapper; - private final IMessagePushClient messagePushClient; - private final OperPhenomenonMapper operPhenomenonMapper; - private final IUserClient userClient; - private final ISpareClient assetsClient; - private final IOperAccessMaterialService materialService; - private final IOperDefectService defectService; - private final IOperDefectStatisticsService defectStatisticsService; + private final IFlowClient flowClient; + private final IDangerSourceClient dangerSourceClient; + private final IOperAccessTaskDetailService detailService; + private final IOperAccessStatisticsService statisticsService; + private final IOperAccessContentService contentService; + private final OperAccessTaskMapper mapper; + private final IMessagePushClient messagePushClient; + private final OperPhenomenonMapper operPhenomenonMapper; + private final IUserClient userClient; + private final ISpareClient assetsClient; + private final IOperAccessMaterialService materialService; + private final IOperDefectService defectService; + private final IOperDefectStatisticsService defectStatisticsService; - @Transactional - @Override - public R doSave(OperAccessTaskDTO req) { - req.setCode("TASK" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999))); - List materialEntityList = JSONObject.parseArray(JSON.toJSONString(req.getAccessMaterials()),OperAccessMaterialEntity.class); - if(super.save(req)){ - if(CollectionUtil.isNotEmpty(materialEntityList)) { - materialEntityList.stream().map(material->{ - material.setPlanId(null); - material.setId(null); - material.setTaskId(req.getId()); - return material; - }).collect(Collectors.toList()); - materialService.saveOrUpdateBatch(materialEntityList); - } - this.updateDetails(req.getId(), req.getAccessTaskDetails()); - //开启检修任务流程 - R bladeFlowR = flowClient.startProcessInstanceContainNameByKey( - "access_task_execute", - FlowUtil.getBusinessKey("hzims_oper_access_task",String.valueOf(req.getId())), - req.getName(), - new HashMap() {{ - put("taskId", req.getId()); - put("handler", TaskUtil.getTaskUser(req.getHandler().toString())); - put("creator", TaskUtil.getTaskUser(AuthUtil.getUserId().toString())); - }}); - Assert.isTrue(bladeFlowR.isSuccess() && ObjectUtil.isNotEmpty(bladeFlowR.getData()),()->{ - throw new ServiceException("保存检修任务失败,开启检修任务流程失败!"); - }); - String processInstanceId = bladeFlowR.getData().getProcessInstanceId(); - req.setProcessInstanceId(processInstanceId); - super.updateById(new OperAccessTaskEntity() {{ - setId(req.getId()); - setProcessInstanceId(processInstanceId); - }}); - } - return R.success("OK"); - } + @Transactional + @Override + public R doSave(OperAccessTaskDTO req) { + req.setCode("TASK" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999))); + List materialEntityList = JSONObject.parseArray(JSON.toJSONString(req.getAccessMaterials()), OperAccessMaterialEntity.class); + if (super.save(req)) { + if (CollectionUtil.isNotEmpty(materialEntityList)) { + materialEntityList.stream().map(material -> { + material.setPlanId(null); + material.setId(null); + material.setTaskId(req.getId()); + return material; + }).collect(Collectors.toList()); + materialService.saveOrUpdateBatch(materialEntityList); + } + this.updateDetails(req.getId(), req.getAccessTaskDetails()); + //开启检修任务流程 + R bladeFlowR = flowClient.startProcessInstanceContainNameByKey("access_task_execute", FlowUtil.getBusinessKey("hzims_oper_access_task", String.valueOf(req.getId())), req.getName(), new HashMap() {{ + put("taskId", req.getId()); + put("handler", TaskUtil.getTaskUser(req.getHandler().toString())); + put("creator", TaskUtil.getTaskUser(AuthUtil.getUserId().toString())); + }}); + Assert.isTrue(bladeFlowR.isSuccess() && ObjectUtil.isNotEmpty(bladeFlowR.getData()), () -> { + throw new ServiceException("保存检修任务失败,开启检修任务流程失败!"); + }); + String processInstanceId = bladeFlowR.getData().getProcessInstanceId(); + req.setProcessInstanceId(processInstanceId); + super.updateById(new OperAccessTaskEntity() {{ + setId(req.getId()); + setProcessInstanceId(processInstanceId); + }}); + } + return R.success("OK"); + } - @Override - public R doUpdateById(OperAccessTaskDTO req, ComleteTask comleteTask, Long handler) { - super.updateById(req); - OperAccessTaskEntity entity = super.getById(req.getId()); + @Override + public R doUpdateById(OperAccessTaskDTO req, ComleteTask comleteTask, Long handler) { + super.updateById(req); + OperAccessTaskEntity entity = super.getById(req.getId()); - if (req.getStatus() == AccessConstants.ACCESS_TASK_STATUS_4) { - List statisticsList = statisticsService.list(new LambdaQueryWrapper() {{ - eq(OperAccessStatisticsEntity::getTaskId, req.getId()); - }}); - //台账 - if (CollectionUtil.isEmpty(statisticsList)) { - OperAccessStatisticsDTO statisticsDTO = BeanUtil.copy(entity, OperAccessStatisticsDTO.class); - statisticsDTO.setId(null); - statisticsDTO.setTaskId(entity.getId()); - statisticsDTO.setManager(entity.getHandler()); - OperAccessContentEntity accessContentEntity = contentService.getById(req.getId()); - if(ObjectUtil.isNotEmpty(accessContentEntity)){ - statisticsDTO.setPid(accessContentEntity.getLibraryId()); - } - statisticsService.doSave(statisticsDTO); - } + if (req.getStatus() == AccessConstants.ACCESS_TASK_STATUS_4) { + List statisticsList = statisticsService.list(new LambdaQueryWrapper() {{ + eq(OperAccessStatisticsEntity::getTaskId, req.getId()); + }}); + //台账 + if (CollectionUtil.isEmpty(statisticsList)) { + OperAccessStatisticsDTO statisticsDTO = BeanUtil.copy(entity, OperAccessStatisticsDTO.class); + statisticsDTO.setId(null); + statisticsDTO.setTaskId(entity.getId()); + statisticsDTO.setManager(entity.getHandler()); + OperAccessContentEntity accessContentEntity = contentService.getById(req.getId()); + if (ObjectUtil.isNotEmpty(accessContentEntity)) { + statisticsDTO.setPid(accessContentEntity.getLibraryId()); + } + statisticsService.doSave(statisticsDTO); + } - //材料库出库 - if(CollectionUtil.isNotEmpty(req.getAccessMaterials())){ - List materialDTOList = req.getAccessMaterials(); - for (OperAccessMaterialDTO materialDTO : materialDTOList) { - SpRecordEntity recordEntity = new SpRecordEntity(); - recordEntity.setSpBasicId(materialDTO.getSpBasicId()); - recordEntity.setAmount(materialDTO.getNumber()); - recordEntity.setWarehouseId(materialDTO.getWarehouseId()); - recordEntity.setHandler(req.getHandler()); - recordEntity.setCreateDept(req.getCreateDept()); - recordEntity.setCreateUser(req.getCreateUser()); - Boolean result = assetsClient.warehouseOut(recordEntity); - if(!result) { - return R.fail("出库失败"); - } - materialDTO.setTaskId(entity.getId()); - materialDTO.setPlanId(entity.getPlanId()); - } - } - //审核完成 关闭工作流 - R flowResult = flowClient.completeTask(comleteTask); - this.finishDefectFlow(entity); + //材料库出库 + if (CollectionUtil.isNotEmpty(req.getAccessMaterials())) { + List materialDTOList = req.getAccessMaterials(); + for (OperAccessMaterialDTO materialDTO : materialDTOList) { + SpRecordEntity recordEntity = new SpRecordEntity(); + recordEntity.setSpBasicId(materialDTO.getSpBasicId()); + recordEntity.setAmount(materialDTO.getNumber()); + recordEntity.setWarehouseId(materialDTO.getWarehouseId()); + recordEntity.setHandler(req.getHandler()); + recordEntity.setCreateDept(req.getCreateDept()); + recordEntity.setCreateUser(req.getCreateUser()); + Boolean result = assetsClient.warehouseOut(recordEntity); + if (!result) { + return R.fail("出库失败"); + } + materialDTO.setTaskId(entity.getId()); + materialDTO.setPlanId(entity.getPlanId()); + } + } + //审核完成 关闭工作流 + R flowResult = flowClient.completeTask(comleteTask); + this.finishDefectFlow(entity); - if(!flowResult.isSuccess()) { - throw new ServiceException(flowResult.getMsg()); - } - } + if (!flowResult.isSuccess()) { + throw new ServiceException(flowResult.getMsg()); + } + } else if (req.getStatus() == AccessConstants.ACCESS_TASK_STATUS_2) { + updateMaterials(entity.getPlanId(), entity.getId(), req.getAccessMaterials()); + //工作流下一步 + completeTask(comleteTask, handler, entity.getProcessInstanceId(), entity.getCreateDept()); + } - else if (req.getStatus() == AccessConstants.ACCESS_TASK_STATUS_2) { - updateMaterials(entity.getPlanId(), entity.getId(), req.getAccessMaterials()); - //工作流下一步 - completeTask(comleteTask, handler, entity.getProcessInstanceId(), entity.getCreateDept()); - } + //如果任务审批未通过 需重新开票 将任务ticketId置空 + else if (req.getStatus() == AccessConstants.ACCESS_TASK_STATUS_3) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(OperAccessTaskEntity::getTicketId, null); + updateWrapper.eq(OperAccessTaskEntity::getId, entity.getId()); + super.update(updateWrapper); + R result = flowClient.completeTask(comleteTask); + if (!result.isSuccess()) { + throw new ServiceException(result.getMsg()); + } - //如果任务审批未通过 需重新开票 将任务ticketId置空 - else if(req.getStatus() == AccessConstants.ACCESS_TASK_STATUS_3) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.set(OperAccessTaskEntity::getTicketId, null); - updateWrapper.eq(OperAccessTaskEntity::getId, entity.getId()); - super.update(updateWrapper); - R result = flowClient.completeTask(comleteTask); - if(!result.isSuccess()){ - throw new ServiceException(result.getMsg()); - } + } + return R.data("操作成功!"); + } - } - return R.data("操作成功!"); - } + @Override + public R detail(Long id) { + OperAccessTaskVO detail = OperAccessTaskWrapper.build().entityVO(super.getById(id)); + detail.setDangerSources(dangerSourceClient.details(detail.getSafeInfos().split(","))); + detail.setDetails(OperAccessTaskDetailWrapper.build().listVO(detailService.list(new LambdaQueryWrapper() {{ + eq(OperAccessTaskDetailEntity::getTaskId, id); + }}))); + detail.setAccessMaterials(materialService.getList(null, String.valueOf(id))); + if (Func.isNotEmpty(id)) { + OperAccessTaskVO operAccessTaskVO = mapper.getAccessPlanByTaskId(id.toString()); + if (ObjectUtil.isNotEmpty(operAccessTaskVO)) { + detail.setPlanName(operAccessTaskVO.getPlanName()); + } + } + return R.data(detail); + } - @Override - public R detail(Long id) { - OperAccessTaskVO detail = OperAccessTaskWrapper.build().entityVO(super.getById(id)); - detail.setDangerSources(dangerSourceClient.details(detail.getSafeInfos().split(","))); - detail.setDetails( - OperAccessTaskDetailWrapper.build().listVO( - detailService.list(new LambdaQueryWrapper() {{ - eq(OperAccessTaskDetailEntity::getTaskId, id); - }}) - ) - ); - detail.setAccessMaterials(materialService.getList(null, String.valueOf(id))); - if(Func.isNotEmpty(id)){ - OperAccessTaskVO operAccessTaskVO = mapper.getAccessPlanByTaskId(id.toString()); - if(ObjectUtil.isNotEmpty(operAccessTaskVO)){ - detail.setPlanName(operAccessTaskVO.getPlanName()); - } - } - return R.data(detail); - } + @Override + public R> list(OperAccessTaskDTO req, Query query) { + IPage page = Condition.getPage(query); + List data = mapper.pageCondition(page, req); + page.setRecords(OperAccessTaskWrapper.build().listVOExtras(data)); + return R.data(page); + } - @Override - public R> list(OperAccessTaskDTO req, Query query) { - IPage page = Condition.getPage(query); - List data = mapper.pageCondition(page, req); - page.setRecords(OperAccessTaskWrapper.build().listVOExtras(data)); - return R.data(page); - } + @Override + public List getByEmCode(String emCode, List list) { + return this.baseMapper.selectByEmCode(emCode, list); + } - @Override - public List getByEmCode(String emCode, List list) { - return this.baseMapper.selectByEmCode(emCode,list); - } + @Override + public List getAccessTaskByDisposer(LocalDate startDate, LocalDate endDate, List deptIdList) { + List inspectOrAccessReportVOList = new ArrayList<>(); + //获取月份内的检修任务 + List operAccessTaskEntityList = this.list(new LambdaQueryWrapper() {{ + ge(OperAccessTaskEntity::getPlanStartTime, startDate); + le(OperAccessTaskEntity::getPlanStartTime, endDate); + in(OperAccessTaskEntity::getCreateDept, deptIdList); + }}); + //组合处理人 + Map> mapByDisposer = operAccessTaskEntityList.stream().collect(Collectors.groupingBy(OperAccessTaskEntity::getHandler)); - @Override - public List getAccessTaskByDisposer(LocalDate startDate, LocalDate endDate, List deptIdList) { - List inspectOrAccessReportVOList = new ArrayList<>(); - //获取月份内的检修任务 - List operAccessTaskEntityList = this.list(new LambdaQueryWrapper(){{ - ge(OperAccessTaskEntity::getPlanStartTime,startDate); - le(OperAccessTaskEntity::getPlanStartTime,endDate); - in(OperAccessTaskEntity::getCreateDept,deptIdList); - }}); - //组合处理人 - Map> mapByDisposer = operAccessTaskEntityList.stream().collect(Collectors.groupingBy(OperAccessTaskEntity::getHandler)); + mapByDisposer.forEach((userId, list) -> { + AccessReportVO accessReportVO = new AccessReportVO(); + accessReportVO.setUserName(UserCache.getUser(userId).getName()); + accessReportVO.setData(list); + //已完成情况 + List finishList = list.stream().filter(o -> AccessConstants.ACCESS_TASK_STATUS_4 == o.getStatus()).collect(Collectors.toList()); + accessReportVO.setCompleteNum(finishList.size()); + accessReportVO.setCompleteSituation(finishList.size() + ""); + //未完成情况 + List immatureList = list.stream().filter(o -> AccessConstants.ACCESS_TASK_STATUS_4 != o.getStatus()).collect(Collectors.toList()); + accessReportVO.setIncompleteNum(immatureList.size()); + accessReportVO.setIncompleteSituation(immatureList.size() + ""); + //工时 + int hours = list.stream().filter(o -> o.getActHours() != null).collect(Collectors.summingInt(OperAccessTaskEntity::getActHours)); + accessReportVO.setHours(hours); + //发现问题数量 + List operPhenomenonEntityList = operPhenomenonMapper.selectList(new LambdaQueryWrapper() {{ + eq(OperPhenomenonEntity::getFinder, userId); + ge(OperPhenomenonEntity::getFindTime, startDate); + le(OperPhenomenonEntity::getFindTime, endDate); + eq(OperPhenomenonEntity::getSourceCode, DefectConstant.DefectSourceEnum.JX.getStatus()); + }}); + accessReportVO.setFindProblemCount(operPhenomenonEntityList.size()); + inspectOrAccessReportVOList.add(accessReportVO); + }); + return inspectOrAccessReportVOList; + } - mapByDisposer.forEach((userId,list)->{ - AccessReportVO accessReportVO = new AccessReportVO(); - accessReportVO.setUserName(UserCache.getUser(userId).getName()); - accessReportVO.setData(list); - //已完成情况 - List finishList = list.stream().filter(o-> AccessConstants.ACCESS_TASK_STATUS_4 == o.getStatus()).collect(Collectors.toList()); - accessReportVO.setCompleteNum(finishList.size()); - accessReportVO.setCompleteSituation(finishList.size()+""); - //未完成情况 - List immatureList = list.stream().filter(o-> AccessConstants.ACCESS_TASK_STATUS_4 != o.getStatus()).collect(Collectors.toList()); - accessReportVO.setIncompleteNum(immatureList.size()); - accessReportVO.setIncompleteSituation(immatureList.size()+""); - //工时 - int hours = list.stream().filter(o->o.getActHours() != null).collect(Collectors.summingInt(OperAccessTaskEntity::getActHours)); - accessReportVO.setHours(hours); - //发现问题数量 - List operPhenomenonEntityList = operPhenomenonMapper.selectList(new LambdaQueryWrapper(){{ - eq(OperPhenomenonEntity::getFinder,userId); - ge(OperPhenomenonEntity::getFindTime,startDate); - le(OperPhenomenonEntity::getFindTime,endDate); - eq(OperPhenomenonEntity::getSourceCode, DefectConstant.DefectSourceEnum.JX.getStatus()); - }}); - accessReportVO.setFindProblemCount(operPhenomenonEntityList.size()); - inspectOrAccessReportVOList.add(accessReportVO); - }); - return inspectOrAccessReportVOList; - } + @Override + public List getAccessTaskByDisposer(Map params) { + LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + List deptIdList = (List) params.get("deptId"); + return getAccessTaskByDisposer(startDate, endDate, deptIdList); + } - @Override - public List getAccessTaskByDisposer(Map params) { - LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - List deptIdList = (List)params.get("deptId"); - return getAccessTaskByDisposer(startDate,endDate,deptIdList); - } + @Override + public List> getAccessConclusion(Map params) { + return mapper.getAccessConclusion(params); + } - @Override - public List> getAccessConclusion(Map params) { - return mapper.getAccessConclusion(params); - } + @Override + public List getAccessTask(String startTime, String endTime, List list) { + return this.baseMapper.selectAccessTask(startTime, endTime, list); + } - @Override - public List getAccessTask(String startTime,String endTime,List list) { - return this.baseMapper.selectAccessTask(startTime,endTime,list); - } + /** + * 调整明细 + * + * @author xiashandong + **/ + @Transactional(rollbackFor = Exception.class) + public void updateDetails(long taskId, List details) { + if (CollectionUtils.isEmpty(details)) { + return; + } - /** - * 调整明细 - * - * @author xiashandong - **/ - @Transactional(rollbackFor = Exception.class) - public void updateDetails(long taskId, List details) { - if (CollectionUtils.isEmpty(details)) { - return; - } + //查询已经存在的明细,并删除部分需要删除的 + List existsDetails = detailService.list(new LambdaQueryWrapper() {{ + eq(OperAccessTaskDetailEntity::getTaskId, taskId); + eq(OperAccessTaskDetailEntity::getIsDeleted, 0L); + }}); + Set detailIds = details.stream().filter(o -> o.getId() != null).map(OperAccessTaskDetailDTO::getId).collect(Collectors.toSet()); + List ids = existsDetails.stream().filter(o -> !detailIds.contains(o.getId())).map(OperAccessTaskDetailEntity::getId).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(ids)) { + detailService.deleteLogic(ids); + } - //查询已经存在的明细,并删除部分需要删除的 - List existsDetails = detailService.list(new LambdaQueryWrapper() {{ - eq(OperAccessTaskDetailEntity::getTaskId, taskId); - eq(OperAccessTaskDetailEntity::getIsDeleted, 0L); - }}); - Set detailIds = details.stream().filter(o -> o.getId() != null).map(OperAccessTaskDetailDTO::getId).collect(Collectors.toSet()); - List ids = existsDetails.stream().filter(o -> !detailIds.contains(o.getId())).map(OperAccessTaskDetailEntity::getId).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(ids)) { - detailService.deleteLogic(ids); - } + //新增或修改操作 + Set existsIds = existsDetails.stream().map(OperAccessTaskDetailEntity::getId).collect(Collectors.toSet()); + for (OperAccessTaskDetailDTO req : details) { + req.setTaskId(taskId); + if (req.getId() == null) { + detailService.doSave(req); + } else if (req.getId() != null && existsIds.contains(req.getId())) { + detailService.updateById(req); + } else { + detailService.doSave(req); + } + } + } - //新增或修改操作 - Set existsIds = existsDetails.stream().map(OperAccessTaskDetailEntity::getId).collect(Collectors.toSet()); - for (OperAccessTaskDetailDTO req : details) { - req.setTaskId(taskId); - if (req.getId() == null) { - detailService.doSave(req); - } else if (req.getId() != null && existsIds.contains(req.getId())) { - detailService.updateById(req); - } else { - detailService.doSave(req); - } - } - } + /** + * 调整检修材料 + * + * @author xiashandong + **/ + @Transactional(rollbackFor = Exception.class) + public void updateMaterials(long planId, long taskId, List materials) { + if (CollectionUtils.isEmpty(materials)) { + materials = new ArrayList<>(); + } + //查询已经存在的检修库明细,并删除部分需要删除的 + List existsDetails = materialService.list(new LambdaQueryWrapper() {{ + eq(OperAccessMaterialEntity::getPlanId, planId); + eq(OperAccessMaterialEntity::getTaskId, taskId); + eq(OperAccessMaterialEntity::getIsDeleted, 0L); + }}); + Set detailIds = materials.stream().filter(o -> o.getId() != null).map(OperAccessMaterialDTO::getId).collect(Collectors.toSet()); + List ids = existsDetails.stream().filter(o -> !detailIds.contains(o.getId())).map(OperAccessMaterialEntity::getId).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(ids)) { + materialService.deleteLogic(ids); + } + if (CollectionUtil.isNotEmpty(materials)) { + List materialEntityList = JSONArray.parseArray(JSON.toJSONString(materials), OperAccessMaterialEntity.class); + materialService.saveOrUpdateBatch(materialEntityList); + } + } - /** - * 调整检修材料 - * - * @author xiashandong - **/ - @Transactional(rollbackFor = Exception.class) - public void updateMaterials(long planId,long taskId, List materials) { - if (CollectionUtils.isEmpty(materials)) { - materials = new ArrayList<>(); - } - //查询已经存在的检修库明细,并删除部分需要删除的 - List existsDetails = materialService.list(new LambdaQueryWrapper() {{ - eq(OperAccessMaterialEntity::getPlanId, planId); - eq(OperAccessMaterialEntity::getTaskId, taskId); - eq(OperAccessMaterialEntity::getIsDeleted, 0L); - }}); - Set detailIds = materials.stream().filter(o -> o.getId() != null).map(OperAccessMaterialDTO::getId).collect(Collectors.toSet()); - List ids = existsDetails.stream().filter(o -> !detailIds.contains(o.getId())).map(OperAccessMaterialEntity::getId).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(ids)) { - materialService.deleteLogic(ids); - } - if(CollectionUtil.isNotEmpty(materials)){ - List materialEntityList = JSONArray.parseArray(JSON.toJSONString(materials),OperAccessMaterialEntity.class); - materialService.saveOrUpdateBatch(materialEntityList); - } - } + /** + * 执行检修任务 + * + * @param accessTaskDTO + * @return + */ + @Override + public R finishAccessTask(OperAccessTaskDTO accessTaskDTO) { + OperAccessTaskEntity taskEntity = getById(accessTaskDTO.getId()); + //TODO 更新任务状态以及 填入数据(待确认) + taskEntity.setStatus(AccessConstants.ACCESS_TASK_STATUS_2); + taskEntity.setActHours(accessTaskDTO.getActHours()); + if (updateById(taskEntity)) { + //更新材料 + updateMaterials(taskEntity.getPlanId(), taskEntity.getId(), accessTaskDTO.getAccessMaterials()); + //终结工作流 + ComleteTask comleteTask = new ComleteTask(); + comleteTask.setProcessInstanceId(taskEntity.getProcessInstanceId()); + comleteTask.setFlag("ok"); + comleteTask.setPass(true); + comleteTask.setComment("执行任务完成,进行下一步流程"); + this.completeTask(comleteTask, AuthUtil.getUserId(), taskEntity.getProcessInstanceId(), taskEntity.getCreateDept()); + } + return R.success("操作成功"); + } - /** - * 执行检修任务 - * @param accessTaskDTO - * @return - */ - @Override - public R finishAccessTask(OperAccessTaskDTO accessTaskDTO) { - OperAccessTaskEntity taskEntity = getById(accessTaskDTO.getId()); - //TODO 更新任务状态以及 填入数据(待确认) - taskEntity.setStatus(AccessConstants.ACCESS_TASK_STATUS_2); - taskEntity.setActHours(accessTaskDTO.getActHours()); - if(updateById(taskEntity)) { - //更新材料 - updateMaterials(taskEntity.getPlanId(), taskEntity.getId(), accessTaskDTO.getAccessMaterials()); - //终结工作流 - ComleteTask comleteTask = new ComleteTask(); - comleteTask.setProcessInstanceId(taskEntity.getProcessInstanceId()); - comleteTask.setFlag("ok"); - comleteTask.setPass(true); - comleteTask.setComment("执行任务完成,进行下一步流程"); - this.completeTask(comleteTask,AuthUtil.getUserId(),taskEntity.getProcessInstanceId(),taskEntity.getCreateDept()); - } - return R.success("操作成功"); - } + /** + * 获取安全检查定期检修项统计 + * + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param dept 机构ID + * @return SafeCheckStatisticVO对象 + */ + @Override + public SafeCheckStatisticVO getAccessTaskCheck(String startDate, String endDate, Long dept) { + SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); + List taskEntityList = this.list(Wrappers.lambdaQuery().eq(OperAccessTaskEntity::getStatus, AccessConstants.ACCESS_TASK_STATUS_4).ge(OperAccessTaskEntity::getCreateTime, startDate).le(OperAccessTaskEntity::getCreateTime, endDate).eq(OperAccessTaskEntity::getCreateDept, dept)); + vo.setProjectType(Constants.SafeCheckProjectEnum.ACCESS_TASK.getType()); + vo.setProjectTypeName(Constants.SafeCheckProjectEnum.ACCESS_TASK.getName()); + vo.setTotal(taskEntityList.size()); + return vo; + } - /** - * 获取安全检查定期检修项统计 - * @param startDate 开始时间 - * @param endDate 结束时间 - * @param dept 机构ID - * @return SafeCheckStatisticVO对象 - */ - @Override - public SafeCheckStatisticVO getAccessTaskCheck(String startDate, String endDate, Long dept) { - SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); - List taskEntityList = this.list(Wrappers.lambdaQuery() - .eq(OperAccessTaskEntity::getStatus,AccessConstants.ACCESS_TASK_STATUS_4) - .ge(OperAccessTaskEntity::getCreateTime,startDate) - .le(OperAccessTaskEntity::getCreateTime,endDate) - .eq(OperAccessTaskEntity::getCreateDept,dept) - ); - vo.setProjectType(Constants.SafeCheckProjectEnum.ACCESS_TASK.getType()); - vo.setProjectTypeName(Constants.SafeCheckProjectEnum.ACCESS_TASK.getName()); - vo.setTotal(taskEntityList.size()); - return vo; - } + /** + * 根据区域和月份分页查询检修任务 + * + * @param dbPage + * @param result + */ + @Override + public IPage selectPage(Page dbPage, OperAccessTaskEntity result) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //区域 + queryWrapper.eq(StringUtils.isNotBlank(result.getAreaId()), "CREATE_DEPT", result.getAreaId()); + //月份 + queryWrapper.eq(result.getYearMonth() != null, "date_format(PLAN_START_TIME, '%Y-%m')", result.getYearMonth()); + //任务名称 + queryWrapper.eq(StringUtils.isNotBlank(result.getName()), "name", result.getName()); + //状态 + queryWrapper.eq(result.getStatus() != null, "STATUS", result.getStatus()); - /*** - * 根据流程ID和处理人完成任务 - * @param comleteTask - * @param handler - * @param processInstanceId - */ - private void completeTask(ComleteTask comleteTask, Long handler, String processInstanceId, Long deptId) { - if(ObjectUtil.isNotEmpty(handler)){ - String taskUser = StringUtil.format("{}_{}",new String[]{"taskUser",String.valueOf(handler)}); - R bladeFlowR = flowClient.getTaskByProcessInstanceIdAndUserId(processInstanceId,taskUser); - if(!bladeFlowR.isSuccess() || ObjectUtil.isEmpty(bladeFlowR.getData())){ - throw new ServiceException("获取检修任务工作流任务失败"); - } - //若成功则封装CompleteTask 执行任务 - comleteTask.setProcessInstanceId(processInstanceId); - comleteTask.setTaskId(bladeFlowR.getData().getTaskId()); - } - //获取检修任务审批人角色下的审批人列表 - R> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), deptId, AccessConstants.TASK_REVIEWER); - if(!userListR.isSuccess()){ - throw new ServiceException(userListR.getMsg()); - } - if(ObjectUtil.isNotEmpty(userListR.getData())) { - String reviewer = userListR.getData().stream().map(user->StringUtil.format("{}_{}","taskUser",String.valueOf(user.getId()))) - .collect(Collectors.joining(",")); - Map variables = new HashMap<>(1); - variables.put("reviewer",reviewer); - comleteTask.setVariables(variables); - } + return baseMapper.selectPage(dbPage, queryWrapper); + } - R result = flowClient.completeTask(comleteTask); - if(!result.isSuccess()){ - throw new ServiceException(result.getMsg()); - } - } + /*** + * 根据流程ID和处理人完成任务 + * @param comleteTask + * @param handler + * @param processInstanceId + */ + private void completeTask(ComleteTask comleteTask, Long handler, String processInstanceId, Long deptId) { + if (ObjectUtil.isNotEmpty(handler)) { + String taskUser = StringUtil.format("{}_{}", new String[]{"taskUser", String.valueOf(handler)}); + R bladeFlowR = flowClient.getTaskByProcessInstanceIdAndUserId(processInstanceId, taskUser); + if (!bladeFlowR.isSuccess() || ObjectUtil.isEmpty(bladeFlowR.getData())) { + throw new ServiceException("获取检修任务工作流任务失败"); + } + //若成功则封装CompleteTask 执行任务 + comleteTask.setProcessInstanceId(processInstanceId); + comleteTask.setTaskId(bladeFlowR.getData().getTaskId()); + } + //获取检修任务审批人角色下的审批人列表 + R> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), deptId, AccessConstants.TASK_REVIEWER); + if (!userListR.isSuccess()) { + throw new ServiceException(userListR.getMsg()); + } + if (ObjectUtil.isNotEmpty(userListR.getData())) { + String reviewer = userListR.getData().stream().map(user -> StringUtil.format("{}_{}", "taskUser", String.valueOf(user.getId()))).collect(Collectors.joining(",")); + Map variables = new HashMap<>(1); + variables.put("reviewer", reviewer); + comleteTask.setVariables(variables); + } - /** - * 根据检修任务完成缺陷处理流程 - * @param accessTaskEntity - */ - private void finishDefectFlow(OperAccessTaskEntity accessTaskEntity) { - if(Func.isNotEmpty(accessTaskEntity.getPhenomenonId())) { - OperPhenomenonEntity operPhenomenonEntity = operPhenomenonMapper.selectById(accessTaskEntity.getPhenomenonId()); - operPhenomenonEntity.setHandleStatus(RepairConstant.CONCLUSION_PROBLEM); - //operPhenomenonEntity.setCheckHours(accessTaskEntity.getActHours()); - operPhenomenonMapper.updateById(operPhenomenonEntity); - String processInstanceId = operPhenomenonEntity.getCheckProcessInstanceId(); - //获取缺陷 - OperDefectEntity operDefectEntity = defectService.getOne(Wrappers.lambdaQuery() - .eq(OperDefectEntity::getDefectCode, operPhenomenonEntity.getDefectCode()) - .last("limit 1;") - ); - if(ObjectUtil.isNotEmpty(operDefectEntity)) { - operDefectEntity.setActEndTime(new Date()); - operDefectEntity.setActHours(ObjectUtil.isNotEmpty(accessTaskEntity.getActHours()) ? accessTaskEntity.getActHours().toString() : null); - operDefectEntity.setHandleStatus(RepairConstant.CONCLUSION_PROBLEM); - operDefectEntity.setDisposeDesc(accessTaskEntity.getDescripiton()); - defectService.updateById(operDefectEntity); - } + R result = flowClient.completeTask(comleteTask); + if (!result.isSuccess()) { + throw new ServiceException(result.getMsg()); + } + } - ComleteTask comleteTask = new ComleteTask(); - comleteTask.setProcessInstanceId(processInstanceId); - //获取当前环节taskId - R bladeFlowR = flowClient.getTaskByProcessInstanceIdAndUserId(processInstanceId, "taskUser_"+AuthUtil.getUserId()); - Assert.isTrue(bladeFlowR.isSuccess() && ObjectUtil.isNotEmpty(bladeFlowR.getData()),()->{ - throw new ServiceException("当前操作人获取消缺任务失败"); - }); - comleteTask.setTaskId(bladeFlowR.getData().getTaskId()); - comleteTask.setComment("审批通过工作流结束"); - comleteTask.setFlag("ok"); - comleteTask.setPass(true); - Map variables = new HashMap<>(1); - R> listR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), operDefectEntity.getCreateDept(), DefectConstant.PROCESS_VARIABLE_CONCLUSION); - Assert.isTrue(listR.isSuccess() && ObjectUtil.isNotEmpty(listR.getData()),()->{ - throw new ServiceException("获取问题定论人失败"); - }); - String conclusion = listR.getData().stream().map(user->"taskUser_"+user.getId()).collect(Collectors.joining(",")); - variables.put("conclusion",conclusion); - comleteTask.setVariables(variables); - flowClient.completeTask(comleteTask); - } - } + /** + * 根据检修任务完成缺陷处理流程 + * + * @param accessTaskEntity + */ + private void finishDefectFlow(OperAccessTaskEntity accessTaskEntity) { + if (Func.isNotEmpty(accessTaskEntity.getPhenomenonId())) { + OperPhenomenonEntity operPhenomenonEntity = operPhenomenonMapper.selectById(accessTaskEntity.getPhenomenonId()); + operPhenomenonEntity.setHandleStatus(RepairConstant.CONCLUSION_PROBLEM); + //operPhenomenonEntity.setCheckHours(accessTaskEntity.getActHours()); + operPhenomenonMapper.updateById(operPhenomenonEntity); + String processInstanceId = operPhenomenonEntity.getCheckProcessInstanceId(); + //获取缺陷 + OperDefectEntity operDefectEntity = defectService.getOne(Wrappers.lambdaQuery().eq(OperDefectEntity::getDefectCode, operPhenomenonEntity.getDefectCode()).last("limit 1;")); + if (ObjectUtil.isNotEmpty(operDefectEntity)) { + operDefectEntity.setActEndTime(new Date()); + operDefectEntity.setActHours(ObjectUtil.isNotEmpty(accessTaskEntity.getActHours()) ? accessTaskEntity.getActHours().toString() : null); + operDefectEntity.setHandleStatus(RepairConstant.CONCLUSION_PROBLEM); + operDefectEntity.setDisposeDesc(accessTaskEntity.getDescripiton()); + defectService.updateById(operDefectEntity); + } - /** - * 巡检任务生成后待办消息提示 - * @param req - */ - private void pushHandleMessage(OperAccessTaskDTO operAccessTaskDTO,PushExtrasReq req){ - req.setTitle(AccessConstants.MESSAGE_TITLE); - req.setType(AccessConstants.MESSAGE_ACCESS_TYPE); - req.setBusinessClassify(OperationalConstants.MessageClassifyEnum.MESSAGE_REMINDSY.getVal()); - req.setPushAlert(AccessConstants.AccessProcessEnum.ACCESS_BACKLOG.getMsg()); - log.info("--------消息推送开始----------"); - messagePushClient.sendMessage(operAccessTaskDTO.getHandler().toString(), req,operAccessTaskDTO.getTenantId(),operAccessTaskDTO.getCreateDept(),operAccessTaskDTO.getCreateUser()); - log.info("消息推送人为:{},推送消息为:{}",operAccessTaskDTO.getHandler().toString(),AccessConstants.AccessProcessEnum.ACCESS_BACKLOG.getMsg()); - log.info("--------消息推送成功----------"); - } + ComleteTask comleteTask = new ComleteTask(); + comleteTask.setProcessInstanceId(processInstanceId); + //获取当前环节taskId + R bladeFlowR = flowClient.getTaskByProcessInstanceIdAndUserId(processInstanceId, "taskUser_" + AuthUtil.getUserId()); + Assert.isTrue(bladeFlowR.isSuccess() && ObjectUtil.isNotEmpty(bladeFlowR.getData()), () -> { + throw new ServiceException("当前操作人获取消缺任务失败"); + }); + comleteTask.setTaskId(bladeFlowR.getData().getTaskId()); + comleteTask.setComment("审批通过工作流结束"); + comleteTask.setFlag("ok"); + comleteTask.setPass(true); + Map variables = new HashMap<>(1); + R> listR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), operDefectEntity.getCreateDept(), DefectConstant.PROCESS_VARIABLE_CONCLUSION); + Assert.isTrue(listR.isSuccess() && ObjectUtil.isNotEmpty(listR.getData()), () -> { + throw new ServiceException("获取问题定论人失败"); + }); + String conclusion = listR.getData().stream().map(user -> "taskUser_" + user.getId()).collect(Collectors.joining(",")); + variables.put("conclusion", conclusion); + comleteTask.setVariables(variables); + flowClient.completeTask(comleteTask); + } + } + + /** + * 巡检任务生成后待办消息提示 + * + * @param req + */ + private void pushHandleMessage(OperAccessTaskDTO operAccessTaskDTO, PushExtrasReq req) { + req.setTitle(AccessConstants.MESSAGE_TITLE); + req.setType(AccessConstants.MESSAGE_ACCESS_TYPE); + req.setBusinessClassify(OperationalConstants.MessageClassifyEnum.MESSAGE_REMINDSY.getVal()); + req.setPushAlert(AccessConstants.AccessProcessEnum.ACCESS_BACKLOG.getMsg()); + log.info("--------消息推送开始----------"); + messagePushClient.sendMessage(operAccessTaskDTO.getHandler().toString(), req, operAccessTaskDTO.getTenantId(), operAccessTaskDTO.getCreateDept(), operAccessTaskDTO.getCreateUser()); + log.info("消息推送人为:{},推送消息为:{}", operAccessTaskDTO.getHandler().toString(), AccessConstants.AccessProcessEnum.ACCESS_BACKLOG.getMsg()); + log.info("--------消息推送成功----------"); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperPhenomenonController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperPhenomenonController.java index f791cb8..7c4e715 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperPhenomenonController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperPhenomenonController.java @@ -45,107 +45,127 @@ import java.util.Date; @Validated public class OperPhenomenonController extends BladeController { - private final IOperPhenomenonService phenomenonService; - - /** - * 详情 - */ - @ApiLog - @GetMapping("/detail") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "详情", notes = "传入phenomenon") - public R detail(OperPhenomenonEntity phenomenon) { - OperPhenomenonEntity detail = phenomenonService.getOne(Condition.getQueryWrapper(phenomenon)); - OperPhenomenonVO vo = OperPhenomenonWrapper.build().entityVO(detail); - return R.data(vo); - } - - /** - * 分页 代码自定义代号 - */ - @ApiLog - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入phenomenon") - @ApiImplicitParams({ - }) - @OperationAnnotation(moduleName = "缺陷管理",title = "现象库",operatorType = OperatorType.MOBILE,businessType = - BusinessType.GENCODE,action - = "分页") - public R> list(OperPhenomenonEntity entity,String taskIds, Query query, Date findTimeEnd) { - LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperPhenomenonEntity(), entity); - if (StringUtil.isNotBlank(taskIds)){ - queryWrapper.in(OperPhenomenonEntity::getId, Lists.newArrayList(taskIds.split(","))); - } - if (Func.isNotEmpty(entity.getFindTime())) { - queryWrapper.ge(OperPhenomenonEntity::getFindTime, entity.getFindTime()); - } - if (Func.isNotEmpty(findTimeEnd)) { - queryWrapper.le(OperPhenomenonEntity::getFindTime, findTimeEnd); - } - if (Func.isNotEmpty(entity.getDiscriminateStatus())) { - queryWrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, entity.getDiscriminateStatus()); - } - queryWrapper.orderByDesc(OperPhenomenonEntity::getUpdateTime); - IPage pages = phenomenonService.page(Condition.getPage(query), queryWrapper); - IPage vos = OperPhenomenonWrapper.build().pageVO(pages); - return R.data(vos); - } - - /** - * 新增 代码自定义代号 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "提交现象,现象提交后不能修改", notes = "传入phenomenon") - public R save(@Valid @RequestBody OperPhenomenonEntity phenomenon) { - return R.data(phenomenonService.submit(phenomenon)); - } - - /* *//** - * 修改 代码自定义代号 - *//* - @PostMapping("/update") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "修改", notes = "传入phenomenon") - public R update(@Valid @RequestBody OperPhenomenonEntity phenomenon) { - return R.status(phenomenonService.updateById(phenomenon)); - } - - *//** - * 新增或修改 代码自定义代号 - *//* - @PostMapping("/submit") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "新增或修改", notes = "传入phenomenon") - public R submit(@Valid @RequestBody OperPhenomenonEntity phenomenon) { - return R.status(phenomenonService.saveOrUpdate(phenomenon)); - }*/ - - - /** - * 删除 代码自定义代号 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 7) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(phenomenonService.deleteLogic(Func.toLongList(ids))); - } - - - @PostMapping("/handleCheckProcess") - @ApiOperation(value = "处理问题甄别流程", notes = "处理问题甄别流程") - public R handleCheckProcess(@RequestBody @ObjectRequiredInvalid(attributes = {"taskId", "processInstanceId", "comment", "flag", - "variables.pass"}, message = "参数不能为空") BladeFlow flow) { - //@DictInvalid(dictKey = "") - return R.status(phenomenonService.handleCheckProcess(flow)); - } - - @GetMapping("/getFdpTaskByDefectCode") - @ApiOperationSupport(order = 9) - @ApiOperation(value = "根据缺陷编码获取智能诊断任务", notes = "传入defectCode") - public R getFdpTaskByDefectCode(@RequestParam("defectCode") String defectCode) { - return R.data(phenomenonService.getFdpTaskByDefectCode(defectCode)); - } + private final IOperPhenomenonService phenomenonService; + + /** + * 详情 + */ + @ApiLog + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入phenomenon") + public R detail(OperPhenomenonEntity phenomenon) { + OperPhenomenonEntity detail = phenomenonService.getOne(Condition.getQueryWrapper(phenomenon)); + OperPhenomenonVO vo = OperPhenomenonWrapper.build().entityVO(detail); + return R.data(vo); + } + + /** + * 分页 代码自定义代号 + */ + @ApiLog + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入phenomenon") + @ApiImplicitParams({ + }) + @OperationAnnotation(moduleName = "缺陷管理", title = "现象库", operatorType = OperatorType.MOBILE, businessType = + BusinessType.GENCODE, action + = "分页") + public R> list(OperPhenomenonEntity entity, String taskIds, Query query, Date findTimeEnd) { + LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperPhenomenonEntity(), entity); + if (StringUtil.isNotBlank(taskIds)) { + queryWrapper.in(OperPhenomenonEntity::getId, Lists.newArrayList(taskIds.split(","))); + } + if (Func.isNotEmpty(entity.getFindTime())) { + queryWrapper.ge(OperPhenomenonEntity::getFindTime, entity.getFindTime()); + } + if (Func.isNotEmpty(findTimeEnd)) { + queryWrapper.le(OperPhenomenonEntity::getFindTime, findTimeEnd); + } + if (Func.isNotEmpty(entity.getDiscriminateStatus())) { + queryWrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, entity.getDiscriminateStatus()); + } + + // // 区域Id + // if (Func.isNotEmpty(entity.getAreaId())) { + // queryWrapper.eq(OperPhenomenonEntity::getCreateDept, entity.getAreaId()); + // } + // + // // 年份 + // if (Func.isNotEmpty(entity.getYearMonth())) { + // queryWrapper.apply("date_format(t.CREATE_TIME, '%Y-%m') = '" + // + (entity.getYearMonth() + "'")); + // } + // + // + // // 是否为缺陷 已定论1 + // if (Func.isNotEmpty(entity.getDefect()) && Func.isNotEmpty(entity.getConclusionStatusNum())) { + // queryWrapper.eq(OperPhenomenonEntity::getIsDefect, entity.getDefect()); + // queryWrapper.or().eq(OperPhenomenonEntity::getConclusionStatus, entity.getConclusionStatusNum()); + // } + + + queryWrapper.orderByDesc(OperPhenomenonEntity::getUpdateTime); + IPage pages = phenomenonService.page(Condition.getPage(query), queryWrapper); + IPage vos = OperPhenomenonWrapper.build().pageVO(pages); + return R.data(vos); + } + + /** + * 新增 代码自定义代号 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "提交现象,现象提交后不能修改", notes = "传入phenomenon") + public R save(@Valid @RequestBody OperPhenomenonEntity phenomenon) { + return R.data(phenomenonService.submit(phenomenon)); + } + + /* */ /** + * 修改 代码自定义代号 + */ /* + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "修改", notes = "传入phenomenon") + public R update(@Valid @RequestBody OperPhenomenonEntity phenomenon) { + return R.status(phenomenonService.updateById(phenomenon)); + } + + */ /** + * 新增或修改 代码自定义代号 + */ /* + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "新增或修改", notes = "传入phenomenon") + public R submit(@Valid @RequestBody OperPhenomenonEntity phenomenon) { + return R.status(phenomenonService.saveOrUpdate(phenomenon)); + }*/ + + + /** + * 删除 代码自定义代号 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "逻辑删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status(phenomenonService.deleteLogic(Func.toLongList(ids))); + } + + + @PostMapping("/handleCheckProcess") + @ApiOperation(value = "处理问题甄别流程", notes = "处理问题甄别流程") + public R handleCheckProcess(@RequestBody @ObjectRequiredInvalid(attributes = {"taskId", "processInstanceId", "comment", "flag", + "variables.pass"}, message = "参数不能为空") BladeFlow flow) { + //@DictInvalid(dictKey = "") + return R.status(phenomenonService.handleCheckProcess(flow)); + } + + @GetMapping("/getFdpTaskByDefectCode") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "根据缺陷编码获取智能诊断任务", notes = "传入defectCode") + public R getFdpTaskByDefectCode(@RequestParam("defectCode") String defectCode) { + return R.data(phenomenonService.getFdpTaskByDefectCode(defectCode)); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java index d5df747..26cad87 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java @@ -923,7 +923,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl taskVoIPage = areaMonthlyDetailsService.queryCheckTaskPageList(task, query); + BladePage taskVoIPage = areaMonthlyDetailsService.queryCheckTaskPageList(task, page,size); return R.data(taskVoIPage); } @@ -190,13 +202,42 @@ public class AreaMonthlyDetailsController { @ApiOperationSupport(order = 70) @ApiOperation(value = "根据区域和月份分页查询缺陷库") @GetMapping("/queryDefectPageList/{page}/{size}") - public R> queryDefectPageList( + public R> queryDefectPageList( @ApiParam(name = "page", value = "当前页", required = true) @PathVariable("page") Long page, @ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size, - OperDefectEntity defect) { - Page operDefectEntityPage = new Page<>(page, size); - IPage pages = defectService.selectPage(operDefectEntityPage, defect); - IPage vos = OperDefectWrapper.build().pageVO(pages); + OperPhenomenonEntity entity, String taskIds, Date findTimeEnd) { + Page operDefectEntityPage = new Page<>(page, size); + LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperPhenomenonEntity(), entity); + if (StringUtil.isNotBlank(taskIds)) { + queryWrapper.in(OperPhenomenonEntity::getId, Lists.newArrayList(taskIds.split(","))); + } + if (Func.isNotEmpty(entity.getFindTime())) { + queryWrapper.ge(OperPhenomenonEntity::getFindTime, entity.getFindTime()); + } + if (Func.isNotEmpty(findTimeEnd)) { + queryWrapper.le(OperPhenomenonEntity::getFindTime, findTimeEnd); + } + if (Func.isNotEmpty(entity.getDiscriminateStatus())) { + queryWrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, entity.getDiscriminateStatus()); + } + // 区域Id + if (Func.isNotEmpty(entity.getAreaId())) { + queryWrapper.eq(OperPhenomenonEntity::getCreateDept, entity.getAreaId()); + } + // 年份 + if (Func.isNotEmpty(entity.getYearMonth())) { + queryWrapper.apply("date_format(CREATE_TIME, '%Y-%m') = '" + + entity.getYearMonth() + "'"); + } + // 是否为缺陷 已定论1 + if (Func.isNotEmpty(entity.getDefect()) && Func.isNotEmpty(entity.getConclusionStatusNum())) { + queryWrapper.eq(OperPhenomenonEntity::getIsDefect, entity.getDefect()); + queryWrapper.or().eq(OperPhenomenonEntity::getConclusionStatus, entity.getConclusionStatusNum()); + } + + queryWrapper.orderByDesc(OperPhenomenonEntity::getUpdateTime); + IPage pages = phenomenonService.page(operDefectEntityPage, queryWrapper); + IPage vos = OperPhenomenonWrapper.build().pageVO(pages); return R.data(vos); } @@ -218,13 +259,13 @@ public class AreaMonthlyDetailsController { @ApiOperationSupport(order = 80) @ApiOperation(value = "根据区域和月份分页查询检修任务") @GetMapping("/queryReconditionPageList/{page}/{size}") - public R> queryReconditionPageList( + public R> queryReconditionPageList( @ApiParam(name = "page", value = "当前页", required = true) @PathVariable("page") Long page, @ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size, - OperAccessStatisticsDTO result) { - Page dbPage = new Page<>(page, size); - R> r = accessStatisticsService.list(result, dbPage); - return r; + OperAccessTaskEntity result) { + Page dbPage = new Page<>(page, size); + IPage list = takeAccessTaskService.selectPage(dbPage, result); + return R.data(list); } @@ -278,7 +319,7 @@ public class AreaMonthlyDetailsController { */ @GetMapping("/queryProduceByAreaCode/{page}/{size}") @ApiOperationSupport(order = 100) - @ApiOperation(value = "根据区域编号查询技能培训") + @ApiOperation(value = "根据区域编号查询月度自查") public R> queryProduceByAreaCode( @ApiParam(name = "page", value = "当前页", required = true) @PathVariable("page") Long page, @ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size, @@ -336,8 +377,8 @@ public class AreaMonthlyDetailsController { @ApiOperationSupport(order = 100) @ApiOperation(value = "根据区域编号查询设备试验") public R> queryEquipmentAreaCode( - @ApiParam(name = "page",value = "当前页",required = true) @PathVariable("page") Long page, - @ApiParam(name = "size",value = "每页记录数",required = true) @PathVariable("size") Long size, + @ApiParam(name = "page", value = "当前页", required = true) @PathVariable("page") Long page, + @ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size, SafeEquipmentTrialDTO safeEquipmentTrialDTO) { BladePage checkMonthVoBladePage = areaMonthlyDetailsService.queryEquipmentAreaCode(page , size, safeEquipmentTrialDTO); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java index 9c3bc26..1de862d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java @@ -73,7 +73,7 @@ public interface AreaMonthlyDetailsService { * @param query * @return */ - BladePage queryCheckTaskPageList(TaskListQuery task, Query query); + BladePage queryCheckTaskPageList(TaskListQuery task,Long page, Long size); /** * 根据id查询巡检任务 @@ -122,4 +122,5 @@ public interface AreaMonthlyDetailsService { */ BladePage queryEquipmentAreaCode(Long page, Long size, SafeEquipmentTrialDTO safeEquipmentTrialDTO); + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java index 1c43df8..51a02cf 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java @@ -147,12 +147,11 @@ public class AreaMonthlyDetailsServiceImpl implements AreaMonthlyDetailsService * 根据区域和月份分页查询巡检任务 * * @param task - * @param query * @return */ @Override - public BladePage queryCheckTaskPageList(TaskListQuery task, Query query) { - R> list = taskFeignClient.list(task, query); + public BladePage queryCheckTaskPageList(TaskListQuery task, Long page, Long size) { + R> list = taskFeignClient.pageList(page,size,task); if (list.isSuccess()) { log.info("获取巡检检查任务列表成功"); return list.getData(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index 56ce66b..b253525 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -341,8 +341,7 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl - queryLogMaintenancePageList(Page pageParam, MaintenanceTaskWithAreaVo areaMonthlyVo) { + public IPage queryLogMaintenancePageList(Page pageParam, MaintenanceTaskWithAreaVo areaMonthlyVo) { //1.根据区域查询 QueryWrapper queryWrapper = new QueryWrapper<>(); //维护内容 @@ -360,7 +359,8 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl operMaintenanceTaskEntityPage = baseMapper.selectPage(pageParam, queryWrapper); //数据转换 diff --git a/hzims-service/operational/src/main/resources/application-dev.yml b/hzims-service/operational/src/main/resources/application-dev.yml index 712302b..a4e0db4 100644 --- a/hzims-service/operational/src/main/resources/application-dev.yml +++ b/hzims-service/operational/src/main/resources/application-dev.yml @@ -53,6 +53,8 @@ mybatis-plus: mapper-locations: classpath:com/hnac/hzims/**/mapper/*Mapper.xml #实体扫描,多个package用逗号或者分号分隔 typeAliasesPackage: com.hnac.hzims.**.entity + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #swagger扫描路径配置 swagger: diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.java index 943098c..137cd31 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.java @@ -1,15 +1,9 @@ package com.hnac.hzims.safeproduct.mapper; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; -import com.hnac.hzims.safeproduct.vo.CheckMonthVo; import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; -import org.springblade.core.mp.support.Query; - -import java.util.List; /** * Created by Sam Huang 2022/5/6 8:23 diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.xml index 84ad46d..0ed48ff 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.xml @@ -17,12 +17,15 @@