add:出库单据同步,其他出入库单页面,调拨出入库单页面

This commit is contained in:
zhaoyf
2026-07-08 09:33:28 +08:00
parent 0a81376f10
commit 5324d1583e
21 changed files with 1280 additions and 15 deletions

View File

@@ -9,4 +9,8 @@ public interface InboundEasSyncService {
void syncTransferBill(BillChangeDto billChangeDto);
void syncOtherBill(BillChangeDto billChangeDto);
void syncTransferOutBill(BillChangeDto billChangeDto);
void syncOtherOutBill(BillChangeDto billChangeDto);
}

View File

@@ -36,6 +36,14 @@ public class EasToWmsServiceImpl implements EasToWmsService {
//其他入库单
inboundEasSyncService.syncOtherBill(billChangeDto);
break;
case "106":
//调拨出库单
inboundEasSyncService.syncTransferOutBill(billChangeDto);
break;
case "108":
//其他出库单
inboundEasSyncService.syncOtherOutBill(billChangeDto);
break;
}
result.put("respCode", 0);
result.put("respMsg", "单据变更通知成功");

View File

@@ -56,4 +56,26 @@ public class InboundEasQueryService {
public List<Purchasedtl> queryDtlList(String billId) {
return easPurchasedtlMapper.selectByBillId(billId);
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Purchasedtl> queryDtlListByOtherOut(String billId) {
return easPurchasedtlMapper.selectOtherOutByBillId(billId);
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Purchasemst queryMstByOtherOut(String billId) {
List<Purchasemst> list = easPurchasemstMapper.selectOtherOutByBillId(billId);
return list != null && !list.isEmpty() ? list.get(0) : null;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Purchasedtl> queryDtlListByTransferOut(String billId) {
return easPurchasedtlMapper.selectTransferOutByBillId(billId);
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Purchasemst queryMstByTransferOut(String billId) {
List<Purchasemst> list = easPurchasemstMapper.selectTransferOutByBillId(billId);
return list != null && !list.isEmpty() ? list.get(0) : null;
}
}

View File

@@ -1,33 +1,26 @@
package org.nl.wms.ext_manage.purchase.service.impl;
import cn.hutool.core.date.DateUtil;
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.config.SpringContextHolder;
import org.nl.wms.ext_manage.enums.EXTConstant;
import org.nl.wms.ext_manage.purchase.service.InboundEasSyncService;
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;
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.dao.mapper.PurchasedtlMapper;
import org.nl.wms.pm_manage.purchase.service.dao.mapper.PurchasemstMapper;
import org.nl.wms.system_manage.enums.SysParamConstant;
import org.nl.wms.pm_manage.purchase.service.enums.PurchaseBillStatus;
import org.nl.wms.system_manage.service.param.ISysParamService;
import org.nl.wms.system_manage.service.param.dao.Param;
import org.nl.wms.system_manage.service.param.impl.SysParamServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
@@ -238,4 +231,130 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
.eq(Purchasemst::getBill_id, billId));
}
}
@Override
public void syncTransferOutBill(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.queryMstByTransferOut(billId);
if (easMst == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
//更新单据
List<Purchasedtl> easDtlList = easQueryService.queryDtlListByTransferOut(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 (easMst.getForwardZD()==1){
if (allZD){
//如果全部都是中鼎的则由中鼎回传EAS
easMst.setBill_status(PurchaseBillStatus.COMPLETED.getCode());
}
//转发中鼎
wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
}
purchasedtlMapper.batchSave(easDtlList);
purchasemstMapper.insert(easMst);
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
break;
case 3:
//删除单据
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
}
}
@Override
public void syncOtherOutBill(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.queryMstByOtherOut(billId);
if (easMst == null) {
throw new BadRequestException("EAS采购单同步失败EAS系统中未找到单据: " + billId);
}
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, billId));
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
.eq(Purchasemst::getBill_id, billId));
//更新单据
List<Purchasedtl> easDtlList = easQueryService.queryDtlListByOtherOut(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 (easMst.getForwardZD()==1){
if (allZD){
//如果全部都是中鼎的则由中鼎回传EAS
easMst.setBill_status(PurchaseBillStatus.COMPLETED.getCode());
}
//转发中鼎
wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
}
purchasedtlMapper.batchSave(easDtlList);
purchasemstMapper.insert(easMst);
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
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

@@ -15,4 +15,8 @@ public interface EasPurchasedtlMapper extends BaseMapper<Purchasedtl> {
List<Purchasedtl> selectTransferByBillId(String billId);
List<Purchasedtl> selectOtherByBillId(String billId);
List<Purchasedtl> selectOtherOutByBillId(String billId);
List<Purchasedtl> selectTransferOutByBillId(String billId);
}

View File

@@ -77,5 +77,43 @@
FROM V_UC_QTRK04
WHERE billid = #{bill_id}
</select>
<select id="selectOtherOutByBillId" 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_QTCK03
WHERE billid = #{bill_id}
</select>
<select id="selectTransferOutByBillId" 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_DBCK01
WHERE billid = #{bill_id}
</select>
</mapper>

View File

@@ -17,4 +17,8 @@ public interface EasPurchasemstMapper extends BaseMapper<Purchasemst> {
List<Purchasemst> selectTransferByBillId(String billId);
List<Purchasemst> selectOtherByBillId(String billId);
List<Purchasemst> selectOtherOutByBillId(String billId);
List<Purchasemst> selectTransferOutByBillId(String billId);
}

View File

@@ -77,5 +77,35 @@
FROM V_UC_QTRK04
WHERE billid = #{bill_id}
</select>
<select id="selectOtherOutByBillId" 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_QTCK03
WHERE billid = #{bill_id}
</select>
<select id="selectTransferOutByBillId" 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_DBCK01
WHERE billid = #{bill_id}
</select>
</mapper>

View File

@@ -23,13 +23,14 @@ public class PurchaseController {
@Autowired
private PurchaseService purchaseService;
@GetMapping
@GetMapping("/{type}")
@Log("查询采购入库单")
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page, @PathVariable String type) {
whereJson.put("type",type);
return new ResponseEntity<>(TableDataInfo.build(purchaseService.queryAll(whereJson, page)), HttpStatus.OK);
}
@GetMapping("/{id}")
@GetMapping("/{type}/{id}")
@Log("查询采购入库单详情")
public ResponseEntity<Object> getById(@PathVariable String id) {
PurchaseDto dto = purchaseService.getDetailById(id);

View File

@@ -24,7 +24,7 @@
FROM st_ivt_purchasemst m
LEFT JOIN st_ivt_purchasedtl d on d.bill_id = m.bill_id
<where>
1=1
m.order_type = #{params.type}
<if test="params.bill_id != null and params.bill_id != ''">
AND m.bill_id LIKE CONCAT('%', #{params.bill_id}, '%')
</if>