Compare commits
No commits in common. "eabf29c694687e3aaa31da5a19517ccd42a280fb" and "6696ebbe242a004c60c24656eb7591715bdaf296" have entirely different histories.
eabf29c694
...
6696ebbe24
|
|
@ -10,7 +10,6 @@ import nc.bs.businessevent.bd.BDCommonEvent;
|
||||||
import nc.bs.dao.BaseDAO;
|
import nc.bs.dao.BaseDAO;
|
||||||
import nc.bs.framework.common.NCLocator;
|
import nc.bs.framework.common.NCLocator;
|
||||||
import nc.bs.logging.Log;
|
import nc.bs.logging.Log;
|
||||||
import nc.bs.trade.business.HYPubBO;
|
|
||||||
import nc.bs.uapbd.util.MyHelper;
|
import nc.bs.uapbd.util.MyHelper;
|
||||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
||||||
import nc.jdbc.framework.processor.MapProcessor;
|
import nc.jdbc.framework.processor.MapProcessor;
|
||||||
|
|
@ -21,14 +20,17 @@ import nc.vo.bd.material.MaterialVO;
|
||||||
import nc.vo.bd.material.marbasclass.MarBasClassVO;
|
import nc.vo.bd.material.marbasclass.MarBasClassVO;
|
||||||
import nc.vo.bd.material.plan.MaterialPlanVO;
|
import nc.vo.bd.material.plan.MaterialPlanVO;
|
||||||
import nc.vo.bd.material.stock.MaterialStockVO;
|
import nc.vo.bd.material.stock.MaterialStockVO;
|
||||||
|
import nc.vo.bd.pub.BDCacheQueryUtil;
|
||||||
import nc.vo.org.OrgVO;
|
import nc.vo.org.OrgVO;
|
||||||
import nc.vo.pub.BusinessException;
|
import nc.vo.pub.BusinessException;
|
||||||
import nc.vo.pub.lang.UFBoolean;
|
import nc.vo.pub.lang.UFBoolean;
|
||||||
import nc.vo.sm.UserVO;
|
import nc.vo.sm.UserVO;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 高压MES-物料新增后同步
|
* 高压MES-物料新增后同步
|
||||||
*
|
*
|
||||||
|
|
@ -42,47 +44,37 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
private static final String updateUrl = "/bip/order/materialUpdate";
|
private static final String updateUrl = "/bip/order/materialUpdate";
|
||||||
private Map<String, String> configParams;
|
private Map<String, String> configParams;
|
||||||
private BaseDAO baseDAO = new BaseDAO();
|
private BaseDAO baseDAO = new BaseDAO();
|
||||||
|
|
||||||
public void doAction(IBusinessEvent event) throws BusinessException {
|
public void doAction(IBusinessEvent event) throws BusinessException {
|
||||||
BDCommonEvent e = (BDCommonEvent) event;
|
BDCommonEvent e = (BDCommonEvent) event;
|
||||||
String eventType = event.getEventType();
|
String eventType = event.getEventType();
|
||||||
Object[] objs = e.getObjs();
|
Object[] objs = e.getObjs();
|
||||||
|
String materialid = ((MaterialStockVO) objs[0]).getPk_material();
|
||||||
|
MaterialVO[] useVOs = (MaterialVO[]) BDCacheQueryUtil.queryVOsByIDs(
|
||||||
|
MaterialVO.class,
|
||||||
|
MaterialVO.PK_MATERIAL,
|
||||||
|
new String[]{materialid},
|
||||||
|
new String[]{MaterialVO.PK_MEASDOC});
|
||||||
configParams = MyHelper.getConfigParams("gy-config", null);
|
configParams = MyHelper.getConfigParams("gy-config", null);
|
||||||
if (configParams.isEmpty()) {
|
if (configParams.isEmpty()) {
|
||||||
throw new BusinessException("高压的gymes接口缺少配置");
|
throw new BusinessException("高压的gymes接口缺少配置");
|
||||||
}
|
}
|
||||||
|
|
||||||
HYPubBO hyPub = new HYPubBO();
|
|
||||||
List<MaterialVO> voList = new ArrayList<>();
|
|
||||||
for (Object obj : objs) {
|
|
||||||
MaterialStockVO materialStockVO = (MaterialStockVO) obj;
|
|
||||||
String pkMaterial = materialStockVO.getPk_material();
|
|
||||||
String pkOrg = materialStockVO.getPk_org();
|
|
||||||
String orgCode = (String) hyPub.findColValue(OrgVO.getDefaultTableName(), OrgVO.CODE, "dr =0 and pk_org = '" + pkOrg + "' ");
|
|
||||||
// 判断物料的业务单元是否是高压公司,不是则跳过
|
|
||||||
if (checkIfOrg(orgCode, configParams)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
MaterialVO materialVO = (MaterialVO) hyPub.queryByPrimaryKey(MaterialVO.class, pkMaterial);
|
|
||||||
materialVO.setPk_org(pkOrg);
|
|
||||||
voList.add(materialVO);
|
|
||||||
}
|
|
||||||
if (!voList.isEmpty()) {
|
|
||||||
MaterialVO[] useVOs = voList.toArray(new MaterialVO[0]);
|
|
||||||
buildSyncData(useVOs, eventType);
|
buildSyncData(useVOs, eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建同步数据
|
* 构建同步数据
|
||||||
*/
|
*/
|
||||||
private void buildSyncData(MaterialVO[] useVOs, String eventType) throws BusinessException {
|
private void buildSyncData(MaterialVO[] useVOs, String eventType) throws BusinessException {
|
||||||
|
// String orgId = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE, "C046");
|
||||||
|
String pkOrg = MyHelper.getStrValByCondition("ORG_ORGS", OrgVO.PK_ORG, OrgVO.CODE + " = '" + "C046" + "'"+ " and ISBUSINESSUNIT = '" + "Y" +"'");
|
||||||
JSONArray dataArr = new JSONArray();
|
JSONArray dataArr = new JSONArray();
|
||||||
for (MaterialVO vo : useVOs) {
|
for (MaterialVO vo : useVOs) {
|
||||||
String pkMaterial = vo.getPk_material();
|
String pkMaterial = vo.getPk_material();
|
||||||
String pkOrg = vo.getPk_org();
|
// 判断物料的业务单元是否是高压公司,不是则跳过
|
||||||
|
// String pkOrg = vo.getPk_org();
|
||||||
|
Integer num = MyHelper.checkIfOrg(configParams, pkMaterial, "gyOrg");
|
||||||
|
if (!"1009".equals(eventType) && (num <= 0)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 字段值翻译
|
// 字段值翻译
|
||||||
String pk_marbasclass = vo.getPk_marbasclass();
|
String pk_marbasclass = vo.getPk_marbasclass();
|
||||||
String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.NAME,
|
String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.NAME,
|
||||||
|
|
@ -197,8 +189,8 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
logger.error("gymes-Material-res = " + result);
|
logger.error("gymes-Material-res = " + result);
|
||||||
|
|
||||||
if (!"200".equals(resultObj.getString("code"))) {
|
if (!"200".equals(resultObj.getString("code"))) {
|
||||||
|
// throw new BusinessException("gymes-Material-error:" + resultObj.getString("msg"));
|
||||||
logger.error("gymes-Material-error,result[" + resultObj.toJSONString() + "]");
|
logger.error("gymes-Material-error,result[" + resultObj.toJSONString() + "]");
|
||||||
throw new BusinessException("gymes-Material-error:" + resultObj.getString("msg"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,7 +226,7 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||||
String targetCode = configParams.get("gyOrg");
|
String targetCode = configParams.get("mesBaseUrl");
|
||||||
if (targetCode == null || StringUtils.isEmpty(targetCode)) {
|
if (targetCode == null || StringUtils.isEmpty(targetCode)) {
|
||||||
throw new BusinessException("未配置组织参数");
|
throw new BusinessException("未配置组织参数");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue