全域VOC由异步入库改为同步入库,解决超过线程数据后无法入库
| | |
| | | <parent> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-parent</artifactId> |
| | | <version>2.3.6.RELEASE</version> |
| | | <version>2.3.3.RELEASE</version> |
| | | </parent> |
| | | |
| | | <packaging>war</packaging> |
| | |
| | | Date date = (Date)calendar.getTime().clone(); |
| | | EasyCsv.read(filePath, VocVals.class, new VocParser(vocValsService, date)).doRead(); |
| | | |
| | | Thread.sleep(5 * 1000); |
| | | // Thread.sleep(3 * 1000); |
| | | } catch (Exception e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | |
| | | return vocValsMapper.deleteByTime(time); |
| | | } |
| | | |
| | | public void insertVocSync(List<VocVals> list) { |
| | | List<List<VocVals>> subLists = Lists.partition(list, 100); |
| | | for (List<VocVals> sub : subLists) { |
| | | vocValsMapper.inserts(sub); |
| | | } |
| | | |
| | | logger.info("------ VOC.csv," + list.size() + " 条数据已入库 ------"); |
| | | } |
| | | |
| | | @Async("threadPoolTaskExecutor") |
| | | public void insertVocVals(List<VocVals> list) throws InterruptedException { |
| | | List<List<VocVals>> lists = Lists.partition(list, IAsyncService.BATCH_INSERT_500); |
| | |
| | | private void inserts() { |
| | | try { |
| | | if (list.size() > 0) { |
| | | this.vocValsService.insertVocVals(list); |
| | | //this.vocValsService.insertVocVals(list); |
| | | this.vocValsService.insertVocSync(list); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error(e.getMessage(), e); |