Преглед на файлове

刀具后台功能处理

oyq28 преди 1 месец
родител
ревизия
98000d767b

+ 5 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/DemoLine/DemoLineConstant.java

@@ -290,6 +290,11 @@ public interface DemoLineConstant {
     //抓手库位
     String DEMOLINE_HAND_STOCK_CODE = "031";
 
+    //刀具出入库
+    String DEMOLINE_CUT_TOOL_CRK = "DEMOLINE_CUT_TOOL_CRK";
+    //机床刀具出入库
+    String DEMOLINE_CUT_TOOL_MACHINE_CRK = "DEMOLINE_CUT_TOOL_MACHINE_CRK";
+
 
     //PLC动作
     String DEMOLINE_FETCHMATERIAL = "fetchMaterial";

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

@@ -913,7 +913,7 @@ public class TaskWorkNode {
         bizJsonObject.put("aimStorge", aimStorge == null ? "" : aimStorge.getId().toString());
         bizJsonObject.put("bizType", bizType);
         bizJsonObject.put("handMode", handMode);
-        bizJsonObject.put("taskType", DictionaryKey.CARRY_TYPE.get("TRAY_HAND"));
+        //bizJsonObject.put("taskType", DictionaryKey.CARRY_TYPE.get("TRAY_HAND"));
         //判断是否已换工装
         if (StringUtil.isNotEmpty(isReload)) {
             bizJsonObject.put("isReload", isReload);

+ 23 - 16
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/OrderTaskServiceImpl.java

@@ -111,7 +111,7 @@ public class OrderTaskServiceImpl extends SuperServiceImpl<OrderTaskMapper, Orde
 
         if(startNameCondition[0].equals(goalNameCondition[0])){
             //同产线内简易搬运处理
-            this.inLineHandle(orderTask, startStorge, bom, startNameCondition[0], startResourceId, endResourceId);
+            this.inLineHandle(orderTask, startStorge, bom, startNameCondition[0], startResourceId, endResourceId, planId);
             return true;
         }
 
@@ -226,35 +226,43 @@ public class OrderTaskServiceImpl extends SuperServiceImpl<OrderTaskMapper, Orde
      * @return
      */
 
-    public TTask getSimpleTask(int currentSort, Order order, BBom bom, Long startResourceId, Long resourceBusinessId){
+    public TTask getSimpleTask(int currentSort, Order order, BBom bom, Long startResourceId, Long resourceBusinessId, String planId){
+        List<Long> ids = taskService.list(new LambdaQueryWrapper<TTask>().eq(TTask::getOrderId, order.getId()).eq(TTask::getStatus, "1")).stream().map(TTask::getId).collect(Collectors.toList());
+        if(ids.size()>0){
+            taskService.removeByIds(ids);
+        }
         TTask simpleTask = taskService.getOne(new LambdaQueryWrapper<TTask>().eq(TTask::getResourceBusinessId, resourceBusinessId).eq(TTask::getProcedureSort, currentSort).orderByDesc(TTask::getCreateTime).last("limit 1"));
         //OrderProduct orderProduct = orderProductService.getOne(new LambdaQueryWrapper<OrderProduct>().eq(OrderProduct::getBomNum, 1).orderByDesc(OrderProduct::getCreateTime).last("limit 1"));
         TTask initTask = TTask.builder().build();
         //OrderProduct initProduct = OrderProduct.builder().build();
-        Plan initPlan = Plan.builder().build();
+        //Plan initPlan = Plan.builder().build();
         if(simpleTask == null){
-            String procedureName = "刀具取放";
             //初始化默认简易任务
             Long bomId = bom.getId();
             Long resourceId = startResourceId;
-            BomProcedure bomProcedure = bomProcedureService.getOne(new LbqWrapper<BomProcedure>().eq(BomProcedure::getName, procedureName).orderByDesc(BomProcedure::getCreateTime).last("limit 1"));
+            BomProcedure bomProcedure = bomProcedureService.getOne(new LbqWrapper<BomProcedure>().eq(BomProcedure::getNo, "OP10").orderByDesc(BomProcedure::getCreateTime).last("limit 1"));
             Long procedureId = null!=bomProcedure ? bomProcedure.getId(): 1234567890L;
             initTask.setCompleteBatchNo(UUID.randomUUID().toString().replace("-", ""));
-            initTask.setOrderNo(order.getOrderNo()).setProcedureNo("OP05").setProcedureName(procedureName).setResourceId(resourceId).setProcedureId(procedureId).setTaskNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK)).
-                    setOrderId(order.getId()).setProcedureSort(0).setFirstProcedureFlag("1").setLastProcedureFlag("1").setDraftFlag("0").setResourceBusinessId(resourceBusinessId).setBomId(bomId);
+            initTask.setOrderNo(order.getOrderNo()).setProcedureNo("OP05").setProcedureName("刀具取放").setResourceId(resourceId).setProcedureId(procedureId).setTaskNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK)).
+                    setOrderId(order.getId()).setProcedureSort(0).setFirstProcedureFlag("1").setLastProcedureFlag("1").setDraftFlag("0").setResourceBusinessId(resourceBusinessId).setBomId(bomId).setMeterialId(bom.getMeterialId()).setPrority(100);
         }else{
             initTask = TTask.builder().build();
             BeanUtil.copyProperties(simpleTask, initTask, "id");
             initTask.setOrderId(order.getId()).setOrderNo(order.getOrderNo()).setPlanId(order.getPlanId()).setCompleteBatchNo(UUID.randomUUID().toString().replace("-", "")).setTaskNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK));
         }
-        Plan plan = planService.getOne(new LambdaQueryWrapper<Plan>().eq(Plan::getProduceStatus, "4").orderByDesc(Plan::getCreateTime).last("limit 1"));
+        Plan plan = planService.getById(planId);
+        /*
         if(plan!=null) {
             BeanUtil.copyProperties(plan, initPlan, "id");
+        }else{
+            initPlan.setPlanStatus("2").setAuditStatus("2").setProduceStatus("2").setPrority(50).setDraftFlag("1");
         }
         initPlan.setOrderId(order.getId()).setOrderNo(order.getOrderNo()).setPlanNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_PLAN));
+        */
         //orderProductService.save(initProduct);
-        planService.save(initPlan);
-        initTask.setPlanId(initPlan.getId());
+        plan.setPlanStatus("2").setAuditStatus("2").setProduceStatus("2");
+        planService.updateAllById(plan);
+        initTask.setPlanId(Long.parseLong(planId));
         return initTask;
     }
 
@@ -266,7 +274,7 @@ public class OrderTaskServiceImpl extends SuperServiceImpl<OrderTaskMapper, Orde
      * @param bom
      * @param conditionName
      */
-    public void inLineHandle(OrderTask orderTask, Storge startStorge, BBom bom, String conditionName, Long startResourceId, Long endResourceId){
+    public void inLineHandle(OrderTask orderTask, Storge startStorge, BBom bom, String conditionName, Long startResourceId, Long endResourceId, String planId){
         //线内提出多余的task任务
         int currentSort = conditionName.equals("BZ")? 0:1;
         Order order = orderService.getById(orderTask.getOrderId());
@@ -282,7 +290,7 @@ public class OrderTaskServiceImpl extends SuperServiceImpl<OrderTaskMapper, Orde
         }
         ResourceBusiness resourceBusiness = resourceBusinessMapper.selectOne(new LbqWrapper<ResourceBusiness>().eq(ResourceBusiness::getName, businessName));
         //初始化任务
-        TTask simpleTask = this.getSimpleTask(currentSort, order, bom, startResourceId, resourceBusiness.getId());
+        TTask simpleTask = this.getSimpleTask(currentSort, order, bom, startResourceId, resourceBusiness.getId(), planId);
         taskService.save(simpleTask);
         //初始化任务节点
         List<TaskNode> switchNodes = taskNodeService.getCreateTaskNode(resourceBusiness.getId(), simpleTask);
@@ -303,10 +311,9 @@ public class OrderTaskServiceImpl extends SuperServiceImpl<OrderTaskMapper, Orde
         });
         taskNodeService.saveBatch(taskNodes);
         //更新零件信息
-        TWorkpiece tWorkpiece = TWorkpiece.builder().build();
-        tWorkpiece.setOrderId(orderTask.getOrderId()).setOrderNo(order.getOrderNo()).setOrderName(order.getOrderName()).setCompleteBatchNo(simpleTask.getCompleteBatchNo()).setSerialNo(1).setIsEnd("0").setPlanId(simpleTask.getPlanId());
-        tWorkpiece.setPointId(startStorge.getPointId()).setStorgeId(startStorge.getId()).setCompleteBatchSort(0).setUniqueCode("");
-        tWorkpieceService.save(tWorkpiece);
+        TWorkpiece tWorkpiece = tWorkpieceService.getOne(new LambdaQueryWrapper<TWorkpiece>().eq(TWorkpiece::getIsEnd,"0").eq(TWorkpiece::getOrderId, simpleTask.getOrderId()).last("LIMIT 1"));
+        tWorkpiece.setCompleteBatchNo(simpleTask.getCompleteBatchNo()).setPointId(startStorge.getPointId()).setStorgeId(startStorge.getId()).setCompleteBatchSort(0).setUniqueCode("");
+        tWorkpieceService.updateById(tWorkpiece);
 
         //更新订单状态
         order.setOrderStatus("2");

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

@@ -2,6 +2,7 @@ package com.github.zuihou.business.operationManagementCenter.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -1586,12 +1587,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         }
         JSONObject callBackJsonParam = JSONObject.parseObject(jsonParam);
 
-        String taskType = callBackJsonParam.get("taskType").toString();
-        if(DictionaryKey.CARRY_TYPE.get("TOOL_HAND").equals(taskType)){
-            //刀具任务
-            //return toolTaskNodeService.toolTaskNodeCallback(bean);
+        //String taskType = callBackJsonParam.get("taskType").toString();
 
-        }
 
         //更换手抓
         /*if(StringUtil.isNotEmpty(stockType) && DemoLineConstant.TASK_TYPE_CHANGE.equals(stockType)){
@@ -2571,6 +2568,13 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
                 }
             }
             return result;
+        }else if (DemoLineConstant.DEMOLINE_CUT_TOOL_CRK.equals(stockType)){
+            //刀具出入库处理
+            targetStorgeId = callBackJson.getString("targetPostion");
+            StockInfo stockInfo = stockInfoService.getOne(new LbqWrapper<StockInfo>().eq(StockInfo::getGoodsType,"6").eq(StockInfo::getStorgeId, srcStorgeId).last("LIMIT 1"));
+            stockInfo.setStorgeId(Long.parseLong(targetStorgeId));
+            stockInfoService.updateById(stockInfo);
+            return R.success("");
         }
 
         // 最后一个工序最后一个节点

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

@@ -140,7 +140,7 @@ public class ToolRobotStrategy implements RobotStrategy {
         }
 
         //todo 与ccs联调需要释放  $需要换地址$
-        bool = this.cutToolActionCondition("/api/getCutterDeviceIsTake", taskNode,pointId);
+        //bool = this.cutToolActionCondition("/api/getCutterDeviceIsTake", taskNode,pointId);
 
         if(!bool){
             msgUtil.createWarnLog("刀具节点起始位取条件不满足","DataException");
@@ -190,7 +190,7 @@ public class ToolRobotStrategy implements RobotStrategy {
 
         msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 10, TimeUnit.DAYS);
 
-        returnMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
+        returnMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_CUT_TOOL_CRK);
         returnMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY")); //移动类型
         // 根据起始点位,获取点位属于的类型
 
@@ -201,10 +201,10 @@ public class ToolRobotStrategy implements RobotStrategy {
         TTask task = taskService.getById(taskNode.getTaskId());
         OrderTask orderTask = orderTaskService.getOne(new LbqWrapper<OrderTask>().eq(OrderTask::getOrderId, task.getOrderId()).last("LIMIT 1"));
         if(StringUtil.isNotEmpty(orderTask.getCutStartNo()) && !orderTask.getCutStartNo().equals("0")) {
-            locationMap.put("locationNo", "");  //起始刀位号
+            locationMap.put("locationNo", orderTask.getCutStartNo());  //起始刀位号
         }
         if(StringUtil.isNotEmpty(orderTask.getCutGoalNo()) && !orderTask.getCutGoalNo().equals("0")) {
-            locationMap.put("destLocationNo", "");  //目的刀位号
+            locationMap.put("destLocationNo", orderTask.getCutGoalNo());  //目的刀位号
         }
 
         locationMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY"));
@@ -259,7 +259,7 @@ public class ToolRobotStrategy implements RobotStrategy {
         }
 
         //todo 与ccs联调需要释放  $需要换地址$
-        bool = this.cutToolActionCondition("/api/getCutterDeviceIsPut", taskNode,pointId);
+        //bool = this.cutToolActionCondition("/api/getCutterDeviceIsPut", taskNode,pointId);
 
         if(!bool){
             msgUtil.createWarnLog("刀具节点目标位放置条件不满足","DataException");

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

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.util;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -524,6 +525,11 @@ public class MsgUtil implements ApplicationContextAware {
                 }
             }else{
                 jsonObject.put("bizType", BizConstant.MQ_TASK_NODE_TYPE_COMMON);
+                //机床刀具任务缓存处理
+                Object cutToolAction = msgUtil.redis_get(DemoLineConstant.DEMOLINE_CUT_DEVICE_ACTION);
+                if(ObjectUtil.isEmpty(cutToolAction)&& cutToolAction.toString().equals(taskNode.getId().toString())){
+                    msgUtil.redis_del(DemoLineConstant.DEMOLINE_CUT_DEVICE_ACTION);
+                }
                 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;