浏览代码

Merge branch 'master' of https://git.steerinfo.com/luobang/DIL-DAZHOU-WMS2

胡半仙 3 年之前
父节点
当前提交
42367f36b4

+ 2 - 0
src/main/java/com/steerinfo/DilApplicationMain.java

@@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.servlet.ServletComponentScan;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 /**
@@ -19,6 +20,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @MapperScan({"com.steerinfo.dil.mapper"})
 @EnableFeignClients(basePackages = "com.steerinfo.dil.feign")
 @EnableDiscoveryClient
+@EnableAsync(proxyTargetClass=true)
 public class DilApplicationMain {
     public static void main(String[] args) {
         SpringApplication.run(DilApplicationMain.class,args);

+ 36 - 0
src/main/java/com/steerinfo/dil/config/TaskScheduleConfig.java

@@ -0,0 +1,36 @@
+package com.steerinfo.dil.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+@Configuration
+@EnableAsync
+public class TaskScheduleConfig {
+    private static final int corePoolSize = 10;            // 默认线程数
+    private static final int maxPoolSize = 100;                // 最大线程数
+    private static final int keepAliveTime = 10;            // 允许线程空闲时间(单位:默认为秒),十秒后就把线程关闭
+    private static final int queueCapacity = 200;            // 缓冲队列数
+    private static final String threadNamePrefix = "it-is-threaddemo-"; // 线程池名前缀
+
+    @Bean("threadPoolTaskExecutor") // bean的名称,默认为首字母小写的方法名
+    public ThreadPoolTaskExecutor getDemoThread() {
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        executor.setCorePoolSize(corePoolSize);
+        executor.setMaxPoolSize(maxPoolSize);
+        executor.setQueueCapacity(keepAliveTime);
+        executor.setKeepAliveSeconds(queueCapacity);
+        executor.setThreadNamePrefix(threadNamePrefix);
+
+        //线程池拒绝任务的处理策略
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        //初始化
+        executor.initialize();
+
+        return executor;
+
+    }
+}

+ 6 - 4
src/main/java/com/steerinfo/dil/service/impl/WmspInventoryCloseServiceImpl.java

@@ -6,6 +6,7 @@ import com.steerinfo.dil.model.WmspInventoryClose;
 import com.steerinfo.dil.service.IWmspInventoryCloseService;
 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;
 
@@ -34,11 +35,12 @@ public class WmspInventoryCloseServiceImpl implements IWmspInventoryCloseService
     }
 
     @Override
-    @Scheduled(cron =  "3 45 23 25 * ? ")
+    @Scheduled(cron =  "5 45 23 25 * ? ")
+    @Async("threadPoolTaskExecutor")
     public int addInventoryClose() {
         int i = 0;
-        int count = wmspInventoryCloseMapper.getClose();
-        if(count == 0){
+       // int count = wmspInventoryCloseMapper.getClose();
+        // if(count == 0){
             //高线库,一棒库,二棒库,配送库
             List<Map<String, Object>> mapList = rmsWarehouseMapper.getWarehouseName();
             //遍历四个仓库
@@ -93,7 +95,7 @@ public class WmspInventoryCloseServiceImpl implements IWmspInventoryCloseService
                 }
 
             }
-        }
+        //}
 
         return i;
     }

+ 6 - 4
src/main/java/com/steerinfo/dil/service/impl/WmspSendReceiveServiceImpl.java

@@ -8,6 +8,7 @@ import com.steerinfo.dil.model.WmspSendReceive;
 import com.steerinfo.dil.service.IWmspSendReceiveService;
 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;
 
@@ -163,10 +164,11 @@ public class WmspSendReceiveServiceImpl implements IWmspSendReceiveService {
     //零点生成前一天的入库、出库、库存
     @Override
     @Scheduled(cron =  "1 45 23 * * ? ")
+    @Async("threadPoolTaskExecutor")
     public int addSendReceive(){
         int i = 0;
-        int count = wmspSendReceiveMapper.getTodaySendReceiveCount();
-        if(count == 0){
+      //  int count = wmspSendReceiveMapper.getTodaySendReceiveCount();
+      // if(count == 0){
             //高线库,一棒库,二棒库,配送库
             List<Map<String, Object>> mapList = rmsWarehouseMapper.getWarehouseName();
             //遍历四个仓库
@@ -228,9 +230,9 @@ public class WmspSendReceiveServiceImpl implements IWmspSendReceiveService {
                     i+=wmspSendReceiveMapper.insertSelective(wmspSendReceive);
                 }
             }
-        }
+      //  }
 
-        return i;
+       return i;
     }
 
 }

+ 4 - 4
src/main/resources/com/steerinfo/dil/mapper/WmspOutboundResultMapper.xml

@@ -645,13 +645,13 @@
     LEFT JOIN RMS_UNIT_OF_MEASURE jldw
     ON wz.UNIT_OF_MEASURE_ID = jldw.UNIT_OF_MEASURE_ID
     WHERE wg.WAREHOUSE_ID = #{warehouseId}
-    <if test="startTime != null and endTime !=null">
-      and ckd.insert_time between to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') and to_date(#{endDate},
-      'yyyy-mm-dd hh24:mi:ss')
-    </if>
     <if test="oneDate != null">
       and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ckd.insert_time
     </if>
+    <if test="startDate != null">
+      and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ckd.insert_time
+      and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ckd.insert_time
+    </if>
     order by ckd.INSERT_TIME desc
     )
     <where>