patch_dev_5接口推送锐制优化_V18_销售出库退货及委外备料计划逻辑_sdlizheng_20250619

This commit is contained in:
李正@用友 2025-06-20 09:11:01 +08:00
parent f7b2ab6dfa
commit 43c63c6831
2 changed files with 172 additions and 14 deletions

View File

@ -16,8 +16,11 @@ import nc.vo.ic.m4c.entity.SaleOutHeadVO;
import nc.vo.ic.m4c.entity.SaleOutVO;
import nc.vo.org.OrgVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
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.MathTool;
import nc.vo.pubapp.pattern.pub.SqlBuilder;
import nc.vo.scmpub.util.ArrayUtil;
@ -73,14 +76,24 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
JSONObject dataIn = new JSONObject();
JSONObject dataIn2 = new JSONObject();
JSONArray details = new JSONArray();
jsonObject.put("dataflow", "ÓÃÓÑBIP¡úRZMOMv6");
jsonObject.put("actionCode", "cpfhtzdb");
//根据行数量正负拆分数组-并判断
UFBoolean isPosValue=checkNumSymbol(saleOutVOS);
//单笔/批量按明细传
for (SaleOutVO saleOutVO : saleOutVOS) {
SaleOutHeadVO head = saleOutVO.getHead();
SaleOutBodyVO[] bodys = saleOutVO.getBodys();
// 构建需要同步的数据
buildSyncData(head, bodys, details);
buildSyncData(head, bodys, details,isPosValue);
}
if(isPosValue.booleanValue()){
//正向
jsonObject.put("dataflow", "用友BIP→RZMOMv6");
jsonObject.put("actionCode", "cpfhtzdb");
}else{
//反向
jsonObject.put("dataflow", "用友BIP→RZMOMv6");
jsonObject.put("actionCode", "thsqb");
}
dataIn2.put("Details", details);
dataIn.put("Data", dataIn2);
@ -96,7 +109,27 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
}
}
private void buildSyncData(SaleOutHeadVO head, SaleOutBodyVO[] bodys, JSONArray details) throws BusinessException {
private UFBoolean checkNumSymbol(SaleOutVO[] saleOutVOS) throws BusinessException {
UFBoolean hasPositive = UFBoolean.FALSE;
UFBoolean hasNegative = UFBoolean.FALSE;
for (SaleOutVO saleOutVO : saleOutVOS) {
SaleOutBodyVO[] bodys = saleOutVO.getBodys();
for (SaleOutBodyVO body : bodys){
if(MathTool.compareTo(body.getNshouldassistnum(), UFDouble.ZERO_DBL)>=0){
hasPositive=UFBoolean.TRUE;
}else{
hasNegative=UFBoolean.TRUE;
}
}
}
if(hasPositive.booleanValue()&&hasNegative.booleanValue()){
throw new BusinessException("销售出库签字推送锐制失败,原因:签字不允许存在正负数量的单据");
}
return hasPositive;
}
private void buildSyncData(SaleOutHeadVO head, SaleOutBodyVO[] bodys, JSONArray details,UFBoolean isPosValue) throws BusinessException {
String vbillcode = head.getVbillcode();//单据号
String vtrantypecode = head.getVtrantypecode();//出入库类型编码
@ -115,7 +148,12 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
singleObj.put("wbid", cgeneralhid + "_" + cgeneralbid + "_" + vtrantypecode);//第三方系统主键id
singleObj.put("wbpid", cgeneralhid);//第三方系统分组id
singleObj.put("operate", 1);//operate int 操作状态 必填 1新增/修改2删除删除时只需上传wbid
if(isPosValue.booleanValue()){
singleObj.put("djly", 1013);//djly varchar(20) 来源单据
}else {
singleObj.put("djly", 1012);//djly varchar(20) 来源单据
}
singleObj.put("djbh_id", cgeneralhid);//单据id
singleObj.put("djbh", vbillcode);//单据编号
singleObj.put("djxh", crowno);//单据序号
@ -125,9 +163,14 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
//第三方系统物料名称id--编码
singleObj.put("wlbm_wbid", cmaterialvid);
if(isPosValue.booleanValue()){
//单据数量
singleObj.put("djsl", body.getNshouldassistnum().getDouble());
}else {
//单据数量
singleObj.put("djsl", MathTool.abs(body.getNshouldassistnum()).getDouble()); //负数取绝对值
}
//第三方系统客户id--编码
singleObj.put("khbh_wbid", casscustid);
//订单编号
@ -143,7 +186,7 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
// 添加两个字段 项目号 项目名称 使用 vbdef1 vbdef10
singleObj.put("wlzdycs06", transferCodeByPk("bd_defdoc", DefdocVO.CODE, DefdocVO.PK_DEFDOC, body.getVbdef1()));
singleObj.put("wlzdycs11", transferCodeByPk("bd_defdoc", DefdocVO.NAME, DefdocVO.PK_DEFDOC, body.getVbdef10()));
singleObj.put("wlzdycs11", body.getVbdef10());
//签发标记
singleObj.put("qfbj", 1);
//操作状态 1新增/修改2删除删除时只需上传wbid

View File

@ -11,12 +11,14 @@ import nc.jdbc.framework.processor.ColumnProcessor;
import nc.pubitf.para.SysInitQuery;
import nc.vo.bd.material.MaterialVO;
import nc.vo.bd.rt.rt0004.entity.RcVO;
import nc.vo.bd.stordoc.StordocVO;
import nc.vo.cmp.util.StringUtils;
import nc.vo.mmpac.pickm.entity.AggPickmVO;
import nc.vo.mmpac.pickm.entity.PickmHeadVO;
import nc.vo.mmpac.pickm.entity.PickmItemVO;
import nc.vo.org.OrgVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pattern.pub.SqlBuilder;
import nc.vo.scmpub.util.ArrayUtil;
@ -41,13 +43,36 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
if (newAggPickmVOS.isEmpty()) {
return;
}
pushToRZMOM(newAggPickmVOS.toArray(new AggPickmVO[0]));
Boolean is55A2=checkSrcBillType(newAggPickmVOS);
if(is55A2){
//来源生产订单
pushToRZMOMBy55A2(newAggPickmVOS.toArray(new AggPickmVO[0]));
}else{
//来源委外订单
pushToRZMOMBy61(newAggPickmVOS.toArray(new AggPickmVO[0]));
}
} catch (Exception e) {
ExceptionUtils.wrappException(e);
}
}
private void buildSyncData(PickmHeadVO head, PickmItemVO[] bodys, JSONArray details) throws BusinessException {
private Boolean checkSrcBillType(List<AggPickmVO> newAggPickmVOS) throws BusinessException {
UFBoolean is61=UFBoolean.FALSE;
UFBoolean is55A2=UFBoolean.FALSE;
for (AggPickmVO aggPickmVO : newAggPickmVOS) {
String vfirstbilltype = aggPickmVO.getParentVO().getVfirstbilltype();
if("61".equals(vfirstbilltype)){
is61=UFBoolean.TRUE;
}else if("55A2".equals(vfirstbilltype)){
is55A2=UFBoolean.TRUE;
}
}
if(is55A2.booleanValue()&&is61.booleanValue()){
throw new BusinessException("备料计划推送锐制失败,原因:不允许源头单据类型为生产订单和委外订单的单据同时审批");
}
return is55A2.booleanValue();
}
private void buildSyncDataBy55A2(PickmHeadVO head, PickmItemVO[] bodys, JSONArray details) throws BusinessException {
Integer fsourcetype = head.getFsourcetype();
if(fsourcetype!=0){
return;
@ -79,7 +104,7 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
//bomlx int BOM类型 必填 默认=0即传入生产BOM1为包装BOM
singleObj.put("bomlx", 0);
singleObj.put("dwyl", body.getNunituseastnum().getDouble()); // µ¥Î»ÓÃÁ¿
singleObj.put("dwyl", body.getNunituseastnum().getDouble()); // 单位用量nunituseastnum
singleObj.put("djyl", body.getNplanoutastnum().getDouble()); // 单据用量
singleObj.put("clyl", body.getNplanoutastnum().getDouble()); // 材料用量
@ -98,20 +123,84 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
}
}
private void buildSyncDataBy61(PickmHeadVO head, PickmItemVO[] bodys, JSONArray details) throws BusinessException {
Integer fsourcetype = head.getFsourcetype();
if(fsourcetype!=1){
return;
}
for (PickmItemVO body : bodys) {
JSONObject singleObj = new JSONObject();
String vsourcebillcode = head.getVsourcebillcode();
String wlbm_wbid =body.getCbmaterialvid();
String scgx_wbid =head.getVstdprocid();
//wbid varchar (200) 第三方系统主键id
singleObj.put("wbid", head.getCpickmid()+"_"+body.getCpickm_bid()); // 第三方系统主键id
//wbzbid varchar (200) 第三方系统分组id
singleObj.put("wbpid", head.getCpickmid());
//operate int 操作状态 必填 1新增/修改2删除删除时只需上传wbid
singleObj.put("operate", "1");
//djly varchar(20) 来源单据 必填 取值read_djlyb中编号
//领料通知默认1011
singleObj.put("djly", "1011");
//_id varchar(50) 单据id 必填 后台该单据类型的唯一ID
singleObj.put("djbh_id", head.getCpickmid());
//djbh varchar(100) 单据编号 必填 前台单据编号
singleObj.put("djbh", head.getVbillcode());
//djxh numeric(5) 单据序号 必填 前台单据序号
singleObj.put("djxh", body.getVrowno());
//djrq datetime 单据日期 必填
singleObj.put("djrq", head.getDmakedate());
//wlbm_wbid varchar(100) 第三方系统物料名称id 必填 物料编码的后台ID
singleObj.put("wlbm_wbid", wlbm_wbid);
//scjh_wbid varchar(100) 第三方系统生产计划ID 必填 生产计划号外部ID一般ERP系统的生产订单号
singleObj.put("scjh_wbid", head.getCsourcebillid());
//jhxh numeric(5) 计划序号 -生产订单行号
singleObj.put("jhxh", head.getVsourcebillrowno());
//djsl numeric(18,3) 单据数量 必填
singleObj.put("djsl", body.getNpscnum().getDouble());
//sddd varchar(510) 送达地点 必填 传仓库名称要求上位ERP仓库名称不重复
singleObj.put("sddd", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.NAME, StordocVO.PK_STORDOC, body.getCoutstockid()));
//ckbh_wbid varchar(100) 第三方系统仓库id 必填 储区根据仓库默认同仓库多储区时两者必填
singleObj.put("ckbh_wbid",transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getCoutstockid()));
//qfbj int 签发标记 必填 默认1上位系统审核传至MOM 1
singleObj.put("qfbj", 1);
//cght_wbid varchar(100) 第三方系统合同id 必填 委外订单
singleObj.put("cght_wbid", head.getVfirstbillcode());
details.add(singleObj);
}
}
private List<AggPickmVO> checkAndFilterBillSrcOrg(AggPickmVO[] aggPickmVOS) throws BusinessException {
List<AggPickmVO> aggvoList = new ArrayList<>();
for (AggPickmVO aggvo : aggPickmVOS) {
String pkOrg = aggvo.getParentVO().getPk_org();
String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
//过滤上游不是生产订单和委外订单的备料计划
String vfirstbilltype = aggvo.getParentVO().getVfirstbilltype();
if ("C022".equals(orgCode)&& 1 == aggvo.getParentVO().getFbillstatus()&&aggvo.getChildrenVO()!=null && aggvo.getChildrenVO().length > 0) {
if("61".equals(vfirstbilltype)||"55A2".equals(vfirstbilltype)){
aggvoList.add(aggvo);
}
}
}
return aggvoList;
}
private void pushToRZMOM(AggPickmVO[] aggPickmVOS) throws BusinessException {
private void pushToRZMOMBy55A2(AggPickmVO[] aggPickmVOS) throws BusinessException {
String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP");
JSONObject jsonObject = new JSONObject();
JSONObject dataIn = new JSONObject();
@ -123,7 +212,7 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
for (AggPickmVO aggPickmVO : aggPickmVOS) {
PickmHeadVO head = aggPickmVO.getParentVO();
PickmItemVO[] bodys = (PickmItemVO[]) aggPickmVO.getChildrenVO();
buildSyncData(head, bodys, details);
buildSyncDataBy55A2(head, bodys, details);
}
dataIn2.put("Details", details);
dataIn.put("Data", dataIn2);
@ -138,7 +227,33 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
log.error("RZMOM同步成功返回参数【"+resultObj.toJSONString()+"");
}
}
private void pushToRZMOMBy61(AggPickmVO[] aggPickmVOS) throws BusinessException {
String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP");
JSONObject jsonObject = new JSONObject();
JSONObject dataIn = new JSONObject();
JSONObject dataIn2 = new JSONObject();
JSONArray details = new JSONArray();
jsonObject.put("dataflow", "用友BIP→RZMOMv6");
jsonObject.put("actionCode", "wwfhtzdb");
for (AggPickmVO aggPickmVO : aggPickmVOS) {
PickmHeadVO head = aggPickmVO.getParentVO();
PickmItemVO[] bodys = (PickmItemVO[]) aggPickmVO.getChildrenVO();
buildSyncDataBy61(head, bodys, details);
}
dataIn2.put("Details", details);
dataIn.put("Data", dataIn2);
jsonObject.put("data", dataIn);
log.error("生产BOW推送锐制请求报文" + jsonObject.toJSONString());
String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString());
JSONObject resultObj = JSONObject.parseObject(result);
if (resultObj == null || !"true".equals(resultObj.getString("success"))) {
String errorMsg = resultObj == null ? "接口返回为空" : resultObj.getString("msg");
throw new BusinessException("RZ同步失败原因" + errorMsg);
}else{
log.error("RZMOM同步成功返回参数【"+resultObj.toJSONString()+"");
}
}
private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException {
if (StringUtils.isEmpty(pk)) {
return null;