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