|
@@ -37,10 +37,8 @@
|
|
|
a.create_by_id as createBy,
|
|
a.create_by_id as createBy,
|
|
|
a.create_time as createDate,
|
|
a.create_time as createDate,
|
|
|
a.ware_house_type,
|
|
a.ware_house_type,
|
|
|
- c.name as trade_name,
|
|
|
|
|
- c.brand,
|
|
|
|
|
- c.specification,
|
|
|
|
|
- c.company,
|
|
|
|
|
|
|
+ a.trade_name,
|
|
|
|
|
+ a.company,
|
|
|
b.NAME AS wareHouseTypeName,
|
|
b.NAME AS wareHouseTypeName,
|
|
|
sum( trade_number ) AS allNumber,
|
|
sum( trade_number ) AS allNumber,
|
|
|
b.collect_number AS borrowNumber,
|
|
b.collect_number AS borrowNumber,
|
|
@@ -50,32 +48,25 @@
|
|
|
psi_management_warehouse_detailed a
|
|
psi_management_warehouse_detailed a
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
SELECT
|
|
|
- sum(
|
|
|
|
|
- CASE
|
|
|
|
|
- WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
|
|
|
|
|
- WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
|
|
|
|
|
- WHEN r.status = '5' AND d.is_return = '1' THEN 0
|
|
|
|
|
- ELSE IFNULL(e.not_surplus_stock, e.collect_number)
|
|
|
|
|
- END
|
|
|
|
|
- ) AS collect_number,
|
|
|
|
|
- e.collect_type,
|
|
|
|
|
|
|
+ sum( g.collect_number ) AS collect_number,
|
|
|
|
|
+ e.goods_name,
|
|
|
c.NAME as name,
|
|
c.NAME as name,
|
|
|
- min(e.basic_id) as mmcId
|
|
|
|
|
|
|
+ e.basic_id as mmcId,
|
|
|
|
|
+ STATUS
|
|
|
FROM
|
|
FROM
|
|
|
- psi_management_collect_detailed_record e
|
|
|
|
|
|
|
+ psi_management_collect_detailed e
|
|
|
LEFT JOIN psi_management_collect_basics f ON e.basic_id = f.id
|
|
LEFT JOIN psi_management_collect_basics f ON e.basic_id = f.id
|
|
|
AND f.del_flag = 0
|
|
AND f.del_flag = 0
|
|
|
- LEFT JOIN psi_management_collect_detailed d ON e.detail_id = d.id
|
|
|
|
|
- LEFT JOIN psi_management_collect_basics_return r ON r.basic_id = e.basic_id AND r.del_flag = 0
|
|
|
|
|
LEFT JOIN psi_management_type c ON e.collect_type = c.id
|
|
LEFT JOIN psi_management_type c ON e.collect_type = c.id
|
|
|
|
|
+ left join psi_management_collect_detailed g on e.goods_name = g.goods_name and g.del_flag = 0
|
|
|
WHERE
|
|
WHERE
|
|
|
f.`status` = 5 AND e.del_flag = 0
|
|
f.`status` = 5 AND e.del_flag = 0
|
|
|
GROUP BY
|
|
GROUP BY
|
|
|
- e.collect_type, c.NAME
|
|
|
|
|
- ) b ON a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ e.id
|
|
|
|
|
+ ) b ON a.trade_name = b.goods_name
|
|
|
LEFT JOIN psi_management_type c ON a.ware_house_type = c.id
|
|
LEFT JOIN psi_management_type c ON a.ware_house_type = c.id
|
|
|
${ew.customSqlSegment}
|
|
${ew.customSqlSegment}
|
|
|
- GROUP BY a.ware_house_type
|
|
|
|
|
|
|
+ GROUP BY a.trade_name,a.ware_house_type
|
|
|
HAVING sum( trade_number ) - IFNULL(collect_number,0) <= 5
|
|
HAVING sum( trade_number ) - IFNULL(collect_number,0) <= 5
|
|
|
ORDER BY a.update_time DESC
|
|
ORDER BY a.update_time DESC
|
|
|
</select>
|
|
</select>
|
|
@@ -86,10 +77,8 @@
|
|
|
a.create_by_id as createBy,
|
|
a.create_by_id as createBy,
|
|
|
a.create_time as createDate,
|
|
a.create_time as createDate,
|
|
|
a.ware_house_type,
|
|
a.ware_house_type,
|
|
|
- c.name as trade_name,
|
|
|
|
|
- c.brand,
|
|
|
|
|
- c.specification,
|
|
|
|
|
- c.company,
|
|
|
|
|
|
|
+ a.trade_name,
|
|
|
|
|
+ a.company,
|
|
|
c.name as wareHouseTypeName,
|
|
c.name as wareHouseTypeName,
|
|
|
sum( trade_number ) AS allNumber,
|
|
sum( trade_number ) AS allNumber,
|
|
|
b.collect_number AS borrowNumber,
|
|
b.collect_number AS borrowNumber,
|
|
@@ -108,51 +97,45 @@
|
|
|
left join
|
|
left join
|
|
|
(
|
|
(
|
|
|
select
|
|
select
|
|
|
- sum(
|
|
|
|
|
- CASE
|
|
|
|
|
- WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
|
|
|
|
|
- WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
|
|
|
|
|
- WHEN r.status = '5' AND d.is_return = '1' THEN 0
|
|
|
|
|
- ELSE IFNULL(e.not_surplus_stock, e.collect_number)
|
|
|
|
|
- END
|
|
|
|
|
- ) as collect_number,
|
|
|
|
|
- e.collect_type
|
|
|
|
|
- from psi_management_collect_detailed_record e
|
|
|
|
|
|
|
+ sum(collect_number) as collect_number,
|
|
|
|
|
+ goods_name,
|
|
|
|
|
+ status
|
|
|
|
|
+ from psi_management_collect_detailed e
|
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
- left join psi_management_collect_detailed d on e.detail_id = d.id
|
|
|
|
|
- left join psi_management_collect_basics_return r on r.basic_id = e.basic_id and r.del_flag = 0
|
|
|
|
|
- WHERE f.`status` = 5 and e.del_flag = 0
|
|
|
|
|
- GROUP BY e.collect_type
|
|
|
|
|
|
|
+ WHERE f.`status` = 5 and e.del_flag = 0 and e.is_return = '0'
|
|
|
|
|
+ GROUP BY e.goods_name
|
|
|
) b
|
|
) b
|
|
|
- on a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = b.goods_name
|
|
|
left join
|
|
left join
|
|
|
(
|
|
(
|
|
|
select
|
|
select
|
|
|
sum(loss_number) as loss_number,
|
|
sum(loss_number) as loss_number,
|
|
|
- collect_type
|
|
|
|
|
|
|
+ goods_name,
|
|
|
|
|
+ status
|
|
|
from psi_management_loss_detailed e
|
|
from psi_management_loss_detailed e
|
|
|
left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
WHERE f.`status` = 5 and e.del_flag = 0
|
|
WHERE f.`status` = 5 and e.del_flag = 0
|
|
|
- GROUP BY e.collect_type
|
|
|
|
|
|
|
+ GROUP BY e.goods_name
|
|
|
) loss
|
|
) loss
|
|
|
- on a.ware_house_type = loss.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = loss.goods_name
|
|
|
left join
|
|
left join
|
|
|
(
|
|
(
|
|
|
select
|
|
select
|
|
|
sum(returned_num) AS returned_num,
|
|
sum(returned_num) AS returned_num,
|
|
|
sum(not_surplus_stock) AS not_surplus_stock,
|
|
sum(not_surplus_stock) AS not_surplus_stock,
|
|
|
- collect_type
|
|
|
|
|
|
|
+ inventory_id,
|
|
|
|
|
+ goods_name,
|
|
|
|
|
+ status
|
|
|
from psi_management_collect_detailed_record e
|
|
from psi_management_collect_detailed_record e
|
|
|
left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
|
|
left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
|
|
|
WHERE pmcba.`status` = 5 and e.del_flag = 0
|
|
WHERE pmcba.`status` = 5 and e.del_flag = 0
|
|
|
- group BY e.collect_type
|
|
|
|
|
|
|
+ group BY e.goods_name
|
|
|
) pmcdra
|
|
) pmcdra
|
|
|
- on a.ware_house_type = pmcdra.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = pmcdra.goods_name
|
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
${ew.customSqlSegment}
|
|
${ew.customSqlSegment}
|
|
|
- GROUP BY a.ware_house_type
|
|
|
|
|
- HAVING SUM(CAST(IFNULL(NULLIF(a.current_inventory, ''), '0') AS DECIMAL(18,4))) > 0
|
|
|
|
|
|
|
+ GROUP BY a.trade_name,a.ware_house_type
|
|
|
ORDER BY a.ware_house_type DESC,a.trade_name
|
|
ORDER BY a.ware_house_type DESC,a.trade_name
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
@@ -163,12 +146,12 @@
|
|
|
a.create_by_id as createBy,
|
|
a.create_by_id as createBy,
|
|
|
a.create_time as createDate,
|
|
a.create_time as createDate,
|
|
|
a.ware_house_type,
|
|
a.ware_house_type,
|
|
|
- c.name as trade_name,
|
|
|
|
|
- c.company,
|
|
|
|
|
|
|
+ a.trade_name,
|
|
|
|
|
+ a.company,
|
|
|
c.name as wareHouseTypeName,
|
|
c.name as wareHouseTypeName,
|
|
|
IFNULL(his_detail.trade_number,0) AS allNumber,
|
|
IFNULL(his_detail.trade_number,0) AS allNumber,
|
|
|
- IFNULL(b.collect_number,0) AS borrowNumber,
|
|
|
|
|
- IFNULL(loss.loss_number,0) AS lossNumber,
|
|
|
|
|
|
|
+ b.collect_number AS borrowNumber,
|
|
|
|
|
+ loss.loss_number AS lossNumber,
|
|
|
IFNULL(loss_after.loss_number, 0) AS afterLossNumber,
|
|
IFNULL(loss_after.loss_number, 0) AS afterLossNumber,
|
|
|
IFNULL(after_pmwd.trade_number, 0) AS afterTradeNumber,
|
|
IFNULL(after_pmwd.trade_number, 0) AS afterTradeNumber,
|
|
|
IFNULL(after_pmcdra.not_surplus_stock, 0) AS afterNotSurplusStock,
|
|
IFNULL(after_pmcdra.not_surplus_stock, 0) AS afterNotSurplusStock,
|
|
@@ -187,32 +170,28 @@
|
|
|
left join
|
|
left join
|
|
|
(
|
|
(
|
|
|
select
|
|
select
|
|
|
- sum(
|
|
|
|
|
- CASE
|
|
|
|
|
- WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
|
|
|
|
|
- WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
|
|
|
|
|
- WHEN r.status = '5' AND d.is_return = '1' THEN 0
|
|
|
|
|
- ELSE IFNULL(e.not_surplus_stock, e.collect_number)
|
|
|
|
|
- END
|
|
|
|
|
- ) as collect_number,
|
|
|
|
|
- e.collect_type
|
|
|
|
|
- from psi_management_collect_detailed_record e
|
|
|
|
|
|
|
+ sum(collect_number) as collect_number,
|
|
|
|
|
+ goods_name,
|
|
|
|
|
+ collect_type,
|
|
|
|
|
+ status
|
|
|
|
|
+ from psi_management_collect_detailed e
|
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
- left join psi_management_collect_detailed d on e.detail_id = d.id
|
|
|
|
|
- left join psi_management_collect_basics_return r on r.basic_id = e.basic_id and r.del_flag = 0
|
|
|
|
|
WHERE f.`status` = 5
|
|
WHERE f.`status` = 5
|
|
|
and e.del_flag = 0
|
|
and e.del_flag = 0
|
|
|
|
|
+ and e.is_return = '0'
|
|
|
<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
|
and f.collect_date >= #{dto.dateRange[0]} AND f.collect_date <= #{dto.dateRange[1]}
|
|
and f.collect_date >= #{dto.dateRange[0]} AND f.collect_date <= #{dto.dateRange[1]}
|
|
|
</if>
|
|
</if>
|
|
|
- GROUP BY e.collect_type
|
|
|
|
|
|
|
+ GROUP BY e.goods_name, e.collect_type
|
|
|
) b
|
|
) b
|
|
|
- on a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = b.goods_name AND a.ware_house_type = b.collect_type
|
|
|
left join
|
|
left join
|
|
|
(
|
|
(
|
|
|
select
|
|
select
|
|
|
sum(loss_number) as loss_number,
|
|
sum(loss_number) as loss_number,
|
|
|
- collect_type
|
|
|
|
|
|
|
+ goods_name,
|
|
|
|
|
+ collect_type,
|
|
|
|
|
+ status
|
|
|
from psi_management_loss_detailed e
|
|
from psi_management_loss_detailed e
|
|
|
left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
WHERE f.`status` = 5
|
|
WHERE f.`status` = 5
|
|
@@ -220,13 +199,15 @@
|
|
|
<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
|
and f.collect_date >= #{dto.dateRange[0]} AND f.collect_date <= #{dto.dateRange[1]}
|
|
and f.collect_date >= #{dto.dateRange[0]} AND f.collect_date <= #{dto.dateRange[1]}
|
|
|
</if>
|
|
</if>
|
|
|
- GROUP BY e.collect_type
|
|
|
|
|
|
|
+ GROUP BY e.goods_name, e.collect_type
|
|
|
) loss
|
|
) loss
|
|
|
- on a.ware_house_type = loss.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = loss.goods_name AND a.ware_house_type = loss.collect_type
|
|
|
left join(
|
|
left join(
|
|
|
select
|
|
select
|
|
|
sum(loss_number) as loss_number,
|
|
sum(loss_number) as loss_number,
|
|
|
- collect_type
|
|
|
|
|
|
|
+ goods_name,
|
|
|
|
|
+ collect_type,
|
|
|
|
|
+ status
|
|
|
from psi_management_loss_detailed e
|
|
from psi_management_loss_detailed e
|
|
|
left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
WHERE f.`status` = 5
|
|
WHERE f.`status` = 5
|
|
@@ -234,14 +215,15 @@
|
|
|
<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
|
and f.collect_date >= #{dto.dateRange[1]}
|
|
and f.collect_date >= #{dto.dateRange[1]}
|
|
|
</if>
|
|
</if>
|
|
|
- GROUP BY e.collect_type
|
|
|
|
|
|
|
+ GROUP BY e.goods_name, e.collect_type
|
|
|
) loss_after
|
|
) loss_after
|
|
|
- on a.ware_house_type = loss_after.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = loss_after.goods_name AND a.ware_house_type = loss_after.collect_type
|
|
|
left join
|
|
left join
|
|
|
(
|
|
(
|
|
|
select
|
|
select
|
|
|
sum(returned_num) AS returned_num,
|
|
sum(returned_num) AS returned_num,
|
|
|
sum(not_surplus_stock) AS not_surplus_stock,
|
|
sum(not_surplus_stock) AS not_surplus_stock,
|
|
|
|
|
+ goods_name,
|
|
|
collect_type
|
|
collect_type
|
|
|
from psi_management_collect_detailed_record e
|
|
from psi_management_collect_detailed_record e
|
|
|
left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
|
|
left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
|
|
@@ -250,13 +232,14 @@
|
|
|
<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
|
and pmcba.collect_date >= #{dto.dateRange[0]} AND pmcba.collect_date <= #{dto.dateRange[1]}
|
|
and pmcba.collect_date >= #{dto.dateRange[0]} AND pmcba.collect_date <= #{dto.dateRange[1]}
|
|
|
</if>
|
|
</if>
|
|
|
- group BY e.collect_type
|
|
|
|
|
|
|
+ group BY e.goods_name, e.collect_type
|
|
|
) pmcdra
|
|
) pmcdra
|
|
|
- on a.ware_house_type = pmcdra.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = pmcdra.goods_name AND a.ware_house_type = pmcdra.collect_type
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
select
|
|
select
|
|
|
sum(returned_num) AS returned_num,
|
|
sum(returned_num) AS returned_num,
|
|
|
sum(not_surplus_stock) AS not_surplus_stock,
|
|
sum(not_surplus_stock) AS not_surplus_stock,
|
|
|
|
|
+ goods_name,
|
|
|
collect_type
|
|
collect_type
|
|
|
from psi_management_collect_detailed_record e
|
|
from psi_management_collect_detailed_record e
|
|
|
left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
|
|
left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
|
|
@@ -265,19 +248,21 @@
|
|
|
<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
|
and pmcba.collect_date >= #{dto.dateRange[1]}
|
|
and pmcba.collect_date >= #{dto.dateRange[1]}
|
|
|
</if>
|
|
</if>
|
|
|
- group BY e.collect_type
|
|
|
|
|
|
|
+ group BY e.goods_name, e.collect_type
|
|
|
) after_pmcdra
|
|
) after_pmcdra
|
|
|
- on a.ware_house_type = after_pmcdra.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = after_pmcdra.goods_name AND a.ware_house_type = after_pmcdra.collect_type
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
SELECT
|
|
|
|
|
+ trade_name,
|
|
|
ware_house_type,
|
|
ware_house_type,
|
|
|
SUM(current_inventory) AS allCurrentInventory
|
|
SUM(current_inventory) AS allCurrentInventory
|
|
|
FROM psi_management_warehouse_detailed
|
|
FROM psi_management_warehouse_detailed
|
|
|
WHERE del_flag = 0
|
|
WHERE del_flag = 0
|
|
|
- GROUP BY ware_house_type
|
|
|
|
|
- ) all_stock ON a.ware_house_type = all_stock.ware_house_type
|
|
|
|
|
|
|
+ GROUP BY trade_name, ware_house_type
|
|
|
|
|
+ ) all_stock ON a.trade_name = all_stock.trade_name AND a.ware_house_type = all_stock.ware_house_type
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
SELECT
|
|
|
|
|
+ pwd.trade_name,
|
|
|
pwd.ware_house_type,
|
|
pwd.ware_house_type,
|
|
|
SUM(pwd.trade_number) AS trade_number
|
|
SUM(pwd.trade_number) AS trade_number
|
|
|
FROM psi_management_warehouse_detailed pwd
|
|
FROM psi_management_warehouse_detailed pwd
|
|
@@ -286,10 +271,11 @@
|
|
|
<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
|
and pmcba.ware_house_date >= #{dto.dateRange[0]} AND pmcba.ware_house_date <= #{dto.dateRange[1]}
|
|
and pmcba.ware_house_date >= #{dto.dateRange[0]} AND pmcba.ware_house_date <= #{dto.dateRange[1]}
|
|
|
</if>
|
|
</if>
|
|
|
- GROUP BY pwd.ware_house_type
|
|
|
|
|
- ) his_detail ON a.ware_house_type = his_detail.ware_house_type
|
|
|
|
|
|
|
+ GROUP BY pwd.trade_name, pwd.ware_house_type
|
|
|
|
|
+ ) his_detail ON a.trade_name = his_detail.trade_name AND a.ware_house_type = his_detail.ware_house_type
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
SELECT
|
|
|
|
|
+ ab.trade_name,
|
|
|
ab.ware_house_type,
|
|
ab.ware_house_type,
|
|
|
SUM(ab.trade_number) AS trade_number
|
|
SUM(ab.trade_number) AS trade_number
|
|
|
FROM psi_management_warehouse_detailed ab
|
|
FROM psi_management_warehouse_detailed ab
|
|
@@ -298,13 +284,12 @@
|
|
|
<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
|
|
|
and pmcba.ware_house_date >= #{dto.dateRange[1]}
|
|
and pmcba.ware_house_date >= #{dto.dateRange[1]}
|
|
|
</if>
|
|
</if>
|
|
|
- GROUP BY ab.ware_house_type
|
|
|
|
|
- ) after_pmwd ON a.ware_house_type = after_pmwd.ware_house_type
|
|
|
|
|
|
|
+ GROUP BY ab.trade_name, ab.ware_house_type
|
|
|
|
|
+ ) after_pmwd ON a.trade_name = after_pmwd.trade_name AND a.ware_house_type = after_pmwd.ware_house_type
|
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
${ew.customSqlSegment}
|
|
${ew.customSqlSegment}
|
|
|
- GROUP BY a.ware_house_type
|
|
|
|
|
- HAVING SUM(CAST(IFNULL(NULLIF(all_stock.allCurrentInventory, ''), '0') AS DECIMAL(18,4))) > 0
|
|
|
|
|
|
|
+ GROUP BY a.trade_name,a.ware_house_type
|
|
|
ORDER BY a.ware_house_type DESC,a.trade_name
|
|
ORDER BY a.ware_house_type DESC,a.trade_name
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
@@ -316,7 +301,7 @@
|
|
|
a.create_by_id as createBy,
|
|
a.create_by_id as createBy,
|
|
|
a.create_time as createDate,
|
|
a.create_time as createDate,
|
|
|
a.ware_house_type,
|
|
a.ware_house_type,
|
|
|
- c.name as trade_name,
|
|
|
|
|
|
|
+ a.trade_name,
|
|
|
a.company,
|
|
a.company,
|
|
|
c.name as wareHouseTypeName,
|
|
c.name as wareHouseTypeName,
|
|
|
sum( trade_number ) AS allNumber,
|
|
sum( trade_number ) AS allNumber,
|
|
@@ -334,17 +319,18 @@
|
|
|
(
|
|
(
|
|
|
select
|
|
select
|
|
|
sum(collect_number) as collect_number,
|
|
sum(collect_number) as collect_number,
|
|
|
- collect_type
|
|
|
|
|
|
|
+ goods_name,
|
|
|
|
|
+ status
|
|
|
from psi_management_collect_detailed e
|
|
from psi_management_collect_detailed e
|
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
WHERE f.`status` = 5 and e.del_flag = 0
|
|
WHERE f.`status` = 5 and e.del_flag = 0
|
|
|
- GROUP BY e.collect_type
|
|
|
|
|
|
|
+ GROUP BY e.goods_name
|
|
|
) b
|
|
) b
|
|
|
- on a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ on a.trade_name = b.goods_name
|
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
${ew.customSqlSegment}
|
|
${ew.customSqlSegment}
|
|
|
- GROUP BY a.ware_house_type
|
|
|
|
|
|
|
+ GROUP BY a.trade_name,a.ware_house_type
|
|
|
ORDER BY a.ware_house_type DESC,a.trade_name
|
|
ORDER BY a.ware_house_type DESC,a.trade_name
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
@@ -353,32 +339,28 @@
|
|
|
SELECT
|
|
SELECT
|
|
|
a.id,
|
|
a.id,
|
|
|
a.produce_date as produce_date,
|
|
a.produce_date as produce_date,
|
|
|
- a.ware_house_type,
|
|
|
|
|
- c.name as trade_name,
|
|
|
|
|
|
|
+ a.trade_name,
|
|
|
a.spec,
|
|
a.spec,
|
|
|
- a.specification,
|
|
|
|
|
a.company,
|
|
a.company,
|
|
|
- a.brand,
|
|
|
|
|
a.current_inventory,
|
|
a.current_inventory,
|
|
|
- a.warn_num,
|
|
|
|
|
- a.warn_flag,
|
|
|
|
|
- bas.ware_house_number,
|
|
|
|
|
- bas.ware_house_date
|
|
|
|
|
|
|
+ pmwd.warn_num,
|
|
|
|
|
+ pmwd.warn_flag
|
|
|
FROM
|
|
FROM
|
|
|
psi_management_warehouse_detailed a
|
|
psi_management_warehouse_detailed a
|
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
|
|
|
+ LEFT JOIN psi_management_warehouse_detailed pmwd on bas.id = pmwd.basic_id
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
${ew.customSqlSegment}
|
|
${ew.customSqlSegment}
|
|
|
|
|
|
|
|
- GROUP BY a.id
|
|
|
|
|
- ORDER BY a.create_time asc
|
|
|
|
|
|
|
+ GROUP BY a.trade_name,a.ware_house_type,a.produce_date
|
|
|
|
|
+ ORDER BY a.produce_date asc
|
|
|
</select>
|
|
</select>
|
|
|
<select id="getAllData"
|
|
<select id="getAllData"
|
|
|
resultType="com.jeeplus.psimanage.psiWareHouse.service.dto.PsiWareHouseDto">
|
|
resultType="com.jeeplus.psimanage.psiWareHouse.service.dto.PsiWareHouseDto">
|
|
|
SELECT
|
|
SELECT
|
|
|
a.id,
|
|
a.id,
|
|
|
a.produce_date as produce_date,
|
|
a.produce_date as produce_date,
|
|
|
- c.name as trade_name,
|
|
|
|
|
|
|
+ a.trade_name,
|
|
|
a.spec,
|
|
a.spec,
|
|
|
a.company,
|
|
a.company,
|
|
|
a.current_inventory,
|
|
a.current_inventory,
|
|
@@ -393,7 +375,7 @@
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
${ew.customSqlSegment}
|
|
${ew.customSqlSegment}
|
|
|
|
|
|
|
|
- GROUP BY a.ware_house_type,a.produce_date
|
|
|
|
|
|
|
+ GROUP BY a.trade_name,a.ware_house_type,a.produce_date
|
|
|
ORDER BY a.produce_date asc
|
|
ORDER BY a.produce_date asc
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
@@ -424,7 +406,7 @@
|
|
|
a.ware_house_date,
|
|
a.ware_house_date,
|
|
|
sy.name as wareHouseHandledBy,
|
|
sy.name as wareHouseHandledBy,
|
|
|
so.name as wareHouseHandledByOff,
|
|
so.name as wareHouseHandledByOff,
|
|
|
- t.name as tradeName,
|
|
|
|
|
|
|
+ b.trade_name,
|
|
|
b.trade_number,
|
|
b.trade_number,
|
|
|
b.current_inventory,
|
|
b.current_inventory,
|
|
|
b.ware_house_type,
|
|
b.ware_house_type,
|
|
@@ -436,7 +418,6 @@
|
|
|
psi_management_warehouse_basics a
|
|
psi_management_warehouse_basics a
|
|
|
LEFT JOIN
|
|
LEFT JOIN
|
|
|
psi_management_warehouse_detailed b on a.id = b.basic_id and b.del_flag = 0
|
|
psi_management_warehouse_detailed b on a.id = b.basic_id and b.del_flag = 0
|
|
|
- LEFT JOIN psi_management_type t ON b.ware_house_type = t.id
|
|
|
|
|
|
|
|
|
|
left join sys_user sy on sy.id = a.handled_by
|
|
left join sys_user sy on sy.id = a.handled_by
|
|
|
left join sys_office so on sy.office_id = so.id
|
|
left join sys_office so on sy.office_id = so.id
|
|
@@ -453,9 +434,9 @@
|
|
|
sy.name as collectHandleBy,
|
|
sy.name as collectHandleBy,
|
|
|
so.name as collectHandleByOff,
|
|
so.name as collectHandleByOff,
|
|
|
a.collect_date,
|
|
a.collect_date,
|
|
|
|
|
+ b.goods_name,
|
|
|
b.collect_number,
|
|
b.collect_number,
|
|
|
- b.current_inventory as currentInventory,
|
|
|
|
|
- c.name AS goodsName,
|
|
|
|
|
|
|
+ b.current_inventory,
|
|
|
pmwd.spec,
|
|
pmwd.spec,
|
|
|
pmcdr.not_surplus_stock as notSurplusStock,
|
|
pmcdr.not_surplus_stock as notSurplusStock,
|
|
|
b.collect_type as collectType
|
|
b.collect_type as collectType
|
|
@@ -465,7 +446,6 @@
|
|
|
psi_management_collect_detailed b on a.id = b.basic_id and b.del_flag = 0
|
|
psi_management_collect_detailed b on a.id = b.basic_id and b.del_flag = 0
|
|
|
LEFT JOIN psi_management_collect_detailed_record pmcdr ON b.id = pmcdr.detail_id
|
|
LEFT JOIN psi_management_collect_detailed_record pmcdr ON b.id = pmcdr.detail_id
|
|
|
LEFT JOIN psi_management_warehouse_detailed pmwd ON pmcdr.inventory_id = pmwd.id
|
|
LEFT JOIN psi_management_warehouse_detailed pmwd ON pmcdr.inventory_id = pmwd.id
|
|
|
- LEFT JOIN psi_management_type c ON b.collect_type = c.id
|
|
|
|
|
left join sys_user sy on sy.id = a.handled_by
|
|
left join sys_user sy on sy.id = a.handled_by
|
|
|
left join sys_office so on sy.office_id = so.id
|
|
left join sys_office so on sy.office_id = so.id
|
|
|
|
|
|
|
@@ -484,22 +464,23 @@
|
|
|
c.name as wareHouseTypeName,
|
|
c.name as wareHouseTypeName,
|
|
|
sum(trade_number) as allNumber,
|
|
sum(trade_number) as allNumber,
|
|
|
b.collect_number as borrowNumber,
|
|
b.collect_number as borrowNumber,
|
|
|
- sum(a.current_inventory) as tradeNumber,
|
|
|
|
|
|
|
+ a.current_inventory as tradeNumber,
|
|
|
a.warn_num,
|
|
a.warn_num,
|
|
|
a.warn_flag
|
|
a.warn_flag
|
|
|
FROM
|
|
FROM
|
|
|
psi_management_warehouse_detailed a
|
|
psi_management_warehouse_detailed a
|
|
|
left join
|
|
left join
|
|
|
- (select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
|
|
|
|
|
|
|
+ (select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
|
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
|
|
WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
|
|
|
- GROUP BY e.collect_type) b
|
|
|
|
|
- on a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ GROUP BY e.goods_name) b
|
|
|
|
|
+ on a.trade_name = b.goods_name
|
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
- where a.ware_house_type = #{collectTypeId}
|
|
|
|
|
|
|
+ where a.trade_name = #{goodsName}
|
|
|
|
|
+ and a.ware_house_type = #{collectTypeId}
|
|
|
and a.del_flag = 0
|
|
and a.del_flag = 0
|
|
|
- GROUP BY a.ware_house_type
|
|
|
|
|
|
|
+ GROUP BY a.trade_name
|
|
|
ORDER BY a.update_time DESC
|
|
ORDER BY a.update_time DESC
|
|
|
</select>
|
|
</select>
|
|
|
<select id="getByTypeAndGoodsNameByProduceDate"
|
|
<select id="getByTypeAndGoodsNameByProduceDate"
|
|
@@ -518,18 +499,19 @@
|
|
|
FROM
|
|
FROM
|
|
|
psi_management_warehouse_detailed a
|
|
psi_management_warehouse_detailed a
|
|
|
left join
|
|
left join
|
|
|
- (select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
|
|
|
|
|
|
|
+ (select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
|
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
|
|
WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
|
|
|
- GROUP BY e.collect_type) b
|
|
|
|
|
- on a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ GROUP BY e.goods_name) b
|
|
|
|
|
+ on a.trade_name = b.goods_name
|
|
|
|
|
|
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
- where a.ware_house_type = #{collectTypeId}
|
|
|
|
|
|
|
+ where a.trade_name = #{goodsName}
|
|
|
|
|
+ and a.ware_house_type = #{collectTypeId}
|
|
|
and a.produce_date = #{produceDate}
|
|
and a.produce_date = #{produceDate}
|
|
|
and a.del_flag = 0
|
|
and a.del_flag = 0
|
|
|
- GROUP BY a.ware_house_type,a.produce_date
|
|
|
|
|
|
|
+ GROUP BY a.trade_name
|
|
|
ORDER BY a.produce_date asc
|
|
ORDER BY a.produce_date asc
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
@@ -548,14 +530,15 @@
|
|
|
FROM
|
|
FROM
|
|
|
psi_management_warehouse_detailed a
|
|
psi_management_warehouse_detailed a
|
|
|
left join
|
|
left join
|
|
|
- (select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
|
|
|
|
|
|
|
+ (select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
|
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
|
|
WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
|
|
|
- GROUP BY e.collect_type) b
|
|
|
|
|
- on a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ GROUP BY e.goods_name) b
|
|
|
|
|
+ on a.trade_name = b.goods_name
|
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
- where a.ware_house_type = #{collectTypeId}
|
|
|
|
|
|
|
+ where a.trade_name = #{goodsName}
|
|
|
|
|
+ and a.ware_house_type = #{collectTypeId}
|
|
|
and a.del_flag = 0
|
|
and a.del_flag = 0
|
|
|
ORDER BY a.produce_date asc
|
|
ORDER BY a.produce_date asc
|
|
|
</select>
|
|
</select>
|
|
@@ -584,36 +567,36 @@
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
|
|
|
|
|
left join
|
|
left join
|
|
|
- (select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
|
|
|
|
|
|
|
+ (select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
|
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
- WHERE f.`status` = 5 and e.del_flag = 0 and e.produce_date <= #{produceDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}
|
|
|
|
|
- GROUP BY e.collect_type) b
|
|
|
|
|
- on a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ WHERE f.`status` = 5 and e.del_flag = 0 and e.produce_date <= #{produceDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}) b
|
|
|
|
|
+ on a.trade_name = b.goods_name
|
|
|
|
|
|
|
|
WHERE a.ware_house_type = #{wareHouseType}
|
|
WHERE a.ware_house_type = #{wareHouseType}
|
|
|
and a.del_flag = 0
|
|
and a.del_flag = 0
|
|
|
|
|
+ and a.trade_name = #{tradeName}
|
|
|
and a.produce_date <= #{produceDate}
|
|
and a.produce_date <= #{produceDate}
|
|
|
- GROUP BY a.ware_house_type
|
|
|
|
|
|
|
+ GROUP BY a.trade_name,a.ware_house_type
|
|
|
ORDER BY a.ware_house_type DESC
|
|
ORDER BY a.ware_house_type DESC
|
|
|
</select>
|
|
</select>
|
|
|
<select id="getCollectInfoByTime" resultType="java.lang.String">
|
|
<select id="getCollectInfoByTime" resultType="java.lang.String">
|
|
|
SELECT
|
|
SELECT
|
|
|
- GREATEST( IFNULL(SUM(trade_number) - collect_number, SUM(trade_number)), 0 ) AS tradeNumber
|
|
|
|
|
|
|
+ IFNULL((sum(trade_number) - collect_number),sum(trade_number)) as tradeNumber
|
|
|
FROM
|
|
FROM
|
|
|
psi_management_warehouse_detailed a
|
|
psi_management_warehouse_detailed a
|
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
left join psi_management_type c on a.ware_house_type = c.id
|
|
|
|
|
|
|
|
left join
|
|
left join
|
|
|
- (select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
|
|
|
|
|
|
|
+ (select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
|
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
|
|
|
- WHERE f.`status` = 5 and e.del_flag = 0 and e.create_time <= #{createDate} and e.collect_type = #{wareHouseType}
|
|
|
|
|
- GROUP BY e.collect_type) b
|
|
|
|
|
- on a.ware_house_type = b.collect_type
|
|
|
|
|
|
|
+ WHERE f.`status` = 5 and e.del_flag = 0 and e.create_time <= #{createDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}) b
|
|
|
|
|
+ on a.trade_name = b.goods_name
|
|
|
|
|
|
|
|
WHERE a.ware_house_type = #{wareHouseType}
|
|
WHERE a.ware_house_type = #{wareHouseType}
|
|
|
and a.del_flag = 0
|
|
and a.del_flag = 0
|
|
|
|
|
+ and a.trade_name = #{tradeName}
|
|
|
and a.create_time <= #{createDate}
|
|
and a.create_time <= #{createDate}
|
|
|
- GROUP BY a.ware_house_type
|
|
|
|
|
|
|
+ GROUP BY a.trade_name,a.ware_house_type
|
|
|
ORDER BY a.ware_house_type DESC
|
|
ORDER BY a.ware_house_type DESC
|
|
|
</select>
|
|
</select>
|
|
|
<select id="getCollectNumByType" resultType="java.lang.String">
|
|
<select id="getCollectNumByType" resultType="java.lang.String">
|