2025-05-17 17:42:59 +08:00
|
|
|
|
package nc.bs.sc.m61.referred.rule.pm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.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.pub.BusinessException;
|
2025-05-18 15:13:21 +08:00
|
|
|
|
import nc.vo.pub.lang.UFDouble;
|
2025-05-17 17:42:59 +08:00
|
|
|
|
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
|
|
|
|
import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
|
|
|
|
import nc.vo.sc.m61.entity.SCOrderHeaderVO;
|
|
|
|
|
import nc.vo.sc.m61.entity.SCOrderItemVO;
|
|
|
|
|
import nc.vo.sc.m61.entity.SCOrderVO;
|
|
|
|
|
import nc.vo.scmpub.util.ArrayUtil;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class AfterApproceRuleSyncRZWMSProcess implements IRule<SCOrderVO> {
|
|
|
|
|
|
|
|
|
|
private static Log log = Log.getInstance("rzmomlog");
|
|
|
|
|
|
|
|
|
|
private static BaseDAO dao = new BaseDAO();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void process(SCOrderVO[] vos) {
|
|
|
|
|
if (ArrayUtil.isEmpty(vos)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
//<2F><><EFBFBD>鲢ɸѡ<C9B8><D1A1><EFBFBD>۳<EFBFBD><DBB3>ⵥ<EFBFBD><E2B5A5>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾
|
|
|
|
|
List<SCOrderVO> newSCOrderVOS = checkAndFilterBillSrcOrg(vos);
|
|
|
|
|
if (newSCOrderVOS == null || newSCOrderVOS.size() < 1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pushToRZMOM(newSCOrderVOS.toArray(new SCOrderVO[0]));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
ExceptionUtils.wrappException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buildSyncData(SCOrderHeaderVO head, SCOrderItemVO[] bodys, JSONArray details) throws BusinessException {
|
|
|
|
|
|
|
|
|
|
for (SCOrderItemVO body : bodys) {
|
|
|
|
|
JSONObject singleObj = new JSONObject();
|
2025-05-18 15:13:21 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>״̬ 1<><31><EFBFBD><EFBFBD>/<2F>ġ<DEB8>2ɾ<32><C9BE><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʱֻ<CAB1><D6BB><EFBFBD>ϴ<EFBFBD>wbid<69><64>
|
|
|
|
|
singleObj.put("operate", 1);
|
2025-05-17 17:42:59 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-05-18 14:35:25 +08:00
|
|
|
|
singleObj.put("cgjh_wbid", body.getVsrctrantype()); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>ɹ<EFBFBD><C9B9>ƻ<EFBFBD>id
|
|
|
|
|
singleObj.put("cgxh", body.getVsrcrowno()); // <20>ɹ<EFBFBD><C9B9>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
singleObj.put("cgbh", body.getVsrccode()); // <20>ɹ<EFBFBD><C9B9>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
singleObj.put("bzsm", body.getVbmemo()); // <20><>ע˵<D7A2><CBB5>
|
|
|
|
|
singleObj.put("cght_wbid", head.getVbillcode()); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>ͬID
|
|
|
|
|
singleObj.put("htxsbh", head.getVbillcode()); // <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>
|
2025-05-17 17:42:59 +08:00
|
|
|
|
// <20><>Ӧ<EFBFBD><D3A6>
|
2025-05-18 14:35:25 +08:00
|
|
|
|
singleObj.put("zbxx_gycs_wbid", transferCodeByPk(SupplierVO.getDefaultTableName(), SupplierVO.CODE, SupplierVO.PK_SUPPLIER, head.getPk_supplier())); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>id
|
2025-05-17 17:42:59 +08:00
|
|
|
|
// <20>ֿ<EFBFBD>
|
2025-05-18 14:35:25 +08:00
|
|
|
|
singleObj.put("sdck", transferCodeByPk(StordocVO.getDefaultTableName(), StordocVO.CODE, StordocVO.PK_STORDOC, body.getPk_recvstordoc())); // <20>ʹ<EFBFBD><CDB4>ֿ<EFBFBD>
|
2025-05-17 17:42:59 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
2025-05-18 14:35:25 +08:00
|
|
|
|
singleObj.put("wlbm_wbid", transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getPk_material())); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>id
|
2025-05-17 17:42:59 +08:00
|
|
|
|
|
2025-05-18 15:13:21 +08:00
|
|
|
|
UFDouble nqtunitnum = body.getNqtunitnum() == null ? UFDouble.ZERO_DBL : body.getNqtunitnum();
|
|
|
|
|
singleObj.put("cgsl", nqtunitnum.getDouble()); // <20>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (body.getDplanarrvdate() != null) {
|
|
|
|
|
singleObj.put("jhrq", body.getDplanarrvdate().toString()); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
if (head.getDbilldate() != null) {
|
|
|
|
|
singleObj.put("zbxx_cgrq", head.getDbilldate().toString()); // <20>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
if (head.getDbilldate() != null) {
|
|
|
|
|
singleObj.put("cgrq", head.getDbilldate().toString()); // <20>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
2025-05-18 14:35:25 +08:00
|
|
|
|
|
|
|
|
|
singleObj.put("htxh", body.getCrowno()); // <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>
|
|
|
|
|
singleObj.put("zbxx_cgy_wbid", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.CODE, PsndocVO.PK_PSNDOC, head.getCemployeeid())); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>ɹ<EFBFBD>Աid
|
2025-05-17 17:42:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
details.add(singleObj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<SCOrderVO> checkAndFilterBillSrcOrg(SCOrderVO[] SCOrderVOS) throws BusinessException {
|
|
|
|
|
List<SCOrderVO> aggvoList = new ArrayList<>();
|
|
|
|
|
for (SCOrderVO aggvo : SCOrderVOS) {
|
|
|
|
|
String pkOrg = aggvo.getParentVO().getPk_org();
|
2025-05-18 15:13:21 +08:00
|
|
|
|
Integer fstatusflag = aggvo.getParentVO().getFstatusflag();
|
2025-05-17 17:42:59 +08:00
|
|
|
|
String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
2025-05-18 15:13:21 +08:00
|
|
|
|
if ("30401".equals(orgCode) && 3 == fstatusflag) {
|
2025-05-17 17:42:59 +08:00
|
|
|
|
aggvoList.add(aggvo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return aggvoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pushToRZMOM(SCOrderVO[] SCOrderVOS) throws BusinessException {
|
|
|
|
|
String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP");
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
JSONObject dataIn = new JSONObject();
|
|
|
|
|
JSONObject dataIn2 = new JSONObject();
|
|
|
|
|
JSONArray details = new JSONArray();
|
|
|
|
|
jsonObject.put("dataflow", "̩<EFBFBD><EFBFBD>BIP<EFBFBD><EFBFBD>RZMOMv6");
|
|
|
|
|
jsonObject.put("actionCode", "cpfhtzdb");
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8>
|
|
|
|
|
for (SCOrderVO SCOrderVO : SCOrderVOS) {
|
|
|
|
|
SCOrderHeaderVO head = SCOrderVO.getParentVO();
|
|
|
|
|
SCOrderItemVO[] bodys = SCOrderVO.getChildrenVO();
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫͬ<D2AA><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
buildSyncData(head, bodys, details);
|
|
|
|
|
}
|
|
|
|
|
dataIn2.put("Details", details);
|
|
|
|
|
dataIn.put("Data", dataIn2);
|
|
|
|
|
data.put("data", dataIn);
|
|
|
|
|
jsonObject.put("data", data);
|
|
|
|
|
log.error("ί<EFBFBD>ⶩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>" + jsonObject.toJSONString());
|
|
|
|
|
String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString());
|
|
|
|
|
JSONObject resultObj = JSONObject.parseObject(result);
|
|
|
|
|
if ("false".equals(resultObj.getString("success"))) {
|
|
|
|
|
throw new BusinessException("RZMOMͬ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + resultObj.getString("msg"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 " + selectField);
|
|
|
|
|
sqlBuilder.append(" from " + tableName);
|
|
|
|
|
sqlBuilder.append(" where ");
|
|
|
|
|
sqlBuilder.append(pkField, pk);
|
|
|
|
|
Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor());
|
|
|
|
|
if (o == null) {
|
|
|
|
|
throw new BusinessException("δ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>sql<EFBFBD><EFBFBD>" + sqlBuilder + "<EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
return o.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|