|
|
|
@ -29,10 +29,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
import com.ruoyi.common.config.Global;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 时段统计
|
|
|
|
@ -114,16 +110,15 @@ public class SelectProRpListController extends BaseController
|
|
|
|
|
public AjaxResult export(ProRpList proRpList) {
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
map.put("beginTime", proRpList.getParams().get("startTime"));
|
|
|
|
|
map.put("startTime", proRpList.getParams().get("startTime"));
|
|
|
|
|
map.put("endTime", proRpList.getParams().get("endTime"));
|
|
|
|
|
|
|
|
|
|
map.put("productId", proRpList.getProductID());
|
|
|
|
|
map.put("productType", proRpList.getProductType());
|
|
|
|
|
map.put("state", proRpList.getState());
|
|
|
|
|
map.put("semiBarcode", proRpList.getSemiBarcode());
|
|
|
|
|
map.put("beginTime", proRpList.getParams().get("beginTime"));
|
|
|
|
|
map.put("endTime", proRpList.getParams().get("endTime"));
|
|
|
|
|
|
|
|
|
|
TSyTracestate tSyTracestate = new TSyTracestate();
|
|
|
|
|
|
|
|
|
|
tSyTracestate.setProductID(proRpList.getProductID());
|
|
|
|
|
tSyTracestate.setState(proRpList.getState());
|
|
|
|
|
tSyTracestate.setBarcode(proRpList.getSemiBarcode());
|
|
|
|
|
|
|
|
|
|
tSyTracestate.setParams(map);
|
|
|
|
|
// 获取TSyTracestate列表
|
|
|
|
|
List<TSyTracestate> list = tracestateService.selectTSyTracestateList(tSyTracestate);
|
|
|
|
@ -133,7 +128,7 @@ public class SelectProRpListController extends BaseController
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 优化线程池配置
|
|
|
|
|
int BATCH_SIZE = 500; // 每批处理500条记录
|
|
|
|
|
int BATCH_SIZE = 1600; // 每批处理1600条记录
|
|
|
|
|
|
|
|
|
|
// 计算最优线程数
|
|
|
|
|
int CPU_CORES = Runtime.getRuntime().availableProcessors();
|
|
|
|
@ -141,7 +136,6 @@ public class SelectProRpListController extends BaseController
|
|
|
|
|
Math.max(CPU_CORES / 4, 4), // CPU核心数的1/4,但不少于4个线程
|
|
|
|
|
8 // 最大不超过8个线程
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 线程池配置
|
|
|
|
|
ThreadPoolExecutor executorService = new ThreadPoolExecutor(
|
|
|
|
|
OPTIMAL_THREADS, // 核心线程数
|
|
|
|
@ -177,7 +171,7 @@ public class SelectProRpListController extends BaseController
|
|
|
|
|
}
|
|
|
|
|
// 优化7:检查是否有足够的数据
|
|
|
|
|
if (printInfo.isEmpty()) {
|
|
|
|
|
return AjaxResult.error("未能成功获取数据,请重试或减少数据量");
|
|
|
|
|
return AjaxResult.error("未能成功获取数据,请重试或减少数据量,或者该段时间无数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建 ExcelUtil 实例
|
|
|
|
@ -186,7 +180,8 @@ public class SelectProRpListController extends BaseController
|
|
|
|
|
Map<String, List<?>> sheetDataMap = new HashMap<>();
|
|
|
|
|
sheetDataMap.put("时段查询", list);
|
|
|
|
|
sheetDataMap.put("工位数据", printInfo);
|
|
|
|
|
String fileName = "data_" + DateUtils.dateTimeNow() + ".xlsx";
|
|
|
|
|
String fileName = DateUtils.dateTimeNow() + ".xlsx";
|
|
|
|
|
|
|
|
|
|
return excelUtil.exportMultiSheet(sheetDataMap, fileName);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|