重构销售订单、盘点单、销售出库(含有前置收货单)、采购入库(含有前置收货单)的逻辑
This commit is contained in:
		
							parent
							
								
									994b14b211
								
							
						
					
					
						commit
						2118f0e3b7
					
				|  | @ -50,7 +50,7 @@ public class SignBP implements ISignBP<PurchaseInVO>, ISignRuleProvider<Purchase | |||
|         processor.addAfterRule(new MobAfterPurchaseInSign()); | ||||
|         processor.addAfterRule(new SignM45AndRewriteCTPayPlan()); | ||||
|         processor.addAfterRule(new SignInsertFeeDetailRule()); | ||||
|         // 签字后推送至MES系统 | ||||
|         // 签字后推送至MES系统 推送销售出库单之前 先推送前置通知单 | ||||
|         processor.addAfterRule(new PurchaseReceiptRuleMES()); | ||||
|         processor.addAfterRule(new AfterSigningSynchronizeRuleMES()); | ||||
|     } | ||||
|  |  | |||
|  | @ -7,7 +7,6 @@ import nc.bs.logging.Log; | |||
| import nc.impl.pubapp.pattern.rule.IRule; | ||||
| import nc.jdbc.framework.processor.ColumnProcessor; | ||||
| import nc.vo.bd.material.MaterialVO; | ||||
| import nc.vo.bd.material.measdoc.MeasdocVO; | ||||
| import nc.vo.bd.psn.PsndocVO; | ||||
| import nc.vo.bd.rack.RackVO; | ||||
| import nc.vo.bd.stordoc.StordocVO; | ||||
|  | @ -15,7 +14,6 @@ import nc.vo.bd.supplier.SupplierVO; | |||
| import nc.vo.ic.m45.entity.PurchaseInBodyVO; | ||||
| import nc.vo.ic.m45.entity.PurchaseInHeadVO; | ||||
| import nc.vo.ic.m45.entity.PurchaseInVO; | ||||
| import nc.vo.org.DeptVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.lang.UFDate; | ||||
| import nc.vo.pub.lang.UFDouble; | ||||
|  | @ -46,17 +44,19 @@ public class AfterSigningSynchronizeRuleMES implements IRule<PurchaseInVO> { | |||
|             if (purchaseInVOs == null || purchaseInVOs.length == 0) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             // 检查并筛选组织为电缆的采购入库单 | ||||
|             List<PurchaseInVO> filteredPurchaseInVOS = checkAndFilterBills(purchaseInVOs); | ||||
|             if (filteredPurchaseInVOS.isEmpty()) { | ||||
|                 return; | ||||
|             } | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             for (PurchaseInVO purchaseInVO : purchaseInVOs) { | ||||
|             for (PurchaseInVO purchaseInVO : filteredPurchaseInVOS) { | ||||
|                 PurchaseInHeadVO hvo = (PurchaseInHeadVO) purchaseInVO.getParentVO(); | ||||
|                 PurchaseInBodyVO[] bvos = (PurchaseInBodyVO[]) purchaseInVO.getChildrenVO(); | ||||
|                 // 构建请求参数 | ||||
|                 JSONObject syncData = buildSyncData(hvo, bvos); | ||||
|                 if (syncData != null) { | ||||
|                     httpPostOtherSys.sendToExternalSystem(ADD_URL, syncData); | ||||
|                 } | ||||
|                 httpPostOtherSys.sendToExternalSystem(ADD_URL, syncData); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             obmlog.error("采购入库同步MES-处理异常:" + e.getMessage(), e); | ||||
|  | @ -69,19 +69,12 @@ public class AfterSigningSynchronizeRuleMES implements IRule<PurchaseInVO> { | |||
|      */ | ||||
|     private JSONObject buildSyncData(PurchaseInHeadVO hvo, PurchaseInBodyVO[] bvos) throws BusinessException { | ||||
|         obmlog.debug("采购入库同步MES-开始构建数据: " + hvo.getVbillcode()); | ||||
| //        if (!hvo.getPk_org().equals("0001A110000000000677")) { | ||||
| //            obmlog.debug("AfterSigningSynchronizeRule-跳过处理销售出库单,因为此单据组织非电缆: " + hvo.getVbillcode()); | ||||
| //            return null; | ||||
| //        } | ||||
|         JSONObject requestData = new JSONObject(); | ||||
|         // 设置操作类型 | ||||
|         requestData.put("operation_type", "I");  // 签字为新增操作 | ||||
| 
 | ||||
|         // 构建data数组 | ||||
|         List<JSONObject> dataList = new ArrayList<>(); | ||||
| 
 | ||||
|         JSONObject dataObj = new JSONObject(); | ||||
| 
 | ||||
|         // 设置入库单基本信息 | ||||
|         UFDate billDate = hvo.getDbilldate(); | ||||
|         dataObj.put("orderDate", billDate != null ? billDate.toString().substring(0, 10) : "");  // 入库日期 - 格式yyyy-MM-dd | ||||
|  | @ -89,7 +82,6 @@ public class AfterSigningSynchronizeRuleMES implements IRule<PurchaseInVO> { | |||
|         // 仓库编码 - 使用正确的仓库字段(cwarehouseid) | ||||
|         dataObj.put("warehouseId", transferCodeByPk(StordocVO.getDefaultTableName(), | ||||
|                 StordocVO.CODE, StordocVO.PK_STORDOC, hvo.getCwarehouseid()));  // 仓库编码 | ||||
| 
 | ||||
|         // 部门ID - 采购部门最新版本(cdptid)而非cdptvid,cdptvid是部门版本信息 | ||||
|         dataObj.put("departmentId", transferCodeByPk(DeptVersionVO.getDefaultTableName(), | ||||
|                 DeptVersionVO.CODE, DeptVersionVO.PK_VID, hvo.getCdptvid()));  // 部门编码 | ||||
|  | @ -141,14 +133,28 @@ public class AfterSigningSynchronizeRuleMES implements IRule<PurchaseInVO> { | |||
|                 detailsList.add(detailMap); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         dataObj.put("details", detailsList); | ||||
|         dataList.add(dataObj); | ||||
| 
 | ||||
|         requestData.put("data", dataList); | ||||
|         return requestData; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 检查并筛选需要同步的单据 | ||||
|      */ | ||||
|     private List<PurchaseInVO> checkAndFilterBills(PurchaseInVO[] purchaseInVOS) throws BusinessException { | ||||
|         List<PurchaseInVO> result = new ArrayList<>(); | ||||
|         for (PurchaseInVO vo : purchaseInVOS) { | ||||
|             // 检查组织是否为电缆组织 | ||||
|             if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) { | ||||
|                 result.add(vo); | ||||
|             } | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 根据主键查询对应的编码 | ||||
|      */ | ||||
|  |  | |||
|  | @ -42,24 +42,20 @@ public class PurchaseReceiptRuleMES implements IRule<PurchaseInVO> { | |||
|     @Override | ||||
|     public void process(PurchaseInVO[] purchaseInVOS) { | ||||
|         try { | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             if (purchaseInVOS == null || purchaseInVOS.length == 0) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             // 쇱꿴깻<EFBFBD>朞꽃뭔澗새데 | ||||
|             // 检查并筛选组织为电缆的采购收货单 | ||||
|             List<PurchaseInVO> filteredPurchaseInVOS = checkAndFilterBills(purchaseInVOS); | ||||
|             if (filteredPurchaseInVOS.isEmpty()) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             // 놓迦뺏HTTP헝헹묏야잚 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
| 
 | ||||
|             // 处理每个采购收货单 | ||||
|             for (PurchaseInVO purchaseInVO : filteredPurchaseInVOS) { | ||||
|                 PurchaseInHeadVO head = purchaseInVO.getHead(); | ||||
|                 PurchaseInBodyVO[] bodys = purchaseInVO.getBodys(); | ||||
| 
 | ||||
|                 // 每次新增采购收货单前,先删除第三方系统中已有的数据,再进行新增 | ||||
|                 String orderNo = head.getVbillcode(); | ||||
|                 boolean deleteSuccess = deletePurchaseReceipt(orderNo); | ||||
|  | @ -128,18 +124,15 @@ public class PurchaseReceiptRuleMES implements IRule<PurchaseInVO> { | |||
|      */ | ||||
|     private List<PurchaseInVO> checkAndFilterBills(PurchaseInVO[] purchaseInVOS) throws BusinessException { | ||||
|         List<PurchaseInVO> result = new ArrayList<>(); | ||||
| 
 | ||||
|         for (PurchaseInVO vo : purchaseInVOS) { | ||||
|             // 检查组织是否为电缆组织 | ||||
|             if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) { | ||||
|                 result.add(vo); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 构建符合MES系统接口规范的请求数据 | ||||
|      */ | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ import nc.vo.bd.material.measdoc.MeasdocVO; | |||
| import nc.vo.bd.psn.PsndocVO; | ||||
| import nc.vo.bd.rack.RackVO; | ||||
| import nc.vo.bd.supplier.SupplierVO; | ||||
| import nc.vo.ic.m45.entity.PurchaseInVO; | ||||
| import nc.vo.ic.m4c.entity.SaleOutBodyVO; | ||||
| import nc.vo.ic.m4c.entity.SaleOutHeadVO; | ||||
| import nc.vo.ic.m4c.entity.SaleOutVO; | ||||
|  | @ -29,6 +30,8 @@ import net.sf.mpxj.primavera.schema.CurrencyType; | |||
| import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  | @ -46,21 +49,23 @@ public class AfterSigningSynchronizeRuleMES implements IRule<SaleOutVO> { | |||
|     @Override | ||||
|     public void process(SaleOutVO[] saleOutVOS) { | ||||
|         try { | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             if (saleOutVOS == null || saleOutVOS.length == 0) { | ||||
|                 return; | ||||
|             } | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             // 检查并筛选组织为电缆的销售出库单 | ||||
|             List<SaleOutVO> filteredSaleOutVOS = checkAndFilterBills(saleOutVOS); | ||||
|             if (filteredSaleOutVOS.isEmpty()) { | ||||
|                 return; | ||||
|             } | ||||
|             // 处理每个销售出库单 | ||||
|             for (SaleOutVO saleOutVO : saleOutVOS) { | ||||
|             for (SaleOutVO saleOutVO : filteredSaleOutVOS) { | ||||
|                 SaleOutHeadVO hvo = (SaleOutHeadVO) saleOutVO.getParentVO(); | ||||
|                 SaleOutBodyVO[] bvos = (SaleOutBodyVO[]) saleOutVO.getChildrenVO(); | ||||
|                 // 构建要发送的数据 | ||||
|                 JSONObject syncData = buildSyncData(hvo, bvos); | ||||
|                 if (syncData != null) { | ||||
|                     // 发送数据到金思维系统(使用HttpPostOtherSysImpl处理网络请求) | ||||
|                     httpPostOtherSys.sendToExternalSystem(SALE_OUT_URL, syncData); | ||||
|                 } | ||||
|                 httpPostOtherSys.sendToExternalSystem(SALE_OUT_URL, syncData); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             obmlog.error("AfterSigningSynchronizeRule-处理异常:" + e.getMessage(), e); | ||||
|  | @ -74,10 +79,6 @@ public class AfterSigningSynchronizeRuleMES implements IRule<SaleOutVO> { | |||
|      */ | ||||
|     private JSONObject buildSyncData(SaleOutHeadVO hvo, SaleOutBodyVO[] bvos) throws BusinessException { | ||||
|         obmlog.debug("AfterSigningSynchronizeRule-开始处理销售出库单: " + hvo.getVbillcode()); | ||||
| //        if (!hvo.getPk_org().equals("0001A110000000000677")) { | ||||
| //            obmlog.debug("AfterSigningSynchronizeRule-跳过处理销售出库单,因为此单据组织非电缆: " + hvo.getVbillcode()); | ||||
| //            return null; | ||||
| //        } | ||||
|         JSONObject requestData = new JSONObject(); | ||||
| 
 | ||||
|         JSONObject dataObj = new JSONObject(); | ||||
|  | @ -177,6 +178,21 @@ public class AfterSigningSynchronizeRuleMES implements IRule<SaleOutVO> { | |||
|         return requestData; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 检查并筛选需要同步的单据 | ||||
|      */ | ||||
|     private List<SaleOutVO> checkAndFilterBills(SaleOutVO[] saleOutVOS) throws BusinessException { | ||||
|         List<SaleOutVO> result = new ArrayList<>(); | ||||
|         for (SaleOutVO vo : saleOutVOS) { | ||||
|             // 检查组织是否为电缆组织 | ||||
|             if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) { | ||||
|                 result.add(vo); | ||||
|             } | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { | ||||
|         if (nc.vo.cmp.util.StringUtils.isEmpty(pk)) { | ||||
|             return null; | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ import nc.vo.bd.material.MaterialVO; | |||
| import nc.vo.bd.material.measdoc.MeasdocVO; | ||||
| import nc.vo.bd.psn.PsndocVO; | ||||
| import nc.vo.bd.stordoc.StordocVO; | ||||
| import nc.vo.ic.m45.entity.PurchaseInVO; | ||||
| import nc.vo.ic.m4c.entity.SaleOutBodyVO; | ||||
| import nc.vo.ic.m4c.entity.SaleOutHeadVO; | ||||
| import nc.vo.ic.m4c.entity.SaleOutVO; | ||||
|  | @ -24,6 +25,8 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; | |||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  | @ -40,29 +43,29 @@ public class SalesDeliveryOrderRuleMES implements IRule<SaleOutVO> { | |||
|     @Override | ||||
|     public void process(SaleOutVO[] saleOutVOS) { | ||||
|         try { | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             if (saleOutVOS == null || saleOutVOS.length == 0) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
| 
 | ||||
|             // 检查并筛选组织为电缆的采购收货单 | ||||
|             List<SaleOutVO> filteredSaleOutVOS = checkAndFilterBills(saleOutVOS); | ||||
|             if (filteredSaleOutVOS.isEmpty()) { | ||||
|                 return; | ||||
|             } | ||||
|             // 处理每个销售交货单 | ||||
|             for (SaleOutVO saleOutVO : saleOutVOS) { | ||||
|             for (SaleOutVO saleOutVO : filteredSaleOutVOS) { | ||||
|                 SaleOutHeadVO hvo = (SaleOutHeadVO) saleOutVO.getParentVO(); | ||||
|                 SaleOutBodyVO[] bvos = (SaleOutBodyVO[]) saleOutVO.getChildrenVO(); | ||||
| 
 | ||||
|                 // 构建要发送的数据 | ||||
|                 JSONObject syncData = buildSyncData(hvo, bvos); | ||||
|                 if (syncData != null) { | ||||
|                     // 每次新增销售交货单之前 先删除 然后再新增 | ||||
|                     String orderNo = hvo.getVbillcode(); | ||||
|                     boolean flag = deleteSalesDeliveryOrder(orderNo); | ||||
|                     if (flag) { | ||||
|                         // 发送数据到MES系统 | ||||
|                         obmlog.debug("SalesDeliveryOrderRuleMES-准备发送销售交货单数据: " + hvo.getVbillcode()); | ||||
|                         httpPostOtherSys.sendToExternalSystem(MES_API_URL, syncData); | ||||
|                     } | ||||
|                 // 每次新增销售交货单之前 先删除 然后再新增 | ||||
|                 String orderNo = hvo.getVbillcode(); | ||||
|                 boolean flag = deleteSalesDeliveryOrder(orderNo); | ||||
|                 if (flag) { | ||||
|                     // 发送数据到MES系统 | ||||
|                     obmlog.debug("SalesDeliveryOrderRuleMES-准备发送销售交货单数据: " + hvo.getVbillcode()); | ||||
|                     httpPostOtherSys.sendToExternalSystem(MES_API_URL, syncData); | ||||
|                 } | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|  | @ -230,6 +233,20 @@ public class SalesDeliveryOrderRuleMES implements IRule<SaleOutVO> { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 检查并筛选需要同步的单据 | ||||
|      */ | ||||
|     private List<SaleOutVO> checkAndFilterBills(SaleOutVO[] saleOutVOS) throws BusinessException { | ||||
|         List<SaleOutVO> result = new ArrayList<>(); | ||||
|         for (SaleOutVO vo : saleOutVOS) { | ||||
|             // 检查组织是否为电缆组织 | ||||
|             if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) { | ||||
|                 result.add(vo); | ||||
|             } | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     private String transferSpecialField(String field) { | ||||
|         if (field == null || field.trim().isEmpty()) { | ||||
|             return null; | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ import nc.vo.bd.material.MaterialVO; | |||
| import nc.vo.bd.rack.RackVO; | ||||
| import nc.vo.bd.stordoc.StordocVO; | ||||
| import nc.vo.bd.supplier.SupplierVO; | ||||
| import nc.vo.ic.m4c.entity.SaleOutVO; | ||||
| import nc.vo.ic.m4r.entity.InvCountBillVO; | ||||
| import nc.vo.ic.m4r.entity.InvCountBodyVO; | ||||
| import nc.vo.ic.m4r.entity.InvCountHeaderVO; | ||||
|  | @ -25,6 +26,9 @@ import nc.vo.pubapp.pattern.pub.SqlBuilder; | |||
| import nc.vo.vorg.DeptVersionVO; | ||||
| import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * 盘点(审批后传MES) | ||||
|  | @ -41,25 +45,24 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<InvCountBillVO> { | |||
|     @Override | ||||
|     public void process(InvCountBillVO[] invCountBillVOs) { | ||||
|         try { | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             if (invCountBillVOs == null || invCountBillVOs.length == 0) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             // 筛选需要处理的单据 | ||||
|             List<InvCountBillVO> filteredBillVOS = checkAndFilterBills(invCountBillVOs); | ||||
|             if (filteredBillVOS.isEmpty()) { | ||||
|                 return; | ||||
|             } | ||||
|             // 处理每个盘点单 | ||||
|             for (InvCountBillVO invCountBillVO : invCountBillVOs) { | ||||
|             for (InvCountBillVO invCountBillVO : filteredBillVOS) { | ||||
|                 InvCountHeaderVO hvo = invCountBillVO.getParentVO(); | ||||
|                 InvCountBodyVO[] bvos = invCountBillVO.getChildrenVO(); | ||||
| 
 | ||||
|                 // 构建要发送的数据 | ||||
|                 JSONObject syncData = buildSyncData(hvo, bvos); | ||||
| 
 | ||||
|                 if (syncData != null) { | ||||
|                     // 发送数据到金思维系统(使用HttpPostOtherSysImpl处理网络请求) | ||||
|                     httpPostOtherSys.sendToExternalSystem(INV_COUNT_URL, syncData); | ||||
| 
 | ||||
|                 } | ||||
|                 // 发送数据到金思维系统(使用HttpPostOtherSysImpl处理网络请求) | ||||
|                 httpPostOtherSys.sendToExternalSystem(INV_COUNT_URL, syncData); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             obmlog.error("AfterApprovingSynchronizeRule-处理异常:" + e.getMessage(), e); | ||||
|  | @ -67,34 +70,39 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<InvCountBillVO> { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 检查并筛选需要同步的单据 | ||||
|      */ | ||||
|     private List<InvCountBillVO> checkAndFilterBills(InvCountBillVO[] invCountBillVOS) throws BusinessException { | ||||
|         List<InvCountBillVO> result = new ArrayList<>(); | ||||
|         for (InvCountBillVO vo : invCountBillVOS) { | ||||
|             // 检查组织是否为电缆组织 | ||||
|             if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) { | ||||
|                 result.add(vo); | ||||
|             } | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 构建符合金思维系统接口规范的请求数据 | ||||
|      * 按照接口文档要求构建JSON结构 | ||||
|      */ | ||||
|     private JSONObject buildSyncData(InvCountHeaderVO hvo, InvCountBodyVO[] bvos) throws BusinessException { | ||||
|         obmlog.debug("AfterApprovingSynchronizeRule-开始处理盘点单: " + hvo.getVbillcode()); | ||||
|         if (!hvo.getPk_org().equals("0001A110000000000677")) { | ||||
|             obmlog.debug("AfterApprovingSynchronizeRule-跳过处理销售出库单,因为此单据组织非电缆: " + hvo.getVbillcode()); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         // 按照新规范构建请求数据 | ||||
|         JSONObject requestBody = new JSONObject(); | ||||
|         JSONObject requestData = new JSONObject(); | ||||
| 
 | ||||
|         // 盘点主信息 盘点单号 为空时自动生成 | ||||
|         requestData.put("PDDH", null); | ||||
| 
 | ||||
|         // 获取仓库编码 | ||||
|         String warehouseCode = transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, hvo.getCwarehouseid()); | ||||
|         requestData.put("CKID", warehouseCode); | ||||
| 
 | ||||
|         // 盘点部门编码 | ||||
|         String deptCode = transferCodeByPk(DeptVersionVO.getDefaultTableName(), DeptVersionVO.CODE, DeptVersionVO.PK_VID, hvo.getCdptvid()); | ||||
|         requestData.put("BMID", deptCode); | ||||
|         // 盘点人 | ||||
|         requestData.put("PDR", getStringValue(hvo.getCountoperator())); | ||||
| 
 | ||||
|         // 日期处理 - 盘点日期 | ||||
|         UFDate dcountdate = hvo.getDcountdate(); | ||||
|         if (dcountdate != null) { | ||||
|  | @ -104,7 +112,6 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<InvCountBillVO> { | |||
|         } | ||||
|         // 备注 | ||||
|         requestData.put("BZ", getStringValue(hvo.getVnote())); | ||||
| 
 | ||||
|         // 构建明细数组 | ||||
|         JSONArray details = new JSONArray(); | ||||
|         if (bvos != null) { | ||||
|  | @ -154,7 +161,6 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<InvCountBillVO> { | |||
|                 detail.put("KHID", transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, bvo.getCasscustid())); | ||||
|                 // 供应商编码 | ||||
|                 detail.put("GYSID", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, bvo.getCvendorid())); | ||||
| 
 | ||||
|                 details.add(detail); | ||||
|             } | ||||
|         } | ||||
|  |  | |||
|  | @ -14,6 +14,7 @@ import nc.vo.bd.material.MaterialVO; | |||
| import nc.vo.bd.material.measdoc.MeasdocVO; | ||||
| import nc.vo.bd.psn.PsndocVO; | ||||
| import nc.vo.cmp.util.StringUtils; | ||||
| import nc.vo.ic.m4c.entity.SaleOutVO; | ||||
| import nc.vo.org.DeptVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.billtype.BilltypeVO; | ||||
|  | @ -30,7 +31,9 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; | |||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * 销售订单审批后推送MES金思维系统 | ||||
|  | @ -47,23 +50,21 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> { | |||
|     @Override | ||||
|     public void process(SaleOrderVO[] saleOrderVOs) { | ||||
|         try { | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             if (saleOrderVOs == null || saleOrderVOs.length == 0) { | ||||
|                 return; | ||||
|             } | ||||
|             // 初始化HTTP请求工具类 | ||||
|             IHttpPostOtherSys httpPostOtherSys = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
|             // 筛选组织为电缆的销售订单 | ||||
|             List<SaleOrderVO> filteredSaleOrderVOS = checkAndFilterBills(saleOrderVOs); | ||||
|             // 处理每个销售订单 | ||||
|             for (SaleOrderVO saleOrderVO : saleOrderVOs) { | ||||
|             for (SaleOrderVO saleOrderVO : filteredSaleOrderVOS) { | ||||
|                 SaleOrderHVO head = saleOrderVO.getParentVO(); | ||||
|                 SaleOrderBVO[] bodys = saleOrderVO.getChildrenVO(); | ||||
| 
 | ||||
|                 // 构建要发送的数据 | ||||
|                 JSONObject syncData = buildSyncData(head, bodys); | ||||
| 
 | ||||
|                 if (syncData != null) { | ||||
|                     // 发送数据到金思维系统 | ||||
|                     httpPostOtherSys.sendToExternalSystem(SALE_ORDER_URL, syncData); | ||||
|                 } | ||||
|                 // 发送数据到金思维系统 | ||||
|                 httpPostOtherSys.sendToExternalSystem(SALE_ORDER_URL, syncData); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             obmlog.error("AfterApprovingSynchronizeRuleMES-处理异常:" + e.getMessage(), e); | ||||
|  | @ -76,12 +77,6 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> { | |||
|      */ | ||||
|     private JSONObject buildSyncData(SaleOrderHVO head, SaleOrderBVO[] bodys) throws BusinessException { | ||||
|         obmlog.debug("AfterApprovingSynchronizeRuleMES-开始处理销售订单: " + head.getVbillcode()); | ||||
|         // 检查组织、单据类型等限制条件 | ||||
|         if (!checkOrderValidForSync(head)) { | ||||
|             obmlog.debug("AfterApprovingSynchronizeRule-跳过处理销售订单,因为此单据组织非电缆: " + head.getVbillcode()); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         // 创建请求数据 | ||||
|         JSONObject requestData = new JSONObject(); | ||||
|         JSONObject data = new JSONObject(); | ||||
|  | @ -137,7 +132,6 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> { | |||
|         data.put("contractType", null); | ||||
|         data.put("deliveryRemarks", null); | ||||
|         data.put("remarks", head.getVnote()); | ||||
| 
 | ||||
|         // 构建明细数据 - 只填必填字段 | ||||
|         JSONArray details = new JSONArray(); | ||||
|         if (bodys != null) { | ||||
|  | @ -153,8 +147,6 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> { | |||
|                 data.put("deliveryDate", dsenddate != null ? dsenddate.toString().substring(0, 10) : null); | ||||
|                 // 汇率 表体nexchangerate | ||||
|                 data.put("exchangeRate", body.getVchangerate() != null ? transferSpecialField(body.getVchangerate()) : null); | ||||
| 
 | ||||
| 
 | ||||
|                 // 以下表体所需字段 | ||||
|                 // 序号 | ||||
|                 detailItem.put("sequenceNum", body.getCrowno()); | ||||
|  | @ -200,28 +192,29 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> { | |||
|                 detailItem.put("customNo", null); | ||||
|                 detailItem.put("customSN", null); | ||||
|                 detailItem.put("remarks", null); | ||||
| 
 | ||||
|                 details.add(detailItem); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         data.put("DETAILS", details); | ||||
|         requestData.put("Data", data); | ||||
| 
 | ||||
|         return requestData; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 检查订单是否符合同步条件 | ||||
|      */ | ||||
|     private boolean checkOrderValidForSync(SaleOrderHVO head) { | ||||
|         if (!head.getPk_org().equals("0001A110000000000677")) { | ||||
|             obmlog.debug("AfterApprovingSynchronizeRule-跳过处理销售出库单,因为此单据组织非电缆: " + head.getVbillcode()); | ||||
|             return true; | ||||
|     private List<SaleOrderVO> checkAndFilterBills(SaleOrderVO[] saleOutVOS) { | ||||
|         List<SaleOrderVO> result = new ArrayList<>(); | ||||
|         for (SaleOrderVO vo : saleOutVOS) { | ||||
|             // 检查组织是否为电缆组织 | ||||
|             if (vo.getParentVO().getPk_org() != null && "0001A110000000000677".equals(vo.getParentVO().getPk_org())) { | ||||
|                 result.add(vo); | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 转换特殊字段  如 1/1 转换为小数 1.0 | ||||
|      */ | ||||
|  | @ -234,11 +227,9 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> { | |||
|         if (split.length == 2) { | ||||
|             String numStr = split[0].trim(); | ||||
|             String denStr = split[1].trim(); | ||||
| 
 | ||||
|             if (denStr.equals("0")) { | ||||
|                 return "0.00"; // 分母不能为零 | ||||
|             } | ||||
| 
 | ||||
|             try { | ||||
|                 BigDecimal numerator = new BigDecimal(numStr); | ||||
|                 BigDecimal denominator = new BigDecimal(denStr); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue