瀏覽代碼

对接MES退火下料读码后反馈的接口

zhifei 9 月之前
父節點
當前提交
3330c32e0e

+ 3 - 1
warewms-admin/src/main/resources/application.yml

@@ -1,7 +1,7 @@
 # 指定环境的默认配置
 spring:
   profiles:
-    active: test
+    active: prod
 
 # MES对接接口
 MES:
@@ -16,4 +16,6 @@ MES:
   sanPanGetBatchNoUrl: /api/WareHouse/UpdateMaterialStockNo
   #退火上料
   tuiHuoShangLiaoUrl: /api/Mes/SyncReceiveBlanking
+  #退火下料
+  tuiHuoXiaLiaoUrl: /api/Mes/SyncReceiveMatno
 

+ 7 - 0
warewms-system/src/main/java/com/warewms/hailiang/MES/MesService.java

@@ -49,4 +49,11 @@ public interface MesService {
      * @return
      */
     public String tuiHuoShangLiao(RetroactiveNow retroactiveNow);
+
+    /**
+     * 退火下料
+     * @param batchNo
+     * @return
+     */
+    public JSONObject tuiHuoXiaLiao(String batchNo);
 }

+ 26 - 1
warewms-system/src/main/java/com/warewms/hailiang/MES/impl/MesServiceImpl.java

@@ -60,6 +60,9 @@ public class MesServiceImpl implements MesService {
     @Value("${MES.tuiHuoShangLiaoUrl}")
     private String tuiHuoShangLiaoUrl;
 
+    @Value("${MES.tuiHuoXiaLiaoUrl}")
+    private String tuiHuoXiaLiaoUrl;
+
     @Autowired
     private DeviceMessageSocket deviceMessageSocket;
 
@@ -176,7 +179,22 @@ public class MesServiceImpl implements MesService {
         return null;
     }
 
-        /**
+    @Override
+    public JSONObject tuiHuoXiaLiao(String batchNo) {
+        JSONObject entries = new JSONObject();
+        entries.set("mat_no", batchNo);
+        entries.set("unit_code", "Z1TH01");
+        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, "tuiHuoDown");
+            return null;
+        }
+
+        return jsonObject;
+    }
+
+    /**
      *  MES反馈重试
      * @param URl
      * @param body
@@ -223,6 +241,13 @@ public class MesServiceImpl implements MesService {
                             return false;
                         }
                     }
+                    if ("tuiHuoDown".equals(type)) {
+                        if ("0".equals(jsonObject.get("res_flag").toString())) {
+                            log.error("退火上料料架信息反馈失败,msg:{}", jsonObject.get("message"));
+                            invokeAlarms("退货上料工序", "工序读码成功反馈MES失败!"+ jsonObject.get("message"));
+                            return false;
+                        }
+                    }
                     return true;
                 });
             } catch (RetryException | ExecutionException e) {

+ 6 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader14Connect.java

@@ -2,6 +2,7 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
+import com.warewms.hailiang.MES.MesService;
 import com.warewms.hailiang.config.CodeReadProperties;
 import com.warewms.hailiang.connect.base.TCPConnectBase;
 import com.warewms.hailiang.domain.Device;
@@ -56,7 +57,10 @@ public class CodeReader14Connect implements TCPConnectBase {
 
     private ScheduledExecutorService scheduledExecutorService;
 
+    private MesService mesService;
+
     {
+        mesService = SpringUtil.getBean(MesService.class);
         retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
         scheduledExecutorService = SpringUtil.getBean(ScheduledExecutorService.class);
     }
@@ -191,6 +195,8 @@ public class CodeReader14Connect implements TCPConnectBase {
                 retroactiveNow.setStatus("7");
                 retroactiveNow.setDeviceId("Z1_TuiHuoXiaLiao_DMQ-1-27.14");
                 retroactiveNowService.finishProduce(retroactiveNow);
+                //反馈MES系统
+                mesService.tuiHuoXiaLiao(message);
                 //添加设备日志
                 SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoXiaLiao_DMQ-1-27.14", deviceName, "识别到码:" + message, "1"));
             }