From e1f46549b858ce90b5e14221de70d8dcb634f593 Mon Sep 17 00:00:00 2001 From: luo jia shan <125556714+Topfunplus@users.noreply.github.com> Date: Sat, 17 May 2025 16:26:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(pu):=20=E9=87=87=E8=B4=AD=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=AE=A1=E6=89=B9=E5=90=8E=E5=90=8C=E6=AD=A5=E5=88=B0?= =?UTF-8?q?=E7=9D=BF=E6=99=BA=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 AfterApprovingSynchronizeRuleRZ 类实现采购订单审批后同步到睿智系统 - 修改 OrderApproveAction 类,添加采购订单审批后的同步规则 - 更新 AfterApprovingSynchronizeRule 和 AfterSigningSynchronizeRule 类,调整组织过滤条件 --- .../rule/AfterSigningSynchronizeRule.java | 6 +- .../rule/AfterApprovingSynchronizeRule.java | 6 +- .../bs/pu/m21/action/OrderApproveAction.java | 133 ++++++++++++ .../AfterApprovingSynchronizeRuleRZ.java | 205 ++++++++++++++++++ 4 files changed, 346 insertions(+), 4 deletions(-) create mode 100644 pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java create mode 100644 pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java diff --git a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java index 9909ce7..f475442 100644 --- a/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java +++ b/ic/src/private/nc/bs/ic/m4c/sign/rule/AfterSigningSynchronizeRule.java @@ -16,7 +16,9 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.text.SimpleDateFormat; -//۳⣨ǩֺMES˼άϵͳ +/** + * ۳⣨ǩֺMES˼άϵͳ + */ public class AfterSigningSynchronizeRule implements IRule { private static final String SALE_OUT_URL = "/GTHINKING/AjaxService/N_MISPRO/SaleOrderOutbound.ashx/SaveData"; // ۳Ǽǽӿ private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -59,7 +61,7 @@ public class AfterSigningSynchronizeRule implements IRule { */ private JSONObject buildSyncData(SaleOutHeadVO hvo, SaleOutBodyVO[] bvos) { obmlog.debug("AfterSigningSynchronizeRule-ʼ۳ⵥ: " + hvo.getVbillcode()); - if (!hvo.getPk_org().equals("0001A1100000000026O5") || !hvo.getPk_org().equals("1001A11000000KFE18FO")) { + if (!hvo.getPk_org().equals("0001A110000000000677")) { obmlog.debug("AfterSigningSynchronizeRule-۳ⵥ,Ϊ˵֯ǵ: " + hvo.getVbillcode()); return null; } diff --git a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java index e4f7a5e..984c808 100644 --- a/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java +++ b/ic/src/private/nc/bs/ic/m4r/approve/rule/AfterApprovingSynchronizeRule.java @@ -18,7 +18,9 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys; import java.text.SimpleDateFormat; -// ̵㣨MES +/** + * ̵㣨MES + */ public class AfterApprovingSynchronizeRule implements IRule { private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/N_MISPRO/InvCount.ashx/SaveData"; // ̵㵥ͬӿ private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -65,7 +67,7 @@ public class AfterApprovingSynchronizeRule implements IRule { */ private JSONObject buildSyncData(InvCountHeaderVO hvo, InvCountBodyVO[] bvos) throws BusinessException { obmlog.debug("AfterApprovingSynchronizeRule-ʼ̵㵥: " + hvo.getVbillcode()); - if (!hvo.getPk_org().equals("0001A1100000000026O5") || !hvo.getPk_org().equals("1001A11000000KFE18FO")) { + if (!hvo.getPk_org().equals("0001A110000000000677")) { obmlog.debug("AfterApprovingSynchronizeRule-۳ⵥ,Ϊ˵֯ǵ: " + hvo.getVbillcode()); return null; } diff --git a/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java b/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java new file mode 100644 index 0000000..e139a9f --- /dev/null +++ b/pu/src/private/nc/bs/pu/m21/action/OrderApproveAction.java @@ -0,0 +1,133 @@ +package nc.bs.pu.m21.action; + +import nc.bs.pu.m21.action.rule.approve.AfterApprovingSynchronizeRuleRZ; +import nc.bs.pu.m21.maintain.rule.SupplierFrozeChkRule; +import nc.bs.pu.m21.plugin.OrderPluginPoint; +import nc.bs.pub.compiler.AbstractCompiler2; +import nc.bs.scmpub.pf.PfParameterUtil; +import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; +import nc.impl.pu.m21.action.OrderReviseApproveAction; +import nc.impl.pu.m21.action.rule.approve.*; +import nc.impl.pu.m21.action.rule.pm.OrderApprovePMSupplyRule; +import nc.impl.pu.m21.action.rule.pm.OrderRewritePMStartDateRule; +import nc.impl.pu.m21.action.rule.revise.CheckBfinalcloseRule; +import nc.impl.pubapp.pattern.data.bill.BillUpdate; +import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; +import nc.itf.pu.m21.compensate.IOrderSagasCompensate; +import nc.itf.pu.reference.ic.ATPServices; +import nc.vo.pu.m21.context.OrderContext; +import nc.vo.pu.m21.entity.OrderVO; +import nc.vo.pu.pub.enumeration.POEnumBillStatus; +import nc.vo.pu.pub.rule.pf.UpdatePflowVORule; +import nc.vo.pu.pub.sagas.PUSagasOperationEnum; +import nc.vo.pub.BusinessException; +import nc.vo.pub.compiler.PfParameterVO; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.scmpub.msg.rule.UpdateMsgStatusRule; +import nc.vo.scmpub.res.billtype.POBillType; +import nc.vo.scmpub.util.AppInfoContext; +import nccloud.commons.lang.ArrayUtils; +import nccloud.pubimpl.pu.mobile.service.order.MobAfterApproveForPoOrderImpl; +import nccloud.pubitf.pu.pub.util.PuSagasUtil; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class OrderApproveAction { + public OrderApproveAction() { + } + + public OrderVO[] approve(OrderVO[] vos, AbstractCompiler2 script, OrderContext[] ctxs) { + Integer reviseStatus = vos[0].getHVO().getRevisionStatus(); + PfParameterUtil util = new PfParameterUtil(script == null ? null : script.getPfParameterVO(), vos); + OrderVO[] originBills = (OrderVO[]) util.getClientOrignBills(); + OrderVO[] clientBills = (OrderVO[]) util.getClientFullInfoBill(); + AroundProcesser processer = new AroundProcesser(OrderPluginPoint.APPROVE); + this.addBeforeRule(processer); + this.addAfterRule(processer, null != script ? script.getPfParameterVO() : null); + OrderVO[] customProperty = (OrderVO[]) script.getPfParameterVO().getCustomProperty("nc.bs.scmpub.pf.ORIGIN_VO_PARAMETER"); + if (customProperty == null || customProperty.length == 0) { + clientBills = vos; + } + + processer.before(clientBills); + if (null != script) { + try { + script.procFlowBacth(script.getPfParameterVO()); + } catch (Exception e) { + ExceptionUtils.wrappException(e); + } + } + + OrderVO[] returnVos; + if (reviseStatus != null && reviseStatus == 0 && vos[0].getHVO().getForderstatus() == POEnumBillStatus.APPROVE.toIntValue()) { + OrderContext ctx = ArrayUtils.isEmpty(ctxs) ? new OrderContext() : ctxs[0]; + returnVos = (new OrderReviseApproveAction()).approve(clientBills, ctx); + } else { + this.atpBeforeUpdate(clientBills); + BillUpdate update = new BillUpdate(); + returnVos = (OrderVO[]) update.update(clientBills, originBills); + + try { + AppInfoContext.setProductCode(PUSagasOperationEnum.OREDERAPPROVE.getResCommon()); + AppInfoContext.setResId(PUSagasOperationEnum.OREDERAPPROVE.getResId()); + PuSagasUtil.frozenAndAddSaga(originBills, POBillType.Order.getCode()); + Map map = new HashMap(); + map.put("opertaion", "approve"); + map.put("pk_order", originBills[0].getHVO().getPk_order()); + map.put("po_order_isrevise", UFBoolean.FALSE); + map.put("po_orderapprover", originBills[0].getHVO().getApprover()); + map.put("po_ordertaudittime", originBills[0].getHVO().getTaudittime()); + map.put("po_orderforderstatus", originBills[0].getHVO().getForderstatus()); + PuSagasUtil.compensate(IOrderSagasCompensate.class, map); + } catch (BusinessException e) { + ExceptionUtils.wrappException(e); + } + + if (vos[0].getHVO().getForderstatus() == POEnumBillStatus.APPROVE.toIntValue()) { + this.atpUpdate(returnVos); + processer.after(returnVos); + } + } + + return returnVos; + } + + private void addAfterRule(AroundProcesser processer, PfParameterVO pfParameterVO) { + processer.addAfterRule(new ApproveBudgetCtrlRule()); + processer.addAfterRule(new FilterOrderByStatusRule(POEnumBillStatus.APPROVE.toInt())); + processer.addAfterRule(new ApproveSupplyRule()); + processer.addAfterRule(new InsertStatusOnWayRule()); + processer.addAfterRule(new InsertPayPlanBillVORule()); + processer.addAfterRule(new ApproveRewritePayPlanConfirmData4CTRule()); + processer.addAfterRule(new ApproveRewritePayPlanConfirmDataRule()); + processer.addAfterRule(new FillNcaninnumRule()); + processer.addAfterRule(new ApproveAfterEventRule()); + processer.addAfterRule(new MobAfterApproveForPoOrderImpl()); + processer.addAfterFinalRule(new UpdatePflowVORule(pfParameterVO)); + processer.addAfterFinalRule(new ApproveM21AndRewriteCTPayPlan()); + processer.addAfterRule(new OrderRewritePMStartDateRule(true)); + processer.addAfterRule(new OrderApprovePMSupplyRule()); + // ɹ ͬMESϵͳ + processer.addAfterRule(new AfterApprovingSynchronizeRuleRZ()); + } + + private void addBeforeRule(AroundProcesser processer) { + processer.addBeforeRule(new VOSagaFrozenValidateRule(true)); + processer.addBeforeRule(new CheckBfinalcloseRule()); + processer.addBeforeRule(new ApproveVOValidateRule()); + processer.addBeforeRule(new SupplierFrozeChkRule()); + processer.addBeforeRule(new ApproveBeforeEventRule()); + processer.addBeforeRule(new UpdateMsgStatusRule("pk_order")); + } + + private void atpBeforeUpdate(OrderVO[] vos) { + ATPServices.modifyATPBefore(POBillType.Order.getCode(), vos); + } + + private void atpUpdate(OrderVO[] vos) { + ATPServices.modifyATPAfter(POBillType.Order.getCode(), vos); + } +} 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 new file mode 100644 index 0000000..aa178ce --- /dev/null +++ b/pu/src/private/nc/bs/pu/m21/action/rule/approve/AfterApprovingSynchronizeRuleRZ.java @@ -0,0 +1,205 @@ +package nc.bs.pu.m21.action.rule.approve; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.dao.BaseDAO; +import nc.bs.logging.Log; +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.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.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.SqlBuilder; +import nc.vo.scmpub.util.ArrayUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * ɹͬϵͳ + */ +public class AfterApprovingSynchronizeRuleRZ implements IRule { + + private static final Log obmlog = 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; + + @Override + public void process(OrderVO[] orderVOS) { + if (ArrayUtil.isEmpty(orderVOS)) { + return; + } + try { + //鲢ɸѡ۳ⵥΪ˾ + List newOrderVOS = checkAndFilterBillSrcOrg(orderVOS); + if (newOrderVOS.isEmpty()) { + return; + } + // ͵ϵͳ + pushToRZMOM(newOrderVOS.toArray(new OrderVO[0])); + } catch (Exception e) { + obmlog.error("ͬɹϵͳʧ: " + e.getMessage(), e); + ExceptionUtils.wrappException(e); + } + } + + private List checkAndFilterBillSrcOrg(OrderVO[] OrderVOS) throws BusinessException { + List aggvoList = new ArrayList<>(); + for (OrderVO aggvo : OrderVOS) { + String pkOrg = aggvo.getHVO().getPk_org(); + String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), pkOrg); + if ("30401".equals(orgCode)) { + aggvoList.add(aggvo); + } + } + return aggvoList; + } + + /** + * ݵMOMϵͳ + */ + private void pushToRZMOM(OrderVO[] orderVOS) throws BusinessException { + String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP"); + + JSONObject jsonObject = new JSONObject(); + // ͷ + jsonObject.put("dataflow", "̩BIPRZMOMv6"); + jsonObject.put("actionCode", "cghtb"); + + JSONObject dataIn = new JSONObject(); + JSONObject dataIn2 = new JSONObject(); + JSONArray details = new JSONArray(); + + // /ϸ + for (OrderVO orderVO : orderVOS) { + OrderHeaderVO head = orderVO.getHVO(); + OrderItemVO[] items = orderVO.getBVO(); + + // ͬ + buildSyncData(head, items, details); + } + + dataIn2.put("Details", details); + dataIn.put("Data", dataIn2); + jsonObject.put("data", dataIn); + + obmlog.error("ɹģ" + jsonObject.toJSONString()); + + // ʹThirdPartyPostRequestUtil + String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString()); + JSONObject resultObj = JSONObject.parseObject(result); + if ("false".equals(resultObj.getString("success"))) { + throw new BusinessException("RZMOMͬʧܣԭ" + resultObj.getString("msg")); + } + } + + /** + * ͬ + */ + private void buildSyncData(OrderHeaderVO head, OrderItemVO[] items, JSONArray details) { + if (items == null) { + return; + } + + for (OrderItemVO item : items) { + if (item == null) { + continue; + } + + JSONObject detailItem = new JSONObject(); + + // öϢ + detailItem.put("htmx_wbid", item.getPk_order_b()); + detailItem.put("cght_wbid", head.getVbillcode()); + 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("htxsbh", head.getVbillcode()); + detailItem.put("htxh", item.getCrowno()); + + // Ϣ + detailItem.put("wlbm_wbid", item.getPk_material()); + + // Ϣ + if (item.getNastnum() != null) { + detailItem.put("cgsl", item.getNastnum().doubleValue()); + } + + // ùӦ̺ͲɹԱϢ + 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); + + // üƻ + if (item.getDplanarrvdate() != null) { + detailItem.put("jhrq", item.getDplanarrvdate().toString()); + } + + // ԴϢ + detailItem.put("cgjh_wbid", item.getVsourcetrantype()); + detailItem.put("cgbh", item.getVsourcecode()); + detailItem.put("cgxh", item.getVsourcerowno()); + + // òֿͱעϢ + detailItem.put("sdck", item.getPk_reqstordoc()); + detailItem.put("bzsm", item.getVbmemo()); + + // ״̬Ϣ + detailItem.put("sdbj", STATUS_LOCKED); + detailItem.put("qfbj", STATUS_ISSUED); + + // õλϢ + detailItem.put("jldw", null); + + details.add(detailItem); + } + } + + /** + * ѯ + */ + private String transferCodeByPk(String tableName, String pk) throws BusinessException { + if (StringUtils.isEmpty(pk)) { + return null; + } + SqlBuilder sqlBuilder = new SqlBuilder(); + sqlBuilder.append(" select " + OrgVO.CODE); + sqlBuilder.append(" from " + tableName); + sqlBuilder.append(" where "); + sqlBuilder.append(OrgVO.PK_ORG, pk); + Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor()); + if (o == null) { + throw new BusinessException("δѯϢsql" + sqlBuilder + ""); + } + return o.toString(); + } +}