DeviceCostMapper.xml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.management.platform.mapper.DeviceCostMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.DeviceCost">
  6. <id column="id" property="id" />
  7. <result column="device_id" property="deviceId" />
  8. <result column="month_cost" property="monthCost" />
  9. <result column="ymonth" property="ymonth" />
  10. </resultMap>
  11. <!-- 通用查询结果列 -->
  12. <sql id="Base_Column_List">
  13. id, device_id, month_cost, ymonth
  14. </sql>
  15. <select id="getDeviceCostList" resultType="java.util.HashMap">
  16. select d.device_code deviceCode,d.device_name deviceName,
  17. d.device_model deviceModel, d.manufacturer,dc.ymonth ,dc.id,dc.month_cost monthCost
  18. from device d
  19. inner JOIN device_cost dc on d.id=dc.device_id
  20. <where>
  21. <if test="companyId !=null">
  22. and d.company_id=#{companyId}
  23. </if>
  24. <if test="deviceCost.deviceCode!=null and deviceCost.deviceCode!='' ">
  25. and d.device_code like CONCAT('%', #{deviceCost.deviceCode}, '%')
  26. </if>
  27. <if test="deviceCost.ymonth!=null and deviceCost.ymonth!='' ">
  28. and dc.ymonth= #{deviceCost.ymonth}
  29. </if>
  30. </where>
  31. <if test="deviceCost.pageIndex!=null and deviceCost.pageSize!=null">
  32. limit #{deviceCost.pageIndex},#{deviceCost.pageSize}
  33. </if>
  34. </select>
  35. <select id="getDeviceCostTotal" resultType="java.lang.Integer">
  36. select count(*) total
  37. from device d
  38. inner JOIN device_cost dc on d.id=dc.device_id
  39. <where>
  40. <if test="companyId !=null">
  41. and d.company_id=#{companyId}
  42. </if>
  43. <if test="deviceCost.deviceCode!=null and deviceCost.deviceCode!='' ">
  44. and d.device_code like CONCAT('%', #{deviceCost.deviceCode}, '%')
  45. </if>
  46. <if test="deviceCost.ymonth!=null and deviceCost.ymonth!='' ">
  47. and dc.ymonth= #{deviceCost.ymonth}
  48. </if>
  49. </where>
  50. </select>
  51. </mapper>