|
@@ -2,6 +2,7 @@ package com.github.zuihou.business.mq;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
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;
|
|
@@ -59,6 +60,7 @@ import com.github.zuihou.tenant.entity.ModuleInstruction;
|
|
|
import com.github.zuihou.tenant.service.ModuleInstructionService;
|
|
|
import com.github.zuihou.tenant.service.ModuleService;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import io.swagger.models.auth.In;
|
|
|
import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import net.sf.jsqlparser.statement.select.KSQLWindow;
|
|
@@ -175,9 +177,6 @@ public class TaskWorkNode {
|
|
|
@Autowired
|
|
|
private OrderTaskService orderTaskService;
|
|
|
|
|
|
- @Value("${imcs-to-ccs.enabled:true}")
|
|
|
- private Boolean imcsTOccsEnable;
|
|
|
-
|
|
|
//总控端口
|
|
|
private final String ZK_port = "120";
|
|
|
|
|
@@ -593,7 +592,6 @@ public class TaskWorkNode {
|
|
|
String jsonParam = getRequestParam(conMap);
|
|
|
//缓存执行当前节点传参
|
|
|
msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam,3,TimeUnit.DAYS);
|
|
|
- HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
|
|
|
|
|
|
//动态调用接口和新增指令执行时间
|
|
|
String instructionUrl = conMap.get("instructionUrl") + "/api/" + conMap.get("method").toString();
|
|
@@ -607,11 +605,7 @@ public class TaskWorkNode {
|
|
|
}
|
|
|
logger.info("instructionUrl={}" ,instructionUrl);
|
|
|
logger.info("[ECS指令发送]节点传参={}" ,jsonParam);
|
|
|
- if(imcsTOccsEnable){
|
|
|
- returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
|
|
|
- }else {
|
|
|
- returnData = "{\"result\": \"true\"}";
|
|
|
- }
|
|
|
+ returnData = msgUtil.httpForPost(instructionUrl, jsonParam);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -645,10 +639,9 @@ public class TaskWorkNode {
|
|
|
if (retJson != null) {
|
|
|
String code = retJson.getString("result").trim();
|
|
|
String concurrency = retJson.containsKey("concurrency")? retJson.getString("concurrency").trim() : "false";
|
|
|
+ String isUpload = retJson.containsKey("isUpload")? retJson.getString("isUpload").trim() : "false";
|
|
|
if (code.equals("true")) {
|
|
|
//回调处理
|
|
|
-// taskNode.setExeStatus("3").setEndTime(new Date()).setExeResult("1");
|
|
|
-// taskNodeService.updateAllById(taskNode);
|
|
|
log.setExeStatus("2").setEndTime(new Date()).setSendStatus("1").setExeResult("").setFeedback("");
|
|
|
// msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE_CONDITION + "_" + taskNode.getId());
|
|
|
// msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId());
|
|
@@ -657,7 +650,24 @@ public class TaskWorkNode {
|
|
|
// log.setExeResult("0").setManual("1").setFeedback(retJson.getString("msg"));
|
|
|
// 释放之前占用的资源 并发延迟带来的异常不释放锁定资源
|
|
|
if(concurrency.equals("false")) {
|
|
|
- // begin modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
|
|
|
+ //机床程序上传连续失败处理
|
|
|
+ if(isUpload.equals("true")){
|
|
|
+ int uploadFailCount = (Integer) msgUtil.redis_get(CacheKey.TASK_UPLOAD_FAIL_COUNT+"_"+taskNode.getId());
|
|
|
+ if(ObjectUtil.isEmpty(uploadFailCount)){
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_UPLOAD_FAIL_COUNT+"_"+taskNode.getId(),0, 7, TimeUnit.DAYS);
|
|
|
+ }else{
|
|
|
+ if(uploadFailCount < 5){
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_UPLOAD_FAIL_COUNT+"_"+taskNode.getId(),uploadFailCount++, 7, TimeUnit.DAYS);
|
|
|
+ }else{
|
|
|
+ //执行失败超过5次 直接改成暂存状态
|
|
|
+ taskNode.setExeStatus("4");
|
|
|
+ taskNodeService.updateById(taskNode);
|
|
|
+ msgUtil.redis_del(CacheKey.TASK_UPLOAD_FAIL_COUNT+"_"+taskNode.getId());
|
|
|
+ msgUtil.createWarnLog("上传程序连续失败节点"+taskNode.getId()+"进入暂停状态", "FileUploadException");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
log.setExeResult("0").setManual("0").setFeedback("设备资源和条件判断不通过");
|
|
|
taskNodeService.freeLock(taskNode.getCompleteBatchNo());
|
|
|
logger.warn("{}设备资源不通过释放节点", taskNode.getCompleteBatchNo());
|