fix: mes对接
This commit is contained in:
@@ -59,32 +59,33 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
if (param.getString("device_code").equals("C007")) { // 油漆线
|
||||
// 分物料上料位与下料位两个工单
|
||||
String deviceCodeWS = deviceCode.getString("device_code") + "WS";
|
||||
String deviceCodeKX = deviceCode.getString("device_code") + "KX";
|
||||
|
||||
// 如果未完成,就把工单完成并插入
|
||||
JSONObject orderWS = workOrderTab.query("device_code = '" + deviceCodeWS + "' AND order_status <> '5'").uniqueResult(0);
|
||||
JSONObject orderKX = workOrderTab.query("device_code = '" + deviceCodeKX + "' AND order_status <> '5'").uniqueResult(0);
|
||||
// JSONObject orderKX = workOrderTab.query("device_code = '" + deviceCodeKX + "' AND order_status <> '5'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(orderWS)) { // 存在,就关闭
|
||||
orderWS.put("order_status", "5");
|
||||
orderWS.put("update_time", DateUtil.now());
|
||||
orderWS.put("realproduceend_date", DateUtil.now());
|
||||
workOrderTab.update(orderWS);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(orderKX)) { // 存在,就关闭
|
||||
orderKX.put("order_status", "5");
|
||||
orderKX.put("update_time", DateUtil.now());
|
||||
orderKX.put("realproduceend_date", DateUtil.now());
|
||||
workOrderTab.update(orderKX);
|
||||
}
|
||||
// if (ObjectUtil.isNotEmpty(orderKX)) { // 存在,就关闭
|
||||
// orderKX.put("order_status", "5");
|
||||
// orderKX.put("update_time", DateUtil.now());
|
||||
// orderKX.put("realproduceend_date", DateUtil.now());
|
||||
// workOrderTab.update(orderKX);
|
||||
// }
|
||||
param.put("workorder_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
param.put("device_id", "1607915464833503232");
|
||||
param.put("device_code", deviceCodeWS);
|
||||
workOrderTab.insert(param);
|
||||
param.put("workorder_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
param.put("device_id", "1654663217064054784");
|
||||
param.put("device_code", deviceCodeKX);
|
||||
// param.put("workorder_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
// param.put("device_id", "1654663217064054784");
|
||||
// param.put("device_code", deviceCodeKX);
|
||||
workOrderTab.insert(param);
|
||||
String deviceCodeWX = deviceCode.getString("device_code") + "WX";
|
||||
String deviceCodeKS = deviceCode.getString("device_code") + "KS";
|
||||
String deviceCodeKX = deviceCode.getString("device_code") + "KX";
|
||||
JSONObject deviceCodeWXOrder = workOrderTab
|
||||
.query("device_code = '" + deviceCodeWX + "' AND order_status <> '5'")
|
||||
.uniqueResult(0);
|
||||
@@ -97,6 +98,10 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
param.put("device_id", "1654663328972279808");
|
||||
param.put("device_code", deviceCodeKS);
|
||||
workOrderTab.insert(param);
|
||||
param.put("workorder_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
param.put("device_id", "1654663217064054784");
|
||||
param.put("device_code", deviceCodeKX);
|
||||
workOrderTab.insert(param);
|
||||
} else {
|
||||
// 有的话就暂存起来
|
||||
param.put("workorder_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
@@ -108,8 +113,20 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
param.put("device_id", "1654663328972279808");
|
||||
param.put("device_code", deviceCodeKS);
|
||||
workOrderCacheTab.insert(param);
|
||||
param.put("workorder_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
param.put("device_id", "1654663217064054784");
|
||||
param.put("device_code", deviceCodeKX);
|
||||
workOrderCacheTab.insert(param);
|
||||
}
|
||||
} else { // 不是油漆线直接存入
|
||||
JSONObject orderObjs = workOrderTab
|
||||
.query("device_code = '" + deviceCode.getString("device_code") + "' AND order_status <> '5'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(orderObjs)) {
|
||||
// 多个工单就完成
|
||||
orderObjs.put("order_status", "5");
|
||||
workOrderTab.update(orderObjs);
|
||||
}
|
||||
param.put("workorder_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
param.put("device_id", deviceCode.getString("device_id"));
|
||||
param.put("device_code", deviceCode.getString("device_code"));
|
||||
|
||||
@@ -37,9 +37,7 @@ public class WmsToMesServiceImpl implements WmsToMesService {
|
||||
@Override
|
||||
public void taskFeedback(JSONObject param, String finterfaceid) {
|
||||
JSONObject feedback = MesUtil.taskFeedback(param, finterfaceid);
|
||||
if (!feedback.getString("code").equals("200")) {
|
||||
taskFeedback(param, finterfaceid);
|
||||
}
|
||||
log.info("反馈结果: {}", feedback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.sch;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -34,6 +35,20 @@ public class MesUtil {
|
||||
String endpointUrl = "http://192.168.4.111:8080/mes/services/HtWebService"; // 替换为实际的 WebService 地址
|
||||
JSONObject result = new JSONObject();
|
||||
JSONObject resObj = new JSONObject();
|
||||
String fsn502 = param.getString("fsn502");
|
||||
String fscanserialid001 = param.getString("fscanserialid001");
|
||||
String fpacknumberpl695 = param.getString("fpacknumberpl695");
|
||||
String fserialid054 = param.getString("fserialid054");
|
||||
// 获取任务编号
|
||||
String task_code = ObjectUtil.isNotEmpty(fsn502)
|
||||
? fsn502
|
||||
: ObjectUtil.isNotEmpty(fscanserialid001)
|
||||
? fscanserialid001
|
||||
: ObjectUtil.isNotEmpty(fpacknumberpl695)
|
||||
? fpacknumberpl695
|
||||
: ObjectUtil.isNotEmpty(fserialid054)
|
||||
? fserialid054
|
||||
: null;
|
||||
Map<String, String> stringMap = new HashMap<>();
|
||||
try {
|
||||
// 创建 HttpClient
|
||||
@@ -53,6 +68,7 @@ public class MesUtil {
|
||||
ir.put("details", p);
|
||||
items.add(ir);
|
||||
req.put("items", items);
|
||||
// xml报文
|
||||
String requestXml = parseXmlStr(JSON.toJSONString(req));
|
||||
// 设置请求体
|
||||
StringEntity entity = new StringEntity(requestXml, "UTF-8");
|
||||
@@ -88,16 +104,21 @@ public class MesUtil {
|
||||
log.error(e.getMessage());
|
||||
result.put("code", 400);
|
||||
result.put("message", resObj.get("ErrorMessage"));
|
||||
} finally {
|
||||
// 不管成不成功,记录数据
|
||||
|
||||
}
|
||||
MDC.remove("log_file_type");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得要发送的webservice的xml形式的参数
|
||||
*
|
||||
* @param method
|
||||
* @return
|
||||
*/
|
||||
private static String parseXmlStr(String method){
|
||||
private static String parseXmlStr(String method) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:io=\"http://io.platform.ht.com\">");
|
||||
sb.append("<soapenv:Header/>");
|
||||
@@ -111,7 +132,7 @@ public class MesUtil {
|
||||
sb.append("</io:post>");
|
||||
sb.append("</soapenv:Body>");
|
||||
sb.append("</soapenv:Envelope>");
|
||||
log.info("parseXmlStr组织参数为-----------------"+sb);
|
||||
log.info("parseXmlStr组织参数为-----------------" + sb);
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
@@ -133,7 +154,7 @@ public class MesUtil {
|
||||
path = map.get(root.getName().trim());
|
||||
map.remove(root.getName().trim());
|
||||
}
|
||||
for (Iterator i = root.elementIterator(); i.hasNext();) {
|
||||
for (Iterator i = root.elementIterator(); i.hasNext(); ) {
|
||||
Element element = (Element) i.next();
|
||||
if (element.isTextOnly()) {
|
||||
if (path.length() > 0) {
|
||||
@@ -142,7 +163,7 @@ public class MesUtil {
|
||||
map.put(element.getName().trim(), element.getTextTrim());
|
||||
}
|
||||
} else {
|
||||
map.put(element.getName().trim(), path+ element.getName().trim() + ".");
|
||||
map.put(element.getName().trim(), path + element.getName().trim() + ".");
|
||||
parseXml2Map(element.asXML(), map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ public class CpSendMaterialTask extends AbstractAcsTask {
|
||||
String task_id = task.getString("task_id");
|
||||
JSONObject taskObj = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
JSONObject feedback = new JSONObject();
|
||||
feedback.put("task_code", taskObj.getString("task_code"));
|
||||
//任务取消
|
||||
if (StrUtil.equals(status, "0")) {
|
||||
// 取消删除任务
|
||||
@@ -56,7 +55,7 @@ public class CpSendMaterialTask extends AbstractAcsTask {
|
||||
throw new BadRequestException("已完成不能取消!");
|
||||
}
|
||||
String point_code2 = taskObj.getString("point_code2");
|
||||
if (ObjectUtil.isEmpty(point_code2)) {
|
||||
if (ObjectUtil.isNotEmpty(point_code2)) {
|
||||
JSONObject endPoint = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
endPoint.put("lock_type", "1");
|
||||
pointTab.update(endPoint);
|
||||
@@ -220,9 +219,9 @@ public class CpSendMaterialTask extends AbstractAcsTask {
|
||||
if (ObjectUtil.isNotEmpty(djwPoint)) {
|
||||
point_code1 = djwPoint.getString("point_code");
|
||||
}
|
||||
//判断当前点是否有未完成的任务
|
||||
JSONObject taskObj = taskTab.query("is_delete='0' and point_code1 = '" + point_code1 + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj)) throw new BadRequestException("当前点位" + point_code1 + "存在未完成的任务");
|
||||
//todo: 判断当前点是否有未完成的任务
|
||||
// JSONObject taskObj = taskTab.query("is_delete='0' and point_code1 = '" + point_code1 + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
// if (ObjectUtil.isNotEmpty(taskObj)) throw new BadRequestException("当前点位" + point_code1 + "存在未完成的任务");
|
||||
|
||||
JSONObject materialObj = materialTab.query("material_code = '" + material_code + "' AND is_used = '1'").uniqueResult(0);
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user