|
|
|
@ -120,6 +120,9 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
double temp = threadSize - maxThreadSize; |
|
|
|
maxThreadSize = (int) (Math.ceil(temp / maxThreadSize) * maxThreadSize); |
|
|
|
} |
|
|
|
if(maxThreadSize < threadSize){ |
|
|
|
maxThreadSize = threadSize; |
|
|
|
} |
|
|
|
|
|
|
|
// 定义开启线程数目
|
|
|
|
int openThreadSize = 0; |
|
|
|
@ -237,10 +240,20 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
// 定义线程数
|
|
|
|
int threadSize = (int) Math.ceil(totalVal / size); |
|
|
|
|
|
|
|
// 定义最大线程数
|
|
|
|
int maxThreadSize = Runtime.getRuntime().availableProcessors(); |
|
|
|
if (threadSize > maxThreadSize) { |
|
|
|
double temp = threadSize - maxThreadSize; |
|
|
|
maxThreadSize = (int) (Math.ceil(temp / maxThreadSize) * maxThreadSize); |
|
|
|
} |
|
|
|
if(maxThreadSize < threadSize){ |
|
|
|
maxThreadSize = threadSize; |
|
|
|
} |
|
|
|
|
|
|
|
// 定义开启线程数目
|
|
|
|
int openThreadSize = 0; |
|
|
|
// 开启对应数量的线程
|
|
|
|
ExecutorService exs = new ThreadPoolExecutor(threadSize, threadSize, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(threadSize)); |
|
|
|
ExecutorService exs = new ThreadPoolExecutor(threadSize, maxThreadSize, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(maxThreadSize)); |
|
|
|
|
|
|
|
// 线程结果集
|
|
|
|
List<Future<List<String>>> futureList = new ArrayList<Future<List<String>>>(); |
|
|
|
@ -357,10 +370,20 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
// 定义线程数
|
|
|
|
int threadSize = (int) Math.ceil(totalVal / size); |
|
|
|
|
|
|
|
// 定义最大线程数
|
|
|
|
int maxThreadSize = Runtime.getRuntime().availableProcessors(); |
|
|
|
if (threadSize > maxThreadSize) { |
|
|
|
double temp = threadSize - maxThreadSize; |
|
|
|
maxThreadSize = (int) (Math.ceil(temp / maxThreadSize) * maxThreadSize); |
|
|
|
} |
|
|
|
if(maxThreadSize < threadSize){ |
|
|
|
maxThreadSize = threadSize; |
|
|
|
} |
|
|
|
|
|
|
|
// 定义开启线程数目
|
|
|
|
int openThreadSize = 0; |
|
|
|
// 开启对应数量的线程
|
|
|
|
ExecutorService exs = new ThreadPoolExecutor(threadSize, threadSize, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(threadSize)); |
|
|
|
ExecutorService exs = new ThreadPoolExecutor(threadSize, maxThreadSize, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(maxThreadSize)); |
|
|
|
|
|
|
|
// 线程结果集
|
|
|
|
List<Future<List<String>>> futureList = new ArrayList<Future<List<String>>>(); |
|
|
|
@ -405,8 +428,6 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
// 关闭线程池
|
|
|
|
PublicConfig.closeThreadPool(exs); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<ExcelInfoByInventory> userExcelInventoryInfo = ExcelFileInfoPool.getUserExcelInventoryInfo(userByPort.getNumber()); |
|
|
|
if (userExcelInventoryInfo == null) { |
|
|
|
userExcelInventoryInfo = new ArrayList<>(); |
|
|
|
@ -612,6 +633,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
public void executeImportForInventory(UserByPort userByPort) { |
|
|
|
List<Object> success = new ArrayList<>(); |
|
|
|
String number = userByPort.getNumber(); |
|
|
|
int successCount = 0; |
|
|
|
List<ExcelInfoByInventory> excelVosForInventory = ExcelFileInfoPool.getUserExcelInventoryInfo(number); |
|
|
|
for (int i = 0; i < excelVosForInventory.size(); i++) { |
|
|
|
ExcelInfoByInventory excelInfoByInventory = excelVosForInventory.get(i); |
|
|
|
@ -648,7 +670,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
} |
|
|
|
|
|
|
|
// 插入库存记录
|
|
|
|
materialService.insertInventoryForImport(insert); |
|
|
|
successCount += materialService.insertInventoryForImport(insert); |
|
|
|
|
|
|
|
// 将该物料同时放入默认库位中
|
|
|
|
String placeCode = excelInfoByInventory.getDepositoryCode(); |
|
|
|
@ -725,7 +747,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelFileInfoPool.removeUserExcelInventoryInfo(number); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForInventory) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber()); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForInventory) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber()+";导入总数为:"+successCount); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -738,6 +760,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
|
|
|
|
List<Object> success = new ArrayList<>(); |
|
|
|
String number = userByPort.getNumber(); |
|
|
|
int successNum = 0; |
|
|
|
List<ExcelInfoByMT> excelVosForMaterialType = ExcelFileInfoPool.getUserExcelMaterialTypeInfo(number); |
|
|
|
for (int i = 0; i < excelVosForMaterialType.size(); i++) { |
|
|
|
ExcelInfoByMT excelInfoByMT = excelVosForMaterialType.get(i); |
|
|
|
@ -751,7 +774,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
} else { |
|
|
|
insert.put("materialTypeId", info.getParentId()); |
|
|
|
} |
|
|
|
materialTypeService.insertMaterialType(insert); |
|
|
|
successNum+=materialTypeService.insertMaterialType(insert); |
|
|
|
success.add(info); |
|
|
|
if ((i + 1) % 100 == 0 || excelVosForMaterialType.size() - 1 == i) { |
|
|
|
// 如果凑够100条或者已经循环完成 发送消息
|
|
|
|
@ -765,7 +788,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
|
|
|
|
} |
|
|
|
ExcelFileInfoPool.removeUserExcelMaterialTypeInfo(number); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterialType) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber()); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterialType) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber()+";导入总数"+successNum); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -776,6 +799,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
List<Object> success = new ArrayList<>(); |
|
|
|
String number = userByPort.getNumber(); |
|
|
|
List<ExcelInfoForMaterial> excelVosForMaterial = ExcelFileInfoPool.getUserExcelMaterialInfo(number); |
|
|
|
int successNum = 0; |
|
|
|
for (int i = 0; i < excelVosForMaterial.size(); i++) { |
|
|
|
ExcelInfoForMaterial excelVo = excelVosForMaterial.get(i); |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
@ -811,7 +835,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
param.put("brand", excelVo.getBrand()); |
|
|
|
param.put("price", excelVo.getPrice() == null ? "0" : excelVo.getPrice()); |
|
|
|
param.put("uid", userByPort.getId()); |
|
|
|
materialService.insertMaterial(param); |
|
|
|
successNum += materialService.insertMaterial(param); |
|
|
|
success.add(excelVo); |
|
|
|
if ((i + 1) % 100 == 0 || excelVosForMaterial.size() - 1 == i) { |
|
|
|
// 如果凑够100条或者已经循环完成 发送消息
|
|
|
|
@ -824,7 +848,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelFileInfoPool.removeUserExcelMaterialInfo(number); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterial) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber()); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterial) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber()+";导入总数"+successNum); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|