流程生产订单审批后推送高压MES
This commit is contained in:
parent
cffbf2577d
commit
05c0570c0f
|
@ -56,11 +56,12 @@ public class PMOApproveBP {
|
||||||
// 审批后推送流程生产订单到艾普MES
|
// 审批后推送流程生产订单到艾普MES
|
||||||
processer.addAfterRule(new AfterApproveSyncEpicMesRule());
|
processer.addAfterRule(new AfterApproveSyncEpicMesRule());
|
||||||
|
|
||||||
// 审批后推送流程生产订单到PLM
|
|
||||||
processer.addAfterRule(new AfterApproveSyncPLMRule());
|
|
||||||
|
|
||||||
// 审批后推送流程生产订单到启源qms
|
// 审批后推送流程生产订单到启源qms
|
||||||
processer.addAfterRule(new AfterApproveSyncEpicQMSRule());
|
processer.addAfterRule(new AfterApproveSyncEpicQMSRule());
|
||||||
|
// 流程生产订单审批后推送高压MES
|
||||||
|
processer.addAfterRule(new AfterApproveSyncHighpressureMesRule());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,235 @@
|
||||||
|
package nc.bs.mmpac.pmo.pac0002.bp.rule;
|
||||||
|
|
||||||
|
|
||||||
|
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.logging.Log;
|
||||||
|
import nc.bs.mmpac.pmo.pac0002.bp.rule.util.SyncEpicMesUtil;
|
||||||
|
import nc.bs.trade.business.HYPubBO;
|
||||||
|
import nc.bs.uapbd.util.MyHelper;
|
||||||
|
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
||||||
|
import nc.impl.pubapp.pattern.rule.IRule;
|
||||||
|
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||||
|
import nc.jdbc.framework.processor.MapProcessor;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||||
|
import nc.vo.org.OrgVO;
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||||
|
import nc.vo.scmpub.util.ArrayUtil;
|
||||||
|
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程生产订单审批后推送高压MES
|
||||||
|
*
|
||||||
|
* @author lihao
|
||||||
|
* @date 2025/9/1
|
||||||
|
*/
|
||||||
|
public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
||||||
|
|
||||||
|
private static final String LOG_INFO_NAME = "dldzlog";
|
||||||
|
|
||||||
|
private static final Log logDl = Log.getInstance(LOG_INFO_NAME);
|
||||||
|
private Map<String, String> configParams;
|
||||||
|
@Override
|
||||||
|
public void process(PMOAggVO[] pmoAggVOS) {
|
||||||
|
if (ArrayUtil.isEmpty(pmoAggVOS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
configParams = MyHelper.getConfigParams("xb-config", null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
buildSyncData(pmoAggVOS);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logDl.error("同步生产订单到高压MES系统失败: " + e.getMessage(), e);
|
||||||
|
ExceptionUtils.wrappException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 构建同步数据
|
||||||
|
*/
|
||||||
|
private void buildSyncData(PMOAggVO[] useVOs) throws BusinessException {
|
||||||
|
BaseDAO baseDAO = new BaseDAO();
|
||||||
|
|
||||||
|
HYPubBO hybo = new HYPubBO();
|
||||||
|
for (PMOAggVO vo : useVOs) {
|
||||||
|
// 判断物料的业务单元是否是箱变公司,不是则跳过
|
||||||
|
String pkOrg = vo.getParentVO().getPk_org();
|
||||||
|
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||||
|
if (checkIfOrg(orgCode, configParams)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
JSONObject singleObj = new JSONObject();
|
||||||
|
PMOHeadVO pmoHeadVO = vo.getParentVO();
|
||||||
|
PMOItemVO[] itemVOS = vo.getChildrenVO();
|
||||||
|
|
||||||
|
singleObj.put("bipProcessProductionOrderId", pmoHeadVO.getVbillcode());
|
||||||
|
singleObj.put("bipId", pmoHeadVO.getCpmohid());// 主键ID
|
||||||
|
// singleObj.put("orderQuantity", pmoHeadVO.getPlanQuantity()); // 订单数量(计划数量)
|
||||||
|
singleObj.put("billDate", pmoHeadVO.getDbilldate()); // 单据日期
|
||||||
|
singleObj.put("orderVersion", pmoHeadVO.getVersion()); // 版本号
|
||||||
|
singleObj.put("orderTranType", pmoHeadVO.getVtrantypecode()); // 订单交易类型
|
||||||
|
singleObj.put("bipCreateBy", pmoHeadVO.getCreator()); // 创建人ID
|
||||||
|
|
||||||
|
// 创建子项数组
|
||||||
|
JSONArray contentArray = new JSONArray();
|
||||||
|
for (PMOItemVO item : itemVOS) {
|
||||||
|
JSONObject itemObj = new JSONObject();
|
||||||
|
|
||||||
|
// 填充子项基础信息
|
||||||
|
|
||||||
|
String sql = " select pk_defdoclist from bd_defdoclist where code='zdy-001' and dr=0 ";
|
||||||
|
String o = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
|
||||||
|
|
||||||
|
Object contractNum = hybo.findColValue("bd_defdoc", "code", " (pk_defdoclist = '" + o + "' and pk_defdoc='" + item.getVdef1() + "') ");
|
||||||
|
|
||||||
|
itemObj.put("contractNum", contractNum); // 合同编号
|
||||||
|
Object pk_project = hybo.findColValue("bd_project", "project_name", " pk_project = '" + item.getCprojectid() + "' ");
|
||||||
|
|
||||||
|
itemObj.put("entryName", pk_project); // 项目名称
|
||||||
|
itemObj.put("bipChildId", item.getCmoid()); // 子项主键ID
|
||||||
|
|
||||||
|
// 部门信息
|
||||||
|
|
||||||
|
|
||||||
|
String deptsql = " select code,name from org_dept where pk_dept='"+item.getCdeptid()+"' and dr=0 ";
|
||||||
|
Map<String, Object> tr = (Map<String, Object>) baseDAO.executeQuery(deptsql, new MapProcessor());
|
||||||
|
itemObj.put("bipDeptName", tr.get("name")); // 生产部门名称
|
||||||
|
itemObj.put("bipDeptId", tr.get("code")); // 生产部门编码
|
||||||
|
|
||||||
|
// 日期信息
|
||||||
|
itemObj.put("requiredDate", item.getTrequiredate()); // 需用日期
|
||||||
|
|
||||||
|
itemObj.put("bipParentProcessProductionOrderId", item.getVparentbillcode());
|
||||||
|
itemObj.put("bipParentProcessProductionOrderRowNum", item.getVparentmorowno());
|
||||||
|
itemObj.put("bipOriginProcessProductionOrderId", item.getVsrccode());
|
||||||
|
itemObj.put("bipOriginProcessProductionOrderRowNum", item.getVsrcrowno());
|
||||||
|
|
||||||
|
// 物料信息
|
||||||
|
String mrlsql = "select code,name,graphid,pk_measdoc from bd_material where pk_material = '" + item.getCmaterialvid() + "' ";
|
||||||
|
Map<String, Object> mrl = (Map<String, Object>) baseDAO.executeQuery(mrlsql, new MapProcessor());
|
||||||
|
itemObj.put("materialCode", mrl.get("code")); // 物料编码
|
||||||
|
itemObj.put("materialName",mrl.get("name")); // 物料名称
|
||||||
|
itemObj.put("drawingNumber",mrl.get("graphid")); // 图号编码 graphid
|
||||||
|
|
||||||
|
Object unit = hybo.findColValue("bd_measdoc", "code", " pk_measdoc = '" +mrl.get("pk_measdoc") + "' ");
|
||||||
|
|
||||||
|
itemObj.put("unit", unit); // 单位 pk_measdoc
|
||||||
|
|
||||||
|
// 生产信息
|
||||||
|
// itemObj.put("intervalModel", item.getCmaterialvid()); // 产品类型 物料分类
|
||||||
|
itemObj.put("processCode", item.getProcedures()); // 工序编码
|
||||||
|
itemObj.put("lineNumber", String.valueOf(item.getVrowno())); // 行号
|
||||||
|
|
||||||
|
// 库存信息
|
||||||
|
itemObj.put("demandInventoryOrganization", item.getCrequireorg()); // 需求库存组织
|
||||||
|
itemObj.put("plannedInputQuantity", item.getNplanputastnum()); // 计划投入量
|
||||||
|
itemObj.put("plannedOutputQuantity", item.getNmmastnum()); // 计划产出量
|
||||||
|
itemObj.put("plannedStartTime", item.getTplanstarttime()); // 计划开工时间
|
||||||
|
itemObj.put("plannedCompletionTime", item.getTplanendtime()); // 计划完工时间
|
||||||
|
itemObj.put("customerMaterialCode", item.getCcustmaterialid()); // 客户物料编码
|
||||||
|
itemObj.put("productionBatch", item.getCbatchid()); // 生产批次(按BIP格式)
|
||||||
|
itemObj.put("productionBatchNumber", item.getVbatchcode()); // 生产批次号(按BIP格式)
|
||||||
|
|
||||||
|
contentArray.add(itemObj); // 将子项添加到数组
|
||||||
|
}
|
||||||
|
|
||||||
|
singleObj.put("itemList", contentArray); // 将子项数组添加到主对象
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"bipProcessProductionOrderId": "流程生产订单号",
|
||||||
|
"bipId": "主键ID",
|
||||||
|
"orderQuantity": "订单数量(计划数量)",
|
||||||
|
"billDate": "单据日期 按Bip格式",
|
||||||
|
"orderVersion": "版本",
|
||||||
|
"orderTranType": "订单交易类型 按BIP状态",
|
||||||
|
"bipCreateBy": "创建人ID",
|
||||||
|
"itemList": [
|
||||||
|
{
|
||||||
|
"contractNum": "TGYZF2520201225",
|
||||||
|
"entryName": "大唐河北故城50MW风电项目",
|
||||||
|
"bipChildId": "子项主键ID",
|
||||||
|
"bipDeptName": "生产部门 名称",
|
||||||
|
"bipDeptId": "生产部门编码",
|
||||||
|
"requiredDate": "需用日期",
|
||||||
|
"bipParentProcessProductionOrderId": "上级单据号",
|
||||||
|
"bipParentProcessProductionOrderRowNum": "上级单据行号",
|
||||||
|
"bipOriginProcessProductionOrderId": "顶级来源单据号",
|
||||||
|
"bipOriginProcessProductionOrderRowNum": "顶级来源单据行号",
|
||||||
|
"materialCode": "物料编码",
|
||||||
|
"materialName": "物料名称",
|
||||||
|
"drawingNumber": "图号编码",
|
||||||
|
"unit": "单位 例如件",
|
||||||
|
"intervalModel": "产品类型 例如35-KV-断路器(物料自定义字段)",
|
||||||
|
"processCode": "产品编码的工序(物料的自定义字段)",
|
||||||
|
"lineNumber": "行号需要 例如 10 20",
|
||||||
|
"demandInventoryOrganization": "需求库存组织",
|
||||||
|
"plannedInputQuantity": "计划投入主数量 1",
|
||||||
|
"plannedOutputQuantity": "计划产出主数量 1",
|
||||||
|
"plannedStartTime": "计划开工时间 2025-08-01",
|
||||||
|
"plannedCompletionTime": "计划完工时间 2026-08-01",
|
||||||
|
"customerMaterialCode": "客户物料编码",
|
||||||
|
"productionBatch": "生产批次 按BIP格式",
|
||||||
|
"productionBatchNumber": "生产批次号 按BIP格式"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
} */
|
||||||
|
pushData(singleObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送同步数据
|
||||||
|
*/
|
||||||
|
private void pushData(JSONObject param) throws BusinessException {
|
||||||
|
// String jsonString = param.toJSONString();
|
||||||
|
// 转json字符串的时候保留null值
|
||||||
|
String jsonStr = JSON.toJSONString(param,
|
||||||
|
SerializerFeature.WriteMapNullValue,
|
||||||
|
SerializerFeature.WriteNullStringAsEmpty
|
||||||
|
);
|
||||||
|
// logDl.error("QMS-Material-param = " + jsonStr);
|
||||||
|
// String baseUrl = configParams.get("qmsBaseUrl");
|
||||||
|
// String requestUrl = baseUrl + configParams.get("pomInsertUrl");
|
||||||
|
// logDl.error("QMS-Material-url = " + requestUrl);
|
||||||
|
String requestUrl ="http://192.168.223.115:8087/bip/order/productionOrderAdd";
|
||||||
|
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
|
||||||
|
JSONObject resultObj = JSONObject.parseObject(result);
|
||||||
|
logDl.error("QMS-Material-res = " + result);
|
||||||
|
|
||||||
|
if (!"success".equals(resultObj.getString("success"))) {
|
||||||
|
// throw new BusinessException("QMS-Material-error:" + resultObj.getString("msg"));
|
||||||
|
logDl.error("QMS-Material-error,result[" + resultObj.toJSONString() + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||||
|
String targetCode = configParams.get("xbOrg");
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue