Parcourir la source

LY 启动项目速度

ly il y a 2 ans
Parent
commit
e97a827232

+ 27 - 6
master/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobServiceImpl.java

@@ -1,7 +1,13 @@
 package com.ruoyi.project.monitor.service.impl;
 
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import javax.annotation.PostConstruct;
+
+import com.ruoyi.common.utils.DictUtils;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.project.system.domain.SysDictType;
 import org.quartz.JobDataMap;
 import org.quartz.JobKey;
 import org.quartz.Scheduler;
@@ -37,12 +43,27 @@ public class SysJobServiceImpl implements ISysJobService
     @PostConstruct
     public void init() throws SchedulerException, TaskException
     {
-        scheduler.clear();
-        List<SysJob> jobList = jobMapper.selectJobAll();
-        for (SysJob job : jobList)
-        {
-            ScheduleUtils.createScheduleJob(scheduler, job);
-        }
+        ExecutorService executorService = Executors.newFixedThreadPool(2);
+        executorService.execute(() -> {
+            try {
+                scheduler.clear();
+            } catch (SchedulerException e) {
+                e.printStackTrace();
+            }
+            List<SysJob> jobList = jobMapper.selectJobAll();
+            for (SysJob job : jobList)
+            {
+                try {
+                    ScheduleUtils.createScheduleJob(scheduler, job);
+                } catch (SchedulerException e) {
+                    e.printStackTrace();
+                } catch (TaskException e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        executorService.shutdown();
+
     }
 
     /**

+ 15 - 5
master/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java

@@ -2,7 +2,13 @@ package com.ruoyi.project.system.service.impl;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import javax.annotation.PostConstruct;
+
+import com.ruoyi.common.utils.DictUtils;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.project.system.domain.SysDictType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.common.constant.Constants;
@@ -35,11 +41,15 @@ public class SysConfigServiceImpl implements ISysConfigService
     @PostConstruct
     public void init()
     {
-        List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
-        for (SysConfig config : configsList)
-        {
-            redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
-        }
+        ExecutorService executorService = Executors.newFixedThreadPool(2);
+        executorService.execute(() -> {
+            List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
+            for (SysConfig config : configsList)
+            {
+                redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
+            }
+        });
+        executorService.shutdown();
     }
 
     /**

+ 16 - 7
master/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java

@@ -1,7 +1,12 @@
 package com.ruoyi.project.system.service.impl;
 
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
+import com.ruoyi.project.ehs.domain.TJobticket;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -26,7 +31,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
     @Autowired
     private SysDictTypeMapper dictTypeMapper;
 
-    @Autowired
+    @Resource
     private SysDictDataMapper dictDataMapper;
 
     /**
@@ -35,12 +40,16 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
     @PostConstruct
     public void init()
     {
-        List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
-        for (SysDictType dictType : dictTypeList)
-        {
-            List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
-            DictUtils.setDictCache(dictType.getDictType(), dictDatas);
-        }
+        ExecutorService executorService = Executors.newFixedThreadPool(2);
+        executorService.execute(() -> {
+            List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
+            for (SysDictType dictType : dictTypeList)
+            {
+                List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
+                DictUtils.setDictCache(dictType.getDictType(), dictDatas);
+            }
+        });
+        executorService.shutdown();
     }
 
     /**

+ 1 - 0
ui/src/views/invoice/unit/index.vue

@@ -334,6 +334,7 @@ export default {
     handleAdd() {
       this.reset();
       this.open = true;
+      this.form.deptId = this.$store.state.user.deptId
       this.title = "添加用户单位管理";
     },
     /** 修改按钮操作 */