|
@@ -3,6 +3,7 @@ package org.jeecg.modules.wzOutboundOrderBNew.service.impl;
|
|
import com.alibaba.excel.EasyExcel;
|
|
import com.alibaba.excel.EasyExcel;
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
import com.alibaba.excel.ExcelReader;
|
|
import com.alibaba.excel.ExcelReader;
|
|
|
|
+import com.alibaba.excel.cache.MapCache;
|
|
import com.alibaba.excel.read.metadata.ReadSheet;
|
|
import com.alibaba.excel.read.metadata.ReadSheet;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -11,10 +12,13 @@ import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
|
+import org.jeecg.modules.dataSourceSwitch.annotation.UseSlaveDataSource;
|
|
import org.jeecg.modules.message.websocket.WebSocket;
|
|
import org.jeecg.modules.message.websocket.WebSocket;
|
|
|
|
+import org.jeecg.modules.projectImportList.readListener.ProjectChbImportReadListener;
|
|
import org.jeecg.modules.projectKmbh.entity.KzksProjectKmbh;
|
|
import org.jeecg.modules.projectKmbh.entity.KzksProjectKmbh;
|
|
import org.jeecg.modules.wzOutboundOrderBNew.entity.WzOutboundOrderBNew;
|
|
import org.jeecg.modules.wzOutboundOrderBNew.entity.WzOutboundOrderBNew;
|
|
import org.jeecg.modules.wzOutboundOrderBNew.mapper.WzOutboundOrderBNewMapper;
|
|
import org.jeecg.modules.wzOutboundOrderBNew.mapper.WzOutboundOrderBNewMapper;
|
|
|
|
+import org.jeecg.modules.wzOutboundOrderBNew.monitor.WzOutboundOrderBNewListenerS;
|
|
import org.jeecg.modules.wzOutboundOrderBNew.monitor.WzOutboundOrderBNewListerner;
|
|
import org.jeecg.modules.wzOutboundOrderBNew.monitor.WzOutboundOrderBNewListerner;
|
|
import org.jeecg.modules.wzOutboundOrderBNew.service.IWzOutboundOrderBNewService;
|
|
import org.jeecg.modules.wzOutboundOrderBNew.service.IWzOutboundOrderBNewService;
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
@@ -28,9 +32,7 @@ import javax.annotation.Resource;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.concurrent.Callable;
|
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
|
-import java.util.concurrent.Executors;
|
|
|
|
|
|
+import java.util.concurrent.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: wz_outbound_order_b_new
|
|
* @Description: wz_outbound_order_b_new
|
|
@@ -52,46 +54,17 @@ public class WzOutboundOrderBNewServiceImpl extends ServiceImpl<WzOutboundOrderB
|
|
private ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
private ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result<?> importExcel1(String strUrl, Class<WzOutboundOrderBNew> clazz) {
|
|
|
|
- InputStream inputStream = null;
|
|
|
|
- try {
|
|
|
|
- inputStream = new FileInputStream(strUrl);
|
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 获取上传文件对象
|
|
|
|
- ImportParams params = new ImportParams();
|
|
|
|
- params.setTitleRows(0);
|
|
|
|
- params.setHeadRows(1);
|
|
|
|
- params.setNeedSave(true);
|
|
|
|
- try {
|
|
|
|
- List<WzOutboundOrderBNew> list = ExcelImportUtil.importExcel(inputStream, clazz, params);
|
|
|
|
- int year = DateUtils.getYear();
|
|
|
|
- orderBNewMapper.deleteByDate(year);
|
|
|
|
- //update-begin-author:taoyan date:20190528 for:批量插入数据
|
|
|
|
- long start = System.currentTimeMillis();
|
|
|
|
- this.saveBatch(list);
|
|
|
|
- log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
|
|
|
- //update-end-author:taoyan date:20190528 for:批量插入数据
|
|
|
|
- return Result.ok("文件导入成功!数据行数:" + list.size());
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
|
|
|
|
- String msg = e.getMessage();
|
|
|
|
- log.error(msg, e);
|
|
|
|
- if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
|
|
|
|
- return Result.error("文件导入失败:有重复数据!");
|
|
|
|
- } else {
|
|
|
|
- return Result.error("文件导入失败:" + e.getMessage());
|
|
|
|
- }
|
|
|
|
- //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
|
|
|
|
- } finally {
|
|
|
|
- try {
|
|
|
|
- inputStream.close();
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ public Result<?> importExcel1(String strUrl, Class<WzOutboundOrderBNew> clazz) throws InterruptedException, ExecutionException, IOException{
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
+ ExcelReader excelReader = EasyExcel.read(new File(strUrl), clazz, new WzOutboundOrderBNewListenerS(this)).build();
|
|
|
|
+ ReadSheet readSheet = EasyExcel.readSheet(0).build();
|
|
|
|
+ excelReader.read(readSheet);
|
|
|
|
+ //这里千万别忘记关闭,读的时候会创建临时文件,到时磁盘会崩的
|
|
|
|
+ excelReader.finish();
|
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
|
+ log.info("导入物资数据花费时间:{}毫秒 | {}分钟", (endTime - startTime), ((endTime - startTime) / 1000 / 60));
|
|
|
|
+
|
|
|
|
+ return Result.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|