Browse Source

添加调用接口ip和端口

yejian 3 years ago
parent
commit
7536047bea

+ 3 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -252,6 +252,7 @@ public class TaskWorkNode {
                     //动态调用接口
                     String instructionUrl = DictionaryKey.INSTRUCTION_URL +"/api/"+ conMap.get("method").toString() ;
                     returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
+                    logger.info("returnData=", returnData);
                 }
             }
         } catch (Exception e) {
@@ -336,8 +337,8 @@ public class TaskWorkNode {
         jsonObject.put("data", conMap.get("data"));
         jsonObject.put("bizType", bizType);
         //jsonObject.put("uid", taskNode.getCreateUser() + "");
-        jsonObject.put("url",  task.getIp());
-        jsonObject.put("port", task.getPort());
+        jsonObject.put("url",  conMap.get("url"));
+        jsonObject.put("port", conMap.get("port"));
 
         //业务回调数据
         JSONObject bizJsonObject = new JSONObject();

+ 20 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/MachineNodeServiceImpl.java

@@ -23,10 +23,12 @@ import com.github.zuihou.business.productionReadyCenter.service.BomProcedureServ
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
 import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.business.productionResourceCenter.entity.ZZoneProductionresource;
 import com.github.zuihou.business.productionResourceCenter.service.NodeOperationService;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneProductionresourceService;
+import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.DictionaryKey;
 import com.github.zuihou.common.util.StringUtil;
@@ -87,6 +89,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
     @Autowired
     private ZZoneProductionresourceService zZoneProductionresourceService;
+    @Autowired
+    private ZZoneService zoneService;
 
     private Map<String, Object> map = Maps.newHashMap();
 
@@ -108,6 +112,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
     private List<ProductionresourcePosition> deviceList;
 
     private Long zone_id;
+    private Map<String, String> plcInfo;
+    private ZZone zZone;
 
     @Override
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
@@ -126,6 +132,11 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         //获取产线ID
         ZZoneProductionresource zZoneProductionresource = zZoneProductionresourceService.getOne(new LbqWrapper<ZZoneProductionresource>().eq(ZZoneProductionresource::getResourceId, taskNode.getResourceId()));
         zone_id = zZoneProductionresource.getZoneId();
+
+
+        zZone = zoneService.getById(zone_id);
+        // 判断该节点使用那条线的plc
+        plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
     }
 
     @Override
@@ -188,12 +199,15 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 //                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
                     //获取打标指令编码
                     map.put("method", moduleInstructions.get(0).getCode());
+                    map.put("url",plcInfo.get("url"));
+                    map.put("port",plcInfo.get("port"));
                     //获取打标唯一码
                     String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
                     JSONObject data = new JSONObject();
                     //默认配置  后期可改可去
                     data.put("workId", "1");
                     data.put("labelContent", unionCode);
+                    data.put("workId", "1");
                     map.put("data", data);//打标内容
                     map.put("result", true);
                 }
@@ -213,6 +227,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                         });
                         //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
                         map.put("method", "UploadFile");
+                        map.put("url",task.getIp());
+                        map.put("port",task.getPort());
                         JSONObject data = new JSONObject();
                         data.put("fileName", fileList.get(0).get("fileName"));
                         map.put("data", data);
@@ -284,6 +300,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "Clean");
                     //获取打标指令编码
                     map.put("method", moduleInstructions.get(0).getCode());
+                    map.put("url",plcInfo.get("url"));
+                    map.put("port",plcInfo.get("port"));
                     map.put("result", true);
                 }
                 break;
@@ -301,6 +319,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     data.put("workType", "1111");
                     //map.put("data", JSONObject.toJSONString(queryMap));
                     map.put("method", moduleInstructions.get(0).getCode());
+                    map.put("url",plcInfo.get("url"));
+                    map.put("port",plcInfo.get("port"));
                     map.put("data", data);
                     map.put("result", true);
                 }

+ 13 - 3
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl.java

@@ -122,6 +122,12 @@ public class RobotNodeServiceImpl implements NodeOperationService {
     private ZZone zZone;
 
     private Long bomZzoneId;
+    // Plc url
+    private String url;
+    // Plc port
+    private String port;
+
+    private Map<String, String> plcInfo;
 
     @Override
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
@@ -147,10 +153,13 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         //获取产线ID
         zoneId = zoneProductionresource.getZoneId();
         zZone = zoneService.getById(zoneId);
-        zoneName = zoneService.getById(zoneId).getName();
+        zoneName = zZone.getName();
         BBom bom = bBomMapper.selectById(task.getBomId());
         bomZzoneId = bom.getZoneId();
-        task.getBomId();
+
+        // 判断该节点使用那条线的plc
+        plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
+
     }
 
     @Override
@@ -322,7 +331,8 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 map.put("deviceUrl", ZK_ip_rxx);
                 break;
         }
-
+        map.put("url",plcInfo.get("url"));
+        map.put("port",plcInfo.get("port"));
         return map;
     }