Przeglądaj źródła

调用指令失败释放预占资源释放改成通用方法

yejian 2 lat temu
rodzic
commit
e180a8abfb

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

@@ -410,15 +410,17 @@ public class TaskWorkNode {
                     // begin modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
                     log.setExeResult("0").setManual("0").setFeedback("设备资源不通过");
                     // 释放之前占用的资源
-                    String occupyResources = conMap.get("occupyResources")==null?"":(String)conMap.get("occupyResources");
-                    String[] occupyResourcesArray = occupyResources.split(",");
-                    for (String occupyResource : occupyResourcesArray){
-                        Storge storge = storgeService.getById(Long.valueOf(occupyResource));
-                        if("0".equals(storge.getLockStatus())){
-                            storge.setLockStatus("1");
-                            storgeService.updateById(storge);
-                        }
-                    }
+//                    String occupyResourcesKey = DictionaryType.OCCUPY_RESOURCE + taskNodeId;
+//                    String occupyResources = conMap.get(occupyResourcesKey)==null?"":(String)conMap.get(occupyResourcesKey);
+//                    String[] occupyResourcesArray = occupyResources.split(",");
+//                    for (String occupyResource : occupyResourcesArray){
+//                        Storge storge = storgeService.getById(Long.valueOf(occupyResource));
+//                        if("0".equals(storge.getLockStatus())){
+//                            storge.setLockStatus("1");
+//                            storgeService.updateById(storge);
+//                        }
+//                    }
+                    taskNodeService.freeLock(taskNode.getCompleteBatchNo());
                     conMap.put("result",false);
                     // end  modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
 
@@ -871,8 +873,8 @@ public class TaskWorkNode {
                         // begin modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
                         // TODO 后续可改成信号对接判断,先如果返回失败释放资源进去队列重新轮训
                         // 返回内容中记录当前任务占用资源
-                        String occupyResources = jqrStorge.getId() + "," + hcwStorge.getId() + "," + targetStorge.getId();
-                        dataMap.put("occupyResources",occupyResources);
+//                        String occupyResources = jqrStorge.getId() + "," + hcwStorge.getId() + "," + targetStorge.getId();
+//                        dataMap.put(DictionaryType.OCCUPY_RESOURCE + taskNode.getId()  ,occupyResources);
                         // end modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
 
                     }else{
@@ -998,8 +1000,8 @@ public class TaskWorkNode {
                         // begin modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
                         // TODO 后续可改成信号对接判断,先如果返回失败释放资源进去队列重新轮训
                         // 返回内容中记录当前任务占用资源
-                        String occupyResources = jqrStorge.getId() + "," + targetStorge.getId();
-                        dataMap.put("occupyResources",occupyResources);
+//                        String occupyResources = jqrStorge.getId() + "," + targetStorge.getId();
+//                        dataMap.put(DictionaryType.OCCUPY_RESOURCE+taskNode.getId(),occupyResources);
                         // end modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
                     }else{
                         dataMap.put("result", false);

+ 5 - 4
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl.java

@@ -31,6 +31,7 @@ import com.github.zuihou.business.productionResourceCenter.service.*;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.DictionaryKey;
+import com.github.zuihou.common.constant.DictionaryType;
 import com.github.zuihou.common.constant.ParameterKey;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
@@ -341,8 +342,8 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                             // begin modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
                             // TODO 后续可改成信号对接判断,先如果返回失败释放资源进去队列重新轮训
                             // 返回内容中记录当前任务占用资源
-                            String occupyResources = jqrStorge.getId() + "," + hcwStorge.getId() + "," + targetStorge.getId();
-                            dataMap.put("occupyResources",occupyResources);
+//                            String occupyResources = jqrStorge.getId() + "," + hcwStorge.getId() + "," + targetStorge.getId();
+//                            dataMap.put(DictionaryType.OCCUPY_RESOURCE+taskNode.getId(),occupyResources);
                             // end modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
                         }else{
                             dataMap.put("result", false);
@@ -446,8 +447,8 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                             // begin modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
                             // TODO 后续可改成信号对接判断,先如果返回失败释放资源进去队列重新轮训
                             // 返回内容中记录当前任务占用资源
-                            String occupyResources = jqrStorge.getId() + "," + targetStorge.getId();
-                            dataMap.put("occupyResources",occupyResources);
+//                            String occupyResources = jqrStorge.getId() + "," + targetStorge.getId();
+//                            dataMap.put(DictionaryType.OCCUPY_RESOURCE+taskNode.getId(),occupyResources);
                             // end modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
 
                         }else{

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

@@ -188,23 +188,23 @@ public class MsgUtil implements ApplicationContextAware {
                 Random random = new Random();
                 Boolean measuringFlag = random.nextBoolean();
 //                int measuringResult = measuringFlag ? 0 : 1;
-                int measuringResult = 1;
+                int measuringResult = 0;
                 String measuringResultFile = filePath + taskNode.getCompleteBatchNo() + "_" + task.getProcedureNo();
                 List<String> fileContents = new ArrayList<>();
                 OrderQuality orderQuality = new OrderQuality();
                 TTaskTestUnqualifiedBom taskTestUnqualifiedBom =  new TTaskTestUnqualifiedBom();
 
                 TWorkpiece workpiece = workpieceMapper.selectOne(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getCompleteBatchNo,task.getCompleteBatchNo()));
-                if(measuringResult == 1){
-                    fileContents.add("NG");
-                    orderQuality.setOkFlag("NG");
-                    workpiece.setTestResult("0");
-                    taskTestUnqualifiedBom.setTestResult("0");
-                }else{
+                if(measuringResult == 0){
                     fileContents.add("OK");
                     orderQuality.setOkFlag("OK");
                     workpiece.setTestResult("1");
                     taskTestUnqualifiedBom.setTestResult("1");
+                }else{
+                    fileContents.add("NG");
+                    orderQuality.setOkFlag("NG");
+                    workpiece.setTestResult("0");
+                    taskTestUnqualifiedBom.setTestResult("0");
                 }
                 SmbShareFileUtil.writeShareFileContent(measuringResultFile,fileContents,userName,password,fileIp);
                 Order order = orderMapper.selectById(task.getOrderId());