Jelajahi Sumber

Merge remote-tracking branch 'origin/master' into master

姚云青 4 tahun lalu
induk
melakukan
aebf4fe4ee
13 mengubah file dengan 515 tambahan dan 208 penghapusan
  1. 48 6
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/impl/ScheduleUserDateServiceImpl.java
  2. 12 4
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/ConsumerHandler.java
  3. 214 170
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java
  4. 24 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/TaskBizMapper.java
  5. 31 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskBizService.java
  6. 28 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskBizServiceImpl.java
  7. 44 14
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/impl/BomProcedureVersionServiceImpl.java
  8. 3 2
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/impl/ProductLinePerformanceServiceImpl.java
  9. 2 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/DynamicRabbitMq.java
  10. 59 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TaskBizMapper.xml
  11. 0 11
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/classSchedule/ScheduleFrequencyController.java
  12. 47 0
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/TaskBizController.java
  13. 3 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/TTask.java

+ 48 - 6
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/impl/ScheduleUserDateServiceImpl.java

@@ -1,6 +1,5 @@
 package com.github.zuihou.business.classSchedule.service.impl;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import com.github.zuihou.authority.service.auth.UserService;
@@ -10,18 +9,18 @@ import com.github.zuihou.business.classSchedule.entity.ScheduleUserDate;
 import com.github.zuihou.business.classSchedule.service.ScheduleUserDateService;
 import com.github.zuihou.base.service.SuperServiceImpl;
 
-import com.github.zuihou.common.constant.BizConstant;
+import com.github.zuihou.common.util.DateUtil;
+import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static com.github.zuihou.utils.BizAssert.isFalse;
 
@@ -194,6 +193,15 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
         return sql;
     }
 
+    private static String dayofWeek(Calendar date) {
+        String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六" };
+        int w = date.get(Calendar.DAY_OF_WEEK) -1;
+        if(w < 0){
+            w = 0;
+        }
+        return weekDays[w];
+    }
+
     @Override
     public ScheduleUserDate save(ScheduleUserDateSaveDTO data) {
         List<Long>userList = data.getUserList();
@@ -203,6 +211,40 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
         isFalse(userList==null||userList.size()==0, "请选择排班部门人员");
         isFalse(dateList==null||dateList.size()==0, "请选择设置日期");
 
+        // 判断基础表c_common_date_info是否存在设定日期的值,如果没有,先插入90天
+        List<Map<String,Object>> maxCommonDates = baseMapper.selectSql("select max(ifnull(date,'')) AS maxCommonDate from c_common_date_info");
+        String maxDate = "";
+        for (String selectDate : data.getDateList()){
+            if(StringUtils.isBlank(maxDate)){
+                maxDate = selectDate;
+            }
+            if(maxDate.compareTo(selectDate) < 0){
+                maxDate = selectDate;
+            }
+        }
+
+        if(CollectionUtil.isEmpty(maxCommonDates)
+                || (!CollectionUtil.isEmpty(maxCommonDates) && maxDate.compareTo(null == maxCommonDates.get(0) ? "":maxCommonDates.get(0).get("maxCommonDate").toString() ) > 0)){
+            int i = 0;
+            Calendar calendar = Calendar.getInstance();
+            Date date = null;
+            if(null == maxCommonDates.get(0)){
+                date=calendar.getTime();
+                calendar.setTime(date);
+                calendar.add(Calendar.DATE , -1);
+            }else{
+                date=  DateUtil.stringToDate3(maxCommonDates.get(0).get("maxCommonDate").toString());
+                calendar.setTime(date);
+            }
+
+            while( i <= 90){
+                calendar.add(Calendar.DATE , 1);
+                String sql = "insert into c_common_date_info values (" + "'" + DateUtil.dateToString(calendar.getTime()) + "','" + dayofWeek(calendar) + "')";
+                baseMapper.selectSql(sql);
+                i++;
+            }
+        }
+
         //主要验证不能同一人,同一天,不能有休班和排班TODO
 
         //同一天,同一个人有相同排班,则先删除,后插入

+ 12 - 4
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/ConsumerHandler.java

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.mq;
 
 import com.github.zuihou.business.util.DynamicRabbitMq;
+import com.github.zuihou.exception.BizException;
 import com.rabbitmq.client.Channel;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
@@ -9,6 +10,8 @@ import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.io.IOException;
+
 @Component
 @Slf4j
 @Data
@@ -35,10 +38,15 @@ public class ConsumerHandler implements ChannelAwareMessageListener {
         try {
             handleMessage(data);
             channel.basicAck(deliveryTag, false);
-        } catch (Exception e) {
-            channel.basicNack(deliveryTag, false, false);//消息消费失败将丢弃该消息
-            //注意 : 第二个参数为true时,重新入队,进入了队列尾部
-            e.printStackTrace();
+        } catch(Exception e){
+            log.error("MQ异常:"+e.getMessage());
+            //是否重试请求
+            if (message.getMessageProperties().getRedelivered()) {
+                channel.basicNack(deliveryTag, false, false);//消息消费失败将丢弃该消息
+            }else{
+                log.error("消息消费失败将丢弃该消息");
+                channel.basicNack(deliveryTag, false, true);
+            }
         }
     }
 

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

@@ -50,6 +50,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 jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -57,14 +58,16 @@ import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestClientException;
 import org.springframework.web.client.RestTemplate;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 import static java.util.stream.Collectors.groupingBy;
 
@@ -104,14 +107,14 @@ public class TaskWorkNode {
     private ModuleService moduleService;
 
     @Autowired
-    private ModuleInstructionService  moduleInstructionService;
+    private ModuleInstructionService moduleInstructionService;
     private NodeOperationService nodeOperationService;
 
     @Autowired
-    private ResourceBusinessService  resourceBusinessService;
+    private ResourceBusinessService resourceBusinessService;
 
     @Autowired
-    private ResourceAutoCodeService  resourceAutoCodeService;
+    private ResourceAutoCodeService resourceAutoCodeService;
 
     @Autowired
     private ZZoneProductionresourceMapper zZoneProductionresourceMapper;
@@ -147,28 +150,28 @@ public class TaskWorkNode {
 
     public void updateTaskStatusJob(String data) throws InterruptedException {
         JSONObject jsonObject = JSONObject.parseObject(data);
-        System.out.println("返回请求数据: "+data);
+        System.out.println("返回请求数据: " + data);
         String taskNodeId = jsonObject.getString("taskNodeId");
         //业务类型-1、是普通的节点类型,2-是线边库轮询
         String bizType = jsonObject.getString("bizType");
 
         //多产品搬运类型
         String carryType = jsonObject.getString("carryType");
-        if(StringUtil.isEmpty(taskNodeId) || StringUtil.isEmpty(bizType)){
-            throw new InterruptedException("全局通知异常");
+        if (StringUtil.isEmpty(taskNodeId) || StringUtil.isEmpty(bizType)) {
+            throw new RuntimeException("全局通知异常");
         }
         logger.info("=======================" + taskNodeId);
         BaseContextHandler.setTenant("0000");
 
         TaskNode taskNode = taskNodeService.getById(taskNodeId);
 //
-        if (taskNode == null || taskNode.getTaskId()== null) {
+        if (taskNode == null || taskNode.getTaskId() == null) {
             //模拟处理数据
-            throw new BizException(-1, "当前任务节点为空");
+            throw new RuntimeException("当前任务节点为空");
         }
         TTask tTask = taskMapper.selectById(taskNode.getTaskId());
         if (tTask == null || tTask.getStatus() == "3") {
-            throw new BizException(-1, "当前任务为空");
+            throw new RuntimeException("当前任务为空");
         }
 //        //获取配置序数据
         //任务初始化判断
@@ -189,7 +192,7 @@ public class TaskWorkNode {
         ResourceAutoCode resourceAutoCode = resourceAutoCodeService.getById(taskNode.getAutoNode().getId());
         taskNode.setAutoNode(resourceAutoCode);
 
-        isFinal = resourceAutoCode.isFinal()? true : false;
+        isFinal = resourceAutoCode.isFinal() ? true : false;
         msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE + "_" + taskNode.getResourceId(), resourceAutoCode);
 
         List<AAutoNodeLog> autoNodeLogList = autoNodeLogMapper.selectList(Wraps.<AAutoNodeLog>lbQ().eq(AAutoNodeLog::getTaskNodeId, taskNode.getId()));
@@ -215,8 +218,7 @@ public class TaskWorkNode {
                 //人工上下料或质检
                 //不用调接口,直接返回成功
                 msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_STATUS + "_" + taskNode.getId(), "0");
-            }
-            else {
+            } else {
                 Map queryMap = Maps.newHashMap();
                 queryMap.put("bizType", bizType);
                 queryMap.put("carryType", carryType);
@@ -225,39 +227,42 @@ public class TaskWorkNode {
                 }
 
                 //把产线放进去,避免多次查询
-                ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId,taskNode.getResourceId()));
+                ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId, taskNode.getResourceId()));
                 ZZone zZone = zoneService.getById(zoneProductionresource.getZoneId());
-                queryMap.put("zone",zZone);
+                queryMap.put("zone", zZone);
                 //运行条件验证
                 Map conMap = checkCon(taskNode, tTask, queryMap);
-                msgUtil.redis_set_map(CacheKey.TASK_CURRENT_NODE_CONDITION+ "_" + taskNode.getId(), conMap);
+                if (null == conMap) {
+                    throw new RuntimeException("执行超时或执行设备状态异常");
+                }
+                msgUtil.redis_set_map(CacheKey.TASK_CURRENT_NODE_CONDITION + "_" + taskNode.getId(), conMap);
 
-                if("03".equals(taskNode.getInterfaceType())){
-                    TaskNode beforTaskNode = taskNodeService.getNextNTaskNode(taskNode,-1);
+                if ("03".equals(taskNode.getInterfaceType())) {
+                    TaskNode beforTaskNode = taskNodeService.getNextNTaskNode(taskNode, -1);
                     // agv搬运
                     Map agvData = new HashMap();
-                    agvData.put("start",conMap.get("start"));
+                    agvData.put("start", conMap.get("start"));
                     agvData.put("goal", conMap.get("goal"));
-                    agvData.put("taskId",tTask.getId().toString());
-                    agvData.put("taskNodeId",taskNode.getId().toString());
+                    agvData.put("taskId", tTask.getId().toString());
+                    agvData.put("taskNodeId", taskNode.getId().toString());
                     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);
                     agvHikOrderInfoService.addHikTask(agvData);
-                }else{
+                } else {
                     //组装接口参数
                     HttpHeaders headers = new HttpHeaders();
                     headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
                     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);
                     HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
 
                     //动态调用接口和新增指令执行时间
                     log.setMethod(conMap.get("method").toString()).setExecuteTime(new Date());
-                    String instructionUrl = DictionaryKey.INSTRUCTION_URL +"/api/"+ conMap.get("method").toString() ;
-                    System.out.println("instructionUrl="+instructionUrl);
-                    System.out.println("jsonParam="+jsonParam);
+                    String instructionUrl = DictionaryKey.INSTRUCTION_URL + "/api/" + conMap.get("method").toString();
+                    System.out.println("instructionUrl=" + instructionUrl);
+                    System.out.println("jsonParam=" + jsonParam);
                     returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
 
                     logger.info("returnData=", returnData);
@@ -270,30 +275,31 @@ public class TaskWorkNode {
             errJsonObject.put("msg", e.getMessage());
             returnData = errJsonObject.toJSONString();
             logger.error("调用接口发生异常" + e.getMessage());
-        }
-        logger.info("===============================接口返回" + returnData);
-        JSONObject retJson = JSONObject.parseObject(returnData);
-        if(retJson!=null){
-            String code = retJson.getString("result").trim();
-            if(code == "true") {
-                //回调处理
-                taskNode.setExeStatus("3").setEndTime(new Date()).setExeResult("1");
-                taskNodeService.updateAllById(taskNode);
-                log.setExeStatus("3").setEndTime(new Date()).setExeResult("1").setFeedback("");
-                msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE_CONDITION + "_" + taskNode.getId());
-                msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId());
-            }else if(code == "0"){
-                //需要人工处理解决警报异常
-                log.setExeResult("0").setManual("1").setFeedback(retJson.getString("msg"));
-            }else if(code == "2"){
-                //执行异常处理(无须人工处理和警报提示)
-                log.setExeResult("0").setManual("0").setFeedback(retJson.getString("msg"));
+        } finally {
+            logger.info("===============================接口返回" + returnData);
+            JSONObject retJson = JSONObject.parseObject(returnData);
+            if (retJson != null) {
+                String code = retJson.getString("result").trim();
+                if (code.equals("true")) {
+                    //回调处理
+                    taskNode.setExeStatus("3").setEndTime(new Date()).setExeResult("1");
+                    taskNodeService.updateAllById(taskNode);
+                    log.setExeStatus("3").setEndTime(new Date()).setExeResult("1").setFeedback("");
+                    msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE_CONDITION + "_" + taskNode.getId());
+                    msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNode.getId());
+                } else if (code.equals("false")) {
+                    //需要人工处理解决警报异常
+                    log.setExeResult("0").setManual("1").setFeedback(retJson.getString("msg"));
+                } else if (code.equals("exception")) {
+                    //执行异常处理(无须人工处理和警报提示)
+                    log.setExeResult("0").setManual("0").setFeedback(retJson.getString("msg"));
+                }
+            }
+            if (log.getId() == null) {
+                autoNodeLogService.save(log);
+            } else {
+                autoNodeLogService.updateAllById(log);
             }
-        }
-        if(log.getId()==null){
-            autoNodeLogService.save(log);
-        }else{
-            autoNodeLogService.updateAllById(log);
         }
     }
 
@@ -341,7 +347,7 @@ public class TaskWorkNode {
         TaskNode taskNode = (TaskNode) conMap.get("taskNode");
         TTask task = (TTask) conMap.get("task");
         //业务类型
-        String bizType = conMap.get("bizType")== null ? "" : conMap.get("bizType").toString();
+        String bizType = conMap.get("bizType") == null ? "" : conMap.get("bizType").toString();
 
         String count = conMap.get(taskNode.getId() + "count") == null ? "" : conMap.get(taskNode.getId() + "count").toString();
 
@@ -355,7 +361,7 @@ public class TaskWorkNode {
         jsonObject.put("taskNodeId", taskNode.getId());
 //        jsonObject.put("bizType", bizType);
         //jsonObject.put("uid", taskNode.getCreateUser() + "");
-        jsonObject.put("url",  conMap.get("url"));
+        jsonObject.put("url", conMap.get("url"));
         jsonObject.put("port", conMap.get("port"));
         jsonObject.put("data", conMap.get("data"));
 
@@ -378,20 +384,20 @@ public class TaskWorkNode {
         }
 
         //起点、终点缓存。
-        Storge fstorge =  conMap.get("fromStorge") == null?null:(Storge) conMap.get("fromStorge") ;
-        Storge tstorge =  conMap.get("toStorge") == null?null:(Storge) conMap.get("toStorge") ;
+        Storge fstorge = conMap.get("fromStorge") == null ? null : (Storge) conMap.get("fromStorge");
+        Storge tstorge = conMap.get("toStorge") == null ? null : (Storge) conMap.get("toStorge");
         //如果是线边库的时候,目标缓存位
-        Storge aimStorge =  conMap.get("aimStorge") == null?null:(Storge) conMap.get("aimStorge") ;
+        Storge aimStorge = conMap.get("aimStorge") == null ? null : (Storge) conMap.get("aimStorge");
 
         //此数据用来业务回传
-        bizJsonObject.put("srcPosition",  fstorge==null?"":fstorge.getId().toString());
-        bizJsonObject.put("targetPostion",tstorge==null?"":tstorge.getId().toString());
-        bizJsonObject.put("aimStorge",aimStorge==null?"":aimStorge.getId().toString());
+        bizJsonObject.put("srcPosition", fstorge == null ? "" : fstorge.getId().toString());
+        bizJsonObject.put("targetPostion", tstorge == null ? "" : tstorge.getId().toString());
+        bizJsonObject.put("aimStorge", aimStorge == null ? "" : aimStorge.getId().toString());
         bizJsonObject.put("bizType", bizType);
 
         //放入到线边库
         String xbkFlag = conMap.get(DemoLineConstant.DEMOLINE_XBKFLAG) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_XBKFLAG).toString();
-        if(StringUtil.isNotEmpty(xbkFlag)){
+        if (StringUtil.isNotEmpty(xbkFlag)) {
             bizJsonObject.put(DemoLineConstant.DEMOLINE_XBKFLAG, xbkFlag);
         }
 
@@ -401,7 +407,7 @@ public class TaskWorkNode {
         jsonObject.put("code", "1");
         logger.info("节点请求参数" + jsonObject.toJSONString());
 
-        msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM+"_"+taskNode.getId(), bizJsonObject.toJSONString(), 1, TimeUnit.DAYS);
+        msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + taskNode.getId(), bizJsonObject.toJSONString(), 1, TimeUnit.DAYS);
         //临时先把请求参数放出来
         msgUtil.redis_set("testParam", bizJsonObject.toJSONString(), 1, TimeUnit.DAYS);
 
@@ -418,48 +424,83 @@ public class TaskWorkNode {
      * @return
      * @throws Exception
      */
-     public Map checkCon(TaskNode taskNode, TTask task, Map<String, Object> dataMap) throws BizException, InterruptedException {
-        Map map = getCheckCon(taskNode, task, dataMap);
-        boolean b = (boolean) map.get("result");
-        if (!b) {
-            Thread.sleep(10000);
-            return checkCon(taskNode, task, dataMap);
+    public Map checkCon(TaskNode taskNode, TTask task, Map<String, Object> dataMap) {
+//        Map map = getCheckCon(taskNode, task, dataMap);
+//        boolean b = (boolean) map.get("result");
+//        if (!b) {
+//            Thread.sleep(10000);
+//            return checkCon(taskNode, task, dataMap);
+//        } else {
+//            return map;
+//        }
+        logger.info("异步消息获取执行状态:");
+        //单线程化线程池
+        //初始化执行次数(默认10次) 10次后按超时处理
+        ExecutorService pool = Executors.newSingleThreadExecutor();
+        List<CompletableFuture<Map>> futures = new ArrayList<CompletableFuture<Map>>();
+
+        List<Map> retList = new ArrayList<Map>();
+        int[] nums = IntStream.range(0, 9).toArray();
+
+        CompletableFuture<Map> future = CompletableFuture.supplyAsync(() -> {
+            Map<String, Object> threadMap = getCheckCon(taskNode, task, dataMap);
+            boolean bool= (Boolean) threadMap.get("result");
+            return bool? threadMap: null;
+        }, pool).handle((result, ex) -> {
+            if (null != ex) {
+                return null;
+            } else {
+                if(null!=result){
+                   retList.add((Map)result);
+                }
+                return result;
+            }
+        });
+
+        if (null == future.join()){
+            //开启异步串行调用
+            for (int i : nums) {
+                logger.info("节点:" + taskNode.getId() + "进行第" + i + "次异步轮询条件查询");
+                future = future.thenApply(map -> {
+                    Map<String, Object> threadMap = null;
+                    try {
+                        TimeUnit.SECONDS.sleep(5 * i);
+                        threadMap = getCheckCon(taskNode, task, dataMap);
+                    } catch (InterruptedException ie) {
+                        ie.printStackTrace();
+                    }
+                    boolean bool= (Boolean) threadMap.get("result");
+                    return bool? threadMap: null;
+                });
+                if (null != future.join()) {
+                    boolean bool = (Boolean) future.join().get("result");
+                    if (bool) {
+                        retList.add((Map) future.join());
+                        break;
+                    }
+                }
+            }
+        }
+
+         /*
+         CompletableFuture.anyOf(futures.toArray(new CompletableFuture[futures.size()])).whenComplete((res, ex)->{
+             if(res!=null && ex==null){
+                 retList.add((Map)res);
+             }
+         }); */
+
+        if (retList.size() == 0) {
+            logger.error("节点:" + taskNode.getId() + "条件判断超时");
+            //return checkCon(taskNode, task, dataMap);
+            //pool.shutdown();
+            //throw new BizException("执行异常或判断超时");
+            return null;
         } else {
-            return map;
+            pool.shutdown();
+            logger.info("条件判断成功");
+            return retList.get(0);
         }
-//        logger.info("异步消息获取执行状态:");
-//        ExecutorService pool = Executors.newCachedThreadPool();
-//        CompletableFuture<Map> future = CompletableFuture.supplyAsync(()->{
-//            Map map = Maps.newHashMap();
-//            try {
-//                TimeUnit.SECONDS.sleep(2);
-//                map = getCheckCon(taskNode, task, dataMap);
-//            }
-//            catch(InterruptedException e){
-//                throw new RuntimeException(e);
-//            }
-//            return map;
-//        }, pool);
-//         future.whenCompleteAsync((v, ex) ->{
-//             if(ex == null){
-//                 Map map = future.join();
-//                 boolean bool = (boolean) map.get("result");
-//                 if(bool){
-//                     logger.info("条件判断成功,关闭线程池");
-//                     pool.shutdown();
-//                 }else{
-//                     try {
-//                         checkCon(taskNode, task, dataMap);
-//                     } catch (Exception e) {
-//                         e.printStackTrace();
-//                     }
-//                 }
-//             }else{
-//                 throw new RuntimeException(ex);
-//             }
-//         });
-//         return future.join();
-     }
+    }
 
     /**
      * 具体验证
@@ -482,7 +523,7 @@ public class TaskWorkNode {
 //        String robotType = resourceAutoCode.getResourceId().toString();
 
         //获取节点指令集
-        Module module  = getModuleInfo(task.getResourceId().toString());
+        Module module = getModuleInfo(task.getResourceId().toString());
         List<ModuleInstruction> moduleInstructions = moduleInstructionService.list(new LbqWrapper<ModuleInstruction>().eq(ModuleInstruction::getModuleId, module.getId()).eq(ModuleInstruction::getPublishStatus, "1"));
 
         //判断夹具资源
@@ -491,7 +532,7 @@ public class TaskWorkNode {
         Map<String, Object> map = Maps.newHashMap();
         map.put("taskNode", taskNode);
         map.put("task", task);
-        map.put(taskNode.getId() +"count", count);
+        map.put(taskNode.getId() + "count", count);
         map.put("bizType", bizType);
         map.put("categoryName", DictionaryKey.RESOURCE_CATEGORY.get(category));
         map.put("instructions", moduleInstructions);
@@ -507,36 +548,37 @@ public class TaskWorkNode {
             //map.put("robotType", DictionaryKey.LINE_ROBOT_NODES.get(robotType));
 //            map.put("robotType", DictionaryKey.YJ_ROBOT_NODES.get(robotType));
             nodeOperationService = MsgUtil.getBean(RobotNodeServiceImpl.class);
-        } else if("4".equals(category)) {
-            nodeOperationService  = MsgUtil.getBean(OtherNodeServiceImpl.class);
+        } else if ("4".equals(category)) {
+            nodeOperationService = MsgUtil.getBean(OtherNodeServiceImpl.class);
         }
         //初始化设备资源
-        logger.info("========设备资源初始化=======" + module.getName()+"====="+taskNode.getResourceId());
+        logger.info("========设备资源初始化=======" + module.getName() + "=====" + taskNode.getResourceId());
         nodeOperationService.initResource(taskNode, task, map);
 
-        if (bizType.equals(BizConstant.MQ_TASK_NODE_TYPE_COMMON))  {//正常节点类型
+        if (bizType.equals(BizConstant.MQ_TASK_NODE_TYPE_COMMON)) {//正常节点类型
 //            BomProcedureProductionresource bomProcedureProductionresource = bomProcedureProductionresourceService.getOne(new QueryWrapper<BomProcedureProductionresource>().eq("resourceId",task.getResourceId()).eq("procedureId", task.getProcedureId()));
             //List<ResourceAutoCode>  resourceAutoCodeList = resourceAutoCodeService.getNodeList(resourceAutoCode);
             //业务序列节点
             //ResourceAutoCode parentAutoCode = resourceAutoCodeService.getById(resourceAutoCode.getParentId());
-            logger.info("=============进入自动化节点条件检测==============" + resourceAutoCode.getName() );
+            logger.info("=============进入自动化节点条件检测==============" + resourceAutoCode.getName());
             map = nodeOperationService.checkCondition(taskNode, task, map);
-        }else{
-            logger.info("=============进入线边库条件检测==============" + resourceAutoCode.getName() );
+        } else {
+            logger.info("=============进入线边库条件检测==============" + resourceAutoCode.getName());
             map = checkXbkCon(taskNode, task, map);
         }
+        //System.out.println(map.get("result").toString());
         return map;
     }
 
     /**
-     *  线边库条件处理判断
-     * @param dataMap
+     * 线边库条件处理判断
      *
+     * @param dataMap
      * @return
      */
-    public Map checkXbkCon(TaskNode taskNode,TTask task, Map<String, Object> dataMap){
-        ZZone zone = dataMap.get("zone")==null?null:(ZZone)dataMap.get("zone");
-        int  count = Integer.parseInt (dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString());
+    public Map checkXbkCon(TaskNode taskNode, TTask task, Map<String, Object> dataMap) {
+        ZZone zone = dataMap.get("zone") == null ? null : (ZZone) dataMap.get("zone");
+        int count = Integer.parseInt(dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString());
 
         Storge jqrStorge = null;
 
@@ -548,7 +590,7 @@ public class TaskWorkNode {
 
         //前序是设备序并且最后一个节点是agv搬运,锁定agv相关库位信息
 
-        if(BizConstant.ROBOT_TYPE_CACHE.equals(zoneService.getRobotTypebyZone(zone.getName()))){//有缓存位的机器人
+        if (BizConstant.ROBOT_TYPE_CACHE.equals(zoneService.getRobotTypebyZone(zone.getName()))) {//有缓存位的机器人
             //执行到第几步
             dataMap.put(taskNode.getId().toString() + "count", count);
             dataMap.put(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG, "1");
@@ -557,23 +599,23 @@ public class TaskWorkNode {
                 //判断机器人是否为空
                 Map<String, List<ProductionresourcePosition>> jqrMap = robotList.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
 
-                robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[] {taskNode.getResourceId().toString()});
+                robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
 //                //目标地址和类型
 //                targetStorge = workpieceService.getWorkPieceTargetStock(taskNode.getId());
 
-                TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode,1);
-                Map returnMap  = getTargetStorge(nextTaskNode,taskNode.getFindAgvFlag(),zone);
+                TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
+                Map returnMap = getTargetStorge(nextTaskNode, taskNode.getFindAgvFlag(), zone);
 
-                targetStorge = returnMap.get("store")==null?null:(Storge)returnMap.get("store");
-                Storge agvEndStationStorge = returnMap.get("agvEndStationStorge")==null?null:(Storge)returnMap.get("agvEndStationStorge");
+                targetStorge = returnMap.get("store") == null ? null : (Storge) returnMap.get("store");
+                Storge agvEndStationStorge = returnMap.get("agvEndStationStorge") == null ? null : (Storge) returnMap.get("agvEndStationStorge");
 
 //                jqrStorge = storgeService.getById(robotList.get(0).getStorgeId());
 
                 Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
 
-                ProductionresourcePosition po = logical(robotList,targetStorge,zone);
+                ProductionresourcePosition po = logical(robotList, targetStorge, zone);
                 //机器人手抓没被锁定,并且有空闲未知
-                if (po!=null) {
+                if (po != null) {
                     jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
                     jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
                     storgeService.lockStorge(jqrStorge, taskNode.getId());
@@ -596,12 +638,12 @@ public class TaskWorkNode {
 
                     //满足条件--机器人空闲,设备或线边库有一个空闲
                     Map locationMap = new HashMap();
-                    locationMap.put("location",startStore);
+                    locationMap.put("location", startStore);
                     dataMap.put("Data", locationMap);
 
                     dataMap.put("method", "MoveRobotPosition");
                 }
-                dataMap.put("result", po!=null);
+                dataMap.put("result", po != null);
             } else if (count == 1) {
                 jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId());
                 dataMap.put("method", "GetFlexibleWire");
@@ -609,7 +651,7 @@ public class TaskWorkNode {
                 dataMap.put("fromStorge", currentStore);
 
                 Map locationMap = new HashMap();
-                locationMap.put("location",currentStore);
+                locationMap.put("location", currentStore);
                 dataMap.put("Data", locationMap);
                 //出入库类型
                 dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
@@ -626,61 +668,62 @@ public class TaskWorkNode {
                 Storge hcwStorge = (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + taskNode.getId());
 
                 Map locationMap = new HashMap();
-                locationMap.put("location",hcwStorge);
+                locationMap.put("location", hcwStorge);
                 dataMap.put("Data", locationMap);
 
                 dataMap.put("toStorge", hcwStorge);
                 dataMap.put("result", true);
-            }if(count==3) {
+            }
+            if (count == 3) {
                 Map locationMap = new HashMap();
-                locationMap.put("location",targetStorge);
+                locationMap.put("location", targetStorge);
                 dataMap.put("Data", locationMap);
 
                 dataMap.put("method", "MoveRobotPosition");
-            }else if(count == 4){//从缓存位拿出来
+            } else if (count == 4) {//从缓存位拿出来
                 dataMap.put("method", "GetFlexibleWire");
-                Storge hcwStorge = (Storge)msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + taskNode.getId());
+                Storge hcwStorge = (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + taskNode.getId());
 
                 Map locationMap = new HashMap();
-                locationMap.put("location",hcwStorge);
+                locationMap.put("location", hcwStorge);
                 dataMap.put("Data", locationMap);
 
                 dataMap.put("fromStorge", hcwStorge);
-                Storge handStorge = (Storge)msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId());
+                Storge handStorge = (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId());
                 dataMap.put("toStorge", handStorge);
                 //出入库类型
-                dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE,DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
-            }else if(count == 5){
+                dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
+            } else if (count == 5) {
                 dataMap.put("method", "SendFlexibleWire");
                 //出入库类型
-                dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE,DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
+                dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
 
                 Map locationMap = new HashMap();
-                locationMap.put("location",targetStorge);
+                locationMap.put("location", targetStorge);
                 dataMap.put("Data", locationMap);
 
                 dataMap.put("toStorge", targetStorge);
 
-                Storge handStorge = (Storge)msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId());
+                Storge handStorge = (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId());
                 dataMap.put("fromStorge", handStorge);
             }
-        }else {//没缓存位的机器人,伺服陀机
+        } else {//没缓存位的机器人,伺服陀机
 
             if (count == 0) {//第一步的时候锁定资源
                 //目标地址和类型
                 targetStorge = workpieceService.getWorkPieceTargetStock(taskNode.getId());
-                robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[] {taskNode.getResourceId().toString()});
+                robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
                 //目标地址和类型
                 jqrStorge = storgeService.getById(robotList.get(0).getStorgeId());
 
                 dataMap.put("method", "GetServoStacker");
-                if (logical(robotList,targetStorge,zone)!=null) {
+                if (logical(robotList, targetStorge, zone) != null) {
                     Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
 
                     dataMap.put("fromStorge", startStore);
 
                     Map locationMap = new HashMap();
-                    locationMap.put("location",startStore);
+                    locationMap.put("location", startStore);
                     dataMap.put("Data", locationMap);
                     //出入库类型
                     dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
@@ -699,13 +742,13 @@ public class TaskWorkNode {
                     //目标缓存
                     msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
                 }
-            }else if(count==1){
-                targetStorge = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId())==null?null:(Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId());
+            } else if (count == 1) {
+                targetStorge = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId()) == null ? null : (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId());
                 dataMap.put("method", "SendServoStacker");
                 dataMap.put("toStorge", targetStorge);
 
                 Map locationMap = new HashMap();
-                locationMap.put("location",targetStorge);
+                locationMap.put("location", targetStorge);
                 dataMap.put("Data", locationMap);
             }
             dataMap.put("result", true);
@@ -714,68 +757,68 @@ public class TaskWorkNode {
     }
 
 
-    public Map getTargetStorge(TaskNode taskNode,String findAgvFlag,ZZone zZone){
+    public Map getTargetStorge(TaskNode taskNode, String findAgvFlag, ZZone zZone) {
         Map returnMap = new HashMap();
         Storge targetStorge = null;
         Storge agvEndStationStorge = null;
         Long resourceId = taskNode.getTargetResourceId();
 
-        if("1".equals(findAgvFlag)){//需要提前锁定下个接驳位
+        if ("1".equals(findAgvFlag)) {//需要提前锁定下个接驳位
             //获取接驳位。
             Map map = storgeService.getPlateStorgeByNo(zZone);
-            targetStorge = map.get("storge") ==null?null:(Storge)map.get("storge");
-            String targetResourceId = map.get("resourceId") ==null?null:(String)map.get("resourceId");
+            targetStorge = map.get("storge") == null ? null : (Storge) map.get("storge");
+            String targetResourceId = map.get("resourceId") == null ? null : (String) map.get("resourceId");
             //对面产线接驳位不为空TODO
             String[] jbwArr = DictionaryKey.YJ_ZONE_JBW.get(zZone.getName()).split(",");
             List<ProductionresourcePosition> jbwBList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jbwArr);
 
-            if(targetStorge!=null&&CollectionUtil.isNotEmpty(jbwBList)){
+            if (targetStorge != null && CollectionUtil.isNotEmpty(jbwBList)) {
                 ProductionresourcePosition position = jbwBList.get(0);
-                agvEndStationStorge =storgeService.getById(position.getStorgeId());
+                agvEndStationStorge = storgeService.getById(position.getStorgeId());
 
-                returnMap.put("store",targetStorge);
+                returnMap.put("store", targetStorge);
 
                 //更新到targetresourceid
 //                TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode,1);
-                TaskNode lastOperationTaskNode = taskNodeService.getOne(Wraps.<TaskNode>lbQ().eq(TaskNode::getTaskId,taskNode.getTaskId()).orderByDesc(TaskNode::getCompleteBatchSort).last("limit 1"));
+                TaskNode lastOperationTaskNode = taskNodeService.getOne(Wraps.<TaskNode>lbQ().eq(TaskNode::getTaskId, taskNode.getTaskId()).orderByDesc(TaskNode::getCompleteBatchSort).last("limit 1"));
                 taskNode.setTargetResourceId(Long.parseLong(targetResourceId));
                 lastOperationTaskNode.setTargetResourceId(position.getResourceId());
                 lastOperationTaskNode.setResourceId(taskNode.getTargetResourceId());
                 taskNodeService.updateById(taskNode);
                 taskNodeService.updateById(lastOperationTaskNode);
             }
-        }else {
+        } else {
             //目标设备
-            if(resourceId!=null){
-                List<ProductionresourcePosition> targetList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[] {resourceId.toString()});
-                if(CollectionUtil.isNotEmpty(targetList)){
+            if (resourceId != null) {
+                List<ProductionresourcePosition> targetList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{resourceId.toString()});
+                if (CollectionUtil.isNotEmpty(targetList)) {
                     targetStorge = storgeService.getById(targetList.get(0).getStorgeId());
-                    returnMap.put("store",targetStorge);
+                    returnMap.put("store", targetStorge);
                 }
             }
         }
-        returnMap.put("agvEndStationStorge",agvEndStationStorge);
+        returnMap.put("agvEndStationStorge", agvEndStationStorge);
         return returnMap;
     }
 
     /**
-     *  设备动态逻辑判断处理
+     * 设备动态逻辑判断处理
      *
      * @param robotList
      * @return
      */
-    public ProductionresourcePosition logical(List<ProductionresourcePosition> robotList,Storge targetStorge,ZZone zone){
+    public ProductionresourcePosition logical(List<ProductionresourcePosition> robotList, Storge targetStorge, ZZone zone) {
         //设备不存在
-        if(checkRobot(robotList,zone.getName())){
+        if (checkRobot(robotList, zone.getName())) {
             return null;
         }
         //资源临界判断
         int current_running_num = storgeService.getstorgeByZone(zone.getId().toString());
-        if(current_running_num == DictionaryKey.RESOURCE_MAX_NUM){
+        if (current_running_num == DictionaryKey.RESOURCE_MAX_NUM) {
             return null;
         }
 
-        if(targetStorge==null){
+        if (targetStorge == null) {
             return null;
         }
 
@@ -784,14 +827,15 @@ public class TaskWorkNode {
 
     /**
      * 判断机器人是否可用
+     *
      * @return
      */
-    public boolean checkRobot(List<ProductionresourcePosition> robotList,String  zoneName){
-        if(BizConstant.ROBOT_TYPE_NOCACHE.equals(zoneService.getRobotTypebyZone(zoneName))){
+    public boolean checkRobot(List<ProductionresourcePosition> robotList, String zoneName) {
+        if (BizConstant.ROBOT_TYPE_NOCACHE.equals(zoneService.getRobotTypebyZone(zoneName))) {
             return CollectionUtil.isNotEmpty(robotList) && robotList.size() == 1;
-        }else if(BizConstant.ROBOT_TYPE_CACHE.equals(zoneService.getRobotTypebyZone(zoneName))){//手抓必须空闲。
+        } else if (BizConstant.ROBOT_TYPE_CACHE.equals(zoneService.getRobotTypebyZone(zoneName))) {//手抓必须空闲。
             Map<String, List<ProductionresourcePosition>> jqrMap = robotList.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
-            return CollectionUtil.isNotEmpty(robotList) && robotList.size() >1&&jqrMap.containsKey(DemoLineConstant.DEMOLINE_RJQR_ZS);
+            return CollectionUtil.isNotEmpty(robotList) && robotList.size() > 1 && jqrMap.containsKey(DemoLineConstant.DEMOLINE_RJQR_ZS);
         }
         return true;
     }

+ 24 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/TaskBizMapper.java

@@ -0,0 +1,24 @@
+package com.github.zuihou.business.operationManagementCenter.dao;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+/**
+ * <p>
+ * Mapper 接口
+ * 计划表
+ * </p>
+ *
+ * @author imcs
+ * @date 2020-12-29
+ */
+@Repository
+public interface TaskBizMapper extends SuperMapper<TTask> {
+    IPage<TTask> pageList(IPage page,   @Param(Constants.WRAPPER) LbqWrapper<TTask> wrapper);
+}

+ 31 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskBizService.java

@@ -0,0 +1,31 @@
+package com.github.zuihou.business.operationManagementCenter.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.R;
+import com.github.zuihou.base.service.SuperService;
+import com.github.zuihou.business.aps.instance.domain.basicdata.CandidateProcess;
+import com.github.zuihou.business.aps.instance.domain.basicdata.Machine;
+import com.github.zuihou.business.operationManagementCenter.entity.OrderProduct;
+import com.github.zuihou.business.operationManagementCenter.entity.PlanProduct;
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProductionresource;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * 业务接口
+ * 计划表
+ * </p>
+ *
+ * @author imcs
+ * @date 2020-12-29
+ */
+public interface TaskBizService extends SuperService<TTask> {
+
+    IPage<TTask> pageList(IPage<TTask> page, LbqWrapper<TTask> wrapper);
+}

+ 28 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskBizServiceImpl.java

@@ -0,0 +1,28 @@
+package com.github.zuihou.business.operationManagementCenter.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.service.SuperServiceImpl;
+import com.github.zuihou.business.operationManagementCenter.dao.*;
+import com.github.zuihou.business.operationManagementCenter.entity.*;
+import com.github.zuihou.business.operationManagementCenter.service.TaskBizService;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 业务实现类
+ * 订单生产单元
+ * </p>
+ *
+ * @author imcs
+ * @date 2020-12-29
+ */
+@Slf4j
+@Service
+public class TaskBizServiceImpl extends SuperServiceImpl<TaskBizMapper, TTask> implements TaskBizService {
+    @Override
+    public IPage<TTask> pageList(IPage<TTask> page, LbqWrapper<TTask> wrapper) {
+        return baseMapper.pageList(page, wrapper);
+    }
+}

+ 44 - 14
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/impl/BomProcedureVersionServiceImpl.java

@@ -10,7 +10,9 @@ import com.github.zuihou.business.basics.service.CustService;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 import com.github.zuihou.business.modelingCenter.dao.MModuleFieldMapper;
 import com.github.zuihou.business.modelingCenter.entity.MModuleField;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.productionReadyCenter.dao.AutoNodeMapper;
+import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureRobotArmMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureVersionMapper;
 import com.github.zuihou.business.productionReadyCenter.dto.BomProcedureVersionSaveDTO;
@@ -103,6 +105,8 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
 
     @Autowired
     private BBomService bomService;
+    @Autowired
+    private BomProcedureMapper bomProcedureMapper;
 
 
     @Override
@@ -197,6 +201,7 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
      * @param map
      * @return
      */
+    @Override
     public Map<String, Object> getList(Map<String, Object> map) {
         map.put("size","10000");
         return this.pageList(map);
@@ -513,8 +518,9 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
 //                }
                 int sort=1;
                 for(BomProcedureTray tray:procedureTrayList){
-                    if(StringUtils.isEmpty(tray.getNo()))
+                    if(StringUtils.isEmpty(tray.getNo())) {
                         continue;
+                    }
                     //添加组
                     BomProcedureTrayGroup groupBean = new BomProcedureTrayGroup();
                     groupBean.setGroupSort(sort);
@@ -586,6 +592,29 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
 //                    }
 //                }
             }
+        }else if("2".equals(bean.getTrayConf())){
+            // 来自上一工序
+            // 查找上一个工序的托盘夹具
+            BomProcedure currBomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getId,bean.getId()));
+            BomProcedure preBomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getBomId,bean.getBomId()).gt(BomProcedure::getSort,currBomProcedure.getSort()).orderByAsc(BomProcedure::getSort).last("limit 1"));
+
+            BomProcedureTrayGroup preBomProcedureTrayGroup = bomProcedureTrayGroupService.getOne(Wraps.<BomProcedureTrayGroup>lbQ().eq(BomProcedureTrayGroup::getProcedureId,preBomProcedure.getId()));
+            BomProcedureTrayGroup currGroupBean = new BomProcedureTrayGroup();
+            currGroupBean.setGroupSort(preBomProcedureTrayGroup.getGroupSort());
+            currGroupBean.setGroupPrority(preBomProcedureTrayGroup.getGroupPrority());
+            currGroupBean.setProcedureId(bean.getId());
+            bomProcedureTrayGroupService.save(currGroupBean);
+
+            List<BomProcedureTray> bomProcedureTrays = bomProcedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId,preBomProcedure.getId()));
+
+            // 插入当前工序的托盘夹具
+            for(BomProcedureTray tray:bomProcedureTrays){
+                //添加明细,添加选择的夹具
+                tray.setId(null);
+                tray.setProcedureId(currBomProcedure.getId());
+                tray.setGroupId(currGroupBean.getId());
+                bomProcedureTrayService.save(tray);
+            }
         }
 
         //查找目标工序
@@ -828,7 +857,7 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
 
     /**
      *
-     * @param bean
+     * @param map
      * @return
      */
     @Override
@@ -841,6 +870,7 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
         return getPreProcedureTray( bean);
     }
 
+    @Override
     public List<BomProcedureTray> getPreProcedureTray(BomProcedureVersion bean) {
         List<BomProcedureTray> procedureTrayList = new ArrayList<BomProcedureTray>();
 //        //看似冗余,不能删除,防止前端数据没传
@@ -856,8 +886,9 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
             List<BomProcedureVersion> list = baseMapper.selectList(Wraps.<BomProcedureVersion>lbQ().
                     eq(BomProcedureVersion::getVersionId,bean.getVersionId()).gt(BomProcedureVersion::getSort,bean.getSort()).orderByAsc(BomProcedureVersion::getSort));
 
-            if(list==null||list.size()==0)
+            if(list==null||list.size()==0) {
                 return procedureTrayList;
+            }
             //最终需要查询的工艺
             BomProcedureVersion targetBomProcedureVersion  = null;
             for(BomProcedureVersion bomProcedureVersion:list){
@@ -883,7 +914,7 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
 
     /**
      * 获取上一序
-     * @param bean
+     * @param map
      * @return
      */
     @Override
@@ -897,6 +928,7 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
         return list;
     }
 
+    @Override
     public List<BomProcedureMeterial> getPreMeterialList(BomProcedureVersion bean) {
         List<BomProcedureMeterial> bomProcedureMeterialList = new ArrayList<BomProcedureMeterial>();
 //        //看似冗余,不能删除,防止前端数据没传
@@ -909,13 +941,11 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
         }else if("2".equals(bean.getMeterialConf())) {//来自于上一序
             //取出当前工艺之后的工艺
 //            BomProcedureVersion srcBean = baseMapper.selectById(bean.getId());
-            List<BomProcedureVersion> list = baseMapper.selectList(Wraps.<BomProcedureVersion>lbQ().
-                    eq(BomProcedureVersion::getVersionId,bean.getVersionId()).gt(BomProcedureVersion::getSort,bean.getSort()).orderByAsc(BomProcedureVersion::getSort));
+            List<BomProcedureVersion> list = baseMapper.selectList(Wraps.<BomProcedureVersion>lbQ().eq(BomProcedureVersion::getVersionId,bean.getVersionId()).gt(BomProcedureVersion::getSort,bean.getSort()).orderByAsc(BomProcedureVersion::getSort));
 
-            if(list==null||list.size()==0)
+            if(list==null||list.size()==0){
                 return bomProcedureMeterialList;
-
-
+            }
             //最终需要查询的工艺
             BomProcedureVersion targetBomProcedureVersion  = null;
             for(BomProcedureVersion bomProcedureVersion:list){
@@ -945,7 +975,8 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
      * @param bean
      * @return
      */
-    public List<BomProcedureTray>getBomProcedureTrayList(BomProcedureVersion bean){
+    @Override
+    public List<BomProcedureTray> getBomProcedureTrayList(BomProcedureVersion bean){
         //托盘夹具
         List<BomProcedureTray> procedureTrayList = baseMapper.getProcedureTray(bean);
 //        //托盘对应位置数据
@@ -990,12 +1021,11 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
         //最终需要查询的工艺
         BomProcedureVersion targetBomProcedure = null;
 
-        List<BomProcedureVersion> list = baseMapper.selectList(Wraps.<BomProcedureVersion>lbQ().
-                eq(BomProcedureVersion::getVersionId,procedure.getVersionId()).gt(BomProcedureVersion::getSort,procedure.getSort()).orderByAsc(BomProcedureVersion::getSort));
+        List<BomProcedureVersion> list = baseMapper.selectList(Wraps.<BomProcedureVersion>lbQ().eq(BomProcedureVersion::getVersionId,procedure.getVersionId()).gt(BomProcedureVersion::getSort,procedure.getSort()).orderByAsc(BomProcedureVersion::getSort));
 
-        if(list==null||list.size()==0)
+        if(list==null||list.size()==0) {
             return targetBomProcedure;
-
+        }
         for(BomProcedureVersion bp:list){
             if(!"2".equals(bp.getTrayConf())){//非上一工序
                 targetBomProcedure = bp;

+ 3 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/impl/ProductLinePerformanceServiceImpl.java

@@ -14,6 +14,7 @@ import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.utils.BeanPlusUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -63,9 +64,9 @@ public class ProductLinePerformanceServiceImpl extends SuperCacheServiceImpl<Pro
             int monthHour = calCalendar.getActualMaximum(Calendar.DATE) * 24;
             params.setMonthHour(monthHour);
         }else{
-            Date searchDate = com.github.zuihou.common.util.DateUtil.stringToDate0(params.getStatisticalDate(),"yyyy-MM");
             Calendar calCalendar = Calendar.getInstance();
-            if(searchDate != null){
+            if(StringUtils.isNotEmpty(params.getStatisticalDate())){
+                Date searchDate = com.github.zuihou.common.util.DateUtil.stringToDate0(params.getStatisticalDate(),"yyyy-MM");
                 calCalendar.setTime(searchDate);
             }
             int monthHour = calCalendar.getActualMaximum(Calendar.DATE) * 24;

+ 2 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/DynamicRabbitMq.java

@@ -74,7 +74,8 @@ public class DynamicRabbitMq {
         container.setAcknowledgeMode(AcknowledgeMode.MANUAL);//消费者需手动确认
         container.setConsumersPerQueue(1);
         container.setMessageListener(consumerHandler);
-        //container.setAdviceChain(createRetry());
+        //配置重发机制
+        container.setAdviceChain(createRetry());
         container.setDefaultRequeueRejected(false);
         container.start();
     }

+ 59 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TaskBizMapper.xml

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.github.zuihou.business.operationManagementCenter.dao.TaskBizMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.github.zuihou.business.operationManagementCenter.entity.TTask">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
+        <result column="order_id" jdbcType="BIGINT" property="orderId"/>
+        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
+        <result column="plan_id" jdbcType="BIGINT" property="planId"/>
+        <result column="plan_no" jdbcType="VARCHAR" property="planNo"/>
+        <result column="resource_id" jdbcType="BIGINT" property="resourceId"/>
+        <result column="procedure_id" jdbcType="BIGINT" property="procedureId"/>
+        <result column="procedure_name" jdbcType="BIGINT" property="procedureName"/>
+        <result column="task_no" jdbcType="VARCHAR" property="taskNo"/>
+        <result column="status" jdbcType="VARCHAR" property="status"/>
+        <result column="expect_start_time" jdbcType="TIMESTAMP" property="expectStartTime"/>
+        <result column="expect_end_time" jdbcType="TIMESTAMP" property="expectEndTime"/>
+        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
+        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
+        <result column="create_user" jdbcType="VARCHAR" property="createUser"/>
+        <result column="prority" jdbcType="INTEGER" property="prority"/>
+        <result column="draft_flag" jdbcType="VARCHAR" property="draftFlag"/>
+        <result column="executor_id" jdbcType="BIGINT" property="executorId"/>
+        <result column="executor_type" jdbcType="VARCHAR" property="executorType"/>
+        <result column="executor_name" jdbcType="BIGINT" property="executorName"/>
+        <result column="procedure_meterial_id" jdbcType="BIGINT" property="procedureMeterialId"/>
+        <result column="procedure_tray_group_id" jdbcType="BIGINT" property="procedureTrayGroupId"/>
+        <result column="procedure_program_id" jdbcType="BIGINT" property="procedureProgramId"/>
+        <result column="task_batch_no" jdbcType="VARCHAR" property="taskBatchNo"/>
+        <result column="bom_batch_no" jdbcType="VARCHAR" property="bomBatchNo"/>
+        <result column="procedure_no" jdbcType="VARCHAR" property="procedureNo"/>
+        <result column="process" jdbcType="FLOAT" property="process"/>
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id,create_time,update_time,update_user,
+        order_id,order_no, plan_id,plan_no, resource_id, procedure_id,procedure_name, task_no, status, expect_start_time, expect_end_time, start_time, end_time,orderName,
+        prority, draft_flag, executor_id, executor_type, executor_name,procedure_meterial_id, procedure_tray_group_id, procedure_program_id, task_batch_no,process,bom_batch_no,
+        overtimeStatus,bomDesc,procedure_no,planTime,ratedWorkHours,actualTime,resourceDesc,content,prepareWorkHours,bomNo,procedureDesc,ip,port,resourceName
+    </sql>
+
+    <!-- 分页 -->
+    <select id="pageList" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from (
+            select a.*,(select itp.name as resourceName from imcs_tenant_productionresource itp where itp.id= a.resource_id )
+            from imcs_t_task a
+            where 1=1
+            and a.complete_batch_no = #{completeBatchNo}
+        )
+        s ${ew.customSqlSegment}
+    </select>
+</mapper>

+ 0 - 11
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/classSchedule/ScheduleFrequencyController.java

@@ -67,17 +67,6 @@ public class ScheduleFrequencyController extends SuperController<ScheduleFrequen
 
     @Override
     public void query(PageParams<ScheduleFrequencyPageDTO> params, IPage<ScheduleFrequency> page, Long defSize) {
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
-        String jsonParam = "";
-        Object obj = redisTemplate.opsForValue().get("testParam");
-        if(obj != null){
-            jsonParam = redisTemplate.opsForValue().get("testParam").toString();
-        }
-
-        HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam,headers);
-        //调用接口
-        String returnData = restTemplate.postForObject(url, formEntity, String.class);
 
         ScheduleFrequencyPageDTO data = params.getModel();
         QueryWrap<ScheduleFrequency> wrap = handlerWrapper(null, params);

+ 47 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/TaskBizController.java

@@ -0,0 +1,47 @@
+package com.github.zuihou.business.controller.operationManagementCenter;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.controller.SuperController;
+import com.github.zuihou.base.request.PageParams;
+import com.github.zuihou.business.operationManagementCenter.dto.TTaskPageDTO;
+import com.github.zuihou.business.operationManagementCenter.dto.TTaskSaveDTO;
+import com.github.zuihou.business.operationManagementCenter.dto.TTaskUpdateDTO;
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.service.TaskBizService;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
+import com.github.zuihou.log.annotation.SysLog;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * <p>
+ * 前端控制器
+ * 计划表
+ * </p>
+ *
+ * @author imcs
+ * @date 2020-12-29
+ */
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/taskTracedBack")
+@Api(value = "taskTracedBack", tags = "任务")
+@SysLog(enabled = true)
+public class TaskBizController extends SuperController<TaskBizService, Long, TTask, TTaskPageDTO, TTaskSaveDTO, TTaskUpdateDTO> {
+    @Override
+    public void query(PageParams<TTaskPageDTO> params, IPage<TTask> page, Long defSize) {
+        TTaskPageDTO data = params.getModel();
+        QueryWrap<TTask> wrap = handlerWrapper(null, params);
+        LbqWrapper<TTask> wrapper = wrap.lambda();
+        TTask task = BeanUtil.toBean(data, TTask.class);
+        wrapper.eq(TTask::getCompleteBatchNo,task.getCompleteBatchNo()).orderByDesc(TTask::getPrority);
+        baseService.pageList(page, wrapper);
+    }
+}

+ 3 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/TTask.java

@@ -575,6 +575,9 @@ public class TTask extends Entity<Long> implements Serializable {
     @TableField(exist = false)
     private String tmpId;
 
+    @TableField(exist = false)
+    private String resourceName;
+
     @Override
     public String toString() {
         return "TTask{" +