|
@@ -0,0 +1,328 @@
|
|
|
+package com.github.zuihou.business.util;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.github.zuihou.business.externalApi.dto.ManualInfo;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 自动模式下参数组装
|
|
|
+ */
|
|
|
+public class AutoTaskOperatorUtil {
|
|
|
+ /**
|
|
|
+ * 上位机系统地址
|
|
|
+ */
|
|
|
+// private static String hostSyetemUrl = "http://192.168.170.240:8090";
|
|
|
+ private static String hostSyetemUrl = "http://192.168.10.155:63570/";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * agv运输
|
|
|
+ */
|
|
|
+ private static String agvURL = "http://localhost:9099/api/authority/mock/mockWms";
|
|
|
+ //质量中心
|
|
|
+ private static String ZK_ip_zlzx = "192.168.170.61";
|
|
|
+ //柔性
|
|
|
+ private static String ZK_ip_rxx = "192.168.170.71";
|
|
|
+ //智能单元
|
|
|
+ private static String ZK_ip_zndy = "192.168.170.81";
|
|
|
+
|
|
|
+ // 质量中心PLC端口
|
|
|
+ private static String ZK_ip_zlzx_port = "102";
|
|
|
+ // 柔性线端口
|
|
|
+ private static String ZK_ip_rxx_port = "102";
|
|
|
+ // 智能单元端口
|
|
|
+ private static String ZK_ip_zndy_port = "102";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装参数
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getRequestParam(Map<String, Object> map){
|
|
|
+ JSONObject jsonParam = new JSONObject();
|
|
|
+ jsonParam.put("url", map.get("deviceUrl").toString());
|
|
|
+ jsonParam.put("port",map.get("devicePort").toString());
|
|
|
+ jsonParam.put("taskId", map.get("taskId").toString());
|
|
|
+ jsonParam.put("taskNodeId", map.get("taskNodeId").toString());
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ String jobType = map.get("bizType").toString();
|
|
|
+
|
|
|
+ if("execProgram".equals(jobType)) {
|
|
|
+ // 执行程序
|
|
|
+ data.put("remotePath", map.get("execProgram"));
|
|
|
+ }else if("clean".equals(jobType)) {
|
|
|
+ // 清洗
|
|
|
+ data.put("workId", map.get("workId").toString());
|
|
|
+ data.put("workType", map.get("workType").toString());
|
|
|
+ }else if("print".equals(jobType)) {
|
|
|
+ // 打标
|
|
|
+ data.put("workId", map.get("workId").toString());
|
|
|
+ data.put("labelContent", map.get("labelContent").toString());
|
|
|
+ }else if("measuring".equals(jobType)) {
|
|
|
+ // 测量
|
|
|
+ data.put("workId", map.get("workId").toString());
|
|
|
+ data.put("workType", map.get("workType").toString());
|
|
|
+ }else{
|
|
|
+ // 机器人相关
|
|
|
+ data.put("location", map.get("location").toString());
|
|
|
+ }
|
|
|
+ jsonParam.put("data", data);
|
|
|
+
|
|
|
+ return jsonParam.toJSONString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理自动模式首次任务结点信息
|
|
|
+ * @param robotTaskNodes
|
|
|
+ * @param robotNoMoveTaskNodes
|
|
|
+ * @param manualInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Map<String,Object> judgeFirstProcessInfo(Map<String, Object> map , ArrayList<String> robotTaskNodes, ArrayList<String> robotNoMoveTaskNodes , ManualInfo manualInfo){
|
|
|
+ Map<String,Object> processInfo = new HashMap<String,Object>();
|
|
|
+ String unit = map.get("unit").toString();
|
|
|
+ String jobType = map.get("jobType").toString();
|
|
|
+ String deviceUrl = "";
|
|
|
+ String devicePort = "";
|
|
|
+ // Plc地址
|
|
|
+ if("capsule".equals(unit)){
|
|
|
+ deviceUrl = ZK_ip_zndy;
|
|
|
+ devicePort = ZK_ip_zndy_port;
|
|
|
+ }else if("framework".equals(unit)){
|
|
|
+ deviceUrl = ZK_ip_zndy;
|
|
|
+ devicePort = ZK_ip_zndy_port;
|
|
|
+ }else if("safeguard".equals(unit)){
|
|
|
+ deviceUrl = ZK_ip_zndy;
|
|
|
+ devicePort = ZK_ip_zndy_port;
|
|
|
+ }
|
|
|
+ if("general".equals(jobType)){
|
|
|
+ if("capsule".equals(unit)){
|
|
|
+ // 舱体(智能单元) 代码先写死,6个动作,后续根据resource_code表中获取
|
|
|
+ // 执行第一个任务
|
|
|
+ int currentIndex = 0;
|
|
|
+ String taskType = robotNoMoveTaskNodes.get(currentIndex);
|
|
|
+ int nextTaskNodeIndex = currentIndex +1;
|
|
|
+ if("move".equals(taskType)){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/MoveRobotPosition";
|
|
|
+ //String location = manualInfo.getStartpointId();
|
|
|
+ String location = map.get("startPointId").toString();
|
|
|
+ setProcessInfo(robotNoMoveTaskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ if(nextTaskNodeIndex < robotNoMoveTaskNodes.size() -1){
|
|
|
+ manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex + 1);
|
|
|
+ }
|
|
|
+ }else if("framework".equals(unit)){
|
|
|
+ int currentIndex = 0;
|
|
|
+ String taskType = robotNoMoveTaskNodes.get(currentIndex);
|
|
|
+ int nextTaskNodeIndex = currentIndex +1;
|
|
|
+ if("move".equals(taskType)){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/MoveRobotPosition";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(robotNoMoveTaskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ if(nextTaskNodeIndex < robotNoMoveTaskNodes.size() -1){
|
|
|
+ manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex + 1);
|
|
|
+ }
|
|
|
+ }else if("safeguard".equals(unit)){
|
|
|
+ // 保障平台(质量中心) 代码先写死,6个动作,后续根据resource_code表中获取
|
|
|
+ // 执行第一个任务
|
|
|
+ int currentIndex = 0;
|
|
|
+ String taskType = robotNoMoveTaskNodes.get(currentIndex);
|
|
|
+ int nextTaskNodeIndex = currentIndex +1;
|
|
|
+ if("get".equals(taskType)){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(robotNoMoveTaskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 设备相关
|
|
|
+ processMachineAutoType(map, processInfo, manualInfo);
|
|
|
+ manualInfo.setNextTaskNodeIndex(-1);
|
|
|
+ }
|
|
|
+ return processInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设备执行程序通用
|
|
|
+ * @param manualInfo
|
|
|
+ * @param processInfo
|
|
|
+ * @param
|
|
|
+ */
|
|
|
+ private static void processMachineAutoType(Map<String, Object> map, Map<String, Object> processInfo,ManualInfo manualInfo) {
|
|
|
+ String jobType = map.get("bizType").toString();
|
|
|
+ String taskNode = map.get("taskNode").toString();
|
|
|
+ String deviceUrl = map.get("deviceUrl").toString();
|
|
|
+ String devicePort = map.get("devicePort").toString();
|
|
|
+ String location = map.get("location").toString();
|
|
|
+
|
|
|
+ if("execProgram".equals(jobType)) {
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/StartNCProgram";
|
|
|
+ //String location = manualInfo.getStartpointId();
|
|
|
+
|
|
|
+ // 查找设备ip及端口
|
|
|
+ setProcessInfo( new ArrayList(), processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("clean".equals(jobType)) {
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/StartCleanMachine";
|
|
|
+ setProcessInfo( new ArrayList(), processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("print".equals(jobType)) {
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/StartLabelMachine";
|
|
|
+ setProcessInfo( new ArrayList(), processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("measuring".equals(jobType)) {
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/StartCoordinateMeasuringMachine";
|
|
|
+ setProcessInfo( new ArrayList(), processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理自动模式回调任务结点信息
|
|
|
+ * @param taskNodes
|
|
|
+ * @param manualInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Map<String,Object> judgeProcessInfo(ArrayList<String> taskNodes, ManualInfo manualInfo){
|
|
|
+ String unit = manualInfo.getDeviceUnit();
|
|
|
+ String manualType = manualInfo.getManualIdType();
|
|
|
+ Map<String,Object> processInfo = new HashMap<String,Object>();
|
|
|
+
|
|
|
+ String deviceUrl = "";
|
|
|
+ String devicePort = "";
|
|
|
+ // Plc地址
|
|
|
+ if("capsule".equals(unit)){
|
|
|
+ deviceUrl = ZK_ip_zndy;
|
|
|
+ devicePort = ZK_ip_zndy_port;
|
|
|
+ }else if("framework".equals(unit)){
|
|
|
+ deviceUrl = ZK_ip_zndy;
|
|
|
+ devicePort = ZK_ip_zndy_port;
|
|
|
+ }else if("safeguard".equals(unit)){
|
|
|
+ deviceUrl = ZK_ip_zndy;
|
|
|
+ devicePort = ZK_ip_zndy_port;
|
|
|
+ }
|
|
|
+
|
|
|
+ if("general".equals(manualType)){
|
|
|
+ if("capsule".equals(unit)){
|
|
|
+ int currentIndex = manualInfo.getNextTaskNodeIndex();
|
|
|
+ int nextTaskNodeIndex = currentIndex +1;
|
|
|
+ String taskType = taskNodes.get(currentIndex);
|
|
|
+
|
|
|
+ if(taskNodes.size() == 6){
|
|
|
+ // 舱体(柔性线) 代码先写死,6个动作,后续根据resource_code表中获取
|
|
|
+ // 执行第一个任务
|
|
|
+ if("get".equals(taskType) && currentIndex == 1){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("put".equals(taskType) && currentIndex == 2){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("move".equals(taskType) && currentIndex == 3){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/MoveRobotPosition";
|
|
|
+
|
|
|
+ // 查找设备机器人
|
|
|
+
|
|
|
+
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }if("get".equals(taskType) && currentIndex == 4){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("put".equals(taskType) && currentIndex == 5){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
|
|
|
+ }else if(taskNodes.size() == 3 && currentIndex == 1){
|
|
|
+ if("get".equals(taskType) ){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("put".equals(taskType) && currentIndex == 2){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
|
|
|
+ String location = manualInfo.getEndpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if("framework".equals(unit)){
|
|
|
+ int currentIndex = manualInfo.getNextTaskNodeIndex();
|
|
|
+ int nextTaskNodeIndex = currentIndex +1;
|
|
|
+ String taskType = taskNodes.get(currentIndex);
|
|
|
+
|
|
|
+ if(taskNodes.size() == 6){
|
|
|
+ // 舱体(柔性线) 代码先写死,6个动作,后续根据resource_code表中获取
|
|
|
+ // 执行第一个任务
|
|
|
+ if("get".equals(taskType) && currentIndex == 1){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("put".equals(taskType) && currentIndex == 2){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("move".equals(taskType) && currentIndex == 3){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/MoveRobotPosition";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }if("get".equals(taskType) && currentIndex == 4){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("put".equals(taskType) && currentIndex == 5){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
|
|
|
+ }else if(taskNodes.size() == 3){
|
|
|
+ if("get".equals(taskType) && currentIndex == 1){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
|
|
|
+ String location = manualInfo.getStartpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }else if("put".equals(taskType) && currentIndex == 2){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
|
|
|
+ String location = manualInfo.getEndpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if("safeguard".equals(unit)){
|
|
|
+ int currentIndex = manualInfo.getNextTaskNodeIndex();
|
|
|
+ int nextTaskNodeIndex = currentIndex +1;
|
|
|
+ String taskType = taskNodes.get(currentIndex);
|
|
|
+ // 保障平台(质量中心)
|
|
|
+ // 执行第一个任务
|
|
|
+ if("put".equals(taskType)){
|
|
|
+ String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
|
|
|
+ String location = manualInfo.getEndpointId();
|
|
|
+ setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
|
|
|
+ }
|
|
|
+ manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return processInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param taskNodes
|
|
|
+ * @param processInfo
|
|
|
+ * @param hostSyetemTaskUrl
|
|
|
+ * @param location
|
|
|
+ * @param deviceUrl
|
|
|
+ * @param devicePort
|
|
|
+ */
|
|
|
+ private static void setProcessInfo(ArrayList<String> taskNodes, Map<String, Object> processInfo, String hostSyetemTaskUrl, String location, String deviceUrl, String devicePort) {
|
|
|
+ processInfo.put("hostSyetemTaskUrl", hostSyetemTaskUrl);
|
|
|
+ processInfo.put("deviceUrl", deviceUrl);
|
|
|
+ processInfo.put("devicePort", devicePort);
|
|
|
+ processInfo.put("location", location);
|
|
|
+ processInfo.put("remindTaskNodes", taskNodes);
|
|
|
+ }
|
|
|
+}
|