Browse Source

Merge branch 'master' of http://106.15.38.8:3000/yaoyq/imcs-yj-be into master

姚云青 3 years ago
parent
commit
c495f6b04c

+ 7 - 6
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/MqInit.java

@@ -54,14 +54,15 @@ public class MqInit implements ApplicationRunner {
                 dynamicRabbitMq.startListener(id.toString());
             }
         }
+        //资源数据中已包含项目设定的线边库设备(七个) MQ关联使用ID直接访问
 
         //添加三个线边库轮询虚拟的MQ
-        dynamicRabbitMq.addQueue(DemoLineConstant.NODE_RESOURCE_ZLZX_XBK);
-        dynamicRabbitMq.startListener(DemoLineConstant.NODE_RESOURCE_ZLZX_XBK);
-        dynamicRabbitMq.addQueue(DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK);
-        dynamicRabbitMq.startListener(DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK);
-        dynamicRabbitMq.addQueue(DemoLineConstant.NODE_RESOURCE_RXSC_XBK);
-        dynamicRabbitMq.startListener(DemoLineConstant.NODE_RESOURCE_RXSC_XBK);
+//        dynamicRabbitMq.addQueue(DemoLineConstant.NODE_RESOURCE_ZLZX_XBK);
+//        dynamicRabbitMq.startListener(DemoLineConstant.NODE_RESOURCE_ZLZX_XBK);
+//        dynamicRabbitMq.addQueue(DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK);
+//        dynamicRabbitMq.startListener(DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK);
+//        dynamicRabbitMq.addQueue(DemoLineConstant.NODE_RESOURCE_RXSC_XBK);
+//        dynamicRabbitMq.startListener(DemoLineConstant.NODE_RESOURCE_RXSC_XBK);
     }
 }
 

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

@@ -223,8 +223,9 @@ public class TaskWorkNode {
                 headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
                 String jsonParam = getRequestParam(conMap);
                 HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
-                //调用接口
-                returnData = restTemplate.postForObject(autoProgrameUrl, formEntity, String.class);
+                //动态调用接口
+                String instructionUrl = DictionaryKey.INSTRUCTION_URL +"/api/"+ conMap.get("method").toString() ;
+                returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -237,6 +238,8 @@ public class TaskWorkNode {
         logger.info("===============================接口返回" + returnData);
         JSONObject retJson = JSONObject.parseObject(returnData);
         if(jsonObject.getString("Code").trim() == "1") {
+            //回调处理
+
             taskNode.setExeStatus("3").setEndTime(new Date()).setExeResult("1");
             taskNodeService.updateAllById(taskNode);
             log.setExeStatus("3").setEndTime(new Date()).setExeResult("1");
@@ -292,16 +295,15 @@ public class TaskWorkNode {
         String bizType = conMap.get("bizType").toString();
         //出入库类型
         String stockType = conMap.get(DemoLineConstant.DEMOLINE_STOCK_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_STOCK_TYPE).toString();
-        ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
 
         JSONObject jsonObject = new JSONObject();
         //jsonObject.put("businessType", taskNode.getAutoNodeCode());
         jsonObject.put("taskId", taskNode.getTaskId());
         jsonObject.put("taskNodeId", taskNode.getId());
-        jsonObject.put("uid", taskNode.getCreateUser() + "");
-        //jsonParam.put("url",deviceUrl);
-        //jsonParam.put("port",devicePort);
-
+        jsonObject.put("data", conMap.get("data"));
+        //jsonObject.put("uid", taskNode.getCreateUser() + "");
+        jsonObject.put("url",  task.getIp());
+        jsonObject.put("port", task.getPort());
 
         //业务回调数据
         JSONObject bizJsonObject = new JSONObject();
@@ -310,6 +312,7 @@ public class TaskWorkNode {
             bizJsonObject.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, stockType);
         }
 
+        /*
         //机器上下料相关
         if (DictionaryKey.INTERFACETYPE_PLC.equals(taskNode.getInterfaceType())) {
             //String location = conMap.get("location").toString();
@@ -317,76 +320,6 @@ public class TaskWorkNode {
             Map map = nodeOperationService.operation(jsonObject, bizJsonObject, conMap);
             jsonObject = (JSONObject) map.get("jsonObject");
             bizJsonObject = (JSONObject) map.get("bizJsonObject");
-
-            /*
-            String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
-                    : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
-            //总控IP
-            String zkIp = conMap.get("zkIp") == null ? "" : conMap.get("zkIp").toString();
-            jsonObject.put("url", zkIp);
-            jsonObject.put("port", ZK_port);
-            jsonObject.put("IsCallBackFlag", "1");
-
-            Storge fstorge = (Storge) conMap.get("fromStorge");
-            Storge tstorge = (Storge) conMap.get("toStorge");
-            //线边库标志
-            String xbkFlag = conMap.get(DemoLineConstant.DEMOLINE_XBKFLAG) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_XBKFLAG).toString();
-            //线边库类型(质量中心、智能生产、柔性)
-            String xbkType = conMap.get(DemoLineConstant.DEMOLINE_XBK_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_XBK_TYPE).toString();
-            //柔性机器人搬运标志
-            String rxjqrFlag = conMap.get(DemoLineConstant.DEMOLINE_RXJQR_FLAG) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_RXJQR_FLAG).toString();
-
-            String rxjqrNoMoveFlag = conMap.get(DemoLineConstant.DEMOLINE_RXJQR_NOMOVE_FLAG) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_RXJQR_NOMOVE_FLAG).toString();
-            //换手标志
-            String jqrhsFlag = conMap.get(DemoLineConstant.DEMOLINE_CHANGEHAND_FLAG) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_CHANGEHAND_FLAG).toString();
-            //搬运类型(区分是具体哪一步的搬运)
-            String carryType = conMap.get(DemoLineConstant.DEMOLINE_XBK_CARRY_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_XBK_CARRY_TYPE).toString();
-            String carryRequest = conMap.get(DemoLineConstant.DEMOLINE_BIZ_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_BIZ_TYPE).toString();
-            String count = conMap.get(taskNode.getId().toString() + "count") == null ? "" : conMap.get(taskNode.getId().toString() + "count").toString();
-            jsonObject.put("BusinessType", carryRequest);
-            //传参数--起始终点位置
-            if ("testwork".equals(carryRequest) || "print".equals(carryRequest)) {
-                //三坐标的Data参数比较特殊
-                String data = conMap.get("Data") == null ? null : conMap.get("Data").toString();
-                jsonObject.put("Data", data);
-            } else {
-                Storge datastorge = conMap.get("Data") == null ? null : (Storge) conMap.get("Data");
-                if (datastorge != null) {
-                    jsonObject.put("Data", storgeService.getPointId(datastorge, task, zoneNo));
-                }
-            }
-
-            //传入数据给回调方法,方便进行数据操作
-            if (fstorge != null) {
-                bizJsonObject.put("srcPosition", fstorge.getId().toString());
-            }
-            if (tstorge != null) {
-                bizJsonObject.put("targetPostion", tstorge.getId().toString());
-            }
-            //柔性机器人搬运标志
-            if (StringUtil.isNotEmpty(rxjqrFlag) || StringUtil.isNotEmpty(rxjqrNoMoveFlag)) {
-                jsonObject.put("uid", taskNode.getId().toString() + count);
-                if (StringUtil.isNotEmpty(rxjqrFlag)) {
-                    bizJsonObject.put(DemoLineConstant.DEMOLINE_RXJQR_FLAG, rxjqrFlag);
-                }
-                if (StringUtil.isNotEmpty(rxjqrNoMoveFlag)) {
-                    bizJsonObject.put(DemoLineConstant.DEMOLINE_RXJQR_NOMOVE_FLAG, rxjqrNoMoveFlag);
-                }
-                bizJsonObject.put(taskNode.getId().toString() + "count", count);
-            }
-            //机器人换手标志
-            if (StringUtil.isNotEmpty(jqrhsFlag)) {
-                jsonObject.put("uid", taskNode.getId().toString() + count);
-                bizJsonObject.put(DemoLineConstant.DEMOLINE_CHANGEHAND_FLAG, jqrhsFlag);
-                bizJsonObject.put(taskNode.getId().toString() + "count", count);
-            }
-            //启用【线边库】队列
-            if (StringUtil.isNotEmpty(xbkFlag)) {
-                bizJsonObject.put(DemoLineConstant.DEMOLINE_XBKFLAG, xbkFlag);
-                bizJsonObject.put(DemoLineConstant.DEMOLINE_XBK_TYPE, xbkType);
-                bizJsonObject.put(DemoLineConstant.DEMOLINE_XBK_CARRY_TYPE, carryType);
-            } */
-
         }
         else if (DictionaryKey.INTERFACETYPE_PRO.equals(taskNode.getInterfaceType())) {
             //生产加工
@@ -398,7 +331,7 @@ public class TaskWorkNode {
         else if (DictionaryKey.INTERFACETYPE_AGV.equals(taskNode.getInterfaceType())) {
             //AGV取料
             nodeOperationService = new AGVNodeServiceImpl();
-            Map map = nodeOperationService.operation(jsonObject, bizJsonObject,conMap);
+            Map map = nodeOperationService.operation(jsonObject, bizJsonObject, conMap);
             jsonObject = (JSONObject) map.get("jsonObject");
             bizJsonObject = (JSONObject) map.get("bizJsonObject");
         }
@@ -409,14 +342,14 @@ public class TaskWorkNode {
             Map map = nodeOperationService.operation(jsonObject, bizJsonObject, conMap);
             jsonObject = (JSONObject) map.get("jsonObject");
             bizJsonObject = (JSONObject) map.get("bizJsonObject");
-        }
+        } */
 
         //业务回调数据,传给接口,接口再返回过来。
         jsonObject.put("bizCallBackData", bizJsonObject.toJSONString());
         //调试得时候打开
         jsonObject.put("code", "1");
         logger.info("节点请求参数" + jsonObject.toJSONString());
-        msgUtil.redis_set("testParam", jsonObject.toJSONString(), 1, TimeUnit.DAYS);
+        //msgUtil.redis_set("testParam", jsonObject.toJSONString(), 1, TimeUnit.DAYS);
         return jsonObject.toJSONString();
     }
 
@@ -486,8 +419,7 @@ public class TaskWorkNode {
 
         //获取节点指令集
         Module module  = getModuleInfo(task.getResourceId().toString());
-        List<ModuleInstruction> moduleInstructions = moduleInstructionService.list(new QueryWrap<ModuleInstruction>().eq("module_id", module.getId()));
-
+        List<ModuleInstruction> moduleInstructions = moduleInstructionService.list(new LbqWrapper<ModuleInstruction>().eq(ModuleInstruction::getModuleId, module.getId()).eq(ModuleInstruction::getPublishStatus, "1"));
 
         //判断夹具资源
         List<BomProcedureTray> bomProcedureTrayList = bomProcedureVersionService.getPreProcedureTray(new HashMap());
@@ -689,28 +621,6 @@ public class TaskWorkNode {
         return map;
     }
 
-    /**
-     * 判断设备是否可用
-     *
-     * @param ip
-     * @param port
-     * @param field
-     * @param goal
-     * @return
-     */
-    public boolean getUseableResource(String ip, String port, String field, String goal) {
-        String cacheValue = msgUtil.redis_get(ip + "_" + port) == null ? "" : msgUtil.redis_get(ip + "_" + port).toString();
-        if (StringUtil.isEmpty(cacheValue)) {//数据异常了,直接先过,不然一直卡着
-            return true;
-        }
-        JSONObject jsonObject = JSONObject.parseObject(cacheValue);
-        if (jsonObject.containsKey(field) && goal.equals(jsonObject.getString(field))) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
     /**
      *  线边库条件处理判断
      * @param map

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

@@ -14,11 +14,14 @@ import com.github.zuihou.business.operationManagementCenter.service.WorkpieceSer
 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.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.common.constant.BizConstant;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.tenant.entity.ModuleInstruction;
 import com.google.common.collect.Maps;
 import lombok.extern.slf4j.Slf4j;
@@ -55,12 +58,13 @@ public class AGVNodeServiceImpl implements NodeOperationService {
     @Autowired
     private MsgUtil msgUtil;
 
+    @Autowired
+    private ZZoneProductionresourceService zZoneProductionresourceService;
+
     private ProductionresourcePosition productionresourcePosition;
-    private String zoneNo = null;
     private String[] jbwarr = null;
     private Map<String, Object> map = Maps.newHashMap();
-    private Map<String, Object> queryMap = Maps.newHashMap();
-
+    private Long zone_id;
 
     @Override
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
@@ -68,6 +72,9 @@ public class AGVNodeServiceImpl implements NodeOperationService {
 
         //初始化线边库位
         productionresourcePosition = getResourcePosition(taskNode);
+        //获取产线ID
+        ZZoneProductionresource zZoneProductionresource = zZoneProductionresourceService.getOne(new LbqWrapper<ZZoneProductionresource>().eq(ZZoneProductionresource::getResourceId, taskNode.getResourceId()));
+        zone_id = zZoneProductionresource.getZoneId();
 
     }
 

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

@@ -42,10 +42,7 @@ import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
@@ -150,7 +147,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         //生产设备操作不关联接驳位,资源占用只暂存在线边库
 
         ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
-        String functionName = resourceAutoCode.getCommand();
+        //加工设备默认指令类型(1-上传程序 2-执行程序 3-坐标系校验) 1只应用于机床设备 3已经弃用
+        String functionType = resourceAutoCode.getCommand();
         String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
 
         //采集接口判断当前设备是否在线
@@ -171,86 +169,79 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         if(isXbk){
             //获取锁定线边库的库位信息
             Storge storge = storgeService.getById(productionresourcePosition.getStorgeId());
-            //设定线边库目标ID
-            //storge.setTargetId(task.getResourceId());
             //锁定当前节点与线边库库位
             storgeService.lockStorge(storge, taskNode.getId());
             //更新零件节点的库位信息————workpiece
-
             map.put("result", false);
             return map;
         }
 
-        switch (moduleName) {
+        //获取设备指令集合
+        List<ModuleInstruction> moduleInstructions = (List<ModuleInstruction>)dataMap.get("instructions");
 
+        switch (moduleName.toLowerCase()) {
             case "打标机":
-                if("print".equals(functionName)){
+                //执行打标程序
+                if("2".equals(functionType) && moduleInstructions.size() == 1){
                     //打标
-                    map.put("zkIp", ZK_ip_rxx);
-                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
+//                    map.put("zkIp", ZK_ip_rxx);
+//                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
+                    //获取打标指令编码
+                    map.put("method", moduleInstructions.get(0).getCode());
                     //获取打标唯一码
                     String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
                     JSONObject data = new JSONObject();
+                    //默认配置  后期可改可去
+                    data.put("workId", "1");
                     data.put("labelContent", unionCode);
                     map.put("data", data);//打标内容
                     map.put("result", true);
                 }
-
                 break;
             case "smu50":
-                 if ("SMU50_FILE".equals(functionName)) {
+                 if ("1".equals(functionType)) {
+                     //程序文件上传
                      List<BomProcedureProgram>procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
 
                      List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
-                    if (procedureProgramList != null && procedureProgramList.size() > 0) {//先按一个处理
+                    if (procedureProgramList != null && procedureProgramList.size() > 0) {
+                        //文件上传只允许单个文件
                         procedureProgramList.forEach(i -> {
                             Map<String, String> m = new HashMap<>();
                             m.put("fileName", i.getSubmittedFileName());
                             fileList.add(m);
                         });
-                        String fileName = procedureProgramList.get(0).getSubmittedFileName();
-                        map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
-                        map.put("Data", JSONArray.parseArray(JSONObject.toJSONString(fileList)));
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo(), fileName, 1, TimeUnit.DAYS);
-
+                        //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
+                        map.put("method", "UploadFile");
+                        JSONObject data = new JSONObject();
+                        data.put("fileName", fileList.get(0).get("fileName"));
+                        map.put("data", data);
+                        //msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo(), fileName, 1, TimeUnit.DAYS);
+                        map.put("result", true);
                     }
-                    map.put("result", true);
-                } else if ("execProgram".equals(functionName)) {
-                    //执行程序,分多次执行
-                    String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
-                            : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
-
-//                if (DemoLineConstant.DEMOLINE_WORK_SPACE1.equals(zoneNo)) {
-//                    map.put("zkIp",ZK_ip_zndy);
-//                }else{
-//                    map.put("zkIp",ZK_ip_rxx);
-//                }
-                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "execProgram");
+                }
+                else if ("2".equals(functionType)) {
+                    //执行加工程序,分多次执行
+                    //String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
+                     //       : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
+                    //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "execProgram");
                     //当前执行数量
-//                int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo()).toString());
-                    String fileName = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()) == null ? "" : msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()).toString();
-                    String fileNames[] = fileName.split(",");
-//                if (currCount < fileNames.length) {
-//                    String uploadFileName = fileNames[currCount];
-//                    Map<String, String> m = new HashMap<>();
-//                    m.put("fileName", uploadFileName);
-//                    map.put("data", JSONArray.parseArray(JSONObject.toJSONString(m)));
-//                    map.put(DemoLineConstant.DEMOLINE_EXEPRO_FLAG, "1");
-//                    //当前执行数量
-//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
-//                }
-//                Map fileMap = new HashMap();
-//                fileMap.put("fileName", fileName);
-                    map.put("Data", fileName);
+                    //String fileName = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()) == null ? "" : msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()).toString();
+                     List<BomProcedureProgram> procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
+                    //执行程序默认按单文件处理
+                    //String fileName = "";
+                    //String fileNames[] = fileName.split(",");
+                    JSONObject data = new JSONObject();
+                    data.put("remotePath", procedureProgramList.get(0).getSubmittedFileName());
+                    map.put("data", data);
+                    map.put("method", "StartNCProgram");
                     map.put("result", true);
-                } else if ("writeOffset".equals(functionName)){
+                }
+                else if ("3".equals(functionType)){
                      // 加工前写入工件坐标系 根据taskid查找工件三坐标测量的工件坐标系,可能存在装夹一次未果的情况,所以取最后一条数据
                      // TODO 工件坐标系根据机场不同系统,不同通讯协议调用不同的接口
                      QueryWrapper<OrderQuality> orderQualityWrapper = new QueryWrapper<OrderQuality>();
-                     orderQualityWrapper.in("taskId", task.getId());
-                     orderQualityWrapper.in("measuringType", "2");
-                     orderQualityWrapper.orderByDesc("updateTime");
-                     orderQualityWrapper.last("limit 1");
+                     orderQualityWrapper.in("taskId", task.getId()).in("measuringType", "2").orderByDesc("updateTime").last("limit 1");
                      OrderQuality orderQuality = orderQualityMapper.selectOne(orderQualityWrapper);
                      if(null == orderQuality){
                          // 简单处理的方式,直接将坐标偏移全部设置成0
@@ -280,29 +271,37 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                          queryMap.put("exactXaxisOffset", orderQuality.getExactBaxisOffset());
                          queryMap.put("exactXaxisOffset", orderQuality.getExactCaxisOffset());
                      }
-                     map.put("Data", JSONObject.toJSONString(queryMap));
+                     map.put("method", "SendLinShift");
+                     map.put("data", JSONObject.toJSONString(queryMap));
                      map.put("result", true);
                  }
 
                 break;
             case "清洗烘干机":
-                if ("clean".equals(functionName)) {
+                if ("2".equals(functionType) && moduleInstructions.size() == 1) {
                     //清洗,PLC接口
-                    map.put("zkIp", ZK_ip_rxx);
-                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "Clean");
+                    //map.put("zkIp", ZK_ip_rxx);
+                    //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "Clean");
+                    //获取打标指令编码
+                    map.put("method", moduleInstructions.get(0).getCode());
                     map.put("result", true);
                 }
                 break;
             case "三坐标检测仪":
-                if ("measuring".equals(functionName)) {
-                    map.put("zkIp", ZK_ip_zlzx);
-                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "testwork");
+                //坐标检测类型判断
+                if ("2".equals(functionType) && moduleInstructions.size()==1) {
+                    //map.put("zkIp", ZK_ip_zlzx);
+                    //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "testwork");
                     //查出工序三坐标相关
-                    BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
-
-                    String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
-
-                    map.put("Data", JSONObject.toJSONString(queryMap));
+                    //BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
+                    //String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
+                    JSONObject data = new JSONObject();
+                    //三坐标生成编号 动态可变
+                    data.put("workId", "measuring_123");
+                    data.put("workType", "1111");
+                    //map.put("data", JSONObject.toJSONString(queryMap));
+                    map.put("method", moduleInstructions.get(0).getCode());
+                    map.put("data", data);
                     map.put("result", true);
                 }
 
@@ -314,59 +313,18 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
     @Override
     public Map operation(JSONObject jsonObject, JSONObject bizJsonObject, Map<String, Object> conMap) {
-        boolean bool = (Boolean) conMap.get("NO_WMS");
-        TTask task = (TTask) conMap.get("task");
-        if(bool) {
-            // 生产加工
-            jsonObject.put("url", task.getIp());
-            jsonObject.put("port", task.getPort());
-            jsonObject.put("IsCallBackFlag", "1");
-            //搬运类型,拿-放
-            String carryRequest = conMap.get(DemoLineConstant.DEMOLINE_BIZ_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_BIZ_TYPE).toString();
-            jsonObject.put("BusinessType", carryRequest);
-
-            //执行程序标志
-            String exePrograme = conMap.get(DemoLineConstant.DEMOLINE_EXEPRO_FLAG) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_EXEPRO_FLAG).toString();
-            bizJsonObject.put(DemoLineConstant.DEMOLINE_EXEPRO_FLAG, exePrograme);
-
-            String data = conMap.get("Data") == null ? "" : conMap.get("Data").toString();
-            if (StringUtil.isNotEmpty(data)) {
-                jsonObject.put("Data", data);
-            }
-        }else{
-            // WMS处理
-            String wmsType = conMap.get(DemoLineConstant.DEMOLINE_WMS_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_WMS_TYPE).toString();
-            //物料类型0-毛坯1-成品
-            String goodsType = conMap.get(DemoLineConstant.DEMOLINE_GOODS_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_GOODS_TYPE).toString();
-            String locationName = conMap.get("locationName") == null ? "" : conMap.get("locationName").toString();
-            String boxes = conMap.get("boxes") == null ? "" : conMap.get("boxes").toString();
-
-            if (DemoLineConstant.DEMOLINE_WMS_CHUKU.equals(wmsType)) {
-                jsonObject.put("jobType", "wmsDown");
-            } else {
-                jsonObject.put("jobType", "wmsUp");
-                //3-货物入库1-无物入库
-                jsonObject.put("type", "3");
-            }
-            jsonObject.put("transferType", "wms");
-            jsonObject.put("locationName", locationName);
-            jsonObject.put("boxes", boxes);
-
-            //WMS只能出一个
-            if (DemoLineConstant.DEMOLINE_GOODS_TYPE_MAOPI.equals(goodsType)) {//毛坯
-                jsonObject.put("goodsId", task.getMeterialId());
-            } else {
-                jsonObject.put("goodsId", task.getBomId());
+            //获取节点指令操作名称
+            String method =  conMap.get("method").toString();
+            String hostSyetemUrl = "http://192.168.170.240:8090/";
+            switch(method){
+                case "execProgram": hostSyetemUrl = hostSyetemUrl + "/api/StartNCProgram"; break;
+                case "clean": hostSyetemUrl = hostSyetemUrl + "/api/StartCleanMachine"; break;
+                case "print": hostSyetemUrl = hostSyetemUrl + "/api/StartLabelMachine"; break;
+                case "measuring":  hostSyetemUrl = hostSyetemUrl + "/api/StartCoordinateMeasuringMachine";break;
+
             }
-            Storge fstorge = (Storge) conMap.get("fromStorge");
-            Storge tstorge = (Storge) conMap.get("toStorge");
-            //此数据用来业务回传
-            bizJsonObject.put("srcPosition", fstorge == null ? "" : fstorge.getId().toString());
-            bizJsonObject.put("targetPostion", tstorge == null ? "" : tstorge.getId().toString());
-        }
-        map.put("jsonObject", jsonObject);
-        map.put("bizJsonObject", bizJsonObject);
-        return map;
+            conMap.put("instructionUrl", hostSyetemUrl);
+            return conMap;
     }
 
     @Override

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

@@ -234,18 +234,6 @@ public class OtherNodeServiceImpl implements NodeOperationService {
         return deviceList.get(0);
     }
 
-    /**
-     * 实时获取当前设备状态
-     *
-     * @param resourceId
-     * @return
-     */
-    private boolean runStatus(Long resourceId){
-       //读取缓存
-       //读取数据库
-       //读取采集接口
-      return true;
-    }
 
     /**
      * 库位处理

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

@@ -193,17 +193,18 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 break;
             case "舱体线机器人":
                 //操作舱体线边库 具有取、移动、放三种指令
-                //取放加工设备
+                //本机存在缓存库位 (取->缓存库位->放->目标库位)
 
                 break;
             case "伺服舵机":
                 //操作三个线边库 只具有取、放两种动作
+                //本机无缓存库位 (取->放->目标库位)
 
 
                 break;
             case "框体线机器人":
                 //操作框体线边库 具有取、移动、放三种指令
-                //取放加工设备
+                //本机存在缓存库位 (取->缓存库位->放->目标库位)
 
                 break;
         }

+ 10 - 0
imcs-admin-boot/imcs-business-entity/pom.xml

@@ -53,6 +53,16 @@
             <groupId>com.baidubce</groupId>
             <artifactId>bce-java-sdk</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.1.22</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 

+ 2 - 3
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/TaskNode.java

@@ -4,9 +4,9 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.github.zuihou.base.entity.Entity;
-import com.github.zuihou.business.operationManagementCenter.typeHandler.ResourceAutoCodeHandler;
 import com.github.zuihou.business.productionReadyCenter.entity.*;
 import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.business.typeHandler.ResourceAutoCodeHandler;
 import com.github.zuihou.common.constant.BizConstant;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -15,7 +15,6 @@ import lombok.experimental.Accessors;
 import org.hibernate.validator.constraints.Length;
 
 import javax.validation.constraints.NotNull;
-import java.io.Serializable;
 import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.List;
@@ -37,7 +36,7 @@ import static com.github.zuihou.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
 @ToString(callSuper = true)
 @EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
-@TableName("imcs_t_task_node")
+@TableName(value = "imcs_t_task_node", autoResultMap = true)
 @ApiModel(value = "TaskNode", description = "节点任务表")
 @AllArgsConstructor
 public class TaskNode extends Entity<Long> {

+ 0 - 39
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/typeHandler/ResourceAutoCodeHandler.java

@@ -1,39 +0,0 @@
-package com.github.zuihou.business.operationManagementCenter.typeHandler;
-
-
-import com.baidubce.util.JsonUtils;
-import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
-import org.apache.ibatis.type.BaseTypeHandler;
-import org.apache.ibatis.type.JdbcType;
-import org.apache.ibatis.type.MappedJdbcTypes;
-import org.apache.ibatis.type.MappedTypes;
-
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-@MappedTypes(ResourceAutoCode.class)
-@MappedJdbcTypes(JdbcType.VARCHAR)
-public class ResourceAutoCodeHandler extends BaseTypeHandler<ResourceAutoCode> {
-
-    @Override
-    public void setNonNullParameter(PreparedStatement preparedStatement, int i, ResourceAutoCode resourceAutoCode, JdbcType jdbcType) throws SQLException {
-        preparedStatement.setString(i, resourceAutoCode.getId().toString());
-    }
-
-    @Override
-    public ResourceAutoCode getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
-        return JsonUtils.fromJsonString(resultSet.getString(columnName),  ResourceAutoCode.class);
-    }
-
-    @Override
-    public ResourceAutoCode getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
-        return JsonUtils.fromJsonString(resultSet.getString(columnIndex), ResourceAutoCode.class);
-    }
-
-    @Override
-    public ResourceAutoCode getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
-        return JsonUtils.fromJsonString(callableStatement.getString(columnIndex),  ResourceAutoCode.class);
-    }
-}

+ 91 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/typeHandler/ResourceAutoCodeHandler.java

@@ -0,0 +1,91 @@
+package com.github.zuihou.business.typeHandler;
+
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.fastjson.JSONObject;
+import com.baidubce.util.JsonUtils;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.common.util.StringUtil;
+import com.github.zuihou.context.BaseContextHandler;
+import lombok.Data;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedJdbcTypes;
+import org.apache.ibatis.type.MappedTypes;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Component;
+
+import javax.sql.DataSource;
+import java.sql.*;
+import java.util.List;
+
+
+@MappedTypes(ResourceAutoCode.class)
+@MappedJdbcTypes(JdbcType.VARCHAR)
+@Configuration
+@Component
+public class ResourceAutoCodeHandler extends BaseTypeHandler<ResourceAutoCode> {
+
+    private JdbcTemplate jdbcTemplate;
+
+    private static String url;
+    @Value("${zuihou.mysql.url}")
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    private static String username;
+    @Value("${zuihou.mysql.username}")
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    private static String password;
+    @Value("${zuihou.mysql.password}")
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    private static String driverClassName;
+    @Value("${zuihou.mysql.driverClassName}")
+    public void setDriverClassName(String driverClassName) {
+        this.driverClassName = driverClassName;
+    }
+
+    @Override
+    public void setNonNullParameter(PreparedStatement preparedStatement, int i, ResourceAutoCode resourceAutoCode, JdbcType jdbcType) throws SQLException {
+        preparedStatement.setString(i, resourceAutoCode.getId().toString());
+    }
+
+    @Override
+    public ResourceAutoCode getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
+        //return resourceAutoCodeService.getById(resultSet.getString(columnName));
+        String id = resultSet.getString(columnName);
+        String sql = "select * from zuihou_base_yj_0000.imcs_resource_autocode where id="+ id;
+        DruidDataSource dataSource = new DruidDataSource();
+        dataSource.setUrl(this.url);
+        dataSource.setUsername(this.username);
+        dataSource.setPassword(this.password);
+        dataSource.setDriverClassName(this.driverClassName);
+        jdbcTemplate = new JdbcTemplate(dataSource);
+        ResourceAutoCode resourceAutoCode = jdbcTemplate.queryForObject(sql, new Object[]{},new BeanPropertyRowMapper<ResourceAutoCode>(ResourceAutoCode.class));
+        return  resourceAutoCode;
+    }
+
+    @Override
+    public ResourceAutoCode getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
+        return JsonUtils.fromJsonString(resultSet.getString(columnIndex), ResourceAutoCode.class);
+    }
+
+    @Override
+    public ResourceAutoCode getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
+        return JsonUtils.fromJsonString(callableStatement.getString(columnIndex),  ResourceAutoCode.class);
+    }
+}

+ 3 - 1
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/constant/DictionaryKey.java

@@ -15,6 +15,8 @@ public interface DictionaryKey {
 
     //线边库最大库位数
     final Integer RESOURCE_MAX_NUM = 20;
+    //指定接口URL地址
+    final String INSTRUCTION_URL = "http://192.168.170.240:8090/";
 
     //PLC
     String INTERFACETYPE_PLC = "01";
@@ -69,7 +71,7 @@ public interface DictionaryKey {
         {
             put("1", "上传程序");
             put("2", "执行程序");
-            put("3", "刀具校验");
+            put("3", "坐标系校验");
         }
     };