Merge remote-tracking branch 'origin/master'

This commit is contained in:
汤锦科 2024-11-29 09:27:04 +08:00
commit 72dac19897
6 changed files with 604 additions and 10 deletions

View File

@ -49,6 +49,7 @@ public class WmsOutPlanController extends BaseController {
@PreAuthorize("@ss.hasPermi('md:PLAN:list')")
@GetMapping("/list")
public TableDataInfo list(WmsOutPlan wmsOutPlan) {
wmsOutPlanService.synchronizationMiniBox(getUsername()); // 调试
startPage();
List<WmsOutPlan> list = wmsOutPlanService.selectWmsOutPlanList(wmsOutPlan);
return getDataTable(list);

View File

@ -0,0 +1,360 @@
package com.ktg.mes.md.domain;
import java.util.Date;
public class AP0AD {
private String AD001 = null;
private String AD002 = null;
private Date AD003 = null;
private String AD004 = null;
private String AD005 = null;
private String AD006 = null;
private String AD007 = null;
private Double AD008 = null;
private Double AD009 = null;
private Double AD010 = null;
private String AD011 = null;
private String AD012 = null;
private String AD013 = null;
private String AD014 = null;
private String AD015 = null;
private String AD016 = null;
private String AD017 = null;
private String UDF01 = null;
private String UDF02 = null;
private String UDF03 = null;
private String UDF04 = null;
private String UDF05 = null;
private Double UDF51 = null;
private Double UDF52 = null;
private Double UDF53 = null;
private Double UDF54 = null;
private Double UDF55 = null;
private String USER01 = null;
private String USER02 = null;
private Date DATE01 = null;
private Date DATE02 = null;
public AP0AD() {
super();
}
public AP0AD(String AD001, String AD002, Date AD003, String AD004, String AD005, String AD006, String AD007, Double AD008, Double AD009, Double AD010, String AD011, String AD012, String AD013, String AD014, String AD015, String AD016, String AD017, String UDF01, String UDF02, String UDF03, String UDF04, String UDF05, Double UDF51, Double UDF52, Double UDF53, Double UDF54, Double UDF55, String USER01, String USER02, Date DATE01, Date DATE02) {
this.AD001 = AD001;
this.AD002 = AD002;
this.AD003 = AD003;
this.AD004 = AD004;
this.AD005 = AD005;
this.AD006 = AD006;
this.AD007 = AD007;
this.AD008 = AD008;
this.AD009 = AD009;
this.AD010 = AD010;
this.AD011 = AD011;
this.AD012 = AD012;
this.AD013 = AD013;
this.AD014 = AD014;
this.AD015 = AD015;
this.AD016 = AD016;
this.AD017 = AD017;
this.UDF01 = UDF01;
this.UDF02 = UDF02;
this.UDF03 = UDF03;
this.UDF04 = UDF04;
this.UDF05 = UDF05;
this.UDF51 = UDF51;
this.UDF52 = UDF52;
this.UDF53 = UDF53;
this.UDF54 = UDF54;
this.UDF55 = UDF55;
this.USER01 = USER01;
this.USER02 = USER02;
this.DATE01 = DATE01;
this.DATE02 = DATE02;
}
public String getAD001() {
return AD001;
}
public void setAD001(String AD001) {
this.AD001 = AD001;
}
public String getAD002() {
return AD002;
}
public void setAD002(String AD002) {
this.AD002 = AD002;
}
public Date getAD003() {
return AD003;
}
public void setAD003(Date AD003) {
this.AD003 = AD003;
}
public String getAD004() {
return AD004;
}
public void setAD004(String AD004) {
this.AD004 = AD004;
}
public String getAD005() {
return AD005;
}
public void setAD005(String AD005) {
this.AD005 = AD005;
}
public String getAD006() {
return AD006;
}
public void setAD006(String AD006) {
this.AD006 = AD006;
}
public String getAD007() {
return AD007;
}
public void setAD007(String AD007) {
this.AD007 = AD007;
}
public Double getAD008() {
return AD008;
}
public void setAD008(Double AD008) {
this.AD008 = AD008;
}
public Double getAD009() {
return AD009;
}
public void setAD009(Double AD009) {
this.AD009 = AD009;
}
public Double getAD010() {
return AD010;
}
public void setAD010(Double AD010) {
this.AD010 = AD010;
}
public String getAD011() {
return AD011;
}
public void setAD011(String AD011) {
this.AD011 = AD011;
}
public String getAD012() {
return AD012;
}
public void setAD012(String AD012) {
this.AD012 = AD012;
}
public String getAD013() {
return AD013;
}
public void setAD013(String AD013) {
this.AD013 = AD013;
}
public String getAD014() {
return AD014;
}
public void setAD014(String AD014) {
this.AD014 = AD014;
}
public String getAD015() {
return AD015;
}
public void setAD015(String AD015) {
this.AD015 = AD015;
}
public String getAD016() {
return AD016;
}
public void setAD016(String AD016) {
this.AD016 = AD016;
}
public String getAD017() {
return AD017;
}
public void setAD017(String AD017) {
this.AD017 = AD017;
}
public String getUDF01() {
return UDF01;
}
public void setUDF01(String UDF01) {
this.UDF01 = UDF01;
}
public String getUDF02() {
return UDF02;
}
public void setUDF02(String UDF02) {
this.UDF02 = UDF02;
}
public String getUDF03() {
return UDF03;
}
public void setUDF03(String UDF03) {
this.UDF03 = UDF03;
}
public String getUDF04() {
return UDF04;
}
public void setUDF04(String UDF04) {
this.UDF04 = UDF04;
}
public String getUDF05() {
return UDF05;
}
public void setUDF05(String UDF05) {
this.UDF05 = UDF05;
}
public Double getUDF51() {
return UDF51;
}
public void setUDF51(Double UDF51) {
this.UDF51 = UDF51;
}
public Double getUDF52() {
return UDF52;
}
public void setUDF52(Double UDF52) {
this.UDF52 = UDF52;
}
public Double getUDF53() {
return UDF53;
}
public void setUDF53(Double UDF53) {
this.UDF53 = UDF53;
}
public Double getUDF54() {
return UDF54;
}
public void setUDF54(Double UDF54) {
this.UDF54 = UDF54;
}
public Double getUDF55() {
return UDF55;
}
public void setUDF55(Double UDF55) {
this.UDF55 = UDF55;
}
public String getUSER01() {
return USER01;
}
public void setUSER01(String USER01) {
this.USER01 = USER01;
}
public String getUSER02() {
return USER02;
}
public void setUSER02(String USER02) {
this.USER02 = USER02;
}
public Date getDATE01() {
return DATE01;
}
public void setDATE01(Date DATE01) {
this.DATE01 = DATE01;
}
public Date getDATE02() {
return DATE02;
}
public void setDATE02(Date DATE02) {
this.DATE02 = DATE02;
}
@Override
public String toString() {
return "AP0AD{" +
"AD001='" + AD001 + '\'' +
", AD002='" + AD002 + '\'' +
", AD003=" + AD003 +
", AD004='" + AD004 + '\'' +
", AD005='" + AD005 + '\'' +
", AD006='" + AD006 + '\'' +
", AD007='" + AD007 + '\'' +
", AD008=" + AD008 +
", AD009=" + AD009 +
", AD010=" + AD010 +
", AD011='" + AD011 + '\'' +
", AD012='" + AD012 + '\'' +
", AD013='" + AD013 + '\'' +
", AD014='" + AD014 + '\'' +
", AD015='" + AD015 + '\'' +
", AD016='" + AD016 + '\'' +
", AD017='" + AD017 + '\'' +
", UDF01='" + UDF01 + '\'' +
", UDF02='" + UDF02 + '\'' +
", UDF03='" + UDF03 + '\'' +
", UDF04='" + UDF04 + '\'' +
", UDF05='" + UDF05 + '\'' +
", UDF51=" + UDF51 +
", UDF52=" + UDF52 +
", UDF53=" + UDF53 +
", UDF54=" + UDF54 +
", UDF55=" + UDF55 +
", USER01='" + USER01 + '\'' +
", USER02='" + USER02 + '\'' +
", DATE01=" + DATE01 +
", DATE02=" + DATE02 +
'}';
}
}

View File

@ -0,0 +1,15 @@
package com.ktg.mes.md.mapper;
import com.ktg.common.annotation.DataSource;
import com.ktg.common.enums.DataSourceType;
import com.ktg.mes.md.domain.AP0AD;
import java.util.List;
public interface AP0ADMapper {
@DataSource(DataSourceType.SQLSERVER)
List<AP0AD> selectOutNewData();
@DataSource(DataSourceType.SQLSERVER)
int updateOutDataToOld(AP0AD ap0ad);
}

View File

@ -9,10 +9,13 @@ import com.ktg.mes.md.mapper.*;
import com.ktg.mes.md.service.IWmsOutPlanService;
import com.ktg.mes.wm.domain.WmStorageArea;
import com.ktg.mes.wm.mapper.WmStorageAreaMapper;
import com.ktg.mes.wm.mapper.WmStorageLocationMapper;
import com.ktg.mes.wm.mapper.WmWarehouseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@ -44,10 +47,16 @@ public class WmsOutPlanServiceImpl implements IWmsOutPlanService {
private MdItemMapper mdItemMapper;
@Autowired
private WmStorageAreaMapper wmStorageAreaMapper;
private AP0AEMapper ap0AEMapper;
@Autowired
private AP0AEMapper ap0AEMapper;
private WmWarehouseMapper wmWarehouseMapper;
@Autowired
private WmStorageLocationMapper wmStorageLocationMapper;
@Autowired
private WmStorageAreaMapper wmStorageAreaMapper;
/**
* 查询出库计划管理
@ -268,17 +277,134 @@ public class WmsOutPlanServiceImpl implements IWmsOutPlanService {
@Override
public int synchronizationMiniBox(String username) {
// 获得全部未记录的小货柜出库数据
HashMap<String, List<AP0AE>> ap0aeDateMap = new HashMap<>();
List<AP0AE> ap0AEList = ap0AEMapper.selectOutNewData();
System.out.println("=========================================");
System.out.println(JSON.toJSONString(ap0AEList));
System.out.println("=========================================");
ap0AEList.forEach(ap0AE -> {
String dateKey = new SimpleDateFormat("yyyy-MM-dd").format(ap0AE.getDATE01());
ap0aeDateMap.computeIfAbsent(dateKey, k -> new ArrayList<>());
ap0aeDateMap.get(dateKey).add(ap0AE);
});
List<WmsOutPlan> wmsOutPlanList = wmsOutPlanMapper.selectWmsOutPlanList(new WmsOutPlan());
System.out.println("=========================================");
System.out.println(JSON.toJSONString(wmsOutPlanList));
System.out.println("=========================================");
// 根据日期进行分组遍历
ap0aeDateMap.keySet().forEach(dateKey -> {
Date itemDate = new Date();
try {
itemDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateKey + " 00:00:00");
} catch (ParseException ignored) {
}
return 0;
// 构建出库计划
WmsOutPlan wmsOutPlan = new WmsOutPlan();
wmsOutPlan.setPlanCode(Long.toString(System.currentTimeMillis(), 32).toUpperCase(Locale.ROOT));
wmsOutPlan.setWmsBusinessTypeId(this.wmsBusinessTypeMapper.selectWmsBusinessTypeByCode("DPCK").getTypeId() != null ? Long.parseLong(this.wmsBusinessTypeMapper.selectWmsBusinessTypeByCode("DPCK").getTypeId()) : 11L);
wmsOutPlan.setPlanState("1");
wmsOutPlan.setPlanType("XTTB");
wmsOutPlan.setRemark("同步小型刀具库数据");
wmsOutPlan.setCreateBy(username);
wmsOutPlan.setCreateTime(itemDate);
wmsOutPlanMapper.insertWmsOutPlan(wmsOutPlan);
// 构建出库计划明细
ap0aeDateMap.get(dateKey).forEach(ap0AE -> {
// 获得物料对象
MdItem mdItem = mdItemMapper.selectMdItemByCode(ap0AE.getAE014());
if (mdItem == null) return;
// 获得库位对象
WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaCode(ap0AE.getAE020());
if (wmStorageArea == null) return;
// 构建出库计划明细
WmsOutPlanDetail wmsOutPlanDetail = new WmsOutPlanDetail();
wmsOutPlanDetail.setWmsOutPlanId(wmsOutPlan.getWmsOutPlanId());
wmsOutPlanDetail.setMdItemId(mdItem.getItemId());
wmsOutPlanDetail.setMdItemCode(mdItem.getItemCode());
wmsOutPlanDetail.setMdItemName(mdItem.getItemName());
wmsOutPlanDetail.setMdItemUnit(mdItem.getUnitName());
wmsOutPlanDetail.setPlannedQuantity((int) ap0AE.getAE017().doubleValue());
wmsOutPlanDetail.setRealQuantity((int) ap0AE.getAE017().doubleValue());
wmsOutPlanDetail.setDetailBatchNum("1");
wmsOutPlanDetail.setWmStorageAreaId(wmStorageArea.getAreaId());
wmsOutPlanDetail.setWmStorageAreaCode(wmStorageArea.getAreaCode());
wmsOutPlanDetail.setWmStorageAreaName(wmStorageArea.getAreaName());
wmsOutPlanDetail.setDetailState("1");
wmsOutPlanDetail.setRemark("同步小型刀具库数据");
wmsOutPlanDetail.setCreateBy(username);
wmsOutPlanDetail.setCreateTime(ap0AE.getDATE01());
wmsOutPlanMapper.insertWmsOutPlanDetail(wmsOutPlanDetail);
// 获得该出库计划子项对应的工具台账实体
List<BaseKnife> baseKnifeList = this.baseKnifeMapper.selectBaseKnifeListByMbbBdMrlIdAndAreaCodeAndKnifeFineStateAndIsLocked(
wmsOutPlanDetail.getMdItemId(),
wmsOutPlanDetail.getWmStorageAreaCode(),
0
);
// 校验库中数量是否足够
if (baseKnifeList.size() < wmsOutPlanDetail.getPlannedQuantity()) {
throw new RuntimeException("库存数量不足以支持本次出库物料:" + ap0AE.getAE015());
}
// 开始遍历出库计划子项
baseKnifeList.subList(0, wmsOutPlanDetail.getPlannedQuantity()).forEach(baseKnife -> {
// 构建出库计划明细实体
WmsOutPlanDetailEntity wmsOutPlanDetailEntity = new WmsOutPlanDetailEntity();
wmsOutPlanDetailEntity.setWmsOutPlanDetailId(wmsOutPlanDetail.getWmsOutPlanDetailId());
wmsOutPlanDetailEntity.setBaseKnifeId(baseKnife.getBaseKnifeId());
wmsOutPlanDetailEntity.setAreaCode(baseKnife.getAreaCode());
wmsOutPlanDetailEntity.setItemOrProduct(baseKnife.getItemOrProduct());
wmsOutPlanDetailEntity.setKnifeCode(baseKnife.getKnifeCode());
wmsOutPlanDetailEntity.setKnifeName(baseKnife.getKnifeName());
wmsOutPlanDetailEntity.setPlanSheet(baseKnife.getPlanSheet());
wmsOutPlanDetailEntity.setKnifeLife(baseKnife.getKnifeLife());
wmsOutPlanDetailEntity.setResetCount(baseKnife.getResetCount());
wmsOutPlanDetailEntity.setKnifeUnit(baseKnife.getKnifeUnit());
wmsOutPlanDetailEntity.setSafeStock(baseKnife.getKnifeType());
wmsOutPlanDetailEntity.setStandardQuantity(baseKnife.getStandardQuantity());
// 插入出库计划明细实体
this.wmsOutPlanDetailEntityMapper.insertWmsOutPlanDetailEntity(wmsOutPlanDetailEntity);
// 锁定工具台账中的物料实体
this.baseKnifeMapper.updateBaseKnifeIsLockedByBaseKnifeId(baseKnife.getBaseKnifeId(), 1);
// 锁定并出库台账明细实体
this.baseKnifeMapper.updateBaseKnifeKnifeFineStateAndIsLockedByBaseKnifeId(
wmsOutPlanDetailEntity.getBaseKnifeId(),
2,
1
);
});
// 构建出库任务
WmsOutTask wmsOutTask = new WmsOutTask();
wmsOutTask.setWmsOutPlanId(wmsOutPlan.getWmsOutPlanId());
wmsOutTask.setWmsOutPlanCode(wmsOutPlan.getPlanCode());
wmsOutTask.setWmsOutPlanDetailId(wmsOutPlanDetail.getWmsOutPlanDetailId());
wmsOutTask.setWmsBusinessTypeId(wmsOutPlan.getWmsBusinessTypeId());
wmsOutTask.setTaskCode(new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()));
wmsOutTask.setTaskNumber(wmsOutPlanDetail.getPlannedQuantity());
wmsOutTask.setOutNumber(wmsOutPlanDetail.getPlannedQuantity());
wmsOutTask.setWmStorageAreaId(wmsOutPlanDetail.getWmStorageAreaId());
wmsOutTask.setBatchNum(wmsOutPlanDetail.getDetailBatchNum());
wmsOutTask.setMdItemId(wmsOutPlanDetail.getMdItemId());
wmsOutTask.setMdItemCode(wmsOutPlanDetail.getMdItemCode());
wmsOutTask.setMdItemName(wmsOutPlanDetail.getMdItemName());
wmsOutTask.setMdItemUnit(wmsOutPlanDetail.getMdItemUnit());
wmsOutTask.setTaskState("1");
wmsOutTask.setRecipientUsername(wmsOutPlan.getRecipientUsername());
wmsOutTask.setCreateTime(new Date());
// 插入出库任务
this.wmsOutTaskMapper.insertWmsOutTask(wmsOutTask);
// 设置小型货柜数据为已读
this.ap0AEMapper.updateOutDataToOld(ap0AE);
});
});
return 1;
}
@Transactional

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ktg.mes.md.mapper.AP0ADMapper">
<resultMap type="AP0AD" id="AP0ADResult">
<result property="AD001" column="AD001"/>
<result property="AD002" column="AD002"/>
<result property="AD003" column="AD003"/>
<result property="AD004" column="AD004"/>
<result property="AD005" column="AD005"/>
<result property="AD006" column="AD006"/>
<result property="AD007" column="AD007"/>
<result property="AD008" column="AD008"/>
<result property="AD009" column="AD009"/>
<result property="AD010" column="AD010"/>
<result property="AD011" column="AD011"/>
<result property="AD012" column="AD012"/>
<result property="AD013" column="AD013"/>
<result property="AD014" column="AD014"/>
<result property="AD015" column="AD015"/>
<result property="AD016" column="AD016"/>
<result property="AD017" column="AD017"/>
<result property="UDF01" column="UDF01"/>
<result property="UDF02" column="UDF02"/>
<result property="UDF03" column="UDF03"/>
<result property="UDF04" column="UDF04"/>
<result property="UDF05" column="UDF05"/>
<result property="UDF51" column="UDF51"/>
<result property="UDF52" column="UDF52"/>
<result property="UDF53" column="UDF53"/>
<result property="UDF54" column="UDF54"/>
<result property="UDF55" column="UDF55"/>
<result property="USER01" column="USER01"/>
<result property="USER02" column="USER02"/>
<result property="DATE01" column="DATE01"/>
<result property="DATE02" column="DATE02"/>
</resultMap>
<sql id="AP0ADSelectAllCol">
select AD001,
AD002,
AD003,
AD004,
AD005,
AD006,
AD007,
AD008,
AD009,
AD010,
AD011,
AD012,
AD013,
AD014,
AD015,
AD016,
AD017,
UDF01,
UDF02,
UDF03,
UDF04,
UDF05,
UDF51,
UDF52,
UDF53,
UDF54,
UDF55,
USER01,
USER02,
DATE01,
DATE02
from AP0AD
</sql>
<select id="selectOutNewData" resultMap="AP0ADResult">
<include refid="AP0ADSelectAllCol"/>
where UDF01 != 'ED'
AND AD011 IS NOT NULL
AND AD008 > 0
AND AD005 IS NOT NULL
</select>
<update id="updateOutDataToOld">
update AP0AD
set UDF01 = 'ED'
where AD001 = #{AD001}
AND AD002 = #{AD002}
AND AD003 = #{AD003}
AND AD004 = #{AD004}
</update>
</mapper>

View File

@ -107,6 +107,7 @@
<select id="selectOutNewData" resultMap="AP0AEResult">
<include refid="AP0AESelectAllCol"/>
where UDF07 != 'ED'
AND AE025 = '借用单'
AND AE017 > 0
AND AE014 IS NOT NULL
AND AE020 IS NOT NULL