refactor(mmpac): 重构 MES 同步接口构建 properties 数组

- 提取 buildProperties 方法,用于构建 MES 同步所需的 properties 数组
- 添加 addProperty 方法,简化单个 property 的添加过程
- 新增 SXZF22、SXZF23、SXZF24 字段的同步- 优化代码结构,提高可读性和可维护性
This commit is contained in:
maolei 2025-05-29 10:04:16 +08:00
parent 14c86ec4d3
commit 4cac17c8bd
1 changed files with 46 additions and 16 deletions

View File

@ -302,22 +302,7 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> {
}
// 通过自定义属性传
JSONArray properties = new JSONArray();
JSONObject SXZF16 = new JSONObject();
JSONObject SXZF17 = new JSONObject();
JSONObject SXZF18 = new JSONObject();
SXZF16.put("propertyFiled", "SXZF16");
SXZF17.put("propertyFiled", "SXZF17");
SXZF18.put("propertyFiled", "SXZF18");
SXZF16.put("propertyValue", item.getVparentbillcode());
SXZF17.put("propertyValue", item.getVparentmorowno());
SXZF18.put("propertyValue", head.getVtrantypecode());
properties.add(SXZF16);
properties.add(SXZF17);
properties.add(SXZF18);
JSONArray properties = buildProperties(head, item);
data.put("properties", properties);
JSONObject requestPayload = new JSONObject();
@ -334,6 +319,51 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> {
obmlog.info("生产订单 " + vbillcode + "" + itemRow + " 已成功发送到MES系统或特定错误已被记录。");
}
/**
* 构建MES同步所需的properties数组
*
* @param head 生产订单表头
* @param item 生产订单明细
* @return JSONArray properties数组
*/
private JSONArray buildProperties(PMOHeadVO head, PMOItemVO item) {
JSONArray properties = new JSONArray();
// SXZF16 - 上级生产订单号
addProperty(properties, "SXZF16", item.getVparentbillcode());
// SXZF17 - 上级生产订单行号
addProperty(properties, "SXZF17", item.getVparentmorowno());
// SXZF18 - 生产订单交易类型编码
addProperty(properties, "SXZF18", head.getVtrantypecode());
// SXZF22 - 生产订单交易类型编码
addProperty(properties, "SXZF22", head.getVtrantypecode());
// SXZF23 - 生产订单主键
addProperty(properties, "SXZF23", head.getCpmohid());
// SXZF24 - 生产订单明细主键
addProperty(properties, "SXZF24", item.getCmoid());
return properties;
}
/**
* 添加单个property到properties数组
*
* @param properties JSONArray数组
* @param propertyField 属性字段名
* @param propertyValue 属性值
*/
private void addProperty(JSONArray properties, String propertyField, String propertyValue) {
JSONObject property = new JSONObject();
property.put("propertyFiled", propertyField);
property.put("propertyValue", propertyValue);
properties.add(property);
}
/**
* 根据主键查询编码