diff --git a/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java b/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java index d20ed33d..59415039 100644 --- a/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java +++ b/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java @@ -176,7 +176,7 @@ public interface ErrorCodeConstants { ErrorCode MATERIAL_INFOMATION_NOT_EXISTS = new ErrorCode(1_032_160_000, "试剂耗材不存在"); ErrorCode MATERIAL_PRODUCT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类不存在"); ErrorCode MATERIAL_PRODUCT_PARENT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类的父类不存在"); - ErrorCode MATERIAL_PRODUCT_CODE_EXISTED = new ErrorCode(1_032_160_000, "物料大类编码重复"); + ErrorCode MATERIAL_PRODUCT_CODE_MODELNO_EXISTED = new ErrorCode(1_032_160_000, "物料大类【编码+型号】重复"); ErrorCode MATERIAL_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_032_160_000, "分类下含有子分类或物料大类,不可删除"); ErrorCode MATERIAL_PRODUCT_EXISTS_BATCH = new ErrorCode(1_032_160_000, "物料大类下存在物料批次,不可删除"); ErrorCode MATERIAL_PRODUCTS_EXISTS_CATEGORY = new ErrorCode(1_032_160_000, "物料大类列表中存在分类数据"); @@ -188,6 +188,7 @@ public interface ErrorCodeConstants { ErrorCode MATERIAL_BATCH_ASSIGN_END = new ErrorCode(1_032_160_000, "物料批次已拆分,不可操作"); ErrorCode GONGDUAN_BELONG_MATERIAL_BATCH_NOT_EQUAL = new ErrorCode(1_032_160_000, "工段所属的物料批次不一致"); ErrorCode GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL = new ErrorCode(1_032_160_000, "工段累加数量和批次数量不一致"); + ErrorCode GONGDUAN_QUANTITY_MATERIAL_BATCH_AVAILABLE_QUANTITY_NOT_EQUAL = new ErrorCode(1_032_160_000, "工段累加数量和批次可用数量不一致"); ErrorCode MATERIAL_INVENTORY_INBOUND_NOT_EXISTS = new ErrorCode(1_032_160_000, "入库,出库不存在"); ErrorCode MATERIAL_INVENTORY_INBOUND_DETAIL_NOT_EXISTS = new ErrorCode(1_032_160_000, "入库明细,出库明细等不存在"); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java index 12ded776..62da82c4 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java @@ -1,5 +1,6 @@ package com.zt.plat.module.qms.resource.material.controller.admin; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; 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; @@ -39,6 +40,7 @@ import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*; @RestController @RequestMapping("/qms/resource/material-infomation") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialInfomationController implements BusinessControllerMarker { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleDetailController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleDetailController.java index 5b214a8f..35c75a72 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleDetailController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialLifecycleDetailController.java @@ -7,6 +7,7 @@ import com.zt.plat.framework.common.pojo.PageParam; 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.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.framework.excel.core.util.ExcelUtils; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialLifecycleDetailRespVO; @@ -33,6 +34,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-lifecycle-detail") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialLifecycleDetailController implements BusinessControllerMarker { 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 9d77f3e5..79021097 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 @@ -9,6 +9,7 @@ import com.zt.plat.framework.common.pojo.PageParam; 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.datapermission.core.annotation.DeptDataPermissionIgnore; 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; @@ -42,6 +43,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RequestMapping("/qms/resource/material-standard-solution") @Validated @FileUploadController(source = "qms.materialstandardsolution") +@DeptDataPermissionIgnore(enable = "true") public class MaterialStandardSolutionController extends AbstractFileUploadController implements BusinessControllerMarker{ static { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseController.java index 9ba44368..4684309a 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseController.java @@ -9,6 +9,7 @@ import com.zt.plat.framework.common.pojo.PageParam; 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.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.framework.excel.core.util.ExcelUtils; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseEndReusePageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseEndReuseRespVO; @@ -36,6 +37,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RequestMapping("/qms/resource/material-use-end-reuse") @Validated @FileUploadController(source = "qms.materialuseendreuse") +@DeptDataPermissionIgnore(enable = "true") public class MaterialUseEndReuseController extends AbstractFileUploadController implements BusinessControllerMarker{ static { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseDetailController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseDetailController.java index 80d4f1fa..2f72ec15 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseDetailController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseEndReuseDetailController.java @@ -7,6 +7,7 @@ import com.zt.plat.framework.common.pojo.PageParam; 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.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.framework.excel.core.util.ExcelUtils; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseEndReuseDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseEndReuseDetailRespVO; @@ -33,6 +34,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-use-end-reuse-detail") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialUseEndReuseDetailController implements BusinessControllerMarker { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordController.java index 4c9cea24..4b5341c8 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordController.java @@ -7,6 +7,7 @@ import com.zt.plat.framework.common.pojo.PageParam; 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.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.framework.excel.core.util.ExcelUtils; import com.zt.plat.module.qms.resource.material.controller.vo.*; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialUseRecordDO; @@ -33,6 +34,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-use-record") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialUseRecordController implements BusinessControllerMarker { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordDetailController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordDetailController.java index 147a0aba..71e448b3 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordDetailController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialUseRecordDetailController.java @@ -7,6 +7,7 @@ import com.zt.plat.framework.common.pojo.PageParam; 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.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.framework.excel.core.util.ExcelUtils; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialUseRecordDetailRespVO; @@ -35,6 +36,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-use-record-detail") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialUseRecordDetailController implements BusinessControllerMarker { 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 c3b49c49..94b01f16 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 @@ -114,6 +114,10 @@ public class MaterialLifecycleDetailRespVO { @ExcelProperty("批次或工段数量") private BigDecimal inboundQuantity; + @Schema(description = "批次或工段可用数量") + @ExcelProperty("批次或工段可用数量") + private BigDecimal remaineQuantity; + @Schema(description = "影响数量", example = "15772") @ExcelProperty("影响数量") private String influenceCount; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductSaveReqVO.java index 66cd8e87..e5e81b79 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductSaveReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductSaveReqVO.java @@ -1,6 +1,5 @@ package com.zt.plat.module.qms.resource.material.controller.vo; -import com.baomidou.mybatisplus.annotation.TableField; 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; @@ -100,10 +99,10 @@ public class MaterialProductSaveReqVO { private Integer assayFlag; @Schema(description = "是否进行库存预警,1-是,0-否") - private Integer InventoryAlarmFlag; + private Integer inventoryAlarmFlag; @Schema(description = "库存预警区间,json格式配置") - private String InventoryAlarmRange; + private String inventoryAlarmRange; @Schema(description = "备注") private String remark; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/query/MaterialProductQueryVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/query/MaterialProductQueryVO.java index cf626edd..bf9cd7ee 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/query/MaterialProductQueryVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/query/MaterialProductQueryVO.java @@ -1,5 +1,6 @@ package com.zt.plat.module.qms.resource.material.controller.vo.query; +import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -40,7 +41,10 @@ public class MaterialProductQueryVO { private Integer assayFlag; @Schema(description = "是否进行库存预警,1-是,0-否") - private Integer InventoryAlarmFlag; + private Integer inventoryAlarmFlag; + + @Schema(description = "分类其他配置") + private String categoryCustomConfig; @Schema(description = "备注") private String remark; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialLifecycleDetailMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialLifecycleDetailMapper.java index 16863a0f..1aec4f55 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialLifecycleDetailMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialLifecycleDetailMapper.java @@ -1,17 +1,13 @@ package com.zt.plat.module.qms.resource.material.dal.mapper; import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; -import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX; 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.dal.dataobject.*; -import groovy.util.logging.Slf4j; import org.apache.ibatis.annotations.Mapper; import java.util.HashMap; @@ -44,7 +40,7 @@ public interface MaterialLifecycleDetailMapper extends BaseMapperX selectListWithPdtBatInfo(Long id){ + default List selectListWithGongPdtBatInfo(Long id){ MPJLambdaWrapper wrapper = new MPJLambdaWrapper() .selectAll(MaterialLifecycleDetailDO.class) .selectAs("product.NAME", MaterialLifecycleDetailRespVO::getProductName) @@ -130,4 +126,22 @@ public interface MaterialLifecycleDetailMapper extends BaseMapperX selectListWithBatchPdtBatInfo(Long id) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapper() + .selectAll(MaterialLifecycleDetailDO.class) + .selectAs("product.NAME", MaterialLifecycleDetailRespVO::getProductName) + .selectAs("product.CD", MaterialLifecycleDetailRespVO::getProductCode) + .selectAs("product.MDL_NO", MaterialLifecycleDetailRespVO::getProductModelNo) + .selectAs("product.UNT", MaterialLifecycleDetailRespVO::getUnit) + .selectAs(MaterialBatchDO::getBatchNo, MaterialLifecycleDetailRespVO::getBatchNo) + .selectAs(MaterialBatchDO::getInboundQuantity, MaterialLifecycleDetailRespVO::getInboundQuantity) + .selectAs(MaterialBatchDO::getRemaineQuantity, MaterialLifecycleDetailRespVO::getRemaineQuantity) + .leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialLifecycleDetailDO::getBatchId) + .leftJoin(MaterialProductDO.class, "product", MaterialProductDO::getId, MaterialBatchDO::getProductId) + + .eq(MaterialLifecycleDetailDO::getLifecycleId, id); + + 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/enums/MaterialFlowType.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialFlowType.java index f159fd52..9bfd9778 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialFlowType.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialFlowType.java @@ -13,7 +13,7 @@ public enum MaterialFlowType { make_apply("配置申请"), - verify_calibrate("检定校准") + verify_calibrate("量具检定") ; private final String name; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java index 5cf7b4d1..dbe83f6f 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java @@ -1,6 +1,7 @@ package com.zt.plat.module.qms.resource.material.service; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.exception.ServiceException; @@ -26,6 +27,7 @@ import com.zt.plat.module.qms.resource.material.enums.MaterialAcceptStatus; import com.zt.plat.module.qms.resource.material.enums.MaterialBatchGongType; import com.zt.plat.module.qms.resource.material.enums.MaterialFlowType; 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; @@ -34,6 +36,7 @@ import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; import java.util.Map; @@ -49,6 +52,7 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*; * * @author 后台管理 */ +@Slf4j @Service @Validated public class MaterialBatchServiceImpl implements MaterialBatchService { @@ -178,8 +182,8 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { for (MaterialBatchSaveReqVO batAsn : createReqVOs) { total = total.add(batAsn.getInboundQuantity()); } - if (total.compareTo(mtrlBat.getInboundQuantity()) != 0) - throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL); + if (total.compareTo(mtrlBat.getRemaineQuantity()) != 0) + throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_AVAILABLE_QUANTITY_NOT_EQUAL); // 修改工段 boolean exists = materialBatchMapper.exists(Wrappers.lambdaQuery(MaterialBatchDO.class) .eq(MaterialBatchDO::getParentId, batId)); @@ -228,8 +232,8 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { for (MaterialBatchDO gongduan : gongduans) { gongTotalInbQuantity = gongTotalInbQuantity.add(gongduan.getInboundQuantity()); } - if (batchDO.getInboundQuantity().compareTo(gongTotalInbQuantity) != 0) - throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL); + if (batchDO.getRemaineQuantity().compareTo(gongTotalInbQuantity) != 0) + throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_AVAILABLE_QUANTITY_NOT_EQUAL); batchDO.setSubmitStatus(1).setSubmitDate(LocalDateTime.now()); materialBatchMapper.updateById(batchDO); // 提交工段 @@ -455,12 +459,12 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { UserSimpleDTO startUser = instanceData.getStartUser(); List batIds = lifecycleDetailDOs.stream().map(MaterialLifecycleDetailDO::getBatchId).toList(); List batchDOS = this.getBatchListByBatchIds(batIds); + LocalDateTime submitDate = LocalDateTime.now(); Map batchDOMap = batchDOS.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity())); List gongs = lifecycleDetailDOs.stream().map(detailDO -> { MaterialBatchDO batchDO = batchDOMap.get(detailDO.getBatchId()); - // TODO 此批次此部门下可能已经创建过 Long deptId = startUser.getDeptId(); - MaterialBatchDO gong = new MaterialBatchDO() + return new MaterialBatchDO() .setParentId(detailDO.getBatchId()) .setProductId(batchDO.getProductId()) .setAssignDepartmentId(deptId) @@ -468,10 +472,14 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { .setInboundQuantity(detailDO.getQualifiedCount()) .setBatchNo(batchDO.getBatchNo()) .setRemaineQuantity(detailDO.getQualifiedCount()) - .setAcceptanceStatus(MaterialAcceptStatus.accepted.name()); - return gong; + .setAcceptanceStatus(MaterialAcceptStatus.accepted.name()) + .setSubmitStatus(1).setSubmitDate(submitDate) + .setRemark(String.format("发起人:%s,发起时间:%s,检定生成的批次拆分", startUser.getNickname(), instanceData.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); }).toList(); materialBatchMapper.insertBatch(gongs); + MaterialBatchDO batchUpdate = new MaterialBatchDO().setSubmitStatus(1).setSubmitDate(submitDate); + materialBatchMapper.update(batchUpdate, Wrappers.lambdaQuery(MaterialBatchDO.class) + .in(MaterialBatchDO::getId, batIds)); } private void lockBatchOrGongReturnExchangeCount(LockType lockType, List batchOrGongDOS, Map lifecycleDetailDOMapByBatOrGongId) { @@ -485,7 +493,11 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { throw new ServiceException(1_032_160_000, "退换货数量大于可用数量"); batOrGong.setLockQuantity(lockQuantity); } - case unlock -> batOrGong.setLockQuantity(batOrGong.getLockQuantity().subtract(influenceCount)); + case unlock -> { + batOrGong.setLockQuantity(batOrGong.getLockQuantity().subtract(influenceCount)); + if (batOrGong.getLockQuantity().compareTo(BigDecimal.ZERO) < 0) + throw new ServiceException(1_032_160_000, "锁定数量小于0,数据异常"); + } } } } 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 68038002..f32609a1 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,21 +1,16 @@ 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.enums.QmsBpmConstant; -import com.zt.plat.module.qms.enums.QmsCommonConstant; -import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundSaveReqVO; 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.*; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialLifecycleDetailMapper; import com.zt.plat.module.qms.resource.material.enums.MaterialFlowType; -import com.zt.plat.module.qms.resource.material.enums.MaterialInfomationOrigin; import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -140,46 +135,52 @@ public class MaterialLifecycleDetailServiceImpl implements MaterialLifecycleDeta @Override public List getDetailListWithPdtInfoByLfcId(MaterialLifecycleDO lifecycleDO) { // 退换货时单独处理 - String businessType = lifecycleDO.getBusinessType(); - MaterialFlowType flowType = MaterialFlowType.fromName(businessType); - if (MaterialFlowType.return_material.equals(flowType) || MaterialFlowType.exchange_material.equals(flowType)) { - List detailRespVOS = materialLifecycleDetailMapper.selectListWithReturnExchangeInfo(lifecycleDO.getId()); - if (CollUtil.isEmpty(detailRespVOS)) return detailRespVOS; - List batOrGongIds = detailRespVOS.stream() - .flatMap(detail -> Stream.of(detail.getBatchId(), detail.getBatchGongduanId()).filter(Objects::nonNull)) - .toList(); - List batOrGongDOS = materialBatchService.getListByIds(batOrGongIds); - if (CollUtil.isEmpty(batOrGongDOS)) return detailRespVOS; - Set pdtIds = batOrGongDOS.stream().map(MaterialBatchDO::getProductId).collect(Collectors.toSet()); - List products = materialProductService.getMaterialProductListByPdtIds(new ArrayList<>(pdtIds)); - if (CollUtil.isEmpty(products)) return detailRespVOS; - Map batOrGongMapById = batOrGongDOS.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity())); - Map productMapById = products.stream().collect(Collectors.toMap(MaterialProductDO::getId, Function.identity())); - for (MaterialLifecycleDetailRespVO detailRespVO : detailRespVOS) { - MaterialProductDO productDO = new MaterialProductDO(); - if (detailRespVO.getBatchId() != null) { - MaterialBatchDO batchDO = batOrGongMapById.get(detailRespVO.getBatchId()); - detailRespVO.setGongParentId(0L); - detailRespVO.setInboundQuantity(batchDO.getInboundQuantity()); - productDO = productMapById.get(batchDO.getProductId()); - } else if (detailRespVO.getBatchGongduanId() != null) { - MaterialBatchDO gongDO = batOrGongMapById.get(detailRespVO.getBatchGongduanId()); - detailRespVO.setGongParentId(gongDO.getParentId()); - detailRespVO.setBatchNo(gongDO.getBatchNo()); - detailRespVO.setInboundQuantity(gongDO.getInboundQuantity()); - productDO = productMapById.get(gongDO.getProductId()); - } - detailRespVO - .setProductId(productDO.getId()) - .setProductName(productDO.getName()) - .setProductCode(productDO.getCode()) - .setProductModelNo(productDO.getModelNo()); + MaterialFlowType flowType = MaterialFlowType.fromName(lifecycleDO.getBusinessType()); + switch (flowType) { + case acceptance -> { + return materialLifecycleDetailMapper.selectListWithGongPdtBatInfo(lifecycleDO.getId()); + } + case verify_calibrate -> { + return materialLifecycleDetailMapper.selectListWithBatchPdtBatInfo(lifecycleDO.getId()); + } + case return_material, exchange_material -> { + List detailRespVOS = materialLifecycleDetailMapper.selectListWithReturnExchangeInfo(lifecycleDO.getId()); + if (CollUtil.isEmpty(detailRespVOS)) return detailRespVOS; + List batOrGongIds = detailRespVOS.stream() + .flatMap(detail -> Stream.of(detail.getBatchId(), detail.getBatchGongduanId()).filter(Objects::nonNull)) + .toList(); + List batOrGongDOS = materialBatchService.getListByIds(batOrGongIds); + if (CollUtil.isEmpty(batOrGongDOS)) return detailRespVOS; + Set pdtIds = batOrGongDOS.stream().map(MaterialBatchDO::getProductId).collect(Collectors.toSet()); + List products = materialProductService.getMaterialProductListByPdtIds(new ArrayList<>(pdtIds)); + if (CollUtil.isEmpty(products)) return detailRespVOS; + Map batOrGongMapById = batOrGongDOS.stream().collect(Collectors.toMap(MaterialBatchDO::getId, Function.identity())); + Map productMapById = products.stream().collect(Collectors.toMap(MaterialProductDO::getId, Function.identity())); + for (MaterialLifecycleDetailRespVO detailRespVO : detailRespVOS) { + MaterialProductDO productDO = new MaterialProductDO(); + if (detailRespVO.getBatchId() != null) { + MaterialBatchDO batchDO = batOrGongMapById.get(detailRespVO.getBatchId()); + detailRespVO.setGongParentId(0L); + detailRespVO.setInboundQuantity(batchDO.getInboundQuantity()); + productDO = productMapById.get(batchDO.getProductId()); + } else if (detailRespVO.getBatchGongduanId() != null) { + MaterialBatchDO gongDO = batOrGongMapById.get(detailRespVO.getBatchGongduanId()); + detailRespVO.setGongParentId(gongDO.getParentId()); + detailRespVO.setBatchNo(gongDO.getBatchNo()); + detailRespVO.setInboundQuantity(gongDO.getInboundQuantity()); + productDO = productMapById.get(gongDO.getProductId()); + } + detailRespVO + .setProductId(productDO.getId()) + .setProductName(productDO.getName()) + .setProductCode(productDO.getCode()) + .setProductModelNo(productDO.getModelNo()); + } + return detailRespVOS; } - return detailRespVOS; - } else { - return materialLifecycleDetailMapper.selectListWithPdtBatInfo(lifecycleDO.getId()); } + return List.of(); } 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 b1dd9960..afc8c125 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 @@ -227,9 +227,10 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , || MaterialFlowType.exchange_material.getName().equals(mtrlLfc.getBusinessType()); if (isReturnExchangeMaterial) lockReturnExchangeResources(oriDetailList, LockType.unlock); - // 释放原理啊物料检定资源 + // 释放原理物料检定资源 boolean isVerifyCalibrate = MaterialFlowType.verify_calibrate.getName().equals(mtrlLfc.getBusinessType()); if (isVerifyCalibrate) lockVerifyCalibrateResources(oriDetailList, LockType.unlock); + List detailDOS = getLifecycleDetailDOSByBusinessType(detailList, mtrlLfc); // 保存新的明细 materialLifecycleDetailService.saveBatch(detailDOS); @@ -317,6 +318,8 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , BigDecimal remaineQuantity = batchDO.getRemaineQuantity(); if (reqDetail.getInfluenceCount().compareTo(remaineQuantity) > 0) throw new ServiceException(1_032_160_000, String.format("检定数量超过了批次【%s】可用数量【%s】", batchDO.getBatchNo(), remaineQuantity)); + if (reqDetail.getQualifiedCount().compareTo(reqDetail.getInfluenceCount()) > 0) + throw new ServiceException(1_032_160_000, "合格数量超过了检定数量"); } return reqDetails.stream().map(detail -> { @@ -324,6 +327,8 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , detailDO.setLifecycleId(mtrlLfc.getId()) .setBatchId(detail.getBatchId()) .setInfluenceCount(detail.getInfluenceCount()) + .setQualifiedCount(detail.getQualifiedCount()) + .setUnqualifiedCount(detail.getInfluenceCount().subtract(detail.getQualifiedCount())) .setBusinessType(mtrlLfc.getBusinessType()) .setTreatmentStatus(0) .setRemark(detail.getRemark()); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java index 4a9e6ba7..ad89d246 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.exception.ServiceException; import com.zt.plat.framework.common.pojo.CommonResult; @@ -195,7 +196,7 @@ public class MaterialProductServiceImpl implements MaterialProductService { // 新增 if (reqId == null) { boolean exists = materialProductMapper.exists(queryWrapperX); - if (exists) throw exception(MATERIAL_PRODUCT_CODE_EXISTED); + if (exists) throw exception(MATERIAL_PRODUCT_CODE_MODELNO_EXISTED); // 从直接父分类获取是否危险品、是否标准物质、是否标准溶液 MaterialProductDO prnCtg = materialProductMapper.selectById(mtrl.getParentId()); if (prnCtg != null) { @@ -214,15 +215,12 @@ public class MaterialProductServiceImpl implements MaterialProductService { if (origDO == null) throw exception(MATERIAL_PRODUCT_NOT_EXISTS); queryWrapperX.neIfPresent(MaterialProductDO::getId, reqId); boolean exists = materialProductMapper.exists(queryWrapperX); - if (exists) throw exception(MATERIAL_PRODUCT_CODE_EXISTED); + if (exists) throw exception(MATERIAL_PRODUCT_CODE_MODELNO_EXISTED); businessFileService.deleteBusinessFileList(createReqVO.getDeleteFileIdList()); Long newParentId = createReqVO.getParentId(); - if (origDO.getParentId().equals(newParentId)) { - materialProductMapper.updateById(mtrl); - return BeanUtils.toBean(mtrl, MaterialProductRespVO.class); - } else { + if (!origDO.getParentId().equals(newParentId)) { // 父节点有变更,更新大类属性 MaterialProductDO productDO = materialProductMapper.selectById(newParentId); MaterialProductDO topParent; @@ -243,9 +241,23 @@ public class MaterialProductServiceImpl implements MaterialProductService { String newIdPath = getIdPath(mtrl); mtrl.setIdPath(newIdPath); materialProductMapper.updateById(mtrl); + // 处理库存预警级别 + handleInventoryAlarmLevel(mtrl, reqId); return BeanUtils.toBean(mtrl, MaterialProductRespVO.class); } + private void handleInventoryAlarmLevel(MaterialProductDO mtrl, Long reqId) { + if (mtrl.getInventoryAlarmFlag() != null && mtrl.getInventoryAlarmFlag() == 1) { + // 根据实际库存数量计算准确的预警级别 + this.updateMaterialProductAlarmLevel(Collections.singletonList(reqId)); + } else if (mtrl.getInventoryAlarmFlag() != null && mtrl.getInventoryAlarmFlag() == 0) { + // 明确禁用预警,清空预警级别 + materialProductMapper.update(Wrappers.lambdaUpdate(MaterialProductDO.class) + .eq(MaterialProductDO::getId, reqId) + .set(MaterialProductDO::getInventoryAlarmLevel, null)); + } + } + @Override public void updateMaterialProduct(MaterialProductSaveReqVO updateReqVO) { // 校验存在 @@ -337,12 +349,16 @@ public class MaterialProductServiceImpl implements MaterialProductService { @Override public List getCategoryAndData(MaterialProductQueryVO queryVO) { - LambdaQueryWrapperX wrapperX = new LambdaQueryWrapperX() + LambdaQueryWrapper wrapperX = new LambdaQueryWrapperX() .eqIfPresent(MaterialProductDO::getNodeType, queryVO.getNodeType()) .eqIfPresent(MaterialProductDO::getHazardous, queryVO.getHazardous()) .eqIfPresent(MaterialProductDO::getStandardSolutionFlag, queryVO.getStandardSolutionFlag()) .eqIfPresent(MaterialProductDO::getStandardMaterialFlag, queryVO.getStandardMaterialFlag()) - .likeIfPresent(MaterialProductDO::getName, queryVO.getName()); + .likeIfPresent(MaterialProductDO::getName, queryVO.getName()) + .and(StrUtil.isNotEmpty(queryVO.getCategoryCustomConfig()), + wrapper -> + wrapper.eq(MaterialProductDO::getNodeType, DataTypeConstant.DATA_TYPE_CATEGORY) + .like(MaterialProductDO::getCustomConfig, queryVO.getCategoryCustomConfig())); List mtrlDos = materialProductMapper.selectList(wrapperX); if (CollUtil.isEmpty(mtrlDos)) return List.of(); @@ -359,11 +375,9 @@ public class MaterialProductServiceImpl implements MaterialProductService { List voList = mtrlDos.stream().map(m -> BeanUtils.toBean(m, MaterialProductRespVO.class)).toList(); // 一次性获取大类下的库存数量 Map stockQuantityMap = materialProductMapper.getStockQuantityByPdtIds(mtrlIds); - if (CollUtil.isNotEmpty(stockQuantityMap)) { - for (MaterialProductRespVO vo : voList) { - Long val = stockQuantityMap.get(vo.getId()); - vo.setInventoryQuantity(BigDecimal.valueOf(val == null ? 0L : val)); - } + for (MaterialProductRespVO vo : voList) { + Long val = stockQuantityMap.get(vo.getId()); + vo.setInventoryQuantity(BigDecimal.valueOf(val == null ? 0L : val)); } return new PageResult<>(voList, pageResult.getTotal()); @@ -401,7 +415,8 @@ public class MaterialProductServiceImpl implements MaterialProductService { // BigDecimal[] safeRange = (BigDecimal[]) alarmRange.get(MaterialInventoryAlarmLevel.safe.name()); List dangerRange = alarmRange.getJSONArray(MaterialInventoryAlarmLevel.danger.name()).toList(BigDecimal.class); List warnRange = alarmRange.getJSONArray(MaterialInventoryAlarmLevel.warn.name()).toList(BigDecimal.class); - BigDecimal inventoryQuantity = BigDecimal.valueOf(stockQuantityMap.get(m.getId())); + Long qty = stockQuantityMap.get(m.getId()); + BigDecimal inventoryQuantity = BigDecimal.valueOf(qty == null ? 0L : qty); if (inventoryQuantity.compareTo(dangerRange.get(1)) <= 0) { alarmLevel = MaterialInventoryAlarmLevel.danger.name(); } else if (inventoryQuantity.compareTo(warnRange.get(1)) <= 0) {