From 4a94b0c84129614269b43dafa9c4c91f972d7204 Mon Sep 17 00:00:00 2001 From: shusir <497819738@qq.com> Date: Wed, 11 Feb 2026 16:47:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=94=B3=E8=AF=B7=E8=BF=87=E5=92=8C?= =?UTF-8?q?=E9=9D=9E=E7=94=B3=E8=AF=B7=E7=9A=84=E6=BA=B6=E6=B6=B2=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/service/DeviceProductService.java | 7 + .../service/DeviceProductServiceImpl.java | 14 ++ .../material/constant/MaterialConstants.java | 6 + .../admin/MaterialInventoryController.java | 38 ----- .../admin/MaterialLifecycleController.java | 6 +- .../admin/MaterialProductController.java | 8 + .../MaterialStandardSolutionController.java | 28 +++- .../vo/DeviceInfomationRespVOBySol.java | 60 +++++++ .../DeviceProductWithInfomationsRespVO.java | 52 ++++++ .../vo/MaterialInfomationRespVO.java | 8 +- .../vo/MaterialLifecycleDetailRespVO.java | 9 +- .../vo/MaterialStandardSolutionRespVO.java | 4 + .../vo/MaterialStandardSolutionSaveReqVO.java | 13 ++ .../MaterialStandardSolutionDO.java | 5 + .../dal/mapper/MaterialInfomationMapper.java | 12 +- .../mapper/MaterialLifecycleDetailMapper.java | 16 +- .../MaterialStandardSolutionMapper.java | 11 ++ .../service/MaterialInfomationService.java | 14 ++ .../MaterialInfomationServiceImpl.java | 10 ++ .../MaterialInventoryInboundServiceImpl.java | 5 +- .../MaterialLifecycleDetailService.java | 9 + .../MaterialLifecycleDetailServiceImpl.java | 15 ++ .../service/MaterialLifecycleService.java | 8 + .../service/MaterialLifecycleServiceImpl.java | 111 ++++++++----- .../MaterialStandardSolutionService.java | 26 +++ .../MaterialStandardSolutionServiceImpl.java | 157 ++++++++++++++++-- 26 files changed, 533 insertions(+), 119 deletions(-) delete mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryController.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/DeviceInfomationRespVOBySol.java create mode 100644 zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/DeviceProductWithInfomationsRespVO.java diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/service/DeviceProductService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/service/DeviceProductService.java index 3ecffd2f..7c0b2101 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/service/DeviceProductService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/service/DeviceProductService.java @@ -77,4 +77,11 @@ public interface DeviceProductService { */ PageResult getDeviceProductPage(DeviceProductPageReqVO pageReqVO); + /** + * 根据分类名获取设备大类 + * + * @param deviceCategoryName 分类名称 + * @return 设备大类列表 + */ + List getDeviceProductByCategoryName(String deviceCategoryName); } \ 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/device/service/DeviceProductServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/service/DeviceProductServiceImpl.java index cbb6a772..b68f3ff6 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/service/DeviceProductServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/service/DeviceProductServiceImpl.java @@ -1,6 +1,7 @@ package com.zt.plat.module.qms.resource.device.service; import cn.hutool.core.collection.CollUtil; +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; @@ -210,6 +211,19 @@ public class DeviceProductServiceImpl implements DeviceProductService { return deviceProductMapper.selectPage(pageReqVO); } + @Override + public List getDeviceProductByCategoryName(String deviceCategoryName) { + List category = deviceProductMapper.selectList(Wrappers.lambdaQuery(DeviceProductDO.class) + .eq(DeviceProductDO::getNodeType, DataTypeConstant.DATA_TYPE_CATEGORY) + .eq(DeviceProductDO::getName, deviceCategoryName) + .last("limit 1")); + if (CollUtil.isEmpty(category)) return List.of(); + + return deviceProductMapper.selectList(Wrappers.lambdaQuery(DeviceProductDO.class) + .like(DeviceProductDO::getIdPath, "/" + category.get(0).getId() + "/") + .eq(DeviceProductDO::getNodeType, DataTypeConstant.DATA_TYPE_DATA)); + } + private String getIdPath(DeviceProductDO entity){ String parIdPath = ""; if(ObjectUtils.isEmpty(entity.getParentId()) || 0L == entity.getParentId()) 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 7b179b27..d32f488c 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 @@ -6,4 +6,10 @@ 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 SEQUENCE_INF_KEY = "QMS_MATERIAL_INF_NO"; + + // 外部模块 + public static final String DEVICE_BURETTE_CATEGORY_NAME = "滴定管"; } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryController.java deleted file mode 100644 index 281b3687..00000000 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryController.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.zt.plat.module.qms.resource.material.controller.admin; - -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.module.qms.resource.material.controller.vo.MaterialProductPageReqVO; -import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO; -import com.zt.plat.module.qms.resource.material.service.MaterialProductService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import org.springframework.beans.factory.annotation.Autowired; -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 static com.zt.plat.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 物料库存") -@RestController -@RequestMapping("/qms/resource/material-inventory") -@Validated -@DeptDataPermissionIgnore(enable = "true") -public class MaterialInventoryController implements BusinessControllerMarker { - - @Autowired - private MaterialProductService materialProductService; - - @GetMapping("/page") - @Operation(summary = "获得物料大类分页") - public CommonResult> getMaterialInventoryPage(@Valid MaterialProductPageReqVO pageReqVO) { - // 需要库存数量和预警信息 - PageResult pageResult = materialProductService.getMaterialInventoryPage(pageReqVO); - return success(pageResult); - } -} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleController.java index 40dc2c24..9a10ce22 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleController.java @@ -97,9 +97,9 @@ public class MaterialLifecycleController extends AbstractFileUploadController im @GetMapping("/page") @Operation(summary = "获得物料流程分页") // @PreAuthorize("@ss.hasPermission('qms:material-lifecycle:query')") - public CommonResult> getMaterialLifecyclePage(@Valid MaterialLifecyclePageReqVO pageReqVO) { - PageResult pageResult = materialLifecycleService.getMaterialLifecyclePage(pageReqVO); - return success(BeanUtils.toBean(pageResult, MaterialLifecycleRespVO.class)); + public CommonResult> getMaterialLifecycleRespVOPage(@Valid MaterialLifecyclePageReqVO pageReqVO) { + PageResult pageResult = materialLifecycleService.getMaterialLifecycleRespVOPage(pageReqVO); + return success(pageResult); } @PutMapping("/submit") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialProductController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialProductController.java index 20d6122c..03e86d54 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialProductController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialProductController.java @@ -88,6 +88,14 @@ public class MaterialProductController extends AbstractFileUploadController impl return success(BeanUtils.toBean(pageResult, MaterialProductRespVO.class)); } + @GetMapping("/inventory-page") + @Operation(summary = "库存管理页面物料大类分页") + public CommonResult> getMaterialInventoryPage(@Valid MaterialProductPageReqVO pageReqVO) { + // 需要库存数量和预警信息 + PageResult pageResult = materialProductService.getMaterialInventoryPage(pageReqVO); + return success(pageResult); + } + @GetMapping("category-data") @Operation(summary = "获得物料分类和大类") public CommonResult> getCategoryAndData(@Valid MaterialProductQueryVO queryVO) { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialStandardSolutionController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialStandardSolutionController.java index a7a0c39d..9d77f3e5 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialStandardSolutionController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialStandardSolutionController.java @@ -10,11 +10,17 @@ import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.excel.core.util.ExcelUtils; +import com.zt.plat.module.qms.resource.device.controller.vo.DeviceProductPageReqVO; +import com.zt.plat.module.qms.resource.device.controller.vo.DeviceProductRespVO; +import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceProductDO; +import com.zt.plat.module.qms.resource.material.controller.vo.DeviceProductWithInfomationsRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialStandardSolutionPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialStandardSolutionRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialStandardSolutionSaveReqVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialStandardSolutionDO; import com.zt.plat.module.qms.resource.material.service.MaterialStandardSolutionService; +import com.zt.plat.module.qms.resource.material.valid.AddGroup; +import com.zt.plat.module.qms.resource.material.valid.UpdateGroup; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -51,14 +57,14 @@ public class MaterialStandardSolutionController extends AbstractFileUploadContro @PostMapping("/create") @Operation(summary = "新建配置") // @PreAuthorize("@ss.hasPermission('qms:material-standard-solution:create')") - public CommonResult createMaterialStandardSolution(@Valid @RequestBody MaterialStandardSolutionSaveReqVO createReqVO) { + public CommonResult createMaterialStandardSolution(@Validated(AddGroup.class) @RequestBody MaterialStandardSolutionSaveReqVO createReqVO) { return success(materialStandardSolutionService.createMaterialStandardSolution(createReqVO)); } @PutMapping("/update") - @Operation(summary = "更新标液,标准溶液,包含配置信息") + @Operation(summary = "更新标液,包含配置信息") // @PreAuthorize("@ss.hasPermission('qms:material-standard-solution:update')") - public CommonResult updateMaterialStandardSolution(@Valid @RequestBody MaterialStandardSolutionSaveReqVO updateReqVO) { + public CommonResult updateMaterialStandardSolution(@Validated(UpdateGroup.class) @RequestBody MaterialStandardSolutionSaveReqVO updateReqVO) { materialStandardSolutionService.updateMaterialStandardSolution(updateReqVO); return success(true); } @@ -75,7 +81,7 @@ public class MaterialStandardSolutionController extends AbstractFileUploadContro @DeleteMapping("/delete-list") @Parameter(name = "ids", description = "编号", required = true) @Operation(summary = "批量删除标液,标准溶液,包含配置信息") -// @PreAuthorize("@ss.hasPermission('qms:material-standard-solution:delete')") + @PreAuthorize("@ss.hasPermission('qms:material-standard-solution:delete')") public CommonResult deleteMaterialStandardSolutionList(@RequestBody BatchDeleteReqVO req) { materialStandardSolutionService.deleteMaterialStandardSolutionListByIds(req.getIds()); return success(true); @@ -85,9 +91,9 @@ public class MaterialStandardSolutionController extends AbstractFileUploadContro @Operation(summary = "获得标液,标准溶液,包含配置信息") @Parameter(name = "id", description = "编号", required = true, example = "1024") // @PreAuthorize("@ss.hasPermission('qms:material-standard-solution:query')") - public CommonResult getMaterialStandardSolution(@RequestParam("id") Long id) { - MaterialStandardSolutionDO materialStandardSolution = materialStandardSolutionService.getMaterialStandardSolution(id); - return success(BeanUtils.toBean(materialStandardSolution, MaterialStandardSolutionRespVO.class)); + public CommonResult getStandardSolutionWithMaterialInfo(@RequestParam("id") Long id) { + MaterialStandardSolutionRespVO solutionRespVO = materialStandardSolutionService.getStandardSolutionWithMaterialInfo(id); + return success(solutionRespVO); } @GetMapping("/page") @@ -98,6 +104,14 @@ public class MaterialStandardSolutionController extends AbstractFileUploadContro return success(pageResult); } + + @GetMapping("/device-burette-list") + @Operation(summary = "获取设备滴定管") + public CommonResult> getDeviceBuretteProductWithInfomationList() { + List deviceProductRespVOS = materialStandardSolutionService.getDeviceBuretteProductWithInfomationList(); + return success(deviceProductRespVOS); + } + @GetMapping("/export-excel") @Operation(summary = "导出标液,标准溶液,包含配置信息 Excel") @PreAuthorize("@ss.hasPermission('qms:material-standard-solution:export')") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/DeviceInfomationRespVOBySol.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/DeviceInfomationRespVOBySol.java new file mode 100644 index 00000000..126c7f46 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/DeviceInfomationRespVOBySol.java @@ -0,0 +1,60 @@ +package com.zt.plat.module.qms.resource.material.controller.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 设备-设备信息 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DeviceInfomationRespVOBySol { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32125") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "设备大类id", example = "32101") + @ExcelProperty("设备大类id") + private Long productId; + + @Schema(description = "设备名称", example = "张三") + @ExcelProperty("设备名称") + private String name; + + @Schema(description = "设备状态", example = "2") + @ExcelProperty("设备状态") + private String deviceStatus; + + + @Schema(description = "数量") + @ExcelProperty("数量") + private String deviceNumber; + + @Schema(description = "管理编号") + @ExcelProperty("管理编号") + private String deviceCode; + + @Schema(description = "资产编号") + @ExcelProperty("资产编号") + private String assetCode; + + @Schema(description = "出厂编号") + @ExcelProperty("出厂编号") + private String factoryCode; + + @Schema(description = "存放位置") + @ExcelProperty("存放位置") + private String position; + + @Schema(description = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; +} \ 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/controller/vo/DeviceProductWithInfomationsRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/DeviceProductWithInfomationsRespVO.java new file mode 100644 index 00000000..2a77f886 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/DeviceProductWithInfomationsRespVO.java @@ -0,0 +1,52 @@ +package com.zt.plat.module.qms.resource.material.controller.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationRespVO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.List; + +@Schema(description = "管理后台 - 设备-设备大类 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DeviceProductWithInfomationsRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2648") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "父ID", example = "5458") + @ExcelProperty("父ID") + private Long parentId; + + @Schema(description = "id路径") + @ExcelProperty("id路径") + private String idPath; + + @Schema(description = "节点类型,分类|大类", example = "1") + @ExcelProperty("节点类型,分类|大类") + private String nodeType; + + + @Schema(description = "名称", example = "王五") + @ExcelProperty("名称") + private String name; + + @Schema(description = "型号") + @ExcelProperty("型号") + private String modelNo; + + @Schema(description = "规格") + @ExcelProperty("规格") + private String specification; + + @Schema(description = "技术指标") + @ExcelProperty("技术指标") + private String parameter; + + @Schema(description = "设备实例列表") + private List children; +} \ 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/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 8b9b498e..c46e7c26 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 @@ -132,10 +132,6 @@ public class MaterialInfomationRespVO { @ExcelProperty("配置日期") private LocalDateTime makeDate; - @Schema(description = "到期日期") - @ExcelProperty("到期日期") - private LocalDateTime dueDate; - @Schema(description = "浓度") @ExcelProperty("浓度") private String concentration; @@ -160,6 +156,10 @@ public class MaterialInfomationRespVO { @ExcelProperty("开封日期") private LocalDateTime openDate; + @Schema(description = "生产日期") + @ExcelProperty("生产日期") + private LocalDate manufacturerDate; + @Schema(description = "到期日期") @ExcelProperty("到期日期") private LocalDate expirationDate; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialLifecycleDetailRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialLifecycleDetailRespVO.java index cc7221e8..417a4330 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialLifecycleDetailRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialLifecycleDetailRespVO.java @@ -5,7 +5,6 @@ import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.math.BigDecimal; import java.time.LocalDateTime; @Schema(description = "管理后台 - 物料通用流程明细 Response VO") @@ -38,6 +37,10 @@ public class MaterialLifecycleDetailRespVO { @ExcelProperty("单位") private String unit; + @Schema(description = "保质期") + @ExcelProperty("保质期") + private Integer due; + @Schema(description = "物料大类型号") @ExcelProperty("物料大类型号") private String productModelNo; @@ -90,6 +93,10 @@ public class MaterialLifecycleDetailRespVO { @ExcelProperty("影响数量") private String influenceCount; + @Schema(description = "已完成数量", example = "15772") + @ExcelProperty("已完成数量") + private Long finishedCount; + @Schema(description = "明细操作类型,【字典】【jy_material_lifecycle_detail_bsn_type】", example = "1") @ExcelProperty("明细操作类型,【字典】【jy_material_lifecycle_detail_bsn_type】") private String businessType; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialStandardSolutionRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialStandardSolutionRespVO.java index 21afeef1..9f9e564b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialStandardSolutionRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialStandardSolutionRespVO.java @@ -60,6 +60,10 @@ public class MaterialStandardSolutionRespVO { @ExcelProperty("到期日期") private LocalDateTime dueDate; + @Schema(description = "滴定管id") + @ExcelProperty("滴定管id") + private String buretteId; + @Schema(description = "滴定管编号") @ExcelProperty("滴定管编号") private String buretteNo; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialStandardSolutionSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialStandardSolutionSaveReqVO.java index 1ab86341..2c3d31a1 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialStandardSolutionSaveReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialStandardSolutionSaveReqVO.java @@ -1,6 +1,10 @@ package com.zt.plat.module.qms.resource.material.controller.vo; +import com.zt.plat.module.qms.resource.material.valid.AddGroup; +import com.zt.plat.module.qms.resource.material.valid.UpdateGroup; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Null; import lombok.Data; import java.time.LocalDateTime; @@ -10,8 +14,14 @@ import java.time.LocalDateTime; public class MaterialStandardSolutionSaveReqVO { @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "19766") + @NotNull(groups = {UpdateGroup.class}, message = "id不能为空") + @Null(groups = {AddGroup.class}, message = "id必须为空") private Long id; + @Schema(description = "物料大类id") + @NotNull(groups = {AddGroup.class}, message = "物料大类id不能为空") + private Long productId; + @Schema(description = "配置申请明细ID", example = "438") private Long detailId; @@ -39,6 +49,9 @@ public class MaterialStandardSolutionSaveReqVO { @Schema(description = "到期日期") private LocalDateTime dueDate; + @Schema(description = "滴定管id") + private String buretteId; + @Schema(description = "滴定管编号") private String buretteNo; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialStandardSolutionDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialStandardSolutionDO.java index e3d482ff..2abffbd5 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialStandardSolutionDO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialStandardSolutionDO.java @@ -75,6 +75,11 @@ public class MaterialStandardSolutionDO extends BusinessBaseDO { */ @TableField("DUE_DT") private LocalDateTime dueDate; + /** + * 滴定管id + */ + @TableField("BRT_ID") + private String buretteId; /** * 滴定管编号 */ 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 a0f88158..833b56b5 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 @@ -57,8 +57,8 @@ public interface MaterialInfomationMapper extends BaseMapperX selectDetailRespVOListByLfcIds(List lfcIds) { - return List.of(); + MPJLambdaWrapper wrapper = new MPJLambdaWrapper() + .selectAll(MaterialLifecycleDetailDO.class) + .select(MaterialProductDO::getDue, MaterialProductDO::getUnit) + .selectAs(MaterialProductDO::getName, MaterialLifecycleDetailRespVO::getProductName) + .selectAs(MaterialProductDO::getCode, MaterialLifecycleDetailRespVO::getProductCode) + .selectAs(MaterialProductDO::getModelNo, MaterialLifecycleDetailRespVO::getProductModelNo) + .leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialLifecycleDetailDO::getProductId) + .in(MaterialLifecycleDetailDO::getLifecycleId, lfcIds); + return selectJoinList(MaterialLifecycleDetailRespVO.class, wrapper); } } \ 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/dal/mapper/MaterialStandardSolutionMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialStandardSolutionMapper.java index 74069bac..20089d9f 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialStandardSolutionMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialStandardSolutionMapper.java @@ -68,4 +68,15 @@ public interface MaterialStandardSolutionMapper extends BaseMapperX() + .selectAll(MaterialStandardSolutionDO.class) + .selectAs(MaterialInfomationDO::getCode, MaterialStandardSolutionRespVO::getInfomationCode) + .selectAs(MaterialProductDO::getName, MaterialStandardSolutionRespVO::getInfomationName) + .leftJoin(MaterialInfomationDO.class, MaterialInfomationDO::getId, MaterialStandardSolutionDO::getInfomationId) + .leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId) + .eq(MaterialStandardSolutionDO::getId, id) + ); + } } \ 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 f01ea0fe..36d2d902 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 @@ -107,4 +107,18 @@ public interface MaterialInfomationService { * @param infIds id集合 */ void updateInfomationByInfIds(MaterialInfomationDO infomationUpdate, List infIds); + + /** + * 保存物料实例 + * + * @param infomationDO 物料实例 + */ + void save(MaterialInfomationDO infomationDO); + + /** + * 更新物料实例 + * + * @param infomationDO 物料实例 + */ + void updateById(MaterialInfomationDO infomationDO); } \ 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 270e3559..b7b95746 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 @@ -138,4 +138,14 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService .in(MaterialInfomationDO::getId, infIds)); } + @Override + public void save(MaterialInfomationDO infomationDO) { + materialInfomationMapper.insert(infomationDO); + } + + @Override + public void updateById(MaterialInfomationDO infomationDO) { + materialInfomationMapper.updateById(infomationDO); + } + } \ 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 79d5c51a..34089bb6 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 @@ -9,7 +9,7 @@ import com.zt.plat.framework.security.core.LoginUser; import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; import com.zt.plat.module.qms.core.code.SequenceUtil; import com.zt.plat.module.qms.core.constant.DataTypeConstant; -import com.zt.plat.module.qms.enums.QmsCommonConstant; +import com.zt.plat.module.qms.resource.material.constant.MaterialConstants; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundSaveReqVO; @@ -57,7 +57,6 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb @Autowired private MaterialInventoryInboundDetailService materialInventoryInboundDetailService; - private final String infSequenceKey = "QMS_MATERIAL_INF_NO"; @Transactional @Override @@ -118,7 +117,7 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb .setOpenStatus(0) .setManufacturerDate(batch.getManufacturerDate()).setExpirationDate(batch.getDueDate()); // 生成编号 - String code = sequenceUtil.genCode(infSequenceKey); + String code = sequenceUtil.genCode(MaterialConstants.SEQUENCE_INF_KEY); infomationDO.setCode(code); infomationDOS.add(infomationDO); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailService.java index fba23232..fbde4c84 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailService.java @@ -8,6 +8,7 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycle import jakarta.validation.Valid; import java.util.List; +import java.util.Map; /** * 物料通用流程明细 Service 接口 @@ -128,4 +129,12 @@ public interface MaterialLifecycleDetailService { * @return 明细列表 */ List getDetailRespVOListByLfcIds(List lfcIds); + + /** + * 根据流程明细ids 获取溶液已配置的数量 + * + * @param detailIds 流程明细ids + * @return map + */ + Map getMadeCountMapByDetailIds(List detailIds); } \ 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/MaterialLifecycleDetailServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailServiceImpl.java index e8ce13c1..06bfdf56 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleDetailServiceImpl.java @@ -1,6 +1,7 @@ package com.zt.plat.module.qms.resource.material.service; import cn.hutool.core.collection.CollUtil; +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; @@ -9,13 +10,18 @@ import com.zt.plat.module.qms.enums.QmsCommonConstant; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycleDetailDO; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialLifecycleDetailMapper; import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; 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.stream.Collectors; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_LIFECYCLE_DETAIL_NOT_EXISTS; @@ -32,6 +38,9 @@ public class MaterialLifecycleDetailServiceImpl implements MaterialLifecycleDeta @Resource private MaterialLifecycleDetailMapper materialLifecycleDetailMapper; + @Autowired + private MaterialStandardSolutionService materialStandardSolutionService; + @Override public MaterialLifecycleDetailRespVO createMaterialLifecycleDetail(MaterialLifecycleDetailSaveReqVO createReqVO) { // 插入 @@ -148,4 +157,10 @@ public class MaterialLifecycleDetailServiceImpl implements MaterialLifecycleDeta return materialLifecycleDetailMapper.selectDetailRespVOListByLfcIds(lfcIds); } + @Override + public Map getMadeCountMapByDetailIds(List detailIds) { + + return materialStandardSolutionService.getMadeCountMapByDetailIds(detailIds); + } + } \ 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/MaterialLifecycleService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleService.java index 116ea5b3..321f8dbf 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleService.java @@ -68,4 +68,12 @@ public interface MaterialLifecycleService { * @return 是否成功 */ Boolean submitLifecycle(Long id); + + /** + * 获得物料通用流程 - 带明细数据 + * + * @param pageReqVO 分页查询 + * @return 物料通用流程分页 + */ + PageResult getMaterialLifecycleRespVOPage(@Valid MaterialLifecyclePageReqVO pageReqVO); } \ 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/MaterialLifecycleServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleServiceImpl.java index 4b7595a6..c9a37fda 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialLifecycleServiceImpl.java @@ -19,7 +19,6 @@ import com.zt.plat.module.bpm.api.task.dto.BpmTaskRespDTO; import com.zt.plat.module.qms.api.task.BMPCallbackInterface; import com.zt.plat.module.qms.api.task.dto.QmsBpmDTO; import com.zt.plat.module.qms.common.data.service.DataKeyCheckService; -import com.zt.plat.module.qms.common.dic.controller.vo.DictionaryBusinessRespVO; import com.zt.plat.module.qms.common.dic.dal.dataobject.DictionaryBusinessDO; import com.zt.plat.module.qms.common.dic.service.DictionaryBusinessService; import com.zt.plat.module.qms.enums.QmsBpmConstant; @@ -110,33 +109,10 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , List detailDOS = List.of(); if (MaterialFlowType.acceptance.getName().equals(mtrlLfc.getBusinessType())) { // 保存工段明细 - List gongIds = detailList.stream().map(MaterialLifecycleDetailSaveReqVO::getBatchGongduanId).toList(); - Map gongAssayMap = detailList.stream().collect(Collectors.toMap( - MaterialLifecycleDetailSaveReqVO::getBatchGongduanId, MaterialLifecycleDetailSaveReqVO::getAssayFlag)); - List gongs = materialBatchService.getGongduanListByGongIds(gongIds); - if (CollUtil.isEmpty(gongs) || gongs.size() != gongIds.size()) - throw new ServiceException(1_032_160_000, "工段不存在或与传入的工段数量不匹配"); - for (MaterialBatchDO gong : gongs) { - gong.setAssayFlag(gongAssayMap.get(gong.getId())); - } - detailDOS = getLifecycleDetailDOsByGongs(gongs, gongIds, mtrlLfc); + detailDOS = getMaterialGongsLifecycleDetailDOS(detailList, mtrlLfc); } else if (MaterialFlowType.config_apply.getName().equals(mtrlLfc.getBusinessType())) { // 保存物料大类明细 - List pdtIds = detailList.stream().map(MaterialLifecycleDetailSaveReqVO::getProductId).toList(); - List products = materialProductService.getMaterialProductListByPdtIds(pdtIds); - if (CollUtil.isEmpty(products) || products.size() != pdtIds.size()) - throw new ServiceException(1_032_160_000, "物料大类不存在或与传入的数量不匹配"); - - detailDOS = detailList.stream().map(detail -> { - MaterialLifecycleDetailDO detailDO = new MaterialLifecycleDetailDO(); - detailDO.setLifecycleId(mtrlLfc.getId()) - .setProductId(detail.getProductId()) - .setInfluenceCount(detail.getInfluenceCount()) - .setBusinessType(mtrlLfc.getBusinessType()) - .setTreatmentStatus(0) - .setRemark(detail.getRemark()); - return detailDO; - }).toList(); + detailDOS = getMaterialProductsLifecycleDetailDOS(detailList, mtrlLfc); } materialLifecycleDetailService.saveBatch(detailDOS); return BeanUtils.toBean(mtrlLfc, MaterialLifecycleRespVO.class); @@ -176,6 +152,20 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , } // 删除原来的明细 materialLifecycleDetailService.deleteLifecycleDetailListByLfcId(reqId); + List detailDOS = List.of(); + if (MaterialFlowType.acceptance.getName().equals(mtrlLfc.getBusinessType())) { + detailDOS = getMaterialGongsLifecycleDetailDOS(detailList, mtrlLfc); + } else if (MaterialFlowType.config_apply.getName().equals(mtrlLfc.getBusinessType())) { + // 保存物料大类明细 + detailDOS = getMaterialProductsLifecycleDetailDOS(detailList, mtrlLfc); + } + // 保存新的明细 + materialLifecycleDetailService.saveBatch(detailDOS); + materialLifecycleMapper.updateById(mtrlLfc); + } + + private List getMaterialGongsLifecycleDetailDOS(List detailList, MaterialLifecycleDO mtrlLfc) { + List gongIds = detailList.stream().map(MaterialLifecycleDetailSaveReqVO::getBatchGongduanId).toList(); Map gongAssayMap = detailList.stream().collect(Collectors.toMap( MaterialLifecycleDetailSaveReqVO::getBatchGongduanId, MaterialLifecycleDetailSaveReqVO::getAssayFlag)); @@ -185,10 +175,26 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , for (MaterialBatchDO gong : gongs) { gong.setAssayFlag(gongAssayMap.get(gong.getId())); } - // 保存新的明细 - List detailDOS = getLifecycleDetailDOsByGongs(gongs, gongIds, mtrlLfc); - materialLifecycleDetailService.saveBatch(detailDOS); - materialLifecycleMapper.updateById(mtrlLfc); + + return getLifecycleDetailDOsByGongs(gongs, gongIds, mtrlLfc); + } + + private List getMaterialProductsLifecycleDetailDOS(List detailList, MaterialLifecycleDO mtrlLfc) { + List pdtIds = detailList.stream().map(MaterialLifecycleDetailSaveReqVO::getProductId).toList(); + List products = materialProductService.getMaterialProductListByPdtIds(pdtIds); + if (CollUtil.isEmpty(products) || products.size() != pdtIds.size()) + throw new ServiceException(1_032_160_000, "物料大类不存在或与传入的数量不匹配"); + + return detailList.stream().map(detail -> { + MaterialLifecycleDetailDO detailDO = new MaterialLifecycleDetailDO(); + detailDO.setLifecycleId(mtrlLfc.getId()) + .setProductId(detail.getProductId()) + .setInfluenceCount(detail.getInfluenceCount()) + .setBusinessType(mtrlLfc.getBusinessType()) + .setTreatmentStatus(0) + .setRemark(detail.getRemark()); + return detailDO; + }).toList(); } @Transactional @@ -249,22 +255,16 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , @Override public PageResult getMaterialLifecyclePage(MaterialLifecyclePageReqVO pageReqVO) { PageResult pageResult = materialLifecycleMapper.selectPage(pageReqVO); - List list = pageResult.getList(); - if (CollUtil.isEmpty(list)) return pageResult; - list.forEach(mtrlLfc -> { + List lifecycleDOS = pageResult.getList(); + if (CollUtil.isEmpty(lifecycleDOS)) return pageResult; + lifecycleDOS.forEach(mtrlLfc -> { String formData = mtrlLfc.getFormData(); if (formData != null) { String title = (String) JSONUtil.parseObj(formData).get("title"); mtrlLfc.setTitle(title); } }); - // 组装明细 - List lfcIds = list.stream().map(MaterialLifecycleDO::getId).toList(); - List detailRespVOS = materialLifecycleDetailService.getDetailRespVOListByLfcIds(lfcIds); - if (CollUtil.isNotEmpty(detailRespVOS)) { - - } - pageResult.setList(list); + pageResult.setList(lifecycleDOS); return pageResult; } @@ -285,6 +285,37 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , return true; } + @Override + public PageResult getMaterialLifecycleRespVOPage(MaterialLifecyclePageReqVO pageReqVO) { + PageResult lifecyclePage = getMaterialLifecyclePage(pageReqVO); + List lifecycleDOS = lifecyclePage.getList(); + PageResult respVOPageResult = BeanUtils.toBean(lifecyclePage, MaterialLifecycleRespVO.class); + if (CollUtil.isEmpty(lifecycleDOS)) return respVOPageResult; + if (MaterialFlowType.config_apply.getName().equals(pageReqVO.getBusinessType())) { + List lifecycleRespVOS = respVOPageResult.getList(); + // 组装明细 + List lfcIds = lifecycleRespVOS.stream().map(MaterialLifecycleRespVO::getId).toList(); + List detailRespVOS = materialLifecycleDetailService.getDetailRespVOListByLfcIds(lfcIds); + if (CollUtil.isNotEmpty(detailRespVOS)) { + + // 获取已配置的数量 + List detailIds = detailRespVOS.stream().map(MaterialLifecycleDetailRespVO::getId).toList(); + Map madeCountMap = materialLifecycleDetailService.getMadeCountMapByDetailIds(detailIds); + for (MaterialLifecycleDetailRespVO detailRespVO : detailRespVOS) { + Long finishedCount = madeCountMap.get(detailRespVO.getId()); + detailRespVO.setFinishedCount(finishedCount == null ? 0L : finishedCount); + } + Map> detailMapByLfcId = detailRespVOS.stream().collect(Collectors.groupingBy(MaterialLifecycleDetailRespVO::getLifecycleId)); + for (MaterialLifecycleRespVO lifecycleRespVO : lifecycleRespVOS) { + lifecycleRespVO.setDetailList(detailMapByLfcId.get(lifecycleRespVO.getId())); + } + + } + respVOPageResult.setList(lifecycleRespVOS); + } + return respVOPageResult; + } + private void createProcessInstance(MaterialLifecycleDO lifecycleDO) { String flowInstanceId = lifecycleDO.getFlowInstanceId(); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionService.java index 59412d6c..9fae539c 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionService.java @@ -1,6 +1,8 @@ package com.zt.plat.module.qms.resource.material.service; import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.module.qms.resource.device.controller.vo.DeviceProductRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.DeviceProductWithInfomationsRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialStandardSolutionPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialStandardSolutionRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialStandardSolutionSaveReqVO; @@ -8,6 +10,7 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialStandardS import jakarta.validation.Valid; import java.util.List; +import java.util.Map; /** * 标液,标准溶液,包含配置信息 Service 接口 @@ -68,4 +71,27 @@ public interface MaterialStandardSolutionService { * @return 标液分页 */ PageResult getStandardSolutionPageWithMaterialInfo(@Valid MaterialStandardSolutionPageReqVO pageReqVO); + + /** + * 获得已配置数量 + * + * @param detailIds 明细编号 + * @return 已配置数量 + */ + Map getMadeCountMapByDetailIds(List detailIds); + + /** + * 滴定管设备列表 + * + * @return 滴定管设备列表 + */ + List getDeviceBuretteProductWithInfomationList(); + + /** + * 获得标液 - 包含物料信息 + * + * @param id 编号 + * @return 标液 - 包含物料信息 + */ + MaterialStandardSolutionRespVO getStandardSolutionWithMaterialInfo(Long id); } \ 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/MaterialStandardSolutionServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialStandardSolutionServiceImpl.java index ee0160a9..5344f99e 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 @@ -1,18 +1,37 @@ package com.zt.plat.module.qms.resource.material.service; import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.zt.plat.framework.common.exception.ServiceException; 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.MaterialStandardSolutionPageReqVO; -import com.zt.plat.module.qms.resource.material.controller.vo.MaterialStandardSolutionRespVO; -import com.zt.plat.module.qms.resource.material.controller.vo.MaterialStandardSolutionSaveReqVO; +import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; +import com.zt.plat.module.qms.core.code.SequenceUtil; +import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceInfomationDO; +import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceProductDO; +import com.zt.plat.module.qms.resource.device.service.DeviceInfomationService; +import com.zt.plat.module.qms.resource.device.service.DeviceProductService; +import com.zt.plat.module.qms.resource.material.constant.MaterialConstants; +import com.zt.plat.module.qms.resource.material.controller.vo.*; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycleDetailDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialStandardSolutionDO; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialStandardSolutionMapper; import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +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.time.LocalDate; +import java.time.LocalDateTime; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_STANDARD_SOLUTION_NOT_EXISTS; @@ -22,6 +41,7 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_STANDARD_ * * @author 后台管理 */ +@Slf4j @Service @Validated public class MaterialStandardSolutionServiceImpl implements MaterialStandardSolutionService { @@ -29,36 +49,106 @@ public class MaterialStandardSolutionServiceImpl implements MaterialStandardSolu @Resource private MaterialStandardSolutionMapper materialStandardSolutionMapper; + @Lazy + @Autowired + private MaterialLifecycleDetailService materialLifecycleDetailService; + + @Lazy + @Autowired + private MaterialLifecycleService materialLifecycleService; + + @Autowired + private MaterialInfomationService materialInfomationService; + @Autowired + private SequenceUtil sequenceUtil; + @Autowired + private DeviceProductService deviceProductService; + @Autowired + private DeviceInfomationService deviceInfomationService; + + @Transactional @Override public MaterialStandardSolutionRespVO createMaterialStandardSolution(MaterialStandardSolutionSaveReqVO createReqVO) { + + Long detailId = createReqVO.getDetailId(); + Long productId = createReqVO.getProductId(); + MaterialStandardSolutionDO mtrlStandSol = BeanUtils.toBean(createReqVO, MaterialStandardSolutionDO.class); + Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); + String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname(); + mtrlStandSol.setMakeUserId(loginUserId).setMakeUser(loginUserNickname).setMakeDate(LocalDateTime.now()); + // 0-未标定 + mtrlStandSol.setStandardFlow("0"); + if (detailId != null) { + // 走申请 + MaterialLifecycleDetailDO lifecycleDetail = materialLifecycleDetailService.getMaterialLifecycleDetail(detailId); + if (lifecycleDetail == null) throw new ServiceException(1_032_160_000, "配置申请明细不存在"); + // 已提交的申请才可配置 + MaterialLifecycleRespVO lifecycle = materialLifecycleService.getMaterialLifecycle(lifecycleDetail.getLifecycleId()); + if (lifecycle == null) throw new ServiceException(1_032_160_000, "配置申请不存在"); + if (lifecycle.getSubmitStatus() != 1) throw new ServiceException(1_032_160_000, "配置申请未提交"); + 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); + materialInfomationService.save(infomationDO); // 插入 - MaterialStandardSolutionDO materialStandardSolution = BeanUtils.toBean(createReqVO, MaterialStandardSolutionDO.class); - materialStandardSolutionMapper.insert(materialStandardSolution); + mtrlStandSol.setInfomationId(infomationDO.getId()); + materialStandardSolutionMapper.insert(mtrlStandSol); + // 返回 - return BeanUtils.toBean(materialStandardSolution, MaterialStandardSolutionRespVO.class); + return BeanUtils.toBean(mtrlStandSol, MaterialStandardSolutionRespVO.class); } + @Transactional @Override public void updateMaterialStandardSolution(MaterialStandardSolutionSaveReqVO updateReqVO) { - // 校验存在 - validateMaterialStandardSolutionExists(updateReqVO.getId()); + MaterialStandardSolutionDO solutionDO = materialStandardSolutionMapper.selectById(updateReqVO.getId()); + if (solutionDO == null) throw exception(MATERIAL_STANDARD_SOLUTION_NOT_EXISTS); + // 如果到期日期有变化,修改物料实例的到期日期 + if (updateReqVO.getDueDate() != null && !solutionDO.getDueDate().equals(updateReqVO.getDueDate())) { + MaterialInfomationDO infomationDO = new MaterialInfomationDO() + .setId(solutionDO.getInfomationId()) + .setExpirationDate(LocalDate.from(updateReqVO.getDueDate())); + materialInfomationService.updateById(infomationDO); + } // 更新 MaterialStandardSolutionDO updateObj = BeanUtils.toBean(updateReqVO, MaterialStandardSolutionDO.class); materialStandardSolutionMapper.updateById(updateObj); } + @Transactional @Override public void deleteMaterialStandardSolution(Long id) { - // 校验存在 - validateMaterialStandardSolutionExists(id); + MaterialStandardSolutionDO solutionDO = materialStandardSolutionMapper.selectById(id); + if (solutionDO == null) throw exception(MATERIAL_STANDARD_SOLUTION_NOT_EXISTS); + // 已标定的不允许删除 + if ("1".equals(solutionDO.getStandardFlow())) throw new ServiceException(1_032_160_000, "已标定的标准溶液不允许删除"); + // 删除物料 + materialInfomationService.deleteMaterialInfomation(solutionDO.getInfomationId()); // 删除 materialStandardSolutionMapper.deleteById(id); } + @Transactional @Override public void deleteMaterialStandardSolutionListByIds(List ids) { - // 校验存在 - validateMaterialStandardSolutionExists(ids); + List solutionDOS = materialStandardSolutionMapper.selectByIds(ids); + if (CollUtil.isEmpty(solutionDOS) || solutionDOS.size() != ids.size()) + throw exception(MATERIAL_STANDARD_SOLUTION_NOT_EXISTS); + solutionDOS.forEach(solutionDO -> { + // 已标定的不允许删除 + if ("1".equals(solutionDO.getStandardFlow())) throw new ServiceException(1_032_160_000, "存在已标定的标准溶液不允许删除"); + }); + // 删除物料 + List infIds = solutionDOS.stream().map(MaterialStandardSolutionDO::getInfomationId).toList(); + materialInfomationService.deleteMaterialInfomationListByIds(infIds); // 删除 materialStandardSolutionMapper.deleteByIds(ids); } @@ -92,4 +182,47 @@ public class MaterialStandardSolutionServiceImpl implements MaterialStandardSolu return materialStandardSolutionMapper.selectPageWithMaterialInfo(pageReqVO); } + @Override + public Map getMadeCountMapByDetailIds(List detailIds) { + QueryWrapper queryWrapper = Wrappers.query(MaterialStandardSolutionDO.class) + .select("DTL_ID ,count(*) as quantity") + .in("DTL_ID", detailIds) + .groupBy("DTL_ID"); + List> maps = materialStandardSolutionMapper.selectMaps(queryWrapper); + log.info("maps: {}", maps); + if (CollUtil.isEmpty(maps)) return new HashMap<>(); + + return maps.stream().collect(Collectors.toMap( + map -> (Long) map.get("DTL_ID"), + map -> (Long) map.get("QUANTITY") + )); + } + + @Override + public List getDeviceBuretteProductWithInfomationList() { + List deviceProducts = deviceProductService.getDeviceProductByCategoryName(MaterialConstants.DEVICE_BURETTE_CATEGORY_NAME); + if (CollUtil.isEmpty(deviceProducts)) throw new ServiceException(1_032_160_000, "未找到滴定管设备类别"); + List devicePdtIds = deviceProducts.stream().map(DeviceProductDO::getId).toList(); + List infomationDOS = deviceInfomationService.getListByProductIdList(devicePdtIds); + if (CollUtil.isEmpty(infomationDOS)) return List.of(); + List respVOBySols = infomationDOS.stream().map( + infomationDO -> { + DeviceInfomationRespVOBySol respVOBySol = BeanUtils.toBean(infomationDO, DeviceInfomationRespVOBySol.class); + respVOBySol.setName(infomationDO.getDeviceName()); + return respVOBySol; + }).toList(); + Map> infoMapByPtdId = respVOBySols.stream().collect(Collectors.groupingBy(DeviceInfomationRespVOBySol::getProductId)); + + return deviceProducts.stream().map(deviceProductDO -> { + DeviceProductWithInfomationsRespVO respVO = BeanUtils.toBean(deviceProductDO, DeviceProductWithInfomationsRespVO.class); + respVO.setChildren(infoMapByPtdId.get(deviceProductDO.getId())); + return respVO; + }).toList(); + } + + @Override + public MaterialStandardSolutionRespVO getStandardSolutionWithMaterialInfo(Long id) { + return materialStandardSolutionMapper.selectStandardSolutionWithMaterialInfoById(id); + } + } \ No newline at end of file