| | |
| | | import com.estate.expert.admin.service.ClientService; |
| | | import com.estate.expert.admin.service.OnDutyService; |
| | | import com.estate.expert.admin.service.PositionService; |
| | | import com.estate.expert.common.exception.BizException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | //1.校验任务id |
| | | CheckTask checkTask = checkTaskService.get(request.getCheckTaskIdId()); |
| | | if (Objects.isNull(checkTask)) { |
| | | throw new RuntimeException("检查任务不存在"); |
| | | throw new BizException("检查任务不存在"); |
| | | } |
| | | Client client = clientService.get(checkTask.getProject().getClient().getId()); |
| | | if (Objects.isNull(client)) { |
| | | throw new RuntimeException("委托方不存在"); |
| | | throw new BizException("委托方不存在"); |
| | | } |
| | | // 2. 查询岗位信息,获取 positionName(MyBatis Plus 方式) |
| | | Position position = positionService.getById(request.getPositionId()); |
| | | if (position == null) { |
| | | throw new RuntimeException("岗位不存在"); |
| | | throw new BizException("岗位不存在"); |
| | | } |
| | | String positionName = position.getName(); |
| | | //校验该岗位是否已添加 |
| | | Long count = lambdaQuery().eq(OnDuty::getCheckTaskIdId, request.getCheckTaskIdId()).eq(OnDuty::getPositionId, request.getPositionId()).count(); |
| | | if (count > 0) { |
| | | throw new RuntimeException("该岗位已上传"); |
| | | throw new BizException("该岗位已上传"); |
| | | } |
| | | |
| | | // 3. 处理图片列表(逗号分隔) |
| | |
| | | // 1. 查询现有记录 |
| | | OnDuty onDuty = this.getById(request.getId()); |
| | | if (onDuty == null) { |
| | | throw new RuntimeException("在岗记录不存在"); |
| | | throw new BizException("在岗记录不存在"); |
| | | } |
| | | |
| | | // 2. 如果岗位ID发生变化,需要更新岗位名称(MyBatis Plus 方式) |
| | | if (!onDuty.getPositionId().equals(request.getPositionId())) { |
| | | Position position = positionService.getById(request.getPositionId()); |
| | | if (position == null) { |
| | | throw new RuntimeException("岗位不存在"); |
| | | throw new BizException("岗位不存在"); |
| | | } |
| | | onDuty.setPositionName(position.getName()); |
| | | } |