소스 검색

刀具功能处理

oyq28 1 개월 전
부모
커밋
746b3ed739

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

@@ -384,6 +384,8 @@ public class TaskWorkNode {
                         msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_STATUS + "_" + taskNode.getId(), "0");
                         // 自定义订单内部加工设备节点执行确认判断处理 判断成功直接更新状态
                         if(taskNode.getNodeName().equals("执行确认")){
+                            //刀具入刀库处理
+
                             taskNode.setExeStatus("3").setExeResult("1").setEndTime(new Date());
                             taskNodeService.updateById(taskNode);
                             tTask.setStatus("3").setEndTime(new Date());
@@ -397,7 +399,6 @@ public class TaskWorkNode {
                             Order order = orderMapper.selectById(tTask.getOrderId());
                             order.setCompleteNum(1).setProduceStatus("3");//完成
                             orderMapper.updateAllById(order);
-                            //机床刀具位上下料处理
 
                         }
                     } else {
@@ -913,7 +914,15 @@ 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(conMap.containsKey("locationNo")){
+            bizJsonObject.put("locationNo", conMap.get("locationNo").toString());
+        }
+        if(conMap.containsKey("destLocationNo")){
+            bizJsonObject.put("destLocationNo", conMap.get("destLocationNo").toString());
+        }
+
         //判断是否已换工装
         if (StringUtil.isNotEmpty(isReload)) {
             bizJsonObject.put("isReload", isReload);

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

@@ -239,7 +239,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     private MMeterialReceiveLogService meterialReceiveLogService;
 
     @Autowired
-    private ToolTaskNodeService toolTaskNodeService;
+    private CuttingToolService cuttingToolService;
 
     private static Logger logger = LoggerFactory.getLogger(TaskNodeServiceImpl.class);
 
@@ -2571,7 +2571,27 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         }else if (DemoLineConstant.DEMOLINE_CUT_TOOL_CRK.equals(stockType)){
             //刀具出入库处理
             targetStorgeId = callBackJson.getString("targetPostion");
+            String locationNo = callBackJson.getString("locationNo"); //起始刀位号
+            String destLocationNo = callBackJson.getString("destLocationNo"); //目的刀位号
             StockInfo stockInfo = stockInfoService.getOne(new LbqWrapper<StockInfo>().eq(StockInfo::getGoodsType,"6").eq(StockInfo::getStorgeId, srcStorgeId).last("LIMIT 1"));
+            //从机床刀库取
+            if(StringUtil.isNotEmpty(locationNo) && stockInfo == null){
+               CuttingTool cuttingTool = cuttingToolService.getOne(new LbqWrapper<CuttingTool>().eq(CuttingTool::getDeviceId, task.getResourceId()).eq(CuttingTool::getCutterNo, locationNo).last("LIMIT 1"));
+               cuttingTool.setDeviceId(null).setCutterNo(0L);
+               cuttingToolService.updateById(cuttingTool);
+               //刀具出库移动到目的位
+               stockInfo = StockInfo.builder().storgeId(Long.parseLong(targetStorgeId)).goodsType("6").goodsId(cuttingTool.getId()).lockStatus("1").num(1).completeBatchNo(task.getCompleteBatchNo()).build();
+               stockInfoService.save(stockInfo);
+               return R.success("");
+            }
+            //刀具放入机床
+            if(StringUtil.isNotEmpty(destLocationNo) && stockInfo != null){
+                CuttingTool cuttingTool = cuttingToolService.getOne(new LbqWrapper<CuttingTool>().eq(CuttingTool::getId, stockInfo.getGoodsId()).eq(CuttingTool::getCutterNo, 0).last("LIMIT 1"));
+                cuttingTool.setDeviceId(taskNode.getTargetResourceId()).setCutterNo(Long.parseLong(destLocationNo));
+                cuttingToolService.updateById(cuttingTool);
+                stockInfoService.delete(stockInfo);
+                return R.success("");
+            }
             stockInfo.setStorgeId(Long.parseLong(targetStorgeId));
             stockInfoService.updateById(stockInfo);
             return R.success("");

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

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.zuihou.authority.dto.priority.TaskNodePriorityDto;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
@@ -527,7 +528,7 @@ public class MsgUtil implements ApplicationContextAware {
                 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())){
+                if(ObjectUtil.isNotEmpty(cutToolAction)&& cutToolAction.toString().equals(taskNode.getId().toString())){
                     msgUtil.redis_del(DemoLineConstant.DEMOLINE_CUT_DEVICE_ACTION);
                 }
                 if(callBackJson.containsKey(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG)){//带缓存位机器人的多步骤执行
@@ -580,7 +581,7 @@ public class MsgUtil implements ApplicationContextAware {
                     logger.warn("【节点任务放入MQ】节点id:{}",nextTaskNode);
                     TaskNode nextNextNode = taskNodeService.getNextNTaskNode(nextTaskNode, 1);
                     boolean bool = nextTaskNode.getTargetResourceId()==null && nextNextNode!=null && nextNextNode.getTargetResourceId()!=null ;
-                    if(!"1".equals(taskNode.getNodeType()) && "0".equals(nextTaskNode.getNodeType())){
+                    if(!"1".equals(taskNode.getNodeType()) && "0".equals(nextTaskNode.getNodeType()) && nextNextNode!=null){
                         Productionresource productionresource = productionresourceBizMapper.selectById(nextNextNode.getTargetResourceId());
                         if(bool && StringUtil.isNotEmpty(productionresource.getModeSpecification())){
                             addPriorityList(nextTaskNode);
@@ -714,10 +715,24 @@ public class MsgUtil implements ApplicationContextAware {
      * @param method
      */
     public void createWarnLog(String content, String method){
-        AAutoNodeLog autoNodeLog = AAutoNodeLog.builder().build();
-        autoNodeLog.setStatus("0").setManual("1").setExeStatus("2").setMethod(method).setExecuteTime(new Date())
-                .setExeResult("0").setFeedback(content);
-        autoNodeLogService.save(autoNodeLog);
+        LambdaQueryWrapper<AAutoNodeLog> lbqWrapper = new LambdaQueryWrapper<AAutoNodeLog>();
+        lbqWrapper.eq(AAutoNodeLog::getStatus, "0").eq(AAutoNodeLog::getExeStatus, "2").eq(AAutoNodeLog::getManual, "1")
+                .eq(AAutoNodeLog::getMethod, method).eq(AAutoNodeLog::getExeResult, "0").eq(AAutoNodeLog::getFeedback, content);
+        AAutoNodeLog exist = autoNodeLogService.getOne(lbqWrapper);
+        if(null == exist) {
+            AAutoNodeLog autoNodeLog = AAutoNodeLog.builder().build();
+            autoNodeLog.setStatus("0").setManual("1").setExeStatus("2").setMethod(method).setExeResult("0").setFeedback(content);
+            autoNodeLog.setExecuteTime(new Date());
+            if(method.contains("Exception") || method.contains("Warn")){
+                //数据异常默认归类到保障中心异常
+                ZZone zone = zoneService.getOne(Wraps.<ZZone>lbQ().eq(ZZone::getNo, "safeguard").last("limit 1"));
+                autoNodeLog.setZoneId(zone.getId());
+            }
+            autoNodeLogService.save(autoNodeLog);
+        }else{
+            exist.setExecuteTime(new Date());
+            autoNodeLogService.updateAllById(exist);
+        }
     }
 
     public void pushDetailTask(TTask task) {

+ 2 - 1
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/edgeLibrary/entity/StockInfo.java

@@ -205,7 +205,7 @@ public class StockInfo extends Entity<Long> {
 
     @Builder
     public StockInfo(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, 
-                    Long storgeId, String lockStatus, String goodsType, Long goodsId, Integer num, 
+                    Long storgeId, String lockStatus, String goodsType, Long goodsId, Integer num, String completeBatchNo,
                     String uniqueCode, String turnTaskNo, String feedTaskNo,Long specId) {
         this.id = id;
         this.createTime = createTime;
@@ -221,6 +221,7 @@ public class StockInfo extends Entity<Long> {
         this.turnTaskNo = turnTaskNo;
         this.feedTaskNo = feedTaskNo;
         this.specId = specId;
+        this.completeBatchNo = completeBatchNo;
     }
 
 }