瀏覽代碼

手动模式

yaoyq 3 年之前
父節點
當前提交
12e58189c5

+ 183 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/HandModeWorkNode.java

@@ -0,0 +1,183 @@
+package com.github.zuihou.business.mq;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.zuihou.business.DemoLine.DemoCacheKey;
+import com.github.zuihou.business.edgeLibrary.service.StorgeService;
+import com.github.zuihou.business.operationManagementCenter.dao.OrderMapper;
+import com.github.zuihou.business.operationManagementCenter.dao.PlanMapper;
+import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
+import com.github.zuihou.business.operationManagementCenter.dao.TaskNodeMapper;
+import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
+import com.github.zuihou.business.productionReadyCenter.dao.AutoNodeLogMapper;
+import com.github.zuihou.business.productionResourceCenter.service.NodeOperationService;
+import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.business.productionResourceCenter.service.impl.AGVNodeServiceImpl;
+import com.github.zuihou.business.productionResourceCenter.service.impl.MachineNodeServiceImpl;
+import com.github.zuihou.business.util.MsgUtil;
+import com.github.zuihou.common.constant.DictionaryKey;
+import com.github.zuihou.common.enums.HandModeTypeEnum;
+import com.github.zuihou.common.util.StringUtil;
+import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
+import com.github.zuihou.tenant.entity.Module;
+import com.github.zuihou.tenant.entity.Productionresource;
+import com.github.zuihou.tenant.service.ModuleService;
+import com.github.zuihou.tenant.service.ProductionresourceService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Map;
+
+@Component
+public class HandModeWorkNode {
+    @Autowired
+    private RestTemplate restTemplate;
+
+    private String url = "http://127.0.0.1:8764/task/testTask";
+
+    private String plcURL = "http://192.168.170.202:8089";
+
+    private String agvURL = "http://localhost:9099/api/authority/mock/mockWms";
+    //质量中心
+    private String ZK_ip_zlzx = "192.168.170.61";
+    //柔性
+    private String ZK_ip_rxx = "192.168.170.71";
+    //智能单元
+    private String ZK_ip_zndy = "192.168.170.81";
+
+    //总控端口
+    private String ZK_port = "120";
+
+
+    private static Logger logger = LoggerFactory.getLogger(HandModeWorkNode.class);
+
+    public String handMode(Map map) {
+        String bizType = map.get("bizType").toString();
+        String interfaceType = getInterfaceType(bizType);
+        String autoProgrameUrl = getInterfaceUrl(interfaceType);
+
+        String returnData = "";
+
+        //组装接口参数
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
+        String jsonParam = getRequestParam(map);
+        HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
+        //调用接口
+        try {
+            returnData = restTemplate.postForObject(autoProgrameUrl, formEntity, String.class);
+        }catch (Exception e) {
+            e.printStackTrace();
+            JSONObject errJsonObject = new JSONObject();
+            errJsonObject.put("msg", e.getMessage());
+            returnData = errJsonObject.toJSONString();
+            logger.error("调用接口发生异常" + e.getMessage());
+        }
+        return returnData;
+    }
+
+
+    /**
+     * 获取请求URL
+     *
+     * @param interfaceType
+     * @return
+     */
+    public String getInterfaceUrl(String interfaceType) {
+        String autoProgrameUrl = "";
+        if (DictionaryKey.INTERFACETYPE_PLC.equals(interfaceType)) {//总控
+            autoProgrameUrl = plcURL;
+        } else if (DictionaryKey.INTERFACETYPE_PRO.equals(interfaceType)) {
+//            autoProgrameUrl = parameterService.getValue(ParameterKey.AUTOPROGRAMEURL, null);
+            autoProgrameUrl = plcURL;
+        } else if (DictionaryKey.INTERFACETYPE_AGV.equals(interfaceType)) {
+//            autoProgrameUrl = parameterService.getValue(ParameterKey.AGVPROGRAMEURL, null);
+            autoProgrameUrl = agvURL;
+            //           autoProgrameUrl = url;
+        } else if (DictionaryKey.INTERFACETYPE_WMS.equals(interfaceType)) {
+//            autoProgrameUrl = parameterService.getValue(ParameterKey.AGVPROGRAMEURL, null);
+            // autoProgrameUrl = agvURL;
+            autoProgrameUrl = url;
+        }
+        //正式调试的时候注释掉
+        autoProgrameUrl = url;
+        return autoProgrameUrl;
+    }
+
+
+
+    /**
+     * 生成请求参数
+     *
+     * @param conMap
+     * @return
+     */
+    public String getRequestParam(Map conMap) {
+        //业务类型
+        String bizType = conMap.get("bizType").toString();
+
+        //获取接口类型
+        String interfaceType = getInterfaceType(bizType);
+
+        String startPointId = conMap.get("startPointId")==null?"":conMap.get("startPointId").toString();
+        String endPointId = conMap.get("endPointId")==null?"":conMap.get("endPointId").toString();
+
+
+        //回调参数构建
+        JSONObject jsonObject = new JSONObject();
+        //业务回调数据
+        JSONObject bizJsonObject = new JSONObject();
+
+
+        if (StringUtil.isNotEmpty(startPointId)) {
+            bizJsonObject.put("srcPosition", startPointId);
+        }
+        if (StringUtil.isNotEmpty(endPointId)) {
+            bizJsonObject.put("targetPostion", endPointId);
+        }
+        //需要回调
+        jsonObject.put("IsCallBackFlag", "1");
+
+        //机器上下料相关
+        if (DictionaryKey.INTERFACETYPE_PLC.equals(interfaceType)) {
+            //传入数据给回调方法,方便进行数据操作
+//            jsonObject.put("url", zkIp);
+            jsonObject.put("port", ZK_port);
+            jsonObject.put("IsCallBackFlag", "1");
+        }
+        else if (DictionaryKey.INTERFACETYPE_PRO.equals(interfaceType)) {
+            //生产加工
+        } else if (DictionaryKey.INTERFACETYPE_AGV.equals(interfaceType)) {
+        }
+        else if (DictionaryKey.INTERFACETYPE_WMS.equals(interfaceType)) {
+        }
+
+        //业务回调数据,传给接口,接口再返回过来。
+        jsonObject.put("bizCallBackData", bizJsonObject.toJSONString());
+        //调试得时候打开
+        jsonObject.put("code", "1");
+        return jsonObject.toJSONString();
+    }
+
+
+    private String getInterfaceType(String bizType){
+        String interfaceType ="";
+        if(HandModeTypeEnum.HandMode_TypeR1.getBizType().equals(bizType)||HandModeTypeEnum.HandMode_TypeR2.getBizType().equals(bizType)||HandModeTypeEnum.HandMode_TypeR3.getBizType().equals(bizType)
+        ||HandModeTypeEnum.HandMode_TypeL1.getBizType().equals(bizType)||HandModeTypeEnum.HandMode_TypeW1.getBizType().equals(bizType)){//PLC相关
+            interfaceType = DictionaryKey.INTERFACETYPE_PLC;
+        }else if(HandModeTypeEnum.HandMode_TypeA1.getBizType().equals(bizType)){
+            interfaceType = DictionaryKey.INTERFACETYPE_AGV;
+        }else if(HandModeTypeEnum.HandMode_TypeM1.getBizType().equals(bizType)||HandModeTypeEnum.HandMode_TypeM2.getBizType().equals(bizType)){
+            interfaceType = DictionaryKey.INTERFACETYPE_AGV;
+        }
+        return interfaceType;
+    }
+
+
+}
+

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/WorkpieceService.java

@@ -34,7 +34,7 @@ public interface WorkpieceService extends SuperService<TWorkpiece> {
     public List<ProductionresourcePosition> getAllStockInfo();
 
     //执行非订单物品
-    public void execute(Map map);
+    public String execute(Map map);
 
 
 }

+ 6 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/WorkpieceServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.base.service.SuperServiceImpl;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
+import com.github.zuihou.business.mq.HandModeWorkNode;
 import com.github.zuihou.business.operationManagementCenter.dao.*;
 import com.github.zuihou.business.operationManagementCenter.dto.OrderProductUpdateDTO;
 import com.github.zuihou.business.operationManagementCenter.dto.OrderUpdateDTO;
@@ -65,6 +66,9 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
     @Autowired
     private TaskNodeService taskNodeService;
 
+    @Autowired
+    private HandModeWorkNode handModeWorkNode;
+
     @Override
     public IPage<TWorkpiece> pageList(IPage page, LbqWrapper<TWorkpiece> wrapper) {
         return baseMapper.pageList(page, wrapper);
@@ -126,7 +130,7 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
     }
 
     @Override
-    public void execute(Map map) {
-
+    public String  execute(Map map) {
+       return handModeWorkNode.getRequestParam(map);
     }
 }

+ 1 - 2
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/WorkpieceController.java

@@ -147,8 +147,7 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
     @ApiOperation(value = "手动执行(非订单)", notes = "手动执行(非订单)")
     @PostMapping("/handMode/execute")
     public R<String>  execute(@RequestBody Map map) {
-        baseService.execute(map);
-        return success("");
+        return success(baseService.execute(map));
     }
 
 

+ 74 - 0
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/enums/HandModeTypeEnum.java

@@ -0,0 +1,74 @@
+package com.github.zuihou.common.enums;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import java.util.stream.Stream;
+
+/**
+ * wsm
+ *
+ * @author
+ * @date 2018/12/29
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+@Getter
+@ApiModel(value = "HandModeTypeEnum", description = "手动模式业务类型")
+public enum HandModeTypeEnum {
+    /**
+     * R1
+     */
+    HandMode_TypeR1("R1", "机器人移动"),
+    /**
+     * R2
+     */
+    HandMode_TypeR2("R2", "机器人拿"),
+    /**
+     * R3
+     */
+    HandMode_TypeR3("R3", "机器人放"),
+    /**
+     * R4
+     */
+    HandMode_TypeA1("A1", "AGV移动"),
+    /**
+     * R5
+     */
+    HandMode_TypeM1("M1", "下发程序"),
+
+    /**
+     * R6
+     */
+    HandMode_TypeM2("M2", "执行程序"),
+
+
+    HandMode_TypeL1("L1", "打标"),
+
+    HandMode_TypeW1("W1", "清洗");
+
+    @ApiModelProperty(value = "业务类型")
+    private String bizType;
+    @ApiModelProperty(value = "业务类型描述")
+    private String desc;
+
+    public static String matchKey(String val, HandModeTypeEnum def) {
+        return Stream.of(values()).parallel().filter((item) -> item.getBizType().equalsIgnoreCase(val)).findAny().orElse(def).getDesc();
+    }
+
+    public static String matchValue(String val, HandModeTypeEnum def) {
+        return Stream.of(values()).parallel().filter((item) -> item.getDesc().equalsIgnoreCase(val)).findAny().orElse(def).getDesc();
+    }
+
+    public static String getKey(String val) {
+        return matchValue(val, null);
+    }
+
+    public static String getValue(String val) {
+        return matchKey(val, null);
+    }
+
+}