diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/AP0AEMapper.java b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/AP0AEMapper.java index c0ae759..3529b4c 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/AP0AEMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/AP0AEMapper.java @@ -6,10 +6,19 @@ import com.ktg.mes.md.domain.AP0AE; import java.util.List; +/** + * @author Kelvin + */ public interface AP0AEMapper { @DataSource(DataSourceType.SQLSERVER) List selectOutNewData(); @DataSource(DataSourceType.SQLSERVER) int updateOutDataToOld(AP0AE ap0ae); + + @DataSource(DataSourceType.SQLSERVER) + List selectInNewData(); + + @DataSource(DataSourceType.SQLSERVER) + int updateInDataToOld(AP0AE ap0ae); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/IAP0AEService.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/IAP0AEService.java index b0c1446..39b039f 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/IAP0AEService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/IAP0AEService.java @@ -4,6 +4,12 @@ import com.ktg.mes.md.domain.AP0AE; import java.util.List; +/** + * @author luo26 + */ public interface IAP0AEService { public List selectOutNewData(); + + + public List selectInNewData(); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/AP0AEServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/AP0AEServiceImpl.java index f875b27..371709e 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/AP0AEServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/AP0AEServiceImpl.java @@ -2,21 +2,106 @@ package com.ktg.mes.md.service.impl; import com.ktg.common.annotation.DataSource; import com.ktg.common.enums.DataSourceType; +import com.ktg.generator.util.MultiModuleCodeGenerator; import com.ktg.mes.md.domain.AP0AE; +import com.ktg.mes.md.domain.MdItem; import com.ktg.mes.md.mapper.AP0AEMapper; import com.ktg.mes.md.service.IAP0AEService; +import com.ktg.mes.md.service.IMdItemService; +import com.ktg.mes.wm.domain.WmStorageArea; +import com.ktg.mes.wm.domain.WmsInPlan; +import com.ktg.mes.wm.domain.WmsInPlanDetails; +import com.ktg.mes.wm.domain.WmsInTask; +import com.ktg.mes.wm.service.IWmStorageAreaService; +import com.ktg.mes.wm.service.IWmsInPlanService; +import com.ktg.mes.wm.service.IWmsInTaskService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; +/** + * 小型刀具库-借领退还表 + * + * @author Kelvin + */ @Service public class AP0AEServiceImpl implements IAP0AEService { @Autowired private AP0AEMapper aP0AEMapper; + @Autowired + private IWmsInPlanService wmsInPlanService; + + @Autowired + private IWmsInTaskService wmsInTaskService; + + @Autowired + private IWmStorageAreaService wmStorageAreaService; + + @Autowired + private IMdItemService mdItemService; + @Override public List selectOutNewData() { return this.aP0AEMapper.selectOutNewData(); } + + @Override + public List selectInNewData() { + List ap0aeList = aP0AEMapper.selectInNewData(); + ap0aeList.stream().filter(ap0ae -> ap0ae.getAE003() != null).forEach(ap0ae -> { + WmsInPlan wmsInPlan = new WmsInPlan(); + wmsInPlan.setPlanCode(MultiModuleCodeGenerator.generateTaskCode("RKP")); + // 发布人 + wmsInPlan.setPublishName(ap0ae.getAE004()); + // 计划日期 + wmsInPlan.setExpectDate(ap0ae.getAE003()); + // 入库类型编码 刀片入库 + wmsInPlan.setPlanTypeCode("DPRK"); + // 库位编码 + wmsInPlan.setCellCode(ap0ae.getAE020()); + // 业务类型 自动生成 + wmsInPlan.setSourceType("XTTB"); + // 已执行 + wmsInPlan.setState("1"); + + // 查询库位信息 + WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaCode(ap0ae.getAE020()); + MdItem mdItem = mdItemService.selectMdItemByCode(ap0ae.getAE014()); + + //-- 入库计划详情 + WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails(); + // 状态-待执行 + wmsInPlanDetails.setPlanInStatus("0"); + // 库位ID + wmsInPlanDetails.setCellId(wmStorageArea.getAreaId()); + wmsInPlanDetails.setQuantity(ap0ae.getAE022().toString()); + wmsInPlanDetails.setQuantityIn(ap0ae.getAE022().toString()); + wmsInPlanDetails.setMaterialId(mdItem.getItemId().toString()); + + wmsInPlan.setWmsInPlanDetailsList(Collections.singletonList(wmsInPlanDetails)); + wmsInPlanService.insertWmsInPlan(wmsInPlan); + + // 执行入库计划 + wmsInPlanService.issueWmsInPlan(wmsInPlan.getPlanId()); + + WmsInTask wmsInTask = new WmsInTask(); + wmsInTask.setPlanInId(wmsInPlan.getPlanId()); + wmsInTask.setPlanInStatus("0"); + List wmsInTaskList = wmsInTaskService.selectWmsInTaskList(wmsInTask); + List taskId = new ArrayList<>(); + wmsInTaskList.forEach(wmsInTask1 -> { + taskId.add(wmsInTask1.getId().toString()); + }); + wmsInTaskService.issueBatch(taskId.toArray(new String[0])); + ap0ae.setUDF06("ED"); + int i = aP0AEMapper.updateInDataToOld(ap0ae); + System.out.println("小型刀具库----" + i); + }); + return Collections.emptyList(); + } } diff --git a/ktg-mes/src/main/resources/mapper/md/AP0AEMapper.xml b/ktg-mes/src/main/resources/mapper/md/AP0AEMapper.xml index 9e77fd9..f2af232 100644 --- a/ktg-mes/src/main/resources/mapper/md/AP0AEMapper.xml +++ b/ktg-mes/src/main/resources/mapper/md/AP0AEMapper.xml @@ -113,6 +113,15 @@ AND AE020 IS NOT NULL + + update AP0AE set UDF07 = 'ED' @@ -121,4 +130,13 @@ AND AE003 = #{AE003} AND AE012 = #{AE012} + + + update AP0AE + set UDF06 = 'ED' + where AE001 = #{AE001} + AND AE002 = #{AE002} + AND AE003 = #{AE003} + AND AE012 = #{AE012} + \ No newline at end of file