diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskRecordServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskRecordServiceImpl.java index fe03308..25905e2 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskRecordServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskRecordServiceImpl.java @@ -1,7 +1,10 @@ package com.hnac.hzinfo.inspect.task.service.impl; +import cn.hutool.core.lang.Assert; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; import com.hnac.hzinfo.inspect.task.TaskContants; import com.hnac.hzinfo.inspect.task.TaskContants.ClaimStatusEnum; import com.hnac.hzinfo.inspect.task.TaskContants.TaskRecordTypeEnum; @@ -19,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; /** * 巡检报备服务实现类 @@ -36,36 +41,21 @@ public class TaskRecordServiceImpl extends ServiceImplquery().lambda().eq(TaskUserEntity::getTaskId, itr.getTaskId()).eq(TaskUserEntity::getClaimStatus,ClaimStatusEnum.UN_COLLECT.getStatus())); - //领取任务 + // 领取任务 TaskUserEntity itu = TaskUserEntity.builder().taskId(itr.getTaskId()).userId(itr.getExecutor()).claimStatus(ClaimStatusEnum.COLLECT.getStatus()).claimTime(LocalDateTime.now()).build(); taskUserService.save(itu); - }else{//任务报备(谁第一个登录任务谁就领取任务) -// //领取任务(抢占任务取第一个人员领取该任务,并发任务,一个任务对应的一个人也是取第一个人) -// TaskUserEntity itu = taskUserService.getOne(Wrappers.query().lambda().eq(TaskUserEntity::getTaskId, itr.getTaskId()).eq(TaskUserEntity::getClaimStatus,ClaimStatusEnum.UN_COLLECT.getStatus()).last("limit 1")); -// if(itu!=null){ -// itu.setClaimStatus(ClaimStatusEnum.COLLECT.getStatus()); -// itu.setClaimTime(LocalDateTime.now()); -// taskUserService.updateById(itu); -// //如果是抢占任务,删除能够抢占此任务的其他人 -// if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { -// taskUserService.remove(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId,task.getId()).ne(TaskUserEntity::getId,itu.getUserId())); -// } -// } } - //报备后任务默认为进行中 - UpdateWrapper uwTask = new UpdateWrapper<>(); - uwTask.lambda() + // 报备后任务默认为进行中 + LambdaUpdateWrapper uwTask = Wrappers.lambdaUpdate() .set(TaskEntity::getKeepOnRecord, keepOnRecordEnum.yes.getType()) - .set(TaskEntity::getStartTime,LocalDateTime.now()) + .set(TaskEntity::getStartTime, LocalDateTime.now()) .set(TaskEntity::getStatus, TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus()) .eq(TaskEntity::getId, itr.getTaskId()); taskService.update(uwTask);