| | |
| | | @Override |
| | | @Transactional |
| | | public OnDuty add(User creator, AddOnDutyRequest request) { |
| | | // 1. 查询项目信息,获取 clientId |
| | | Project project = projectRepository.findById(request.getProjectId()) |
| | | .orElseThrow(() -> new RuntimeException("项目不存在")); |
| | | |
| | | if (project.getClient() == null) { |
| | | throw new RuntimeException("项目未关联委托方"); |
| | | } |
| | | Integer clientId = project.getClient().getId(); |
| | | |
| | | // 2. 查询岗位信息,获取 positionName(MyBatis Plus 方式) |
| | | Position position = positionService.getById(request.getPositionId()); |
| | | if (position == null) { |
| | |
| | | |
| | | // 4. 构建 OnDuty 实体 |
| | | OnDuty onDuty = new OnDuty(); |
| | | onDuty.setPlanId(request.getPlanId()); |
| | | onDuty.setProjectId(request.getProjectId()); |
| | | onDuty.setClientId(clientId); |
| | | onDuty.setCheckTaskIdId(request.getCheckTaskIdId()); |
| | | onDuty.setContent("人员在岗"); // 固定值 |
| | | onDuty.setPositionId(request.getPositionId()); |
| | | onDuty.setPositionName(positionName); |
| | |
| | | * 用于新的列表查询接口,支持"全部/我创建的"筛选 |
| | | */ |
| | | @Override |
| | | public PageRespMp<OnDuty> listOnDutyRecords(Integer planId, Integer creatorId, PageReq pageReq) { |
| | | Page<OnDuty> page = lambdaQuery().eq(OnDuty::getPlanId, planId).eq(Objects.nonNull(creatorId), OnDuty::getCreatorId, creatorId) |
| | | public PageRespMp<OnDuty> listOnDutyRecords(Integer checkTaskId, Integer creatorId, PageReq pageReq) { |
| | | Page<OnDuty> page = lambdaQuery().eq(OnDuty::getCheckTaskIdId, checkTaskId).eq(Objects.nonNull(creatorId), OnDuty::getCreatorId, creatorId) |
| | | .page(new Page<>(pageReq.getPage(), pageReq.getSize())); |
| | | //转换为 PageRespMp |
| | | return PageRespMp.of(page); |