Files
smart_management_dev/src/main/resources/mybatis/wisdom/RkStatisticsMapper.xml

117 lines
4.6 KiB
XML
Raw Normal View History

2025-08-26 17:01:43 +08:00
<?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="com.zg.project.wisdom.mapper.RkStatisticsMapper">
2026-02-02 08:06:58 +08:00
<!-- 当前入库类型统计 -->
<select id="statCurrentInByOperationType"
resultType="com.zg.project.wisdom.domain.vo.StockStatisticGroupVO">
2025-08-26 17:01:43 +08:00
SELECT
2026-02-02 08:06:58 +08:00
ri.operation_type AS groupValue,
IFNULL(SUM(ri.real_qty * ri.ht_dj), 0) AS totalAmount,
COUNT(DISTINCT ri.pcode) AS locationCount,
IFNULL(SUM(ri.real_qty), 0) AS totalQuantity,
COUNT(DISTINCT ri.xm_no) AS projectCount
2025-08-26 17:01:43 +08:00
FROM rk_info ri
2026-02-02 08:06:58 +08:00
WHERE ri.exec_status = 1
2025-08-26 17:01:43 +08:00
AND ri.is_chuku = 0
2026-02-02 08:06:58 +08:00
AND ri.is_delete = 0
GROUP BY ri.operation_type
2025-08-26 17:01:43 +08:00
</select>
2026-02-02 08:06:58 +08:00
<!-- 当前物资类型统计 -->
<select id="statCurrentByMaterialType"
resultType="com.zg.project.wisdom.domain.vo.StockStatisticGroupVO">
2025-08-26 17:01:43 +08:00
SELECT
2026-02-02 08:06:58 +08:00
ri.wl_type AS groupValue,
IFNULL(SUM(ri.real_qty * ri.ht_dj), 0) AS totalAmount,
COUNT(DISTINCT ri.pcode) AS locationCount,
IFNULL(SUM(ri.real_qty), 0) AS totalQuantity,
COUNT(DISTINCT ri.xm_no) AS projectCount
2025-08-26 17:01:43 +08:00
FROM rk_info ri
2026-02-02 08:06:58 +08:00
WHERE ri.exec_status = 1
2025-08-26 17:01:43 +08:00
AND ri.is_chuku = 0
2026-02-02 08:06:58 +08:00
AND ri.is_delete = 0
GROUP BY ri.wl_type
2025-08-26 17:01:43 +08:00
</select>
2026-02-02 08:06:58 +08:00
<!-- 入库类型统计(时间) -->
<select id="statInByOperationType"
resultType="com.zg.project.wisdom.domain.vo.StockStatisticGroupVO">
2025-08-26 17:01:43 +08:00
SELECT
2026-02-02 08:06:58 +08:00
ri.operation_type AS groupValue,
IFNULL(SUM(ri.real_qty * ri.ht_dj), 0) AS totalAmount,
COUNT(DISTINCT ri.pcode) AS locationCount,
IFNULL(SUM(ri.real_qty), 0) AS totalQuantity,
COUNT(DISTINCT ri.xm_no) AS projectCount
2025-08-26 17:01:43 +08:00
FROM rk_info ri
2026-02-02 08:06:58 +08:00
WHERE ri.exec_status = 1
2025-08-26 17:01:43 +08:00
AND ri.is_chuku = 0
2026-02-02 08:06:58 +08:00
AND ri.is_delete = 0
<if test="startDate != null">
AND ri.operation_time <![CDATA[>=]]> #{startDate}
</if>
<if test="endDate != null">
AND ri.operation_time <![CDATA[<=]]> #{endDate}
</if>
GROUP BY ri.operation_type
2025-08-26 17:01:43 +08:00
</select>
2026-02-02 08:06:58 +08:00
<!-- 出库类型统计(时间) -->
<select id="statOutByOperationType"
resultType="com.zg.project.wisdom.domain.vo.StockStatisticGroupVO">
2025-08-26 17:01:43 +08:00
SELECT
2026-02-02 08:06:58 +08:00
ri.operation_type AS groupValue,
IFNULL(SUM(ri.real_qty * ri.ht_dj), 0) AS totalAmount,
COUNT(DISTINCT ri.pcode) AS locationCount,
IFNULL(SUM(ri.real_qty), 0) AS totalQuantity,
COUNT(DISTINCT ri.xm_no) AS projectCount
2025-08-26 17:01:43 +08:00
FROM rk_info ri
2026-02-02 08:06:58 +08:00
WHERE ri.exec_status = 1
AND ri.is_chuku = 1
AND ri.is_delete = 0
<if test="startDate != null">
AND ri.operation_time <![CDATA[>=]]> #{startDate}
</if>
<if test="endDate != null">
AND ri.operation_time <![CDATA[<=]]> #{endDate}
</if>
GROUP BY ri.operation_type
2025-08-26 17:01:43 +08:00
</select>
2026-02-02 08:06:58 +08:00
<select id="statHomeKpi"
resultType="com.zg.project.wisdom.domain.vo.HomeKpiVO">
2025-08-26 17:01:43 +08:00
SELECT
2026-02-02 08:06:58 +08:00
/* 月入库 */
COUNT(CASE WHEN ri.is_chuku = 0
AND DATE_FORMAT(ri.operation_time,'%Y-%m') = DATE_FORMAT(CURDATE(),'%Y-%m')
THEN 1 END) AS monthInCount,
2025-08-26 17:01:43 +08:00
2026-02-02 08:06:58 +08:00
COUNT(DISTINCT CASE WHEN ri.is_chuku = 0
AND DATE_FORMAT(ri.operation_time,'%Y-%m') = DATE_FORMAT(CURDATE(),'%Y-%m')
THEN ri.xm_no END) AS monthInProjectCount,
2025-08-26 17:01:43 +08:00
2026-02-02 08:06:58 +08:00
IFNULL(SUM(CASE WHEN ri.is_chuku = 0
AND DATE_FORMAT(ri.operation_time,'%Y-%m') = DATE_FORMAT(CURDATE(),'%Y-%m')
THEN ri.real_qty * ri.ht_dj END),0) AS monthInAmount,
2025-08-26 17:01:43 +08:00
2026-02-02 08:06:58 +08:00
/* 月出库 */
COUNT(CASE WHEN ri.is_chuku = 1
AND DATE_FORMAT(ri.operation_time,'%Y-%m') = DATE_FORMAT(CURDATE(),'%Y-%m')
THEN 1 END) AS monthOutCount,
2025-08-26 17:01:43 +08:00
2026-02-02 08:06:58 +08:00
COUNT(DISTINCT CASE WHEN ri.is_chuku = 1
AND DATE_FORMAT(ri.operation_time,'%Y-%m') = DATE_FORMAT(CURDATE(),'%Y-%m')
THEN ri.xm_no END) AS monthOutProjectCount,
2025-08-26 17:01:43 +08:00
2026-02-02 08:06:58 +08:00
IFNULL(SUM(CASE WHEN ri.is_chuku = 1
AND DATE_FORMAT(ri.operation_time,'%Y-%m') = DATE_FORMAT(CURDATE(),'%Y-%m')
THEN ri.real_qty * ri.ht_dj END),0) AS monthOutAmount
2025-08-26 17:01:43 +08:00
FROM rk_info ri
2026-02-02 08:06:58 +08:00
WHERE ri.exec_status = 1
AND ri.is_delete = 0
2025-08-26 17:01:43 +08:00
</select>
2025-09-04 16:55:56 +08:00
2025-08-26 17:01:43 +08:00
</mapper>