feat(pu): 采购订单审批后同步到睿智系统

- 新增 AfterApprovingSynchronizeRuleRZ 类实现采购订单审批后同步到睿智系统
- 修改 OrderApproveAction 类,添加采购订单审批后的同步规则
- 更新 AfterApprovingSynchronizeRule 和 AfterSigningSynchronizeRule 类,调整组织过滤条件
This commit is contained in:
luo jia shan 2025-05-17 16:26:07 +08:00
parent f237cd1f40
commit e1f46549b8
4 changed files with 346 additions and 4 deletions

View File

@ -16,7 +16,9 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
//销售出库签字后传MES金思维系统 /**
* 销售出库签字后传MES金思维系统
*/
public class AfterSigningSynchronizeRule implements IRule<SaleOutVO> { public class AfterSigningSynchronizeRule implements IRule<SaleOutVO> {
private static final String SALE_OUT_URL = "/GTHINKING/AjaxService/N_MISPRO/SaleOrderOutbound.ashx/SaveData"; // 销售出库登记接口 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"); private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -59,7 +61,7 @@ public class AfterSigningSynchronizeRule implements IRule<SaleOutVO> {
*/ */
private JSONObject buildSyncData(SaleOutHeadVO hvo, SaleOutBodyVO[] bvos) { private JSONObject buildSyncData(SaleOutHeadVO hvo, SaleOutBodyVO[] bvos) {
obmlog.debug("AfterSigningSynchronizeRule-开始处理销售出库单: " + hvo.getVbillcode()); 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()); obmlog.debug("AfterSigningSynchronizeRule-跳过处理销售出库单,因为此单据组织非电缆: " + hvo.getVbillcode());
return null; return null;
} }

View File

@ -18,7 +18,9 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
// 盘点审批后传MES /**
* 盘点审批后传MES
*/
public class AfterApprovingSynchronizeRule implements IRule<InvCountBillVO> { public class AfterApprovingSynchronizeRule implements IRule<InvCountBillVO> {
private static final String INV_COUNT_URL = "/GTHINKING/AjaxService/N_MISPRO/InvCount.ashx/SaveData"; // 盘点单同步接口 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"); private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -65,7 +67,7 @@ public class AfterApprovingSynchronizeRule implements IRule<InvCountBillVO> {
*/ */
private JSONObject buildSyncData(InvCountHeaderVO hvo, InvCountBodyVO[] bvos) throws BusinessException { private JSONObject buildSyncData(InvCountHeaderVO hvo, InvCountBodyVO[] bvos) throws BusinessException {
obmlog.debug("AfterApprovingSynchronizeRule-开始处理盘点单: " + hvo.getVbillcode()); 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()); obmlog.debug("AfterApprovingSynchronizeRule-跳过处理销售出库单,因为此单据组织非电缆: " + hvo.getVbillcode());
return null; return null;
} }

View File

@ -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<OrderVO> util = new PfParameterUtil(script == null ? null : script.getPfParameterVO(), vos);
OrderVO[] originBills = (OrderVO[]) util.getClientOrignBills();
OrderVO[] clientBills = (OrderVO[]) util.getClientFullInfoBill();
AroundProcesser<OrderVO> 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<OrderVO> 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<String, Serializable> 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<OrderVO> 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<OrderVO> 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);
}
}

View File

@ -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<OrderVO> {
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<OrderVO> 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<OrderVO> checkAndFilterBillSrcOrg(OrderVO[] OrderVOS) throws BusinessException {
List<OrderVO> 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", "泰开BIP→RZMOMv6");
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();
}
}