Browse Source

:white_check_mark: 优化出库操作批量插入速度、配置文件更改、延长请求超时时间

Twelve615 1 year ago
parent
commit
da5c410e43

+ 1 - 1
suyuan-vue/src/utils/request.js

@@ -18,7 +18,7 @@ const service = axios.create({
   //baseURL: '/jeecg-boot',
   baseURL: apiBaseUrl, // api base_url
   // timeout: 9000 // 请求超时时间
-  timeout: 20000 // 请求超时时间
+  timeout: 60000 // 请求超时时间
 })
 
 const err = (error) => {

+ 2 - 2
suyuan/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/RestTemplateConfig.java

@@ -21,8 +21,8 @@ public class RestTemplateConfig {
     @Bean
     public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
         SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
-        factory.setReadTimeout(5000);//ms
-        factory.setConnectTimeout(15000);//ms
+        factory.setReadTimeout(50000);//ms
+        factory.setConnectTimeout(50000);//ms
         return factory;
     }
 }

+ 5 - 1
suyuan/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/admincasehistory/controller/AdminGodownEntryController.java

@@ -389,7 +389,7 @@ public class AdminGodownEntryController {
                 // excel表格中的数据
                 List<SYMCode> excelDatalist = ExcelImportUtil.importExcel( file.getInputStream(), SYMCode.class, params );
                 // 过滤后excel表格中的数据
-                List<SYMCode> list = new ArrayList<>();
+                List<SYMCode> list = null;
                 List<SYMCode> list3 = new ArrayList<>(  );
                 if (excelDatalist.size() == 0) {
                     return Result.error( "文件导入失败:查不到了文件数据,或者文件数据格式错误!" );
@@ -400,6 +400,10 @@ public class AdminGodownEntryController {
 //                        boolean b = list.stream().allMatch( list2 -> list2.getRetrospectiveSourceCode().equals( list.get( finalIa ).getRetrospectiveSourceCode() ) );
                     // 去除空的对象
                     list = excelDatalist.stream().filter(item -> item != null && !Strings.isNullOrEmpty(item.getRetrospectiveSourceCode()) && !Strings.isNullOrEmpty(item.getName())).collect(Collectors.toList());
+                    // 为空直接返回
+                    if(list.size() == 0){
+                        return Result.error( "文件导入失败:查不到了文件数据,或者文件数据格式错误!" );
+                    }
                     // 根据指定属性分组,并统计数量(key:指定属性,value:数量)
                             Map<String, Long> mapGroup =
                                     list.stream().collect(Collectors.groupingBy(lists -> lists.getRetrospectiveSourceCode(),

+ 9 - 5
suyuan/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/adminpurchasenote/service/impl/AdminPurchaseNoteServiceImpl.java

@@ -5,6 +5,7 @@ import org.jeecg.modules.aa.adminpurchasenote.entity.AdminRscode2;
 import org.jeecg.modules.aa.adminpurchasenote.mapper.AdminRscode2Mapper;
 import org.jeecg.modules.aa.adminpurchasenote.mapper.AdminPurchaseNoteMapper;
 import org.jeecg.modules.aa.adminpurchasenote.service.IAdminPurchaseNoteService;
+import org.jeecg.modules.aa.adminpurchasenote.service.IAdminRscode2Service;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,7 +27,10 @@ public class AdminPurchaseNoteServiceImpl extends ServiceImpl<AdminPurchaseNoteM
 	private AdminPurchaseNoteMapper adminPurchaseNoteMapper;
 	@Autowired
 	private AdminRscode2Mapper adminRscode2Mapper;
-	
+
+	@Autowired
+	private IAdminRscode2Service adminRscode2Service;
+
 	@Override
 	@Transactional
 	public void saveMain(AdminPurchaseNote adminPurchaseNote, List<AdminRscode2> adminRscode2List) {
@@ -44,17 +48,17 @@ public class AdminPurchaseNoteServiceImpl extends ServiceImpl<AdminPurchaseNoteM
 	@Transactional
 	public void updateMain(AdminPurchaseNote adminPurchaseNote,List<AdminRscode2> adminRscode2List) {
 		adminPurchaseNoteMapper.updateById(adminPurchaseNote);
-		
+
 		//1.先删除子表数据
 		adminRscode2Mapper.deleteByMainId(adminPurchaseNote.getId());
-		
+
 		//2.子表数据重新插入
 		if(adminRscode2List!=null && adminRscode2List.size()>0) {
 			for(AdminRscode2 entity:adminRscode2List) {
 				//外键设置
 				entity.setSalesTicketId(adminPurchaseNote.getId());
-				adminRscode2Mapper.insert(entity);
 			}
+			adminRscode2Service.saveBatch(adminRscode2List,1000);
 		}
 	}
 
@@ -73,5 +77,5 @@ public class AdminPurchaseNoteServiceImpl extends ServiceImpl<AdminPurchaseNoteM
 			adminPurchaseNoteMapper.deleteById(id);
 		}
 	}
-	
+
 }

+ 8 - 8
suyuan/jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -135,9 +135,9 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://101.200.162.45:3306/suyuan?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-          username: suyuan
-          password: epi8KhZxY66BwKDB
+          url: jdbc:mysql://120.79.86.50:3306/suyuan_java?rewriteBatchedStatements=true&characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          username: suyuan_java
+          password: 44114e80aa
           driver-class-name: com.mysql.cj.jdbc.Driver
           # 多数据源配置
   #        multi-datasource1:
@@ -148,7 +148,7 @@ spring:
   #redis 配置
   redis:
     database: 0
-    host: 101.200.162.45
+    host: 120.79.86.50
     lettuce:
       pool:
         max-active: 8   #最大连接数据库连接数,设 -1 为没有限制
@@ -156,7 +156,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: 'suyuan123'
+    password: 'hdl2022'
     port: 6379
 #  redis:
 #    database: 0
@@ -202,11 +202,11 @@ jeecg :
     #文件上传根目录 设置
 #    upload: /usr/java/AJeecgBootFiles
 #    upload: D:\\AJeecgBootFiles
-    upload: C:\\AJeecgBootFiles
+    upload: E:\tempFile\suyuanFile
     #webapp文件路径
 #    webapp: /usr/java/AJeecgBootFiles
 #    webapp: D:\\AJeecgBootFiles
-    webapp: C:\\AJeecgBootFiles
+    webapp: E:\tempFile\suyuanFile
   shiro:
     excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
   #阿里云oss存储和大鱼短信秘钥配置
@@ -338,4 +338,4 @@ third-app:
       client-id: ??
       # appSecret
       client-secret: ??
-      agent-id: ??
+      agent-id: ??

+ 1 - 1
suyuan/jeecg-boot-module-system/src/main/resources/application-prod.yml

@@ -135,7 +135,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://101.200.162.45:3306/suyuan?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          url: jdbc:mysql://101.200.162.45:3306/suyuan?rewriteBatchedStatements=true&characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
           username: suyuan
           password: epi8KhZxY66BwKDB
           driver-class-name: com.mysql.cj.jdbc.Driver