xuhy
2 天以前 8586161442cbe058fae93bfd35a468485b9b505e
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInspectionReportController.java
@@ -71,6 +71,38 @@
    @PostMapping(value = "/api/t-inspection-report/pageList")
    public R<PageInfo<TInspectionReportVO>> pageList(@RequestBody String param) {
        TInspectionReportQuery query = JSON.parseObject(param, TInspectionReportQuery.class);
        // 获取当前用户
        Long userId = tokenService.getLoginUser().getUserId();
        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
        query.setRoleType(roleType);
        if (roleType != 1){
            query.setUserId(userId);
            if(roleType ==2){
                // 查询项目组
                TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class)
                        .eq(TProjectTeamStaff::getUserId, userId));
                // 查询项目的工艺工程师id
                TProjectTeamStaff teamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class)
                        .eq(TProjectTeamStaff::getTeamId, projectTeamStaff.getTeamId())
                        .eq(TProjectTeamStaff::getRoleType, 3)
                        .last("LIMIT 1"));
                // 查询实验参与人员
                List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class)
                        .eq(TExperimentDispatchParticipants::getUserId, teamStaff.getUserId()));
                if(!CollectionUtils.isEmpty(experimentDispatchParticipants)){
                    List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList());
                    query.setDispatchIds(dispatchIds);
                }
            }else {
                // 查询实验参与人员
                List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class)
                        .eq(TExperimentDispatchParticipants::getUserId, userId));
                if (!CollectionUtils.isEmpty(experimentDispatchParticipants)) {
                    List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList());
                    query.setDispatchIds(dispatchIds);
                }
            }
        }
        return R.ok(inspectionReportService.pageList(query));
    }
@@ -112,6 +144,23 @@
    public R<Boolean> update(@RequestBody String param) {
        TInspectionReportDTO dto = JSON.parseObject(param,TInspectionReportDTO.class);
        inspectionReportService.updateById(dto);
        if(dto.getStatus() != -1){
            // 通过当前用户查询项目组
            Long userId = tokenService.getLoginUser().getUserId();
            TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class)
                    .eq(TProjectTeamStaff::getUserId, userId)
                    .last("LIMIT 1"));
            // 查询项目组
            TProjectTeam projectTeam = projectTeamService.getById(projectTeamStaff.getTeamId());
            // MESSAGE 添加消息
            TProjectTeamStaff teamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class)
                    .eq(TProjectTeamStaff::getTeamId, projectTeam.getId())
                    .eq(TProjectTeamStaff::getRoleType, 3)
                    .last("LIMIT 1"));
            if(Objects.nonNull(teamStaff)){
                noticeService.saveNotice(teamStaff.getUserId(), "化验师已提交检验报告,请查收!", tokenService.getLoginUser().getUser().getNickName(),7);
            }
        }
        return R.ok();
    }