Explorar el Código

后台代码更新

oyq28 hace 1 mes
padre
commit
e5755f7876

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

@@ -251,6 +251,15 @@ public class CacheRobotStrategy implements RobotStrategy {
             returnMap.put(YunjianConstant.YUNJIAN_HCW_XBKFLAG, "1");
             msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 10, TimeUnit.DAYS);
         }else if(hcwList.size() == 1 && ObjectUtil.isEmpty(hcwExecFlag) && ObjectUtil.isEmpty(hcwXbkFlag)){
+            //已在暂存位上工装没有暂存位缓存时限制正常接入
+            ProductionresourcePosition hcwStorgePosition = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getResourceId, taskNode.getResourceId()).ne(ProductionresourcePosition::getPointId, DemoLineConstant.DEMOLINE_RJQR_ZS).ne(ProductionresourcePosition::getStorgeId, hcwStorge.getId()).last("limit 1"));
+            TWorkpiece tWorkpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getIsEnd, "0").eq(TWorkpiece::getStorgeId, hcwStorgePosition.getStorgeId()).last("limit 1"));
+            Object preHcwXbkFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + tWorkpiece.getTaskNodeId());
+            if(ObjectUtil.isEmpty(preHcwXbkFlag)){
+                returnMap.put("msg", "已暂存位工装数据无缓存数据");
+                returnMap.put("result", false);
+                return returnMap;
+            }
             targetStorge = hcwStorge;
             returnMap.put(YunjianConstant.YUNJIAN_XBKFLAG, "1");
             returnMap.put(YunjianConstant.YUNJIAN_HCW_XBKFLAG, "1");
@@ -327,12 +336,12 @@ public class CacheRobotStrategy implements RobotStrategy {
         //暂存位线边库处理
         //Object targetHcwXbk =  msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + taskNode.getId());
         //if(ObjectUtil.isNotEmpty(targetHcwXbk)){
-            Object jqrHcwPartPriotyExec = (null == msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + taskNode.getId())) ? null : msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + taskNode.getId());
-            if(ObjectUtil.isNotEmpty(jqrHcwPartPriotyExec)){
-                robotList = robotList.stream().filter(item->item.getPointId().equals(DemoLineConstant.DEMOLINE_RJQR_ZS) && item.getStatus().equals("0")).collect(Collectors.toList());
-            }
+            List<ProductionresourcePosition> jqrList = null;
+            //if(ObjectUtil.isNotEmpty(jqrHcwPartPriotyExec)){
+               jqrList = robotList.stream().filter(item->item.getPointId().equals(DemoLineConstant.DEMOLINE_RJQR_ZS) && item.getStatus().equals("0")).collect(Collectors.toList());
+            //}
         //}
-        if(robotList.size() == 0 ) {
+        if(jqrList.size() == 0) {
             dataMap.put("result", false);
             dataMap.put("resultMsg","手抓/暂存位不满足");
             return dataMap;
@@ -352,9 +361,13 @@ public class CacheRobotStrategy implements RobotStrategy {
         //线边库目标位置被占用
         if (ObjectUtil.isNotEmpty(targetXbk) && targetXbk.equals("1") && StringUtils.isNotEmpty(xbkCount) && xbkCount.equals("1")) {
             //暂存位优先级低的节点目标位线边库模式,当暂存位上只有一块工装时将优先级低调整成优先级高
-            TaskNode taskNode1= dataMap.get("taskNode") != null ?  (TaskNode) dataMap.get("taskNode") : new TaskNode();
+            Object jqrHcwPartPriotyExec = (null == msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + taskNode.getId())) ? null : msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + taskNode.getId());
+            if(ObjectUtil.isNotEmpty(jqrHcwPartPriotyExec) && robotList.size() == 2 && jqrList.size() == 1){
+                msgUtil.redis_del(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + taskNode.getId());
+                msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + taskNode.getId(), "1");
+            }
             dataMap.put("result", false);
-            dataMap.put("resultMsg", "条件判断不通过,涉及到多次搬运,节点名字"+ taskNode1.getNodeName()+"节点id:"+taskNode1.getId());
+            dataMap.put("resultMsg", "条件判断不通过,涉及到多次搬运,节点名字"+ taskNode.getNodeName()+"节点id:"+taskNode.getId());
             return dataMap;
         }
         Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);

+ 4 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/strategy/impl/NoCacheRobotStrategy.java

@@ -1,5 +1,6 @@
 package com.github.zuihou.business.productionResourceCenter.strategy.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
@@ -38,6 +39,8 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
+import static java.util.stream.Collectors.groupingBy;
+
 @Component("NOCACHE")
 @Slf4j
 public class NoCacheRobotStrategy implements RobotStrategy {
@@ -99,7 +102,7 @@ public class NoCacheRobotStrategy implements RobotStrategy {
 
     @Override
     public Map robotCheck(TaskNode taskNode, Map robotInfo, List<StockInfo> flikustockInfos, BomProcedure bomProcedure,Map<String, Object> dataMap) {
-        return null;
+          return null;
     }
 
     @Override

+ 78 - 11
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/strategy/impl/ToolRobotStrategy.java

@@ -12,6 +12,7 @@ import com.github.zuihou.business.edgeLibrary.service.StorgeService;
 import com.github.zuihou.business.operationManagementCenter.entity.*;
 import com.github.zuihou.business.operationManagementCenter.service.*;
 import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
+import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureMapper;
 import com.github.zuihou.business.productionReadyCenter.entity.BBom;
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
@@ -87,6 +88,8 @@ public class ToolRobotStrategy implements RobotStrategy {
     @Value("${imcs-to-ccs.enabled:true}")
     private Boolean imcsTOccsEnable;
 
+    @Autowired
+    private BomProcedureMapper bomProcedureMapper;
 
     @Override
     public Map robotInfo(TaskNode taskNode, String zoneName) {
@@ -162,10 +165,10 @@ public class ToolRobotStrategy implements RobotStrategy {
         }
 
         //处理目标库位
-        this.robotTarget(taskNode, orderTask, null, bomProcedure,returnMap);
-        if(returnMap.get("result") !=null && "false".equals(returnMap.get("result").toString())){
-            return returnMap;
-        }
+        ZZone zZone = (ZZone) robotInfo.get("zZone");
+        String zoneName = zZone.getName();
+        List<ProductionresourcePosition> xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(DictionaryKey.YJ_ZONE_XBK.get(zoneName+"-tool").split(","));
+        returnMap = this.robotTarget(taskNode, orderTask, xbkList, bomProcedure,returnMap);
 
         Storge targetStorge = !returnMap.containsKey("store") ? null : (Storge) returnMap.get("store");
         Long targetStorgeResourceId = !returnMap.containsKey("storeResourceId") ? null : Long.valueOf(returnMap.get("storeResourceId").toString());
@@ -175,11 +178,11 @@ public class ToolRobotStrategy implements RobotStrategy {
             dataMap.put("resultMsg","目标点位不满足,线边库不符合要求存放");
             return dataMap;
         }
-        //String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
+        String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
 
         //处理机器人库位
         List<ProductionresourcePosition> robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
-        Map putMap = this.robotPut(returnMap, taskNode, startStore, targetStorge, robotList, null, targetStorgeResourceId);
+        Map putMap = this.robotPut(returnMap, taskNode, startStore, targetStorge, robotList, targetXbk, targetStorgeResourceId);
         return putMap;
     }
 
@@ -222,6 +225,10 @@ public class ToolRobotStrategy implements RobotStrategy {
             locationMap.put("destLocationNo", orderTask.getCutGoalNo());  //目的刀位号
         }
 
+        if(StringUtil.isNotEmpty(targetxbk) && targetxbk.equals("1")) {
+           returnMap.put(YunjianConstant.YUNJIAN_XBKFLAG, "1");
+        }
+
         locationMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY"));
         locationMap.put("carryType", DictionaryKey.CARRY_TYPE.get("TOOL_HAND"));
         returnMap.put("data", locationMap);
@@ -235,13 +242,23 @@ public class ToolRobotStrategy implements RobotStrategy {
 
     @Override
     public Map robotXbk(Map dataMap, Map robotInfo, TaskNode taskNode, Storge startStorge, Storge endStorge, List<ProductionresourcePosition> robotList) {
-        return null;
+
+        OrderTask orderTask = (OrderTask) robotInfo.get("orderTask");
+        TTask task = taskService.getById(taskNode.getTaskId());
+        BomProcedure bomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getId,task.getProcedureId()));
+        ZZone zZone = (ZZone) robotInfo.get("zZone");
+        String zoneName = zZone.getName();
+        List<ProductionresourcePosition> xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(DictionaryKey.YJ_ZONE_XBK.get(zoneName+"-tool").split(","));
+
+        Map returnMap = this.robotTarget(taskNode, orderTask, xbkList, bomProcedure, dataMap);
+        return returnMap;
     }
 
     //获取目标地址
     public Map robotTarget(TaskNode taskNode, OrderTask orderTask, List<ProductionresourcePosition> xbkList, BomProcedure bomProcedure, Map<String, Object> returnMap) {
         List<ProductionresourcePosition> targetList = null;
         Long targetResourceId = taskNode.getTargetResourceId();
+/*
         if(targetResourceId == null){
             //msgUtil.createWarnLog("刀具节点目标位数据为空","DataException");
             returnMap.put("resultMsg","刀具节点目标位数据为空");
@@ -294,12 +311,62 @@ public class ToolRobotStrategy implements RobotStrategy {
             returnMap.put("resultMsg",resultMsg ==null? "刀具节点目标位放置条件不满足": resultMsg);
             returnMap.put("result", false);
             return null;
-        }
 
-        returnMap.put("storeResourceId", targetResourceId);
-        returnMap.put("store", targetStorge);
-        returnMap.put("targetxbk", "0");
+ */
+        String xbkFlag = "";
+        Storge startStorge = null;
+        Storge targetStorge = null;
 
+        if(targetResourceId != null) {
+            targetList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{targetResourceId.toString()});
+            if (CollectionUtil.isEmpty(targetList)) {
+                xbkFlag = "1";
+            } else {
+                //按类型获取目标库位
+                if (StringUtil.isNotEmpty(orderTask.getGoal())) {
+                    String pointId = orderTask.getGoal().replace("CT_", "");
+                    List<ProductionresourcePosition> positionList = targetList.stream().filter(item -> item.getPointId().equals(pointId)).collect(Collectors.toList());
+                    targetStorge = storgeService.getById(positionList.get(0).getStorgeId());
+                } else {
+                    targetStorge = storgeService.getById(targetList.get(0).getStorgeId());
+                }
+                //CCS判断目标位点位是否允许放置判断
+                boolean bool = true;
+                String pointId = targetStorge.getPointId();
+                if (pointId.contains(DemoLineConstant.DEMOLINE_CUT_TOOL_TYPE_CNCT)) {
+                    //从机床刀具库放需要预置处理
+                    Object cutToolAction = msgUtil.redis_get(DemoLineConstant.DEMOLINE_CUT_DEVICE_ACTION);
+                    if (ObjectUtil.isEmpty(cutToolAction)) {
+                        this.CNCTActionHandle(taskNode, true, pointId, orderTask);
+                        msgUtil.redis_set(DemoLineConstant.DEMOLINE_CUT_DEVICE_ACTION, taskNode.getId().toString(), 10, TimeUnit.MINUTES);
+                        return null;
+                    }
+                }
+
+                //todo 与ccs联调需要释放  $需要换地址$
+                String resultData = this.cutToolActionCondition("/api/getCutterDeviceIsPut", taskNode, pointId);
+                JSONObject resultObj = JSONObject.parseObject(resultData);
+                bool = resultObj.getBoolean("result");
+                if (!bool) {
+                    msgUtil.createWarnLog("刀具节点目标位放置条件不满足", "DataException");
+                    return null;
+                }
+                if (CollectionUtil.isNotEmpty(targetList)) {
+                    returnMap.put("storeResourceId", targetResourceId);
+                    returnMap.put("store", targetStorge);
+                    returnMap.put("targetxbk", "0");
+                }else{
+                    xbkFlag = "1";
+                }
+            }
+        }
+        if ("1".equals(xbkFlag)) {
+            ProductionresourcePosition position = xbkList.get(0);
+            targetStorge = storgeService.getById(position.getStorgeId());
+            returnMap.put("storeResourceId", position.getResourceId());
+            returnMap.put("store", targetStorge);
+            returnMap.put("targetxbk", "1");
+        }
         return returnMap;
     }