PMO-艾普mes-v2

This commit is contained in:
mzr 2025-09-24 12:48:35 +08:00
parent 966ad2d606
commit ab19b96215
5 changed files with 32 additions and 25 deletions

View File

@ -40,7 +40,7 @@ public class PmoToEpicMesAction implements ICommonAction {
ExceptionUtils.wrapBusinessException("查询不到对应流程生产订单"); ExceptionUtils.wrapBusinessException("查询不到对应流程生产订单");
} }
HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil(); HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil();
mesUtil.processData(pmoAggVOS, "Y"); mesUtil.processData(pmoAggVOS, "Y", false);
return ResultMessageUtil.toJSON(true, "推送成功"); return ResultMessageUtil.toJSON(true, "推送成功");
} catch (Exception e) { } catch (Exception e) {
logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e); logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e);

View File

@ -34,14 +34,14 @@ public class AfterupdateSyncEpicMesRule implements IRule<AggPickmVO> {
for (AggPickmVO aggPickmVO : aggPickmVOS) { for (AggPickmVO aggPickmVO : aggPickmVOS) {
IPMOQueryService queryService= NCLocator.getInstance().lookup(IPMOQueryService.class); IPMOQueryService queryService = NCLocator.getInstance().lookup(IPMOQueryService.class);
List<PMOAggVO> list = new ArrayList<PMOAggVO>(); List<PMOAggVO> list = new ArrayList<PMOAggVO>();
if(null!=aggPickmVO.getParentVO().getVfirstbilltype() && aggPickmVO.getParentVO().getVfirstbilltype().indexOf("55A2")!=-1){ if (null != aggPickmVO.getParentVO().getVfirstbilltype() && aggPickmVO.getParentVO().getVfirstbilltype().indexOf("55A2") != -1) {
try { try {
PMOAggVO[] pmoAggVO = queryService.queryPMOAggVOByBid( new String[]{aggPickmVO.getParentVO().getCsourcebillid()}); PMOAggVO[] pmoAggVO = queryService.queryPMOAggVOByBid(new String[]{aggPickmVO.getParentVO().getCsourcebillid()});
if(null!=pmoAggVO){ if (null != pmoAggVO) {
for (PMOAggVO pmoAggVO1 : pmoAggVO) { for (PMOAggVO pmoAggVO1 : pmoAggVO) {
if (1 == pmoAggVO1.getParentVO().getFbillstatus()){ if (1 == pmoAggVO1.getParentVO().getFbillstatus()) {
list.add(pmoAggVO1); list.add(pmoAggVO1);
} }
} }
@ -56,7 +56,7 @@ public class AfterupdateSyncEpicMesRule implements IRule<AggPickmVO> {
// ±¸ÁÏÖØËãºó´¥·¢ÉóºË // ±¸ÁÏÖØËãºó´¥·¢ÉóºË
String n = "Y"; String n = "Y";
try { try {
mesUtil.processData((PMOAggVO[])list.toArray(new PMOAggVO[list.size()]),n); mesUtil.processData((PMOAggVO[]) list.toArray(new PMOAggVO[list.size()]), n, false);
} catch (BusinessException e) { } catch (BusinessException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -27,7 +27,7 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
} }
try { try {
HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil(); HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil();
mesUtil.processData(pmoAggVOS, "Y"); mesUtil.processData(pmoAggVOS, "Y", true);
} catch (Exception e) { } catch (Exception e) {
logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e); logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e);
ExceptionUtils.wrappException(e); ExceptionUtils.wrappException(e);

View File

@ -27,7 +27,7 @@ public class AfterUnApproveSyncEpicMesRule implements ICompareRule<PMOAggVO> {
} }
try { try {
HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil(); HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil();
mesUtil.processData(pmoAggVOS, "N"); mesUtil.processData(pmoAggVOS, "N", false);
} catch (Exception e) { } catch (Exception e) {
logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e); logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e);

View File

@ -46,51 +46,51 @@ public class HttpPmoEpicMesUtil {
private static final BaseDAO dao = new BaseDAO(); private static final BaseDAO dao = new BaseDAO();
public void processData(PMOAggVO[] pmoAggVOS, String flag) throws BusinessException { public void processData(PMOAggVO[] pmoAggVOS, String flag, boolean syncCodeFlag) throws BusinessException {
auditCode = flag; auditCode = flag;
configParams = MyHelper.getConfigParams("Dldz-config", null); configParams = MyHelper.getConfigParams("Dldz-config", null);
if (configParams.isEmpty()) { if (configParams.isEmpty()) {
// throw new BusinessException("????????????MES??????????"); // throw new BusinessException("电力电子的艾普MES接口缺少配置");
logDl.error("????????????MES??????????"); logDl.error("电力电子的艾普MES接口缺少配置");
return; return;
} }
deptParams = MyHelper.getConfigParams("Dldz-dept", null); deptParams = MyHelper.getConfigParams("Dldz-dept", null);
if (deptParams.isEmpty()) { if (deptParams.isEmpty()) {
// throw new BusinessException("????????????MES???????????????????"); // throw new BusinessException("电力电子的艾普MES接口缺少部门编码映射配置");
logDl.error("????????????MES???????????????????"); logDl.error("电力电子的艾普MES接口缺少部门编码映射配置");
return; return;
} }
String deptRange = String.join(",", deptParams.keySet()); String deptRange = String.join(",", deptParams.keySet());
configParams.put("deptRange", deptRange); configParams.put("deptRange", deptRange);
List<PMOAggVO> filteredOrders = checkAndFilterBillSrcOrg(pmoAggVOS); List<PMOAggVO> filteredOrders = checkAndFilterBillSrcOrg(pmoAggVOS);
if (filteredOrders.isEmpty()) { if (filteredOrders.isEmpty()) {
logDl.error("??§Ù?????????????????????????????MES????"); logDl.error("没有符合条件的生产订单需要同步到艾普MES系统。");
return; return;
} }
logDl.info("????????????????????MES?????????????????????: " + filteredOrders.size()); logDl.info("开始同步生产订单到艾普MES系统符合条件的订单数量: " + filteredOrders.size());
Set<String> billTypeCodes = Set.of( Set<String> billTypeCodes = Set.of(
"55A2-Cxx-01", "55A2-Cxx-18" "55A2-Cxx-01", "55A2-Cxx-18"
); );
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
// ?????????MES?? // 推送到艾普MES系统
for (PMOAggVO aggVO : filteredOrders) { for (PMOAggVO aggVO : filteredOrders) {
PMOHeadVO head = aggVO.getParentVO(); PMOHeadVO head = aggVO.getParentVO();
// ?§Ø????????,????????????? // 判断订单类型,期初订单不处理
String vtrantypecode = head.getVtrantypecode(); String vtrantypecode = head.getVtrantypecode();
if (billTypeCodes.contains(vtrantypecode)) { if (billTypeCodes.contains(vtrantypecode)) {
continue; continue;
} }
PMOItemVO[] bodys = aggVO.getChildrenVO(); PMOItemVO[] bodys = aggVO.getChildrenVO();
if (bodys == null || bodys.length == 0) { if (bodys == null || bodys.length == 0) {
logDl.error("???????? " + head.getVbillcode() + " ???????????????????"); logDl.error("生产订单 " + head.getVbillcode() + " 没有行信息,跳过同步。");
continue; continue;
} }
if ("N".equals(auditCode)) { if ("N".equals(auditCode)) {
JSONObject data = buildSyncData(aggVO); JSONObject data = buildSyncData(aggVO);
pushData(pmoUrl, data); pushData(pmoUrl, data, "");
} else { } else {
JSONObject data = buildSyncData(aggVO); JSONObject data = buildSyncData(aggVO);
pushData(pmoUrl, data); pushData(pmoUrl, data, head.getPrimaryKey());
JSONObject buildSyncData = buildSyncCodeData(aggVO); JSONObject buildSyncData = buildSyncCodeData(aggVO);
if (buildSyncData != null && !buildSyncData.isEmpty()) { if (buildSyncData != null && !buildSyncData.isEmpty()) {
@ -98,11 +98,11 @@ public class HttpPmoEpicMesUtil {
} }
} }
} }
if (!jsonArray.isEmpty()) { if (!jsonArray.isEmpty() && syncCodeFlag) {
pushData(codeUrl, jsonArray); pushData(codeUrl, jsonArray, "");
} }
logDl.info("?????????????????MES????????¨À?"); logDl.info("生产订单同步到艾普MES系统处理完成。");
} }
@ -112,7 +112,7 @@ public class HttpPmoEpicMesUtil {
* @param param 请求体 * @param param 请求体
* @throws BusinessException 如果发生非特定可忽略的错误 * @throws BusinessException 如果发生非特定可忽略的错误
*/ */
private void pushData(String reqUrl, Object param) throws BusinessException { private void pushData(String reqUrl, Object param, String hid) throws BusinessException {
String responseString = null; String responseString = null;
try { try {
// 转json字符串的时候保留null值 // 转json字符串的时候保留null值
@ -128,6 +128,13 @@ public class HttpPmoEpicMesUtil {
if (!"1".equals(resultObj.getString("flag"))) { if (!"1".equals(resultObj.getString("flag"))) {
logDl.error("EpicMes-PMO-error,result[" + resultObj.toJSONString() + "]"); logDl.error("EpicMes-PMO-error,result[" + resultObj.toJSONString() + "]");
throw new BusinessException("艾普MES返回错误信息:" + resultObj.getString("msg")); throw new BusinessException("艾普MES返回错误信息:" + resultObj.getString("msg"));
} else {
if (hid != null && !hid.isEmpty()) {
// 调整MES传输状态
String updateSql = "update mm_mo set vdef34 = 'Y' where cpmohid = '[cpmohid]'";
updateSql = updateSql.replace("[cpmohid]", hid);
dao.executeUpdate(updateSql);
}
} }
} catch (Exception e) { } catch (Exception e) {
logDl.error(" 调用MES或处理响应时发生错误。原始响应: " + responseString + " 错误: " + e.getMessage(), e); logDl.error(" 调用MES或处理响应时发生错误。原始响应: " + responseString + " 错误: " + e.getMessage(), e);