Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

116 рядки
6.1 KiB

  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.iformall.mapper.WxEnergyMeterReadingMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxEnergyMeterReading">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  9. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  10. <result column="cur_number" jdbcType="VARCHAR" property="curNumber"/>
  11. <result column="pre_number" jdbcType="VARCHAR" property="preNumber"/>
  12. <result column="pre_time" jdbcType="TIMESTAMP" property="preTime"/>
  13. <result column="pre_by" jdbcType="BIGINT" property="preBy"/>
  14. <result column="pre_by_name" jdbcType="VARCHAR" property="preByName"/>
  15. <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
  16. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  17. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  18. <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
  19. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  20. <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
  21. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  22. <result column="time_id" jdbcType="BIGINT" property="timeId"/>
  23. <result column="meter_id" jdbcType="BIGINT" property="meterId"/>
  24. <result column="meter_type" jdbcType="INTEGER" property="meterType"/>
  25. <result column="meter_rate" jdbcType="VARCHAR" property="meterRate"/>
  26. <result column="is_public" jdbcType="INTEGER" property="isPublic"/>
  27. <result column="meter_name" jdbcType="VARCHAR" property="meterName"/>
  28. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  29. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
  30. <result column="building_id" jdbcType="BIGINT" property="buildingId"/>
  31. <result column="floor_id" jdbcType="BIGINT" property="floorId"/>
  32. <result column="price" jdbcType="VARCHAR" property="price"/>
  33. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  34. </resultMap>
  35. <sql id="allColumns">
  36. `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`cur_number`,`pre_number`,`pre_time`,`pre_by`,`pre_by_name`,`start_time`,`end_time`,`create_by`,`create_by_name`,
  37. `update_by`,`update_by_name`,`remark`,`time_id`,`meter_id`,`meter_type`,`meter_rate`,`is_public`,`meter_name`,`shop_id`,`shop_number`,`building_id`,`floor_id`,`price`,`is_del`
  38. </sql>
  39. <sql id="dynamicWhereConditions">
  40. where 1=1
  41. <if test=" null != id ">and `id` = #{id}</if>
  42. <if test=" null != tenantId and '' != tenantId">
  43. and `tenant_id` = #{tenantId}
  44. </if>
  45. <if test=" null != parentTenantId and '' != parentTenantId">
  46. and `parent_tenant_id` = #{parentTenantId}
  47. </if>
  48. <if test=" null != createBy ">and `create_by` = #{createBy}</if>
  49. <if test=" null != timeId ">and `time_id` = #{timeId}</if>
  50. <if test=" null != meterId ">and `meter_id` = #{meterId}</if>
  51. <if test=" null != meterType ">and `meter_type` = #{meterType}</if>
  52. <if test=" null != isPublic ">and `is_public` = #{isPublic}</if>
  53. <if test=" null != meterName and '' != meterName ">and meter_name like concat('%', #{meterName},'%')</if>
  54. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  55. <if test=" null != shopNumber and '' != shopNumber ">and shop_number like concat('%', #{shopNumber},'%')</if>
  56. <if test=" null != buildingId ">and `building_id` = #{buildingId}</if>
  57. <if test=" null != floorId ">and `floor_id` = #{floorId}</if>
  58. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  59. <if test=" null != createByName and '' != createByName ">and create_by_name like concat('%', #{createByName},'%')</if>
  60. <if test=" null != shopIds ">
  61. and shop_id in
  62. <foreach collection="shopIds" index="index" item="sidItem" open="(" separator="," close=")">
  63. #{sidItem}
  64. </foreach>
  65. </if>
  66. <if test=" null != ids ">
  67. and id in
  68. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  69. #{idItem}
  70. </foreach>
  71. </if>
  72. <if test=" null != sortColumns">order by ${sortColumns}</if>
  73. </sql>
  74. <select id="findList" parameterType="com.iformall.domain.po.WxEnergyMeterReading" resultMap="BaseResultMap">
  75. select
  76. <include refid="allColumns"/>
  77. from wx_energy_meter_reading
  78. <include refid="dynamicWhereConditions"/>
  79. </select>
  80. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  81. select
  82. <include refid="allColumns"/>
  83. from wx_energy_meter_reading where id = #{id} and `tenant_id` = #{tenantId}
  84. </select>
  85. <select id="findAllSumMoney" parameterType="com.iformall.domain.po.WxEnergyMeterReading" resultType="string">
  86. select sum((CAST(cur_number AS DECIMAL(20,4)) - CAST(pre_number AS DECIMAL(20,4)))*(CAST(price AS DECIMAL(20,4))) / (CAST(meter_rate AS DECIMAL(20,4)))) as money
  87. from wx_energy_meter_reading
  88. <include refid="dynamicWhereConditions"/>
  89. </select>
  90. <select id="findBuildingSumMoney" parameterType="com.iformall.domain.po.WxEnergyMeterReading" resultType="hashmap">
  91. select building_id, sum((CAST(cur_number AS DECIMAL(20,4)) - CAST(pre_number AS DECIMAL(20,4)))*(CAST(price AS DECIMAL(20,4))) / (CAST(meter_rate AS DECIMAL(20,4)))) as money
  92. from wx_energy_meter_reading
  93. <include refid="dynamicWhereConditions"/>
  94. group by building_id
  95. </select>
  96. <select id="findFloorSumMoney" parameterType="com.iformall.domain.po.WxEnergyMeterReading" resultType="hashmap">
  97. select floor_id, sum((CAST(cur_number AS DECIMAL(20,4)) - CAST(pre_number AS DECIMAL(20,4)))*(CAST(price AS DECIMAL(20,4))) / (CAST(meter_rate AS DECIMAL(20,4)))) as money
  98. from wx_energy_meter_reading
  99. <include refid="dynamicWhereConditions"/>
  100. group by floor_id
  101. </select>
  102. <update id = "setIsDel" parameterType="HashMap">
  103. update wx_energy_meter_reading set is_del = #{isDel} where id = #{id} and `tenant_id` = #{tenantId}
  104. </update>
  105. </mapper>