|
@@ -4,6 +4,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpResponse;
|
|
import cn.hutool.http.HttpResponse;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.github.rholder.retry.*;
|
|
import com.github.rholder.retry.*;
|
|
@@ -14,6 +15,7 @@ import com.warewms.hailiang.MES.MesService;
|
|
import com.warewms.hailiang.config.DeviceMessageSocket;
|
|
import com.warewms.hailiang.config.DeviceMessageSocket;
|
|
import com.warewms.hailiang.domain.Device;
|
|
import com.warewms.hailiang.domain.Device;
|
|
import com.warewms.hailiang.domain.DeviceLog;
|
|
import com.warewms.hailiang.domain.DeviceLog;
|
|
|
|
+import com.warewms.hailiang.domain.RetroactiveNow;
|
|
import com.warewms.hailiang.enums.DaSanPanPlcEnum;
|
|
import com.warewms.hailiang.enums.DaSanPanPlcEnum;
|
|
import com.warewms.hailiang.enums.DeviceNameEnum;
|
|
import com.warewms.hailiang.enums.DeviceNameEnum;
|
|
import com.warewms.hailiang.init.PlcConnectServiceRunner;
|
|
import com.warewms.hailiang.init.PlcConnectServiceRunner;
|
|
@@ -55,6 +57,9 @@ public class MesServiceImpl implements MesService {
|
|
@Value("${MES.sanPanGetBatchNoUrl}")
|
|
@Value("${MES.sanPanGetBatchNoUrl}")
|
|
private String sanPanGetBatchNoUrl;
|
|
private String sanPanGetBatchNoUrl;
|
|
|
|
|
|
|
|
+ @Value("${MES.tuiHuoShangLiaoUrl}")
|
|
|
|
+ private String tuiHuoShangLiaoUrl;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private DeviceMessageSocket deviceMessageSocket;
|
|
private DeviceMessageSocket deviceMessageSocket;
|
|
|
|
|
|
@@ -75,12 +80,12 @@ public class MesServiceImpl implements MesService {
|
|
body = HttpRequest.post(MESAddress + getBatchNoUrl).body(entries.toString()).execute().body();
|
|
body = HttpRequest.post(MESAddress + getBatchNoUrl).body(entries.toString()).execute().body();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("调用MES系统拿铜管批次号失败,msg:{}", e.getMessage());
|
|
log.error("调用MES系统拿铜管批次号失败,msg:{}", e.getMessage());
|
|
- return invokeAlarms("称重辊道PLC", "获取MES铜管批次号失败!");
|
|
|
|
|
|
+ return invokeAlarms("称重辊道PLC", "获取MES铜管批次号失败!"+e.getMessage());
|
|
}
|
|
}
|
|
JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
- if ("false".equals(jsonObject.get("ret"))) {
|
|
|
|
|
|
+ if ("false".equals(jsonObject.get("ret").toString())) {
|
|
log.error("调用MES系统拿铜管批次号失败,msg:{}", jsonObject.get("message"));
|
|
log.error("调用MES系统拿铜管批次号失败,msg:{}", jsonObject.get("message"));
|
|
- return invokeAlarms("称重辊道PLC", "获取MES铜管批次号失败!");
|
|
|
|
|
|
+ return invokeAlarms("称重辊道PLC", "获取MES铜管批次号失败!"+jsonObject.get("message"));
|
|
}
|
|
}
|
|
return JSONUtil.parseObj(body).get("BatchNo").toString();
|
|
return JSONUtil.parseObj(body).get("BatchNo").toString();
|
|
}
|
|
}
|
|
@@ -102,7 +107,7 @@ public class MesServiceImpl implements MesService {
|
|
entries.set("type", result);
|
|
entries.set("type", result);
|
|
String body = HttpRequest.post(MESAddress + getBatchNoResultURl).body(entries.toString()).execute().body();
|
|
String body = HttpRequest.post(MESAddress + getBatchNoResultURl).body(entries.toString()).execute().body();
|
|
JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
- if ("false".equals(jsonObject.get("ret"))) {
|
|
|
|
|
|
+ if ("false".equals(jsonObject.get("ret").toString())) {
|
|
retryTofeedback(MESAddress + processFeedbackUrl, entries, "BatchNoResult");
|
|
retryTofeedback(MESAddress + processFeedbackUrl, entries, "BatchNoResult");
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -115,10 +120,10 @@ public class MesServiceImpl implements MesService {
|
|
JSONObject entries = new JSONObject();
|
|
JSONObject entries = new JSONObject();
|
|
entries.set("BatchNo", batchNo);
|
|
entries.set("BatchNo", batchNo);
|
|
entries.set("Type", type);
|
|
entries.set("Type", type);
|
|
- entries.set("d", "Z1");
|
|
|
|
|
|
+ entries.set("LineNo", "Z1");
|
|
String body = HttpRequest.post(MESAddress + processFeedbackUrl).body(entries.toString()).execute().body();
|
|
String body = HttpRequest.post(MESAddress + processFeedbackUrl).body(entries.toString()).execute().body();
|
|
JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
- if ("0".equals(jsonObject.get("RES_FLAG"))) {
|
|
|
|
|
|
+ if ("false".equals(jsonObject.get("ret"))) {
|
|
retryTofeedback(MESAddress + processFeedbackUrl, entries, "process");
|
|
retryTofeedback(MESAddress + processFeedbackUrl, entries, "process");
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -129,20 +134,46 @@ public class MesServiceImpl implements MesService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String bindLotNo(String deviceId,String lotNot) {
|
|
public String bindLotNo(String deviceId,String lotNot) {
|
|
- log.info("散盘产出设备:{}",deviceId);
|
|
|
|
- JSONObject entries = new JSONObject();
|
|
|
|
- entries.set("StockNo", lotNot);
|
|
|
|
- entries.set("UnitNo",deviceId );
|
|
|
|
- entries.set("LineNo", "Z1");
|
|
|
|
- String body = HttpRequest.post( MESAddress+ sanPanGetBatchNoUrl).body(entries.toString()).execute().body();
|
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
|
- if ("0".equals(jsonObject.get("RES_FLAG"))) {
|
|
|
|
|
|
+ JSONObject entries = null;
|
|
|
|
+ String body = null;
|
|
|
|
+ try {
|
|
|
|
+ log.info("散盘产出设备:{}",deviceId);
|
|
|
|
+ entries = new JSONObject();
|
|
|
|
+ entries.set("StockNo", lotNot);
|
|
|
|
+ entries.set("UnitNo",deviceId );
|
|
|
|
+ entries.set("LineNo", "Z1");
|
|
|
|
+ body = HttpRequest.post( MESAddress+ sanPanGetBatchNoUrl).body(entries.toString()).execute().body();
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
|
+ if ("0".equals(jsonObject.get("RES_FLAG").toString())) {
|
|
retryTofeedback(MESAddress + sanPanGetBatchNoUrl, entries, "sanpan");
|
|
retryTofeedback(MESAddress + sanPanGetBatchNoUrl, entries, "sanpan");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return JSONUtil.parseObj(jsonObject.get("Result")).get("mat_no").toString();
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("大散盘绑定批次号发生错误,json:{},body:{},msg",entries,body,e);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- log.info(body);
|
|
|
|
- return JSONUtil.parseObj(jsonObject.get("Result")).get("mat_no").toString();
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String tuiHuoShangLiao(RetroactiveNow retroactiveNow) {
|
|
|
|
+ JSONObject entries = new JSONObject();
|
|
|
|
+ JSONArray matDatas = new JSONArray();
|
|
|
|
+ entries.set("matDatas",matDatas);
|
|
|
|
+ entries.set("unit_code",retroactiveNow.getUniuCode());
|
|
|
|
+ JSONObject matDate = new JSONObject();
|
|
|
|
+ matDate.set("mat_no",retroactiveNow.getBatchNo());
|
|
|
|
+ matDate.set("stand_no",retroactiveNow.getShelfNumber());
|
|
|
|
+ matDate.set("stand_position",retroactiveNow.getNumberOfLayers());
|
|
|
|
+ matDate.set("loaction",retroactiveNow.getLotAddress());
|
|
|
|
+ matDate.set("layerno",retroactiveNow.getLayerno());
|
|
|
|
+ String body = HttpRequest.post( MESAddress+ tuiHuoShangLiaoUrl).body(entries.toString()).execute().body();
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
|
+ if ("0".equals(jsonObject.get("res_flag").toString())) {
|
|
|
|
+ retryTofeedback(MESAddress + tuiHuoShangLiaoUrl, entries, "tuiHuoUP");
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -165,23 +196,30 @@ public class MesServiceImpl implements MesService {
|
|
String data = HttpRequest.post(URl).body(body.toString()).execute().body();
|
|
String data = HttpRequest.post(URl).body(body.toString()).execute().body();
|
|
JSONObject jsonObject = JSONUtil.parseObj(data);
|
|
JSONObject jsonObject = JSONUtil.parseObj(data);
|
|
if ("process".equals(type)) {
|
|
if ("process".equals(type)) {
|
|
- if ("0".equals(jsonObject.get("RES_FLAG"))) {
|
|
|
|
|
|
+ if ("false".equals(jsonObject.get("ret").toString())) {
|
|
log.error("工序读码成功反馈失败,msg:{}", jsonObject.get("message"));
|
|
log.error("工序读码成功反馈失败,msg:{}", jsonObject.get("message"));
|
|
- invokeAlarms("1".equals(type) ? "铣面工序" : "轧制工序", "工序读码成功反馈MES失败!");
|
|
|
|
|
|
+ invokeAlarms("1".equals(type) ? "铣面工序" : "轧制工序", "工序读码成功反馈MES失败!"+ jsonObject.get("message"));
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ("BatchNoResult".equals(type)){
|
|
if ("BatchNoResult".equals(type)){
|
|
- if ("false".equals(jsonObject.get("ret"))) {
|
|
|
|
|
|
+ if ("false".equals(jsonObject.get("ret").toString())) {
|
|
log.error("喷码成功反馈MES失败,msg:{}", jsonObject.get("message"));
|
|
log.error("喷码成功反馈MES失败,msg:{}", jsonObject.get("message"));
|
|
- invokeAlarms("喷码器", "喷码成功反馈MES失败!");
|
|
|
|
|
|
+ invokeAlarms("喷码器", "喷码成功反馈MES失败!"+ jsonObject.get("message"));
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ("sanpan".equals(type)){
|
|
if ("sanpan".equals(type)){
|
|
- if ("false".equals(jsonObject.get("ret"))) {
|
|
|
|
|
|
+ if ("0".equals(jsonObject.get("RES_FLAG").toString())) {
|
|
log.error("散盘托盘号反馈MES失败,msg:{}", jsonObject.get("message"));
|
|
log.error("散盘托盘号反馈MES失败,msg:{}", jsonObject.get("message"));
|
|
- invokeAlarms("大散盘", "获取批次号失败!");
|
|
|
|
|
|
+ invokeAlarms("大散盘", "获取批次号失败!"+ jsonObject.get("message"));
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ("tuiHuoUP".equals(type)) {
|
|
|
|
+ if ("0".equals(jsonObject.get("res_flag").toString())) {
|
|
|
|
+ log.error("退火上料料架信息反馈失败,msg:{}", jsonObject.get("message"));
|
|
|
|
+ invokeAlarms("退货上料工序", "工序读码成功反馈MES失败!"+ jsonObject.get("message"));
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|