采购订单/销售出库审批同步锐制代码优化
This commit is contained in:
parent
8f7a6a11a5
commit
73d5e0c732
|
@ -109,7 +109,7 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
|
|||
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);//单据序号
|
||||
|
|
|
@ -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<OrderVO> {
|
||||
|
||||
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<OrderVO> {
|
|||
// 推送到睿智系统
|
||||
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<OrderVO> {
|
|||
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)) {
|
||||
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<OrderVO> {
|
|||
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<OrderVO> {
|
|||
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<OrderVO> {
|
|||
/**
|
||||
* 构建同步数据
|
||||
*/
|
||||
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<OrderVO> {
|
|||
}
|
||||
|
||||
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<OrderVO> {
|
|||
/**
|
||||
* 根据主键查询编码
|
||||
*/
|
||||
private String transferCodeByPk(String tableName, String pk) throws BusinessException {
|
||||
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 + "】");
|
||||
|
|
|
@ -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;
|
Loading…
Reference in New Issue