PMO-艾普mes-v2
This commit is contained in:
parent
966ad2d606
commit
ab19b96215
|
|
@ -40,7 +40,7 @@ public class PmoToEpicMesAction implements ICommonAction {
|
|||
ExceptionUtils.wrapBusinessException("查询不到对应流程生产订单");
|
||||
}
|
||||
HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil();
|
||||
mesUtil.processData(pmoAggVOS, "Y");
|
||||
mesUtil.processData(pmoAggVOS, "Y", false);
|
||||
return ResultMessageUtil.toJSON(true, "推送成功");
|
||||
} catch (Exception e) {
|
||||
logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e);
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ public class AfterupdateSyncEpicMesRule implements IRule<AggPickmVO> {
|
|||
|
||||
for (AggPickmVO aggPickmVO : aggPickmVOS) {
|
||||
|
||||
IPMOQueryService queryService= NCLocator.getInstance().lookup(IPMOQueryService.class);
|
||||
IPMOQueryService queryService = NCLocator.getInstance().lookup(IPMOQueryService.class);
|
||||
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 {
|
||||
PMOAggVO[] pmoAggVO = queryService.queryPMOAggVOByBid( new String[]{aggPickmVO.getParentVO().getCsourcebillid()});
|
||||
if(null!=pmoAggVO){
|
||||
PMOAggVO[] pmoAggVO = queryService.queryPMOAggVOByBid(new String[]{aggPickmVO.getParentVO().getCsourcebillid()});
|
||||
if (null != pmoAggVO) {
|
||||
for (PMOAggVO pmoAggVO1 : pmoAggVO) {
|
||||
if (1 == pmoAggVO1.getParentVO().getFbillstatus()){
|
||||
if (1 == pmoAggVO1.getParentVO().getFbillstatus()) {
|
||||
list.add(pmoAggVO1);
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ public class AfterupdateSyncEpicMesRule implements IRule<AggPickmVO> {
|
|||
// ±¸ÁÏÖØËãºó´¥·¢ÉóºË
|
||||
String n = "Y";
|
||||
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) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
}
|
||||
try {
|
||||
HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil();
|
||||
mesUtil.processData(pmoAggVOS, "Y");
|
||||
mesUtil.processData(pmoAggVOS, "Y", true);
|
||||
} catch (Exception e) {
|
||||
logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e);
|
||||
ExceptionUtils.wrappException(e);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class AfterUnApproveSyncEpicMesRule implements ICompareRule<PMOAggVO> {
|
|||
}
|
||||
try {
|
||||
HttpPmoEpicMesUtil mesUtil = new HttpPmoEpicMesUtil();
|
||||
mesUtil.processData(pmoAggVOS, "N");
|
||||
mesUtil.processData(pmoAggVOS, "N", false);
|
||||
|
||||
} catch (Exception e) {
|
||||
logDl.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e);
|
||||
|
|
|
|||
|
|
@ -46,51 +46,51 @@ public class HttpPmoEpicMesUtil {
|
|||
|
||||
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;
|
||||
configParams = MyHelper.getConfigParams("Dldz-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
// throw new BusinessException("????????????MES??????????");
|
||||
logDl.error("????????????MES??????????");
|
||||
// throw new BusinessException("电力电子的艾普MES接口缺少配置");
|
||||
logDl.error("电力电子的艾普MES接口缺少配置");
|
||||
return;
|
||||
}
|
||||
deptParams = MyHelper.getConfigParams("Dldz-dept", null);
|
||||
if (deptParams.isEmpty()) {
|
||||
// throw new BusinessException("????????????MES???????????????????");
|
||||
logDl.error("????????????MES???????????????????");
|
||||
// throw new BusinessException("电力电子的艾普MES接口缺少部门编码映射配置");
|
||||
logDl.error("电力电子的艾普MES接口缺少部门编码映射配置");
|
||||
return;
|
||||
}
|
||||
String deptRange = String.join(",", deptParams.keySet());
|
||||
configParams.put("deptRange", deptRange);
|
||||
List<PMOAggVO> filteredOrders = checkAndFilterBillSrcOrg(pmoAggVOS);
|
||||
if (filteredOrders.isEmpty()) {
|
||||
logDl.error("??§Ù?????????????????????????????MES????");
|
||||
logDl.error("没有符合条件的生产订单需要同步到艾普MES系统。");
|
||||
return;
|
||||
}
|
||||
logDl.info("????????????????????MES?????????????????????: " + filteredOrders.size());
|
||||
logDl.info("开始同步生产订单到艾普MES系统,符合条件的订单数量: " + filteredOrders.size());
|
||||
Set<String> billTypeCodes = Set.of(
|
||||
"55A2-Cxx-01", "55A2-Cxx-18"
|
||||
);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
// ?????????MES??
|
||||
// 推送到艾普MES系统
|
||||
for (PMOAggVO aggVO : filteredOrders) {
|
||||
PMOHeadVO head = aggVO.getParentVO();
|
||||
// ?§Ø????????,?????????????
|
||||
// 判断订单类型,期初订单不处理
|
||||
String vtrantypecode = head.getVtrantypecode();
|
||||
if (billTypeCodes.contains(vtrantypecode)) {
|
||||
continue;
|
||||
}
|
||||
PMOItemVO[] bodys = aggVO.getChildrenVO();
|
||||
if (bodys == null || bodys.length == 0) {
|
||||
logDl.error("???????? " + head.getVbillcode() + " ???????????????????");
|
||||
logDl.error("生产订单 " + head.getVbillcode() + " 没有行信息,跳过同步。");
|
||||
continue;
|
||||
}
|
||||
if ("N".equals(auditCode)) {
|
||||
JSONObject data = buildSyncData(aggVO);
|
||||
pushData(pmoUrl, data);
|
||||
pushData(pmoUrl, data, "");
|
||||
} else {
|
||||
JSONObject data = buildSyncData(aggVO);
|
||||
pushData(pmoUrl, data);
|
||||
pushData(pmoUrl, data, head.getPrimaryKey());
|
||||
|
||||
JSONObject buildSyncData = buildSyncCodeData(aggVO);
|
||||
if (buildSyncData != null && !buildSyncData.isEmpty()) {
|
||||
|
|
@ -98,11 +98,11 @@ public class HttpPmoEpicMesUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!jsonArray.isEmpty()) {
|
||||
pushData(codeUrl, jsonArray);
|
||||
if (!jsonArray.isEmpty() && syncCodeFlag) {
|
||||
pushData(codeUrl, jsonArray, "");
|
||||
}
|
||||
|
||||
logDl.info("?????????????????MES????????¨À?");
|
||||
logDl.info("生产订单同步到艾普MES系统处理完成。");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ public class HttpPmoEpicMesUtil {
|
|||
* @param param 请求体
|
||||
* @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;
|
||||
try {
|
||||
// 转json字符串的时候保留null值
|
||||
|
|
@ -128,6 +128,13 @@ public class HttpPmoEpicMesUtil {
|
|||
if (!"1".equals(resultObj.getString("flag"))) {
|
||||
logDl.error("EpicMes-PMO-error,result[" + resultObj.toJSONString() + "]");
|
||||
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) {
|
||||
logDl.error(" 调用MES或处理响应时发生错误。原始响应: " + responseString + " 错误: " + e.getMessage(), e);
|
||||
|
|
|
|||
Loading…
Reference in New Issue