refactor: 完善小型刀具库同步

This commit is contained in:
Kelvin 2024-12-16 08:48:06 +08:00
parent 19ffe615e5
commit 8fad8ba16c
9 changed files with 115 additions and 77 deletions

View File

@ -45,56 +45,6 @@ public class AP0AEServiceImpl implements IAP0AEService {
@Override
public List<AP0AE> selectReturnedNewData() {
List<AP0AE> 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<WmsInTask> wmsInTaskList = wmsInTaskService.selectWmsInTaskList(wmsInTask);
List<String> 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();
return this.aP0AEMapper.selectInNewData();
}
}

View File

@ -13,6 +13,12 @@ public interface InventoryAdjustmentMapper {
@DataSource(DataSourceType.SQLSERVER)
List<InventoryAdjustment> selectOutNewData();
@DataSource(DataSourceType.SQLSERVER)
List<InventoryAdjustment> selectInNewData();
@DataSource(DataSourceType.SQLSERVER)
int updateOutDataToOld(InventoryAdjustment inventoryAdjustment);
@DataSource(DataSourceType.SQLSERVER)
int updateInDataToOld(InventoryAdjustment inventoryAdjustment);
}

View File

@ -52,7 +52,7 @@ public class WmsInPlanController extends BaseController {
*/
@GetMapping(value = "/sync")
public AjaxResult sync() {
return AjaxResult.success(iAP0AEService.selectReturnedNewData());
return AjaxResult.success(wmsInPlanService.asyncSmallKnifeData());
}
/**

View File

@ -2,6 +2,7 @@ package com.ktg.mes.wm.mapper;
import java.util.List;
import com.ktg.mes.wm.domain.WmsInPlanDetailEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 入库计划明细实体Mapper接口
@ -9,7 +10,8 @@ import com.ktg.mes.wm.domain.WmsInPlanDetailEntity;
* @author yinjinlu
* @date 2024-11-05
*/
public interface WmsInPlanDetailEntityMapper
@Mapper
public interface WmsInPlanDetailEntityMapper
{
/**
* 查询入库计划明细实体

View File

@ -3,6 +3,7 @@ package com.ktg.mes.wm.mapper;
import java.util.List;
import com.ktg.mes.wm.domain.WmsInPlan;
import com.ktg.mes.wm.domain.WmsInPlanDetails;
import org.apache.ibatis.annotations.Mapper;
/**
* 入库计划Mapper接口
@ -10,7 +11,8 @@ import com.ktg.mes.wm.domain.WmsInPlanDetails;
* @author yinjinlu
* @date 2024-10-31
*/
public interface WmsInPlanMapper
@Mapper
public interface WmsInPlanMapper
{
/**
* 查询入库计划

View File

@ -29,6 +29,8 @@ public interface IWmsInPlanService
*/
public List<WmsInPlan> selectWmsInPlanList(WmsInPlan wmsInPlan);
public int asyncSmallKnifeData();
/**
* 新增入库计划
*

View File

@ -1,16 +1,22 @@
package com.ktg.mes.wm.service.impl;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import com.ktg.common.utils.DateUtils;
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.IMdItemService;
import com.ktg.mes.wm.domain.WmsInPlanDetailEntity;
import com.ktg.mes.wm.domain.WmsInTask;
import com.ktg.mes.stl.domain.InventoryAdjustment;
import com.ktg.mes.stl.mapper.InventoryAdjustmentMapper;
import com.ktg.mes.wm.domain.*;
import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper;
import com.ktg.mes.wm.service.IWmStorageAreaService;
import com.ktg.mes.wm.service.IWmsInTaskService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -19,9 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
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;
/**
@ -31,18 +35,15 @@ import com.ktg.mes.wm.service.IWmsInPlanService;
* @date 2024-10-31
*/
@Service
@RequiredArgsConstructor
public class WmsInPlanServiceImpl implements IWmsInPlanService {
@Autowired
private WmsInPlanMapper wmsInPlanMapper;
@Autowired
private WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper;
@Autowired
private IWmsInTaskService wmsInTaskService;
@Autowired
private IMdItemService mdItemService;
private final WmsInPlanMapper wmsInPlanMapper;
private final WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper;
private final IWmStorageAreaService wmStorageAreaService;
private final IWmsInTaskService wmsInTaskService;
private final IMdItemService mdItemService;
private final AP0AEMapper ap0AEMapper;
private final InventoryAdjustmentMapper inventoryAdjustmentMapper;
/**
* 查询入库计划
@ -81,6 +82,63 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService {
return wmsInPlanMapper.selectWmsInPlanList(wmsInPlan);
}
@Override
public int asyncSmallKnifeData() {
// List<AP0AE> ap0aeList = ap0AEMapper.selectInNewData();
List<InventoryAdjustment> inventoryAdjustments = inventoryAdjustmentMapper.selectInNewData();
int count = 0;
inventoryAdjustments.stream().filter(adjustment -> adjustment.getBillDate() != null).forEach(ap0ae -> {
WmsInPlan wmsInPlan = new WmsInPlan();
wmsInPlan.setPlanCode(MultiModuleCodeGenerator.generateTaskCode("RKP"));
// 发布人
wmsInPlan.setPublishName(ap0ae.getDataEntryClerk());
// 计划日期
wmsInPlan.setExpectDate(ap0ae.getInTime());
// 入库类型编码 刀片入库
wmsInPlan.setPlanTypeCode("DPRK");
// 库位编码
wmsInPlan.setCellCode(ap0ae.getInWarehouse());
// 业务类型 自动生成
wmsInPlan.setSourceType("XTTB");
// 已执行
wmsInPlan.setState("1");
// 查询库位信息
WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaCode(ap0ae.getInWarehouse());
MdItem mdItem = mdItemService.selectMdItemByCode(ap0ae.getProductNumber());
//-- 入库计划详情
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails();
// 状态-待执行
wmsInPlanDetails.setPlanInStatus("0");
// 库位ID
wmsInPlanDetails.setCellId(wmStorageArea.getAreaId());
wmsInPlanDetails.setQuantity(ap0ae.getQuantity().toString());
wmsInPlanDetails.setQuantityIn(ap0ae.getQuantity().toString());
wmsInPlanDetails.setMaterialId(mdItem.getItemId().toString());
wmsInPlan.setWmsInPlanDetailsList(Collections.singletonList(wmsInPlanDetails));
this.insertWmsInPlan(wmsInPlan);
// 执行入库计划
this.issueWmsInPlan(wmsInPlan.getPlanId());
WmsInTask wmsInTask = new WmsInTask();
wmsInTask.setPlanInId(wmsInPlan.getPlanId());
wmsInTask.setPlanInStatus("0");
List<WmsInTask> wmsInTaskList = wmsInTaskService.selectWmsInTaskList(wmsInTask);
List<String> taskId = new ArrayList<>();
wmsInTaskList.forEach(wmsInTask1 -> {
taskId.add(wmsInTask1.getId().toString());
});
wmsInTaskService.issueBatch(taskId.toArray(new String[0]));
ap0ae.setCustomField1("ED");
int i = inventoryAdjustmentMapper.updateInDataToOld(ap0ae);
System.out.println("小型刀具库----" + i);
});
return count;
}
/**
* 新增入库计划
*

View File

@ -32,9 +32,7 @@ public class WmsInTaskServiceImpl implements IWmsInTaskService {
private final IMdItemService mdItemService;
private final IWmsInPlanDetailEntityService wmsInPlanDetailEntityService;
private final WmStorageAreaMapper wmStorageAreaMapper;
private final IWmsInPlanService wmsInPlanService;
private final IWmStorageAreaService wmStorageAreaService;
private final IWmsZdTaskService wmsZdTaskService;
private final IBaseKnifeService baseKnifeService;
/**

View File

@ -79,12 +79,23 @@
<select id="selectOutNewData" resultMap="InventoryAdjustmentResult">
<include refid="InventoryAdjustmentSelectAllCol"/>
where UDF02 IS NULL
AND AD001 IS NOT NULL
AND AD002 IS NOT NULL
AND AD003 IS NOT NULL
AND AD004 IS NOT NULL
AND AD008 > 0
AND AD011 IS NOT NULL
AND AD001 IS NOT NULL
AND AD002 IS NOT NULL
AND AD003 IS NOT NULL
AND AD004 IS NOT NULL
AND AD008 > 0
AND AD011 IS NOT NULL
</select>
<select id="selectInNewData" resultMap="InventoryAdjustmentResult">
<include refid="InventoryAdjustmentSelectAllCol"/>
where UDF01 IS NULL
AND AD001 IS NOT NULL
AND AD002 IS NOT NULL
AND AD003 IS NOT NULL
AND AD004 IS NOT NULL
AND AD008 > 0
AND AD011 IS NOT NULL
</select>
<update id="updateOutDataToOld">
@ -95,4 +106,13 @@
AND AD003 = #{billDate}
AND AD004 = #{serialNumber}
</update>
<update id="updateInDataToOld">
update AP0AD
set UDF01 = 'ED'
where AD001 = #{singetsu}
AND AD002 = #{oddNumber}
AND AD003 = #{billDate}
AND AD004 = #{serialNumber}
</update>
</mapper>