opt:EAS同步采购单,如果单据存在并且已创建状态,则删除重新插入

This commit is contained in:
zhaoyf
2026-06-13 15:35:58 +08:00
parent e28627d001
commit 1a02baed68

View File

@@ -2,6 +2,7 @@ package org.nl.wms.ext_manage.purchase.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException; import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext_manage.service.WmsToZDWmdService; import org.nl.wms.ext_manage.service.WmsToZDWmdService;
@@ -44,9 +45,19 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId); throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
} }
Purchasemst existing = purchasemstMapper.selectById(billId); Purchasemst existing = purchasemstMapper.selectOne(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
if (existing != null) { if (existing != null) {
throw new BadRequestException("EAS采购单同步失败单据已存在: " + billId); if (!existing.getBill_status().equals(PurchaseBillStatus.CREATED.getCode())){
throw new BadRequestException("EAS采购单同步失败该单据正在执行或已完成: " + billId);
}else {
//单据还未执行则删除重新插入单据
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, existing.getBill_id()));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, existing.getBill_id()));
}
} }
List<Purchasedtl> easDtlList = easQueryService.queryDtlList(billId); List<Purchasedtl> easDtlList = easQueryService.queryDtlList(billId);
@@ -65,9 +76,6 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
} }
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size()); log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("status", 200); result.put("status", 200);
result.put("message", "同步成功"); result.put("message", "同步成功");