|
|
@@ -32,7 +32,152 @@
|
|
|
|
|
|
<!-- 通用查询结果列 -->
|
|
|
<sql id="Base_Column_List">
|
|
|
- id, type, gas_name, level, size, bottle_code, gas_composition, college_id, college_name, subject_id, subject_name, room_num, beacon_tag, operator_id, operator, phone, valid_period, gas_pressure, create_name, create_by, create_time, update_name, update_by, update_time, remark
|
|
|
+ id
|
|
|
+ , type, gas_name, level, size, bottle_code, gas_composition, college_id, college_name, subject_id, subject_name, room_num, beacon_tag, operator_id, operator, phone, valid_period, gas_pressure, create_name, create_by, create_time, update_name, update_by, update_time, remark
|
|
|
</sql>
|
|
|
|
|
|
+ <select id="selectInOutListCount" parameterType="com.zd.airbottle.domain.bo.DbInOutRecordBo"
|
|
|
+ resultType="com.zd.airbottle.domain.vo.DbInOutRecordVo">
|
|
|
+ select x1.yearMonth,
|
|
|
+ CASE
|
|
|
+ WHEN substring(x1.yearMonth, 6) >= 10 THEN concat(SUBSTRING(x1.yearMonth, 6, 7), '月')
|
|
|
+ ELSE concat(substring(x1.yearMonth, 6), '月') END recordMonth,
|
|
|
+ IFNULL(sum(x2.count), 0) totalNum
|
|
|
+ from (
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-01') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-02') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-03') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-04') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-05') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-06') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-07') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-08') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-09') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-10') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-11') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ UNION ALL
|
|
|
+ SELECT CONCAT((SELECT YEAR (NOW())),'-12') yearMonth
|
|
|
+ FROM DUAL
|
|
|
+ ) x1
|
|
|
+ left join (
|
|
|
+ select DATE_FORMAT(a.create_time, '%Y-%m') yearMonth, a.type, count(1) count
|
|
|
+ from db_in_out_record a
|
|
|
+ where a.type=#{type}
|
|
|
+ <if test="gasName!=null and gasName!=''">
|
|
|
+ and a.gas_name=#{gasName}
|
|
|
+ </if>
|
|
|
+ GROUP BY DATE_FORMAT(a.create_time, '%Y-%m'), a.type
|
|
|
+ ) x2 on x1.yearMonth = x2.yearMonth
|
|
|
+ group by x1.yearMonth
|
|
|
+ order by x1.yearMonth
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectOutListCount" parameterType="com.zd.airbottle.domain.bo.DbInOutRecordBo"
|
|
|
+ resultType="com.zd.airbottle.domain.vo.DbInOutRecordVo">
|
|
|
+ select x1.yearMonth,
|
|
|
+ CASE
|
|
|
+ WHEN substring(x1.yearMonth, 6) >= 10 THEN concat(SUBSTRING(x1.yearMonth, 6, 7), '月')
|
|
|
+ ELSE concat(substring(x1.yearMonth, 6), '月') END recordMonth,
|
|
|
+ IFNULL(sum(x2.count), 0) totalNum
|
|
|
+ from (
|
|
|
+ select date_format(curdate(), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 1 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 2 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 3 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 4 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 5 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 6 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 7 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 8 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 9 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 10 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 11 month), '%Y-%m') AS `yearMonth`) x1
|
|
|
+ left join (
|
|
|
+ select DATE_FORMAT(a.create_time, '%Y-%m') yearMonth, a.type, count(1) count
|
|
|
+ from db_in_out_record a
|
|
|
+ where a.type=2
|
|
|
+ <if test="gasName!=null and gasName!=''">
|
|
|
+ and a.gas_name=#{gasName}
|
|
|
+ </if>
|
|
|
+ GROUP BY DATE_FORMAT(a.create_time, '%Y-%m'), a.type
|
|
|
+ ) x2 on x1.yearMonth = x2.yearMonth
|
|
|
+ group by x1.yearMonth
|
|
|
+ order by x1.yearMonth
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectApplyListCount" parameterType="com.zd.airbottle.domain.bo.DbInOutRecordBo"
|
|
|
+ resultType="com.zd.airbottle.domain.vo.DbInOutRecordVo">
|
|
|
+ select x1.yearMonth,
|
|
|
+ CASE
|
|
|
+ WHEN substring(x1.yearMonth, 6) >= 10 THEN concat(SUBSTRING(x1.yearMonth, 6, 7), '月')
|
|
|
+ ELSE concat(substring(x1.yearMonth, 6), '月') END recordMonth,
|
|
|
+ IFNULL(sum(x2.count), 0) totalNum
|
|
|
+ from (
|
|
|
+ select date_format(curdate(), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 1 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 2 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 3 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 4 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 5 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 6 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 7 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 8 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 9 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 10 month), '%Y-%m') AS `yearMonth`
|
|
|
+ union
|
|
|
+ select date_format((curdate() - interval 11 month), '%Y-%m') AS `yearMonth`) x1
|
|
|
+ left join (
|
|
|
+ select DATE_FORMAT(a.create_time,'%Y-%m') yearMonth ,sum(a.usage_amount) count from db_usage_record a
|
|
|
+ <where>
|
|
|
+ <if test="gasName!=null and gasName!=''">
|
|
|
+ and a.gas_name=#{gasName}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY DATE_FORMAT(a.create_time, '%Y-%m')
|
|
|
+ ) x2 on x1.yearMonth = x2.yearMonth
|
|
|
+ group by x1.yearMonth
|
|
|
+ order by x1.yearMonth
|
|
|
+ </select>
|
|
|
</mapper>
|