wukai 2 месяцев назад
Родитель
Сommit
30afd4b1c4

+ 2 - 0
jjt-admin/src/main/resources/application-dev.yml

@@ -5,6 +5,8 @@ mssql:
   url: jdbc:sqlserver://192.168.66.133:31433;databaseName=WMS_V2_1
   user: MES
   pass: MES
+mes:
+  url: http://192.168.33.113
 # 数据源配置
 spring:
   # redis 配置

+ 2 - 0
jjt-admin/src/main/resources/application-devp.yml

@@ -5,6 +5,8 @@ mssql:
   url: jdbc:sqlserver://192.168.66.133:31433;databaseName=WMS_V2_1
   user: MES
   pass: MES
+mes:
+  url: http://192.168.33.113
 # 数据源配置
 spring:
   # redis 配置

+ 2 - 0
jjt-admin/src/main/resources/application-devt.yml

@@ -5,6 +5,8 @@ mssql:
   url: jdbc:sqlserver://192.168.66.133:31433;databaseName=WMS_V2_1
   user: MES
   pass: MES
+mes:
+  url: http://192.168.33.113
 # 数据源配置
 spring:
   # redis 配置

+ 2 - 0
jjt-admin/src/main/resources/application-prod.yml

@@ -5,6 +5,8 @@ mssql:
   url: jdbc:sqlserver://wmsdb.tlct.com.cn:1433;databaseName=WMS_V2_1
   user: MES
   pass: MES
+mes:
+  url: http://192.168.33.113
 # 数据源配置
 spring:
   # redis 配置

+ 2 - 0
jjt-admin/src/main/resources/application-test.yml

@@ -5,6 +5,8 @@ mssql:
   url: jdbc:sqlserver://192.168.33.153:1433;databaseName=WMS_V2_1
   user: MES
   pass: MES
+mes:
+  url: http://192.168.33.113
 # 数据源配置
 spring:
   # redis 配置

+ 82 - 0
jjt-admin/src/test/java/com/jjt/order/MesTest.java

@@ -0,0 +1,82 @@
+package com.jjt.order;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.jjt.JjtApplication;
+import com.jjt.biz.vo.OrderFlowerVO;
+import com.jjt.order.service.ITwinOrderService;
+import com.jjt.utils.MssqlService;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+import java.util.*;
+
+/**
+ * DataProcess$
+ *
+ * @author wukai
+ * @date 2024/5/7 11:49
+ */
+@SpringBootTest(classes = JjtApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class MesTest {
+    @Resource
+    private ITwinOrderService orderService;
+    //    @Resource
+//    private ITwinFormulaInfoService formulaInfoService;
+    @Resource
+    private MssqlService mssqlService;
+
+    public static void main(String[] args) {
+        Map<String, Map<String, Object>> map = new HashMap<>();
+        String url = "http://192.168.33.113/mes/api/v1/PmOrderFace4ZHENA/getOrderFlowerLister";
+        String result = HttpUtil.post(url, "{}");
+
+        // 解析JSON数据并放入List中
+        List<OrderFlowerVO> orderFlowers = parseOrderFlowers(result);
+
+        // 打印解析结果
+        for (OrderFlowerVO flower : orderFlowers) {
+            System.out.println(flower.toString());
+        }
+    }
+
+    /**
+     * 解析订单花型数据
+     * @param jsonResult JSON结果字符串
+     * @return 订单花型列表
+     */
+    private static List<OrderFlowerVO> parseOrderFlowers(String jsonResult) {
+        List<OrderFlowerVO> orderFlowers = new ArrayList<>();
+
+        // 解析JSON
+        JSONObject jsonObject = JSON.parseObject(jsonResult);
+        JSONArray dataObj = jsonObject.getJSONArray("dataObj");
+
+        if (dataObj != null) {
+            for (int i = 0; i < dataObj.size(); i++) {
+                JSONObject item = dataObj.getJSONObject(i);
+                OrderFlowerVO orderFlower = new OrderFlowerVO();
+
+                orderFlower.setBillNo(item.getString("BILLNO"));
+                orderFlower.setDefine11(item.getString("DEFINE11"));
+                orderFlower.setDefine12(item.getString("DEFINE12"));
+                orderFlower.setDefine20(item.getString("DEFINE20"));
+                orderFlower.setDefine28(item.getString("DEFINE28"));
+                orderFlower.setDefine29(item.getString("DEFINE29"));
+                orderFlower.setDefine31(item.getString("DEFINE31"));
+                orderFlower.setDefine32(item.getString("DEFINE32"));
+                orderFlower.setDefine33(item.getString("DEFINE33"));
+                orderFlower.setDefine45(item.getString("DEFINE45"));
+                orderFlower.setClientName(item.getString("CLIENT_NAME"));
+                orderFlower.setSorderNo(item.getString("SORDER_NO"));
+                orderFlower.setDeviceNo(item.getString("DEVICE_NO"));
+
+                orderFlowers.add(orderFlower);
+            }
+        }
+
+        return orderFlowers;
+    }
+}

+ 13 - 4
jjt-biz/src/main/java/com/jjt/biz/controller/ApiYrController.java

@@ -1,16 +1,14 @@
 package com.jjt.biz.controller;
 
 import com.jjt.biz.service.IApiYrService;
-import com.jjt.biz.vo.YrCompareBackReq;
-import com.jjt.biz.vo.YrCompareReq;
-import com.jjt.biz.vo.YrLineCurrVO;
-import com.jjt.biz.vo.YrTwinVO;
+import com.jjt.biz.vo.*;
 import com.jjt.common.constant.CacheConstants;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.R;
 import com.jjt.common.core.redis.RedisCache;
 import com.jjt.dye.domain.DyeHourLine;
 import com.jjt.dye.service.IDyeHourLineService;
+import com.jjt.utils.MesService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -20,6 +18,9 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * swagger 用户测试方法
@@ -38,6 +39,8 @@ public class ApiYrController extends BaseController {
     private String path;
     @Resource
     private IDyeHourLineService hourLineService;
+    @Resource
+    private MesService mesService;
 
     @ApiOperation("染整线数字孪生")
     @GetMapping("/api/yr/data")
@@ -47,6 +50,8 @@ public class ApiYrController extends BaseController {
         YrTwinVO vo = redisCache.getCacheObject(CacheConstants.RZ_MOCK);
         startPage();
         List<DyeHourLine> list = hourLineService.selectDyeHourLineListLast();
+        List<OrderFlowerVO> mesFlower = mesService.data();
+        Map<String, OrderFlowerVO> orderFlowerMap = mesFlower.stream().collect(Collectors.toMap(OrderFlowerVO::getLine, Function.identity()));
         List<YrLineCurrVO> currVOS = new ArrayList<>();
         list.forEach(dhl -> {
             YrLineCurrVO curr = new YrLineCurrVO();
@@ -54,6 +59,10 @@ public class ApiYrController extends BaseController {
             curr.setSpeed(dhl.getSpeed());
             curr.setTgTmp(dhl.getTmpTg());
             curr.setDxTmp(dhl.getTmpDx());
+
+            OrderFlowerVO orderFlowerVO = orderFlowerMap.get(dhl.getLine());
+            curr.setOrder(orderFlowerVO == null ? "" : orderFlowerVO.getBillNo());
+            curr.setColor(orderFlowerVO == null ? "" : orderFlowerVO.getDefine20() + "(" + orderFlowerVO.getDefine12() + ")");
             currVOS.add(curr);
         });
         vo.setCurr(currVOS);

+ 86 - 0
jjt-biz/src/main/java/com/jjt/biz/vo/OrderFlowerVO.java

@@ -0,0 +1,86 @@
+package com.jjt.biz.vo;
+
+import lombok.Data;
+
+/**
+ * 订单花型信息实体类
+ *
+ * @author wukai
+ */
+@Data
+public class OrderFlowerVO {
+    /**
+     * 订单号
+     */
+    private String billNo;
+
+    /**
+     * 花型编号
+     */
+    private String define11;
+
+    /**
+     * 艾弗色名称
+     */
+    private String define12;
+
+    /**
+     * 花型名称
+     */
+    private String define20;
+
+    /**
+     * 印花长度
+     */
+    private String define28;
+
+    /**
+     * 印花宽度
+     */
+    private String define29;
+
+    /**
+     * 前整定型宽度
+     */
+    private String define31;
+
+    /**
+     * 后整烘干下机幅宽
+     */
+    private String define32;
+
+    /**
+     * 后整烘干下机版长
+     */
+    private String define33;
+
+    /**
+     * 印花板数
+     */
+    private String define45;
+
+    /**
+     * 客户名称
+     */
+    private String clientName;
+
+    /**
+     * 销售单号
+     */
+    private String sorderNo;
+
+    /**
+     * 设备编号
+     */
+    private String deviceNo;
+
+    /**
+     * 产线
+     */
+    private String line;
+
+    public void setDeviceNo(String deviceNo) {
+    	this.deviceNo = deviceNo;
+    	this.line = deviceNo.substring(deviceNo.length() - 1);
+    }
+}

+ 69 - 0
jjt-biz/src/main/java/com/jjt/utils/MesService.java

@@ -0,0 +1,69 @@
+package com.jjt.utils;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.jjt.biz.vo.OrderFlowerVO;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author wukai
+ */
+@Service
+public class MesService {
+    @Value("${mes.url}")
+    private String mesUrl;
+
+    public List<OrderFlowerVO> data() {
+        Map<String, Map<String, Object>> map = new HashMap<>();
+        String url = mesUrl + "/mes/api/v1/PmOrderFace4ZHENA/getOrderFlowerLister";
+        String result = HttpUtil.post(url, "{}");
+        // 解析JSON数据并放入List中
+        return parseOrderFlowers(result);
+    }
+
+
+    /**
+     * 解析订单花型数据
+     *
+     * @param jsonResult JSON结果字符串
+     * @return 订单花型列表
+     */
+    private List<OrderFlowerVO> parseOrderFlowers(String jsonResult) {
+        List<OrderFlowerVO> orderFlowers = new ArrayList<>();
+
+        // 解析JSON
+        JSONObject jsonObject = JSON.parseObject(jsonResult);
+        JSONArray dataObj = jsonObject.getJSONArray("dataObj");
+
+        if (dataObj != null) {
+            for (int i = 0; i < dataObj.size(); i++) {
+                JSONObject item = dataObj.getJSONObject(i);
+                OrderFlowerVO orderFlower = new OrderFlowerVO();
+                orderFlower.setBillNo(item.getString("BILLNO"));
+                orderFlower.setDefine11(item.getString("DEFINE11"));
+                orderFlower.setDefine12(item.getString("DEFINE12"));
+                orderFlower.setDefine20(item.getString("DEFINE20"));
+                orderFlower.setDefine28(item.getString("DEFINE28"));
+                orderFlower.setDefine29(item.getString("DEFINE29"));
+                orderFlower.setDefine31(item.getString("DEFINE31"));
+                orderFlower.setDefine32(item.getString("DEFINE32"));
+                orderFlower.setDefine33(item.getString("DEFINE33"));
+                orderFlower.setDefine45(item.getString("DEFINE45"));
+                orderFlower.setClientName(item.getString("CLIENT_NAME"));
+                orderFlower.setSorderNo(item.getString("SORDER_NO"));
+                orderFlower.setDeviceNo(item.getString("DEVICE_NO"));
+                orderFlowers.add(orderFlower);
+            }
+        }
+
+        return orderFlowers;
+    }
+}