|
|
@ -9,55 +9,82 @@ |
|
|
|
<select id="queryAll" resultType="org.nl.wms.sch.data.service.dto.MaterialDataResponse"> |
|
|
|
SELECT |
|
|
|
supplierCode, |
|
|
|
MAX(md.supplierName) AS supplierName, |
|
|
|
MAX( md.supplierName ) AS supplierName, |
|
|
|
productName, |
|
|
|
specification, |
|
|
|
MAX(batch) AS batch, |
|
|
|
MAX(barLevel) AS barLevel, |
|
|
|
DATE_FORMAT(md.createTime, '%Y-%m-%d') AS date, |
|
|
|
COALESCE(SUM(CASE WHEN md.type = 1 THEN md.length ELSE 0 END), 0) AS ll_length, |
|
|
|
COALESCE(SUM(CASE WHEN md.type = 1 THEN md.weight ELSE 0 END), 0) AS ll_weight, |
|
|
|
COALESCE(SUM(CASE WHEN md.type = 2 THEN md.length ELSE 0 END), 0) AS sc_length, |
|
|
|
COALESCE(SUM(CASE WHEN md.type = 2 THEN md.weight ELSE 0 END), 0) AS sc_weight, |
|
|
|
COALESCE( |
|
|
|
(SELECT |
|
|
|
SUM(CASE WHEN type = 1 THEN length ELSE 0 END) - SUM(CASE WHEN type = 2 THEN length ELSE 0 END) |
|
|
|
FROM material_data |
|
|
|
MAX( batch ) AS batch, |
|
|
|
MAX( barLevel ) AS barLevel, |
|
|
|
DATE_FORMAT( md.createTime, '%Y-%m-%d' ) AS date, |
|
|
|
COALESCE ( SUM( CASE WHEN md.type = 1 THEN md.length ELSE 0 END ), 0 ) AS ll_length, |
|
|
|
COALESCE ( SUM( CASE WHEN md.type = 1 THEN md.weight ELSE 0 END ), 0 ) AS ll_weight, |
|
|
|
COALESCE ( SUM( CASE WHEN md.type = 2 THEN md.length ELSE 0 END ), 0 ) AS sc_length, |
|
|
|
COALESCE ( SUM( CASE WHEN md.type = 2 THEN md.weight ELSE 0 END ), 0 ) AS sc_weight, |
|
|
|
COALESCE ( |
|
|
|
( |
|
|
|
SELECT |
|
|
|
SUM( CASE WHEN type = 1 THEN length ELSE 0 END ) - SUM( CASE WHEN type = 2 THEN length ELSE 0 END ) |
|
|
|
FROM |
|
|
|
material_data |
|
|
|
WHERE |
|
|
|
supplierCode = md.supplierCode AND |
|
|
|
createTime <![CDATA[ < ]]> DATE_FORMAT(DATE_SUB(CONCAT(YEAR(#{query.start_time}), '-', MONTH(#{query.start_time}), '-01'), INTERVAL 1 DAY), '%Y-%m-%d') |
|
|
|
), 0) AS sy_length, |
|
|
|
COALESCE( |
|
|
|
(SELECT |
|
|
|
SUM(CASE WHEN type = 1 THEN weight ELSE 0 END) - SUM(CASE WHEN type = 2 THEN weight ELSE 0 END) |
|
|
|
FROM material_data |
|
|
|
supplierCode = md.supplierCode |
|
|
|
AND productName = md.productName |
|
|
|
AND specification = md.specification |
|
|
|
AND createTime like CONCAT(DATE_FORMAT(DATE_SUB( #{query.start_time}, INTERVAL 1 DAY ), '%Y-%m-%d') , '%') |
|
|
|
), |
|
|
|
0 |
|
|
|
) AS sy_length, |
|
|
|
COALESCE ( |
|
|
|
( |
|
|
|
SELECT |
|
|
|
SUM( CASE WHEN type = 1 THEN weight ELSE 0 END ) - SUM( CASE WHEN type = 2 THEN weight ELSE 0 END ) |
|
|
|
FROM |
|
|
|
material_data |
|
|
|
WHERE |
|
|
|
supplierCode = md.supplierCode AND |
|
|
|
createTime <![CDATA[ < ]]> DATE_FORMAT(DATE_SUB(CONCAT(YEAR(#{query.start_time}), '-', DAY(#{query.start_time}), '-01'), INTERVAL 1 DAY), '%Y-%m-%d') |
|
|
|
), 0) AS sy_weight, |
|
|
|
COALESCE( |
|
|
|
(SELECT |
|
|
|
SUM(CASE WHEN type = 1 THEN length ELSE 0 END) - SUM(CASE WHEN type = 2 THEN length ELSE 0 END) |
|
|
|
FROM material_data |
|
|
|
supplierCode = md.supplierCode |
|
|
|
AND productName = md.productName |
|
|
|
AND specification = md.specification |
|
|
|
AND createTime like CONCAT(DATE_FORMAT(DATE_SUB( #{query.start_time}, INTERVAL 1 DAY ), '%Y-%m-%d') , '%') |
|
|
|
), |
|
|
|
0 |
|
|
|
) AS sy_weight, |
|
|
|
COALESCE ( |
|
|
|
( |
|
|
|
SELECT |
|
|
|
SUM( CASE WHEN type = 1 THEN length ELSE 0 END ) - SUM( CASE WHEN type = 2 THEN length ELSE 0 END ) |
|
|
|
FROM |
|
|
|
material_data |
|
|
|
WHERE |
|
|
|
supplierCode = md.supplierCode and productName = md.productName and specification = md.specification |
|
|
|
), 0) AS jc_length, |
|
|
|
COALESCE( |
|
|
|
(SELECT |
|
|
|
SUM(CASE WHEN type = 1 THEN weight ELSE 0 END) - SUM(CASE WHEN type = 2 THEN weight ELSE 0 END) |
|
|
|
FROM material_data |
|
|
|
supplierCode = md.supplierCode |
|
|
|
AND productName = md.productName |
|
|
|
AND specification = md.specification |
|
|
|
), |
|
|
|
0 |
|
|
|
) AS jc_length, |
|
|
|
COALESCE ( |
|
|
|
( |
|
|
|
SELECT |
|
|
|
SUM( CASE WHEN type = 1 THEN weight ELSE 0 END ) - SUM( CASE WHEN type = 2 THEN weight ELSE 0 END ) |
|
|
|
FROM |
|
|
|
material_data |
|
|
|
WHERE |
|
|
|
supplierCode = md.supplierCode and productName =md.productName and specification = md.specification |
|
|
|
), 0) AS jc_weight |
|
|
|
supplierCode = md.supplierCode |
|
|
|
AND productName = md.productName |
|
|
|
AND specification = md.specification |
|
|
|
), |
|
|
|
0 |
|
|
|
) AS jc_weight |
|
|
|
FROM |
|
|
|
material_data md |
|
|
|
WHERE |
|
|
|
DATE_FORMAT(md.createTime, '%Y-%m-%d') = DATE_FORMAT(#{query.start_time}, '%Y-%m-%d') |
|
|
|
DATE_FORMAT( md.createTime, '%Y-%m-%d' ) = DATE_FORMAT( #{query.start_time}, '%Y-%m-%d' ) |
|
|
|
GROUP BY |
|
|
|
md.productName,md.specification,supplierCode, DATE_FORMAT(md.createTime, '%Y-%m-%d') |
|
|
|
md.productName, |
|
|
|
md.specification, |
|
|
|
supplierCode, |
|
|
|
DATE_FORMAT( md.createTime, '%Y-%m-%d' ) |
|
|
|
ORDER BY |
|
|
|
md.supplierCode, md.productName |
|
|
|
|
|
|
|
md.supplierCode, |
|
|
|
md.productName |
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|