opt:优化成品出库查询导出
This commit is contained in:
@@ -255,27 +255,27 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
|
|||||||
@Override
|
@Override
|
||||||
public void download2(Map map, HttpServletResponse response, String[] bill_types) throws IOException {
|
public void download2(Map map, HttpServletResponse response, String[] bill_types) throws IOException {
|
||||||
String stor_id = MapUtil.getStr(map, "stor_id");
|
String stor_id = MapUtil.getStr(map, "stor_id");
|
||||||
|
|
||||||
String bill_type = MapUtil.getStr(map, "bill_type");
|
String bill_type = MapUtil.getStr(map, "bill_type");
|
||||||
String with = MapUtil.getStr(map, "with"); // 厚度*幅宽
|
String with = MapUtil.getStr(map, "with"); // 厚度*幅宽
|
||||||
String begin_time = MapUtil.getStr(map, "begin_time");
|
String begin_time = MapUtil.getStr(map, "begin_time");
|
||||||
String pcsn = MapUtil.getStr(map, "pcsn");
|
|
||||||
String end_time = MapUtil.getStr(map, "end_time");
|
String end_time = MapUtil.getStr(map, "end_time");
|
||||||
|
String pcsn = MapUtil.getStr(map, "pcsn");
|
||||||
String customer_name = MapUtil.getStr(map, "customer_name");
|
String customer_name = MapUtil.getStr(map, "customer_name");
|
||||||
|
|
||||||
JSONObject mapParam = new JSONObject();
|
map.put("flag", "2");
|
||||||
mapParam.put("flag", "2");
|
map.put("stor_id", stor_id);
|
||||||
mapParam.put("stor_id", stor_id);
|
|
||||||
if (ObjectUtil.isNotEmpty(bill_types)) {
|
if (ObjectUtil.isNotEmpty(bill_types)) {
|
||||||
StringJoiner joiner = new StringJoiner(",", "(", ")");
|
StringJoiner joiner = new StringJoiner(",", "(", ")");
|
||||||
for (String type : bill_types) {
|
for (String type : bill_types) {
|
||||||
joiner.add("'" + type + "'");
|
joiner.add("'" + type + "'");
|
||||||
}
|
}
|
||||||
mapParam.put("bill_type", joiner.toString());
|
map.put("bill_type", joiner.toString());
|
||||||
}
|
}
|
||||||
mapParam.put("with", with);
|
map.put("with", with);
|
||||||
mapParam.put("pcsn", pcsn);
|
map.put("pcsn", pcsn);
|
||||||
if (ObjectUtil.isNotEmpty(customer_name)) {
|
if (ObjectUtil.isNotEmpty(customer_name)) {
|
||||||
mapParam.put("customer_name", "%" + customer_name + "%");
|
map.put("customer_name", "%" + customer_name + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理时间
|
// 处理时间
|
||||||
@@ -293,11 +293,20 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
|
|||||||
|
|
||||||
String today_end_time = substring + " 07:59:59";
|
String today_end_time = substring + " 07:59:59";
|
||||||
|
|
||||||
mapParam.put("begin_time", today_begin_time);
|
map.put("begin_time", today_begin_time);
|
||||||
mapParam.put("end_time", today_end_time);
|
map.put("end_time", today_end_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONArray resultJSONArray = WQL.getWO("ST_IVT_OUTBILLQUERY").addParamMap(mapParam).process().getResultJSONArray(0);
|
JSONArray resultJSONArray = WQL.getWO("ST_IVT_OUTBILLQUERY").addParamMap(map).process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
List<JSONObject> content = resultJSONArray.toJavaList(JSONObject.class);
|
||||||
|
String pcsn_in = content.stream()
|
||||||
|
.map(row -> row.getString("pcsn"))
|
||||||
|
.collect(Collectors.joining("','"));
|
||||||
|
|
||||||
|
List<JSONObject> subList = WQLObject.getWQLObject("pdm_bi_subpackagerelationrecord")
|
||||||
|
.query("container_name IN ('" + pcsn_in + "') AND io_type = '0' ORDER BY insert_time")
|
||||||
|
.getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||||
|
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
for (int i = 0; i < resultJSONArray.size(); i++) {
|
for (int i = 0; i < resultJSONArray.size(); i++) {
|
||||||
@@ -305,9 +314,10 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
|
|||||||
Map<String, Object> mp = new LinkedHashMap<>();
|
Map<String, Object> mp = new LinkedHashMap<>();
|
||||||
|
|
||||||
// 查询第一次入库的源销售订单
|
// 查询第一次入库的源销售订单
|
||||||
JSONObject jsonSub = WQLObject.getWQLObject("pdm_bi_subpackagerelationrecord")
|
JSONObject jsonSub = subList.stream()
|
||||||
.query("container_name = '" + json.getString("pcsn") + "' AND io_type = '0' ORDER BY insert_time")
|
.filter(row -> row.getString("container_name").equals(json.getString("pcsn")))
|
||||||
.uniqueResult(0);
|
.min(Comparator.comparing(row -> row.getString("insert_time")))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
mp.put("仓库", json.getString("stor_name"));
|
mp.put("仓库", json.getString("stor_name"));
|
||||||
if (ObjectUtil.isNotEmpty(bill_type) && "1004".equals(bill_type)) {
|
if (ObjectUtil.isNotEmpty(bill_type) && "1004".equals(bill_type)) {
|
||||||
|
|||||||
@@ -149,47 +149,169 @@
|
|||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
IF 输入.flag = "2"
|
IF 输入.flag = "2"
|
||||||
PAGEQUERY
|
PAGEQUERY
|
||||||
|
SELECT
|
||||||
|
mst.stor_name,
|
||||||
|
mst.input_time,
|
||||||
|
mst.bill_type,
|
||||||
|
mst.confirm_time,
|
||||||
|
mst.estimated_freight,
|
||||||
|
mst.input_optname,
|
||||||
|
mst.remark,
|
||||||
|
dtl.vbeln,
|
||||||
|
base.cust_name,
|
||||||
|
dis.sect_name,
|
||||||
|
dis.box_no,
|
||||||
|
dis.qty_unit_name,
|
||||||
|
mater.material_code,
|
||||||
|
mater.material_name,
|
||||||
|
c.pcsn,
|
||||||
|
sub.sap_pcsn,
|
||||||
|
sub.net_weight,
|
||||||
|
sub.customer_name,
|
||||||
|
sub.customer_description,
|
||||||
|
sub.sale_order_name,
|
||||||
|
cust.sales_owner,
|
||||||
|
sub.width,
|
||||||
|
sub.thickness,
|
||||||
|
sub.mass_per_unit_area,
|
||||||
|
case when plan.paper_tube_or_FRP = '1' then '纸管' when plan.paper_tube_or_FRP = '2' then 'FRP管' end AS paper_type,
|
||||||
|
case when plan.paper_tube_or_FRP = '1' then plan.paper_tube_material when plan.paper_tube_or_FRP = '2' then plan.FRP_material end AS paper_code,
|
||||||
|
case when plan.paper_tube_or_FRP = '1' then plan.paper_tube_description when plan.paper_tube_or_FRP = '2' then plan.FRP_description end AS paper_name,
|
||||||
|
stor.stor_name AS in_stor_name
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
MAX( a.iostorinvdis_id ) AS iostorinvdis_id,
|
||||||
|
a.pcsn
|
||||||
|
FROM
|
||||||
|
st_ivt_iostorinvdis a
|
||||||
|
LEFT JOIN st_ivt_iostorinv b ON a.iostorinv_id = b.iostorinv_id
|
||||||
|
WHERE
|
||||||
|
b.io_type = '1'
|
||||||
|
AND b.bill_status = '99'
|
||||||
|
AND b.is_delete = '0'
|
||||||
|
OPTION 输入.bill_type <> ""
|
||||||
|
b.bill_type IN 输入.bill_type
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.stor_id <> ""
|
||||||
|
b.stor_id = 输入.stor_id
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.pcsn <> ""
|
||||||
|
a.pcsn = 输入.pcsn
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.begin_time <> ""
|
||||||
|
b.confirm_time >= 输入.begin_time
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.end_time <> ""
|
||||||
|
b.confirm_time <= 输入.end_time
|
||||||
|
ENDOPTION
|
||||||
|
GROUP BY
|
||||||
|
a.pcsn
|
||||||
|
) AS c
|
||||||
|
inner JOIN st_ivt_iostorinvdis dis ON dis.iostorinvdis_id = c.iostorinvdis_id
|
||||||
|
inner JOIN st_ivt_iostorinv mst ON mst.iostorinv_id = dis.iostorinv_id
|
||||||
|
inner JOIN st_ivt_iostorinvdtl dtl ON dtl.iostorinvdtl_id = dis.iostorinvdtl_id
|
||||||
|
LEFT JOIN md_cs_transportationbase base ON base.cust_code = mst.trans_code
|
||||||
|
LEFT JOIN md_me_materialbase mater ON mater.material_id = dis.material_id
|
||||||
|
LEFT JOIN st_ivt_bsrealstorattr stor ON stor.stor_id = mst.out_stor_id
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT
|
||||||
|
record.bill_code,
|
||||||
|
record.container_name,
|
||||||
|
record.package_box_sn,
|
||||||
|
record.sap_pcsn,
|
||||||
|
max(record.customer_name) as customer_name,
|
||||||
|
max(record.customer_description) as customer_description,
|
||||||
|
max(record.width) as width,
|
||||||
|
max(record.thickness) as thickness,
|
||||||
|
max(record.mass_per_unit_area) as mass_per_unit_area,
|
||||||
|
max(record.net_weight) as net_weight,
|
||||||
|
max(record.sale_order_name) as sale_order_name,
|
||||||
|
max(record.bill_id) as bill_id,
|
||||||
|
COUNT( * ) AS num
|
||||||
|
FROM
|
||||||
|
pdm_bi_subpackagerelationrecord record
|
||||||
|
where 1=1
|
||||||
|
OPTION 输入.with <> ""
|
||||||
|
CONCAT(record.width,'*',record.thickness) = 输入.with
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.customer_name <> ""
|
||||||
|
(record.customer_name LIKE 输入.customer_name OR record.customer_description LIKE 输入.customer_name)
|
||||||
|
ENDOPTION
|
||||||
|
GROUP BY
|
||||||
|
record.bill_code,
|
||||||
|
record.container_name,
|
||||||
|
record.sap_pcsn,
|
||||||
|
record.package_box_sn) sub ON (sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no AND sub.bill_id = mst.iostorinv_id)
|
||||||
|
LEFT JOIN md_cs_customerbase cust ON cust.cust_code = sub.customer_name
|
||||||
|
LEFT JOIN (SELECT
|
||||||
|
container_name,
|
||||||
|
MAX(paper_tube_or_FRP) AS paper_tube_or_FRP,
|
||||||
|
MAX(paper_tube_material) AS paper_tube_material,
|
||||||
|
MAX(paper_tube_description) AS paper_tube_description,
|
||||||
|
MAX(paper_tube_model) AS paper_tube_model,
|
||||||
|
MAX(FRP_material) AS FRP_material,
|
||||||
|
MAX(FRP_description) AS FRP_description,
|
||||||
|
MAX(FRP_model) AS FRP_model
|
||||||
|
FROM
|
||||||
|
pdm_bi_slittingproductionplan plan1
|
||||||
|
WHERE
|
||||||
|
plan1.is_delete = '0'
|
||||||
|
GROUP BY container_name) plan ON plan.container_name = sub.container_name
|
||||||
|
WHERE 1=1
|
||||||
|
ENDSELECT
|
||||||
|
ENDPAGEQUERY
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF 输入.flag = "22"
|
||||||
|
QUERY
|
||||||
SELECT
|
SELECT
|
||||||
mst.stor_name,
|
mst.stor_name,
|
||||||
dis.sect_name,
|
mst.input_time,
|
||||||
mst.bill_type,
|
mst.bill_type,
|
||||||
|
mst.confirm_time,
|
||||||
|
mst.estimated_freight,
|
||||||
|
mst.input_optname,
|
||||||
|
mst.remark,
|
||||||
dtl.vbeln,
|
dtl.vbeln,
|
||||||
base.cust_name,
|
base.cust_name,
|
||||||
mst.estimated_freight,
|
dis.sect_name,
|
||||||
dis.box_no,
|
dis.box_no,
|
||||||
|
dis.qty_unit_name,
|
||||||
mater.material_code,
|
mater.material_code,
|
||||||
mater.material_name,
|
mater.material_name,
|
||||||
dis.pcsn,
|
c.pcsn,
|
||||||
sub.sap_pcsn,
|
sub.sap_pcsn,
|
||||||
sub.net_weight,
|
sub.net_weight,
|
||||||
dis.qty_unit_name,
|
|
||||||
sub.customer_name,
|
sub.customer_name,
|
||||||
sub.customer_description,
|
sub.customer_description,
|
||||||
sub.sale_order_name,
|
sub.sale_order_name,
|
||||||
cust.sales_owner,
|
cust.sales_owner,
|
||||||
mst.input_time,
|
|
||||||
sub.width,
|
sub.width,
|
||||||
mst.confirm_time,
|
|
||||||
sub.thickness,
|
sub.thickness,
|
||||||
sub.mass_per_unit_area,
|
sub.mass_per_unit_area,
|
||||||
mst.input_optname,
|
|
||||||
case when plan.paper_tube_or_FRP = '1' then '纸管' when plan.paper_tube_or_FRP = '2' then 'FRP管' end AS paper_type,
|
case when plan.paper_tube_or_FRP = '1' then '纸管' when plan.paper_tube_or_FRP = '2' then 'FRP管' end AS paper_type,
|
||||||
case when plan.paper_tube_or_FRP = '1' then plan.paper_tube_material when plan.paper_tube_or_FRP = '2' then plan.FRP_material end AS paper_code,
|
case when plan.paper_tube_or_FRP = '1' then plan.paper_tube_material when plan.paper_tube_or_FRP = '2' then plan.FRP_material end AS paper_code,
|
||||||
case when plan.paper_tube_or_FRP = '1' then plan.paper_tube_description when plan.paper_tube_or_FRP = '2' then plan.FRP_description end AS paper_name,
|
case when plan.paper_tube_or_FRP = '1' then plan.paper_tube_description when plan.paper_tube_or_FRP = '2' then plan.FRP_description end AS paper_name,
|
||||||
mst.remark,
|
|
||||||
stor.stor_name AS in_stor_name
|
stor.stor_name AS in_stor_name
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
MAX( a.iostorinvdis_id ) AS iostorinvdis_id
|
MAX( a.iostorinvdis_id ) AS iostorinvdis_id,
|
||||||
|
a.pcsn
|
||||||
FROM
|
FROM
|
||||||
st_ivt_iostorinvdis a
|
st_ivt_iostorinvdis a
|
||||||
LEFT JOIN st_ivt_iostorinv b ON a.iostorinv_id = b.iostorinv_id
|
LEFT JOIN st_ivt_iostorinv b ON a.iostorinv_id = b.iostorinv_id
|
||||||
WHERE
|
WHERE
|
||||||
b.io_type = '1'
|
b.io_type = '1'
|
||||||
|
AND b.bill_status = '99'
|
||||||
|
AND b.is_delete = '0'
|
||||||
OPTION 输入.bill_type <> ""
|
OPTION 输入.bill_type <> ""
|
||||||
b.bill_type IN 输入.bill_type
|
b.bill_type IN 输入.bill_type
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.stor_id <> ""
|
||||||
|
b.stor_id = 输入.stor_id
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
OPTION 输入.pcsn <> ""
|
OPTION 输入.pcsn <> ""
|
||||||
a.pcsn = 输入.pcsn
|
a.pcsn = 输入.pcsn
|
||||||
@@ -197,66 +319,64 @@
|
|||||||
OPTION 输入.begin_time <> ""
|
OPTION 输入.begin_time <> ""
|
||||||
b.confirm_time >= 输入.begin_time
|
b.confirm_time >= 输入.begin_time
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
|
|
||||||
OPTION 输入.end_time <> ""
|
OPTION 输入.end_time <> ""
|
||||||
b.confirm_time <= 输入.end_time
|
b.confirm_time <= 输入.end_time
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
AND b.bill_status = '99'
|
|
||||||
GROUP BY
|
GROUP BY
|
||||||
pcsn
|
a.pcsn
|
||||||
) AS c
|
) AS c
|
||||||
LEFT JOIN st_ivt_iostorinvdis dis ON dis.iostorinvdis_id = c.iostorinvdis_id
|
inner JOIN st_ivt_iostorinvdis dis ON dis.iostorinvdis_id = c.iostorinvdis_id
|
||||||
LEFT JOIN st_ivt_iostorinv mst ON mst.iostorinv_id = dis.iostorinv_id
|
inner JOIN st_ivt_iostorinv mst ON mst.iostorinv_id = dis.iostorinv_id
|
||||||
LEFT JOIN st_ivt_iostorinvdtl dtl ON dtl.iostorinvdtl_id = dis.iostorinvdtl_id
|
inner JOIN st_ivt_iostorinvdtl dtl ON dtl.iostorinvdtl_id = dis.iostorinvdtl_id
|
||||||
LEFT JOIN md_cs_transportationbase base ON base.cust_code = mst.trans_code
|
LEFT JOIN md_cs_transportationbase base ON base.cust_code = mst.trans_code
|
||||||
LEFT JOIN md_me_materialbase mater ON mater.material_id = dis.material_id
|
LEFT JOIN md_me_materialbase mater ON mater.material_id = dis.material_id
|
||||||
LEFT JOIN st_ivt_bsrealstorattr stor ON stor.stor_id = mst.out_stor_id
|
LEFT JOIN st_ivt_bsrealstorattr stor ON stor.stor_id = mst.out_stor_id
|
||||||
INNER JOIN pdm_bi_subpackagerelationrecord sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no AND sub.bill_id = mst.iostorinv_id
|
INNER JOIN (
|
||||||
|
SELECT
|
||||||
|
record.bill_code,
|
||||||
|
record.container_name,
|
||||||
|
record.package_box_sn,
|
||||||
|
record.sap_pcsn,
|
||||||
|
max(record.customer_name) as customer_name,
|
||||||
|
max(record.customer_description) as customer_description,
|
||||||
|
max(record.width) as width,
|
||||||
|
max(record.thickness) as thickness,
|
||||||
|
max(record.mass_per_unit_area) as mass_per_unit_area,
|
||||||
|
max(record.net_weight) as net_weight,
|
||||||
|
max(record.sale_order_name) as sale_order_name,
|
||||||
|
max(record.bill_id) as bill_id,
|
||||||
|
COUNT( * ) AS num
|
||||||
|
FROM
|
||||||
|
pdm_bi_subpackagerelationrecord record
|
||||||
|
where 1=1
|
||||||
|
OPTION 输入.with <> ""
|
||||||
|
CONCAT(record.width,'*',record.thickness) = 输入.with
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.customer_name <> ""
|
||||||
|
(record.customer_name LIKE 输入.customer_name OR record.customer_description LIKE 输入.customer_name)
|
||||||
|
ENDOPTION
|
||||||
|
GROUP BY
|
||||||
|
record.bill_code,
|
||||||
|
record.container_name,
|
||||||
|
record.sap_pcsn,
|
||||||
|
record.package_box_sn) sub ON (sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no AND sub.bill_id = mst.iostorinv_id)
|
||||||
LEFT JOIN md_cs_customerbase cust ON cust.cust_code = sub.customer_name
|
LEFT JOIN md_cs_customerbase cust ON cust.cust_code = sub.customer_name
|
||||||
LEFT JOIN (SELECT
|
LEFT JOIN (SELECT
|
||||||
container_name,
|
container_name,
|
||||||
MAX(paper_tube_or_FRP) AS paper_tube_or_FRP,
|
MAX(paper_tube_or_FRP) AS paper_tube_or_FRP,
|
||||||
MAX(paper_tube_material) AS paper_tube_material,
|
MAX(paper_tube_material) AS paper_tube_material,
|
||||||
MAX(paper_tube_description) AS paper_tube_description,
|
MAX(paper_tube_description) AS paper_tube_description,
|
||||||
MAX(paper_tube_model) AS paper_tube_model,
|
MAX(paper_tube_model) AS paper_tube_model,
|
||||||
MAX(FRP_material) AS FRP_material,
|
MAX(FRP_material) AS FRP_material,
|
||||||
MAX(FRP_description) AS FRP_description,
|
MAX(FRP_description) AS FRP_description,
|
||||||
MAX(FRP_model) AS FRP_model
|
MAX(FRP_model) AS FRP_model
|
||||||
FROM
|
FROM
|
||||||
pdm_bi_slittingproductionplan plan1
|
pdm_bi_slittingproductionplan plan1
|
||||||
WHERE
|
WHERE
|
||||||
plan1.is_delete = '0'
|
plan1.is_delete = '0'
|
||||||
GROUP BY container_name) plan ON plan.container_name = sub.container_name
|
GROUP BY container_name) plan ON plan.container_name = sub.container_name
|
||||||
WHERE
|
WHERE 1=1
|
||||||
mst.io_type = '1'
|
limit 0,10000
|
||||||
AND mst.is_delete = '0'
|
|
||||||
AND mst.bill_status = '99'
|
|
||||||
|
|
||||||
OPTION 输入.stor_id <> ""
|
|
||||||
mst.stor_id = 输入.stor_id
|
|
||||||
ENDOPTION
|
|
||||||
|
|
||||||
OPTION 输入.bill_type <> ""
|
|
||||||
mst.bill_type IN 输入.bill_type
|
|
||||||
ENDOPTION
|
|
||||||
|
|
||||||
OPTION 输入.begin_time <> ""
|
|
||||||
mst.confirm_time >= 输入.begin_time
|
|
||||||
ENDOPTION
|
|
||||||
|
|
||||||
OPTION 输入.end_time <> ""
|
|
||||||
mst.confirm_time <= 输入.end_time
|
|
||||||
ENDOPTION
|
|
||||||
|
|
||||||
OPTION 输入.with <> ""
|
|
||||||
CONCAT(sub.width,'*',sub.thickness) = 输入.with
|
|
||||||
ENDOPTION
|
|
||||||
|
|
||||||
OPTION 输入.customer_name <> ""
|
|
||||||
(sub.customer_name LIKE 输入.customer_name OR
|
|
||||||
sub.customer_description LIKE 输入.customer_name)
|
|
||||||
ENDOPTION
|
|
||||||
|
|
||||||
ENDSELECT
|
ENDSELECT
|
||||||
ENDPAGEQUERY
|
ENDQUERY
|
||||||
ENDIF
|
ENDIF
|
||||||
Reference in New Issue
Block a user