Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
8ed886eb99
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
|
|
||||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterApproveSyncEpicMesRule;
|
import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterApproveSyncEpicMesRule;
|
||||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterApprovingSynchronizeRuleRZ;
|
import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterApprovingSynchronizeRuleRZ;
|
||||||
|
import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterPmoSyncJmQMSRule;
|
||||||
import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint;
|
import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint;
|
||||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOATPUpdateRule;
|
import nc.bs.mmpac.pmo.pac0002.rule.PMOATPUpdateRule;
|
||||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOAdjustReserveRule;
|
import nc.bs.mmpac.pmo.pac0002.rule.PMOAdjustReserveRule;
|
||||||
|
|
@ -254,6 +255,8 @@ public class PMOAdjustBP {
|
||||||
processer.addAfterFinalRule(pushRZRule);
|
processer.addAfterFinalRule(pushRZRule);
|
||||||
// 变更后推送流程生产订单到艾普MES
|
// 变更后推送流程生产订单到艾普MES
|
||||||
processer.addAfterRule(new AfterApproveSyncEpicMesRule());
|
processer.addAfterRule(new AfterApproveSyncEpicMesRule());
|
||||||
|
// 变更后推送流程生产订单到启源(精密铸造)
|
||||||
|
processer.addAfterRule(new AfterPmoSyncJmQMSRule());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 挪退料建议
|
// 挪退料建议
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@ import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
import nc.bs.dao.BaseDAO;
|
import nc.bs.dao.BaseDAO;
|
||||||
import nc.bs.dao.DAOException;
|
|
||||||
import nc.bs.logging.Log;
|
import nc.bs.logging.Log;
|
||||||
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.impl.pubapp.pattern.rule.IRule;
|
import nc.impl.pubapp.pattern.rule.IRule;
|
||||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||||
import nc.jdbc.framework.processor.MapProcessor;
|
import nc.jdbc.framework.processor.MapProcessor;
|
||||||
|
import nc.util.mmf.framework.base.MMValueCheck;
|
||||||
import nc.vo.bc.pmpub.project.ProjectHeadVO;
|
import nc.vo.bc.pmpub.project.ProjectHeadVO;
|
||||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
||||||
|
|
@ -23,6 +23,7 @@ import nc.vo.pub.lang.UFDateTime;
|
||||||
import nc.vo.sm.UserVO;
|
import nc.vo.sm.UserVO;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精密-流程生产订单投放后推送QMS
|
* 精密-流程生产订单投放后推送QMS
|
||||||
|
|
@ -70,19 +71,18 @@ public class AfterPmoSyncJmQMSRule implements IRule<PMOAggVO> {
|
||||||
if (checkIfOrg(orgCode, configParams)) {
|
if (checkIfOrg(orgCode, configParams)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vo.getChildrenVO().length >=0 ){
|
|
||||||
if(vo.getChildrenVO()[0].getAttributeValue("vdef32").equals("Y")){
|
|
||||||
// continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 组装数据
|
|
||||||
JSONObject singleObj = new JSONObject();
|
|
||||||
PMOHeadVO pmoHeadVO = vo.getParentVO();
|
PMOHeadVO pmoHeadVO = vo.getParentVO();
|
||||||
PMOItemVO[] itemVOS = vo.getChildrenVO();
|
PMOItemVO[] itemVOS = vo.getChildrenVO();
|
||||||
|
|
||||||
|
// 判断单据类型,部分类型的生产订单跳过推送
|
||||||
|
String vtrantypecode = pmoHeadVO.getVtrantypecode();
|
||||||
|
if (checkBillType(vtrantypecode)) continue;
|
||||||
|
|
||||||
String sql = " select user_name from sm_user where dr = 0 and cuserid = '" + pmoHeadVO.getBillmaker() + "' ";
|
String sql = " select user_name from sm_user where dr = 0 and cuserid = '" + pmoHeadVO.getBillmaker() + "' ";
|
||||||
String billmakerName = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
|
String billmakerName = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
|
||||||
|
|
||||||
|
// 组装数据
|
||||||
|
JSONObject singleObj = new JSONObject();
|
||||||
singleObj.put("batchid", System.currentTimeMillis());
|
singleObj.put("batchid", System.currentTimeMillis());
|
||||||
singleObj.put("bipzyid", pmoHeadVO.getCpmohid());// BIP订单主键
|
singleObj.put("bipzyid", pmoHeadVO.getCpmohid());// BIP订单主键
|
||||||
singleObj.put("scdh", pmoHeadVO.getVbillcode());
|
singleObj.put("scdh", pmoHeadVO.getVbillcode());
|
||||||
|
|
@ -115,12 +115,12 @@ public class AfterPmoSyncJmQMSRule implements IRule<PMOAggVO> {
|
||||||
String wlxhgg = MyHelper.skipNull(mrlmap.get("materialspec")) + MyHelper.skipNull(mrlmap.get("materialtype"));
|
String wlxhgg = MyHelper.skipNull(mrlmap.get("materialspec")) + MyHelper.skipNull(mrlmap.get("materialtype"));
|
||||||
itemObj.put("wlxhgg", wlxhgg);// 产品型号规格
|
itemObj.put("wlxhgg", wlxhgg);// 产品型号规格
|
||||||
itemObj.put("jhsl", item.getNastnum().toString());// 计划数量,该产品的生产计划数量
|
itemObj.put("jhsl", item.getNastnum().toString());// 计划数量,该产品的生产计划数量
|
||||||
UFDateTime tplanendtime = item.getTplanendtime();
|
UFDateTime tplanendtime = item.getTplanendtime(); // 计划完工时间
|
||||||
String tplanendtimeStr = "";
|
String tplanendtimeStr = "";
|
||||||
if (tplanendtime != null) {
|
if (tplanendtime != null) {
|
||||||
tplanendtimeStr = tplanendtime.toString();
|
tplanendtimeStr = tplanendtime.toString();
|
||||||
}
|
}
|
||||||
itemObj.put("jhrq", tplanendtimeStr);// 计划数量,该产品的生产计划数量
|
itemObj.put("jhrq", tplanendtimeStr);// 计划日期,该产品的计划生产日期
|
||||||
int flag_wg = 0;
|
int flag_wg = 0;
|
||||||
int flag_jqbz = 0;
|
int flag_jqbz = 0;
|
||||||
if (fitemstatus == 2) {
|
if (fitemstatus == 2) {
|
||||||
|
|
@ -145,7 +145,6 @@ public class AfterPmoSyncJmQMSRule implements IRule<PMOAggVO> {
|
||||||
|
|
||||||
singleObj.put("Content", contentArray);
|
singleObj.put("Content", contentArray);
|
||||||
pushData(singleObj);
|
pushData(singleObj);
|
||||||
updatePmo(vo.getParentVO().getCpmohid());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,12 +169,30 @@ public class AfterPmoSyncJmQMSRule implements IRule<PMOAggVO> {
|
||||||
|
|
||||||
if (!"true".equals(resultObj.getString("success"))) {
|
if (!"true".equals(resultObj.getString("success"))) {
|
||||||
logger.error("QMS-PMO-JM-error,result[" + resultObj.toJSONString() + "]");
|
logger.error("QMS-PMO-JM-error,result[" + resultObj.toJSONString() + "]");
|
||||||
throw new BusinessException("QMS-PMO-JM-error:" + resultObj.getString("message"));
|
throw new BusinessException("启源错误信息:" + resultObj.getString("message"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断单据类型
|
||||||
|
*
|
||||||
|
* @param vtrantypecode 单据类型编码
|
||||||
|
*/
|
||||||
|
private boolean checkBillType(String vtrantypecode) {
|
||||||
|
String typeCodeStr = configParams.get("MMleixingCode");
|
||||||
|
if (MMValueCheck.isNotEmpty(typeCodeStr)) {
|
||||||
|
if (typeCodeStr.contains(",")) {
|
||||||
|
Set<String> codeSet = Set.of(typeCodeStr.split(",", -1));
|
||||||
|
return codeSet.contains(vtrantypecode);
|
||||||
|
} else {
|
||||||
|
return typeCodeStr.equals(vtrantypecode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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("xbOrg");
|
String targetCode = configParams.get("jmOrg");
|
||||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
||||||
throw new BusinessException("未配置组织参数");
|
throw new BusinessException("未配置组织参数");
|
||||||
}
|
}
|
||||||
|
|
@ -187,12 +204,5 @@ public class AfterPmoSyncJmQMSRule implements IRule<PMOAggVO> {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void updatePmo(String cpmohid) throws DAOException {
|
|
||||||
BaseDAO dao = new BaseDAO();
|
|
||||||
String sql = "update mm_mo set vdef32='Y' where cpmohid='"
|
|
||||||
+ cpmohid + "'";
|
|
||||||
dao.executeUpdate(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,299 +0,0 @@
|
||||||
//
|
|
||||||
// Source code recreated from a .class file by IntelliJ IDEA
|
|
||||||
// (powered by FernFlower decompiler)
|
|
||||||
//
|
|
||||||
|
|
||||||
package nc.bs.bd.pfxx.plugin;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
||||||
import nc.bs.dao.BaseDAO;
|
|
||||||
import nc.bs.dao.DAOException;
|
|
||||||
import nc.bs.framework.common.NCLocator;
|
|
||||||
import nc.bs.logging.Log;
|
|
||||||
import nc.bs.pfxx.ISwapContext;
|
|
||||||
import nc.bs.pfxx.plugin.AbstractPfxxPlugin;
|
|
||||||
import nc.bs.trade.business.HYPubBO;
|
|
||||||
import nc.bs.trade.business.HYSuperDMO;
|
|
||||||
import nc.bs.uapbd.util.MyHelper;
|
|
||||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
|
||||||
import nc.itf.bd.material.assign.IMaterialAssignService;
|
|
||||||
import nc.itf.bd.material.plan.IMaterialPlanQueryService;
|
|
||||||
import nc.itf.bd.material.plan.IMaterialPlanService;
|
|
||||||
import nc.jdbc.framework.processor.MapProcessor;
|
|
||||||
import nc.pubitf.uapbd.IMaterialPubService;
|
|
||||||
import nc.util.mmf.framework.base.MMValueCheck;
|
|
||||||
import nc.vo.bd.defdoc.DefdocVO;
|
|
||||||
import nc.vo.bd.errorlog.ErrLogReturnValue;
|
|
||||||
import nc.vo.bd.material.MaterialVO;
|
|
||||||
import nc.vo.bd.material.plan.MaterialPlanVO;
|
|
||||||
import nc.vo.bd.material.stock.MaterialReplVO;
|
|
||||||
import nc.vo.bd.material.stock.MaterialStockVO;
|
|
||||||
import nc.vo.pfxx.auxiliary.AggxsysregisterVO;
|
|
||||||
import nc.vo.pfxx.util.PfxxPluginUtils;
|
|
||||||
import nc.vo.pub.BusinessException;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class MaterialPlanPfxxPlugin extends AbstractPfxxPlugin {
|
|
||||||
IMaterialPlanQueryService materialplanqueryservice = null;
|
|
||||||
IMaterialPlanService materialplanservice = null;
|
|
||||||
IMaterialAssignService assignservice = null;
|
|
||||||
|
|
||||||
private static final String LOG_INFO_NAME = "qyMesLog";
|
|
||||||
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
|
|
||||||
private static final String reqUrl = "/IF_QyErpApi.ashx?action=addwlxx";
|
|
||||||
private Map<String, String> configParams;
|
|
||||||
|
|
||||||
public MaterialPlanPfxxPlugin() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Object processBill(Object vo, ISwapContext swapContext, AggxsysregisterVO aggvo) throws BusinessException {
|
|
||||||
MaterialPlanVO planvo = (MaterialPlanVO) vo;
|
|
||||||
MaterialPlanVO[] pvos = this.getMaterialPlanQueryService().queryMaterialPlanVOs(new String[]{planvo.getPk_org()}, planvo.getPk_material());
|
|
||||||
if (pvos != null && pvos.length != 0) {
|
|
||||||
planvo = this.updateMaterialPlan(pvos, planvo);
|
|
||||||
} else {
|
|
||||||
planvo = this.insertMaterialPlan(planvo);
|
|
||||||
PfxxPluginUtils.addDocIDVsPKContrast(swapContext.getBilltype(), swapContext.getDocID(), planvo.getPrimaryKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
return planvo.getPrimaryKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
private MaterialPlanVO insertMaterialPlan(MaterialPlanVO planvo) throws BusinessException {
|
|
||||||
ErrLogReturnValue value = this.getService().assignByPks(new String[]{planvo.getPk_material()}, new String[]{planvo.getPk_org()}, true);
|
|
||||||
MaterialPlanVO[] pvos = this.getMaterialPlanQueryService().queryMaterialPlanVOs(new String[]{planvo.getPk_org()}, planvo.getPk_material());
|
|
||||||
if (pvos != null && pvos.length > 0) {
|
|
||||||
planvo = this.updateMaterialPlan(pvos, planvo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return planvo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MaterialPlanVO updateMaterialPlan(MaterialPlanVO[] pvos, MaterialPlanVO planvo) throws BusinessException {
|
|
||||||
List<MaterialReplVO> list = new ArrayList();
|
|
||||||
MaterialPlanVO vo = pvos[0];
|
|
||||||
String[] attrs = planvo.getAttributeNames();
|
|
||||||
|
|
||||||
for (String attr : attrs) {
|
|
||||||
if (planvo.getAttributeValue(attr) != null && !"materialrepl".equals(attr)) {
|
|
||||||
vo.setAttributeValue(attr, planvo.getAttributeValue(attr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vo.getMaterialrepl() != null && vo.getMaterialrepl().length > 0) {
|
|
||||||
for (MaterialReplVO replvo : vo.getMaterialrepl()) {
|
|
||||||
replvo.setStatus(3);
|
|
||||||
list.add(replvo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (planvo.getMaterialrepl() != null && planvo.getMaterialrepl().length > 0) {
|
|
||||||
for (MaterialReplVO replvo : planvo.getMaterialrepl()) {
|
|
||||||
replvo.setStatus(2);
|
|
||||||
list.add(replvo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vo.setMaterialrepl((MaterialReplVO[]) list.toArray(new MaterialReplVO[0]));
|
|
||||||
vo = this.getMaterialPlanService().updateMaterialPlanVO(vo);
|
|
||||||
syncQMS(vo);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMaterialPlanQueryService getMaterialPlanQueryService() {
|
|
||||||
if (this.materialplanqueryservice == null) {
|
|
||||||
this.materialplanqueryservice = (IMaterialPlanQueryService) NCLocator.getInstance().lookup(IMaterialPlanQueryService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.materialplanqueryservice;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMaterialPlanService getMaterialPlanService() {
|
|
||||||
if (this.materialplanservice == null) {
|
|
||||||
this.materialplanservice = (IMaterialPlanService) NCLocator.getInstance().lookup(IMaterialPlanService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.materialplanservice;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMaterialAssignService getService() {
|
|
||||||
if (this.assignservice == null) {
|
|
||||||
this.assignservice = (IMaterialAssignService) NCLocator.getInstance().lookup(IMaterialAssignService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.assignservice;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void syncQMS(MaterialPlanVO planVO) throws BusinessException {
|
|
||||||
// 修改物料计划信息的接口执行之后同步修改启源物料
|
|
||||||
configParams = MyHelper.getConfigParams("jm-config", null);
|
|
||||||
buildSyncData(planVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建同步数据
|
|
||||||
*/
|
|
||||||
private void buildSyncData(MaterialPlanVO planVO) throws BusinessException {
|
|
||||||
String pkMaterial = planVO.getPk_material();
|
|
||||||
String pkOrg = planVO.getPk_org();
|
|
||||||
HYPubBO hyPub = new HYPubBO();
|
|
||||||
MaterialVO vo = (MaterialVO) hyPub.queryByPrimaryKey(MaterialVO.class, pkMaterial);
|
|
||||||
// 判断物料的业务单元是否是精密公司,不是则跳过
|
|
||||||
Integer num = MyHelper.checkIfOrg(configParams, pkMaterial, "jmOrg");
|
|
||||||
if (num <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 字段值翻译
|
|
||||||
// String pk_marbasclass = vo.getPk_marbasclass();
|
|
||||||
// String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.NAME,
|
|
||||||
// "pk_marbasclass = '" + pk_marbasclass + "'");
|
|
||||||
// 计量单位
|
|
||||||
Map unitMap = getGoodsInfo(pkMaterial);
|
|
||||||
// 启源物料编码
|
|
||||||
Map<String, MaterialPlanVO> planMap = queryMaterialPlanInfoByPks(new String[]{pkMaterial}, pkOrg,
|
|
||||||
new String[]{MaterialPlanVO.DEF2});
|
|
||||||
// 计划信息自定义项2(原系统编码)BIP传启源物料档案的物料编码,BIP中物料编码传启源自定义字段“BIP物料编码”
|
|
||||||
String qyCode = "";
|
|
||||||
if (MMValueCheck.isNotEmpty(planMap) &&
|
|
||||||
MMValueCheck.isNotEmpty(planMap.get(pkMaterial))) {
|
|
||||||
qyCode = planMap.get(pkMaterial).getDef2();
|
|
||||||
} else {
|
|
||||||
qyCode = vo.getCode();
|
|
||||||
}
|
|
||||||
// 1=未启用;2=已启用;3=已停用;
|
|
||||||
Integer enablestate = vo.getEnablestate();
|
|
||||||
String statusCode = (3 == enablestate) ? "1" : "0";
|
|
||||||
Map<String, Object> stockMap = MyHelper.getMapValByCondition(MaterialStockVO.getDefaultTableName(), "def3,def4,martype",
|
|
||||||
MaterialStockVO.PK_MATERIAL + " = '" + pkMaterial + "' and pk_org = '" + pkOrg + "'");
|
|
||||||
// 制造件传启源
|
|
||||||
if (!"MR".equals(stockMap.get("martype"))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 物料标志和产品分类字段在库存信息页签中,分配物料的时候没有默认值,需要在此处设置
|
|
||||||
// 物料标志
|
|
||||||
String wlbz = "产品";
|
|
||||||
String wlbzId = stockMap.get("def3") + "";
|
|
||||||
String defName = getDefName("zdy-jmzz001", wlbzId);
|
|
||||||
if (MMValueCheck.isNotEmpty(defName)) {
|
|
||||||
wlbz = defName;
|
|
||||||
}
|
|
||||||
// 产品分类
|
|
||||||
String cpfl;
|
|
||||||
String cpflId = stockMap.get("def4") + "";
|
|
||||||
String defName1 = getDefName("zdy-jmzz002", cpflId);
|
|
||||||
if (MMValueCheck.isEmpty(defName1)) {
|
|
||||||
return;// 缺少产品分类则跳过同步启源
|
|
||||||
}
|
|
||||||
cpfl = defName1;
|
|
||||||
// 组装数据
|
|
||||||
JSONObject singleObj = new JSONObject();
|
|
||||||
// 批次编号,用于唯一标识当前传输的物料数据批次,便于追溯和批量处理
|
|
||||||
long cts = System.currentTimeMillis();
|
|
||||||
singleObj.put("batchid", cts);
|
|
||||||
JSONObject contentObj = new JSONObject();
|
|
||||||
contentObj.put("meswlbh", qyCode); // 启源物料编码
|
|
||||||
contentObj.put("bipwlbh", vo.getCode()); // BIP物料编码
|
|
||||||
contentObj.put("wlmc", vo.getName()); // 物料名称
|
|
||||||
String wlxhgg = MyHelper.skipNull(vo.getMaterialtype()) + MyHelper.skipNull(vo.getMaterialspec());
|
|
||||||
contentObj.put("wlxhgg", wlxhgg); // 物料型号规格
|
|
||||||
contentObj.put("wlfl", ""); // 物料分类
|
|
||||||
contentObj.put("cpfl", cpfl); // 产品分类
|
|
||||||
contentObj.put("wlbz", wlbz); // 物料标志
|
|
||||||
contentObj.put("sjjldw", unitMap.get("unitname")); // 设计计量单位
|
|
||||||
contentObj.put("cgjldw", unitMap.get("deputy_unitname")); // 采购计量单位
|
|
||||||
contentObj.put("zhxs", unitMap.getOrDefault("convertRate", "1.00")); // 转换系数
|
|
||||||
contentObj.put("flag_fq", statusCode); // 1/0 传递1代表物料废弃
|
|
||||||
contentObj.put("bz", vo.getMemo()); // 备注信息
|
|
||||||
JSONArray contentArr = new JSONArray();
|
|
||||||
contentArr.add(contentObj);
|
|
||||||
singleObj.put("Content", contentArr);
|
|
||||||
pushData(singleObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 推送同步数据
|
|
||||||
*/
|
|
||||||
private void pushData(JSONObject param) throws BusinessException {
|
|
||||||
// String jsonString = param.toJSONString();
|
|
||||||
// 转json字符串的时候保留null值
|
|
||||||
String jsonStr = JSON.toJSONString(param,
|
|
||||||
SerializerFeature.WriteMapNullValue,
|
|
||||||
SerializerFeature.WriteNullStringAsEmpty
|
|
||||||
);
|
|
||||||
logger.error("QMS-Material-param = " + jsonStr);
|
|
||||||
// NCCForUAPLogger.debug("QMS-Material-param = " + jsonStr);
|
|
||||||
String baseUrl = configParams.get("qmsBaseUrl");
|
|
||||||
String requestUrl = baseUrl + reqUrl;
|
|
||||||
logger.error("QMS-Material-url = " + requestUrl);
|
|
||||||
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
|
|
||||||
JSONObject resultObj = JSONObject.parseObject(result);
|
|
||||||
logger.error("QMS-Material-res = " + result);
|
|
||||||
|
|
||||||
if (!"true".equals(resultObj.getString("success"))) {
|
|
||||||
logger.error("QMS-Material-error,result[" + resultObj.toJSONString() + "]");
|
|
||||||
throw new BusinessException("QMS-Material-error:" + resultObj.getString("message"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map getGoodsInfo(String pkMaterial) throws BusinessException {
|
|
||||||
String sql = " select a.pk_measdoc, c.name unitname, b.pk_measdoc deputyUnit, d.name deputy_unitname, nvl(b.measrate, '1/1') measrate " +
|
|
||||||
"from bd_material a " +
|
|
||||||
"left join bd_materialconvert b on a.pk_material = b.pk_material " +
|
|
||||||
"left join bd_measdoc c on a.pk_measdoc = c.pk_measdoc " +
|
|
||||||
"left join bd_measdoc d on b.pk_measdoc = d.pk_measdoc " +
|
|
||||||
"where a.pk_material = '" + pkMaterial + "' ";
|
|
||||||
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
|
||||||
map.put("convertRate", MyHelper.transferSpecialField(map.get("measrate") + ""));
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
|
||||||
String targetCode = configParams.get("jmOrg");
|
|
||||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
|
||||||
throw new BusinessException("未配置组织参数");
|
|
||||||
}
|
|
||||||
String[] orgItem = targetCode.split(",");
|
|
||||||
for (String orgCode : orgItem) {
|
|
||||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, MaterialPlanVO> queryMaterialPlanInfoByPks(String[] pks, String pk_stockorg,
|
|
||||||
String[] fields) throws BusinessException {
|
|
||||||
Map<String, MaterialPlanVO> map = null;
|
|
||||||
List<String> vids = Stream.of(pks).filter(Objects::nonNull).distinct().toList();
|
|
||||||
if (vids.isEmpty()) {
|
|
||||||
map = new HashMap<>();
|
|
||||||
} else {
|
|
||||||
map = NCLocator.getInstance().lookup(IMaterialPubService.class)
|
|
||||||
.queryMaterialPlanInfoByPks(vids.toArray(new String[0]), pk_stockorg, fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取自定义项信息
|
|
||||||
*/
|
|
||||||
private String getDefName(String code, String pk_defdoc) {
|
|
||||||
String res = "";
|
|
||||||
String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='" + code + "' and dr=0 ) and dr = 0 and pk_defdoc = '" + pk_defdoc + "'";
|
|
||||||
try {
|
|
||||||
DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
|
|
||||||
if (defdocVOs != null && defdocVOs.length > 0) {
|
|
||||||
res = defdocVOs[0].getName().trim();
|
|
||||||
}
|
|
||||||
} catch (DAOException e) {
|
|
||||||
logger.error("gyMes-SaleOrder-error,getDefName[" + e.getMessage() + "]");
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -42,6 +42,7 @@ 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();
|
||||||
|
private String orgId = "";
|
||||||
|
|
||||||
public void doAction(IBusinessEvent event) throws BusinessException {
|
public void doAction(IBusinessEvent event) throws BusinessException {
|
||||||
BDCommonEvent e = (BDCommonEvent) event;
|
BDCommonEvent e = (BDCommonEvent) event;
|
||||||
|
|
@ -52,7 +53,7 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
if (configParams.isEmpty()) {
|
if (configParams.isEmpty()) {
|
||||||
throw new BusinessException("¸ßѹµÄgymes½Ó¿ÚȱÉÙÅäÖÃ");
|
throw new BusinessException("¸ßѹµÄgymes½Ó¿ÚȱÉÙÅäÖÃ");
|
||||||
}
|
}
|
||||||
|
orgId = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE + " = 'C046' and ISBUSINESSUNIT = 'Y'");
|
||||||
HYPubBO hyPub = new HYPubBO();
|
HYPubBO hyPub = new HYPubBO();
|
||||||
List<MaterialVO> voList = new ArrayList<>();
|
List<MaterialVO> voList = new ArrayList<>();
|
||||||
for (Object obj : objs) {
|
for (Object obj : objs) {
|
||||||
|
|
@ -217,7 +218,7 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
private Map getStockInfo(String pkMaterial) throws BusinessException {
|
private Map getStockInfo(String pkMaterial) throws BusinessException {
|
||||||
String sql = " select martype, wholemanaflag, outpriority, remain,bd_stordoc.code as pk_stordoc" +
|
String sql = " select martype, wholemanaflag, outpriority, remain,bd_stordoc.code as pk_stordoc" +
|
||||||
" from bd_materialstock left join bd_stordoc on bd_stordoc.pk_stordoc = bd_materialstock.pk_stordoc " +
|
" from bd_materialstock left join bd_stordoc on bd_stordoc.pk_stordoc = bd_materialstock.pk_stordoc " +
|
||||||
" where pk_material = '" + pkMaterial + "' ";
|
" where pk_material = '" + pkMaterial + "' " + " and bd_materialstock.pk_org = '" + orgId + "' ";
|
||||||
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
@ -228,7 +229,7 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
"FROM " +
|
"FROM " +
|
||||||
" bd_materialprod a" +
|
" bd_materialprod a" +
|
||||||
" left join org_dept b on a.pk_prodeptdoc = b.pk_dept " +
|
" left join org_dept b on a.pk_prodeptdoc = b.pk_dept " +
|
||||||
" where a.pk_material = '" + pkMaterial + "' ";
|
" where a.pk_material = '" + pkMaterial + "' " + " and a.pk_org = '" + orgId + "' ";
|
||||||
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,14 +51,17 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
BDCommonEvent e = (BDCommonEvent) event;
|
BDCommonEvent e = (BDCommonEvent) event;
|
||||||
String eventType = event.getEventType();
|
String eventType = event.getEventType();
|
||||||
Object[] objs = e.getObjs();
|
Object[] objs = e.getObjs();
|
||||||
|
if (objs == null || objs.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
configParams = MyHelper.getConfigParams("gy-config", null);
|
||||||
|
if (configParams.isEmpty()) {
|
||||||
|
throw new BusinessException("¸ßѹµÄgymes½Ó¿ÚȱÉÙÅäÖÃ");
|
||||||
|
}
|
||||||
|
orgId = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE + " = 'C046' and ISBUSINESSUNIT = 'Y'");
|
||||||
HYPubBO hyPub = new HYPubBO();
|
HYPubBO hyPub = new HYPubBO();
|
||||||
// EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后
|
// EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后
|
||||||
if ("1004".equals(eventType) || "1071".equals(eventType) || "1069".equals(eventType)) {
|
if ("1004".equals(eventType) || "1071".equals(eventType) || "1069".equals(eventType)) {
|
||||||
configParams = MyHelper.getConfigParams("gy-config", null);
|
|
||||||
if (configParams.isEmpty()) {
|
|
||||||
throw new BusinessException("高压的gymes接口缺少配置");
|
|
||||||
}
|
|
||||||
orgId = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE + " = 'C046' and ISBUSINESSUNIT = 'Y'");
|
|
||||||
List<MaterialVO> list = new ArrayList<>();
|
List<MaterialVO> list = new ArrayList<>();
|
||||||
if (objs instanceof MaterialStockVO[]) {
|
if (objs instanceof MaterialStockVO[]) {
|
||||||
// 库存信息修改后
|
// 库存信息修改后
|
||||||
|
|
@ -88,11 +91,6 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
}
|
}
|
||||||
} else if ("1009".equals(eventType)) {
|
} else if ("1009".equals(eventType)) {
|
||||||
// 物料可见性范围-分配后 1009
|
// 物料可见性范围-分配后 1009
|
||||||
configParams = MyHelper.getConfigParams("gy-config", null);
|
|
||||||
if (configParams.isEmpty()) {
|
|
||||||
throw new BusinessException("高压的gymes接口缺少配置");
|
|
||||||
}
|
|
||||||
orgId = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE + " = 'C046' and ISBUSINESSUNIT = 'Y'");
|
|
||||||
List<MaterialVO> voList = new ArrayList<>();
|
List<MaterialVO> voList = new ArrayList<>();
|
||||||
for (Object obj : objs) {
|
for (Object obj : objs) {
|
||||||
MultiOrgAssignVO vo = (MultiOrgAssignVO) obj;
|
MultiOrgAssignVO vo = (MultiOrgAssignVO) obj;
|
||||||
|
|
@ -242,7 +240,7 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
/**
|
/**
|
||||||
* 处理物料VO的通用方法
|
* 处理物料VO的通用方法
|
||||||
*/
|
*/
|
||||||
private <T> void processMaterialChange(Object[] objs, List<MaterialVO> list) throws BusinessException {
|
private void processMaterialChange(Object[] objs, List<MaterialVO> list) throws BusinessException {
|
||||||
HYPubBO hyPub = new HYPubBO();
|
HYPubBO hyPub = new HYPubBO();
|
||||||
for (Object newVO : objs) {
|
for (Object newVO : objs) {
|
||||||
String pk_material = getPkMaterialFromVO(newVO);
|
String pk_material = getPkMaterialFromVO(newVO);
|
||||||
|
|
@ -302,7 +300,7 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
private Map getStockInfo(String pkMaterial) throws BusinessException {
|
private Map getStockInfo(String pkMaterial) throws BusinessException {
|
||||||
String sql = " select martype, wholemanaflag, outpriority, remain,bd_stordoc.code as pk_stordoc" +
|
String sql = " select martype, wholemanaflag, outpriority, remain,bd_stordoc.code as pk_stordoc" +
|
||||||
" from bd_materialstock left join bd_stordoc on bd_stordoc.pk_stordoc = bd_materialstock.pk_stordoc " +
|
" from bd_materialstock left join bd_stordoc on bd_stordoc.pk_stordoc = bd_materialstock.pk_stordoc " +
|
||||||
" where pk_material = '" + pkMaterial + "' ";
|
" where pk_material = '" + pkMaterial + "' " + " and bd_materialstock.pk_org = '" + orgId + "' ";
|
||||||
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
@ -313,7 +311,7 @@ public class MaterialToGyMesListener implements IBusinessListener {
|
||||||
"FROM " +
|
"FROM " +
|
||||||
" bd_materialprod a" +
|
" bd_materialprod a" +
|
||||||
" left join org_dept b on a.pk_prodeptdoc = b.pk_dept " +
|
" left join org_dept b on a.pk_prodeptdoc = b.pk_dept " +
|
||||||
" where a.pk_material = '" + pkMaterial + "' ";
|
" where a.pk_material = '" + pkMaterial + "' " + " and a.pk_org = '" + orgId + "' ";
|
||||||
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import nc.util.mmf.framework.base.MMValueCheck;
|
||||||
import nc.vo.bd.defdoc.DefdocVO;
|
import nc.vo.bd.defdoc.DefdocVO;
|
||||||
import nc.vo.bd.material.MaterialVO;
|
import nc.vo.bd.material.MaterialVO;
|
||||||
import nc.vo.bd.material.plan.MaterialPlanVO;
|
import nc.vo.bd.material.plan.MaterialPlanVO;
|
||||||
|
import nc.vo.bd.material.prod.MaterialProdVO;
|
||||||
import nc.vo.bd.material.stock.MaterialStockVO;
|
import nc.vo.bd.material.stock.MaterialStockVO;
|
||||||
import nc.vo.org.OrgVO;
|
import nc.vo.org.OrgVO;
|
||||||
import nc.vo.pub.BusinessException;
|
import nc.vo.pub.BusinessException;
|
||||||
|
|
@ -41,58 +42,50 @@ public class MaterialToJmQmsListener implements IBusinessListener {
|
||||||
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
|
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
|
||||||
private static final String reqUrl = "/IF_QyErpApi.ashx?action=addwlxx";
|
private static final String reqUrl = "/IF_QyErpApi.ashx?action=addwlxx";
|
||||||
private Map<String, String> configParams;
|
private Map<String, String> configParams;
|
||||||
|
private String pkOrg1 = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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();
|
||||||
|
if (objs == null || objs.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
configParams = MyHelper.getConfigParams("jm-config", null);
|
||||||
|
if (configParams.isEmpty()) {
|
||||||
|
throw new BusinessException("精密的QMS接口缺少配置");
|
||||||
|
}
|
||||||
|
pkOrg1 = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE + " = 'C038' and ISBUSINESSUNIT = 'Y'");
|
||||||
HYPubBO hyPub = new HYPubBO();
|
HYPubBO hyPub = new HYPubBO();
|
||||||
// EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后 MaterialStockVO
|
// EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后
|
||||||
if ("1004".equals(eventType) || "1071".equals(eventType) || "1069".equals(eventType)) {
|
if ("1004".equals(eventType) || "1071".equals(eventType) || "1069".equals(eventType)) {
|
||||||
MaterialVO[] useVOs = null;
|
List<MaterialVO> list = new ArrayList<>();
|
||||||
if (objs == null) {
|
if (objs instanceof MaterialVO[]) {
|
||||||
return;
|
// 基本信息修改后/停用启用
|
||||||
} else if (objs instanceof MaterialVO[]) {
|
MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
|
||||||
useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class);
|
for (MaterialVO materialVO : useVOs) {
|
||||||
|
String pkMaterial = materialVO.getPk_material();
|
||||||
|
// 如果修改基本信息,判断物料所属组织中是否存在精密铸造,不存在则跳过
|
||||||
|
Integer num = MyHelper.checkIfOrg(configParams, pkMaterial, "jmOrg");
|
||||||
|
if (num <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.add(materialVO);
|
||||||
|
}
|
||||||
} else if (objs instanceof MaterialStockVO[]) {
|
} else if (objs instanceof MaterialStockVO[]) {
|
||||||
List<MaterialVO> list = new ArrayList<>();
|
|
||||||
// 库存信息修改
|
// 库存信息修改
|
||||||
MaterialStockVO[] materialStockVOS = ArrayClassConvertUtil.convert(objs, MaterialStockVO.class);
|
processMaterialChange(objs, list);
|
||||||
for (MaterialStockVO stockVO : materialStockVOS) {
|
|
||||||
String pkMaterial = stockVO.getPk_material();
|
|
||||||
if (MMValueCheck.isEmpty(pkMaterial)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
MaterialVO materialVO = (MaterialVO) hyPub.queryByPrimaryKey(MaterialVO.class, pkMaterial);
|
|
||||||
list.add(materialVO);
|
|
||||||
}
|
|
||||||
useVOs = list.toArray(new MaterialVO[0]);
|
|
||||||
} else if (objs instanceof MaterialPlanVO[]) {
|
} else if (objs instanceof MaterialPlanVO[]) {
|
||||||
List<MaterialVO> list = new ArrayList<>();
|
|
||||||
// 计划信息修改
|
// 计划信息修改
|
||||||
MaterialPlanVO[] planVOS = ArrayClassConvertUtil.convert(objs, MaterialPlanVO.class);
|
processMaterialChange(objs, list);
|
||||||
for (MaterialPlanVO planVO : planVOS) {
|
|
||||||
String pkMaterial = planVO.getPk_material();
|
|
||||||
if (MMValueCheck.isEmpty(pkMaterial)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
MaterialVO materialVO = (MaterialVO) hyPub.queryByPrimaryKey(MaterialVO.class, pkMaterial);
|
|
||||||
list.add(materialVO);
|
|
||||||
}
|
|
||||||
useVOs = list.toArray(new MaterialVO[0]);
|
|
||||||
}
|
}
|
||||||
configParams = MyHelper.getConfigParams("jm-config", null);
|
if (!list.isEmpty()) {
|
||||||
if (configParams.isEmpty()) {
|
MaterialVO[] useVOs = list.toArray(new MaterialVO[0]);
|
||||||
throw new BusinessException("精密的QMS接口缺少配置");
|
buildSyncData(useVOs, eventType);
|
||||||
}
|
}
|
||||||
buildSyncData(useVOs, eventType);
|
|
||||||
} else if ("1009".equals(eventType)) {
|
} else if ("1009".equals(eventType)) {
|
||||||
// 物料可见性范围-分配后 1009
|
// 物料可见性范围-分配后 1009
|
||||||
configParams = MyHelper.getConfigParams("jm-config", null);
|
|
||||||
if (configParams.isEmpty()) {
|
|
||||||
throw new BusinessException("精密的QMS接口缺少配置");
|
|
||||||
}
|
|
||||||
List<MaterialVO> voList = new ArrayList<>();
|
List<MaterialVO> voList = new ArrayList<>();
|
||||||
for (Object obj : objs) {
|
for (Object obj : objs) {
|
||||||
MultiOrgAssignVO vo = (MultiOrgAssignVO) obj;
|
MultiOrgAssignVO vo = (MultiOrgAssignVO) obj;
|
||||||
|
|
@ -119,19 +112,8 @@ public class MaterialToJmQmsListener implements IBusinessListener {
|
||||||
*/
|
*/
|
||||||
private void buildSyncData(MaterialVO[] useVOs, String eventType) throws BusinessException {
|
private void buildSyncData(MaterialVO[] useVOs, String eventType) throws BusinessException {
|
||||||
for (MaterialVO vo : useVOs) {
|
for (MaterialVO vo : useVOs) {
|
||||||
// 判断物料的业务单元是否是精密公司,不是则跳过
|
|
||||||
String pkOrg = vo.getPk_org();
|
|
||||||
String pkMaterial = vo.getPk_material();
|
String pkMaterial = vo.getPk_material();
|
||||||
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
|
||||||
String pkOrg1 = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE, "C038");
|
|
||||||
Integer num = MyHelper.checkIfOrg(configParams, pkMaterial, "jmOrg");
|
|
||||||
if (!"1009".equals(eventType) && ((num <= 0))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 字段值翻译
|
// 字段值翻译
|
||||||
// String pk_marbasclass = vo.getPk_marbasclass();
|
|
||||||
// String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.NAME,
|
|
||||||
// "pk_marbasclass = '" + pk_marbasclass + "'");
|
|
||||||
// 计量单位
|
// 计量单位
|
||||||
Map unitMap = getGoodsInfo(pkMaterial);
|
Map unitMap = getGoodsInfo(pkMaterial);
|
||||||
Map<String, MaterialPlanVO> planMap = queryMaterialPlanInfoByPks(new String[]{pkMaterial}, pkOrg1,
|
Map<String, MaterialPlanVO> planMap = queryMaterialPlanInfoByPks(new String[]{pkMaterial}, pkOrg1,
|
||||||
|
|
@ -188,28 +170,15 @@ public class MaterialToJmQmsListener implements IBusinessListener {
|
||||||
contentObj.put("zhxs", unitMap.getOrDefault("convertRate", "1.00")); // 转换系数
|
contentObj.put("zhxs", unitMap.getOrDefault("convertRate", "1.00")); // 转换系数
|
||||||
contentObj.put("flag_fq", statusCode); // 1/0 传递1代表物料废弃
|
contentObj.put("flag_fq", statusCode); // 1/0 传递1代表物料废弃
|
||||||
contentObj.put("bz", vo.getMemo()); // 备注信息
|
contentObj.put("bz", vo.getMemo()); // 备注信息
|
||||||
|
contentObj.put("djzl", vo.getDef28()); // 单台重量(净重)
|
||||||
|
contentObj.put("djzl_mz", vo.getDef27()); // 单件重量(毛重)
|
||||||
|
contentObj.put("jmkzl_bkhs", vo.getDef32()); // 不可回收浇冒口重量
|
||||||
|
contentObj.put("jmkzl_khs", vo.getDef33()); // 可回收浇冒口重量
|
||||||
|
contentObj.put("lxzl", vo.getDef31()); // 铝屑重量
|
||||||
|
contentObj.put("cz", vo.getDef5()); // 材质
|
||||||
JSONArray contentArr = new JSONArray();
|
JSONArray contentArr = new JSONArray();
|
||||||
contentArr.add(contentObj);
|
contentArr.add(contentObj);
|
||||||
singleObj.put("Content", contentArr);
|
singleObj.put("Content", contentArr);
|
||||||
/*
|
|
||||||
{
|
|
||||||
"batchid": "10001",
|
|
||||||
"Content": [
|
|
||||||
{
|
|
||||||
"meswlbh": "ACC26711", 启源物料编码
|
|
||||||
"bipwlbh": "ACC26711", BIP物料编码
|
|
||||||
"wlmc": "铜排",物料名称
|
|
||||||
"wlxhgg": "15558190831", 物料型号规格
|
|
||||||
"wlfl": "铜排", 物料分类
|
|
||||||
"cpfl": "", 如果物料是产品需要填写产品分类
|
|
||||||
"sjjldw": "根", 设计计量单位
|
|
||||||
"cgjldw": "KG", 采购计量单位
|
|
||||||
"zhxs": "6", 转换系数,用于实物单位与采购单位的换算(即 1 根铜排的长度为 6.00 米),精确到两位小数,提升换算准确性
|
|
||||||
"bz": "备注" 备注信息
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
pushData(singleObj);
|
pushData(singleObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -251,6 +220,54 @@ public class MaterialToJmQmsListener implements IBusinessListener {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理物料VO的通用方法
|
||||||
|
*/
|
||||||
|
private void processMaterialChange(Object[] objs, List<MaterialVO> list) throws BusinessException {
|
||||||
|
HYPubBO hyPub = new HYPubBO();
|
||||||
|
for (Object newVO : objs) {
|
||||||
|
String pk_material = getPkMaterialFromVO(newVO);
|
||||||
|
if (MMValueCheck.isEmpty(pk_material)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String pkOrg = getPkOrgFromVO(newVO);
|
||||||
|
// 判断各个页签修改信息是否属于精密铸造
|
||||||
|
if (MMValueCheck.isNotEmpty(pkOrg1) && !pkOrg1.equals(pkOrg)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MaterialVO materialVO = (MaterialVO) hyPub.queryByPrimaryKey(MaterialVO.class, pk_material);
|
||||||
|
list.add(materialVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从不同类型的VO中获取pk_material
|
||||||
|
*/
|
||||||
|
private String getPkMaterialFromVO(Object vo) {
|
||||||
|
if (vo instanceof MaterialStockVO newVo) {
|
||||||
|
return newVo.getPk_material();
|
||||||
|
} else if (vo instanceof MaterialPlanVO newVo) {
|
||||||
|
return newVo.getPk_material();
|
||||||
|
} else if (vo instanceof MaterialProdVO) {
|
||||||
|
return ((MaterialProdVO) vo).getPk_material();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从不同类型的VO中获取pk_org
|
||||||
|
*/
|
||||||
|
private String getPkOrgFromVO(Object vo) {
|
||||||
|
if (vo instanceof MaterialStockVO) {
|
||||||
|
return ((MaterialStockVO) vo).getPk_org();
|
||||||
|
} else if (vo instanceof MaterialPlanVO) {
|
||||||
|
return ((MaterialPlanVO) vo).getPk_org();
|
||||||
|
} else if (vo instanceof MaterialProdVO) {
|
||||||
|
return ((MaterialProdVO) vo).getPk_org();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
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("jmOrg");
|
String targetCode = configParams.get("jmOrg");
|
||||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,7 @@ public class MyHelper {
|
||||||
DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
|
DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
|
||||||
if (defdocVOs != null) {
|
if (defdocVOs != null) {
|
||||||
for (DefdocVO defdocVO : defdocVOs) {
|
for (DefdocVO defdocVO : defdocVOs) {
|
||||||
String value = StringUtils.isEmpty(defdocVO.getMemo()) ? defdocVO.getName() : defdocVO.getMemo();
|
map.put(defdocVO.getCode().trim(), defdocVO.getName());
|
||||||
map.put(defdocVO.getCode().trim(), value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DAOException e) {
|
} catch (DAOException e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue