|
|
@ -1,8 +1,12 @@ |
|
|
|
package com.hnac.hzinfo.inspect.task.service.impl; |
|
|
|
package com.hnac.hzinfo.inspect.task.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
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.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.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzims.safeproduct.Constants; |
|
|
|
import com.hnac.hzims.safeproduct.Constants; |
|
|
|
import com.hnac.hzims.safeproduct.entity.ImsMonCameraInfoEntity; |
|
|
|
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 com.hnac.hzinfo.inspect.utils.HiKUtil; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
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.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tenant.mp.TenantEntity; |
|
|
|
import org.springblade.core.tenant.mp.TenantEntity; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
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.feign.ISysClient; |
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -130,10 +137,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void checkProjectFinish(EventAddVO eventAddVO) { |
|
|
|
public void checkProjectFinish(EventAddVO eventAddVO) { |
|
|
|
List<TaskObjectProjectContentEntity> topcList = taskObjectProjectContentService.list(Wrappers.<TaskObjectProjectContentEntity>lambdaQuery() |
|
|
|
List<TaskObjectProjectContentEntity> topcList = taskObjectProjectContentService.list(Wrappers.<TaskObjectProjectContentEntity>lambdaQuery().eq(TaskObjectProjectContentEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectProjectContentEntity::getObjectId, eventAddVO.getObjId()).eq(TaskObjectProjectContentEntity::getProjectId, eventAddVO.getProjectId())); |
|
|
|
.eq(TaskObjectProjectContentEntity::getTaskId, eventAddVO.getTaskId()) |
|
|
|
|
|
|
|
.eq(TaskObjectProjectContentEntity::getObjectId, eventAddVO.getObjId()) |
|
|
|
|
|
|
|
.eq(TaskObjectProjectContentEntity::getProjectId, eventAddVO.getProjectId())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(topcList)) { |
|
|
|
if (Func.isNotEmpty(topcList)) { |
|
|
|
for (TaskObjectProjectContentEntity content : topcList) { |
|
|
|
for (TaskObjectProjectContentEntity content : topcList) { |
|
|
@ -144,11 +148,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 任务项目状态设置为已完成*/ |
|
|
|
/** 任务项目状态设置为已完成*/ |
|
|
|
taskObjectProjectService.update(Wrappers.<TaskObjectProjectEntity>lambdaUpdate() |
|
|
|
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())); |
|
|
|
.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); |
|
|
|
checkObjFinish(eventAddVO); |
|
|
|
} |
|
|
|
} |
|
|
@ -159,9 +159,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
* @param eventAddVO |
|
|
|
* @param eventAddVO |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void checkObjFinish(EventAddVO eventAddVO) { |
|
|
|
private void checkObjFinish(EventAddVO eventAddVO) { |
|
|
|
List<TaskObjectProjectEntity> topList = taskObjectProjectService.list(Wrappers.<TaskObjectProjectEntity>lambdaQuery() |
|
|
|
List<TaskObjectProjectEntity> topList = taskObjectProjectService.list(Wrappers.<TaskObjectProjectEntity>lambdaQuery().eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId())); |
|
|
|
.eq(TaskObjectProjectEntity::getTaskId, eventAddVO.getTaskId()) |
|
|
|
|
|
|
|
.eq(TaskObjectProjectEntity::getObjectId, eventAddVO.getObjId())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(topList)) { |
|
|
|
if (Func.isNotEmpty(topList)) { |
|
|
@ -173,10 +171,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 任务项目状态设置为已完成*/ |
|
|
|
/** 任务项目状态设置为已完成*/ |
|
|
|
taskObjectService.update(Wrappers.<TaskObjectEntity>lambdaUpdate() |
|
|
|
taskObjectService.update(Wrappers.<TaskObjectEntity>lambdaUpdate().set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()).eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId()).eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId())); |
|
|
|
.set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()) |
|
|
|
|
|
|
|
.eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId()) |
|
|
|
|
|
|
|
.eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkTaskFinish(eventAddVO); |
|
|
|
checkTaskFinish(eventAddVO); |
|
|
|
} |
|
|
|
} |
|
|
@ -188,8 +183,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void checkTaskFinish(EventAddVO eventAddVO) { |
|
|
|
public void checkTaskFinish(EventAddVO eventAddVO) { |
|
|
|
List<TaskObjectEntity> topList = taskObjectService.list(Wrappers.<TaskObjectEntity>lambdaQuery() |
|
|
|
List<TaskObjectEntity> topList = taskObjectService.list(Wrappers.<TaskObjectEntity>lambdaQuery().eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId())); |
|
|
|
.eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(topList)) { |
|
|
|
if (Func.isNotEmpty(topList)) { |
|
|
|
for (TaskObjectEntity obj : topList) { |
|
|
|
for (TaskObjectEntity obj : topList) { |
|
|
@ -236,26 +230,17 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
} |
|
|
|
} |
|
|
|
//检查任务
|
|
|
|
//检查任务
|
|
|
|
checkOpenMutipleTask(AuthUtil.getUserId()); |
|
|
|
checkOpenMutipleTask(AuthUtil.getUserId()); |
|
|
|
TaskUserEntity userEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery() |
|
|
|
TaskUserEntity userEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).eq(TaskUserEntity::getTaskId, task.getId())); |
|
|
|
.eq(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) |
|
|
|
|
|
|
|
.eq(TaskUserEntity::getTaskId, task.getId())); |
|
|
|
|
|
|
|
if (Func.isNotEmpty(userEntity)) { |
|
|
|
if (Func.isNotEmpty(userEntity)) { |
|
|
|
removeStartTaskId(id); |
|
|
|
removeStartTaskId(id); |
|
|
|
throw new ServiceException("该任务已被领用,请刷新页面"); |
|
|
|
throw new ServiceException("该任务已被领用,请刷新页面"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//给当前人领取任务
|
|
|
|
//给当前人领取任务
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate() |
|
|
|
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())); |
|
|
|
.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())) { |
|
|
|
if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { |
|
|
|
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery() |
|
|
|
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); |
|
|
|
.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.setStatus(Integer.valueOf(TaskStatusEnum.UNDERWAY_STATUS.getStatus())); |
|
|
|
task.setStartTime(LocalDateTime.now()); |
|
|
|
task.setStartTime(LocalDateTime.now()); |
|
|
@ -288,11 +273,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
//检查任务
|
|
|
|
//检查任务
|
|
|
|
checkOpenMutipleTask(userId); |
|
|
|
checkOpenMutipleTask(userId); |
|
|
|
//给当前人领取任务
|
|
|
|
//给当前人领取任务
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate() |
|
|
|
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)); |
|
|
|
.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())) { |
|
|
|
if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { |
|
|
|
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getId, userId)); |
|
|
|
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(); |
|
|
|
List<TaskObjectVO> result = Lists.newArrayList(); |
|
|
|
for (TaskObjectEntity taskObject : list) { |
|
|
|
for (TaskObjectEntity taskObject : list) { |
|
|
|
TaskObjectVO vo = TaskObjectVO.builder().objId(taskObject.getObjectId()).taskId(taskObject.getTaskId()).objName(taskObject.getName()).build(); |
|
|
|
TaskObjectVO vo = TaskObjectVO.builder().objId(taskObject.getObjectId()).taskId(taskObject.getTaskId()).objName(taskObject.getName()).build(); |
|
|
|
List<TaskObjectProjectEntity> taskObjectProjectList = taskObjectProjectService.list(Wrappers.<TaskObjectProjectEntity>lambdaQuery() |
|
|
|
List<TaskObjectProjectEntity> taskObjectProjectList = taskObjectProjectService.list(Wrappers.<TaskObjectProjectEntity>lambdaQuery().eq(TaskObjectProjectEntity::getTaskId, taskObject.getTaskId()).eq(TaskObjectProjectEntity::getObjectId, taskObject.getObjectId())); |
|
|
|
.eq(TaskObjectProjectEntity::getTaskId, taskObject.getTaskId()) |
|
|
|
|
|
|
|
.eq(TaskObjectProjectEntity::getObjectId, taskObject.getObjectId())); |
|
|
|
|
|
|
|
List<TaskObjectProjectVO> projectVOList = Lists.newArrayList(); |
|
|
|
List<TaskObjectProjectVO> projectVOList = Lists.newArrayList(); |
|
|
|
for (TaskObjectProjectEntity taskObjectProject : taskObjectProjectList) { |
|
|
|
for (TaskObjectProjectEntity taskObjectProject : taskObjectProjectList) { |
|
|
|
TaskObjectProjectVO projectVO = TaskObjectProjectVO.builder().projectId(taskObjectProject.getProjectId()).projectName(taskObjectProject.getName()).build(); |
|
|
|
TaskObjectProjectVO projectVO = TaskObjectProjectVO.builder().projectId(taskObjectProject.getProjectId()).projectName(taskObjectProject.getName()).build(); |
|
|
|
List<TaskObjectProjectContentEntity> taskObjectProjectContentList = taskObjectProjectContentService.list(Wrappers.<TaskObjectProjectContentEntity>lambdaQuery() |
|
|
|
List<TaskObjectProjectContentEntity> taskObjectProjectContentList = taskObjectProjectContentService.list(Wrappers.<TaskObjectProjectContentEntity>lambdaQuery().eq(TaskObjectProjectContentEntity::getTaskId, taskObjectProject.getTaskId()).eq(TaskObjectProjectContentEntity::getObjectId, taskObjectProject.getObjectId()).eq(TaskObjectProjectContentEntity::getProjectId, taskObjectProject.getProjectId())); |
|
|
|
.eq(TaskObjectProjectContentEntity::getTaskId, taskObjectProject.getTaskId()) |
|
|
|
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()); |
|
|
|
.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(); |
|
|
|
List<TaskObjectProjectContentVO> contentVOList = Lists.newArrayList(); |
|
|
|
for (TaskObjectProjectContentEntity entity : taskObjectProjectContentList) { |
|
|
|
for (TaskObjectProjectContentEntity entity : taskObjectProjectContentList) { |
|
|
|
TaskObjectProjectContentVO contentVO = BeanUtil.copy(entity, TaskObjectProjectContentVO.class); |
|
|
|
TaskObjectProjectContentVO contentVO = BeanUtil.copy(entity, TaskObjectProjectContentVO.class); |
|
|
|
if ("0".equals(contentVO.getAvailable()) && eventIds.size() > 0) {//不可重复记录时,需要显示之前记录的值
|
|
|
|
if ("0".equals(contentVO.getAvailable()) && eventIds.size() > 0) {//不可重复记录时,需要显示之前记录的值
|
|
|
|
EventRecordEntity ere = eventRecordService.getOne(Wrappers.<EventRecordEntity>lambdaQuery() |
|
|
|
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")); |
|
|
|
.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.setCurrentStatus(ere.getCurrentStatus()); |
|
|
|
contentVO.setCurrentValue(ere.getCurrentValue()); |
|
|
|
contentVO.setCurrentValue(ere.getCurrentValue()); |
|
|
|
contentVO.setFileUrl(ere.getFileUrl()); |
|
|
|
contentVO.setFileUrl(ere.getFileUrl()); |
|
|
@ -380,11 +349,9 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
taskReportVO.setUserId(userId); |
|
|
|
taskReportVO.setUserId(userId); |
|
|
|
taskReportVO.setHours(list.stream().mapToLong(TaskCountVO::getHours).sum()); |
|
|
|
taskReportVO.setHours(list.stream().mapToLong(TaskCountVO::getHours).sum()); |
|
|
|
//巡检任务完成情况
|
|
|
|
//巡检任务完成情况
|
|
|
|
String finishSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))) |
|
|
|
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")); |
|
|
|
.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()))) |
|
|
|
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")); |
|
|
|
.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.setCompleteNum(list.stream().filter(taskCountVO -> Func.isNotEmpty(taskCountVO.getFinishTask())).collect(Collectors.summingInt(TaskCountVO::getFinishTask))); |
|
|
|
taskReportVO.setCompleteSituation(finishSituation); |
|
|
|
taskReportVO.setCompleteSituation(finishSituation); |
|
|
|
taskReportVO.setIncompleteNum(list.stream().filter(taskCountVO -> Func.isNotEmpty(taskCountVO.getUndoneTask())).collect(Collectors.summingInt(TaskCountVO::getUndoneTask))); |
|
|
|
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.setTaskId(id); |
|
|
|
eventQuery.setObjectId(taskObject.getObjectId()); |
|
|
|
eventQuery.setObjectId(taskObject.getObjectId()); |
|
|
|
eventQuery.setProjectId(taskObjectProject.getProjectId()); |
|
|
|
eventQuery.setProjectId(taskObjectProject.getProjectId()); |
|
|
|
List<Long> eventIds = eventService.getEventList(eventQuery) |
|
|
|
List<Long> eventIds = eventService.getEventList(eventQuery).stream().map(entity -> entity.getId()).collect(Collectors.toList()); |
|
|
|
.stream().map(entity -> entity.getId()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<TaskObjectProjectContentVO> contentVOList = Lists.newArrayList(); |
|
|
|
List<TaskObjectProjectContentVO> contentVOList = Lists.newArrayList(); |
|
|
|
|
|
|
|
|
|
|
|
for (TaskObjectProjectContentEntity entity : taskObjectProjectContentList) { |
|
|
|
for (TaskObjectProjectContentEntity entity : taskObjectProjectContentList) { |
|
|
|
TaskObjectProjectContentVO contentVO = BeanUtil.copy(entity, TaskObjectProjectContentVO.class); |
|
|
|
TaskObjectProjectContentVO contentVO = BeanUtil.copy(entity, TaskObjectProjectContentVO.class); |
|
|
|
if ("0".equals(contentVO.getAvailable()) && eventIds.size() > 0) {//不可重复记录时,需要显示之前记录的值
|
|
|
|
if ("0".equals(contentVO.getAvailable()) && eventIds.size() > 0) {//不可重复记录时,需要显示之前记录的值
|
|
|
|
EventRecordEntity ere = eventRecordService.getOne(Wrappers.<EventRecordEntity>lambdaQuery() |
|
|
|
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")); |
|
|
|
.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.setCurrentStatus(ere.getCurrentStatus()); |
|
|
|
contentVO.setCurrentValue(ere.getCurrentValue()); |
|
|
|
contentVO.setCurrentValue(ere.getCurrentValue()); |
|
|
|
contentVO.setFileUrl(ere.getFileUrl()); |
|
|
|
contentVO.setFileUrl(ere.getFileUrl()); |
|
|
@ -611,15 +573,9 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
if (entity != null) { |
|
|
|
if (entity != null) { |
|
|
|
throw new ServiceException("该任务已有历史记录,不能撤销领用"); |
|
|
|
throw new ServiceException("该任务已有历史记录,不能撤销领用"); |
|
|
|
} |
|
|
|
} |
|
|
|
taskUserService.update(Wrappers.lambdaUpdate(TaskUserEntity.class) |
|
|
|
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)); |
|
|
|
.eq(TaskUserEntity::getUserId, AuthUtil.getUserId()) |
|
|
|
|
|
|
|
.eq(TaskUserEntity::getTaskId, taskId) |
|
|
|
|
|
|
|
.set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.UN_COLLECT.getStatus()) |
|
|
|
|
|
|
|
.set(TaskUserEntity::getClaimTime, null)); |
|
|
|
|
|
|
|
taskUserService.updateDeleteStatus(taskId); |
|
|
|
taskUserService.updateDeleteStatus(taskId); |
|
|
|
this.update(Wrappers.lambdaUpdate(TaskEntity.class) |
|
|
|
this.update(Wrappers.lambdaUpdate(TaskEntity.class).eq(TaskEntity::getId, taskId).set(TenantEntity::getStatus, TaskStatusEnum.INIT_STATUS.ordinal())); |
|
|
|
.eq(TaskEntity::getId, taskId) |
|
|
|
|
|
|
|
.set(TenantEntity::getStatus, TaskStatusEnum.INIT_STATUS.ordinal())); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -663,8 +619,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
} |
|
|
|
} |
|
|
|
if (vo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal())) { |
|
|
|
if (vo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal())) { |
|
|
|
//任务执行人
|
|
|
|
//任务执行人
|
|
|
|
TaskUserEntity query = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery() |
|
|
|
TaskUserEntity query = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, vo.getId())); |
|
|
|
.eq(TaskUserEntity::getTaskId, vo.getId())); |
|
|
|
|
|
|
|
if (Func.isNotEmpty(query)) { |
|
|
|
if (Func.isNotEmpty(query)) { |
|
|
|
vo.setRobot(robotService.getDetailByUserId(query.getUserId())); |
|
|
|
vo.setRobot(robotService.getDetailByUserId(query.getUserId())); |
|
|
|
} |
|
|
|
} |
|
|
@ -939,24 +894,13 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
throw new ServiceException("任务" + task.getPlanName() + "[" + task.getPlanId() + "]有人在领用,请稍后重试!"); |
|
|
|
throw new ServiceException("任务" + task.getPlanName() + "[" + task.getPlanId() + "]有人在领用,请稍后重试!"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 任务归属人设置
|
|
|
|
// 任务归属人设置
|
|
|
|
taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate() |
|
|
|
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())); |
|
|
|
.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())) { |
|
|
|
if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { |
|
|
|
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery() |
|
|
|
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); |
|
|
|
.eq(TaskUserEntity::getTaskId, task.getId()) |
|
|
|
} |
|
|
|
.ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()) |
|
|
|
boolean flag = this.update(Wrappers.<TaskEntity>lambdaUpdate().set(TaskEntity::getStatus, TaskStatusEnum.UNDERWAY_STATUS.getStatus()).set(TaskEntity::getStartTime, LocalDateTime.now()).eq(TaskEntity::getId, task.getId())); |
|
|
|
.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) { |
|
|
|
if (!flag) { |
|
|
|
throw new ServiceException("任务领取异常,请稍后重试!"); |
|
|
|
throw new ServiceException("任务领取异常,请稍后重试!"); |
|
|
|
} |
|
|
|
} |
|
|
@ -971,4 +915,68 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 巡检任务分页 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @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; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|