opt:优化导出功能
This commit is contained in:
@@ -346,123 +346,131 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
|
||||
for (List<JSONObject> jsonObjects : deque) {
|
||||
datas.addAll(jsonObjects);
|
||||
}
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
for (int i = 0; i < resultJSONArray.size(); i++) {
|
||||
JSONObject json = resultJSONArray.getJSONObject(i);
|
||||
Map<String, String> mp = new LinkedHashMap<>();
|
||||
// 查询第一次入库的源销售订单
|
||||
JSONObject jsonSub = datas.stream()
|
||||
.filter(row -> row.getString("container_name").equals(json.getString("pcsn")))
|
||||
.min(Comparator.comparing(row -> row.getString("insert_time")))
|
||||
.orElse(null);
|
||||
ConcurrentLinkedDeque<List<Map<String,String>>> listDeque = new ConcurrentLinkedDeque<>();
|
||||
Lists.partition(resultJSONArray,1000).stream().map((Function<List, CompletableFuture>) o->CompletableFuture.runAsync(() -> {
|
||||
List<Map<String, String>> items = new ArrayList<>();
|
||||
for (Object item : o) {
|
||||
JSONObject json = (JSONObject) item;
|
||||
Map<String, String> mp = new LinkedHashMap<>();
|
||||
// 查询第一次入库的源销售订单
|
||||
JSONObject jsonSub = datas.stream()
|
||||
.filter(row -> row.getString("container_name").equals(json.getString("pcsn")))
|
||||
.min(Comparator.comparing(row -> row.getString("insert_time")))
|
||||
.orElse(null);
|
||||
|
||||
mp.put("仓库", json.getString("stor_name"));
|
||||
if (ObjectUtil.isNotEmpty(bill_type) && "1004".equals(bill_type)) {
|
||||
mp.put("移入仓库", json.getString("in_stor_name"));
|
||||
}
|
||||
mp.put("库区", json.getString("sect_name"));
|
||||
mp.put("生产区域", json.getString("pcsn").substring(0, 2));
|
||||
String bill_type1 = json.getString("bill_type");
|
||||
|
||||
String bill_name = "";
|
||||
switch (bill_type1) {
|
||||
case "1001" :
|
||||
bill_name = "发货出库";
|
||||
break;
|
||||
case "1003" :
|
||||
bill_name = "改切出库";
|
||||
break;
|
||||
case "1004" :
|
||||
bill_name = "调拨出库";
|
||||
break;
|
||||
case "1005" :
|
||||
bill_name = "拆箱出库";
|
||||
break;
|
||||
case "1006" :
|
||||
bill_name = "返检出库";
|
||||
break;
|
||||
case "1007" :
|
||||
bill_name = "超期报废";
|
||||
break;
|
||||
case "1008" :
|
||||
bill_name = "退货报废";
|
||||
break;
|
||||
case "1010" :
|
||||
bill_name = "质量问题报废";
|
||||
break;
|
||||
case "1002" :
|
||||
bill_name = "其他报废";
|
||||
break;
|
||||
case "1011" :
|
||||
bill_name = "分拣出库";
|
||||
break;
|
||||
case "1009" :
|
||||
bill_name = "手工出库";
|
||||
break;
|
||||
}
|
||||
mp.put("业务类型", bill_name);
|
||||
mp.put("交货单号", json.getString("vbeln"));
|
||||
mp.put("物流公司", json.getString("cust_name"));
|
||||
mp.put("运费", json.getString("estimated_freight"));
|
||||
mp.put("木箱号", json.getString("box_no"));
|
||||
mp.put("物料编码", json.getString("material_code"));
|
||||
mp.put("物料名称", json.getString("material_name"));
|
||||
mp.put("子卷号", json.getString("pcsn"));
|
||||
mp.put("sap批次", json.getString("sap_pcsn"));
|
||||
mp.put("净重", json.getString("net_weight"));
|
||||
mp.put("单位", json.getString("qty_unit_name"));
|
||||
mp.put("管件类型", json.getString("paper_type"));
|
||||
mp.put("管件编码", json.getString("paper_code"));
|
||||
mp.put("管件描述", json.getString("paper_name"));
|
||||
mp.put("客户编码", json.getString("customer_name"));
|
||||
mp.put("发货客户名称", json.getString("customer_description"));
|
||||
mp.put("销售订单", json.getString("sale_order_name"));
|
||||
mp.put("行号", "");
|
||||
mp.put("原销售订单", json.getString("sale_order_name"));
|
||||
mp.put("原行号", "");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(json.getString("sale_order_name"))) {
|
||||
try {
|
||||
mp.put("销售订单", json.getString("sale_order_name").substring(0, json.getString("sale_order_name").indexOf("-")));
|
||||
mp.put("行号", json.getString("sale_order_name").substring(json.getString("sale_order_name").indexOf("-") + 1, json.getString("sale_order_name").length()));
|
||||
} catch (Exception e) {
|
||||
mp.put("销售订单", json.getString("sale_order_name"));
|
||||
mp.put("行号", "");
|
||||
mp.put("仓库", json.getString("stor_name"));
|
||||
if (ObjectUtil.isNotEmpty(bill_type) && "1004".equals(bill_type)) {
|
||||
mp.put("移入仓库", json.getString("in_stor_name"));
|
||||
}
|
||||
}
|
||||
// 原销售订单
|
||||
if (ObjectUtil.isEmpty(jsonSub)) {
|
||||
mp.put("库区", json.getString("sect_name"));
|
||||
mp.put("生产区域", json.getString("pcsn").substring(0, 2));
|
||||
String bill_type1 = json.getString("bill_type");
|
||||
|
||||
String bill_name = "";
|
||||
switch (bill_type1) {
|
||||
case "1001" :
|
||||
bill_name = "发货出库";
|
||||
break;
|
||||
case "1003" :
|
||||
bill_name = "改切出库";
|
||||
break;
|
||||
case "1004" :
|
||||
bill_name = "调拨出库";
|
||||
break;
|
||||
case "1005" :
|
||||
bill_name = "拆箱出库";
|
||||
break;
|
||||
case "1006" :
|
||||
bill_name = "返检出库";
|
||||
break;
|
||||
case "1007" :
|
||||
bill_name = "超期报废";
|
||||
break;
|
||||
case "1008" :
|
||||
bill_name = "退货报废";
|
||||
break;
|
||||
case "1010" :
|
||||
bill_name = "质量问题报废";
|
||||
break;
|
||||
case "1002" :
|
||||
bill_name = "其他报废";
|
||||
break;
|
||||
case "1011" :
|
||||
bill_name = "分拣出库";
|
||||
break;
|
||||
case "1009" :
|
||||
bill_name = "手工出库";
|
||||
break;
|
||||
}
|
||||
mp.put("业务类型", bill_name);
|
||||
mp.put("交货单号", json.getString("vbeln"));
|
||||
mp.put("物流公司", json.getString("cust_name"));
|
||||
mp.put("运费", json.getString("estimated_freight"));
|
||||
mp.put("木箱号", json.getString("box_no"));
|
||||
mp.put("物料编码", json.getString("material_code"));
|
||||
mp.put("物料名称", json.getString("material_name"));
|
||||
mp.put("子卷号", json.getString("pcsn"));
|
||||
mp.put("sap批次", json.getString("sap_pcsn"));
|
||||
mp.put("净重", json.getString("net_weight"));
|
||||
mp.put("单位", json.getString("qty_unit_name"));
|
||||
mp.put("管件类型", json.getString("paper_type"));
|
||||
mp.put("管件编码", json.getString("paper_code"));
|
||||
mp.put("管件描述", json.getString("paper_name"));
|
||||
mp.put("客户编码", json.getString("customer_name"));
|
||||
mp.put("发货客户名称", json.getString("customer_description"));
|
||||
mp.put("销售订单", json.getString("sale_order_name"));
|
||||
mp.put("行号", "");
|
||||
mp.put("原销售订单", json.getString("sale_order_name"));
|
||||
mp.put("原行号", "");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(json.getString("sale_order_name"))) {
|
||||
try {
|
||||
mp.put("原销售订单", json.getString("sale_order_name").substring(0, json.getString("sale_order_name").indexOf("-")));
|
||||
mp.put("原行号", json.getString("sale_order_name").substring(json.getString("sale_order_name").indexOf("-") + 1, json.getString("sale_order_name").length()));
|
||||
mp.put("销售订单", json.getString("sale_order_name").substring(0, json.getString("sale_order_name").indexOf("-")));
|
||||
mp.put("行号", json.getString("sale_order_name").substring(json.getString("sale_order_name").indexOf("-") + 1, json.getString("sale_order_name").length()));
|
||||
} catch (Exception e) {
|
||||
mp.put("原销售订单", json.getString("sale_order_name"));
|
||||
mp.put("原行号", "");
|
||||
mp.put("销售订单", json.getString("sale_order_name"));
|
||||
mp.put("行号", "");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ObjectUtil.isNotEmpty(jsonSub.getString("sale_order_name"))) {
|
||||
try {
|
||||
mp.put("原销售订单", jsonSub.getString("sale_order_name").substring(0, jsonSub.getString("sale_order_name").indexOf("-")));
|
||||
mp.put("原行号", jsonSub.getString("sale_order_name").substring(jsonSub.getString("sale_order_name").indexOf("-") + 1, jsonSub.getString("sale_order_name").length()));
|
||||
} catch (Exception e) {
|
||||
mp.put("原销售订单", jsonSub.getString("sale_order_name"));
|
||||
mp.put("原行号", "");
|
||||
// 原销售订单
|
||||
if (ObjectUtil.isEmpty(jsonSub)) {
|
||||
if (ObjectUtil.isNotEmpty(json.getString("sale_order_name"))) {
|
||||
try {
|
||||
mp.put("原销售订单", json.getString("sale_order_name").substring(0, json.getString("sale_order_name").indexOf("-")));
|
||||
mp.put("原行号", json.getString("sale_order_name").substring(json.getString("sale_order_name").indexOf("-") + 1, json.getString("sale_order_name").length()));
|
||||
} catch (Exception e) {
|
||||
mp.put("原销售订单", json.getString("sale_order_name"));
|
||||
mp.put("原行号", "");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ObjectUtil.isNotEmpty(jsonSub.getString("sale_order_name"))) {
|
||||
try {
|
||||
mp.put("原销售订单", jsonSub.getString("sale_order_name").substring(0, jsonSub.getString("sale_order_name").indexOf("-")));
|
||||
mp.put("原行号", jsonSub.getString("sale_order_name").substring(jsonSub.getString("sale_order_name").indexOf("-") + 1, jsonSub.getString("sale_order_name").length()));
|
||||
} catch (Exception e) {
|
||||
mp.put("原销售订单", jsonSub.getString("sale_order_name"));
|
||||
mp.put("原行号", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mp.put("业务员", json.getString("sales_owner"));
|
||||
mp.put("出库日期", json.getString("input_time"));
|
||||
mp.put("产品规格", String.format("%.0f", json.getDoubleValue("width")));
|
||||
mp.put("产品厚度", json.getString("thickness"));
|
||||
mp.put("单位面积", json.getString("mass_per_unit_area"));
|
||||
mp.put("制单人", json.getString("input_optname"));
|
||||
mp.put("备注", json.getString("remark"));
|
||||
list.add(mp);
|
||||
mp.put("业务员", json.getString("sales_owner"));
|
||||
mp.put("出库日期", json.getString("input_time"));
|
||||
mp.put("产品规格", String.format("%.0f", json.getDoubleValue("width")));
|
||||
mp.put("产品厚度", json.getString("thickness"));
|
||||
mp.put("单位面积", json.getString("mass_per_unit_area"));
|
||||
mp.put("制单人", json.getString("input_optname"));
|
||||
mp.put("备注", json.getString("remark"));
|
||||
items.add(mp);
|
||||
}
|
||||
listDeque.add(items);
|
||||
})).parallel().forEach(CompletableFuture::join);
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
for (List<Map<String, String>> maps : listDeque) {
|
||||
list.addAll(maps);
|
||||
}
|
||||
Set<String> set = list.get(0).keySet();
|
||||
Set<String> set = listDeque.getFirst().get(0).keySet();
|
||||
int colIndex = 0;
|
||||
String[] col = new String[set.size()];
|
||||
for (String s : set) {
|
||||
@@ -470,6 +478,5 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
|
||||
colIndex++;
|
||||
}
|
||||
new FileUtil().downloadExcelIO(list,col,response);
|
||||
// FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@ spring:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:88lmsdb}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_lms5}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.87}:${DB_PORT:3306}/${DB_NAME:lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:NLABC&hl123}
|
||||
password: ${DB_PWD:12356}
|
||||
password: ${DB_PWD:NLABC&hl123}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接数
|
||||
|
||||
Reference in New Issue
Block a user