feat(入库): 同步小型刀具库

This commit is contained in:
Kelvin 2024-11-29 09:28:15 +08:00
parent cf0e3d0739
commit 42b1f93f4b
4 changed files with 118 additions and 0 deletions

View File

@ -6,10 +6,19 @@ import com.ktg.mes.md.domain.AP0AE;
import java.util.List;
/**
* @author Kelvin
*/
public interface AP0AEMapper {
@DataSource(DataSourceType.SQLSERVER)
List<AP0AE> selectOutNewData();
@DataSource(DataSourceType.SQLSERVER)
int updateOutDataToOld(AP0AE ap0ae);
@DataSource(DataSourceType.SQLSERVER)
List<AP0AE> selectInNewData();
@DataSource(DataSourceType.SQLSERVER)
int updateInDataToOld(AP0AE ap0ae);
}

View File

@ -4,6 +4,12 @@ import com.ktg.mes.md.domain.AP0AE;
import java.util.List;
/**
* @author luo26
*/
public interface IAP0AEService {
public List<AP0AE> selectOutNewData();
public List<AP0AE> selectInNewData();
}

View File

@ -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<AP0AE> selectOutNewData() {
return this.aP0AEMapper.selectOutNewData();
}
@Override
public List<AP0AE> selectInNewData() {
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();
}
}

View File

@ -113,6 +113,15 @@
AND AE020 IS NOT NULL
</select>
<select id="selectInNewData" resultMap="AP0AEResult">
<include refid="AP0AESelectAllCol"/>
WHERE UDF06 != 'ED'
AND AE025 = '归还单'
AND AE022 > 0
AND AE014 IS NOT NULL
AND AE020 IS NOT NULL
</select>
<update id="updateOutDataToOld">
update AP0AE
set UDF07 = 'ED'
@ -121,4 +130,13 @@
AND AE003 = #{AE003}
AND AE012 = #{AE012}
</update>
<update id="updateInDataToOld">
update AP0AE
set UDF06 = 'ED'
where AE001 = #{AE001}
AND AE002 = #{AE002}
AND AE003 = #{AE003}
AND AE012 = #{AE012}
</update>
</mapper>