txf %!s(int64=3) %!d(string=hai) anos
pai
achega
5f6b0c6461

+ 7 - 7
src/main/java/com/steerinfo/dil/config/AsyncConfiguration.java

@@ -8,24 +8,24 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
 import java.util.concurrent.Executor;
 
-//@Configuration
-//@EnableAsync  // 启用异步任务
+@Configuration
+@EnableAsync  // 启用异步任务
 public class AsyncConfiguration {
 
     // 声明一个线程池(并指定线程池的名字)
-//    @Bean("taskExecutor")
+    @Bean("taskExecutor")
     public Executor asyncExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         //核心线程数5:线程池创建时候初始化的线程数
-        executor.setCorePoolSize(5);
+        executor.setCorePoolSize(4);
         //最大线程数5:线程池最大的线程数,只有在缓冲队列满了之后才会申请超过核心线程数的线程
-        executor.setMaxPoolSize(5);
+        executor.setMaxPoolSize(4);
         //缓冲队列500:用来缓冲执行任务的队列
-        executor.setQueueCapacity(500);
+        executor.setQueueCapacity(10);
         //允许线程的空闲时间60秒:当超过了核心线程出之外的线程在空闲时间到达之后会被销毁
         executor.setKeepAliveSeconds(60);
         //线程池名的前缀:设置好了之后可以方便我们定位处理任务所在的线程池
-        executor.setThreadNamePrefix("DailyAsync-");
+        executor.setThreadNamePrefix("queue-");
         executor.initialize();
         return executor;
     }

+ 7 - 1
src/main/java/com/steerinfo/dil/controller/QmsQueueListController.java

@@ -127,7 +127,13 @@ public class QmsQueueListController extends BaseRESTfulController {
     })
     @PostMapping("/allowEnFactory")
     public RESTfulResult allowEnFactory(@RequestBody(required=false) Map<String, Object> mapValue){
-        return success(qmsQueueListService.allowEnFactory(mapValue));
+        int i = qmsQueueListService.allowEnFactory(mapValue);
+        if(i == -1){
+            return failed("请按顺序进行勾选进厂");
+        }else if (i == -2){
+            return failed("未勾选进厂车辆");
+        }
+        return success();
     }
 
     @ApiOperation(value="测试门岗计算接口")

+ 44 - 0
src/main/java/com/steerinfo/dil/service/impl/QmsQueueListServiceImpl.java

@@ -306,6 +306,17 @@ public class QmsQueueListServiceImpl implements IQmsQueueListService {
      */
     public int allowEnFactory(Map<String, Object> map){
         List<Map<String, Object>> mapList = (List<Map<String, Object>>) map.get("mapList"); //获取勾选列表
+        if( ! (mapList == null || mapList.size() == 0)){
+            if(mapList.get(0).get("listId") != null){ //如果是单拼 需要判断有没有跳行打钩
+                boolean judgeRowIdOrder = judgeRowIdOrder(mapList);
+                if( ! judgeRowIdOrder){
+                    return -1;
+                }
+            }
+        }else {
+            return -2;
+        }
+        judgeRowIdOrder(mapList);
         String ssoId = String.valueOf(map.get("ssoId"));
         String jobName = null;
         if(!"null".equals(ssoId)){
@@ -344,6 +355,39 @@ public class QmsQueueListServiceImpl implements IQmsQueueListService {
         return count;
     }
 
+    /**
+     * 判断是否隔行打钩
+     * @param mapList
+     * @return
+     */
+    public boolean judgeRowIdOrder(List<Map<String, Object>> mapList){
+        Integer firstRowId = (Integer) mapList.get(0).get("ROW_ID");
+        if(mapList.size() == 1){
+            return firstRowId == 1; //行ID必须等于1才可以 避免跳选后取消勾选
+        }else {
+            if(firstRowId != 1){
+                return false;
+            }
+        }
+        ArrayList<Integer> list = new ArrayList<>();
+        for (Map<String, Object> map : mapList) {
+            list.add((Integer) map.get("ROW_ID"));
+        }
+        //从小到大排序
+        list.sort(new Comparator<Integer>() {
+            @Override
+            public int compare(Integer o1, Integer o2) {
+                return Integer.compare(o1, o2);
+            }
+        });
+        for (int i = 1; i < list.size(); i++){
+            if((list.get(i) - list.get(i - 1) != 1)){
+                return false;
+            }
+        }
+        return true;
+    }
+
 
     /**
      * 链表监控

+ 114 - 0
src/main/java/com/steerinfo/dil/service/impl/QueueDealWithAsync.java

@@ -0,0 +1,114 @@
+package com.steerinfo.dil.service.impl;
+
+import com.steerinfo.dil.mapper.QmsQueueListMapper;
+import com.steerinfo.dil.mapper.QmsQueueSpellingListMapper;
+import com.steerinfo.dil.mapper.QueuingRulesMapper;
+import com.steerinfo.dil.util.DataChange;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class QueueDealWithAsync {
+
+    @Resource
+    private QueuingRulesMapper queuingRulesMapper;
+
+    @Autowired
+    private QmsQueueListMapper qmsQueueListMapper;
+
+    @Autowired
+    private QmsQueueSpellingListMapper qmsQueueSpellingListMapper;
+
+    /**
+     * 单拼
+     * @param nowTime
+     */
+    @Async("taskExecutor")
+    public void dealWithOne(long nowTime){
+        //查询所有单拼排队网格已经确认进厂的记录
+        List<Map<String, Object>> listListMap = queuingRulesMapper.getAllSureTimeList();
+        for (Map<String, Object> map : listListMap) {
+            if((nowTime - ((Date) map.get("entrySureTime")).getTime()) > 1800000){
+                //如果超过勾选时间30分钟 自动回滚到队列最后
+                BigDecimal listId = DataChange.dataToBigDecimal(map.get("listId"));
+                Integer maxListNodeOrder = qmsQueueListMapper.getMaxListNodeOrder(map);
+                queuingRulesMapper.updateListToLast(listId, maxListNodeOrder + 1);
+                //移除可进厂资格
+                queuingRulesMapper.updateEnFactory(DataChange.dataToBigDecimal(map.get("resultTotalId")));
+                if((nowTime - ((Date) map.get("insertTime")).getTime()) > 86400000){
+                    //如果大于一天则直接删除队列信息
+                    qmsQueueListMapper.deleteByPrimaryKey(listId);
+                    queuingRulesMapper.updateQQRRemoveList(DataChange.dataToBigDecimal(map.get("resultId")));
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 多拼
+     * @param nowTime
+     */
+    @Async("taskExecutor")
+    public void dealWithTwo(long nowTime){
+        //查询所有多拼排队网格已经确认进厂的记录
+        List<Map<String, Object>> allSureTimeSpellingList = queuingRulesMapper.getAllSureTimeSpellingList();
+        for (Map<String, Object> map : allSureTimeSpellingList) {
+            if ((nowTime - ((Date) map.get("entrySureTime")).getTime()) > 1800000) {
+                BigDecimal spellingResultId = DataChange.dataToBigDecimal(map.get("spellingResultId"));
+                //如果超过勾选时间30分钟 自动回滚到队列最后
+                queuingRulesMapper.updateSpellingListToLast(spellingResultId);
+                //移除可进厂资格
+                queuingRulesMapper.updateEnFactory(DataChange.dataToBigDecimal(map.get("resultTotalId")));
+                if((nowTime - ((Date) map.get("spellingSureTime")).getTime()) > 86400000){
+                    //如果大于一天则直接删除队列信息
+                    qmsQueueSpellingListMapper.deleteByPrimaryKey(spellingResultId);
+                    queuingRulesMapper.updateQQRRemoveList(DataChange.dataToBigDecimal(map.get("resultId")));
+                }
+            }
+        }
+    }
+
+    /**
+     * 多拼
+     * @param nowTime
+     */
+    @Async("taskExecutor")
+    public void dealWithThree(long nowTime){
+
+        List<Map<String, Object>> listMap = queuingRulesMapper.getAllNotSureEnFactoryList();
+        for (Map<String, Object> map : listMap) {
+            if((nowTime - ((Date) map.get("insertTime")).getTime()) > 86400000){
+                //踢出队列
+                qmsQueueListMapper.deleteByPrimaryKey(DataChange.dataToBigDecimal(map.get("listId")));
+                //修改信息
+                queuingRulesMapper.updateQQRRemoveList(DataChange.dataToBigDecimal(map.get("resultId")));
+            }
+        }
+    }
+
+
+    /**
+     * 多拼
+     * @param nowTime
+     */
+    @Async("taskExecutor")
+    public void dealWithFour(long nowTime){
+        List<Map<String, Object>> spellingListMap = queuingRulesMapper.getAllNotSureEnFactorySpellingList();
+        for (Map<String, Object> map : spellingListMap) {
+            if((nowTime - ((Date) map.get("spellingSureTime")).getTime()) > 86400000){
+                //如果大于一天则直接删除队列信息
+                qmsQueueSpellingListMapper.deleteByPrimaryKey(DataChange.dataToBigDecimal(map.get("spellingResultId")));
+                queuingRulesMapper.updateQQRRemoveList(DataChange.dataToBigDecimal(map.get("resultId")));
+            }
+        }
+    }
+
+}

+ 7 - 65
src/main/java/com/steerinfo/dil/service/impl/QueuingRulesServiceImpl.java

@@ -2,20 +2,16 @@ package com.steerinfo.dil.service.impl;
 
 import com.steerinfo.dil.feign.IMFeign;
 import com.steerinfo.dil.mapper.QmsQueueListMapper;
-import com.steerinfo.dil.mapper.QmsQueueResultMapper;
 import com.steerinfo.dil.mapper.QmsQueueSpellingListMapper;
 import com.steerinfo.dil.mapper.QueuingRulesMapper;
-import com.steerinfo.dil.model.QmsQueueList;
-import com.steerinfo.dil.model.QmsQueueSpellingList;
 import com.steerinfo.dil.service.IQueuingRulesService;
 import com.steerinfo.dil.util.DataChange;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -27,18 +23,11 @@ import java.util.*;
 @Service
 public class QueuingRulesServiceImpl implements IQueuingRulesService {
 
-    @Resource
-    private QueuingRulesMapper queuingRulesMapper;
-
-    @Autowired
-    private QmsQueueListMapper qmsQueueListMapper;
-
-    @Autowired
-    private QmsQueueSpellingListMapper qmsQueueSpellingListMapper;
-
     @Autowired
     private IMFeign imFeign;
 
+    @Autowired
+    private QueueDealWithAsync queueDealWithAsync;
 
     /**
      * 定时检查  钢材科已确认进厂之后  30分钟没有结束 自动回滚到队列末尾,移除可进厂时间
@@ -46,39 +35,8 @@ public class QueuingRulesServiceImpl implements IQueuingRulesService {
     @Scheduled(fixedRate = 1000 * 60)
     public void checkoutQueueList(){
         long nowTime = System.currentTimeMillis();
-        //查询所有单拼排队网格已经确认进厂的记录
-        List<Map<String, Object>> listListMap = queuingRulesMapper.getAllSureTimeList();
-        for (Map<String, Object> map : listListMap) {
-            if((nowTime - ((Date) map.get("entrySureTime")).getTime()) > 1800000){
-                //如果超过勾选时间30分钟 自动回滚到队列最后
-                BigDecimal listId = DataChange.dataToBigDecimal(map.get("listId"));
-                Integer maxListNodeOrder = qmsQueueListMapper.getMaxListNodeOrder(map);
-                queuingRulesMapper.updateListToLast(listId, maxListNodeOrder + 1);
-                //移除可进厂资格
-                queuingRulesMapper.updateEnFactory(DataChange.dataToBigDecimal(map.get("resultTotalId")));
-                if((nowTime - ((Date) map.get("insertTime")).getTime()) > 86400000){
-                    //如果大于一天则直接删除队列信息
-                    qmsQueueListMapper.deleteByPrimaryKey(listId);
-                    queuingRulesMapper.updateQQRRemoveList(DataChange.dataToBigDecimal(map.get("resultId")));
-                }
-            }
-        }
-        //查询所有多拼排队网格已经确认进厂的记录
-        List<Map<String, Object>> allSureTimeSpellingList = queuingRulesMapper.getAllSureTimeSpellingList();
-        for (Map<String, Object> map : allSureTimeSpellingList) {
-            if ((nowTime - ((Date) map.get("entrySureTime")).getTime()) > 1800000) {
-                BigDecimal spellingResultId = DataChange.dataToBigDecimal(map.get("spellingResultId"));
-                //如果超过勾选时间30分钟 自动回滚到队列最后
-                queuingRulesMapper.updateSpellingListToLast(spellingResultId);
-                //移除可进厂资格
-                queuingRulesMapper.updateEnFactory(DataChange.dataToBigDecimal(map.get("resultTotalId")));
-                if((nowTime - ((Date) map.get("spellingSureTime")).getTime()) > 86400000){
-                    //如果大于一天则直接删除队列信息
-                    qmsQueueSpellingListMapper.deleteByPrimaryKey(spellingResultId);
-                    queuingRulesMapper.updateQQRRemoveList(DataChange.dataToBigDecimal(map.get("resultId")));
-                }
-            }
-        }
+        queueDealWithAsync.dealWithOne(nowTime);
+        queueDealWithAsync.dealWithTwo(nowTime);
     }
 
     /**
@@ -87,26 +45,10 @@ public class QueuingRulesServiceImpl implements IQueuingRulesService {
     @Scheduled(fixedRate = 1000 * 60 * 30)
     public void checkoutQueue(){
         long nowTime = System.currentTimeMillis();
-        List<Map<String, Object>> listMap = queuingRulesMapper.getAllNotSureEnFactoryList();
-        for (Map<String, Object> map : listMap) {
-            if((nowTime - ((Date) map.get("insertTime")).getTime()) > 86400000){
-                //踢出队列
-                qmsQueueListMapper.deleteByPrimaryKey(DataChange.dataToBigDecimal(map.get("listId")));
-                //修改信息
-                queuingRulesMapper.updateQQRRemoveList(DataChange.dataToBigDecimal(map.get("resultId")));
-            }
-        }
-        List<Map<String, Object>> spellingListMap = queuingRulesMapper.getAllNotSureEnFactorySpellingList();
-        for (Map<String, Object> map : spellingListMap) {
-            if((nowTime - ((Date) map.get("spellingSureTime")).getTime()) > 86400000){
-                //如果大于一天则直接删除队列信息
-                qmsQueueSpellingListMapper.deleteByPrimaryKey(DataChange.dataToBigDecimal(map.get("spellingResultId")));
-                queuingRulesMapper.updateQQRRemoveList(DataChange.dataToBigDecimal(map.get("resultId")));
-            }
-        }
+        queueDealWithAsync.dealWithThree(nowTime);
+        queueDealWithAsync.dealWithFour(nowTime);
     }
 
-
     /**
      * 推送消息给websocket
      */

+ 7 - 7
src/main/resources/com/steerinfo/dil/mapper/QmsQueueResultMapper.xml

@@ -856,7 +856,7 @@
                RM.MATERIAL_SPECIFICATION    "materialSpecification",
                RM.MATERIAL_MODEL        "materialModel",
                QQL.LIST_ID              "listId",
-               RC.CAPACITY_NUMBER       "capacityNumber",
+               RC.CAPACITY_NUMBER  "capacityNumber",
                RC.CAPACITY_ID           "capacityId",
                QQL.ENTRY_SURE_TIME          "sureTime",
                OOM.ORDER_MATERIAL_NUMBER    "materialNumber",
@@ -868,8 +868,8 @@
                    select COUNT(QQL2.LIST_ID)
                    from QMS_QUEUE_LIST QQL2
                    where QQL2.GRID_ID = QQL.GRID_ID
-                         and QQL2.LIST_NODE_ORDER >= QQL.LIST_NODE_ORDER
-               )    "listNodeOrder"
+                         and QQL2.LIST_NODE_ORDER &lt;= QQL.LIST_NODE_ORDER
+               )  || (case when QQL.IS_VIP is not null then ' 优先进厂' else '' end ) "listNodeOrder"
         FROM QMS_QUEUE_LIST QQL
             LEFT JOIN QMS_QUEUE_RESULT QQR ON QQL.QUEUE_RESULT_ID = QQR.RESULT_ID
             LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR ON QQR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
@@ -890,11 +890,11 @@
             </if>
             <if test="locationId != null">
                 and QQL.GRID_ID = #{locationId}
-                ORDER BY QQL.IS_VIP, QQL.ENTRY_SURE_TIME DESC, "listNodeOrder"
+                ORDER BY QQL.ENTRY_SURE_TIME DESC, QQL.IS_VIP, "listNodeOrder"
             </if>
         </where>
         <if test="locationId == null">
-            ORDER BY QQL.IS_VIP, QQL.ENTRY_SURE_TIME DESC, "materialName" DESC, "listNodeOrder"
+            ORDER BY  QQL.ENTRY_SURE_TIME DESC,  QQL.IS_VIP, "materialName" DESC, "listNodeOrder"
         </if>
     </select>
 
@@ -957,11 +957,11 @@
             </if>
             <if test="locationId != null">
                 and QQSL.SPELILING_NUM  = #{locationId}
-                ORDER BY QQSL.IS_VIP, QQSL.ENTRY_SURE_TIME DESC,  "listNodeOrder"
+                ORDER BY  QQSL.ENTRY_SURE_TIME DESC, QQSL.IS_VIP,  "listNodeOrder"
             </if>
         </where>
         <if test="locationId == null">
-            order by QQSL.IS_VIP, QQSL.ENTRY_SURE_TIME DESC, QQSL.SPELILING_NUM DESC, "listNodeOrder"
+            order by  QQSL.ENTRY_SURE_TIME DESC, QQSL.IS_VIP, QQSL.SPELILING_NUM DESC, "listNodeOrder"
         </if>
     </select>