psh
8 months ago
9 changed files with 136 additions and 18 deletions
@ -0,0 +1,64 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="org.nl.wms.sch.data.service.dao.mapper.MaterialDataMapper"> |
|||
|
|||
<select id="set"> |
|||
SET SESSION sql_mode = (SELECT REPLACE(@@SESSION.sql_mode, 'ONLY_FULL_GROUP_BY', '')); |
|||
</select> |
|||
|
|||
<select id="queryAll" resultType="org.nl.wms.sch.data.service.dto.MaterialDataResponse"> |
|||
SELECT |
|||
supplierCode, |
|||
MAX(md.supplierName) AS supplierName, |
|||
productName, |
|||
specification, |
|||
MAX(batch) AS batch, |
|||
MAX(barLevel) AS barLevel, |
|||
DATE_FORMAT(md.createTime, '%Y-%m') 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 |
|||
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_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 |
|||
WHERE |
|||
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') = DATE_FORMAT(#{query.start_time}, '%Y-%m') |
|||
GROUP BY |
|||
md.productName,md.specification,supplierCode, DATE_FORMAT(md.createTime, '%Y-%m') |
|||
ORDER BY |
|||
md.supplierCode, md.productName |
|||
|
|||
|
|||
</select> |
|||
|
|||
</mapper> |
@ -0,0 +1,23 @@ |
|||
package org.nl.wms.sch.data.service.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
import java.sql.Timestamp; |
|||
|
|||
/** |
|||
* @description / |
|||
* @author psh |
|||
* @date 2024-05-17 |
|||
**/ |
|||
@Data |
|||
public class MaterialDataRequest implements Serializable { |
|||
|
|||
/** 客户编码 */ |
|||
private String start_time; |
|||
|
|||
/** 客户名称 */ |
|||
private String end_time; |
|||
|
|||
} |
Loading…
Reference in new issue