|
|
|
@ -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; |
|
|
|
@ -130,10 +137,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void checkProjectFinish(EventAddVO eventAddVO) { |
|
|
|
|
List<TaskObjectProjectContentEntity> topcList = taskObjectProjectContentService.list(Wrappers.<TaskObjectProjectContentEntity>lambdaQuery() |
|
|
|
|
.eq(TaskObjectProjectContentEntity::getTaskId, eventAddVO.getTaskId()) |
|
|
|
|
.eq(TaskObjectProjectContentEntity::getObjectId, eventAddVO.getObjId()) |
|
|
|
|
.eq(TaskObjectProjectContentEntity::getProjectId, eventAddVO.getProjectId())); |
|
|
|
|
List<TaskObjectProjectContentEntity> topcList = taskObjectProjectContentService.list(Wrappers.<TaskObjectProjectContentEntity>lambdaQuery().eq(TaskObjectProjectContentEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectProjectContentEntity::getObjectId, eventAddVO.getObjId()).eq(TaskObjectProjectContentEntity::getProjectId, eventAddVO.getProjectId())); |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(topcList)) { |
|
|
|
|
for (TaskObjectProjectContentEntity content : topcList) { |
|
|
|
@ -144,11 +148,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 任务项目状态设置为已完成*/ |
|
|
|
|
taskObjectProjectService.update(Wrappers.<TaskObjectProjectEntity>lambdaUpdate() |
|
|
|
|
.set(TaskObjectProjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()) |
|
|
|
|
.eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()) |
|
|
|
|
.eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId()) |
|
|
|
|
.eq(TaskObjectProjectEntity::getProjectId, eventAddVO.getProjectId())); |
|
|
|
|
taskObjectProjectService.update(Wrappers.<TaskObjectProjectEntity>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); |
|
|
|
|
} |
|
|
|
@ -159,9 +159,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
* @param eventAddVO |
|
|
|
|
*/ |
|
|
|
|
private void checkObjFinish(EventAddVO eventAddVO) { |
|
|
|
|
List<TaskObjectProjectEntity> topList = taskObjectProjectService.list(Wrappers.<TaskObjectProjectEntity>lambdaQuery() |
|
|
|
|
.eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()) |
|
|
|
|
.eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId())); |
|
|
|
|
List<TaskObjectProjectEntity> topList = taskObjectProjectService.list(Wrappers.<TaskObjectProjectEntity>lambdaQuery().eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(topList)) { |
|
|
|
@ -173,10 +171,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 任务项目状态设置为已完成*/ |
|
|
|
|
taskObjectService.update(Wrappers.<TaskObjectEntity>lambdaUpdate() |
|
|
|
|
.set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()) |
|
|
|
|
.eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId()) |
|
|
|
|
.eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId())); |
|
|
|
|
taskObjectService.update(Wrappers.<TaskObjectEntity>lambdaUpdate().set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()).eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId())); |
|
|
|
|
|
|
|
|
|
checkTaskFinish(eventAddVO); |
|
|
|
|
} |
|
|
|
@ -188,8 +183,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void checkTaskFinish(EventAddVO eventAddVO) { |
|
|
|
|
List<TaskObjectEntity> topList = taskObjectService.list(Wrappers.<TaskObjectEntity>lambdaQuery() |
|
|
|
|
.eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId())); |
|
|
|
|
List<TaskObjectEntity> topList = taskObjectService.list(Wrappers.<TaskObjectEntity>lambdaQuery().eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId())); |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(topList)) { |
|
|
|
|
for (TaskObjectEntity obj : topList) { |
|
|
|
@ -236,26 +230,17 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
} |
|
|
|
|
//检查任务
|
|
|
|
|
checkOpenMutipleTask(AuthUtil.getUserId()); |
|
|
|
|
TaskUserEntity userEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery() |
|
|
|
|
.eq(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) |
|
|
|
|
.eq(TaskUserEntity::getTaskId, task.getId())); |
|
|
|
|
TaskUserEntity userEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).eq(TaskUserEntity::getTaskId, task.getId())); |
|
|
|
|
if (Func.isNotEmpty(userEntity)) { |
|
|
|
|
removeStartTaskId(id); |
|
|
|
|
throw new ServiceException("该任务已被领用,请刷新页面"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//给当前人领取任务
|
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate() |
|
|
|
|
.set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) |
|
|
|
|
.set(TaskUserEntity::getClaimTime, LocalDateTime.now()) |
|
|
|
|
.eq(TaskUserEntity::getTaskId, task.getId()) |
|
|
|
|
.eq(TaskUserEntity::getUserId, AuthUtil.getUserId())); |
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>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.<TaskUserEntity>lambdaQuery() |
|
|
|
|
.eq(TaskUserEntity::getTaskId, task.getId()) |
|
|
|
|
.ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) |
|
|
|
|
.ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); |
|
|
|
|
taskUserService.remove(Wrappers.<TaskUserEntity>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()); |
|
|
|
@ -288,11 +273,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
//检查任务
|
|
|
|
|
checkOpenMutipleTask(userId); |
|
|
|
|
//给当前人领取任务
|
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate() |
|
|
|
|
.set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) |
|
|
|
|
.set(TaskUserEntity::getClaimTime, LocalDateTime.now()) |
|
|
|
|
.eq(TaskUserEntity::getTaskId, task.getId()) |
|
|
|
|
.eq(TaskUserEntity::getUserId, userId)); |
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>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.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getId, userId)); |
|
|
|
@ -314,29 +295,17 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
List<TaskObjectVO> result = Lists.newArrayList(); |
|
|
|
|
for (TaskObjectEntity taskObject : list) { |
|
|
|
|
TaskObjectVO vo = TaskObjectVO.builder().objId(taskObject.getObjectId()).taskId(taskObject.getTaskId()).objName(taskObject.getName()).build(); |
|
|
|
|
List<TaskObjectProjectEntity> taskObjectProjectList = taskObjectProjectService.list(Wrappers.<TaskObjectProjectEntity>lambdaQuery() |
|
|
|
|
.eq(TaskObjectProjectEntity::getTaskId, taskObject.getTaskId()) |
|
|
|
|
.eq(TaskObjectProjectEntity::getObjectId, taskObject.getObjectId())); |
|
|
|
|
List<TaskObjectProjectEntity> taskObjectProjectList = taskObjectProjectService.list(Wrappers.<TaskObjectProjectEntity>lambdaQuery().eq(TaskObjectProjectEntity::getTaskId, taskObject.getTaskId()).eq(TaskObjectProjectEntity::getObjectId, taskObject.getObjectId())); |
|
|
|
|
List<TaskObjectProjectVO> projectVOList = Lists.newArrayList(); |
|
|
|
|
for (TaskObjectProjectEntity taskObjectProject : taskObjectProjectList) { |
|
|
|
|
TaskObjectProjectVO projectVO = TaskObjectProjectVO.builder().projectId(taskObjectProject.getProjectId()).projectName(taskObjectProject.getName()).build(); |
|
|
|
|
List<TaskObjectProjectContentEntity> taskObjectProjectContentList = taskObjectProjectContentService.list(Wrappers.<TaskObjectProjectContentEntity>lambdaQuery() |
|
|
|
|
.eq(TaskObjectProjectContentEntity::getTaskId, taskObjectProject.getTaskId()) |
|
|
|
|
.eq(TaskObjectProjectContentEntity::getObjectId, taskObjectProject.getObjectId()) |
|
|
|
|
.eq(TaskObjectProjectContentEntity::getProjectId, taskObjectProject.getProjectId())); |
|
|
|
|
List<Long> eventIds = eventService.list(Wrappers.<EventEntity>lambdaQuery() |
|
|
|
|
.eq(EventEntity::getTaskId, taskId) |
|
|
|
|
.eq(EventEntity::getObjectId, taskObject.getObjectId()) |
|
|
|
|
.eq(EventEntity::getProjectId, taskObjectProject.getProjectId())).stream().map(entity -> entity.getId()).collect(Collectors.toList()); |
|
|
|
|
List<TaskObjectProjectContentEntity> taskObjectProjectContentList = taskObjectProjectContentService.list(Wrappers.<TaskObjectProjectContentEntity>lambdaQuery().eq(TaskObjectProjectContentEntity::getTaskId, taskObjectProject.getTaskId()).eq(TaskObjectProjectContentEntity::getObjectId, taskObjectProject.getObjectId()).eq(TaskObjectProjectContentEntity::getProjectId, taskObjectProject.getProjectId())); |
|
|
|
|
List<Long> eventIds = eventService.list(Wrappers.<EventEntity>lambdaQuery().eq(EventEntity::getTaskId, taskId).eq(EventEntity::getObjectId, taskObject.getObjectId()).eq(EventEntity::getProjectId, taskObjectProject.getProjectId())).stream().map(entity -> entity.getId()).collect(Collectors.toList()); |
|
|
|
|
List<TaskObjectProjectContentVO> 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.<EventRecordEntity>lambdaQuery() |
|
|
|
|
.in(EventRecordEntity::getEventId, eventIds) |
|
|
|
|
.eq(EventRecordEntity::getObjectId, taskObject.getObjectId()) |
|
|
|
|
.eq(EventRecordEntity::getProjectId, taskObjectProject.getProjectId()) |
|
|
|
|
.eq(EventRecordEntity::getContentId, contentVO.getContentId()).last("LIMIT 1")); |
|
|
|
|
EventRecordEntity ere = eventRecordService.getOne(Wrappers.<EventRecordEntity>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()); |
|
|
|
@ -380,11 +349,9 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
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 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")); |
|
|
|
|
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))); |
|
|
|
@ -494,18 +461,13 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
eventQuery.setTaskId(id); |
|
|
|
|
eventQuery.setObjectId(taskObject.getObjectId()); |
|
|
|
|
eventQuery.setProjectId(taskObjectProject.getProjectId()); |
|
|
|
|
List<Long> eventIds = eventService.getEventList(eventQuery) |
|
|
|
|
.stream().map(entity -> entity.getId()).collect(Collectors.toList()); |
|
|
|
|
List<Long> eventIds = eventService.getEventList(eventQuery).stream().map(entity -> entity.getId()).collect(Collectors.toList()); |
|
|
|
|
List<TaskObjectProjectContentVO> 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.<EventRecordEntity>lambdaQuery() |
|
|
|
|
.in(EventRecordEntity::getEventId, eventIds) |
|
|
|
|
.eq(EventRecordEntity::getObjectId, taskObject.getObjectId()) |
|
|
|
|
.eq(EventRecordEntity::getProjectId, taskObjectProject.getProjectId()) |
|
|
|
|
.eq(EventRecordEntity::getContentId, contentVO.getContentId()).last("LIMIT 1")); |
|
|
|
|
EventRecordEntity ere = eventRecordService.getOne(Wrappers.<EventRecordEntity>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()); |
|
|
|
@ -611,15 +573,9 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
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.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())); |
|
|
|
|
this.update(Wrappers.lambdaUpdate(TaskEntity.class).eq(TaskEntity::getId, taskId).set(TenantEntity::getStatus, TaskStatusEnum.INIT_STATUS.ordinal())); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -663,8 +619,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
} |
|
|
|
|
if (vo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal())) { |
|
|
|
|
//任务执行人
|
|
|
|
|
TaskUserEntity query = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery() |
|
|
|
|
.eq(TaskUserEntity::getTaskId, vo.getId())); |
|
|
|
|
TaskUserEntity query = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, vo.getId())); |
|
|
|
|
if (Func.isNotEmpty(query)) { |
|
|
|
|
vo.setRobot(robotService.getDetailByUserId(query.getUserId())); |
|
|
|
|
} |
|
|
|
@ -774,7 +729,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
/** |
|
|
|
|
* 立即生成任务 发送短信通知提醒 |
|
|
|
|
* @param it |
|
|
|
|
*//*
|
|
|
|
|
*/ /* |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void taskGenerateSMSNoticeNew(TaskEntity it){ |
|
|
|
@ -807,7 +762,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
* TODO 巡检通知 |
|
|
|
|
* 向通知表添加任务结束记录 |
|
|
|
|
* @param taskSMS |
|
|
|
|
*//*
|
|
|
|
|
*/ /* |
|
|
|
|
|
|
|
|
|
private void addNotice (InspectionTaskSMS taskSMS,String type){ |
|
|
|
|
Notify notify = new Notify(); |
|
|
|
@ -838,7 +793,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* 另开线程发送短信 |
|
|
|
|
*//*
|
|
|
|
|
*/ /* |
|
|
|
|
|
|
|
|
|
private void otherThreadSendSMS(InspectionTaskSMS taskSMS,String templateCode){ |
|
|
|
|
HzimsThreadPool.getFixedThreadExecutor().execute(new Runnable() { |
|
|
|
@ -854,7 +809,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
/** |
|
|
|
|
* TODO |
|
|
|
|
* 发送短信 |
|
|
|
|
*//*
|
|
|
|
|
*/ /* |
|
|
|
|
|
|
|
|
|
private int sendSMS(InspectionTaskSMS taskSMS,String templateCode){ |
|
|
|
|
int re = 0; |
|
|
|
@ -918,46 +873,35 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
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)){ |
|
|
|
|
if (CollectionUtil.isEmpty(taskIds)) { |
|
|
|
|
// 查询当天可操作任务
|
|
|
|
|
List<TaskEntity> sameDayTasks = this.getSameDayTask(null,TaskStatusEnum.UNDERWAY_STATUS.getStatus(),startDate,endDate); |
|
|
|
|
if(CollectionUtil.isNotEmpty(sameDayTasks)){ |
|
|
|
|
List<TaskEntity> sameDayTasks = this.getSameDayTask(null, TaskStatusEnum.UNDERWAY_STATUS.getStatus(), startDate, endDate); |
|
|
|
|
if (CollectionUtil.isNotEmpty(sameDayTasks)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
throw new ServiceException("当前没有可领用的巡检任务!"); |
|
|
|
|
} |
|
|
|
|
// 查询可领用任务
|
|
|
|
|
List<TaskEntity> tasks = this.getSameDayTask(taskIds,TaskStatusEnum.INIT_STATUS.getStatus(),startDate,endDate); |
|
|
|
|
if(CollectionUtil.isEmpty(tasks)){ |
|
|
|
|
List<TaskEntity> tasks = this.getSameDayTask(taskIds, TaskStatusEnum.INIT_STATUS.getStatus(), startDate, endDate); |
|
|
|
|
if (CollectionUtil.isEmpty(tasks)) { |
|
|
|
|
throw new ServiceException("选择巡检任务已被领用完成!"); |
|
|
|
|
} |
|
|
|
|
if(taskIds.size() != taskIds.size()){ |
|
|
|
|
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() +"]有人在领用,请稍后重试!"); |
|
|
|
|
throw new ServiceException("任务" + task.getPlanName() + "[" + task.getPlanId() + "]有人在领用,请稍后重试!"); |
|
|
|
|
} |
|
|
|
|
// 任务归属人设置
|
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate() |
|
|
|
|
.set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) |
|
|
|
|
.set(TaskUserEntity::getClaimTime, LocalDateTime.now()) |
|
|
|
|
.eq(TaskUserEntity::getTaskId, task.getId()) |
|
|
|
|
.eq(TaskUserEntity::getUserId, AuthUtil.getUserId())); |
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>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.<TaskUserEntity>lambdaQuery() |
|
|
|
|
.eq(TaskUserEntity::getTaskId, task.getId()) |
|
|
|
|
.ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) |
|
|
|
|
.ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); |
|
|
|
|
} |
|
|
|
|
boolean flag = this.update(Wrappers.<TaskEntity>lambdaUpdate() |
|
|
|
|
.set(TaskEntity::getStatus, TaskStatusEnum.UNDERWAY_STATUS.getStatus()) |
|
|
|
|
.set(TaskEntity::getStartTime, LocalDateTime.now()) |
|
|
|
|
.eq(TaskEntity::getId, task.getId()) |
|
|
|
|
); |
|
|
|
|
if(!flag){ |
|
|
|
|
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); |
|
|
|
|
} |
|
|
|
|
boolean flag = this.update(Wrappers.<TaskEntity>lambdaUpdate().set(TaskEntity::getStatus, TaskStatusEnum.UNDERWAY_STATUS.getStatus()).set(TaskEntity::getStartTime, LocalDateTime.now()).eq(TaskEntity::getId, task.getId())); |
|
|
|
|
if (!flag) { |
|
|
|
|
throw new ServiceException("任务领取异常,请稍后重试!"); |
|
|
|
|
} |
|
|
|
|
// 任务开始列表中移除已进行领用任务
|
|
|
|
@ -967,8 +911,72 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<TaskEntity> getSameDayTask(List<Long> taskIds, String status, String startDate, String endDate) { |
|
|
|
|
return this.baseMapper.getSameDayTask(taskIds,status,startDate,endDate); |
|
|
|
|
return this.baseMapper.getSameDayTask(taskIds, status, startDate, endDate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 巡检任务分页 |
|
|
|
|
* |
|
|
|
|
* @param pageInfo |
|
|
|
|
* @param task |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public BladePage<TaskVo> selectPage(Page<TaskEntity> pageInfo, TaskListQuery task) { |
|
|
|
|
QueryWrapper<TaskEntity> 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<TaskEntity> taskEntityPage = baseMapper.selectPage(pageInfo, queryWrapper); |
|
|
|
|
|
|
|
|
|
List<TaskEntity> records = taskEntityPage.getRecords(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(records)) { |
|
|
|
|
List<TaskVo> collect = records.stream().map(item -> { |
|
|
|
|
TaskVo taskVo = new TaskVo(); |
|
|
|
|
BeanUtils.copyProperties(item, taskVo); |
|
|
|
|
return taskVo; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
Page<TaskVo> taskVoList = new Page<>(); |
|
|
|
|
taskVoList.setRecords(collect); |
|
|
|
|
taskVoList.setPages(taskEntityPage.getPages()); |
|
|
|
|
taskVoList.setSize(taskEntityPage.getSize()); |
|
|
|
|
taskVoList.setTotal(taskEntityPage.getTotal()); |
|
|
|
|
taskVoList.setCurrent(taskEntityPage.getCurrent()); |
|
|
|
|
BladePage<TaskVo> bladePage = BladePage.of(taskVoList); |
|
|
|
|
return bladePage; |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|