From 4fa4371f0c299d70852b3e4190824b4c76e7c64b Mon Sep 17 00:00:00 2001 From: shusir <497819738@qq.com> Date: Wed, 25 Mar 2026 18:08:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=89=A9=E6=96=99=E6=8A=BD=E8=B1=A1?= =?UTF-8?q?=E5=87=BA=E5=AE=9E=E4=BE=8B=E7=9A=84=E5=85=A5=E5=BA=93=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialInventoryCheckDetailMapper.java | 2 +- .../material/enums/MaterialInboundType.java | 6 ++- .../service/MaterialInfomationService.java | 3 +- .../MaterialInfomationServiceImpl.java | 4 +- .../MaterialInventoryInboundService.java | 14 +++++- .../MaterialInventoryInboundServiceImpl.java | 48 +++++++++++++++---- .../service/MaterialLifecycleServiceImpl.java | 11 ++--- .../MaterialUseRecordDetailServiceImpl.java | 25 ++++++---- 8 files changed, 83 insertions(+), 30 deletions(-) diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryCheckDetailMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryCheckDetailMapper.java index 3ea834bd..28d48a3e 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryCheckDetailMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryCheckDetailMapper.java @@ -54,7 +54,7 @@ public interface MaterialInventoryCheckDetailMapper extends BaseMapperX inbounds); + + /** + * 入库物料实例 + * + * @param inbound 入库信息 + * @param product 需要入库的大类 + * @param totalQuantity 实例的总量 + * @param infomations 需要入库的物料实例 + * @return 物料实例 + */ + List inboundInfomation(MaterialInventoryInboundDO inbound, MaterialProductDO product, BigDecimal totalQuantity, List infomations); } \ 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 06fe1834..ae3c5bcb 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 @@ -20,24 +20,16 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.*; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryInboundMapper; import com.zt.plat.module.qms.resource.material.enums.MaterialAcceptStatus; import com.zt.plat.module.qms.resource.material.enums.MaterialInboundType; -import com.zt.plat.module.system.api.dept.DeptApi; -import com.zt.plat.module.system.api.dept.dto.DeptRespDTO; -import com.zt.plat.module.system.api.user.AdminUserApi; -import com.zt.plat.module.system.api.user.dto.AdminUserRespDTO; import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.ArrayList; import java.util.Collections; 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.*; @@ -146,6 +138,46 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb materialInventoryInboundMapper.insertBatch(inbounds); } + @Override + public List inboundInfomation(MaterialInventoryInboundDO inboundInfo, MaterialProductDO product, BigDecimal totalOperationQuantity, List infomations) { + MaterialInboundType inboundType = MaterialInboundType.fromName(inboundInfo.getBusinessType()); + // 1. 保存入库单 + materialInventoryInboundMapper.insert(inboundInfo); + if (inboundType == MaterialInboundType.hzrd_make_inbound) { + MaterialInfomationDO infomation = materialInfomationService.saveMaterialInfomationByHzrdMtrlMake(product, totalOperationQuantity); + MaterialInventoryInboundDetailDO detailDO = new MaterialInventoryInboundDetailDO() + .setInboundId(inboundInfo.getId()) + .setMaterialInfomationId(infomation.getId()) + .setInboundUserName(inboundInfo.getApplyUser()) + .setInboundUserId(inboundInfo.getApplyUserId()) + .setInboundDepartmentName(inboundInfo.getApplyDepartment()) + .setInboundDepartmentId(inboundInfo.getApplyDepartmentId()) + .setInboundTime(LocalDateTime.now()) + .setRemark(inboundInfo.getRemark()); + materialInventoryInboundDetailService.saveBatch(List.of(detailDO)); + return List.of(infomation); + } else if (inboundType == MaterialInboundType.check_inbound) { + // 保存入库明细 + List inboundDetails = infomations.stream() + .map(inf -> new MaterialInventoryInboundDetailDO() + .setInboundId(inboundInfo.getId()) + .setMaterialInfomationId(inf.getId()) + .setInboundUserName(inboundInfo.getApplyUser()) + .setInboundUserId(inboundInfo.getApplyUserId()) + .setInboundDepartmentName(inboundInfo.getApplyDepartment()) + .setInboundDepartmentId(inboundInfo.getApplyDepartmentId()) + .setInboundTime(LocalDateTime.now()) + .setRemark(inboundInfo.getRemark())) + .toList(); + materialInventoryInboundDetailService.saveBatch(inboundDetails); + + // 更新物料在库状态 + List infIds = infomations.stream().map(MaterialInfomationDO::getId).toList(); + materialInfomationService.updateByIds(infIds, new MaterialInfomationDO().setUsageStatus(0)); + } + return List.of(); + } + private MaterialInventoryInboundDO getInbound(MaterialInventoryInboundSaveReqVO createReqVO, MaterialBatchDO gongDO) { MaterialInventoryInboundDO inbound = BeanUtils.toBean(createReqVO, MaterialInventoryInboundDO.class); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); 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 7f1d67db..0a44d2bc 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 @@ -106,8 +106,6 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , private MaterialInventoryCheckDetailService materialInventoryCheckDetailService; @Autowired private MaterialInventoryInboundService materialInventoryInboundService; - @Autowired - private MaterialInventoryInboundDetailService materialInventoryInboundDetailService; @Transactional @Override @@ -1127,7 +1125,8 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , .setApplyTime(lifecycleDO.getApplyTime()) .setLocationId(locationId).setQuantity(BigDecimal.valueOf(infList.size())) .setRemark("盘点后不在库的入库"); - inbounds.add(inbound); + materialInventoryInboundService.inboundInfomation(inbound, null, null, infList); + /*inbounds.add(inbound); List detailDOS = infList.stream().map(inf -> new MaterialInventoryInboundDetailDO() .setInboundId(inbound.getId()) .setMaterialInfomationId(inf.getId()) @@ -1137,13 +1136,13 @@ public class MaterialLifecycleServiceImpl implements MaterialLifecycleService , .setInboundDepartmentId(inbound.getApplyDepartmentId()) .setInboundTime(LocalDateTime.now()) .setRemark("盘点后入库")).toList(); - inboundDetails.addAll(detailDOS); + inboundDetails.addAll(detailDOS);*/ } }); - materialInventoryInboundService.saveBatch(inbounds); + /*materialInventoryInboundService.saveBatch(inbounds); materialInventoryInboundDetailService.saveBatch(inboundDetails); // 更新物料在库状态 List infIds = infs.stream().map(MaterialInfomationDO::getId).toList(); - materialInfomationService.updateByIds(infIds, new MaterialInfomationDO().setUsageStatus(0)); + materialInfomationService.updateByIds(infIds, new MaterialInfomationDO().setUsageStatus(0));*/ } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailServiceImpl.java index 5c2c9994..863b253c 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialUseRecordDetailServiceImpl.java @@ -6,15 +6,14 @@ 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.framework.security.core.LoginUser; import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; import com.zt.plat.module.qms.resource.material.controller.vo.*; import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialUseRecordWithMakeInfoQueryVO; import com.zt.plat.module.qms.resource.material.controller.vo.resp.MaterialUseRecordWithMakeInfoRespVO; -import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; -import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO; -import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialUseRecordDO; -import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialUseRecordDetailDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.*; import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialUseRecordDetailMapper; +import com.zt.plat.module.qms.resource.material.enums.MaterialInboundType; import com.zt.plat.module.qms.resource.material.enums.MaterialOutboundType; import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; @@ -46,12 +45,12 @@ public class MaterialUseRecordDetailServiceImpl implements MaterialUseRecordDeta private MaterialInfomationService materialInfomationService; @Autowired private MaterialUseRecordService materialUseRecordService; - @Autowired private MaterialProductService materialProductService; - @Autowired private MaterialInventoryOutboundService materialInventoryOutboundService; + @Autowired + private MaterialInventoryInboundService materialInventoryInboundService; @Override public MaterialUseRecordDetailRespVO createMaterialUseRecordDetail(MaterialUseRecordDetailSaveReqVO createReqVO) { @@ -214,14 +213,24 @@ public class MaterialUseRecordDetailServiceImpl implements MaterialUseRecordDeta updateInfomationsRemainingVolume(recordDOS, infomations); // 生成物料实例 - MaterialInfomationDO infomationDO = materialInfomationService.saveMaterialInfomationByHzrdMtrlMake(product, totalOperationQuantity, productId); + // 入库 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + assert loginUser != null; + String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); + MaterialInventoryInboundDO inbound = new MaterialInventoryInboundDO() + .setTitle("危化品配置后入库") + .setBusinessType(MaterialInboundType.hzrd_make_inbound.getName()) + .setApplyUser(userNickname).setApplyUserId(loginUser.getId()) + .setApplyDepartment(loginUser.getVisitDeptName()).setApplyDepartmentId(loginUser.getVisitDeptId()) + .setApplyTime(LocalDateTime.now()); + MaterialInfomationDO infomationDO = materialInventoryInboundService.inboundInfomation(inbound, product, totalOperationQuantity, null).get(0); // 保存配置明细 List recordDetailDOS = recordDOS.stream().map(record -> new MaterialUseRecordDetailDO() .setRecordId(record.getId()).setInfomationId(record.getInfomationId()) .setTargetInfomationId(infomationDO.getId())).toList(); this.saveBatch(recordDetailDOS); - // 保存领用记录 + // 保存领用记录 - 出库 MaterialInventoryOutboundSaveReqVO outboundSaveReqVO = new MaterialInventoryOutboundSaveReqVO() .setBusinessType(MaterialOutboundType.receive_outbound.getName()) .setInfomationIds(Collections.singletonList(infomationDO.getId()))