|
|
@ -16,8 +16,12 @@ import com.gaotao.modules.handlingunit.entity.HandlingUnitDetail; |
|
|
import com.gaotao.modules.handlingunit.service.HandlingUnitDetailService; |
|
|
import com.gaotao.modules.handlingunit.service.HandlingUnitDetailService; |
|
|
import com.gaotao.modules.handlingunit.service.HandlingUnitService; |
|
|
import com.gaotao.modules.handlingunit.service.HandlingUnitService; |
|
|
import com.gaotao.modules.po.dao.PoMapper; |
|
|
import com.gaotao.modules.po.dao.PoMapper; |
|
|
|
|
|
import com.gaotao.modules.po.entity.PoReceipt; |
|
|
|
|
|
import com.gaotao.modules.po.entity.PoReceiptDetail; |
|
|
import com.gaotao.modules.po.entity.PurchaseOrder; |
|
|
import com.gaotao.modules.po.entity.PurchaseOrder; |
|
|
import com.gaotao.modules.po.entity.PurchaseOrderDto; |
|
|
import com.gaotao.modules.po.entity.PurchaseOrderDto; |
|
|
|
|
|
import com.gaotao.modules.po.service.PoReceiptDetailService; |
|
|
|
|
|
import com.gaotao.modules.po.service.PoReceiptService; |
|
|
import com.gaotao.modules.po.service.PoService; |
|
|
import com.gaotao.modules.po.service.PoService; |
|
|
import com.gaotao.modules.sys.entity.SysUserEntity; |
|
|
import com.gaotao.modules.sys.entity.SysUserEntity; |
|
|
import com.gaotao.modules.trans.entity.*; |
|
|
import com.gaotao.modules.trans.entity.*; |
|
|
@ -56,6 +60,10 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
@Autowired |
|
|
@Autowired |
|
|
private HandlingUnitDetailService handlingUnitDetailService; |
|
|
private HandlingUnitDetailService handlingUnitDetailService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
|
|
|
private PoReceiptService poReceiptService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private PoReceiptDetailService poReceiptDetailService; |
|
|
|
|
|
@Autowired |
|
|
private AgvClientUtil agvClientUtil; |
|
|
private AgvClientUtil agvClientUtil; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private AccessSiteMapper accessSiteMapper; |
|
|
private AccessSiteMapper accessSiteMapper; |
|
|
@ -70,77 +78,39 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
@Value("${custom.wcs-url}") |
|
|
@Value("${custom.wcs-url}") |
|
|
private String wcsUrl; |
|
|
private String wcsUrl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<Map<String, Object>> getPoList(PurchaseOrderDto purchaseOrder) { |
|
|
public List<Map<String, Object>> getPoList(PurchaseOrderDto purchaseOrder) { |
|
|
try { |
|
|
try { |
|
|
// 注意:这里应该根据实际的IFS接口调用方式进行调整 |
|
|
|
|
|
// 如果需要获取多行数据,可能需要先获取PO头,再获取行数据 |
|
|
|
|
|
Map<String, Object> params = Map.of("ifsDBName", ifsDBName, "domainUserID", domainUserID, |
|
|
Map<String, Object> params = Map.of("ifsDBName", ifsDBName, "domainUserID", domainUserID, |
|
|
"ifsSiteID", purchaseOrder.getSite(), |
|
|
"ifsSiteID", purchaseOrder.getSite(), |
|
|
"ifsPurchaseOrderNo", purchaseOrder.getPoNumber() |
|
|
"ifsPurchaseOrderNo", purchaseOrder.getPoNumber() |
|
|
); |
|
|
); |
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
String jsonBody = objectMapper.writeValueAsString(params); |
|
|
String jsonBody = objectMapper.writeValueAsString(params); |
|
|
//String ifsResponse = HttpUtils.doGetWithBody(ifsUrl+"PurchaseOrderLine",jsonBody,null); |
|
|
|
|
|
|
|
|
String poResponse = HttpUtils.doGetWithBody(ifsUrl+"PurchaseOrder",jsonBody,null); |
|
|
|
|
|
String poLineResponse = HttpUtils.doGetWithBody(ifsUrl+"PurchaseOrderLine",jsonBody,null); |
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
|
|
|
/*Map<String, Object> params2 = Map.of( |
|
|
|
|
|
"ifsDBName", ifsDBName, |
|
|
|
|
|
"domainUserID", domainUserID, |
|
|
|
|
|
"ifsSiteID", "55", |
|
|
|
|
|
"partNo", "80900095-1DF", |
|
|
|
|
|
"qtyToIssue", 10, |
|
|
|
|
|
"locationNo", "DF1FT0101", |
|
|
|
|
|
"destLocationNo", "DF1RS0202", |
|
|
|
|
|
"lotBatchNo", "2883779-*-*-1" |
|
|
|
|
|
); |
|
|
|
|
|
String jsonBody2 = objectMapper.writeValueAsString(params2); |
|
|
|
|
|
String ifsResponse2 = HttpUtils.doPost("https://cclifswebservice.ccldesign.com/api/v1/MoveInventoryPart",jsonBody2,null);*/ |
|
|
|
|
|
|
|
|
|
|
|
String json = """ |
|
|
|
|
|
[ |
|
|
|
|
|
{ |
|
|
|
|
|
"convFactor":1, |
|
|
|
|
|
"description":"micro R6p 4up P19.05 S42.5 Dry 22x7.5", |
|
|
|
|
|
"inventoryQty":537000, |
|
|
|
|
|
"inventoryuoM":"pcs", |
|
|
|
|
|
"invotyToReceive":530000, |
|
|
|
|
|
"lineNo":"1", |
|
|
|
|
|
"orderNo":"1321807", |
|
|
|
|
|
"partNo":"70004171", |
|
|
|
|
|
"plannedDeliveryDate":"2025-05-21T00:00:00", |
|
|
|
|
|
"purchaseQty":537000, |
|
|
|
|
|
"purchaseUOM":"pcs", |
|
|
|
|
|
"qtyToReceive":530000, |
|
|
|
|
|
"receivecase":"Receive into Arrival", |
|
|
|
|
|
"releaseNo":"1", |
|
|
|
|
|
"site":"55", |
|
|
|
|
|
"status":"Arrived" |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"convFactor":1, |
|
|
|
|
|
"description":"micro R6p 4up P19.05 S42.5 Dry 22x7.5", |
|
|
|
|
|
"inventoryQty":537000, |
|
|
|
|
|
"inventoryuoM":"pcs", |
|
|
|
|
|
"invotyToReceive":530000, |
|
|
|
|
|
"lineNo":"1", |
|
|
|
|
|
"orderNo":"1321807", |
|
|
|
|
|
"partNo":"70004171", |
|
|
|
|
|
"plannedDeliveryDate":"2025-05-21T00:00:00", |
|
|
|
|
|
"purchaseQty":537000, |
|
|
|
|
|
"purchaseUOM":"pcs", |
|
|
|
|
|
"qtyToReceive":530000, |
|
|
|
|
|
"receivecase":"Receive into Arrival", |
|
|
|
|
|
"releaseNo":"1", |
|
|
|
|
|
"site":"55", |
|
|
|
|
|
"status":"Arrived" |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
"""; |
|
|
|
|
|
List<Map<String, Object>> ifsData = mapper.readValue(json, new TypeReference<>() {}); |
|
|
|
|
|
|
|
|
|
|
|
return ifsData; |
|
|
|
|
|
|
|
|
List<Map<String, Object>> poData = mapper.readValue(poResponse, new TypeReference<>() {}); |
|
|
|
|
|
List<Map<String, Object>> poLineData = mapper.readValue(poLineResponse, new TypeReference<>() {}); |
|
|
|
|
|
if (poData.isEmpty()) { |
|
|
|
|
|
throw new XJException("未找到对应的采购订单"); |
|
|
|
|
|
} |
|
|
|
|
|
if (poLineData.isEmpty()) { |
|
|
|
|
|
throw new XJException("未找到对应的采购订单行"); |
|
|
|
|
|
} |
|
|
|
|
|
// 将Po状态放到每个行数据中 |
|
|
|
|
|
String poStatus = poData.getFirst().get("status") != null ? poData.getFirst().get("status").toString() : ""; |
|
|
|
|
|
for (Map<String, Object> line : poLineData) { |
|
|
|
|
|
line.put("poStatus", poStatus); |
|
|
|
|
|
// 根据poLine的receiveCase判断是否需要检验 |
|
|
|
|
|
String receiveCase = line.get("receiveCase") != null ? line.get("receiveCase").toString() : ""; |
|
|
|
|
|
if ("Receive into Inventory".equals(receiveCase)) { |
|
|
|
|
|
line.put("needCheck", "N"); |
|
|
|
|
|
} else { |
|
|
|
|
|
line.put("needCheck", "Y"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return poLineData; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("获取PO列表异常: {}", e.getMessage()); |
|
|
log.error("获取PO列表异常: {}", e.getMessage()); |
|
|
throw new XJException("获取PO列表失败: " + e.getMessage()); |
|
|
throw new XJException("获取PO列表失败: " + e.getMessage()); |
|
|
@ -154,6 +124,7 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
TransHeader transHeader = headerService.genTrans(inData, "CRT"); |
|
|
TransHeader transHeader = headerService.genTrans(inData, "CRT"); |
|
|
inData.setTransNo(transHeader.getTransNo()); |
|
|
inData.setTransNo(transHeader.getTransNo()); |
|
|
|
|
|
inData.setDirection("+"); |
|
|
detailService.save(inData); |
|
|
detailService.save(inData); |
|
|
if ("Y".equals(inData.getNeedHandlingUnit())) { |
|
|
if ("Y".equals(inData.getNeedHandlingUnit())) { |
|
|
// 创建Handling Unit相关数据 |
|
|
// 创建Handling Unit相关数据 |
|
|
@ -167,8 +138,8 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
transDetailSub.setItemNo((double) i); |
|
|
transDetailSub.setItemNo((double) i); |
|
|
String subType = "HU"; |
|
|
String subType = "HU"; |
|
|
// 获取流水号 |
|
|
// 获取流水号 |
|
|
TransNoControl subNo = transNoService.getTransNo(inData.getSite(), subType, 8); |
|
|
|
|
|
transDetailSub.setSubNo(subNo.getNewTransNo()); |
|
|
|
|
|
|
|
|
TransNoControl huTrans = transNoService.getTransNo(inData.getSite(), subType, 10); |
|
|
|
|
|
transDetailSub.setHandlingUnitId(huTrans.getNewTransNo()); |
|
|
transDetailSub.setSeqNo(inData.getItemNo()); |
|
|
transDetailSub.setSeqNo(inData.getItemNo()); |
|
|
transDetailSub.setSubQty(huInfo.getPerQty()); |
|
|
transDetailSub.setSubQty(huInfo.getPerQty()); |
|
|
transDetailSub.setOrderRef1(inData.getPoNo()); |
|
|
transDetailSub.setOrderRef1(inData.getPoNo()); |
|
|
@ -178,7 +149,7 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
HandlingUnit handlingUnit = new HandlingUnit(); |
|
|
HandlingUnit handlingUnit = new HandlingUnit(); |
|
|
|
|
|
|
|
|
// 生成处理单元ID |
|
|
// 生成处理单元ID |
|
|
TransNoControl huTrans = transNoService.getTransNo(inData.getSite(), "HU", 10); |
|
|
|
|
|
|
|
|
|
|
|
String unitId = huTrans.getNewTransNo(); |
|
|
String unitId = huTrans.getNewTransNo(); |
|
|
handlingUnit.setUnitId(unitId); |
|
|
handlingUnit.setUnitId(unitId); |
|
|
handlingUnit.setSite(inData.getSite()); |
|
|
handlingUnit.setSite(inData.getSite()); |
|
|
@ -259,6 +230,10 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
//subService.updateById(transDetailSub); |
|
|
//subService.updateById(transDetailSub); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 创建采购接收记录 - 在库存更新之前创建 |
|
|
|
|
|
createPoReceiptRecords(inData, transHeader); |
|
|
|
|
|
|
|
|
// 免检更新库存 待检验的出入库记录状态为待检验 |
|
|
// 免检更新库存 待检验的出入库记录状态为待检验 |
|
|
if ("N".equals(inData.getNeedCheck())) { |
|
|
if ("N".equals(inData.getNeedCheck())) { |
|
|
genInventoryStock(inData, transHeader); |
|
|
genInventoryStock(inData, transHeader); |
|
|
@ -281,6 +256,7 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
handlePalletAndAGVDispatch(inData, transHeader); |
|
|
handlePalletAndAGVDispatch(inData, transHeader); |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("采购入库失败,PO号: {}, 错误: {}", inData.getPoNo(), e.getMessage()); |
|
|
throw new XJException("采购入库失败: " + e.getMessage()); |
|
|
throw new XJException("采购入库失败: " + e.getMessage()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -545,4 +521,108 @@ public class PoServiceImpl extends ServiceImpl<PoMapper, PurchaseOrder> implemen |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 创建采购接收记录 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void createPoReceiptRecords(TransDetailDto inData, TransHeader transHeader) { |
|
|
|
|
|
try { |
|
|
|
|
|
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
|
|
|
|
|
|
|
// 生成接收单号 |
|
|
|
|
|
TransNoControl receiptNoControl = transNoService.getTransNo(inData.getSite(), "PR", 10); |
|
|
|
|
|
String receiptNo = receiptNoControl.getNewTransNo(); |
|
|
|
|
|
|
|
|
|
|
|
// 创建采购接收单主记录 |
|
|
|
|
|
PoReceipt poReceipt = new PoReceipt(); |
|
|
|
|
|
poReceipt.setSite(inData.getSite()); |
|
|
|
|
|
poReceipt.setReceiptNo(receiptNo); |
|
|
|
|
|
poReceipt.setReceiveDate(new Date()); |
|
|
|
|
|
poReceipt.setEnterDate(new Date()); |
|
|
|
|
|
// 从PO或其他地方获取供应商信息,这里先设为空 |
|
|
|
|
|
poReceipt.setSupplierId(""); |
|
|
|
|
|
poReceipt.setReceiver(currentUser.getUserDisplay()); |
|
|
|
|
|
poReceipt.setUsername(currentUser.getUserDisplay()); |
|
|
|
|
|
poReceipt.setDeliveryNoteNo(inData.getPoNo()); // 使用PO号作为送货单号 |
|
|
|
|
|
poReceipt.setPrinted("N"); |
|
|
|
|
|
poReceipt.setRemark("PO接收自动创建 - " + inData.getRemark()); |
|
|
|
|
|
poReceipt.setWarehouseId(transHeader.getWarehouseId()); |
|
|
|
|
|
poReceipt.setOutWorkOrderFlag("N"); |
|
|
|
|
|
poReceipt.setEmailCanSendFlag("N"); |
|
|
|
|
|
poReceipt.setOrderref1(inData.getPoNo()); |
|
|
|
|
|
// 保存采购接收单主记录 |
|
|
|
|
|
poReceiptService.save(poReceipt); |
|
|
|
|
|
|
|
|
|
|
|
// 创建采购接收单明细记录 |
|
|
|
|
|
PoReceiptDetail poReceiptDetail = new PoReceiptDetail(); |
|
|
|
|
|
poReceiptDetail.setSite(inData.getSite()); |
|
|
|
|
|
poReceiptDetail.setReceiptNo(receiptNo); |
|
|
|
|
|
poReceiptDetail.setItemNo(inData.getItemNo()); |
|
|
|
|
|
poReceiptDetail.setPartNo(inData.getPartNo()); |
|
|
|
|
|
poReceiptDetail.setArriveQty(inData.getTransQty()); |
|
|
|
|
|
poReceiptDetail.setQtyInspectedNew(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setPoumId(""); // TODO: 需要从其他地方获取单位信息 |
|
|
|
|
|
poReceiptDetail.setConvertFactor((int) 1.0); |
|
|
|
|
|
poReceiptDetail.setStatus("Y".equals(inData.getNeedCheck())?"ARRIVED":"RECEIVED"); |
|
|
|
|
|
|
|
|
|
|
|
// 设置检验相关字段 |
|
|
|
|
|
poReceiptDetail.setNeedInspectFlag(inData.getNeedCheck()); |
|
|
|
|
|
if ("Y".equals(inData.getNeedCheck())) { |
|
|
|
|
|
poReceiptDetail.setQtyToInspect(inData.getTransQty()); |
|
|
|
|
|
poReceiptDetail.setQtyInspected(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setQtyApproved(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
} else { |
|
|
|
|
|
poReceiptDetail.setQtyToInspect(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setQtyInspected(inData.getTransQty()); |
|
|
|
|
|
poReceiptDetail.setQtyApproved(inData.getTransQty()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
poReceiptDetail.setQtyReturned(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setQtyReplace(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setQtyScrapt(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setQtyToReceived(inData.getTransQty()); |
|
|
|
|
|
poReceiptDetail.setQtyReceived(inData.getTransQty()); |
|
|
|
|
|
poReceiptDetail.setInvoiceQty(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setInvoicePrice(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setLocationId(inData.getLocationNo()); |
|
|
|
|
|
|
|
|
|
|
|
// PO相关信息 |
|
|
|
|
|
poReceiptDetail.setOrderNo(inData.getOrderNo()); |
|
|
|
|
|
poReceiptDetail.setOrderItemNo(Double.valueOf(inData.getLineNo() != null ? inData.getLineNo() : "0")); |
|
|
|
|
|
poReceiptDetail.setBatchNo(inData.getBatchNo()); |
|
|
|
|
|
|
|
|
|
|
|
// 日期信息 |
|
|
|
|
|
if (inData.getManufactureDate() != null) { |
|
|
|
|
|
poReceiptDetail.setManuFactureDate(inData.getManufactureDate()); |
|
|
|
|
|
|
|
|
|
|
|
// 计算失效日期 |
|
|
|
|
|
Date expiredDate = calculateExpiredDate(inData.getManufactureDate(), inData.getPartNo()); |
|
|
|
|
|
if (expiredDate != null) { |
|
|
|
|
|
poReceiptDetail.setExpiredDate(expiredDate); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
poReceiptDetail.setRemark("PO接收自动创建 - " + inData.getRemark()); |
|
|
|
|
|
poReceiptDetail.setNeedReceiveFlag("Y"); |
|
|
|
|
|
poReceiptDetail.setToInvoiceQty(inData.getTransQty()); |
|
|
|
|
|
poReceiptDetail.setQtyRbjs(BigDecimal.valueOf(0.0)); |
|
|
|
|
|
poReceiptDetail.setInspectType("ARRIVAL"); |
|
|
|
|
|
poReceiptDetail.setInspectTypeDb("A"); |
|
|
|
|
|
|
|
|
|
|
|
// 保存采购接收单明细记录 |
|
|
|
|
|
poReceiptDetailService.save(poReceiptDetail); |
|
|
|
|
|
|
|
|
|
|
|
// 如果是免检,创建检验记录 |
|
|
|
|
|
if ("N".equals(inData.getNeedCheck())) { |
|
|
|
|
|
//createInspectionRecord(inData, transHeader, receiptNo); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.info("采购接收记录创建成功,接收单号: {}, PO号: {}, 物料: {}, 数量: {}", |
|
|
|
|
|
receiptNo, inData.getPoNo(), inData.getPartNo(), inData.getTransQty()); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("创建采购接收记录失败,PO号: {}, 错误: {}", inData.getPoNo(), e.getMessage()); |
|
|
|
|
|
throw new XJException("创建采购接收记录失败: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |