Przeglądaj źródła

fix:优化自动化刀具

wang.sq@aliyun.com 2 miesięcy temu
rodzic
commit
30367a65ab

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

@@ -145,7 +145,7 @@ public class ToolRobotStrategy implements RobotStrategy {
             String pointId = orderTask.getStart().replace("CT_", "");
             startStore = storgeService.getOne(new LbqWrapper<Storge>().eq(Storge::getPointId, pointId).last("LIMIT 1"));
         } */
-        String pointId = orderTask.getStart().replace("CT_", "");
+        String pointId = orderTask.getStart().replace("CT_", "").replace("CT2_","");
         startStore = storgeService.getOne(new LbqWrapper<Storge>().eq(Storge::getPointId, pointId).last("LIMIT 1"));
 
         //CCS判断取条件是否满足getCutterDeviceIsTake
@@ -154,15 +154,30 @@ public class ToolRobotStrategy implements RobotStrategy {
             //从机床刀具库取需要预置处理
             Object cutToolAction = msgUtil.redis_get(DemoLineConstant.DEMOLINE_CUT_DEVICE_ACTION);
             if(ObjectUtil.isEmpty(cutToolAction)){
-                //this.CNCTActionHandle(taskNode, false, pointId, orderTask);
-                msgUtil.redis_set(DemoLineConstant.DEMOLINE_CUT_DEVICE_ACTION, taskNode.getId().toString(),10, TimeUnit.MINUTES);
-                dataMap.put("result", false);
-                dataMap.put("resultMsg","已下发CNC刀具口请求");
                 //机床内刀具库位信息同步到机床待取位
                 CuttingTool cuttingTool = cuttingToolService.getOne(new LbqWrapper<CuttingTool>().eq(CuttingTool::getCutterNo, orderTask.getCutStartNo()));
+                if(cuttingTool == null){
+                    throw new RuntimeException("刀具点位与刀具信息点位数据不对,起始刀位号:"+orderTask.getCutStartNo());
+                }
+                StockInfo one = stockInfoService.getOne(new LbqWrapper<StockInfo>().eq(StockInfo::getGoodsId, cuttingTool.getId()));
+                if(one !=null){
+                    throw new RuntimeException("刀具信息在库存中已存在,位置:"+one.getStorgeId());
+                }
+
+                // 调用plc 让plc把机床刀具转到待取位
+                this.CNCTActionHandle(taskNode, false, pointId, orderTask);
+
                 StockInfo stockInfo = StockInfo.builder().storgeId(startStore.getId()).lockStatus("1").num(1).uniqueCode(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_UNIQUE)).goodsType("6").specId(cuttingTool.getId()).goodsId(cuttingTool.getId()).build();
                 stockInfoService.save(stockInfo);
-                return null;
+
+                dataMap.put("result", false);
+                dataMap.put("resultMsg","已下发CNC刀具口请求");
+
+                msgUtil.redis_set(DemoLineConstant.DEMOLINE_CUT_DEVICE_ACTION, taskNode.getId().toString(),10, TimeUnit.MINUTES);
+                return dataMap;
+            }else if(!cutToolAction.toString().equals(taskNode.getId().toString())){
+                // 判断是否为同一个任务
+                throw new RuntimeException("取刀位转动其他任务已占用");
             }
         }
 
@@ -298,7 +313,7 @@ public class ToolRobotStrategy implements RobotStrategy {
             } else {
                 //按类型获取目标库位
                 if (StringUtil.isNotEmpty(orderTask.getGoal())) {
-                    String pointId = orderTask.getGoal().replace("CT_", "");
+                    String pointId = orderTask.getGoal().replace("CT_", "").replace("CT2_","");
                     List<ProductionresourcePosition> positionList = targetList.stream().filter(item -> item.getPointId().equals(pointId)).collect(Collectors.toList());
                     targetStorge = storgeService.getById(positionList.get(0).getStorgeId());
                 } else {

+ 3 - 3
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/productionResourceCenter/ToolController.java

@@ -114,7 +114,7 @@ public class ToolController extends SuperController<ToolService, Long, Tool, Too
     @ApiOperation(value = "同步刀具", notes = "同步刀具")
     @PostMapping("/synchronousTool")
     public R<Boolean> synchronousTool() throws Exception {
-        BaseContextHandler.setTenant("000");
+        BaseContextHandler.setTenant("0000");
         List<Productionresource> dataList = productionresourceBizService.list(new LbqWrapper<Productionresource>().eq(Productionresource::getStatus, "1").ne(Productionresource::getOnlineStatus,"0").isNotNull(Productionresource::getModeSpecification));
         List<Long> ids = dataList.stream().map(Productionresource::getId).collect(Collectors.toList());
         MachineCuttingTool machineCuttingTool = new MachineCuttingTool();
@@ -133,11 +133,11 @@ public class ToolController extends SuperController<ToolService, Long, Tool, Too
             for(int i=0;i<cutToolList.size(); i++) {
                 MachineCuttingTool item = cutToolList.get(i);
                 //默认取刀具去刀架
-                boolean isWarn = item.getTl().equals("L")? true : false;
+                boolean isWarn = item.getDoc().equals("HD")? true : false;
                 //同步添加天轨处理订单
                 Map<String, String> data = Maps.newHashMap();
                 //获取机床待取库位
-                ProductionresourcePosition productionresourcePosition = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getResourceId, item.getMachineId()).like(ProductionresourcePosition::getPointId, "CNC0").last("LIMIT 1"));
+                ProductionresourcePosition productionresourcePosition = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getResourceId, item.getMachineId()).like(ProductionresourcePosition::getPointId, "CNCT").last("LIMIT 1"));
                 data.put("start", "CT2_" + productionresourcePosition.getPointId());
                 if (isWarn) {
                     //报警直接上下料站下料

+ 1 - 1
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionReadyCenter/entity/MachineCuttingTool.java

@@ -203,7 +203,7 @@ public class MachineCuttingTool extends Entity<Long> {
     /**
      * 锁定运行状态
      */
-    @ApiModelProperty(value = "换刀标识位(''-不需换刀 HD-需要换刀)")
+    @ApiModelProperty(value = "换刀标识位(''-不需换刀 HD-刀具寿命到期,FDJ-换刀,把刀放到中央刀库)")
     @TableField(value = "doc", condition = EQUAL)
     @Excel(name = "换刀标识位")
     private String doc;