Commit 3b1002a9 authored by renjie's avatar renjie

批量添加文件bug

parent 3cbe5a56
...@@ -51,7 +51,7 @@ public class ShopController { ...@@ -51,7 +51,7 @@ public class ShopController {
} }
@RequestMapping(value = "/multiadd", method = RequestMethod.POST) @RequestMapping(value = "/multiadd", method = RequestMethod.POST)
public List<String> addShops(Principal principal, @RequestParam("file") MultipartFile file) { public ResultDto addShops(Principal principal, @RequestParam("file") MultipartFile file) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
String name = file.getOriginalFilename(); String name = file.getOriginalFilename();
if(name.length()<6 || !name.substring(name.length()-5).equals(".xlsx")){ if(name.length()<6 || !name.substring(name.length()-5).equals(".xlsx")){
...@@ -63,6 +63,7 @@ public class ShopController { ...@@ -63,6 +63,7 @@ public class ShopController {
} }
try { try {
shopService.addShops(principal.getName(), file); shopService.addShops(principal.getName(), file);
resultDto.setStatus(0);
} catch (ClientRequestException | IOException e) { } catch (ClientRequestException | IOException e) {
resultDto.setStatus(-1); resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>(); Map<String, Object> statusInfo = new HashMap<>();
...@@ -72,7 +73,7 @@ public class ShopController { ...@@ -72,7 +73,7 @@ public class ShopController {
} }
return null; return resultDto;
} }
......
...@@ -87,7 +87,7 @@ public class FileUtil { ...@@ -87,7 +87,7 @@ public class FileUtil {
//得到指定的单元格 //得到指定的单元格
Cell cell = row.getCell(0);; Cell cell = row.getCell(0);;
int size = 1; int size = 1;
for (int i = 2; i < rowLength; i++) { for (int i = 1; i < rowLength; i++) {
row = sheet.getRow(i); row = sheet.getRow(i);
List<Object> rowvalue = new ArrayList<>(); List<Object> rowvalue = new ArrayList<>();
size = 0; size = 0;
......
package com.edgec.browserbackend.common.utils;
import java.time.Instant;
public class PollerUtils {
public static void poll(int timeoutInSeconds, int intervalInSeconds, Evaluator evaluator) {
boolean result = evaluator.eval();
long start = Instant.now().toEpochMilli();
while (!result) {
long end = Instant.now().toEpochMilli();
if((end - start) > timeoutInSeconds * 1000)
return;
try {
Thread.sleep(intervalInSeconds * 1000);
} catch (InterruptedException e) {
}
result = evaluator.eval();
}
}
public static interface Evaluator {
boolean eval();
}
}
package com.edgec.browserbackend.common.utils;
import com.edgec.browserbackend.common.commons.utils.PriorityThreadPoolExecutor;
import com.edgec.browserbackend.common.commons.utils.UniquePriorityBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.*;
public abstract class ThreadPoolUtils {
private static final Logger log = LoggerFactory.getLogger(ThreadPoolUtils.class);
private static final int SCHEDULER_POOL_COUNT = 50;
public static final int MAX_WAITING_TASKS = 10;
public static final BlockingQueue<Runnable> schedulerQueue = new UniquePriorityBlockingQueue<>(50);
private static final int TASK_POOL_COUNT = 80;
public static final ExecutorService taskExecutorPool = Executors.newFixedThreadPool(TASK_POOL_COUNT, new ThreadFactory() {
int count = 1;
@Override
public Thread newThread(Runnable runnable) {
return new Thread(runnable, "intelligroup-taskexec-" + count++);
}
});
private static final int TIME_SCHEDULER_POOL_COUNT = 10;
public static final ScheduledExecutorService timeSchedulerPool = Executors.newScheduledThreadPool(TIME_SCHEDULER_POOL_COUNT, new ThreadFactory() {
int count = 1;
@Override
public Thread newThread(Runnable runnable) {
return new Thread(runnable, "intelligroup-time-scheduler-" + count++);
}
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment