add:销售出库单

This commit is contained in:
zhaoyf
2026-07-31 21:06:11 +08:00
parent 52d1f44418
commit 1d87add97d
11 changed files with 454 additions and 1 deletions

View File

@@ -83,7 +83,7 @@ public class MdPbStoragevehicleextServiceImpl extends ServiceImpl<MdPbStorageveh
String key = local.getString("material_code") + "_" + local.getString("pcsn");
localMap.put(key, local);
}
if ("6.007".equals(warehouseno)){//装配线边库同步中鼎库存
if ("-----".equals(warehouseno)){//装配线边库同步中鼎库存
List<ZDInventory> zdInventories = wmsToZDWmdService.queryInventoryByHouseCode(warehouseno);
Set<String> zdKeys = new HashSet<>();
for (ZDInventory zdInventory : zdInventories) {

View File

@@ -13,4 +13,6 @@ public interface InboundEasSyncService {
void syncTransferOutBill(BillChangeDto billChangeDto);
void syncOtherOutBill(BillChangeDto billChangeDto);
void syncSaleOutBill(BillChangeDto billChangeDto);
}

View File

@@ -44,6 +44,10 @@ public class EasToWmsServiceImpl implements EasToWmsService {
//其他出库单
inboundEasSyncService.syncOtherOutBill(billChangeDto);
break;
case "102":
//销售出库单
inboundEasSyncService.syncSaleOutBill(billChangeDto);
break;
}
result.put("respCode", 0);
result.put("respMsg", "单据变更通知成功");

View File

@@ -78,4 +78,15 @@ public class InboundEasQueryService {
List<Purchasemst> list = easPurchasemstMapper.selectTransferOutByBillId(billId);
return list != null && !list.isEmpty() ? list.get(0) : null;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Purchasemst queryMstBySaleOut(String billId) {
List<Purchasemst> list = easPurchasemstMapper.selectSaleOutByBillId(billId);
return list != null && !list.isEmpty() ? list.get(0) : null;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Purchasedtl> queryDtlListBySaleOut(String billId) {
return easPurchasedtlMapper.selectSaleOutByBillId(billId);
}
}

View File

@@ -468,4 +468,89 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
purchasemstMapper.deleteById(mst.getId());
}
}
@Override
public void syncSaleOutBill(BillChangeDto billChangeDto) {
String billId = billChangeDto.getBillid();
Integer status = billChangeDto.getStatus();//1:已提交2:更新3:删除;
//更新单据
final Purchasemst purchasemst = purchasemstMapper.selectOne(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
if (purchasemst!=null && !purchasemst.getBill_status().equals(PurchaseBillStatus.CREATED.getCode())){
throw new BadRequestException("EAS采购单同步失败当前单据在WMS系统中已经执行 " + billId);
}
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
List ZD_STOR_SET;
if (zdStorParam!=null){
ZD_STOR_SET = JSONObject.parseObject(zdStorParam.getValue(), List.class);
} else {
ZD_STOR_SET = new ArrayList<>();
}
switch (status){
case 1:
case 2:
//增加单据
Purchasemst easMst = easQueryService.queryMstBySaleOut(billId);
if (easMst == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
//判断是否因为填错仓库号保证中鼎一致
List<Purchasedtl> purchasedtlList = purchasedtlMapper.selectList(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
List<Purchasedtl> easDtlList = easQueryService.queryDtlListBySaleOut(billId);
boolean hasZDEas = easDtlList.stream().anyMatch((item) -> ZD_STOR_SET.contains(item.getHouse_code()));
if (!purchasedtlList.isEmpty() &&!hasZDEas){ //不包含立库则判断是否是填错仓库单据
boolean hasZD = purchasedtlList.stream().anyMatch((item) -> ZD_STOR_SET.contains(item.getHouse_code()));
if (hasZD){//原来单据包含中鼎立库
billChangeDto.setStatus(3);//删除中鼎异常单据
wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
}
}
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
//更新单据
Boolean allZD = true;
for (Purchasedtl dtl : easDtlList) {
if (ZD_STOR_SET.contains(dtl.getHouse_code())){
//中鼎立库
dtl.setInstock_qty(dtl.getQty());
easMst.setForwardZD(1);
easMst.setBill_status(PurchaseBillStatus.EXECUTING.getCode());
}else {
allZD = false;
}
}
if (Objects.equals(1, easMst.getForwardZD())){
if (allZD){
//如果全部都是中鼎的则由中鼎回传EAS
easMst.setBill_status(PurchaseBillStatus.COMPLETED.getCode());
}
//转发中鼎
try {
wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
easMst.setForwardZD(2);
} catch (Exception e) {
easMst.setForwardZD(1);
}
}
purchasedtlMapper.batchSave(easDtlList);
purchasemstMapper.insert(easMst);
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
break;
case 3:
//删除单据
LambdaQueryWrapper<Purchasemst> eq = new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId);
Purchasemst mst = purchasemstMapper.selectOne(eq);
if (mst.getForwardZD() == 2){
wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
}
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.deleteById(mst.getId());
}
}
}

View File

@@ -19,4 +19,6 @@ public interface EasPurchasedtlMapper extends BaseMapper<Purchasedtl> {
List<Purchasedtl> selectOtherOutByBillId(String billId);
List<Purchasedtl> selectTransferOutByBillId(String billId);
List<Purchasedtl> selectSaleOutByBillId(String billId);
}

View File

@@ -115,5 +115,24 @@
FROM EAS_NOBLE.V_UC_DBCK01
WHERE billid = #{bill_id}
</select>
<select id="selectSaleOutByBillId" resultType="org.nl.wms.pm_manage.purchase.service.dao.Purchasedtl">
SELECT
entryid,
billid,
itemNo,
categoryCode,
categoryName,
skuCode,
skuName,
model,
batchNo,
houseCode,
qty,
unitCode,
unit,
trackNo
FROM EAS_NOBLE.V_UC_XSCK05
WHERE billid = #{bill_id}
</select>
</mapper>

View File

@@ -21,4 +21,6 @@ public interface EasPurchasemstMapper extends BaseMapper<Purchasemst> {
List<Purchasemst> selectOtherOutByBillId(String billId);
List<Purchasemst> selectTransferOutByBillId(String billId);
List<Purchasemst> selectSaleOutByBillId(String billId);
}

View File

@@ -95,5 +95,18 @@
FROM EAS_NOBLE.V_UC_DBCK01
WHERE billid = #{bill_id}
</select>
<select id="selectSaleOutByBillId" resultType="org.nl.wms.pm_manage.purchase.service.dao.Purchasemst">
SELECT DISTINCT
orderNo,
orderType,
creator,
createTime,
modifyDate,
status,
billid,
red
FROM EAS_NOBLE.V_UC_XSCK05
WHERE billid = #{bill_id}
</select>
</mapper>