From 5b9a47918bbbde6f4dd2c92f918329f8da6d3f3e Mon Sep 17 00:00:00 2001 From: wxr Date: Thu, 26 Feb 2026 16:39:35 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8A=A5=E5=87=BA=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SampleReportDataQueryController.java | 1 + .../admin/SampleResultQueryController.java | 53 +++++++ .../vo/SampleProjectResultDetailReqVO.java | 14 ++ .../vo/SampleProjectResultDetailRespVO.java | 140 ++++++++++++++++++ .../vo/SampleProjectResultPageReqVO.java | 47 ++++++ .../vo/SampleProjectResultRespVO.java | 99 +++++++++++++ .../dal/mapper/SampleResultQueryMapper.java | 22 +++ .../SampleAnalysisAuditServiceImpl.java | 17 ++- .../bus/service/SampleResultQueryService.java | 17 +++ .../service/SampleResultQueryServiceImpl.java | 38 +++++ .../dal/mapper/SampleResultQueryMapper.xml | 127 ++++++++++++++++ 11 files changed, 570 insertions(+), 5 deletions(-) create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleResultQueryController.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailReqVO.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailRespVO.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultPageReqVO.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultRespVO.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleResultQueryService.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleResultQueryServiceImpl.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.xml diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleReportDataQueryController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleReportDataQueryController.java index a0e41805..eb22a52b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleReportDataQueryController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleReportDataQueryController.java @@ -44,4 +44,5 @@ public class SampleReportDataQueryController { JSONObject result = sampleAnalysisAuditService.getCrossAuditDataByTaskId(businessAssayTaskId); return success(result); } + } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleResultQueryController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleResultQueryController.java new file mode 100644 index 00000000..7ba4f682 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleResultQueryController.java @@ -0,0 +1,53 @@ +package com.zt.plat.module.qms.business.bus.controller.admin; + +import java.util.List; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.zt.plat.framework.business.interceptor.BusinessControllerMarker; +import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; +import com.zt.plat.framework.security.core.LoginUser; +import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailRespVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultPageReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultRespVO; +import com.zt.plat.module.qms.business.bus.service.SampleResultQueryService; + +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; + +/** + * 样品结果查询 + */ +@Tag(name = "管理后台 - 样品结果查询") +@RestController +@RequestMapping("/qms/bus/sample/result-query") +@Validated +@DeptDataPermissionIgnore(enable = "true") +public class SampleResultQueryController implements BusinessControllerMarker { + + @Resource + private SampleResultQueryService sampleResultQueryService; + + @GetMapping("/sampleProjectResultQuery") + public CommonResult> sampleProjectResultQuery(SampleProjectResultPageReqVO reqVO) { + if (reqVO.getAssayDepartmentId() == null) { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + reqVO.setAssayDepartmentId(loginUser.getVisitDeptId()); + } + PageResult page = sampleResultQueryService.sampleProjectResultQuery(reqVO); + return CommonResult.success(page); + } + + @GetMapping("/sampleProjectResultDetailQuery") + public CommonResult> sampleProjectResultDetailQuery(SampleProjectResultDetailReqVO reqVO) { + List list = sampleResultQueryService.sampleProjectResultDetailQuery(reqVO); + return CommonResult.success(list); + } +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailReqVO.java new file mode 100644 index 00000000..a8011891 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailReqVO.java @@ -0,0 +1,14 @@ +package com.zt.plat.module.qms.business.bus.controller.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class SampleProjectResultDetailReqVO { + + @Schema(description = "样品分样ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25701") + private Long businessSubParentSampleId; + + @Schema(description = "检测方法分析项目配置ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7653") + private Long configAssayMethodProjectId; +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailRespVO.java new file mode 100644 index 00000000..b8c5eaf4 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailRespVO.java @@ -0,0 +1,140 @@ +package com.zt.plat.module.qms.business.bus.controller.vo; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 样品检测项目结果响应 + */ +@Data +public class SampleProjectResultDetailRespVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18701") + private Long id; + + @Schema(description = "样品主样ID", example = "23293") + private Long businessBaseSampleId; + + @Schema(description = "样品分样ID", example = "15024") + private Long businessSubParentSampleId; + + @Schema(description = "分样子样ID", example = "20464") + private Long businessSubSampleId; + + @Schema(description = "分样子样判定ID", example = "14560") + private Long businessSubSampleAssessmentId; + + @Schema(description = "检测方法配置ID", example = "9130") + private Long configAssayMethodId; + + @Schema(description = "方法名称及类别") + private String methodNameCategory; + + @Schema(description = "任务单模板key") + private String configReportTemplateKey; + + @Schema(description = "检测方法分析项目配置ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7653") + private Long configAssayMethodProjectId; + + @Schema(description = "指派单ID", example = "23566") + private Long businessAssayTaskId; + + @Schema(description = "指派编号") + private String taskNo; + + @Schema(description = "指派单名称", example = "张三") + private String taskName; + + @Schema(description = "任务类型,【字典】【jy_sample_task_type】常规、抽查...", example = "2") + private String taskType; + + + @Schema(description = "符号,=、>、<、等") + private String symbol; + + @Schema(description = "值") + @ExcelProperty("值") + private String value; + + @Schema(description = "补正系数ID", example = "1008") + private Long configAssayMethodProjectCoefficientId; + + @Schema(description = "补正系数") + private BigDecimal coefficient; + + @Schema(description = "补正后的值") + private String valueAfter; + + @Schema(description = "方法检出下限值") + private String minimumLimitValue; + + + @Schema(description = "样品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + private String sampleName; + + @Schema(description = "样品编号", requiredMode = Schema.RequiredMode.REQUIRED) + private String sampleCode; + + @Schema(description = "分析编号") + private String sampleAssayCode; + + @Schema(description = "归库编号") + private String sampleReturnCode; + + @Schema(description = "检测项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @ExcelProperty("检测项目名称") + private String projectName; + + @Schema(description = "检测项目缩写", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @ExcelProperty("检测项目缩写") + private String projectSimpleName; + + @Schema(description = "显示名称", example = "李四") + @ExcelProperty("显示名称") + private String projectShowName; + + @Schema(description = "键值") + @ExcelProperty("键值") + private String projectKey; + + @Schema(description = "单位") + @ExcelProperty("单位") + private String dictionaryProjectUnit; + + + + @Schema(description = "分析部门ID", example = "16988") + private Long assayDepartmentId; + + @Schema(description = "分析部门名称", example = "芋艿") + private String assayDepartmentName; + + @Schema(description = "分析人") + private String assayOperator; + + @Schema(description = "分析人ID", example = "27835") + private Long assayOperatorId; + + @Schema(description = "是否已上报") + private Integer isReported; + + @Schema(description = "上报人") + private String reporter; + + @Schema(description = "上报人ID", example = "15920") + private Long reporterId; + + @Schema(description = "上报时间") + private LocalDateTime reportTime; + + + + + + +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultPageReqVO.java new file mode 100644 index 00000000..d80b829c --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultPageReqVO.java @@ -0,0 +1,47 @@ +package com.zt.plat.module.qms.business.bus.controller.vo; + +import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +import java.time.LocalDateTime; + +import org.springframework.format.annotation.DateTimeFormat; + +import com.zt.plat.framework.common.pojo.PageParam; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 样品检测项目结果分页条件VO + */ +@Data +public class SampleProjectResultPageReqVO extends PageParam { + + private static final long serialVersionUID = 7153959501553288866L; + + @Schema(description = "分析部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2493") + private Long assayDepartmentId; + + @Schema(description = "样品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + private String sampleName; + + @Schema(description = "样品编号", requiredMode = Schema.RequiredMode.REQUIRED) + private String sampleCode; + + @Schema(description = "检测项目缩写", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + private String projectSimpleName; + + @Schema(description = "收样人") + private String sampleReceiver; + + @Schema(description = "收样时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] sampleReceiveTime; + + @Schema(description = "上报人") + private String reporter; + + @Schema(description = "上报时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] reportTime; +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultRespVO.java new file mode 100644 index 00000000..7684da46 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultRespVO.java @@ -0,0 +1,99 @@ +package com.zt.plat.module.qms.business.bus.controller.vo; + +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 样品检测项目结果响应 + */ +@Data +public class SampleProjectResultRespVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18701") + private Long id; + + @Schema(description = "样品分样ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25701") + @ExcelProperty("样品分样ID") + private Long businessSubParentSampleId; + + @Schema(description = "检测方法配置ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "13131") + @ExcelProperty("检测方法配置ID") + private Long configAssayMethodId; + + @Schema(description = "检测方法分析项目配置ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7653") + @ExcelProperty("检测方法分析项目配置ID") + private Long configAssayMethodProjectId; + + @Schema(description = "样品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + private String sampleName; + + @Schema(description = "样品编号", requiredMode = Schema.RequiredMode.REQUIRED) + private String sampleCode; + + @Schema(description = "分析编号") + private String sampleAssayCode; + + @Schema(description = "归库编号") + private String sampleReturnCode; + + @Schema(description = "检测项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @ExcelProperty("检测项目名称") + private String projectName; + + @Schema(description = "检测项目缩写", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @ExcelProperty("检测项目缩写") + private String projectSimpleName; + + @Schema(description = "显示名称", example = "李四") + @ExcelProperty("显示名称") + private String projectShowName; + + @Schema(description = "键值") + @ExcelProperty("键值") + private String projectKey; + + @Schema(description = "单位") + @ExcelProperty("单位") + private String dictionaryProjectUnit; + + @Schema(description = "分析部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2493") + @ExcelProperty("分析部门ID") + private Long assayDepartmentId; + + @Schema(description = "分析部门名称", example = "赵六") + @ExcelProperty("分析部门名称") + private String assayDepartmentName; + + @Schema(description = "收样人") + @ExcelProperty("收样人") + private String sampleReceiver; + + @Schema(description = "收样时间") + @ExcelProperty("收样时间") + private LocalDateTime sampleReceiveTime; + + @Schema(description = "判定值") + @ExcelProperty("判定值") + private String assessmentValue; + + @Schema(description = "方法检出下限值") + private String minimumLimitValue; + + @Schema(description = "是否已上报", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("是否已上报") + private Integer isReported; + + @Schema(description = "上报人") + @ExcelProperty("上报人") + private String reporter; + + @Schema(description = "上报时间") + @ExcelProperty("上报时间") + private LocalDateTime reportTime; + + +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.java new file mode 100644 index 00000000..18f13b56 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.java @@ -0,0 +1,22 @@ +package com.zt.plat.module.qms.business.bus.dal.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailRespVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultPageReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultRespVO; + +@Mapper +public interface SampleResultQueryMapper { + + Page sampleProjectResultQuery(IPage page, @Param("reqVO") SampleProjectResultPageReqVO reqVO); + + List sampleProjectResultDetailQuery(@Param("reqVO") SampleProjectResultDetailReqVO reqVO); + +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisAuditServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisAuditServiceImpl.java index e8dbb830..ba444900 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisAuditServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisAuditServiceImpl.java @@ -67,11 +67,13 @@ import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleAssessmen import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleAssessmentProjectMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleMapper; import com.zt.plat.module.qms.business.config.controller.vo.*; +import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodParameterDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectAssessmentDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectParameterDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigRuleDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleParentMethodDO; +import com.zt.plat.module.qms.business.config.dal.mapper.ConfigAssayMethodParameterMapper; import com.zt.plat.module.qms.business.config.dal.mapper.ConfigAssayMethodProjectAssessmentMapper; import com.zt.plat.module.qms.business.config.dal.mapper.ConfigAssayMethodProjectCoefficientMapper; import com.zt.plat.module.qms.business.config.dal.mapper.ConfigAssayMethodProjectMapper; @@ -889,7 +891,7 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic //执行自动上报 if (automaticBusinessSubSampleAssessmentList.size() > 0) { for (BusinessSubSampleAssessmentDO automaticBusinessSubSampleAssessment : automaticBusinessSubSampleAssessmentList) { - this.assessmentDataReporting(automaticBusinessSubSampleAssessment.getBusinessSubSampleId(), businessAssayTaskDO.getConfigAssayMethodId(), automaticBusinessSubSampleAssessment.getRetestCount()); + this.assessmentDataReporting(automaticBusinessSubSampleAssessment.getBusinessSubSampleId(), automaticBusinessSubSampleAssessment.getConfigAssayMethodId(), automaticBusinessSubSampleAssessment.getRetestCount()); } } @@ -1063,6 +1065,9 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic @Resource private ConfigSubSampleMapper configSubSampleMapper; + @Resource + private ConfigAssayMethodParameterMapper configAssayMethodParameterMapper; + @Resource private BusinessSubSampleMapper businessSubSampleMapper; @@ -1153,11 +1158,13 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic businessAssayTaskParameterDataDO.setBusinessAssayTaskDataId(newBusinessAssayTaskDataDO.getId()); businessAssayTaskParameterDataDO.setConfigAssayMethodParameterId(currentBusinessAssayTaskParameterData.getConfigAssayMethodParameterId()); businessAssayTaskParameterDataDO.setDataType(currentBusinessAssayTaskParameterData.getDataType()); - businessAssayTaskParameterDataDO.setDecimalPosition(currentBusinessAssayTaskParameterData.getDecimalPosition()); + businessAssayTaskParameterDataDO.setDecimalPosition(currentBusinessAssayTaskParameterData.getDecimalPosition()); -// if (StringUtils.isNotBlank(configAssayMethodParameterDO.getDefaultValue())) { -// businessAssayTaskParameterDataDO.setValue(configAssayMethodParameterDO.getDefaultValue()); -// } + ConfigAssayMethodParameterDO configAssayMethodParameterDO = configAssayMethodParameterMapper.selectById(currentBusinessAssayTaskParameterData.getConfigAssayMethodParameterId()); + + if (configAssayMethodParameterDO != null && StringUtils.isNotBlank(configAssayMethodParameterDO.getDefaultValue())) { + businessAssayTaskParameterDataDO.setValue(configAssayMethodParameterDO.getDefaultValue()); + } if (getParamList != null) { ConfigSubSampleMethodConfItem targetAttribute = getParamList.stream().filter(f -> StringUtils.isNotBlank(f.getTarget().getAttribute()) && f.getTarget().getAttribute().equals(currentBusinessAssayTaskParameterData.getKey())).findFirst().orElse(null); if (targetAttribute != null) { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleResultQueryService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleResultQueryService.java new file mode 100644 index 00000000..e602bf29 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleResultQueryService.java @@ -0,0 +1,17 @@ +package com.zt.plat.module.qms.business.bus.service; + +import java.util.List; + +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailRespVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultPageReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultRespVO; + +public interface SampleResultQueryService { + + PageResult sampleProjectResultQuery(SampleProjectResultPageReqVO reqVO); + + List sampleProjectResultDetailQuery(SampleProjectResultDetailReqVO reqVO); + +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleResultQueryServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleResultQueryServiceImpl.java new file mode 100644 index 00000000..8114e671 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleResultQueryServiceImpl.java @@ -0,0 +1,38 @@ +package com.zt.plat.module.qms.business.bus.service; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zt.plat.framework.common.pojo.PageParam; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.mybatis.core.util.MyBatisUtils; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailRespVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultPageReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultRespVO; +import com.zt.plat.module.qms.business.bus.dal.mapper.SampleResultQueryMapper; + +import jakarta.annotation.Resource; + +@Service +public class SampleResultQueryServiceImpl implements SampleResultQueryService { + + @Resource + private SampleResultQueryMapper sampleResultQueryMapper; + + @Override + public PageResult sampleProjectResultQuery(SampleProjectResultPageReqVO reqVO) { + IPage mpPage = MyBatisUtils.buildPage((PageParam)reqVO); + Page pageResult = sampleResultQueryMapper.sampleProjectResultQuery(mpPage, reqVO); + return new PageResult(pageResult.getRecords(), pageResult.getTotal()); + } + + @Override + public List sampleProjectResultDetailQuery(SampleProjectResultDetailReqVO reqVO) { + return sampleResultQueryMapper.sampleProjectResultDetailQuery(reqVO); + } + +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.xml new file mode 100644 index 00000000..36a1eab5 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.xml @@ -0,0 +1,127 @@ + + + + + + + + + \ No newline at end of file From 951d6d45d03a826a726dfc30fda746a114b4165d Mon Sep 17 00:00:00 2001 From: wxr Date: Thu, 26 Feb 2026 17:29:15 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=8A=A5=E5=87=BA=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/SampleProjectResultDetailRespVO.java | 3 +++ .../service/SampleTaskAssignServiceImpl.java | 27 +++++++++++++++++++ .../dal/mapper/SampleResultQueryMapper.xml | 1 + 3 files changed, 31 insertions(+) diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailRespVO.java index b8c5eaf4..95086304 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/SampleProjectResultDetailRespVO.java @@ -72,6 +72,9 @@ public class SampleProjectResultDetailRespVO { @Schema(description = "方法检出下限值") private String minimumLimitValue; + + @Schema(description = "是否不参与超差判定", requiredMode = Schema.RequiredMode.REQUIRED) + private Integer isNotAssessment; @Schema(description = "样品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleTaskAssignServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleTaskAssignServiceImpl.java index 00318831..541478d2 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleTaskAssignServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleTaskAssignServiceImpl.java @@ -31,6 +31,7 @@ import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDat import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDetailDO; +import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskParameterDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCCoefficientDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCCoefficientParameterDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementDataDO; @@ -46,6 +47,7 @@ import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayReportDataMap import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskDataMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskDetailMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskMapper; +import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskParameterDataMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessQCCoefficientDataMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessQCCoefficientParameterDataMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessQCManagementDataMapper; @@ -105,6 +107,9 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { @Resource private BusinessAssayTaskMapper businessAssayTaskMapper; + @Resource + private BusinessAssayTaskParameterDataMapper businessAssayTaskParameterDataMapper; + @Resource private BusinessAssayTaskDetailMapper businessAssayTaskDetailMapper; @@ -317,6 +322,8 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { //需要更新的分析任务 List updateBusinessAssayTaskDataDOList = new ArrayList<>(); + //需要更新的分析任务参数 + List updateBusinessAssayTaskParameterDataDOList = new ArrayList<>(); //需要更新的分析任务检测项目 List updateBusinessAssayProjectDataDOList = new ArrayList<>(); //需要更新的分析任务检测项目参数 @@ -330,6 +337,8 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { //需要新建的分析任务 List saveBusinessAssayTaskDataDOList = new ArrayList<>(); + //需要新建的分析任务参数 + List saveBusinessAssayTaskParameterDataDOList = new ArrayList<>(); //需要新建的分析任务检测项目 List saveBusinessAssayProjectDataDOList = new ArrayList<>(); //需要新建的分析任务检测项目参数 @@ -343,6 +352,8 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { //需要删除的分析任务 List removeAssayTaskDataIdList = new ArrayList<>(); + //需要删除的分析任务参数 + List removeAssayTaskParameterDataIdList = new ArrayList<>(); //需要删除的分析任务检测项目 List removeAssayProjectIdList = new ArrayList<>(); //需要删除的分析任务检测项目参数 @@ -368,6 +379,9 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { } List businessAssayTaskDataIdList = businessAssayTaskDataDOList.stream().map(m -> m.getId()).collect(Collectors.toList()); + //查询检测任务的参数 + List businessAssayTaskParameterDataList = businessAssayTaskParameterDataMapper.selectExtendByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + //查询检测任务的检测项目 List businessAssayProjectDataList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); List businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); @@ -382,6 +396,8 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { //查询要变更的分析方法配置 List configAssayMethodDOList = configAssayMethodMapper.selectByIds(changeConfigAssayMethodIdList); + //查询要变更的分析方法参数配置 + List configAssayMethodParameterDOList = configAssayMethodParameterMapper.selectByConfigAssayMethodIds(changeConfigAssayMethodIdList); //分析方法检测项目配置 List configAssayMethodProjectList = configAssayMethodProjectMapper.selectByConfigAssayMethodIds(changeConfigAssayMethodIdList); //分析方法检测项目参数配置 @@ -702,6 +718,10 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { if (removeAssayTaskDataIdList.size() > 0) { businessAssayTaskDataMapper.deleteByIds(removeAssayTaskDataIdList); } + if (removeAssayTaskParameterDataIdList.size() > 0) { + businessAssayTaskParameterDataMapper.deleteByIds(removeAssayTaskParameterDataIdList); + } + if (removeAssayProjectIdList.size() > 0) { businessAssayProjectDataMapper.deleteByIds(removeAssayProjectIdList); } @@ -722,6 +742,9 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { if (updateBusinessAssayReportDataDOList.size() > 0) { businessAssayReportDataMapper.updateBatch(updateBusinessAssayReportDataDOList); } + if (updateBusinessAssayTaskParameterDataDOList.size() > 0) { + businessAssayTaskParameterDataMapper.updateBatch(updateBusinessAssayTaskParameterDataDOList); + } if (updateBusinessAssayTaskDataDOList.size() > 0) { businessAssayTaskDataMapper.updateBatch(updateBusinessAssayTaskDataDOList); @@ -746,6 +769,10 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { if (saveBusinessAssayTaskDataDOList.size() > 0) { businessAssayTaskDataMapper.insertBatch(saveBusinessAssayTaskDataDOList); } + if (saveBusinessAssayTaskParameterDataDOList.size() > 0) { + businessAssayTaskParameterDataMapper.insertBatch(saveBusinessAssayTaskParameterDataDOList); + } + if (saveBusinessAssayProjectDataDOList.size() > 0) { businessAssayProjectDataMapper.insertBatch(saveBusinessAssayProjectDataDOList); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.xml index 36a1eab5..fa49e55d 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.xml +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/business/bus/dal/mapper/SampleResultQueryMapper.xml @@ -81,6 +81,7 @@ tbapd.COEF AS coefficient, tbapd.VAL_AFT AS valueAfter, tbapd.MIN_LIM_VAL AS minimumLimitValue, + tbapd.IS_NT_ASMT AS isNotAssessment, tbatd.ASY_OPTR AS assayOperator, tbatd.RPT_TM AS reportTime, tbatd.RPTR AS reporter, From 5faf04e626278351a892b65ed8162ccc1c33ba19 Mon Sep 17 00:00:00 2001 From: shusir <497819738@qq.com> Date: Thu, 26 Feb 2026 17:55:32 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=E5=8D=B1=E5=8C=96=E5=93=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/MaterialInfomationPageReqVO.java | 3 + .../vo/MaterialInfomationRespVO.java | 12 +- .../vo/MaterialUseRecordPageReqVO.java | 5 +- .../vo/MaterialUseRecordRespVO.java | 8 ++ .../MaterialUseRecordWithMakeInfoRespVO.java | 3 +- .../dal/dataobject/MaterialInfomationDO.java | 5 + .../dal/mapper/MaterialInfomationMapper.java | 5 +- .../dal/mapper/MaterialUseRecordMapper.java | 20 +++- .../service/MaterialInfomationService.java | 35 ++++++ .../MaterialInfomationServiceImpl.java | 104 ++++++++++++++++-- ...MaterialInventoryInboundDetailService.java | 12 ++ ...rialInventoryInboundDetailServiceImpl.java | 23 ++++ .../MaterialInventoryInboundServiceImpl.java | 72 +++--------- .../MaterialStandardSolutionServiceImpl.java | 12 +- .../MaterialUseRecordDetailService.java | 8 ++ .../MaterialUseRecordDetailServiceImpl.java | 74 ++++++++----- .../service/MaterialUseRecordService.java | 9 ++ .../service/MaterialUseRecordServiceImpl.java | 91 ++++++++------- 18 files changed, 357 insertions(+), 144 deletions(-) diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationPageReqVO.java index 30066434..61a2943b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationPageReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationPageReqVO.java @@ -33,6 +33,9 @@ public class MaterialInfomationPageReqVO extends PageParam { @Schema(description = "名称") private String name; + @Schema(description = "是否需要识别存在危化品配置信息,默认false") + private Boolean needDetectExistHazardousMake = false; + @Schema(description = "技术参数") private String parameter; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationRespVO.java index 3c078918..f412be59 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationRespVO.java @@ -1,10 +1,8 @@ package com.zt.plat.module.qms.resource.material.controller.vo; -import com.baomidou.mybatisplus.annotation.TableField; import com.zt.plat.module.qms.core.aspect.annotation.Dict; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; -import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.time.LocalDate; @@ -124,6 +122,10 @@ public class MaterialInfomationRespVO { @Dict(dicCode = "yes_or_no") private Integer hazardous; + @Schema(description = "是否存在危化品配置信息") + @ExcelProperty("是否存在危化品配置信息") + private Boolean existHazardousMake; + @Schema(description = "是否标准溶液,1-是,0-否") @ExcelProperty("是否标准溶液,1-是,0-否") @Dict(dicCode = "yes_or_no") @@ -184,7 +186,11 @@ public class MaterialInfomationRespVO { @Schema(description = "剩余量") @ExcelProperty("剩余量") - private String remainingVolume; + private BigDecimal remainingVolume; + + @Schema(description = "初始总量") + @ExcelProperty("初始总量") + private BigDecimal initialVolume; @Schema(description = "用完标记,0-未标记,1-已用完标记") @ExcelProperty("用完标记,0-未标记,1-已用完标记") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialUseRecordPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialUseRecordPageReqVO.java index 5958dc42..ff2fcc38 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialUseRecordPageReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialUseRecordPageReqVO.java @@ -13,9 +13,12 @@ import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH @Data public class MaterialUseRecordPageReqVO extends PageParam { - @Schema(description = "物料实例id,1-是;0-否", example = "16550") + @Schema(description = "物料实例id", example = "16550") private Long infomationId; + @Schema(description = "大类id", example = "16550") + private Long productId; + @Schema(description = "是否配置危险品") private String hazardousMakeFlag; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialUseRecordRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialUseRecordRespVO.java index 716d48a4..aaf26320 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialUseRecordRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialUseRecordRespVO.java @@ -25,6 +25,14 @@ public class MaterialUseRecordRespVO { @ExcelProperty("物料实例编号") private String infomationCode; + @Schema(description = "物料实例名称") + @ExcelProperty("物料实例名称") + private String infomationName; + + @Schema(description = "型号") + @ExcelProperty("型号") + private String modelNo; + @Schema(description = "是否配置危险品", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("是否配置危险品") @Dict(dicCode = "yes_or_no") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialUseRecordWithMakeInfoRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialUseRecordWithMakeInfoRespVO.java index 8bb39638..81eb53d1 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialUseRecordWithMakeInfoRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/resp/MaterialUseRecordWithMakeInfoRespVO.java @@ -1,6 +1,7 @@ package com.zt.plat.module.qms.resource.material.controller.vo.resp; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordRespVO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -11,7 +12,7 @@ import java.util.List; public class MaterialUseRecordWithMakeInfoRespVO { @Schema(description = "参与配置明细") - private List makeInfoList; + private List makeInfoList; @Schema(description = "配置生成的实例") private MaterialInfomationRespVO targetInfo; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInfomationDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInfomationDO.java index b11b4788..bd2968bf 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInfomationDO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInfomationDO.java @@ -174,6 +174,11 @@ public class MaterialInfomationDO extends BusinessBaseDO { @TableField("RMNG_VOL") private BigDecimal remainingVolume; /** + * 初始总量 + */ + @TableField("INIT_VOL") + private BigDecimal initialVolume; + /** * 用完标记,0-未标记,1-已用完标记 */ @TableField("USE_END_FLG") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java index c5cdb6a8..1d29c751 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java @@ -16,7 +16,6 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialStandardS import org.apache.ibatis.annotations.Mapper; import java.util.List; -import java.util.Set; /** * 物料实例 Mapper @@ -123,7 +122,7 @@ public interface MaterialInfomationMapper extends BaseMapperX selectOneWithPdtInfoByInfIds(List ids) { + default List selectListWithPdtInfoByInfIds(List ids) { MPJLambdaWrapper wrapper = getInfomationDOMPJLambdaWrapper(); wrapper.in(MaterialInfomationDO::getId, ids); return selectJoinList(MaterialInfomationRespVO.class, wrapper); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialUseRecordMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialUseRecordMapper.java index 5520e578..9f850a42 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialUseRecordMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialUseRecordMapper.java @@ -7,9 +7,12 @@ import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordRespVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialUseRecordDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 使用记录 Mapper * @@ -42,6 +45,9 @@ public interface MaterialUseRecordMapper extends BaseMapperX selectListWithInf(List ids) { + MPJLambdaWrapperX wrapperX = new MPJLambdaWrapperX() + .selectAll(MaterialUseRecordDO.class) + .selectAs(MaterialInfomationDO::getCode, MaterialUseRecordRespVO::getInfomationCode) + .selectAs(MaterialProductDO::getName, MaterialUseRecordRespVO::getInfomationName) + .selectAs(MaterialProductDO::getModelNo, MaterialUseRecordRespVO::getModelNo) + .leftJoin(MaterialInfomationDO.class, MaterialInfomationDO::getId, MaterialUseRecordDO::getInfomationId) + .leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId) + .in(MaterialUseRecordDO::getId, ids); + return selectJoinList(MaterialUseRecordRespVO.class, wrapperX); + } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java index 5ffbaf73..05ba60f8 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java @@ -1,12 +1,16 @@ package com.zt.plat.module.qms.resource.material.service; +import java.math.BigDecimal; import java.util.*; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationSaveReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialInfomationQueryVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialStandardSolutionDO; import jakarta.validation.*; import com.zt.plat.framework.common.pojo.PageResult; @@ -145,4 +149,35 @@ public interface MaterialInfomationService { * @return 物料信息 */ List getMaterialInfomationsWithPdtInfoByIds(List ids); + + /** + * 保存物料信息 - 危化品配置生成 + * + * @param product 大类信息 + * @param totalOperationQuantity 总操作数量 + * @param productId 大类id + * @return 物料信息 + */ + MaterialInfomationDO saveMaterialInfomationByHzrdMtrlMake(MaterialProductDO product, BigDecimal totalOperationQuantity, Long productId); + + /** + * 批量保存物料信息 - 标准溶液配置生成生成 + * + * @param productId 大类id + * @param mtrlStandSol 标液 + * @return 物料信息 + */ + MaterialInfomationDO saveMaterialInfomationByStdSolMake(Long productId, MaterialStandardSolutionDO mtrlStandSol); + + /** + * 批量保存物料信息 - 批次入库生成 + * + * @param locationId 位置id + * @param reqQuantity 数量 + * @param gongduanId 工段id + * @param product 大类信息 + * @param batch 批次信息 + * @return 物料信息 + */ + List saveMaterialInfomationsByBatInb(Long locationId, BigDecimal reqQuantity, Long gongduanId, MaterialProductDO product, MaterialBatchDO batch); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java index 8d466b6f..3ac31dea 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java @@ -5,22 +5,27 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.module.qms.core.code.SequenceUtil; +import com.zt.plat.module.qms.resource.material.constant.MaterialConstants; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationSaveReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialInfomationQueryVO; -import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.*; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInfomationMapper; +import com.zt.plat.module.qms.resource.material.enums.MaterialInfomationOrigin; import groovy.util.logging.Slf4j; import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_INFOMATION_NOT_EXISTS; @@ -38,6 +43,11 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService @Resource private MaterialInfomationMapper materialInfomationMapper; + @Autowired + private SequenceUtil sequenceUtil; + @Lazy + @Autowired + private MaterialUseRecordDetailService materialUseRecordDetailService; @Override public MaterialInfomationRespVO createMaterialInfomation(MaterialInfomationSaveReqVO createReqVO) { @@ -119,7 +129,24 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService @Override public PageResult getMaterialInfomationPageWithPdtInfo(MaterialInfomationPageReqVO pageReqVO) { - return materialInfomationMapper.selectPageWithPdtInfo(pageReqVO); + PageResult pageResult = materialInfomationMapper.selectPageWithPdtInfo(pageReqVO); + if (pageReqVO.getNeedDetectExistHazardousMake()) { + List infomationRespVOS = pageResult.getList(); + if (CollUtil.isEmpty(infomationRespVOS)) return pageResult; + List infIds = infomationRespVOS.stream().map(MaterialInfomationRespVO::getId).toList(); + List detailsByInfIds = materialUseRecordDetailService.getMaterialUseRecordDetailsByInfIds(infIds); + if (CollUtil.isEmpty(detailsByInfIds)) return pageResult; + Set relatedInfIds = detailsByInfIds.stream() + .flatMap(detail -> Stream.of(detail.getInfomationId(), detail.getTargetInfomationId())) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + + for (MaterialInfomationRespVO infomationRespVO : infomationRespVOS) { + infomationRespVO.setExistHazardousMake(relatedInfIds.contains(infomationRespVO.getId())); + } + pageResult.setList(infomationRespVOS); + } + return pageResult; } @Override @@ -162,7 +189,70 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService @Override public List getMaterialInfomationsWithPdtInfoByIds(List ids) { - return materialInfomationMapper.selectOneWithPdtInfoByInfIds(ids); + return materialInfomationMapper.selectListWithPdtInfoByInfIds(ids); + } + + @Override + public MaterialInfomationDO saveMaterialInfomationByHzrdMtrlMake(MaterialProductDO product, BigDecimal totalOperationQuantity, Long productId) { + MaterialInfomationDO infomationDO = BeanUtils.toBean(product, MaterialInfomationDO.class); + infomationDO + .setId(null) + .setInitialVolume(totalOperationQuantity) + .setRemainingVolume(totalOperationQuantity) + .setProductId(productId) + .setCode(sequenceUtil.genCode(MaterialConstants.SEQUENCE_INF_KEY)) + .setManufacturerDate(LocalDate.now()) + .setExpirationDate(LocalDate.now().plusDays(product.getDue())) + .setUsageStatus(0) + .setUseEndFlag(0) + .setOrigin(MaterialInfomationOrigin.hazardousMaterialMake.name()); + this.save(infomationDO); + return infomationDO; + } + + @Override + public MaterialInfomationDO saveMaterialInfomationByStdSolMake(Long productId, MaterialStandardSolutionDO mtrlStandSol) { + MaterialInfomationDO infomationDO = new MaterialInfomationDO(); + infomationDO + .setProductId(productId) + .setCode(sequenceUtil.genCode(MaterialConstants.SEQUENCE_INF_KEY)) + .setManufacturerDate(LocalDate.from(mtrlStandSol.getMakeDate())) + .setExpirationDate(LocalDate.from(mtrlStandSol.getDueDate())) + .setUsageStatus(0) + .setUseEndFlag(0) + .setOrigin(MaterialInfomationOrigin.standardSolutionMake.name()); + this.save(infomationDO); + return infomationDO; + } + + @Override + public List saveMaterialInfomationsByBatInb(Long locationId, BigDecimal reqQuantity, Long gongduanId, MaterialProductDO product, MaterialBatchDO batch) { + List infomationDOS = new ArrayList<>(); + for (int i = 0; i < reqQuantity.intValue(); i++) { + MaterialInfomationDO infomationDO = new MaterialInfomationDO(); + infomationDO + .setProductId(product.getId()).setBatchId(batch.getId()) + .setLocationId(locationId) + .setGongduanId(gongduanId) + .setName(product.getName()) + .setSpecification(product.getSpecification()).setModelNo(product.getModelNo()) + .setParameter(product.getParameter()) + .setManufacturer(product.getManufacturer()).setUnit(product.getUnit()) + .setDue(product.getDue()).setOpenDueAfter(product.getOpenDueAfter()) + .setPublishStatus(0) + .setUsageStatus(0) + .setOpenStatus(0) + .setManufacturerDate(batch.getManufacturerDate()).setExpirationDate(batch.getDueDate()) + .setInitialVolume(product.getStandardCapacity()) + .setRemainingVolume(product.getStandardCapacity()) + .setOrigin(MaterialInfomationOrigin.batchInbound.name()); + // 生成编号 + String code = sequenceUtil.genCode(MaterialConstants.SEQUENCE_INF_KEY); + infomationDO.setCode(code); + infomationDOS.add(infomationDO); + } + this.saveBatch(infomationDOS); + return infomationDOS; } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundDetailService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundDetailService.java index cc514893..34493298 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundDetailService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundDetailService.java @@ -4,6 +4,8 @@ import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDetailDO; import jakarta.validation.Valid; @@ -83,4 +85,14 @@ public interface MaterialInventoryInboundDetailService { * @return 物料列表 */ List getMaterialInfoListByInboundId(Long inboundId); + + /** + * 保存入库单明细 + * + * @param infomationDOS 物料信息 + * @param inbound 入库单 + * @param batchId 批次ID + * @param gongduanId 工段ID + */ + void saveInboundDetails(List infomationDOS, MaterialInventoryInboundDO inbound, Long batchId, Long gongduanId); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundDetailServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundDetailServiceImpl.java index 1db9d584..7a11b88a 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundDetailServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundDetailServiceImpl.java @@ -6,12 +6,15 @@ import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDetailDO; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryInboundDetailMapper; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import java.util.ArrayList; import java.util.List; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -104,4 +107,24 @@ public class MaterialInventoryInboundDetailServiceImpl implements MaterialInvent return materialInventoryInboundDetailMapper.selectMaterialInfoListByInboundId(inboundId); } + @Override + public void saveInboundDetails(List infomationDOS, MaterialInventoryInboundDO inbound, Long batchId, Long gongduanId) { + List detailList = new ArrayList<>(); + for (MaterialInfomationDO infomationDO : infomationDOS) { + MaterialInventoryInboundDetailDO detail = new MaterialInventoryInboundDetailDO(); + detail + .setInboundId(inbound.getId()) + .setBatchId(batchId) + .setBatchGongduanId(gongduanId) + .setMaterialInfomationId(infomationDO.getId()) + .setInboundUserName(inbound.getApplyUser()) + .setInboundUserId(inbound.getApplyUserId()) + .setInboundDepartmentName(inbound.getApplyDepartment()) + .setInboundDepartmentId(inbound.getApplyDepartmentId()) + .setInboundTime(inbound.getApplyTime()); + detailList.add(detail); + } + this.saveBatch(detailList); + } + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java index 6213c2c4..a89835a2 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java @@ -19,6 +19,7 @@ import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryInbo import com.zt.plat.module.qms.resource.material.enums.MaterialAcceptStatus; import com.zt.plat.module.qms.resource.material.enums.MaterialInfomationOrigin; import jakarta.annotation.Resource; +import org.jspecify.annotations.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -46,16 +47,11 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb @Resource private MaterialInventoryInboundMapper materialInventoryInboundMapper; - - @Autowired - private MaterialLifecycleDetailService materialLifecycleDetailService; @Autowired private MaterialBatchService materialBatchService; @Autowired private MaterialProductService materialProductService; @Autowired - private SequenceUtil sequenceUtil; - @Autowired private MaterialInfomationService materialInfomationService; @Autowired private MaterialInventoryInboundDetailService materialInventoryInboundDetailService; @@ -86,15 +82,7 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb if (totalQuantity.compareTo(gongDO.getInboundQuantity()) > 0) throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段数量"); } // 3.保存入库记录 - MaterialInventoryInboundDO inbound = BeanUtils.toBean(createReqVO, MaterialInventoryInboundDO.class); - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - if (loginUser == null) throw exception(USER_NOT_EXISTS); - String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname(); - inbound.setApplyUser(loginUserNickname).setApplyUserId(loginUser.getId()) - .setApplyDepartment(loginUser.getVisitDeptName()).setApplyDepartmentId(loginUser.getVisitDeptId()) - .setApplyTime(LocalDateTime.now()) - .setRemark(gongDO.getRemark()); - materialInventoryInboundMapper.insert(inbound); + MaterialInventoryInboundDO inbound = saveInbound(createReqVO, gongDO); // 4.生成物料实例 Long productId = gongDO.getProductId(); MaterialProductDO product = materialProductService.getMaterialProduct(productId); @@ -103,47 +91,10 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb Long batchId = gongDO.getParentId(); MaterialBatchDO batch = materialBatchService.getMaterialBatch(batchId); if (batch == null || batch.getParentId() != 0) throw exception(MATERIAL_BATCH_NOT_EXISTS); - List infomationDOS = new ArrayList<>(); - for (int i = 0; i < reqQuantity.intValue(); i++) { - MaterialInfomationDO infomationDO = new MaterialInfomationDO(); - infomationDO - .setProductId(productId).setBatchId(batchId) - .setLocationId(createReqVO.getLocationId()) - .setGongduanId(gongduanId) - .setName(product.getName()) - .setSpecification(product.getSpecification()).setModelNo(product.getModelNo()) - .setParameter(product.getParameter()) - .setManufacturer(product.getManufacturer()).setUnit(product.getUnit()) - .setDue(product.getDue()).setOpenDueAfter(product.getOpenDueAfter()) - .setPublishStatus(0) - .setUsageStatus(0) - .setOpenStatus(0) - .setManufacturerDate(batch.getManufacturerDate()).setExpirationDate(batch.getDueDate()) - .setRemainingVolume(product.getStandardCapacity()) - .setOrigin(MaterialInfomationOrigin.batchInbound.name()); - // 生成编号 - String code = sequenceUtil.genCode(MaterialConstants.SEQUENCE_INF_KEY); - infomationDO.setCode(code); - infomationDOS.add(infomationDO); - } - materialInfomationService.saveBatch(infomationDOS); + Long locationId = createReqVO.getLocationId(); + List infomationDOS = materialInfomationService.saveMaterialInfomationsByBatInb(locationId, reqQuantity, gongduanId, product, batch); // 5.保存入库明细 - List detailList = new ArrayList<>(); - for (MaterialInfomationDO infomationDO : infomationDOS) { - MaterialInventoryInboundDetailDO detail = new MaterialInventoryInboundDetailDO(); - detail - .setInboundId(inbound.getId()) - .setBatchId(batchId) - .setBatchGongduanId(gongduanId) - .setMaterialInfomationId(infomationDO.getId()) - .setInboundUserName(loginUserNickname) - .setInboundUserId(loginUser.getId()) - .setInboundDepartmentName(loginUser.getVisitDeptName()) - .setInboundDepartmentId(loginUser.getVisitDeptId()) - .setInboundTime(inbound.getApplyTime()); - detailList.add(detail); - } - materialInventoryInboundDetailService.saveBatch(detailList); + materialInventoryInboundDetailService.saveInboundDetails(infomationDOS, inbound, batchId, gongduanId); // 更新工段已入库数量 gongDO.setInboundEndQuantity(gongDO.getInboundEndQuantity().add(reqQuantity)); materialBatchService.updateMaterialBatchInbEndQty(gongDO); @@ -157,6 +108,19 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb return respVO; } + private MaterialInventoryInboundDO saveInbound(MaterialInventoryInboundSaveReqVO createReqVO, MaterialBatchDO gongDO) { + MaterialInventoryInboundDO inbound = BeanUtils.toBean(createReqVO, MaterialInventoryInboundDO.class); + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + if (loginUser == null) throw exception(USER_NOT_EXISTS); + String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname(); + inbound.setApplyUser(loginUserNickname).setApplyUserId(loginUser.getId()) + .setApplyDepartment(loginUser.getVisitDeptName()).setApplyDepartmentId(loginUser.getVisitDeptId()) + .setApplyTime(LocalDateTime.now()) + .setRemark(gongDO.getRemark()); + materialInventoryInboundMapper.insert(inbound); + return inbound; + } + @Override public void updateMaterialInventoryInbound(MaterialInventoryInboundSaveReqVO updateReqVO) { // 校验存在 diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionServiceImpl.java index e1fdc715..68c09bfa 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionServiceImpl.java @@ -21,6 +21,7 @@ import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialStandardSolut import com.zt.plat.module.qms.resource.material.enums.MaterialInfomationOrigin; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; +import org.jspecify.annotations.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -92,16 +93,7 @@ public class MaterialStandardSolutionServiceImpl implements MaterialStandardSolu mtrlStandSol.setDetailId(detailId); } // 生成物料 - MaterialInfomationDO infomationDO = new MaterialInfomationDO(); - infomationDO - .setProductId(productId) - .setCode(sequenceUtil.genCode(MaterialConstants.SEQUENCE_INF_KEY)) - .setManufacturerDate(LocalDate.from(mtrlStandSol.getMakeDate())) - .setExpirationDate(LocalDate.from(mtrlStandSol.getDueDate())) - .setUsageStatus(0) - .setUseEndFlag(0) - .setOrigin(MaterialInfomationOrigin.standardSolutionMake.name()); - materialInfomationService.save(infomationDO); + MaterialInfomationDO infomationDO = materialInfomationService.saveMaterialInfomationByStdSolMake(productId, mtrlStandSol); // 插入 mtrlStandSol.setInfomationId(infomationDO.getId()); materialStandardSolutionMapper.insert(mtrlStandSol); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailService.java index 59cf71d4..5986d62e 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailService.java @@ -85,4 +85,12 @@ public interface MaterialUseRecordDetailService { * @return 是否存在危化品配置信息 */ Boolean checkIsExistMakeInfoByRecordIds(List recordIds); + + /** + * 根据危化品信息编号获取使用记录详情列表 + * + * @param infIds 危化品信息编号 + * @return 使用记录详情 + */ + List getMaterialUseRecordDetailsByInfIds(List infIds); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailServiceImpl.java index 5f3e34f7..e509c833 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailServiceImpl.java @@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; -import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO; -import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordDetailPageReqVO; -import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordDetailRespVO; -import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordDetailSaveReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.*; import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialUseRecordWithMakeInfoQueryVO; import com.zt.plat.module.qms.resource.material.controller.vo.resp.MaterialUseRecordWithMakeInfoRespVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; @@ -16,14 +13,12 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialUseRecord import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialUseRecordDetailMapper; import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -44,6 +39,9 @@ public class MaterialUseRecordDetailServiceImpl implements MaterialUseRecordDeta private MaterialUseRecordDetailMapper materialUseRecordDetailMapper; @Autowired private MaterialInfomationService materialInfomationService; + @Lazy + @Autowired + private MaterialUseRecordService materialUseRecordService; @Override public MaterialUseRecordDetailRespVO createMaterialUseRecordDetail(MaterialUseRecordDetailSaveReqVO createReqVO) { @@ -115,34 +113,51 @@ public class MaterialUseRecordDetailServiceImpl implements MaterialUseRecordDeta LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); if (infomationId != null) { // 根据物料id查询 - wrapper = Wrappers.lambdaQuery(MaterialUseRecordDetailDO.class) + List detailDOS = materialUseRecordDetailMapper.selectList(Wrappers.lambdaQuery(MaterialUseRecordDetailDO.class) .eq(MaterialUseRecordDetailDO::getInfomationId, infomationId) .or() - .eq(MaterialUseRecordDetailDO::getTargetInfomationId, infomationId); + .eq(MaterialUseRecordDetailDO::getTargetInfomationId, infomationId)); + if (CollUtil.isEmpty(detailDOS)) return List.of(); + Set targetInfomationIds = detailDOS.stream().map(MaterialUseRecordDetailDO::getTargetInfomationId).collect(Collectors.toSet()); + wrapper = Wrappers.lambdaQuery(MaterialUseRecordDetailDO.class) + .in(MaterialUseRecordDetailDO::getTargetInfomationId, targetInfomationIds); } else if (recordId != null) { // 根据使用记录id查询 wrapper = Wrappers.lambdaQuery(MaterialUseRecordDetailDO.class) .eq(MaterialUseRecordDetailDO::getRecordId, recordId); } - List recordDetailDOS = materialUseRecordDetailMapper.selectList(wrapper); + // 获取物料存在的全部配置 + List recordDetailDOS = materialUseRecordDetailMapper.selectList( + wrapper.orderByDesc(MaterialUseRecordDetailDO::getId)); if (CollUtil.isEmpty(recordDetailDOS)) return List.of(); - Set informationIds = recordDetailDOS.stream() - .flatMap(detail -> Stream.of(detail.getInfomationId(), detail.getTargetInfomationId())) + // 获取配置生成的物料 + Set targetInfomationIds = recordDetailDOS.stream().map(MaterialUseRecordDetailDO::getTargetInfomationId) .collect(Collectors.toSet()); - List infomationRespVOS = materialInfomationService.getMaterialInfomationsWithPdtInfoByIds(new ArrayList<>(informationIds)); - if (CollUtil.isEmpty(infomationRespVOS)) return List.of(); - Map infomationRespVOMapById = infomationRespVOS.stream().collect(Collectors.toMap(MaterialInfomationRespVO::getId, Function.identity())); - Map> recordDetailMapByTargetInfId = recordDetailDOS.stream().collect(Collectors.groupingBy(MaterialUseRecordDetailDO::getTargetInfomationId)); - ArrayList result = new ArrayList<>(); - recordDetailMapByTargetInfId.forEach((targetInfId, detailDOS) -> { - MaterialUseRecordWithMakeInfoRespVO makeInfoRespVO = new MaterialUseRecordWithMakeInfoRespVO(); - makeInfoRespVO.setTargetInfo(infomationRespVOMapById.get(targetInfId)); - List infIds = detailDOS.stream().map(MaterialUseRecordDetailDO::getInfomationId).toList(); - List infomationRespVOS1 = infIds.stream().map(infomationRespVOMapById::get).toList(); - makeInfoRespVO.setMakeInfoList(infomationRespVOS1); - result.add(makeInfoRespVO); + List targetInfomationRespVOS = materialInfomationService + .getMaterialInfomationsWithPdtInfoByIds(new ArrayList<>(targetInfomationIds)); + if (CollUtil.isEmpty(targetInfomationRespVOS)) return List.of(); + // 获取使用记录 + Set recordIds = recordDetailDOS.stream().map(MaterialUseRecordDetailDO::getRecordId).collect(Collectors.toSet()); + List recordRespVOS = materialUseRecordService.getUseRecordsWithMaterialInfoByIds(new ArrayList<>(recordIds)); + + List result = new ArrayList<>(); + Map> detailMapByTargetInfId = recordDetailDOS.stream().collect(Collectors.groupingBy(MaterialUseRecordDetailDO::getTargetInfomationId)); + Map targetInfoRespVOMapById = targetInfomationRespVOS.stream().collect(Collectors.toMap(MaterialInfomationRespVO::getId, Function.identity())); + Map recordRespVOMap = recordRespVOS.stream() + .collect(Collectors.toMap(MaterialUseRecordRespVO::getId, Function.identity())); + detailMapByTargetInfId.forEach((targetInfId, detailDOS) -> { + MaterialUseRecordWithMakeInfoRespVO respVO = new MaterialUseRecordWithMakeInfoRespVO(); + respVO.setTargetInfo(targetInfoRespVOMapById.get(targetInfId)); + List makeRecordVOS = detailDOS.stream() + .map(MaterialUseRecordDetailDO::getRecordId) + .map(recordRespVOMap::get) + .filter(Objects::nonNull) + .toList(); + respVO.setMakeInfoList(makeRecordVOS); + result.add(respVO); }); + return result; } @@ -152,4 +167,13 @@ public class MaterialUseRecordDetailServiceImpl implements MaterialUseRecordDeta .in(MaterialUseRecordDetailDO::getRecordId, recordIds)); } + @Override + public List getMaterialUseRecordDetailsByInfIds(List infIds) { + + return materialUseRecordDetailMapper.selectList(Wrappers.lambdaQuery(MaterialUseRecordDetailDO.class) + .in(MaterialUseRecordDetailDO::getInfomationId, infIds) + .or() + .in(MaterialUseRecordDetailDO::getTargetInfomationId, infIds)); + } + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordService.java index b3ac7c42..1631e0d7 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordService.java @@ -5,6 +5,7 @@ import com.zt.plat.module.qms.resource.material.controller.vo.*; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialUseRecordDO; import jakarta.validation.Valid; +import java.util.ArrayList; import java.util.List; /** @@ -74,4 +75,12 @@ public interface MaterialUseRecordService { * @return 使用记录分页 */ PageResult getMaterialUseRecordPageWithInf(@Valid MaterialUseRecordPageReqVO pageReqVO); + + /** + * 获得使用记录列表 - 含物料信息 + * + * @param ids id集合 + * @return 使用记录列表 + */ + List getUseRecordsWithMaterialInfoByIds(List ids); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordServiceImpl.java index d35b08ed..a7bb12f3 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordServiceImpl.java @@ -16,6 +16,7 @@ import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialUseRecordMapp import com.zt.plat.module.qms.resource.material.enums.MaterialInfomationOrigin; import com.zt.plat.module.qms.resource.material.enums.MaterialOutboundType; import jakarta.annotation.Resource; +import org.jspecify.annotations.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -48,8 +49,7 @@ public class MaterialUseRecordServiceImpl implements MaterialUseRecordService { @Autowired private MaterialProductService materialProductService; - @Autowired - private SequenceUtil sequenceUtil; + @Autowired private MaterialUseRecordDetailService materialUseRecordDetailService; @Autowired @@ -79,7 +79,13 @@ public class MaterialUseRecordServiceImpl implements MaterialUseRecordService { // 更新物料剩余量 infomationDO.setRemainingVolume(remainingVolume.subtract(operationQuantity)); + // 物料用完 + if (operationQuantity.compareTo(remainingVolume) >= 0) { + infomationDO.setUseEndFlag(1); + // TODO 新增用完标记记录 + } materialInfomationService.updateById(infomationDO); + // 返回 return BeanUtils.toBean(recordDO, MaterialUseRecordRespVO.class); } @@ -172,6 +178,43 @@ public class MaterialUseRecordServiceImpl implements MaterialUseRecordService { if (reduce.compareTo(infomation.getRemainingVolume()) > 0) throw new ServiceException(1_032_160_000, "使用量不能大于剩余量"); } // 保存使用记录 + List recordDOS = saveMaterialUseRecordDOS(infomations, records); + + // 更新物料剩余量 + updateInfomationsRemainingVolume(recordDOS, infomations); + + // 生成物料实例 + MaterialInfomationDO infomationDO = materialInfomationService.saveMaterialInfomationByHzrdMtrlMake(product, totalOperationQuantity, productId); + // 保存配置明细 + List recordDetailDOS = recordDOS.stream().map(record -> new MaterialUseRecordDetailDO() + .setRecordId(record.getId()).setInfomationId(record.getInfomationId()) + .setTargetInfomationId(infomationDO.getId())).toList(); + materialUseRecordDetailService.saveBatch(recordDetailDOS); + + // 保存领用记录 + MaterialInventoryOutboundSaveReqVO outboundSaveReqVO = new MaterialInventoryOutboundSaveReqVO() + .setBusinessType(MaterialOutboundType.receiveOutbound.getName()) + .setInfomationIds(Collections.singletonList(infomationDO.getId())) + .setApplyUser(recordDOS.get(0).getUserName()).setApplyUserId(recordDOS.get(0).getUserId()) + .setSuperviseUser(recordDOS.get(0).getSupervisorName()) + .setSuperviseUserId(recordDOS.get(0).getSupervisorId()); + materialInventoryOutboundService.createMaterialInventoryOutbound(outboundSaveReqVO); + return materialInfomationService.getMaterialInfomationWithPdtInfoByInfId(infomationDO.getId()); + } + + + + private void updateInfomationsRemainingVolume(List recordDOS, List infomations) { + Map> groupRecordDOSByInfId = recordDOS.stream().collect(Collectors.groupingBy(MaterialUseRecordDO::getInfomationId)); + for (MaterialInfomationDO infomation : infomations) { + List recordDOS1 = groupRecordDOSByInfId.get(infomation.getId()); + BigDecimal totalOperationQuantity1 = recordDOS1.stream().map(MaterialUseRecordDO::getOperationQuantity).reduce(BigDecimal.ZERO, BigDecimal::add); + infomation.setRemainingVolume(infomation.getRemainingVolume().subtract(totalOperationQuantity1)); + } + materialInfomationService.updateBatch(infomations); + } + + private List saveMaterialUseRecordDOS(List infomations, List records) { Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname(); Map infomationDOMapById = infomations.stream().collect(Collectors.toMap(MaterialInfomationDO::getId, Function.identity())); @@ -191,43 +234,7 @@ public class MaterialUseRecordServiceImpl implements MaterialUseRecordService { return recordDO; }).toList(); materialUseRecordMapper.insertBatch(recordDOS); - - // 更新物料剩余量 - Map> groupRecordDOSByInfId = recordDOS.stream().collect(Collectors.groupingBy(MaterialUseRecordDO::getInfomationId)); - for (MaterialInfomationDO infomation : infomations) { - List recordDOS1 = groupRecordDOSByInfId.get(infomation.getId()); - BigDecimal totalOperationQuantity1 = recordDOS1.stream().map(MaterialUseRecordDO::getOperationQuantity).reduce(BigDecimal.ZERO, BigDecimal::add); - infomation.setRemainingVolume(infomation.getRemainingVolume().subtract(totalOperationQuantity1)); - } - materialInfomationService.updateBatch(infomations); - - // 生成物料实例 - MaterialInfomationDO infomationDO = BeanUtils.toBean(product, MaterialInfomationDO.class); - infomationDO - .setId(null).setRemainingVolume(totalOperationQuantity) - .setProductId(productId) - .setCode(sequenceUtil.genCode(MaterialConstants.SEQUENCE_INF_KEY)) - .setManufacturerDate(LocalDate.now()) - .setExpirationDate(LocalDate.now().plusDays(product.getDue())) - .setUsageStatus(0) - .setUseEndFlag(0) - .setOrigin(MaterialInfomationOrigin.hazardousMaterialMake.name()); - materialInfomationService.save(infomationDO); - // 保存配置明细 - List recordDetailDOS = recordDOS.stream().map(record -> new MaterialUseRecordDetailDO() - .setRecordId(record.getId()).setInfomationId(record.getInfomationId()) - .setTargetInfomationId(infomationDO.getId())).toList(); - materialUseRecordDetailService.saveBatch(recordDetailDOS); - - // 保存领用记录 - MaterialInventoryOutboundSaveReqVO outboundSaveReqVO = new MaterialInventoryOutboundSaveReqVO() - .setBusinessType(MaterialOutboundType.receiveOutbound.getName()) - .setInfomationIds(Collections.singletonList(infomationDO.getId())) - .setApplyUser(recordDOS.get(0).getUserName()).setApplyUserId(recordDOS.get(0).getUserId()) - .setSuperviseUser(recordDOS.get(0).getSupervisorName()) - .setSuperviseUserId(recordDOS.get(0).getSupervisorId()); - materialInventoryOutboundService.createMaterialInventoryOutbound(outboundSaveReqVO); - return materialInfomationService.getMaterialInfomationWithPdtInfoByInfId(infomationDO.getId()); + return recordDOS; } @Override @@ -235,4 +242,10 @@ public class MaterialUseRecordServiceImpl implements MaterialUseRecordService { return materialUseRecordMapper.selectPageWithInf(pageReqVO); } + @Override + public List getUseRecordsWithMaterialInfoByIds(List ids) { + + return materialUseRecordMapper.selectListWithInf(ids); + } + } \ No newline at end of file From fcb1dbf7f54d4fcd50b63a96c4e1a2bf9f064215 Mon Sep 17 00:00:00 2001 From: shusir <497819738@qq.com> Date: Fri, 27 Feb 2026 10:08:21 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=E7=B3=BB=E7=BB=9F=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E9=99=90=E5=88=B6=EF=BC=8C=E7=89=A9=E6=96=99=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qms/core/constant/CommonConstant.java | 14 ++++++++++ .../material/constant/MaterialConstants.java | 3 ++- .../MaterialInventoryInboundServiceImpl.java | 26 +++++++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/core/constant/CommonConstant.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/core/constant/CommonConstant.java index fc354922..a19b8ef3 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/core/constant/CommonConstant.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/core/constant/CommonConstant.java @@ -1,5 +1,7 @@ package com.zt.plat.module.qms.core.constant; +import java.math.BigDecimal; + public class CommonConstant { @@ -75,4 +77,16 @@ public class CommonConstant { //================数据库常量====================== public static final String SQL_WHERE = "where"; + //================数量限制======================== + /** + * 单次最大生成数量(防止系统资源耗尽) + */ + public static final BigDecimal MAX_GENERATE_QUANTITY = new BigDecimal("10000"); + + /** + * 单次最大响应数量(防止响应数据过大) + */ + public static final BigDecimal MAX_RESPONSE_QUANTITY = new BigDecimal("1000"); + + } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/constant/MaterialConstants.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/constant/MaterialConstants.java index d32f488c..2f2045fd 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/constant/MaterialConstants.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/constant/MaterialConstants.java @@ -4,8 +4,9 @@ package com.zt.plat.module.qms.resource.material.constant; * 物料常量 */ public class MaterialConstants { - // 字典 类型 + // 字典 public static final String DICT_MATERIAL_FLOW_TYPE = "jy_material_lifecycle_bsn_type"; + public static final String DICT_MATERIAL_INBOUND_QUANTITY_LIMIT = "materialInboundQuantityLimit"; // 序列号 public static final String SEQUENCE_INF_KEY = "QMS_MATERIAL_INF_NO"; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java index a89835a2..9c5daa40 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryInboundServiceImpl.java @@ -1,13 +1,18 @@ package com.zt.plat.module.qms.resource.material.service; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.exception.ServiceException; +import com.zt.plat.framework.common.pojo.CommonResult; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.security.core.LoginUser; import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; +import com.zt.plat.module.qms.common.dic.controller.vo.DictionaryBusinessRespVO; +import com.zt.plat.module.qms.common.dic.service.DictionaryBusinessService; import com.zt.plat.module.qms.core.code.SequenceUtil; +import com.zt.plat.module.qms.core.constant.CommonConstant; import com.zt.plat.module.qms.core.constant.DataTypeConstant; import com.zt.plat.module.qms.resource.material.constant.MaterialConstants; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailRespVO; @@ -55,6 +60,8 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb private MaterialInfomationService materialInfomationService; @Autowired private MaterialInventoryInboundDetailService materialInventoryInboundDetailService; + @Autowired + private DictionaryBusinessService dictionaryBusinessService; @Transactional @@ -63,6 +70,19 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb Long gongduanId = createReqVO.getGongduanId(); BigDecimal reqQuantity = createReqVO.getQuantity(); if (reqQuantity.compareTo(BigDecimal.ZERO) <= 0) throw new ServiceException(1_032_160_000, "入库数量不能小于等于0"); + CommonResult inboundQuantityLimitResult = dictionaryBusinessService.getDataByDataKey(MaterialConstants.DICT_MATERIAL_INBOUND_QUANTITY_LIMIT); + DictionaryBusinessRespVO inboundQuantityLimit = inboundQuantityLimitResult.getData(); + if (reqQuantity.compareTo(CommonConstant.MAX_GENERATE_QUANTITY) > 0 + || reqQuantity.compareTo(CommonConstant.MAX_RESPONSE_QUANTITY) > 0) + throw new ServiceException(1_032_160_000, + String.format("入库数量不能超过系统限制数量:%s", Math.min(CommonConstant.MAX_GENERATE_QUANTITY.doubleValue(), CommonConstant.MAX_RESPONSE_QUANTITY.doubleValue()))); + if (inboundQuantityLimit != null) { + BigDecimal inbQtyLimit = new BigDecimal(inboundQuantityLimit.getValue()); + if (reqQuantity.compareTo(inbQtyLimit) > 0) { + throw new ServiceException(1_032_160_000, + String.format("入库数量超出配置限制:%s,当前请求数量:%s", inbQtyLimit, reqQuantity)); + } + } MaterialBatchDO gongDO = materialBatchService.getMaterialBatch(gongduanId); if (gongDO == null) throw exception(MATERIAL_BATCH_GONG_NOT_EXISTS); // 1.检查工段是否已经验收 @@ -70,7 +90,6 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb throw new ServiceException(1_032_160_000, "工段未验收,不能入库"); // 2.入库数量不大于批次工段数量 - if (reqQuantity.compareTo(gongDO.getInboundQuantity()) > 0) throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段数量"); // TODO 这儿应该调整为去物料实例统计出此工段的入库数量 List inboundDOS = materialInventoryInboundMapper.selectList(Wrappers.lambdaQuery(MaterialInventoryInboundDO.class) .eq(MaterialInventoryInboundDO::getGongduanId, gongduanId)); @@ -79,7 +98,10 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb for (MaterialInventoryInboundDO inboundDO : inboundDOS) { totalQuantity = totalQuantity.add(inboundDO.getQuantity()); } - if (totalQuantity.compareTo(gongDO.getInboundQuantity()) > 0) throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段数量"); + if (totalQuantity.compareTo(gongDO.getInboundQuantity()) > 0) + throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段未入库数量"); + } else if (reqQuantity.compareTo(gongDO.getInboundQuantity()) > 0) { + throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段数量"); } // 3.保存入库记录 MaterialInventoryInboundDO inbound = saveInbound(createReqVO, gongDO);