opt:EAS入库单同步调整优化

This commit is contained in:
zhaoyf
2026-07-06 21:13:28 +08:00
parent 09bba0589b
commit d1051867f9
13 changed files with 334 additions and 54 deletions

View File

@@ -6,13 +6,15 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.ext_manage.purchase.service.EasToWmsService;
import org.nl.wms.ext_manage.purchase.service.dto.BillChangeDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/wms/inbound")
@RequestMapping("/app/restful/api/v3/wms")
@SaIgnore
@Slf4j
public class EasToWmsController {
@@ -20,13 +22,11 @@ public class EasToWmsController {
@PostMapping("/pushPurchase")
@Log("EAS推送采购")
@PostMapping("/orderChangeNotice")
@Log("EAS推送单据变更")
@SaIgnore
public ResponseEntity<Object> pushPurchase(@RequestBody JSONObject body) {
String billId = body.getString("billid");
log.info("EAS推送采购单, billId: {}", billId);
JSONObject result = easToWmsService.receivePurchaseBill(billId);
public ResponseEntity<Object> billChange(@RequestBody BillChangeDto body) {
JSONObject result = easToWmsService.billChangeHandler(body);
return new ResponseEntity<>(result, HttpStatus.OK);
}

View File

@@ -1,8 +1,9 @@
package org.nl.wms.ext_manage.purchase.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.ext_manage.purchase.service.dto.BillChangeDto;
public interface EasToWmsService {
JSONObject receivePurchaseBill(String billId);
JSONObject billChangeHandler(BillChangeDto billChangeDto);
}

View File

@@ -1,8 +1,12 @@
package org.nl.wms.ext_manage.purchase.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.ext_manage.purchase.service.dto.BillChangeDto;
public interface InboundEasSyncService {
JSONObject syncPurchaseBill(String billId);
void syncPurchaseBill(BillChangeDto billChangeDto);
void syncTransferBill(BillChangeDto billChangeDto);
void syncOtherBill(BillChangeDto billChangeDto);
}

View File

@@ -0,0 +1,13 @@
package org.nl.wms.ext_manage.purchase.service.dto;
import lombok.Data;
@Data
public class BillChangeDto {
private String billid;
private String orderNo;
private String orderType;
private Integer red;
private Integer status;
private String noticeTime;
}

View File

@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext_manage.purchase.service.EasToWmsService;
import org.nl.wms.ext_manage.purchase.service.InboundEasSyncService;
import org.nl.wms.ext_manage.purchase.service.dto.BillChangeDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -17,10 +18,28 @@ public class EasToWmsServiceImpl implements EasToWmsService {
private InboundEasSyncService inboundEasSyncService;
@Override
public JSONObject receivePurchaseBill(String billId) {
if (StrUtil.isEmptyIfStr(billId)){
throw new BadRequestException("EAS采购单同步失败billid为空");
public JSONObject billChangeHandler(BillChangeDto billChangeDto) {
if (StrUtil.isEmptyIfStr(billChangeDto.getBillid())){
throw new BadRequestException("EAS同步失败billid为空");
}
return inboundEasSyncService.syncPurchaseBill(billId);
JSONObject result = new JSONObject();
switch (billChangeDto.getOrderType()){
case "103":
//采购入库单
inboundEasSyncService.syncPurchaseBill(billChangeDto);
break;
case "107":
//调拨入库单
inboundEasSyncService.syncTransferBill(billChangeDto);
break;
case "109":
//其他入库单
inboundEasSyncService.syncOtherBill(billChangeDto);
break;
}
result.put("respCode", 0);
result.put("respMsg", "单据变更通知成功");
return result;
}
}

View File

@@ -24,16 +24,36 @@ public class InboundEasQueryService {
@Autowired
private EasPurchasedtlMapper easPurchasedtlMapper;
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Purchasemst queryMstByTransfer(String billId) {
List<Purchasemst> list = easPurchasemstMapper.selectTransferByBillId(billId);
return list != null && !list.isEmpty() ? list.get(0) : null;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Purchasedtl> queryDtlListByTransfer(String billId) {
return easPurchasedtlMapper.selectTransferByBillId(billId);
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Purchasemst queryMstByOther(String billId) {
List<Purchasemst> list = easPurchasemstMapper.selectOtherByBillId(billId);
return list != null && !list.isEmpty() ? list.get(0) : null;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Purchasedtl> queryDtlListByOther(String billId) {
return easPurchasedtlMapper.selectOtherByBillId(billId);
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Purchasemst queryMst(String billId) {
log.info("从EAS数据源查询采购入库主表, billId: {}", billId);
List<Purchasemst> list = easPurchasemstMapper.selectByBillId(billId);
return list != null && !list.isEmpty() ? list.get(0) : null;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Purchasedtl> queryDtlList(String billId) {
log.info("从EAS数据源查询采购入库明细, billId: {}", billId);
return easPurchasedtlMapper.selectByBillId(billId);
}
}

View File

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext_manage.purchase.service.dto.BillChangeDto;
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
import org.nl.wms.pm_manage.purchase.service.enums.PurchaseBillStatus;
import org.nl.wms.ext_manage.purchase.service.InboundEasSyncService;
@@ -37,50 +38,194 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject syncPurchaseBill(String billId) {
log.info("开始同步EAS采购入库单, billId: {}", billId);
public void syncPurchaseBill(BillChangeDto billChangeDto) {
String billId = billChangeDto.getBillid();
Integer status = billChangeDto.getStatus();//1:已提交2:更新3:删除;
switch (status){
case 1:
//增加单据
Purchasemst easMst = easQueryService.queryMst(billId);
if (easMst == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
easMst.setBill_status(PurchaseBillStatus.CREATED.getCode());
easMst.setModify_date(DateUtil.now());
List<Purchasedtl> easDtlList = easQueryService.queryDtlList(billId);
for (Purchasedtl dtl : easDtlList) {
purchasedtlMapper.insert(dtl);
if (dtl.getHouse_code().contains("ZDLK")){
//中鼎立库
easMst.setForwardZD(1);
//TODO 转发中鼎参数待确定
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
}
}
purchasemstMapper.insert(easMst);
Purchasemst easMst = easQueryService.queryMst(billId);
if (easMst == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
Purchasemst existing = purchasemstMapper.selectOne(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
if (existing != null) {
if (!existing.getBill_status().equals(PurchaseBillStatus.CREATED.getCode())){
throw new BadRequestException("EAS采购单同步失败该单据正在执行或已完成: " + billId);
}else {
//单据还未执行则删除重新插入单据
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
break;
case 2:
//更新单据
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, existing.getBill_id()));
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, existing.getBill_id()));
}
.eq(Purchasemst::getBill_id, billId));
//增加单据
Purchasemst easMstUpdate = easQueryService.queryMst(billId);
if (easMstUpdate == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
easMstUpdate.setBill_status(PurchaseBillStatus.CREATED.getCode());
easMstUpdate.setModify_date(DateUtil.now());
List<Purchasedtl> easDtlListUpdate = easQueryService.queryDtlList(billId);
for (Purchasedtl dtl : easDtlListUpdate) {
purchasedtlMapper.insert(dtl);
if (dtl.getHouse_code().contains("ZDLK")){
//中鼎立库
easMstUpdate.setForwardZD(1);
//TODO 转发中鼎参数待确定
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
}
}
purchasemstMapper.insert(easMstUpdate);
log.info("EAS采购入库单更新完成, billId: {}", billId);
break;
case 3:
//删除单据
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
}
}
List<Purchasedtl> easDtlList = easQueryService.queryDtlList(billId);
@Override
public void syncTransferBill(BillChangeDto billChangeDto) {
String billId = billChangeDto.getBillid();
Integer status = billChangeDto.getStatus();//1:已提交2:更新3:删除;
switch (status){
case 1:
//增加单据
Purchasemst easMst = easQueryService.queryMstByTransfer(billId);
if (easMst == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
easMst.setBill_status(PurchaseBillStatus.CREATED.getCode());
easMst.setModify_date(DateUtil.now());
List<Purchasedtl> easDtlList = easQueryService.queryDtlListByTransfer(billId);
for (Purchasedtl dtl : easDtlList) {
purchasedtlMapper.insert(dtl);
if (dtl.getHouse_code().contains("ZDLK")){
//中鼎立库
easMst.setForwardZD(1);
//TODO 转发中鼎参数待确定
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
}
}
purchasemstMapper.insert(easMst);
easMst.setBill_status(PurchaseBillStatus.CREATED.getCode());
easMst.setModify_date(DateUtil.now());
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
break;
case 2:
//更新单据
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
for (Purchasedtl dtl : easDtlList) {
purchasedtlMapper.insert(dtl);
if (dtl.getHouse_code().contains("ZDLK")){
//中鼎立库
easMst.setForwardZD(1);
//TODO 转发中鼎参数待确定
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
}
//增加单据
Purchasemst easMstUpdate = easQueryService.queryMstByTransfer(billId);
if (easMstUpdate == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
easMstUpdate.setBill_status(PurchaseBillStatus.CREATED.getCode());
easMstUpdate.setModify_date(DateUtil.now());
List<Purchasedtl> easDtlListUpdate = easQueryService.queryDtlListByTransfer(billId);
for (Purchasedtl dtl : easDtlListUpdate) {
purchasedtlMapper.insert(dtl);
if (dtl.getHouse_code().contains("ZDLK")){
//中鼎立库
easMstUpdate.setForwardZD(1);
//TODO 转发中鼎参数待确定
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
}
}
purchasemstMapper.insert(easMstUpdate);
log.info("EAS采购入库单更新完成, billId: {}", billId);
break;
case 3:
//删除单据
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
}
purchasemstMapper.insert(easMst);
}
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
JSONObject result = new JSONObject();
result.put("status", 200);
result.put("message", "同步成功");
result.put("bill_id", billId);
return result;
@Override
public void syncOtherBill(BillChangeDto billChangeDto) {
String billId = billChangeDto.getBillid();
Integer status = billChangeDto.getStatus();//1:已提交2:更新3:删除;
switch (status){
case 1:
//增加单据
Purchasemst easMst = easQueryService.queryMstByOther(billId);
if (easMst == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
easMst.setBill_status(PurchaseBillStatus.CREATED.getCode());
easMst.setModify_date(DateUtil.now());
List<Purchasedtl> easDtlList = easQueryService.queryDtlListByOther(billId);
for (Purchasedtl dtl : easDtlList) {
purchasedtlMapper.insert(dtl);
if (dtl.getHouse_code().contains("ZDLK")){
//中鼎立库
easMst.setForwardZD(1);
//TODO 转发中鼎参数待确定
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
}
}
purchasemstMapper.insert(easMst);
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
break;
case 2:
//更新单据
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
//增加单据
Purchasemst easMstUpdate = easQueryService.queryMstByOther(billId);
if (easMstUpdate == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
easMstUpdate.setBill_status(PurchaseBillStatus.CREATED.getCode());
easMstUpdate.setModify_date(DateUtil.now());
List<Purchasedtl> easDtlListUpdate = easQueryService.queryDtlListByOther(billId);
for (Purchasedtl dtl : easDtlListUpdate) {
purchasedtlMapper.insert(dtl);
if (dtl.getHouse_code().contains("ZDLK")){
//中鼎立库
easMstUpdate.setForwardZD(1);
//TODO 转发中鼎参数待确定
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
}
}
purchasemstMapper.insert(easMstUpdate);
log.info("EAS采购入库单更新完成, billId: {}", billId);
break;
case 3:
//删除单据
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
}
}
}

View File

@@ -11,4 +11,8 @@ import java.util.List;
public interface EasPurchasedtlMapper extends BaseMapper<Purchasedtl> {
List<Purchasedtl> selectByBillId(@Param("bill_id") String billId);
List<Purchasedtl> selectTransferByBillId(String billId);
List<Purchasedtl> selectOtherByBillId(String billId);
}

View File

@@ -39,5 +39,43 @@
FROM v_uc_cgrk06
WHERE billid = #{bill_id}
</select>
<select id="selectTransferByBillId" resultType="org.nl.wms.pm_manage.purchase.service.dao.Purchasedtl">
SELECT
entryid,
billid,
itemNo,
categoryCode,
categoryName,
skuCode,
skuName,
model,
houseCode,
batchNo,
qty,
unitCode,
unit,
trackNo
FROM V_UC_DBRK02
WHERE billid = #{bill_id}
</select>
<select id="selectOtherByBillId" resultType="org.nl.wms.pm_manage.purchase.service.dao.Purchasedtl">
SELECT
entryid,
billid,
itemNo,
categoryCode,
categoryName,
skuCode,
skuName,
model,
houseCode,
batchNo,
qty,
unitCode,
unit,
trackNo
FROM V_UC_QTRK04
WHERE billid = #{bill_id}
</select>
</mapper>

View File

@@ -13,4 +13,8 @@ public interface EasPurchasemstMapper extends BaseMapper<Purchasemst> {
List<Purchasemst> selectByBillId(@Param("bill_id") String billId);
List<PurchaseMatInfoVo> selectByOrderNo(@Param("orderNo") String orderNo);
List<Purchasemst> selectTransferByBillId(String billId);
List<Purchasemst> selectOtherByBillId(String billId);
}

View File

@@ -47,5 +47,35 @@
FROM v_uc_cgrk06
WHERE orderNo = #{orderNo}
</select>
<select id="selectTransferByBillId" resultType="org.nl.wms.pm_manage.purchase.service.dao.Purchasemst">
SELECT DISTINCT
billid,
orderNo,
orderType,
supplierCode,
supplierName,
creator,
createTime,
modifyDate,
status,
red
FROM V_UC_DBRK02
WHERE billid = #{bill_id}
</select>
<select id="selectOtherByBillId" resultType="org.nl.wms.pm_manage.purchase.service.dao.Purchasemst">
SELECT DISTINCT
billid,
orderNo,
orderType,
supplierCode,
supplierName,
creator,
createTime,
modifyDate,
status,
red
FROM V_UC_QTRK04
WHERE billid = #{bill_id}
</select>
</mapper>

View File

@@ -12,7 +12,6 @@ import org.nl.wms.pm_manage.purchase.service.PurchasedtlService;
import org.nl.wms.pm_manage.purchase.service.dao.Purchasedtl;
import org.nl.wms.pm_manage.purchase.service.dao.Purchasemst;
import org.nl.wms.pm_manage.purchase.service.enums.PurchaseBillStatus;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDtl;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDtlMapper;
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
@@ -87,10 +86,9 @@ public class DealPurchaseRecBillCallback implements CallbackStrategy {
final PmStockReturn stockReturn = new PmStockReturn();
stockReturn.setRequest_Id(orderCode);
stockReturn.setCreate_time(DateUtil.now());
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("采购入库"));
stockReturn.setRequest_type(purchasemst.getOrder_type());
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode());
stockReturn.setRequest_data(JSON.toJSONString(easAuditRequestDto));
// iPmStockReturnService.save(stockReturn);
//回传
try {
ErpUtil.create().login().audit(JSONObject.toJSONString(easAuditRequestDto));
@@ -99,6 +97,7 @@ public class DealPurchaseRecBillCallback implements CallbackStrategy {
stockReturn.setError_msg(e.getMessage());
stockReturn.setStatus(StockReturnStatusEnum.FAIL.getCode());
}
iPmStockReturnService.save(stockReturn);
}else {
//更新单据状态执行中
purchaseService.lambdaUpdate()

View File

@@ -297,9 +297,12 @@ export default {
const requestTypeMap = {
'0001': '生产入库',
'0005': '采购入库',
'103': '采购入库',
'0009': '手工入库',
'1001': '销售出库',
'1004': '库存调拨',
'107': '调拨入库',
'109': '其他入库',
'1005': '生产出库',
'1009': '手工出库'
}