|
@@ -21,9 +21,7 @@ import com.github.zuihou.business.externalApi.entity.AgvHikOrderInfo;
|
|
|
import com.github.zuihou.business.externalApi.service.AgvHikOrderInfoService;
|
|
import com.github.zuihou.business.externalApi.service.AgvHikOrderInfoService;
|
|
|
import com.github.zuihou.business.externalApi.service.ExternalApiService;
|
|
import com.github.zuihou.business.externalApi.service.ExternalApiService;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.*;
|
|
import com.github.zuihou.business.operationManagementCenter.dao.*;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.TTask;
|
|
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
|
|
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
|
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.*;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
|
|
import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
|
|
import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.AAutoNodeLogMapper;
|
|
import com.github.zuihou.business.productionReadyCenter.dao.AAutoNodeLogMapper;
|
|
@@ -185,7 +183,7 @@ public class TaskWorkNode {
|
|
|
|
|
|
|
|
private boolean lockCondition = true;
|
|
private boolean lockCondition = true;
|
|
|
|
|
|
|
|
- public void updateTaskStatusJob(String data, String consumerQueue) throws InterruptedException {
|
|
|
|
|
|
|
+ public void updateTaskStatusJob(String data, String consumerQueue, int priority) throws InterruptedException {
|
|
|
|
|
|
|
|
String returnData = "";
|
|
String returnData = "";
|
|
|
boolean specialCallBackMyselfFlag = false;
|
|
boolean specialCallBackMyselfFlag = false;
|
|
@@ -307,8 +305,8 @@ public class TaskWorkNode {
|
|
|
planMapper.updateproduceStatusBegin();
|
|
planMapper.updateproduceStatusBegin();
|
|
|
orderMapper.updateproduceStatusBegin();
|
|
orderMapper.updateproduceStatusBegin();
|
|
|
|
|
|
|
|
- msgUtil.redis_set(CacheKey.PRESOURCE_CURRENT_TASK + "_" + tTask.getResourceId(), tTask.getId());
|
|
|
|
|
- msgUtil.redis_set(CacheKey.PRESOURCE_CURRENT_TASK_OBJECT + "_" + tTask.getResourceId(), tTask);
|
|
|
|
|
|
|
+ msgUtil.redis_set(CacheKey.PRESOURCE_CURRENT_TASK + "_" + tTask.getResourceId(), tTask.getId(), 3, TimeUnit.DAYS);
|
|
|
|
|
+ msgUtil.redis_set(CacheKey.PRESOURCE_CURRENT_TASK_OBJECT + "_" + tTask.getResourceId(), tTask, 3, TimeUnit.DAYS);
|
|
|
}
|
|
}
|
|
|
//获取配置节点
|
|
//获取配置节点
|
|
|
// String autoProgramUrl = getInterfaceUrl(taskNode);
|
|
// String autoProgramUrl = getInterfaceUrl(taskNode);
|
|
@@ -318,7 +316,7 @@ public class TaskWorkNode {
|
|
|
taskNode.setAutoNode(resourceAutoCode);
|
|
taskNode.setAutoNode(resourceAutoCode);
|
|
|
|
|
|
|
|
isFinal = resourceAutoCode.isFinal() ? true : false;
|
|
isFinal = resourceAutoCode.isFinal() ? true : false;
|
|
|
- msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE + "_" + taskNode.getResourceId(), resourceAutoCode);
|
|
|
|
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE + "_" + taskNode.getResourceId(), resourceAutoCode, 3, TimeUnit.DAYS);
|
|
|
|
|
|
|
|
//更新节点任务
|
|
//更新节点任务
|
|
|
if("1".equals(taskNode.getExeStatus())){
|
|
if("1".equals(taskNode.getExeStatus())){
|
|
@@ -331,6 +329,22 @@ public class TaskWorkNode {
|
|
|
//不用调接口,直接返回成功
|
|
//不用调接口,直接返回成功
|
|
|
conMap.put("result",true);
|
|
conMap.put("result",true);
|
|
|
msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_STATUS + "_" + taskNode.getId(), "0", 2,TimeUnit.DAYS);
|
|
msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_STATUS + "_" + taskNode.getId(), "0", 2,TimeUnit.DAYS);
|
|
|
|
|
+ // 自定义订单内部加工设备节点执行确认判断处理 判断成功直接更新状态
|
|
|
|
|
+ if(taskNode.getNodeName().equals("执行确认")){
|
|
|
|
|
+ taskNode.setExeStatus("3").setExeResult("1").setEndTime(new Date());
|
|
|
|
|
+ taskNodeService.updateById(taskNode);
|
|
|
|
|
+ tTask.setStatus("3").setEndTime(new Date());
|
|
|
|
|
+ taskMapper.updateAllById(tTask);
|
|
|
|
|
+ TWorkpiece currWorkpiece = workpieceService.getWorkPiece(taskNode.getId());
|
|
|
|
|
+ currWorkpiece.setIsEnd("1");
|
|
|
|
|
+ workpieceService.updateById(currWorkpiece);
|
|
|
|
|
+ Plan plan = planMapper.selectById(tTask.getPlanId());
|
|
|
|
|
+ plan.setProduceStatus("4").setPlanStatus("3");
|
|
|
|
|
+ planMapper.updateById(plan);
|
|
|
|
|
+ Order order = orderMapper.selectById(tTask.getOrderId());
|
|
|
|
|
+ order.setCompleteNum(1).setProduceStatus("3");//完成
|
|
|
|
|
+ orderMapper.updateAllById(order);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
Map queryMap = Maps.newHashMap();
|
|
Map queryMap = Maps.newHashMap();
|
|
|
queryMap.put("bizType", bizType);
|
|
queryMap.put("bizType", bizType);
|
|
@@ -380,7 +394,7 @@ public class TaskWorkNode {
|
|
|
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
|
String jsonParam = getRequestParam(conMap);
|
|
String jsonParam = getRequestParam(conMap);
|
|
|
//缓存执行当前节点传参
|
|
//缓存执行当前节点传参
|
|
|
- msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam);
|
|
|
|
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam, 3, TimeUnit.DAYS);
|
|
|
HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
|
|
HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
|
|
|
|
|
|
|
|
//动态调用接口和新增指令执行时间
|
|
//动态调用接口和新增指令执行时间
|
|
@@ -404,7 +418,7 @@ public class TaskWorkNode {
|
|
|
JSONObject agvParam = new JSONObject();
|
|
JSONObject agvParam = new JSONObject();
|
|
|
agvParam.putAll(agvData);
|
|
agvParam.putAll(agvData);
|
|
|
//缓存执行当前节点传参
|
|
//缓存执行当前节点传参
|
|
|
- msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), agvParam.toJSONString());
|
|
|
|
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), agvParam.toJSONString(),3, TimeUnit.DAYS);
|
|
|
String zoneType = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.ZONE_TYPE).toString());
|
|
String zoneType = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.ZONE_TYPE).toString());
|
|
|
if(zoneType.equals(ParameterKey.ZONE_SFX)){
|
|
if(zoneType.equals(ParameterKey.ZONE_SFX)){
|
|
|
agvData.put("transferType","agv");
|
|
agvData.put("transferType","agv");
|
|
@@ -470,7 +484,7 @@ public class TaskWorkNode {
|
|
|
specialCallBackMyselfFlag = true;
|
|
specialCallBackMyselfFlag = true;
|
|
|
String jsonParam = getRequestParam(conMap);
|
|
String jsonParam = getRequestParam(conMap);
|
|
|
//缓存执行当前节点传参
|
|
//缓存执行当前节点传参
|
|
|
- msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam);
|
|
|
|
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam,3,TimeUnit.DAYS);
|
|
|
JSONObject ret = new JSONObject();
|
|
JSONObject ret = new JSONObject();
|
|
|
ret.put("result","true");
|
|
ret.put("result","true");
|
|
|
returnData = ret.toJSONString();
|
|
returnData = ret.toJSONString();
|
|
@@ -478,7 +492,7 @@ public class TaskWorkNode {
|
|
|
specialCallBackMyselfFlag = true;
|
|
specialCallBackMyselfFlag = true;
|
|
|
String jsonParam = getRequestParam(conMap);
|
|
String jsonParam = getRequestParam(conMap);
|
|
|
//缓存执行当前节点传参
|
|
//缓存执行当前节点传参
|
|
|
- msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam);
|
|
|
|
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam,3,TimeUnit.DAYS);
|
|
|
JSONObject ret = new JSONObject();
|
|
JSONObject ret = new JSONObject();
|
|
|
ret.put("result","true");
|
|
ret.put("result","true");
|
|
|
returnData = ret.toJSONString();
|
|
returnData = ret.toJSONString();
|
|
@@ -502,7 +516,7 @@ public class TaskWorkNode {
|
|
|
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
|
String jsonParam = getRequestParam(conMap);
|
|
String jsonParam = getRequestParam(conMap);
|
|
|
//缓存执行当前节点传参
|
|
//缓存执行当前节点传参
|
|
|
- msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam);
|
|
|
|
|
|
|
+ msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId(), jsonParam,3,TimeUnit.DAYS);
|
|
|
HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
|
|
HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
|
|
|
|
|
|
|
|
//动态调用接口和新增指令执行时间
|
|
//动态调用接口和新增指令执行时间
|
|
@@ -605,6 +619,9 @@ public class TaskWorkNode {
|
|
|
lock.unlock();
|
|
lock.unlock();
|
|
|
logger.info("节点{}名称{}释放锁",taskNode.getId(),taskNode.getNodeName());
|
|
logger.info("节点{}名称{}释放锁",taskNode.getId(),taskNode.getNodeName());
|
|
|
}
|
|
}
|
|
|
|
|
+ //优先级队列缓存处理
|
|
|
|
|
+ this.checkPriorityCondition(priority,"PRIORITY_"+consumerQueue.toUpperCase(),(boolean)conMap.get("result"), taskNodeId);
|
|
|
|
|
+
|
|
|
if(!(boolean)conMap.get("result")){
|
|
if(!(boolean)conMap.get("result")){
|
|
|
throw new InterruptedException("设备资源不通过,消息重新进入队尾");
|
|
throw new InterruptedException("设备资源不通过,消息重新进入队尾");
|
|
|
}else{
|
|
}else{
|
|
@@ -664,13 +681,38 @@ public class TaskWorkNode {
|
|
|
return count==0? true: false;
|
|
return count==0? true: false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 获取请求URL
|
|
|
|
|
|
|
+ * 优先级队列缓存处理
|
|
|
*
|
|
*
|
|
|
- * @param taskNode
|
|
|
|
|
- * @return
|
|
|
|
|
|
|
+ * @param priority
|
|
|
|
|
+ * @param key
|
|
|
*/
|
|
*/
|
|
|
|
|
+ private void checkPriorityCondition(int priority, String key, boolean flag, String taskNodeId) {
|
|
|
|
|
+ //优先级消息本地缓存队列处理
|
|
|
|
|
+ List<String> priorityConsumerQueue = null;
|
|
|
|
|
+ if(priority>0) {
|
|
|
|
|
+ key = key.replace(".","_");
|
|
|
|
|
+ String content = taskNodeId + "_" + priority;
|
|
|
|
|
+ priorityConsumerQueue = msgUtil.redis_get_list(key);
|
|
|
|
|
+ if(priorityConsumerQueue==null || priorityConsumerQueue.size()==0){
|
|
|
|
|
+ if(!flag) msgUtil.redis_set_list(key, content);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ boolean bool = priorityConsumerQueue.contains(content);
|
|
|
|
|
+ if(flag && bool){
|
|
|
|
|
+ msgUtil.redis_remove_list(key, content);
|
|
|
|
|
+ }else if(!bool){
|
|
|
|
|
+ msgUtil.redis_set_list(key, content);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取请求URL
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param taskNode
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
public String getInterfaceUrl(TaskNode taskNode) {
|
|
public String getInterfaceUrl(TaskNode taskNode) {
|
|
|
String autoProgramUrl = "";
|
|
String autoProgramUrl = "";
|
|
|
if (DictionaryKey.INTERFACETYPE_PLC.equals(taskNode.getInterfaceType())) {//总控
|
|
if (DictionaryKey.INTERFACETYPE_PLC.equals(taskNode.getInterfaceType())) {//总控
|
|
@@ -773,7 +815,7 @@ public class TaskWorkNode {
|
|
|
jsonObject.put("code", "1");
|
|
jsonObject.put("code", "1");
|
|
|
logger.info("节点请求参数" + jsonObject.toJSONString());
|
|
logger.info("节点请求参数" + jsonObject.toJSONString());
|
|
|
|
|
|
|
|
- msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + taskNode.getId(), bizJsonObject.toJSONString(), 10, TimeUnit.DAYS);
|
|
|
|
|
|
|
+ msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + taskNode.getId(), bizJsonObject.toJSONString(), 7, TimeUnit.DAYS);
|
|
|
//临时先把请求参数放出来
|
|
//临时先把请求参数放出来
|
|
|
msgUtil.redis_set("testParam", bizJsonObject.toJSONString(), 1, TimeUnit.DAYS);
|
|
msgUtil.redis_set("testParam", bizJsonObject.toJSONString(), 1, TimeUnit.DAYS);
|
|
|
|
|
|
|
@@ -1455,14 +1497,17 @@ public class TaskWorkNode {
|
|
|
int count = agvHikOrderInfoService.count(new LbqWrapper<AgvHikOrderInfo>().eq(AgvHikOrderInfo::getTaskNodeId, taskNode.getId()).eq(AgvHikOrderInfo::getTaskId, taskNode.getTaskId()).eq(AgvHikOrderInfo::getAgvTaskType, "1").eq(AgvHikOrderInfo::getResponseCode, "0"));
|
|
int count = agvHikOrderInfoService.count(new LbqWrapper<AgvHikOrderInfo>().eq(AgvHikOrderInfo::getTaskNodeId, taskNode.getId()).eq(AgvHikOrderInfo::getTaskId, taskNode.getTaskId()).eq(AgvHikOrderInfo::getAgvTaskType, "1").eq(AgvHikOrderInfo::getResponseCode, "0"));
|
|
|
|
|
|
|
|
//目标产线的可用线边库数量小于3时 不呼叫AGV
|
|
//目标产线的可用线边库数量小于3时 不呼叫AGV
|
|
|
- String targetNo = stockInfoService.getTargetNo(goalZone, targetPosition.getCode());
|
|
|
|
|
- Map paramMap = Maps.newHashMap();
|
|
|
|
|
- paramMap.put("targetNo", targetNo);
|
|
|
|
|
- //获取目标线边库
|
|
|
|
|
- List<Map> xbkValidList = stockInfoService.getXbkCountByShelves(paramMap);
|
|
|
|
|
- xbkValidList = xbkValidList.stream().filter(item->item.containsKey("cnt") && (long)item.get("cnt")<=3).collect(Collectors.toList());
|
|
|
|
|
- if(xbkValidList.size()>0){
|
|
|
|
|
- msgUtil.createWarnLog("目标产线临时线边库("+targetNo+")可用库位小于3,系统停止自动呼叫AGV托板功能", "DataException");
|
|
|
|
|
|
|
+ List<Map> xbkValidList = new ArrayList<Map>();
|
|
|
|
|
+ if(targetPosition!=null) {
|
|
|
|
|
+ String targetNo = stockInfoService.getTargetNo(goalZone, targetPosition.getCode());
|
|
|
|
|
+ Map paramMap = Maps.newHashMap();
|
|
|
|
|
+ paramMap.put("targetNo", targetNo);
|
|
|
|
|
+ //获取目标线边库
|
|
|
|
|
+ xbkValidList = stockInfoService.getXbkCountByShelves(paramMap);
|
|
|
|
|
+ xbkValidList = xbkValidList.stream().filter(item->item.containsKey("cnt") && (long)item.get("cnt")<=3).collect(Collectors.toList());
|
|
|
|
|
+ if(xbkValidList.size()>0){
|
|
|
|
|
+ msgUtil.createWarnLog("目标产线临时线边库("+targetNo+")可用库位小于3,系统停止自动呼叫AGV托板功能", "DataException");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(startPosition!=null && targetPosition!=null && count == 0 && xbkValidList.size()==0){
|
|
if(startPosition!=null && targetPosition!=null && count == 0 && xbkValidList.size()==0){
|