Browse Source

fix:巡检报备无法执行任务bug修复

zhongwei
haungxing 4 months ago
parent
commit
64628cfa4a
  1. 33
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java

33
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java

@ -1,6 +1,7 @@
package com.hnac.hzinfo.inspect.task.service.impl; package com.hnac.hzinfo.inspect.task.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.operational.defect.constants.DefectConstant; import com.hnac.hzims.operational.defect.constants.DefectConstant;
@ -92,13 +93,16 @@ public class EventServiceImpl extends ServiceImpl<TaskEventMapper, EventEntity>
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean addTaskEvent(EventAddVO eventVO){ public boolean addTaskEvent(EventAddVO eventVO){
BladeUser user = AuthUtil.getUser();
//第一次登记时,需领用任务 //第一次登记时,需领用任务
if(!AuthUtil.isAdministrator()){ if(!AuthUtil.isAdministrator()){
// 判断当前登录人是否在任务人员列表中
ITaskService taskService = SpringUtil.getBean(ITaskService.class); ITaskService taskService = SpringUtil.getBean(ITaskService.class);
TaskEntity taskEntity = taskService.getById(eventVO.getTaskId()); TaskEntity taskEntity = taskService.getById(eventVO.getTaskId());
TaskUserEntity taskUserEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).eq(TaskUserEntity::getUserId,user == null ? eventVO.getUserId() : user.getUserId())); BladeUser user = AuthUtil.getUser();
LambdaQueryWrapper<TaskUserEntity> wrapper = Wrappers.<TaskUserEntity>lambdaQuery()
.eq(TaskUserEntity::getTaskId, eventVO.getTaskId())
.eq(TaskUserEntity::getUserId, user == null ? eventVO.getUserId() : user.getUserId());
TaskUserEntity taskUserEntity = taskUserService.getOne(wrapper);
if(taskUserEntity == null){ if(taskUserEntity == null){
throw new ServiceException("该任务已被别人领取"); throw new ServiceException("该任务已被别人领取");
} }
@ -106,17 +110,18 @@ public class EventServiceImpl extends ServiceImpl<TaskEventMapper, EventEntity>
taskUserEntity.setClaimStatus(TaskContants.ClaimStatusEnum.COLLECT.getStatus()); taskUserEntity.setClaimStatus(TaskContants.ClaimStatusEnum.COLLECT.getStatus());
taskUserEntity.setClaimTime(LocalDateTime.now()); taskUserEntity.setClaimTime(LocalDateTime.now());
taskUserService.updateById(taskUserEntity); taskUserService.updateById(taskUserEntity);
if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(taskEntity.getMethod())){//如果是抢占任务,删除能够抢占此任务的其他人 if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(taskEntity.getMethod())){
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).ne(TaskUserEntity::getId,taskUserEntity.getUserId())); //如果是抢占任务,删除能够抢占此任务的其他人
LambdaQueryWrapper<TaskUserEntity> removeUser = Wrappers.<TaskUserEntity>lambdaQuery()
.eq(TaskUserEntity::getTaskId, eventVO.getTaskId())
.ne(TaskUserEntity::getUserId, taskUserEntity.getUserId());
taskUserService.remove(removeUser);
} }
} }
} }
EventEntity event = BeanUtil.copy(eventVO, EventEntity.class); EventEntity event = BeanUtil.copy(eventVO, EventEntity.class);
event.setUserId(eventVO.getUserId()); event.setUserId(eventVO.getUserId());
// if(Func.isEmpty(user)){
// event.setTenantId("000000");
// }
event.setObjectId(eventVO.getObjId()); event.setObjectId(eventVO.getObjId());
event.setCode(CodeUtils.randomCode()); event.setCode(CodeUtils.randomCode());
boolean success = this.save(event); boolean success = this.save(event);
@ -160,18 +165,6 @@ public class EventServiceImpl extends ServiceImpl<TaskEventMapper, EventEntity>
if(success && fileList.size()>0){ if(success && fileList.size()>0){
success = eventAttachmentService.saveBatch(fileList); success = eventAttachmentService.saveBatch(fileList);
} }
//如果是问题则启动工作流引擎
if(TaskContants.ProblemEnum.yes.getType().equals(eventVO.getIsProblem())){
//TODO 并入缺陷处理模块
// startFlow(user,taskObj,event);
/* OperPhenomenonEntity phenomenon = new OperPhenomenonEntity();
phenomenon.setSourceCode(DefectConstant.DefectSourceEnum.XJ.getStatus());
phenomenon.setSourceId(event.getId());
phenomenon.setFinder(user == null ? eventVO.getUserId() : user.getUserId());
phenomenon.setDescripiton(eventVO.getDescription());
phenomenon.setInitResult(eventVO.getInitResult());
startPhenomenonFlow(phenomenon);*/
}
checkProjectFinish(eventVO); checkProjectFinish(eventVO);
return success; return success;
} }

Loading…
Cancel
Save