| | |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TTestMethodConfirmSheetOriginalDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.TTestMethodConfirmSheetOriginal; |
| | | import com.ruoyi.system.model.TTestMethodConfirmSheetOriginalData; |
| | | import com.ruoyi.system.model.TTestMethodConfirmSheetTerm; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TTestMethodConfirmSheetOriginalQuery; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.TTestMethodConfirmSheetOriginalDataService; |
| | | import com.ruoyi.system.service.TTestMethodConfirmSheetOriginalService; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TTestMethodConfirmSheetOriginalVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Api(tags = "原始检测项管理") |
| | | @RestController |
| | | @RequestMapping("/t-test-method-confirm-sheet-original") |
| | | @RequestMapping("") |
| | | public class TTestMethodConfirmSheetOriginalController { |
| | | |
| | | private final TokenService tokenService; |
| | |
| | | private final SysUserMapper sysUserMapper; |
| | | private final TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService; |
| | | private final TTestMethodConfirmSheetOriginalDataService testMethodConfirmSheetOriginalDataService; |
| | | private final TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService; |
| | | private final TProjectTeamStaffService projectTeamStaffService; |
| | | private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; |
| | | private final TInspectionReportService inspectionReportService; |
| | | @Autowired |
| | | public TTestMethodConfirmSheetOriginalController(TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService, TTestMethodConfirmSheetOriginalDataService testMethodConfirmSheetOriginalDataService) { |
| | | public TTestMethodConfirmSheetOriginalController(TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService, TTestMethodConfirmSheetOriginalDataService testMethodConfirmSheetOriginalDataService, TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TInspectionReportService inspectionReportService) { |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | | this.sysUserMapper = sysUserMapper; |
| | | this.testMethodConfirmSheetOriginalService = testMethodConfirmSheetOriginalService; |
| | | this.testMethodConfirmSheetOriginalDataService = testMethodConfirmSheetOriginalDataService; |
| | | this.testMethodConfirmSheetTermService = testMethodConfirmSheetTermService; |
| | | this.projectTeamStaffService = projectTeamStaffService; |
| | | this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; |
| | | this.inspectionReportService = inspectionReportService; |
| | | } |
| | | |
| | | /** |
| | | * 获取检验方法确认单管理列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheetOriginal:list')") |
| | | @ApiOperation(value = "获取检验方法确认单分页列表") |
| | | //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheetOriginal:list')") |
| | | @ApiOperation(value = "获取检验方法确认单分页列表", notes = "获取检验方法确认单分页列表",response = TTestMethodConfirmSheetOriginalQuery.class) |
| | | @PostMapping(value = "/api/t-test-method-confirm-sheet-original/pageList") |
| | | public R<PageInfo<TTestMethodConfirmSheetOriginalVO>> pageList(@RequestBody String param) { |
| | | TTestMethodConfirmSheetOriginalQuery query = JSON.parseObject(param, TTestMethodConfirmSheetOriginalQuery.class); |
| | | // 获取当前用户 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | 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); |
| | | } |
| | | } |
| | | if(roleType == 4){ |
| | | // 查询检验报告 |
| | | List<TInspectionReport> inspectionReports = inspectionReportService.list(Wrappers.lambdaQuery(TInspectionReport.class) |
| | | .eq(TInspectionReport::getStatus, 1)); |
| | | if (!CollectionUtils.isEmpty(inspectionReports)) { |
| | | List<String> dispatchIds = inspectionReports.stream().map(TInspectionReport::getDispatchId).distinct().collect(Collectors.toList()); |
| | | List<String> dispatchIds1 = query.getDispatchIds(); |
| | | Iterator<String> iterator = dispatchIds1.iterator(); |
| | | while (iterator.hasNext()) { |
| | | String next = iterator.next(); |
| | | if (!dispatchIds.contains(next)) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | if(CollectionUtils.isEmpty(dispatchIds1)){ |
| | | List<String> id = new ArrayList<>(); |
| | | id.add("-1"); |
| | | query.setDispatchIds(id); |
| | | }else { |
| | | query.setDispatchIds(dispatchIds1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.ok(testMethodConfirmSheetOriginalService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 修改检验方法确认单 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheetOriginal:edit')") |
| | | //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheetOriginal:edit')") |
| | | @Log(title = "检验方法确认单信息-修改检验方法确认单", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改检验方法确认单") |
| | | @PostMapping(value = "/api/t-test-method-confirm-sheet-original/update") |
| | |
| | | /** |
| | | * 查看检验方法确认单详情 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheetOriginal:detail')") |
| | | //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheetOriginal:detail')") |
| | | @ApiOperation(value = "查看检验方法确认单详情") |
| | | @GetMapping(value = "/open/t-test-method-confirm-sheet-original/getDetailById") |
| | | public R<TTestMethodConfirmSheetOriginalVO> getDetailById(@RequestParam String id) { |
| | | TTestMethodConfirmSheetOriginal testMethodConfirmSheet = testMethodConfirmSheetOriginalService.getById(id); |
| | | TTestMethodConfirmSheetOriginalVO testMethodConfirmSheetVO = new TTestMethodConfirmSheetOriginalVO(); |
| | | BeanUtils.copyProperties(testMethodConfirmSheet, testMethodConfirmSheetVO); |
| | | TTestMethodConfirmSheetOriginal testMethodConfirmSheetOriginal = testMethodConfirmSheetOriginalService.getById(id); |
| | | TTestMethodConfirmSheetOriginalVO testMethodConfirmSheetOriginalVO = new TTestMethodConfirmSheetOriginalVO(); |
| | | BeanUtils.copyProperties(testMethodConfirmSheetOriginal, testMethodConfirmSheetOriginalVO); |
| | | |
| | | // 查询检测项数据 |
| | | TTestMethodConfirmSheetTerm testMethodConfirmSheetTerm = testMethodConfirmSheetTermService.getById(testMethodConfirmSheetOriginal.getTermId()); |
| | | testMethodConfirmSheetOriginalVO.setTestMethodConfirmSheetTerm(testMethodConfirmSheetTerm); |
| | | |
| | | // 查询检测数据 |
| | | List<TTestMethodConfirmSheetOriginalData> testMethodConfirmSheetOriginalDataList = testMethodConfirmSheetOriginalDataService.list(Wrappers.lambdaQuery(TTestMethodConfirmSheetOriginalData.class).eq(TTestMethodConfirmSheetOriginalData::getOriginalId, id)); |
| | | testMethodConfirmSheetVO.setTestMethodConfirmSheetOriginalDataList(testMethodConfirmSheetOriginalDataList); |
| | | return R.ok(testMethodConfirmSheetVO); |
| | | testMethodConfirmSheetOriginalVO.setTestMethodConfirmSheetOriginalDataList(testMethodConfirmSheetOriginalDataList); |
| | | return R.ok(testMethodConfirmSheetOriginalVO); |
| | | } |
| | | |
| | | } |