From 0220811fbcffd4bd4df334502a2af272ae29f1e3 Mon Sep 17 00:00:00 2001
From: wenminjie <1036699586@qq.com>
Date: 星期一, 13 七月 2026 10:14:30 +0800
Subject: [PATCH] 修复了已知BUG
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java | 423 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 420 insertions(+), 3 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java
index 9818bd8..3afd72c 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java
@@ -1,9 +1,35 @@
package com.ruoyi.web.controller.api;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+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.utils.StringUtils;
+import com.ruoyi.framework.web.service.TokenService;
+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 com.ruoyi.system.service.*;
+import com.ruoyi.system.vo.TSamplingRecordVO;
import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* <p>
@@ -15,8 +41,399 @@
*/
@Api(tags = "取样记录管理")
@RestController
-@RequestMapping("/t-sampling-record")
+@RequestMapping("")
public class TSamplingRecordController {
+ private final TSamplingRecordService samplingRecordService;
+ private final TokenService tokenService;
+ private final ISysUserService sysUserService;
+ private final SysUserMapper sysUserMapper;
+ private final TSamplingRecordOperationService samplingRecordOperationService;
+ private final TExperimentDispatchService experimentDispatchService;
+ private final TProjectProposalService projectProposalService;
+ private final TProjectTeamService projectTeamService;
+ private final TProjectTeamStaffService projectTeamStaffService;
+ private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService;
+ private final TNoticeService noticeService;
+ private final TInspectionReportService inspectionReportService;
+ @Autowired
+ public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TNoticeService noticeService, TInspectionReportService inspectionReportService) {
+ this.samplingRecordService = samplingRecordService;
+ this.tokenService = tokenService;
+ this.sysUserService = sysUserService;
+ this.sysUserMapper = sysUserMapper;
+ this.samplingRecordOperationService = samplingRecordOperationService;
+ this.experimentDispatchService = experimentDispatchService;
+ this.projectProposalService = projectProposalService;
+ this.projectTeamService = projectTeamService;
+ this.projectTeamStaffService = projectTeamStaffService;
+ this.experimentDispatchParticipantsService = experimentDispatchParticipantsService;
+ this.noticeService = noticeService;
+ this.inspectionReportService = inspectionReportService;
+ }
+
+ /**
+ * 获取取样记录管理列表
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecord:list')")
+ @ApiOperation(value = "获取取样记录分页列表", response = TSamplingRecordQuery.class)
+ @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();
+ query.setRoleType(roleType);
+ if (roleType != 1){
+ query.setUserId(userId);
+ if(roleType ==2){
+ // 查询项目组
+ TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class)
+ .eq(TProjectTeamStaff::getUserId, userId));
+ if(Objects.isNull(projectTeamStaff)){
+ return R.fail("当前用户未加入项目组,无法进行操作");
+ }
+ // 查询项目的工艺工程师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<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class)
+ .eq(TProjectTeamStaff::getUserId, userId));
+ if (!CollectionUtils.isEmpty(projectTeamStaffs)) {
+ List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList());
+ List<TProjectProposal> projectProposals = projectProposalService.list(Wrappers.lambdaQuery(TProjectProposal.class)
+ .in(TProjectProposal::getTeamId, teamIds));
+ if (!CollectionUtils.isEmpty(projectProposals)) {
+ List<String> projectIds = projectProposals.stream().map(TProjectProposal::getId).collect(Collectors.toList());
+ List<TExperimentDispatch> experimentDispatches = experimentDispatchService.list(Wrappers.lambdaQuery(TExperimentDispatch.class)
+ .in(TExperimentDispatch::getProposalId, projectIds));
+ if (!CollectionUtils.isEmpty(experimentDispatches)) {
+ List<String> dispatchIds2 = experimentDispatches.stream().map(TExperimentDispatch::getId).collect(Collectors.toList());
+ // 查询检验报告
+ List<TInspectionReport> inspectionReports = inspectionReportService.list(Wrappers.lambdaQuery(TInspectionReport.class)
+ .eq(TInspectionReport::getStatus, 2)
+ .in(TInspectionReport::getDispatchId, dispatchIds2));
+ 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(samplingRecordService.pageList(query));
+ }
+
+ /**
+ * 添加取样记录管理
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecord:add')")
+ @Log(title = "取样记录信息-新增取样记录", businessType = BusinessType.INSERT)
+ @ApiOperation(value = "添加取样记录",response = TSamplingRecordDTO.class)
+ @PostMapping(value = "/api/t-sampling-record/add")
+ public R<Boolean> add(@RequestBody String param) {
+ TSamplingRecordDTO dto = JSON.parseObject(param,TSamplingRecordDTO.class);
+
+ // 通过当前用户查询项目组
+ Long userId = tokenService.getLoginUser().getUserId();
+ TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class)
+ .eq(TProjectTeamStaff::getUserId, userId)
+ .last("LIMIT 1"));
+ if(Objects.isNull(projectTeamStaff)){
+ return R.fail("当前用户未分配项目组,无法创建项目课题方案");
+ }
+ // 查询项目组
+ TProjectTeam projectTeam = projectTeamService.getById(projectTeamStaff.getTeamId());
+ if(Objects.isNull(projectTeam)){
+ return R.fail("项目组不存在");
+ }
+ if(projectTeam.getStatus() == 2){
+ return R.fail("项目组已封存,无法创建项目课题方案");
+ }
+ // 生成取样单编号
+ String format = new SimpleDateFormat("yyyyMMdd").format(new Date());
+ String samplingCode = projectTeam.getTeamName() + "-" + format.substring(2) + "S";
+
+ // 查询上个项目课题方案的序号
+ long count = samplingRecordService.count(Wrappers.lambdaQuery(TSamplingRecord.class)
+ .like(TSamplingRecord::getSamplingCode, samplingCode));
+ samplingCode = samplingCode + String.format("%02d", count+1);
+ dto.setSamplingCode(samplingCode);
+
+ samplingRecordService.save(dto);
+ List<TSamplingRecordOperation> samplingRecordOperations = dto.getSamplingRecordOperations();
+ samplingRecordOperations.forEach(samplingRecordOperation -> {
+ samplingRecordOperation.setSamplingId(dto.getId());
+ });
+ samplingRecordOperationService.saveBatch(samplingRecordOperations);
+ return R.ok();
+ }
+
+ /**
+ * 修改取样记录
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecord:edit')")
+ @Log(title = "取样记录信息-修改取样记录", businessType = BusinessType.UPDATE)
+ @ApiOperation(value = "修改取样记录")
+ @PostMapping(value = "/api/t-sampling-record/update")
+ 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()));
+ List<TSamplingRecordOperation> samplingRecordOperations = dto.getSamplingRecordOperations();
+ samplingRecordOperations.forEach(samplingRecordOperation -> {
+ samplingRecordOperation.setSamplingId(dto.getId());
+ });
+ samplingRecordOperationService.saveOrUpdateBatch(samplingRecordOperations);
+ return R.ok();
+ }
+
+ /**
+ * 修改取样操作记录
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecordOperation:edit')")
+ @Log(title = "取样记录信息-修改取样操作记录", businessType = BusinessType.UPDATE)
+ @ApiOperation(value = "修改取样操作记录")
+ @PostMapping(value = "/api/t-sampling-record/updateRecordOperation")
+ public R<Boolean> updateRecordOperation(@RequestBody String param) {
+ TSamplingRecordOperation operation = JSON.parseObject(param,TSamplingRecordOperation.class);
+ Long userId = tokenService.getLoginUser().getUserId();
+ operation.setHandlePersonId(userId);
+ samplingRecordOperationService.updateById(operation);
+ return R.ok();
+ }
+
+ /**
+ * 修改取样操作记录
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecordOperation:edit')")
+ @Log(title = "取样记录信息-实验员提交取样记录", businessType = BusinessType.UPDATE)
+ @ApiOperation(value = "实验员提交取样记录")
+ @PostMapping(value = "/api/t-sampling-record/commitRecord")
+ public R<Boolean> commitRecord(@RequestBody String param) {
+ TSamplingRecord samplingRecord = JSON.parseObject(param,TSamplingRecord.class);
+ if(StringUtils.isBlank(samplingRecord.getCommitSign())){
+ return R.fail("请提交实验员签字");
+ }
+ 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();
+ }
+
+ /**
+ * 查看取样记录详情
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecord:detail')")
+ @ApiOperation(value = "查看取样记录详情")
+ @GetMapping(value = "/open/t-sampling-record/getDetailById")
+ public R<TSamplingRecordVO> getDetailById(@RequestParam String id) {
+ TSamplingRecord samplingRecord = samplingRecordService.getById(id);
+ TSamplingRecordVO samplingRecordVO = new TSamplingRecordVO();
+ BeanUtils.copyProperties(samplingRecord, samplingRecordVO);
+
+ Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+ Long userId = tokenService.getLoginUser().getUserId();
+ LambdaQueryWrapper<TSamplingRecordOperation> wrapper = new LambdaQueryWrapper<>();
+ if(roleType == 4){
+ // 化验师只查看自己接收得数据
+ wrapper.eq(TSamplingRecordOperation::getReceiptsPersonId,userId );
+ }
+ wrapper.eq(TSamplingRecordOperation::getSamplingId, id);
+ // 查询取样操作记录
+ List<TSamplingRecordOperation> samplingRecordOperations = samplingRecordOperationService.list(wrapper);
+
+ 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);
+ if(!CollectionUtils.isEmpty(userIds)){
+ List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds);
+ for (TSamplingRecordOperation samplingRecordOperation : samplingRecordOperations) {
+ if(Objects.nonNull(samplingRecordOperation.getHandlePersonId())){
+ List<SysUser> users = sysUsers.stream().filter(user -> user.getUserId().equals(samplingRecordOperation.getHandlePersonId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(users)){
+ samplingRecordOperation.setHandlePersonName(users.get(0).getNickName());
+ }
+ }
+ if(Objects.nonNull(samplingRecordOperation.getSendPersonId())){
+ List<SysUser> users = sysUsers.stream().filter(user -> user.getUserId().equals(samplingRecordOperation.getSendPersonId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(users)){
+ samplingRecordOperation.setSendPersonName(users.get(0).getNickName());
+ }
+ }
+ if(Objects.nonNull(samplingRecordOperation.getReceiptsPersonId())){
+ List<SysUser> users = sysUsers.stream().filter(user -> user.getUserId().equals(samplingRecordOperation.getReceiptsPersonId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(users)){
+ samplingRecordOperation.setReceiptsPersonName(users.get(0).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);
+
+ // 返回化验师列表
+ List<TExperimentDispatchParticipants> experimentDispatchParticipantChemists = tExperimentDispatchParticipants.stream().
+ filter(a -> a.getRoleType().equals(4)).collect(Collectors.toList());
+ experimentDispatch.setExperimentDispatchParticipantChemists(experimentDispatchParticipantChemists);
+ // 查询课题方案名称
+ TProjectProposal projectProposal = projectProposalService.getById(experimentDispatch.getProposalId());
+ if(Objects.nonNull(projectProposal)){
+ experimentDispatch.setProjectName(projectProposal.getProjectName());
+ experimentDispatch.setProjectCode(projectProposal.getProjectCode());
+ }
+ }
+ samplingRecordVO.setExperimentDispatch(experimentDispatch);
+ return R.ok(samplingRecordVO);
+ }
+
+ /**
+ * 删除取样记录
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecord:delete')")
+ @Log(title = "取样记录信息-删除取样记录", businessType = BusinessType.DELETE)
+ @ApiOperation(value = "删除取样记录")
+ @DeleteMapping(value = "/open/t-sampling-record/deleteById")
+ public R<Boolean> deleteById(@RequestParam String id) {
+ // 删除取样操作记录
+ samplingRecordOperationService.removeById(id);
+ return R.ok();
+ }
+
+ /**
+ * 批量删除取样记录
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecord:delete')")
+ @Log(title = "取样记录信息-删除取样记录", businessType = BusinessType.DELETE)
+ @ApiOperation(value = "批量删除取样记录")
+ @DeleteMapping(value = "/open/t-sampling-record/deleteByIds")
+ public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
+ // 删除取样操作记录
+ samplingRecordOperationService.remove(Wrappers.lambdaQuery(TSamplingRecordOperation.class).in(TSamplingRecordOperation::getSamplingId, ids));
+ return R.ok(samplingRecordService.removeByIds(ids));
+ }
+
+ /**
+ * 批量送样
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecord:sendSamples')")
+ @Log(title = "取样记录信息-批量送样", businessType = BusinessType.UPDATE)
+ @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<TSamplingRecordOperation> samplingRecordOperations = batchSendSamplesDTO.getRecordOperationList();
+ for (TSamplingRecordOperation samplingRecordOperation : samplingRecordOperations) {
+ samplingRecordOperation.setStatus(2);
+ samplingRecordOperation.setSendPersonId(userId);
+ samplingRecordOperation.setSendTime(LocalDateTime.now());
+ }
+ samplingRecordOperationService.updateBatchById(samplingRecordOperations);
+
+ // 查询取样记录信息
+// TSamplingRecord samplingRecord = samplingRecordService.getById(samplingRecordOperations.get(0).getSamplingId());
+ // 查询实验调度
+// TExperimentDispatch experimentDispatch = experimentDispatchService.getById(samplingRecord.getDispatchId());
+ // 查询实验调度参与人员
+// List<TExperimentDispatchParticipants> teamStaffs = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class)
+// .eq(TExperimentDispatchParticipants::getDispatchId, experimentDispatch.getId())
+// .eq(TExperimentDispatchParticipants::getRoleType, 4));
+ // MESSAGE 添加消息
+ samplingRecordOperations.forEach(samplingRecordOperation -> {
+ noticeService.saveNotice(samplingRecordOperation.getReceiptsPersonId(), "您有【1】条【送样单】等待确认接收样品", tokenService.getLoginUser().getUser().getNickName(),13);
+ });
+ return R.ok();
+ }
+
+ /**
+ * 批量删除取样记录
+ */
+ //@PreAuthorize("@ss.hasPermi('system:samplingRecord:collectSamples')")
+ @Log(title = "取样记录信息-批量收样", businessType = BusinessType.UPDATE)
+ @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();
+ // 批量送样
+ List<TSamplingRecordOperation> samplingRecordOperations = samplingRecordOperationService.list(Wrappers.lambdaQuery(TSamplingRecordOperation.class)
+ .in(TSamplingRecordOperation::getId, ids));
+ for (TSamplingRecordOperation samplingRecordOperation : samplingRecordOperations) {
+ samplingRecordOperation.setStatus(3);
+// samplingRecordOperation.setReceiptsPersonId(userId);
+ samplingRecordOperation.setReceiptsSign(samplingRecordOperation.getReceiptsSign());
+ samplingRecordOperation.setReceiptsTime(LocalDateTime.now());
+ }
+ samplingRecordOperationService.updateBatchById(samplingRecordOperations);
+
+ // 判断是否所有取样记录都收样了
+ List<TSamplingRecordOperation> allRecordOperations = samplingRecordOperationService.list(Wrappers.lambdaQuery(TSamplingRecordOperation.class)
+ .eq(TSamplingRecordOperation::getSamplingId, samplingRecordOperations.get(0).getSamplingId()));
+ if(allRecordOperations.stream().allMatch(e -> e.getStatus() == 3)){
+ samplingRecordService.update(Wrappers.lambdaUpdate(TSamplingRecord.class)
+ .set(TSamplingRecord::getStatus, 4)
+ .eq(TSamplingRecord::getId, samplingRecordOperations.get(0).getSamplingId()));
+ }
+ return R.ok();
+ }
+
}
--
Gitblit v1.7.1