Browse Source

fix:巡检报备限制状态判断

(cherry picked from commit 9bf35972120fffaad41ad4719ea21ecb6034a51b)
zhongwei
haungxing 4 months ago
parent
commit
4bc1403afa
  1. 36
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskRecordServiceImpl.java

36
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; 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.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; 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;
import com.hnac.hzinfo.inspect.task.TaskContants.ClaimStatusEnum; import com.hnac.hzinfo.inspect.task.TaskContants.ClaimStatusEnum;
import com.hnac.hzinfo.inspect.task.TaskContants.TaskRecordTypeEnum; 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 org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/** /**
* 巡检报备服务实现类 * 巡检报备服务实现类
@ -36,36 +41,21 @@ public class TaskRecordServiceImpl extends ServiceImpl<TaskRecordMapper, TaskRec
@Override @Override
public Boolean addTaskRecord(TaskRecordEntity itr) { public Boolean addTaskRecord(TaskRecordEntity itr) {
TaskEntity task = taskService.getById(itr.getTaskId()); TaskEntity task = taskService.getById(itr.getTaskId());
if(TaskContants.TaskStatusEnum.UNFINISH_STATUS.getStatus().equals(task.getStatus())){ // 只有未开始的任务可进行报备操作
throw new ServiceException("未完成的任务不能报备"); if(!TaskContants.TaskStatusEnum.INIT_STATUS.getStatus().equals(String.valueOf(task.getStatus()))) {
} throw new ServiceException("只有未开始的任务可进行报备操作");
if(TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus().equals(task.getStatus())){
throw new ServiceException("已完成的任务不能报备");
} }
if(TaskRecordTypeEnum.people.getType().equals(itr.getType())) { if(TaskRecordTypeEnum.people.getType().equals(itr.getType())) {
//人员报备(删除此任务以前的所属人,然后将任务指派给新的人) // 人员报备(删除此任务以前的所属人,然后将任务指派给新的人)
taskUserService.remove(Wrappers.<TaskUserEntity>query().lambda().eq(TaskUserEntity::getTaskId, itr.getTaskId()).eq(TaskUserEntity::getClaimStatus,ClaimStatusEnum.UN_COLLECT.getStatus())); taskUserService.remove(Wrappers.<TaskUserEntity>query().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(); TaskUserEntity itu = TaskUserEntity.builder().taskId(itr.getTaskId()).userId(itr.getExecutor()).claimStatus(ClaimStatusEnum.COLLECT.getStatus()).claimTime(LocalDateTime.now()).build();
taskUserService.save(itu); taskUserService.save(itu);
}else{//任务报备(谁第一个登录任务谁就领取任务)
// //领取任务(抢占任务取第一个人员领取该任务,并发任务,一个任务对应的一个人也是取第一个人)
// TaskUserEntity itu = taskUserService.getOne(Wrappers.<TaskUserEntity>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.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId,task.getId()).ne(TaskUserEntity::getId,itu.getUserId()));
// }
// }
} }
//报备后任务默认为进行中 // 报备后任务默认为进行中
UpdateWrapper<TaskEntity> uwTask = new UpdateWrapper<>(); LambdaUpdateWrapper<TaskEntity> uwTask = Wrappers.<TaskEntity>lambdaUpdate()
uwTask.lambda()
.set(TaskEntity::getKeepOnRecord, keepOnRecordEnum.yes.getType()) .set(TaskEntity::getKeepOnRecord, keepOnRecordEnum.yes.getType())
.set(TaskEntity::getStartTime,LocalDateTime.now()) .set(TaskEntity::getStartTime, LocalDateTime.now())
.set(TaskEntity::getStatus, TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus()) .set(TaskEntity::getStatus, TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus())
.eq(TaskEntity::getId, itr.getTaskId()); .eq(TaskEntity::getId, itr.getTaskId());
taskService.update(uwTask); taskService.update(uwTask);

Loading…
Cancel
Save