From 73d5e0c732391e9fd541f565fe62025ac8796de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Sun, 18 May 2025 14:45:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95/=E9=94=80?= =?UTF-8?q?=E5=94=AE=E5=87=BA=E5=BA=93=E5=AE=A1=E6=89=B9=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=94=90=E5=88=B6=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rule/AfterSigningSynchronizeRuleRZ.java | 2 +- .../AfterApprovingSynchronizeRuleRZ.java | 84 ++++++++++--------- .../pu/m21/action/OrderApproveAction.java | 2 +- 3 files changed, 45 insertions(+), 43 deletions(-) rename pu/src/private/nc/{bs => impl}/pu/m21/action/OrderApproveAction.java (99%) diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java index 01ce6b2..52aad8a 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRuleRZ.java @@ -109,7 +109,7 @@ public class AfterSigningSynchronizeRuleRZ implements IRule { String cmaterialvid = body.getCmaterialvid();//物料 String casscustid = body.getCasscustid();//客户 String cbodywarehouseid = body.getCbodywarehouseid();//仓库 - UFDate dbizdate = body.getDbizdate();//仓库 + UFDate dbizdate = body.getDbizdate();//出库日期 singleObj.put("djbh_id",cgeneralhid+"_"+cgeneralbid);//单据id singleObj.put("djbh",vbillcode);//单据编号 singleObj.put("djxh",crowno);//单据序号 diff --git a/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java index aa178ce..243cfb5 100644 --- a/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java +++ b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java @@ -8,12 +8,18 @@ import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; import nc.impl.pubapp.pattern.rule.IRule; import nc.jdbc.framework.processor.ColumnProcessor; import nc.pubitf.para.SysInitQuery; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.psn.PsndocVO; +import nc.vo.bd.stordoc.StordocVO; +import nc.vo.bd.supplier.SupplierVO; import nc.vo.cmp.util.StringUtils; import nc.vo.org.OrgVO; import nc.vo.pu.m21.entity.OrderVO; import nc.vo.pu.m21.entity.OrderHeaderVO; import nc.vo.pu.m21.entity.OrderItemVO; import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFDate; +import nc.vo.pub.lang.UFDouble; import nc.vo.pubapp.pattern.exception.ExceptionUtils; import nc.vo.pubapp.pattern.pub.SqlBuilder; import nc.vo.scmpub.util.ArrayUtil; @@ -21,15 +27,15 @@ import nc.vo.scmpub.util.ArrayUtil; import java.util.ArrayList; import java.util.List; +import static nccloud.openapi.ic.m4c.mapping.M4cFieldsEnum.cmaterialvid; + /** - * 采购订单审批后同步到睿智系统 + * 采购订单审批后同步到锐制系统 */ public class AfterApprovingSynchronizeRuleRZ implements IRule { - private static final Log obmlog = Log.getInstance("rzmomlog"); + private static Log log = Log.getInstance("rzmomlog"); private static final BaseDAO dao = new BaseDAO(); - - private static final String DEFAULT_PURCHASE_TYPE = "材料采购"; private static final int OPERATION_ADD = 1; private static final int STATUS_LOCKED = 1; private static final int STATUS_ISSUED = 1; @@ -48,7 +54,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { // 推送到睿智系统 pushToRZMOM(newOrderVOS.toArray(new OrderVO[0])); } catch (Exception e) { - obmlog.error("同步采购订单到睿智系统失败: " + e.getMessage(), e); + log.error("同步采购订单到睿智系统失败: " + e.getMessage(), e); ExceptionUtils.wrappException(e); } } @@ -57,8 +63,9 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { List aggvoList = new ArrayList<>(); for (OrderVO aggvo : OrderVOS) { String pkOrg = aggvo.getHVO().getPk_org(); - String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), pkOrg); - if ("30401".equals(orgCode)) { + Integer forderstatus = aggvo.getHVO().getForderstatus(); + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if ("30401".equals(orgCode)&& 3==forderstatus) { aggvoList.add(aggvo); } } @@ -74,7 +81,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { JSONObject jsonObject = new JSONObject(); // 设置请求头 jsonObject.put("dataflow", "泰开BIP→RZMOMv6"); - jsonObject.put("actionCode", "cghtb"); + jsonObject.put("actionCode", "htmxb"); JSONObject dataIn = new JSONObject(); JSONObject dataIn2 = new JSONObject(); @@ -93,7 +100,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { dataIn.put("Data", dataIn2); jsonObject.put("data", dataIn); - obmlog.error("采购订单推送锐制请求报文:" + jsonObject.toJSONString()); + log.error("采购订单推送锐制请求报文:" + jsonObject.toJSONString()); // 使用ThirdPartyPostRequestUtil发送请求 String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString()); @@ -106,7 +113,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { /** * 构建同步数据 */ - private void buildSyncData(OrderHeaderVO head, OrderItemVO[] items, JSONArray details) { + private void buildSyncData(OrderHeaderVO head, OrderItemVO[] items, JSONArray details) throws BusinessException { if (items == null) { return; } @@ -117,60 +124,55 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { } JSONObject detailItem = new JSONObject(); - + UFDate dbilldate = item.getDbilldate(); // 设置订单基本信息 +// 第三方系统表体主键id detailItem.put("htmx_wbid", item.getPk_order_b()); + //第三方系统合同ID detailItem.put("cght_wbid", head.getVbillcode()); + //操作状态 1新增/修改、2删除(删除时只需上传wbid) detailItem.put("operate", OPERATION_ADD); - detailItem.put("zbxx_cglb_wbid", null); - detailItem.put("zbxx_cglx", DEFAULT_PURCHASE_TYPE); - // 设置日期类信息 - if (head.getDbilldate() != null) { - detailItem.put("zbxx_cgrq", head.getDbilldate().toString()); - detailItem.put("cgrq", head.getDbilldate().toString()); - } +// detailItem.put("zbxx_cglb_wbid", null); +// detailItem.put("zbxx_cglx", DEFAULT_PURCHASE_TYPE); // 设置合同信息 +// 合同编号 必填 例如:采购订单编号:1001 detailItem.put("htxsbh", head.getVbillcode()); +// 合同序号 必填 例如:采购订单序号:1、2、3 detailItem.put("htxh", item.getCrowno()); // 设置物料信息 - detailItem.put("wlbm_wbid", item.getPk_material()); + detailItem.put("wlbm_wbid",transferCodeByPk(MaterialVO.getDefaultTableName(),MaterialVO.CODE,MaterialVO.PK_MATERIAL,item.getPk_material())); // 设置数量信息 - if (item.getNastnum() != null) { - detailItem.put("cgsl", item.getNastnum().doubleValue()); + UFDouble nastnum = item.getNastnum()==null?UFDouble.ZERO_DBL:item.getNastnum(); + detailItem.put("cgsl", nastnum); + + //采购日期 必填 明细行的采购日期 + if (dbilldate != null) { + detailItem.put("cgrq", dbilldate.toString()); } - // 设置供应商和采购员信息 - detailItem.put("zbxx_gycs_wbid", head.getPk_supplier()); - detailItem.put("zbxx_cgy_wbid", head.getCemployeeid()); - - // 设置各种标记信息 - detailItem.put("zbxx_cgbz", null); - detailItem.put("zbxx_cslxr", null); - detailItem.put("zbxx_blbj", null); - detailItem.put("zbxx_hqbj", null); - detailItem.put("zbxx_hqsj", null); - detailItem.put("zbxx_dybj", null); - detailItem.put("zbxx_dysj", null); - detailItem.put("zbxx_httk", null); - detailItem.put("zbxx_cgyq", null); - detailItem.put("zbxx_fkfs", null); + detailItem.put("zbxx_gycs_wbid", transferCodeByPk(SupplierVO.getDefaultTableName(),SupplierVO.CODE,SupplierVO.PK_SUPPLIER,head.getPk_supplier())); + detailItem.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC,head.getCemployeeid())); // 设置计划日期 +// 交货日期 必填 明细行的交货日期 if (item.getDplanarrvdate() != null) { detailItem.put("jhrq", item.getDplanarrvdate().toString()); } // 设置来源单据信息 + //第三方系统采购计划id detailItem.put("cgjh_wbid", item.getVsourcetrantype()); + //采购计划编号 detailItem.put("cgbh", item.getVsourcecode()); + //采购计划序号 detailItem.put("cgxh", item.getVsourcerowno()); // 设置仓库和备注信息 - detailItem.put("sdck", item.getPk_reqstordoc()); + detailItem.put("sdck",transferCodeByPk(StordocVO.getDefaultTableName(),StordocVO.CODE, StordocVO.PK_STORDOC,item.getPk_reqstordoc())); detailItem.put("bzsm", item.getVbmemo()); // 设置状态信息 @@ -187,15 +189,15 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule { /** * 根据主键查询编码 */ - private String transferCodeByPk(String tableName, String pk) throws BusinessException { - if (StringUtils.isEmpty(pk)) { + private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException { + if(StringUtils.isEmpty(pk)){ return null; } SqlBuilder sqlBuilder = new SqlBuilder(); - sqlBuilder.append(" select " + OrgVO.CODE); + sqlBuilder.append(" select " + selectField); sqlBuilder.append(" from " + tableName); sqlBuilder.append(" where "); - sqlBuilder.append(OrgVO.PK_ORG, pk); + sqlBuilder.append(pkField, pk); Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); if (o == null) { throw new BusinessException("未查询到编码信息,sql【" + sqlBuilder + "】"); diff --git a/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java b/pu/src/private/nc/impl/pu/m21/action/OrderApproveAction.java similarity index 99% rename from pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java rename to pu/src/private/nc/impl/pu/m21/action/OrderApproveAction.java index e139a9f..141428f 100644 --- a/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java +++ b/pu/src/private/nc/impl/pu/m21/action/OrderApproveAction.java @@ -1,4 +1,4 @@ -package nc.bs.pu.m21.action; +package nc.impl.pu.m21.action; import nc.bs.pu.m21.action.rule.approve.AfterApprovingSynchronizeRuleRZ; import nc.bs.pu.m21.maintain.rule.SupplierFrozeChkRule;