src/main/java/com/yssh/mapper/XlsReportMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/service/XlsReportService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/XlsReportMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/yssh/mapper/XlsReportMapper.java
@@ -13,9 +13,33 @@ */ @Mapper public interface XlsReportMapper { List<XlsReport> selectByPage(@Param("type") String type, @Param("start") String start, @Param("end") String end, @Param("limit") Integer limit, @Param("offset") Integer offset); /** * 分页查询报告 */ List<XlsReport> selectReportByPage(@Param("type") String type, @Param("start") String start, @Param("end") String end, @Param("limit") Integer limit, @Param("offset") Integer offset); int xlsExists(@Param("type") String type, @Param("start") String start); /** * 报告是否存在 */ int reportExists(@Param("type") String type, @Param("start") String start); int insert(XlsReport xls); /** * 插入报告 */ int insertReport(XlsReport xls); /** * 查询日均值 */ double selectDayAvg(@Param("time") String time, @Param("name") String name); /** * 查询累计值 */ double selectAccumulate(@Param("start") Integer start, @Param("end") Integer end, @Param("name") String name); /** * 查询年累计值 */ double selectYearAccumulate(@Param("time") String time, @Param("name") String name); } src/main/java/com/yssh/service/XlsReportService.java
@@ -51,7 +51,7 @@ * Excel是否已存在 */ private boolean xlsExists(String type, String name) { int rows = mapper.xlsExists(type, name); int rows = mapper.reportExists(type, name); return rows > 0; } src/main/resources/mapper/XlsReportMapper.xml
@@ -1,7 +1,8 @@ <?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.yssh.mapper.QxshMapper"> <select id="selectByPage" resultType="com.yssh.entity.xls.XlsReport"> <!-- 分页查询报告 --> <select id="selectReportByPage" resultType="com.yssh.entity.xls.XlsReport"> select * from xls_report <where> @@ -20,16 +21,46 @@ limit #{limit} offset #{offset} </select> <select id="xlsExists" resultType="java.lang.Integer"> <!-- 报告是否存在 --> <select id="reportExists" resultType="java.lang.Integer"> select count(*) from xls_report where type = #{type} and name = #{name} </select> <insert id="insert" parameterType="com.yssh.entity.xls.XlsReport"> <!-- 插入报告 --> <insert id="insertReport" parameterType="com.yssh.entity.xls.XlsReport"> insert into xls_report (name, type, path, create_time) values (#{name}, #{type}, #{path}, #{createTime}) </insert> <!-- 查询日均值 --> <select id="selectDayAvg" resultType="java.lang.Double"> select format(avg(value), 2) from yssh_qxsh where time like #{time} and name = #{name}; </select> <!-- 查询日均值 --> <select id="selectDayAvg" resultType="java.lang.Double"> select format(avg(value), 2) from yssh_qxsh where time like #{time} and name = #{name}; </select> <!-- 查询累计值 --> <select id="selectAccumulate" resultType="java.lang.Double"> select format(avg(value), 2) from yssh_qxsh where time between #{start} and #{end} and name = #{name}; </select> <!-- 查询年累计值 --> <select id="selectYearAccumulate" resultType="java.lang.Double"> select format(avg(value), 2) from yssh_qxsh where time like #{time} and name = #{name}; </select> </mapper>