diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java index dc0e3f5..ee0244c 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java @@ -3,7 +3,13 @@ package com.ktg.mes.wm.service.impl; import java.util.List; import com.ktg.common.utils.DateUtils; -import com.ktg.mes.wm.domain.WmsInPlanDetailEntity; +import com.ktg.generator.util.MultiModuleCodeGenerator; +import com.ktg.mes.md.domain.BaseKnife; +import com.ktg.mes.md.domain.MdItem; +import com.ktg.mes.md.service.IMdItemService; +import com.ktg.mes.md.service.impl.BaseKnifeServiceImpl; +import com.ktg.mes.wm.domain.*; +import com.ktg.mes.wm.mapper.UcmCtBaseMapper; import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; @@ -13,9 +19,7 @@ import java.util.ArrayList; import com.ktg.common.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; -import com.ktg.mes.wm.domain.WmsInPlanDetails; import com.ktg.mes.wm.mapper.WmsInPlanMapper; -import com.ktg.mes.wm.domain.WmsInPlan; import com.ktg.mes.wm.service.IWmsInPlanService; /** @@ -81,6 +85,10 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { @Override public int insertWmsInPlan(WmsInPlan wmsInPlan) { wmsInPlan.setCreateTime(DateUtils.getNowDate()); + // 设置计划编码 + if (wmsInPlan.getPlanCode() == null) { + wmsInPlan.setPlanCode(MultiModuleCodeGenerator.generateTaskCode("RKP")); + } int rows = wmsInPlanMapper.insertWmsInPlan(wmsInPlan); insertWmsInPlanDetails(wmsInPlan); return rows; @@ -132,6 +140,7 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { * * @param wmsInPlan 入库计划对象 */ + @Transactional public void insertWmsInPlanDetails(WmsInPlan wmsInPlan) { List wmsInPlanDetailsList = wmsInPlan.getWmsInPlanDetailsList(); Long planId = wmsInPlan.getPlanId(); @@ -160,17 +169,49 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { * * @param wmsInPlanDetails 入库计划明细对象 */ + @Transactional public void insertWmsInPlanDetailEntity(WmsInPlanDetails wmsInPlanDetails) { List wmsInPlanDetailEntityList = wmsInPlanDetails.getWmsInPlanDetailEntityList(); Long planId = wmsInPlanDetails.getPlanId(); Long planDetailsId = wmsInPlanDetails.getDetailsId(); + + // 查询物料信息 + MdItem mdItem = mdItemService.selectMdItemById(Long.parseLong(wmsInPlanDetails.getMaterialId())); + // 查询库位信息 + WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaId(wmsInPlanDetails.getCellId()); + if (StringUtils.isNotNull(wmsInPlanDetailEntityList)) { ArrayList list = new ArrayList<>(); for (WmsInPlanDetailEntity wmsInPlanDetailEntity : wmsInPlanDetailEntityList) { + if (wmsInPlanDetailEntity.getKnifeId() == null) { + // 生成台账 + BaseKnife baseKnife = new BaseKnife(); + baseKnife.setMbbBdMrlId(mdItem.getItemId()); + baseKnife.setKnifeCode(mdItem.getItemCode()); + baseKnife.setKnifeName(mdItem.getItemName()); + baseKnife.setKnifeUnit(mdItem.getUnitName()); + baseKnife.setKnifeType(mdItem.getItemTypeName()); + baseKnife.setAreaCode(wmStorageArea.getAreaCode()); + baseKnife.setSafeStock(mdItem.getMinStock()); + baseKnife.setStandardQuantity("1"); + baseKnife.setKnifeLife(100); + baseKnife.setRfid(wmsInPlanDetailEntity.getRfid()); + // 设置台账状态 入库 + baseKnife.setKnifeFineState(1); + // 设置为失效 + baseKnife.setIsValid(1); + baseKnife.setPlanSheet(""); + baseKnife.setResetCount(mdItem.getAttr1()); + baseKnife.setItemOrProduct(mdItem.getItemOrProduct()); + baseKnifeService.insertBaseKnife(baseKnife); + // 插入实例中台账ID + wmsInPlanDetailEntity.setKnifeId(baseKnife.getBaseKnifeId()); + } + + // 实例 wmsInPlanDetailEntity.setPlanId(planId); wmsInPlanDetailEntity.setPlanDetailsId(planDetailsId); wmsInPlanDetailEntity.setCreateTime(DateUtils.getNowDate()); - list.add(wmsInPlanDetailEntity); } if (!list.isEmpty()) { @@ -184,6 +225,7 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { * @param planCode 入库计划ID * @return 是否重复 */ + @Override public Boolean isDuplicatePlanCode(String planCode) { return wmsInPlanMapper.isDuplicatePlanCode(planCode); }