|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|