123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- <?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.bz.smart_city.dao.WaterMeterReplaceLogMapper">
- <!--auto generated Code-->
- <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.WaterMeterReplaceLog">
- <!--@mbg.generated-->
- <!--@Table sc_water_meter_replace_log-->
- <id column="id" property="id" />
- <result column="site_id" property="siteId" />
- <result column="main_log_id" property="mainLogId" />
- <result column="device_id" property="deviceId" />
- <result column="replace_method" property="replaceMethod" />
- <result column="new_device_type_id" property="newDeviceTypeId" />
- <result column="old_device_type_id" property="oldDeviceTypeId" />
- <result column="new_water_no" property="newWaterNo" />
- <result column="old_water_no" property="oldWaterNo" />
- <result column="new_begin_wsv" property="newBeginWsv" />
- <result column="old_end_wsv" property="oldEndWsv" />
- <result column="new_device_no" property="newDeviceNo" />
- <result column="old_device_no" property="oldDeviceNo" />
- <result column="new_sim_no" property="newSimNo" />
- <result column="old_sim_no" property="oldSimNo" />
- <result column="new_device_flag_no" property="newDeviceFlagNo" />
- <result column="old_device_flag_no" property="oldDeviceFlagNo" />
- <result column="remark" property="remark" />
- <result column="status" property="status" />
- <result column="replace_username" property="replaceUsername" />
- <result column="replace_user_phone" property="replaceUserPhone" />
- <result column="date_create" property="dateCreate" />
- <result column="date_update" property="dateUpdate" />
- <result column="create_by" property="createBy" />
- <result column="update_by" property="updateBy" />
- </resultMap>
- <sql id="Base_Column_List">
- <!--@mbg.generated-->
- id, site_id, main_log_id, device_id, replace_method, new_device_type_id, old_device_type_id,
- new_water_no, old_water_no, new_begin_wsv, old_end_wsv, new_device_no, old_device_no,
- new_sim_no, old_sim_no, new_device_flag_no, old_device_flag_no, remark, `status`,
- replace_username, replace_user_phone, date_create, date_update, create_by, update_by
- </sql>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.WaterMeterReplaceLog" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into sc_water_meter_replace_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="siteId != null">
- site_id,
- </if>
- <if test="mainLogId != null">
- main_log_id,
- </if>
- <if test="deviceId != null">
- device_id,
- </if>
- <if test="replaceMethod != null">
- replace_method,
- </if>
- <if test="newDeviceTypeId != null">
- new_device_type_id,
- </if>
- <if test="oldDeviceTypeId != null">
- old_device_type_id,
- </if>
- <if test="newWaterNo != null">
- new_water_no,
- </if>
- <if test="oldWaterNo != null">
- old_water_no,
- </if>
- <if test="newBeginWsv != null">
- new_begin_wsv,
- </if>
- <if test="oldEndWsv != null">
- old_end_wsv,
- </if>
- <if test="newDeviceNo != null">
- new_device_no,
- </if>
- <if test="oldDeviceNo != null">
- old_device_no,
- </if>
- <if test="newSimNo != null">
- new_sim_no,
- </if>
- <if test="oldSimNo != null">
- old_sim_no,
- </if>
- <if test="newDeviceFlagNo != null">
- new_device_flag_no,
- </if>
- <if test="oldDeviceFlagNo != null">
- old_device_flag_no,
- </if>
- <if test="remark != null">
- remark,
- </if>
- <if test="status != null">
- `status`,
- </if>
- <if test="replaceUsername != null">
- replace_username,
- </if>
- <if test="replaceUserPhone != null">
- replace_user_phone,
- </if>
- <if test="dateCreate != null">
- date_create,
- </if>
- <if test="dateUpdate != null">
- date_update,
- </if>
- <if test="createBy != null">
- create_by,
- </if>
- <if test="updateBy != null">
- update_by,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="siteId != null">
- #{siteId},
- </if>
- <if test="mainLogId != null">
- #{mainLogId},
- </if>
- <if test="deviceId != null">
- #{deviceId},
- </if>
- <if test="replaceMethod != null">
- #{replaceMethod},
- </if>
- <if test="newDeviceTypeId != null">
- #{newDeviceTypeId},
- </if>
- <if test="oldDeviceTypeId != null">
- #{oldDeviceTypeId},
- </if>
- <if test="newWaterNo != null">
- #{newWaterNo},
- </if>
- <if test="oldWaterNo != null">
- #{oldWaterNo},
- </if>
- <if test="newBeginWsv != null">
- #{newBeginWsv},
- </if>
- <if test="oldEndWsv != null">
- #{oldEndWsv},
- </if>
- <if test="newDeviceNo != null">
- #{newDeviceNo},
- </if>
- <if test="oldDeviceNo != null">
- #{oldDeviceNo},
- </if>
- <if test="newSimNo != null">
- #{newSimNo},
- </if>
- <if test="oldSimNo != null">
- #{oldSimNo},
- </if>
- <if test="newDeviceFlagNo != null">
- #{newDeviceFlagNo},
- </if>
- <if test="oldDeviceFlagNo != null">
- #{oldDeviceFlagNo},
- </if>
- <if test="remark != null">
- #{remark},
- </if>
- <if test="status != null">
- #{status},
- </if>
- <if test="replaceUsername != null">
- #{replaceUsername},
- </if>
- <if test="replaceUserPhone != null">
- #{replaceUserPhone},
- </if>
- <if test="dateCreate != null">
- #{dateCreate},
- </if>
- <if test="dateUpdate != null">
- #{dateUpdate},
- </if>
- <if test="createBy != null">
- #{createBy},
- </if>
- <if test="updateBy != null">
- #{updateBy},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.WaterMeterReplaceLog">
- <!--@mbg.generated-->
- update sc_water_meter_replace_log
- <set>
- <if test="siteId != null">
- site_id = #{siteId},
- </if>
- <if test="mainLogId != null">
- main_log_id = #{mainLogId},
- </if>
- <if test="deviceId != null">
- device_id = #{deviceId},
- </if>
- <if test="replaceMethod != null">
- replace_method = #{replaceMethod},
- </if>
- <if test="newDeviceTypeId != null">
- new_device_type_id = #{newDeviceTypeId},
- </if>
- <if test="oldDeviceTypeId != null">
- old_device_type_id = #{oldDeviceTypeId},
- </if>
- <if test="newWaterNo != null">
- new_water_no = #{newWaterNo},
- </if>
- <if test="oldWaterNo != null">
- old_water_no = #{oldWaterNo},
- </if>
- <if test="newBeginWsv != null">
- new_begin_wsv = #{newBeginWsv},
- </if>
- <if test="oldEndWsv != null">
- old_end_wsv = #{oldEndWsv},
- </if>
- <if test="newDeviceNo != null">
- new_device_no = #{newDeviceNo},
- </if>
- <if test="oldDeviceNo != null">
- old_device_no = #{oldDeviceNo},
- </if>
- <if test="newSimNo != null">
- new_sim_no = #{newSimNo},
- </if>
- <if test="oldSimNo != null">
- old_sim_no = #{oldSimNo},
- </if>
- <if test="newDeviceFlagNo != null">
- new_device_flag_no = #{newDeviceFlagNo},
- </if>
- <if test="oldDeviceFlagNo != null">
- old_device_flag_no = #{oldDeviceFlagNo},
- </if>
- <if test="remark != null">
- remark = #{remark},
- </if>
- <if test="status != null">
- `status` = #{status},
- </if>
- <if test="replaceUsername != null">
- replace_username = #{replaceUsername},
- </if>
- <if test="replaceUserPhone != null">
- replace_user_phone = #{replaceUserPhone},
- </if>
- <if test="dateCreate != null">
- date_create = #{dateCreate},
- </if>
- <if test="dateUpdate != null">
- date_update = #{dateUpdate},
- </if>
- <if test="createBy != null">
- create_by = #{createBy},
- </if>
- <if test="updateBy != null">
- update_by = #{updateBy},
- </if>
- </set>
- where id = #{id}
- </update>
- <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into sc_water_meter_replace_log
- (site_id, main_log_id, device_id, replace_method, new_device_type_id, old_device_type_id,
- new_water_no, old_water_no, new_begin_wsv, old_end_wsv, new_device_no, old_device_no,
- new_sim_no, old_sim_no, new_device_flag_no, old_device_flag_no, remark, `status`,
- replace_username, replace_user_phone, date_create, date_update, create_by, update_by
- )
- values
- <foreach collection="list" item="item" separator=",">
- (#{item.siteId}, #{item.mainLogId}, #{item.deviceId}, #{item.replaceMethod}, #{item.newDeviceTypeId},
- #{item.oldDeviceTypeId}, #{item.newWaterNo}, #{item.oldWaterNo}, #{item.newBeginWsv},
- #{item.oldEndWsv}, #{item.newDeviceNo}, #{item.oldDeviceNo}, #{item.newSimNo},
- #{item.oldSimNo}, #{item.newDeviceFlagNo}, #{item.oldDeviceFlagNo}, #{item.remark},
- #{item.status}, #{item.replaceUsername}, #{item.replaceUserPhone}, #{item.dateCreate},
- #{item.dateUpdate}, #{item.createBy}, #{item.updateBy})
- </foreach>
- </insert>
- <select id="findByMainLogId" resultMap="BaseResultMap">
- select <include refid="Base_Column_List"/> from sc_water_meter_replace_log where status = 1 and main_log_id = #{mainLogId}
- </select>
- <select id="findList" resultType="com.bz.smart_city.dto.WaterMeterReplaceLogDto">
- select
- rl.*,
- d.water_meter_file_no,
- d.loc_desc,
- sc.customer_name,
- sb.name as building_name,
- sil.is_accepted,
- sdt1.equipment_type as new_equipment_type,
- sdt1.model as new_model,
- sdm1.name as new_manufacturer_name,
- sdt2.equipment_type as old_equipment_type,
- sdt2.model as old_model,
- sdm2.name as old_manufacturer_name
- from sc_water_meter_replace_log rl
- left join sc_device d on(d.id = rl.device_id)
- left join sc_customer sc on(sc.id = d.customer_id)
- left join sc_building sb on(sb.id = d.building_id)
- left join sc_install_list sil on(sil.device_id = rl.device_id)
- left join sc_device_type sdt1 on(sdt1.id = rl.new_device_type_id)
- left join sc_device_manufacturer sdm1 on(sdm1.id = sdt1.manufacturer_id)
- left join sc_device_type sdt2 on(sdt2.id = rl.old_device_type_id)
- left join sc_device_manufacturer sdm2 on(sdm2.id = sdt2.manufacturer_id)
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = d.id and sdd.status = 1)</if>
- where rl.status = 1 and d.status = 1
- <if test="siteId != null"> and d.site_id = #{siteId}</if>
- <if test="deviceId != null"> and rl.device_id = #{deviceId}</if>
- <if test="deviceNo != null and deviceNo != ''"> and (
- rl.new_device_no LIKE concat('%',#{deviceNo},'%') or rl.old_device_no LIKE concat('%',#{deviceNo},'%') or
- rl.new_water_no LIKE concat('%',#{deviceNo},'%') or rl.old_water_no LIKE concat('%',#{deviceNo},'%') or
- d.water_meter_file_no LIKE concat('%',#{deviceNo},'%')
- )</if>
- <if test="replaceMethod != null"> and rl.replace_method = #{replaceMethod}</if>
- <if test="customerId != null"> and d.customer_id = #{customerId}</if>
- <if test="replaceUsername != null and replaceUsername != ''"> and rl.replace_username LIKE concat('%',#{replaceUsername},'%')</if>
- <if test="isAccepted != null and isAccepted == 1"> and sil.is_accepted = #{isAccepted}</if>
- <if test="isAccepted != null and isAccepted == 0"> and (sil.is_accepted = #{isAccepted} or sil.is_accepted is null)</if>
- <if test="provinceId != null"> and sb.province = #{provinceId}</if>
- <if test="cityId != null"> and sb.city = #{cityId}</if>
- <if test="regionId != null"> and sb.region = #{regionId}</if>
- <if test="communityId != null"> and sb.community = #{communityId}</if>
- <if test="buildingId != null"> and d.building_id = #{buildingId}</if>
- <if test="startDate != null"> and rl.date_create <![CDATA[ >= ]]> #{startDate}</if>
- <if test="endDate != null"> and rl.date_create <![CDATA[ <= ]]> #{endDate}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- order by rl.date_create desc
- </select>
- <select id="findList_COUNT" resultType="Long">
- select
- count(1)
- from sc_water_meter_replace_log rl
- left join sc_device d on(d.id = rl.device_id)
- left join sc_building sb on(sb.id = d.building_id)
- <if test="isAccepted != null">left join sc_install_list sil on(sil.device_id = rl.device_id)</if>
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = d.id and sdd.status = 1)</if>
- where rl.status = 1 and d.status = 1
- <if test="siteId != null"> and d.site_id = #{siteId}</if>
- <if test="deviceId != null"> and rl.device_id = #{deviceId}</if>
- <if test="deviceNo != null and deviceNo != ''"> and (
- rl.new_device_no LIKE concat('%',#{deviceNo},'%') or rl.old_device_no LIKE concat('%',#{deviceNo},'%') or
- rl.new_water_no LIKE concat('%',#{deviceNo},'%') or rl.old_water_no LIKE concat('%',#{deviceNo},'%') or
- d.water_meter_file_no LIKE concat('%',#{deviceNo},'%')
- )</if>
- <if test="replaceMethod != null"> and rl.replace_method = #{replaceMethod}</if>
- <if test="customerId != null"> and d.customer_id = #{customerId}</if>
- <if test="replaceUsername != null and replaceUsername != ''"> and rl.replace_username LIKE concat('%',#{replaceUsername},'%')</if>
- <if test="isAccepted != null and isAccepted == 1"> and sil.is_accepted = #{isAccepted}</if>
- <if test="isAccepted != null and isAccepted == 0"> and (sil.is_accepted = #{isAccepted} or sil.is_accepted is null)</if>
- <if test="provinceId != null"> and sb.province = #{provinceId}</if>
- <if test="cityId != null"> and sb.city = #{cityId}</if>
- <if test="regionId != null"> and sb.region = #{regionId}</if>
- <if test="communityId != null"> and sb.community = #{communityId}</if>
- <if test="buildingId != null"> and d.building_id = #{buildingId}</if>
- <if test="startDate != null"> and rl.date_create <![CDATA[ >= ]]> #{startDate}</if>
- <if test="endDate != null"> and rl.date_create <![CDATA[ <= ]]> #{endDate}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- </select>
- <select id="getAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
- select
- b.id,
- b.name,
- b.province,
- b.city,
- b.region,
- b.community,
- b.longitude,
- b.latitude,
- t1.device_count
- from sc_building b
- right join (
- select sd.building_id,count(1) as device_count
- from sc_water_meter_replace_log rl
- left join sc_device sd on(sd.id = rl.device_id)
- <if test="isAccepted != null">left join sc_install_list sil on(sil.device_id = rl.device_id)</if>
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = d.id and sdd.status = 1)</if>
- where rl.status = 1 and sd.status = 1
- <if test="siteId != null"> and sd.site_id = #{siteId}</if>
- <if test="deviceId != null"> and rl.device_id = #{deviceId}</if>
- <if test="deviceNo != null and deviceNo != ''"> and (
- rl.new_device_no LIKE concat('%',#{deviceNo},'%') or rl.old_device_no LIKE concat('%',#{deviceNo},'%') or
- rl.new_water_no LIKE concat('%',#{deviceNo},'%') or rl.old_water_no LIKE concat('%',#{deviceNo},'%') or
- sd.water_meter_file_no LIKE concat('%',#{deviceNo},'%')
- )</if>
- <if test="replaceMethod != null"> and rl.replace_method = #{replaceMethod}</if>
- <if test="customerId != null"> and sd.customer_id = #{customerId}</if>
- <if test="replaceUsername != null and replaceUsername != ''"> and rl.replace_username LIKE concat('%',#{replaceUsername},'%')</if>
- <if test="isAccepted != null and isAccepted == 1"> and sil.is_accepted = #{isAccepted}</if>
- <if test="isAccepted != null and isAccepted == 0"> and (sil.is_accepted = #{isAccepted} or sil.is_accepted is null)</if>
- <if test="startDate != null"> and rl.date_create <![CDATA[ >= ]]> #{startDate}</if>
- <if test="endDate != null"> and rl.date_create <![CDATA[ <= ]]> #{endDate}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id
- ) t1 on (t1.building_id = b.id)
- where b.status = 1
- </select>
- </mapper>
|