瀏覽代碼

后端节点功能处理

oyq28 2 周之前
父節點
當前提交
4c99766c0f

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

@@ -507,10 +507,11 @@ public class TaskWorkNode {
                                         List<String> storgePoints = storgeList.stream().map(p -> p.getPointId()).collect(Collectors.toList());
                                         if (CollectionUtil.isNotEmpty(storgeList)) {
                                             logger.info("节点{}开始释放占用的资源{}", taskNode.getId(), storgePoints.toString());
-                                            storgeService.unlockStorgeList(storgeList);
+                                            //storgeService.unlockStorgeList(storgeList);
                                         }
-                                        msgUtil.pushToNextMq(taskNode, 3);
-                                    } else {
+                                        //msgUtil.pushToNextMq(taskNode, 1);
+                                    }
+                                    //else {
                                         /**
                                          String zoneType = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.ZONE_TYPE).toString());
                                          if(zoneType.equals(ParameterKey.ZONE_YJ)){
@@ -617,8 +618,8 @@ public class TaskWorkNode {
 
                                                 //todo $需要换地址$
                                                 HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
-                                                returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
-                                                //returnData = "{\"result\": \"true\"}";
+                                                //returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
+                                                returnData = "{\"result\": \"true\"}";
 
                                             }
 
@@ -627,7 +628,7 @@ public class TaskWorkNode {
                                 }
                             }
                         }
-                    }
+ //                   }
                 } else {
                     logger.info("节点{}未获取到了执行锁", taskNode.getId());
                     conMap.put("result", false);

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

@@ -1814,7 +1814,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             //更新节点任务
 
             if (callBackJson.containsKey(YunjianConstant.YUNJIAN_XBKFLAG))  {//临时存放到了线边库,向虚拟线边库发一个MQ。
-                int count = callBackJson.getString(taskNode.getId().toString() + "count") == null ? -1 :
+                int count = callBackJson.getString(taskNode.getId().toString() + "count") == null ? 0 :
                         Integer.parseInt(callBackJson.getString(taskNode.getId().toString() + "count"));
                 int limit = 1;
                 if (!callBackJson.containsKey(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG)) {

+ 39 - 17
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/strategy/impl/CacheRobotStrategy.java

@@ -46,12 +46,15 @@ import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
+import static java.util.stream.Collectors.groupingBy;
+
 @Component("CACHE")
 @Slf4j
 public class CacheRobotStrategy implements RobotStrategy {
@@ -108,7 +111,6 @@ public class CacheRobotStrategy implements RobotStrategy {
 
         com.github.zuihou.business.productionResourceCenter.entity.Productionresource robot = productionresourceBizMapper.selectById(taskNode.getResourceId());
         ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId, taskNode.getResourceId()));
-        List<ProductionresourcePosition> robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
         ZZone zZone = zoneService.getOne(new LbqWrapper<ZZone>().eq(ZZone::getName, zoneName).last("limit 1"));
         Plan orderPlan = planService.getById(task.getPlanId());
         BBom bom = bBomMapper.selectById(task.getBomId());
@@ -124,7 +126,7 @@ public class CacheRobotStrategy implements RobotStrategy {
         robotInfo.put("bomzZone", bomzZone);
         robotInfo.put("plcInfo", plcInfo);
         robotInfo.put("singleRunFlag", orderPlan.getSingleRunFlag());
-        robotInfo.put("robotList", robotList);
+        //robotInfo.put("robotList", robotList);
         //robotInfo.put("xbkList", xbkList);
 
         return robotInfo;
@@ -156,7 +158,7 @@ public class CacheRobotStrategy implements RobotStrategy {
         Storge targetStorge = !returnMap.containsKey("store") ? null : (Storge) returnMap.get("store");
         Long targetStorgeResourceId = !returnMap.containsKey("storeResourceId") ? null : Long.valueOf(returnMap.get("storeResourceId").toString());
 
-        if (targetStorge == null) {
+        if (ObjectUtil.isEmpty(targetStorge)) {
             dataMap.put("result", false);
             dataMap.put("resultmsg","目标点位不满足,线边库不符合要求存放");
             return dataMap;
@@ -164,7 +166,7 @@ public class CacheRobotStrategy implements RobotStrategy {
         String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
 
         //处理机器人库位
-        List<ProductionresourcePosition> robotList = (List<ProductionresourcePosition>) robotInfo.get("robotList");
+        List<ProductionresourcePosition> robotList = productionresourcePositionService.list(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId, taskNode.getResourceId()));
         Map putMap = this.robotPut(returnMap, taskNode, startStore, targetStorge, robotList, targetXbk, targetStorgeResourceId);
         return putMap;
     }
@@ -178,20 +180,23 @@ public class CacheRobotStrategy implements RobotStrategy {
 
         //锁定机器人抓手
         Storge jqrStorge = null;
-        try {
-            jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
-
-            if(jqrStorge == null){
-                throw new BizException("没有查询到可执行的关节机器人");
-            }
-        }catch (Exception e){
-            throw new BizException("没有查询到可执行的关节机器人");
+        List<ProductionresourcePosition> jqrList = jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS);
+        if(jqrList.size() == 0){
+             returnMap.put("result", false);
+             return returnMap;
+        }else {
+             jqrStorge = storgeService.getById(jqrList.get(0).getStorgeId());
+              if (null == jqrStorge) {
+                  returnMap.put("result", false);
+                  return returnMap;
+              }
         }
 
         jqrStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
         storgeService.lockStorge(jqrStorge, taskNode.getId());
 
-        List<ProductionresourcePosition> hcwList = jqrMap.get(jqrMap.keySet().stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p) && !DemoLineConstant.DEMOLINE_RJQR_SIX.equals(p)).findFirst().get());
+        //List<ProductionresourcePosition> hcwList = jqrMap.get(jqrMap.keySet().stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p) && !DemoLineConstant.DEMOLINE_RJQR_SIX.equals(p)).findFirst().get());
+        List<ProductionresourcePosition> hcwList = robotList.stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p.getPointId()) && !DemoLineConstant.DEMOLINE_RJQR_SIX.equals(p.getPointId())).collect(Collectors.toList());
         if (hcwList.size() == 0) {
             //限定抓手交换功能
             boolean hasJqrhcwPartFlag = false;
@@ -225,10 +230,14 @@ public class CacheRobotStrategy implements RobotStrategy {
         storgeService.lockStorge(hcwStorge, taskNode.getId());
         storgeService.lockStorge(startStorge, taskNode.getId());
 
-        if (hcwList.size() > 1) {
+        //暂存位线边库判断
+        if (hcwList.size() > 1 && targetXbk.equals("1")) {
             //锁定暂存缓存位库位
             targetStorge = hcwStorge;
             msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + taskNode.getId(), "1");
+            returnMap.put(YunjianConstant.YUNJIAN_XBKFLAG, "1");
+            returnMap.put(YunjianConstant.YUNJIAN_HCW_XBKFLAG, "1");
+            msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 10, TimeUnit.DAYS);
         } else {
             //锁定目标线边库库位
             targetStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
@@ -239,6 +248,8 @@ public class CacheRobotStrategy implements RobotStrategy {
             } else {
                 //目标是线边库
                 msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + taskNode.getId(), targetXbk, 10, TimeUnit.DAYS);
+                returnMap.put(YunjianConstant.YUNJIAN_XBKFLAG, "1");
+                returnMap.remove(taskNode.getId().toString()+"count");
             }
         }
         // 放入线边库或机器人缓存位
@@ -271,12 +282,14 @@ public class CacheRobotStrategy implements RobotStrategy {
         locationMap.put("destLocation", targetStorge.getPointId()); //机器人缓存位
         locationMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY"));
         locationMap.put("carryType", "1");
+        returnMap.put(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG, "1");
         returnMap.put("data", locationMap);
         returnMap.put("method", "RobotAction");
         returnMap.put("result", true);
         returnMap.put("fromStorge", startStorge);
         returnMap.put("toStorge", targetStorge);
 
+
         // 机器人移动到redis记录实时位子
         msgUtil.redis_set(taskNode.getResourceId() + "postion", startStorge.getPointId());
 
@@ -302,12 +315,22 @@ public class CacheRobotStrategy implements RobotStrategy {
         }
         TTask task = taskService.getById(taskNode.getTaskId());
         BomProcedure bomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getId,task.getProcedureId()));
-        String zoneName = robotInfo.get("zoneName").toString();
+        ZZone zZone = (ZZone) robotInfo.get("zZone");
+        String zoneName = zZone.getName();
         List<ProductionresourcePosition> xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(DictionaryKey.YJ_ZONE_XBK.get(zoneName).split(","));
 
         Map returnMap = this.robotTarget(taskNode, robotInfo, xbkList, bomProcedure, dataMap);
         //线边库处理
-        return returnMap;
+        Storge targetStorge = !returnMap.containsKey("store") ? null : (Storge) returnMap.get("store");
+        Long targetStorgeResourceId = !returnMap.containsKey("storeResourceId") ? null : Long.valueOf(returnMap.get("storeResourceId").toString());
+        String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
+        if (ObjectUtil.isNotEmpty(targetXbk) && targetXbk.equals("1")) {
+            dataMap.put("result", false);
+            return dataMap;
+        }
+        Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
+        Map putMap = this.robotPut(returnMap, taskNode, startStore, targetStorge, robotList, targetXbk, targetStorgeResourceId);
+        return putMap;
     }
 
     public Map robotTarget(TaskNode taskNode, Map robotInfo, List<ProductionresourcePosition> xbkList, BomProcedure bomProcedure, Map<String, Object> returnMap) {
@@ -427,5 +450,4 @@ public class CacheRobotStrategy implements RobotStrategy {
         return returnMap;
     }
 
-
 }

+ 3 - 3
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/MsgUtil.java

@@ -468,7 +468,7 @@ public class MsgUtil implements ApplicationContextAware {
             }
 
             if(callBackJson.containsKey(YunjianConstant.YUNJIAN_XBKFLAG)){//临时存放到了线边库,向虚拟线边库发一个MQ。
-                    int count =  callBackJson.getString(taskNode.getId().toString()+"count")==null?-1:Integer.parseInt(callBackJson.getString(taskNode.getId().toString()+"count"));
+                    int count =  callBackJson.getString(taskNode.getId().toString()+"count")==null? 0:Integer.parseInt(callBackJson.getString(taskNode.getId().toString()+"count"));
                     int limit =1;
                     if(!callBackJson.containsKey(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG)) {
                         limit =1;
@@ -533,8 +533,8 @@ public class MsgUtil implements ApplicationContextAware {
                 }
                 if(callBackJson.containsKey(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG)){//带缓存位机器人的多步骤执行
                     int count =  callBackJson.getString(taskNode.getId().toString()+"count")==null?0:Integer.parseInt(callBackJson.getString(taskNode.getId().toString()+"count"));
-                    int limit = 0;
-                    if(count<limit){//
+                    int limit = callBackJson.getString(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + taskNode.getId()) == null? 0 : 1;
+                    if(count<limit){
                         count = ++count;
                         jsonObject.put(taskNode.getId().toString()+"count",count);
                         //把当前节点推送到mq