From 64628cfa4af4e2c4565f375d9c63d8de8eae3d56 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 31 Jul 2024 08:47:31 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=B7=A1=E6=A3=80=E6=8A=A5?= =?UTF-8?q?=E5=A4=87=E6=97=A0=E6=B3=95=E6=89=A7=E8=A1=8C=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/service/impl/EventServiceImpl.java | 35 +++++++++------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java index a0a406c..495e95e 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java +++ b/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; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.hnac.hzims.operational.defect.constants.DefectConstant; @@ -92,31 +93,35 @@ public class EventServiceImpl extends ServiceImpl @Override @Transactional(rollbackFor = Exception.class) public boolean addTaskEvent(EventAddVO eventVO){ - BladeUser user = AuthUtil.getUser(); - //第一次登记时,需领用任务 if(!AuthUtil.isAdministrator()){ + // 判断当前登录人是否在任务人员列表中 ITaskService taskService = SpringUtil.getBean(ITaskService.class); TaskEntity taskEntity = taskService.getById(eventVO.getTaskId()); - TaskUserEntity taskUserEntity = taskUserService.getOne(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).eq(TaskUserEntity::getUserId,user == null ? eventVO.getUserId() : user.getUserId())); - if(taskUserEntity==null){ + BladeUser user = AuthUtil.getUser(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .eq(TaskUserEntity::getTaskId, eventVO.getTaskId()) + .eq(TaskUserEntity::getUserId, user == null ? eventVO.getUserId() : user.getUserId()); + TaskUserEntity taskUserEntity = taskUserService.getOne(wrapper); + if(taskUserEntity == null){ throw new ServiceException("该任务已被别人领取"); } if(TaskContants.ClaimStatusEnum.UN_COLLECT.getStatus().equals(taskUserEntity.getClaimStatus())){ taskUserEntity.setClaimStatus(TaskContants.ClaimStatusEnum.COLLECT.getStatus()); taskUserEntity.setClaimTime(LocalDateTime.now()); taskUserService.updateById(taskUserEntity); - if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(taskEntity.getMethod())){//如果是抢占任务,删除能够抢占此任务的其他人 - taskUserService.remove(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).ne(TaskUserEntity::getId,taskUserEntity.getUserId())); + if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(taskEntity.getMethod())){ + //如果是抢占任务,删除能够抢占此任务的其他人 + LambdaQueryWrapper removeUser = Wrappers.lambdaQuery() + .eq(TaskUserEntity::getTaskId, eventVO.getTaskId()) + .ne(TaskUserEntity::getUserId, taskUserEntity.getUserId()); + taskUserService.remove(removeUser); } } } EventEntity event = BeanUtil.copy(eventVO, EventEntity.class); event.setUserId(eventVO.getUserId()); -// if(Func.isEmpty(user)){ -// event.setTenantId("000000"); -// } event.setObjectId(eventVO.getObjId()); event.setCode(CodeUtils.randomCode()); boolean success = this.save(event); @@ -160,18 +165,6 @@ public class EventServiceImpl extends ServiceImpl if(success && fileList.size()>0){ 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); return success; }