Browse Source

对接MES退火上料PDA填写料架信息后上传对应信息

zhifei 9 months ago
parent
commit
c4602cd3a7

+ 8 - 1
warewms-system/src/main/java/com/warewms/hailiang/MES/MesService.java

@@ -1,6 +1,7 @@
 package com.warewms.hailiang.MES;
 
 import cn.hutool.json.JSONObject;
+import com.warewms.hailiang.domain.RetroactiveNow;
 import org.springframework.stereotype.Service;
 
 /**
@@ -39,7 +40,13 @@ public interface MesService {
      *  绑定批次号
      * @param v 大散盘下料点
      */
-    String bindLotNo(String deviceId,String lotNo);
+    public String bindLotNo(String deviceId,String lotNo);
 
 
+    /**
+     * 退火上料反馈
+     * @param message
+     * @return
+     */
+    public String tuiHuoShangLiao(RetroactiveNow retroactiveNow);
 }

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

@@ -4,6 +4,7 @@ import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 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.domain.Device;
 import com.warewms.hailiang.domain.DeviceLog;
+import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.enums.DaSanPanPlcEnum;
 import com.warewms.hailiang.enums.DeviceNameEnum;
 import com.warewms.hailiang.init.PlcConnectServiceRunner;
@@ -55,6 +57,9 @@ public class MesServiceImpl implements MesService {
     @Value("${MES.sanPanGetBatchNoUrl}")
     private String sanPanGetBatchNoUrl;
 
+    @Value("${MES.tuiHuoShangLiaoUrl}")
+    private String tuiHuoShangLiaoUrl;
+
     @Autowired
     private DeviceMessageSocket deviceMessageSocket;
 
@@ -151,6 +156,26 @@ public class MesServiceImpl implements MesService {
         }
     }
 
+    @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;
+    }
+
     /**
      *  MES反馈重试
      * @param URl
@@ -185,12 +210,19 @@ public class MesServiceImpl implements MesService {
                         }
                     }
                     if ("sanpan".equals(type)){
-                        if ("false".equals(jsonObject.get("ret").toString())) {
+                        if ("0".equals(jsonObject.get("RES_FLAG").toString())) {
                             log.error("散盘托盘号反馈MES失败,msg:{}", jsonObject.get("message"));
                             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 true;
                 });
             } catch (RetryException | ExecutionException e) {

+ 4 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.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 CodeReader13Connect implements TCPConnectBase {
 
     private ScheduledExecutorService scheduledExecutorService;
 
+    private MesService mesService;
+
     {
+        mesService = SpringUtil.getBean(MesService.class);
         retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
         scheduledExecutorService = SpringUtil.getBean(ScheduledExecutorService.class);
     }

+ 1 - 2
warewms-system/src/main/java/com/warewms/hailiang/controller/RetroactiveNowController.java

@@ -86,8 +86,7 @@ public class RetroactiveNowController {
             return R.fail("机组号不能为空");
         }
         System.out.println(retroactiveNow);
-        return R.ok();
-//        return retroactiveNowService.update(retroactiveNow);
+        return retroactiveNowService.update(retroactiveNow);
     }
 
 

+ 5 - 0
warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveNow.java

@@ -59,6 +59,11 @@ public class RetroactiveNow extends BaseEntity {
      */
     private String numberOfLayers;
 
+    /**
+     * 列内层
+     */
+    private String layerno;
+
     /**
      * 托盘号
      */

+ 6 - 1
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

@@ -191,12 +191,17 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     public R update(RetroactiveNow retroactiveNow) {
         RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
                 .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+                .eq (RetroactiveNow::getStatus, "6")
         );
         if (ObjectUtil.isNull(baseData)) {
             throw new ServiceException("数据库中不存在该批次号," + retroactiveNow.getBatchNo());
         }
-        baseData.setLotNo(retroactiveNow.getLotNo());
+        baseData.setUniuCode(retroactiveNow.getUniuCode());
+        baseData.setShelfNumber(retroactiveNow.getShelfNumber());
+        baseData.setLotAddress(retroactiveNow.getLotAddress());
+        baseData.setNumberOfLayers(retroactiveNow.getNumberOfLayers());
         retroactiveNowMapper.updateById(baseData);
+        mesService .tuiHuoShangLiao(baseData);
         return R.ok();
     }