| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.enums.QaReportTypeEnum; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.*; |
| | | import com.ruoyi.system.dto.BatchCollectSamplesDTO; |
| | | import com.ruoyi.system.dto.BatchSendSamplesDTO; |
| | | import com.ruoyi.system.dto.TSamplingRecordDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TSamplingRecordQuery; |
| | |
| | | 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.text.SimpleDateFormat; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private final TProjectProposalService projectProposalService; |
| | | private final TProjectTeamService projectTeamService; |
| | | private final TProjectTeamStaffService projectTeamStaffService; |
| | | private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; |
| | | @Autowired |
| | | public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService) { |
| | | public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService) { |
| | | this.samplingRecordService = samplingRecordService; |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | |
| | | this.projectProposalService = projectProposalService; |
| | | this.projectTeamService = projectTeamService; |
| | | this.projectTeamStaffService = projectTeamStaffService; |
| | | this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping(value = "/api/t-sampling-record/pageList") |
| | | public R<PageInfo<TSamplingRecordVO>> pageList(@RequestBody String param) { |
| | | TSamplingRecordQuery query = JSON.parseObject(param, TSamplingRecordQuery.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); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(samplingRecordService.pageList(query)); |
| | | } |
| | | |
| | |
| | | public R<Boolean> update(@RequestBody String param) { |
| | | TSamplingRecordDTO dto = JSON.parseObject(param,TSamplingRecordDTO.class); |
| | | samplingRecordService.updateById(dto); |
| | | samplingRecordOperationService.remove(Wrappers.lambdaQuery(TSamplingRecordOperation.class).eq(TSamplingRecordOperation::getSamplingId,dto.getId())); |
| | | // samplingRecordOperationService.remove(Wrappers.lambdaQuery(TSamplingRecordOperation.class).eq(TSamplingRecordOperation::getSamplingId,dto.getId())); |
| | | List<TSamplingRecordOperation> samplingRecordOperations = dto.getSamplingRecordOperations(); |
| | | samplingRecordOperations.forEach(samplingRecordOperation -> { |
| | | samplingRecordOperation.setSamplingId(dto.getId()); |
| | | }); |
| | | samplingRecordOperationService.saveBatch(samplingRecordOperations); |
| | | samplingRecordOperationService.saveOrUpdateBatch(samplingRecordOperations); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | samplingRecord.setCommitPersonId(userId); |
| | | samplingRecord.setStatus(2); |
| | | samplingRecord.setCommitSign(samplingRecord.getCommitSign()); |
| | | samplingRecord.setRemark(samplingRecord.getRemark()); |
| | | samplingRecord.setCommitTime(LocalDateTime.now()); |
| | | samplingRecordService.updateById(samplingRecord); |
| | | return R.ok(); |
| | |
| | | BeanUtils.copyProperties(samplingRecord, samplingRecordVO); |
| | | |
| | | // 查询取样操作记录 |
| | | samplingRecordVO.setSamplingRecordOperations(samplingRecordOperationService.list(Wrappers.lambdaQuery(TSamplingRecordOperation.class).eq(TSamplingRecordOperation::getSamplingId, id))); |
| | | List<TSamplingRecordOperation> samplingRecordOperations = samplingRecordOperationService.list(Wrappers.lambdaQuery(TSamplingRecordOperation.class).eq(TSamplingRecordOperation::getSamplingId, id)); |
| | | |
| | | List<Long> userIds = samplingRecordOperations.stream().map(TSamplingRecordOperation::getHandlePersonId).collect(Collectors.toList()); |
| | | List<Long> sendUserIds = samplingRecordOperations.stream().map(TSamplingRecordOperation::getSendPersonId).collect(Collectors.toList()); |
| | | List<Long> receiptsUserIds = samplingRecordOperations.stream().map(TSamplingRecordOperation::getReceiptsPersonId).collect(Collectors.toList()); |
| | | userIds.addAll(sendUserIds); |
| | | userIds.addAll(receiptsUserIds); |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); |
| | | samplingRecordOperations.forEach(samplingRecordOperation -> { |
| | | if(Objects.nonNull(samplingRecordOperation.getHandlePersonId())){ |
| | | samplingRecordOperation.setHandlePersonName(Objects.requireNonNull(sysUsers.stream().filter(user -> user.getUserId().equals(samplingRecordOperation.getHandlePersonId())).findFirst().orElse(null)).getNickName()); |
| | | } |
| | | if(Objects.nonNull(samplingRecordOperation.getSendPersonId())){ |
| | | samplingRecordOperation.setSendPersonName(Objects.requireNonNull(sysUsers.stream().filter(user -> user.getUserId().equals(samplingRecordOperation.getSendPersonId())).findFirst().orElse(null)).getNickName()); |
| | | } |
| | | if(Objects.nonNull(samplingRecordOperation.getReceiptsPersonId())){ |
| | | samplingRecordOperation.setReceiptsPersonName(Objects.requireNonNull(sysUsers.stream().filter(user -> user.getUserId().equals(samplingRecordOperation.getReceiptsPersonId())).findFirst().orElse(null)).getNickName()); |
| | | } |
| | | }); |
| | | |
| | | samplingRecordVO.setSamplingRecordOperations(samplingRecordOperations); |
| | | // 查询实验调度信息 |
| | | TExperimentDispatch experimentDispatch = experimentDispatchService.getById(samplingRecordVO.getDispatchId()); |
| | | if(Objects.nonNull(experimentDispatch)){ |
| | | List<TExperimentDispatchParticipants> tExperimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getDispatchId, experimentDispatch.getId())); |
| | | List<Long> userIdList = tExperimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getUserId).collect(Collectors.toList()); |
| | | List<SysUser> sysUserList = sysUserMapper.selectUserByIds(userIdList); |
| | | tExperimentDispatchParticipants.forEach(tExperimentDispatchParticipant -> { |
| | | SysUser sysUser = sysUserList.stream().filter(user -> user.getUserId().equals(tExperimentDispatchParticipant.getUserId())).findFirst().orElse(null); |
| | | if(sysUser != null){ |
| | | tExperimentDispatchParticipant.setNickName(sysUser.getNickName()); |
| | | } |
| | | }); |
| | | String participantsName = tExperimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getNickName).collect(Collectors.joining(";")); |
| | | experimentDispatch.setParticipantsName(participantsName); |
| | | // 查询课题方案名称 |
| | | TProjectProposal projectProposal = projectProposalService.getById(experimentDispatch.getProposalId()); |
| | | if(Objects.nonNull(projectProposal)){ |
| | |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:sendSamples')") |
| | | @Log(title = "取样记录信息-批量送样", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "批量送样") |
| | | @ApiOperation(value = "批量送样",response = BatchSendSamplesDTO.class) |
| | | @PostMapping(value = "/open/t-sampling-record/batchSendSamples") |
| | | public R<Boolean> batchSendSamples(@RequestBody String param) { |
| | | BatchSendSamplesDTO batchSendSamplesDTO = JSON.parseObject(param, BatchSendSamplesDTO.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | List<String> ids = batchSendSamplesDTO.getRecordOperationId(); |
| | | // 批量送样 |
| | | samplingRecordOperationService.update(Wrappers.lambdaUpdate(TSamplingRecordOperation.class) |
| | | .eq(TSamplingRecordOperation::getId, batchSendSamplesDTO.getRecordOperationId()) |
| | | .set(TSamplingRecordOperation::getStatus, 2) |
| | | .set(TSamplingRecordOperation::getSendSign, batchSendSamplesDTO.getSendSign()) |
| | | .set(TSamplingRecordOperation::getSendTime, LocalDateTime.now()) |
| | | .set(TSamplingRecordOperation::getSendPersonId, userId)); |
| | | List<TSamplingRecordOperation> samplingRecordOperations = samplingRecordOperationService.list(Wrappers.lambdaQuery(TSamplingRecordOperation.class) |
| | | .in(TSamplingRecordOperation::getId, ids)); |
| | | for (TSamplingRecordOperation samplingRecordOperation : samplingRecordOperations) { |
| | | samplingRecordOperation.setStatus(2); |
| | | samplingRecordOperation.setSendPersonId(userId); |
| | | samplingRecordOperation.setSendSign(samplingRecordOperation.getSendSign()); |
| | | samplingRecordOperation.setSendTime(LocalDateTime.now()); |
| | | } |
| | | samplingRecordOperationService.updateBatchById(samplingRecordOperations); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:collectSamples')") |
| | | @Log(title = "取样记录信息-批量收样", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "批量收样") |
| | | @ApiOperation(value = "批量收样",response = BatchCollectSamplesDTO.class) |
| | | @PostMapping(value = "/open/t-sampling-record/batchCollectSamples") |
| | | public R<Boolean> batchCollectSamples(@RequestBody String param) { |
| | | BatchCollectSamplesDTO batchCollectSamplesDTO = JSON.parseObject(param, BatchCollectSamplesDTO.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | List<String> ids = batchCollectSamplesDTO.getRecordOperationId(); |
| | | // 批量送样 |
| | | samplingRecordOperationService.update(Wrappers.lambdaUpdate(TSamplingRecordOperation.class) |
| | | .eq(TSamplingRecordOperation::getId, batchCollectSamplesDTO.getRecordOperationId()) |
| | | .set(TSamplingRecordOperation::getStatus, 3) |
| | | .set(TSamplingRecordOperation::getReceiptsSign, batchCollectSamplesDTO.getReceiptsSign()) |
| | | .set(TSamplingRecordOperation::getReceiptsTime, LocalDateTime.now()) |
| | | .set(TSamplingRecordOperation::getReceiptsPersonId, userId)); |
| | | List<TSamplingRecordOperation> samplingRecordOperations = samplingRecordOperationService.list(Wrappers.lambdaQuery(TSamplingRecordOperation.class) |
| | | .in(TSamplingRecordOperation::getId, ids)); |
| | | for (TSamplingRecordOperation samplingRecordOperation : samplingRecordOperations) { |
| | | samplingRecordOperation.setStatus(3); |
| | | samplingRecordOperation.setSendPersonId(userId); |
| | | samplingRecordOperation.setSendSign(samplingRecordOperation.getReceiptsSign()); |
| | | samplingRecordOperation.setSendTime(LocalDateTime.now()); |
| | | } |
| | | samplingRecordOperationService.updateBatchById(samplingRecordOperations); |
| | | return R.ok(); |
| | | } |
| | | |