123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929 |
- <?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.assistant.InstallListMapper">
- <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.assistant.InstallList">
- <!--@mbg.generated-->
- <id column="id" property="id" />
- <result column="site_id" property="siteId" />
- <result column="install_plan_id" property="installPlanId" />
- <result column="install_plan_data_id" property="installPlanDataId" />
- <result column="building_id" property="buildingId" />
- <result column="accept_plan_id" property="acceptPlanId" />
- <result column="intall_batch_id" property="intallBatchId" />
- <result column="customer_id" property="customerId" />
- <result column="door_no" property="doorNo" />
- <result column="device_id" property="deviceId" />
- <result column="device_type_id" property="deviceTypeId" />
- <result column="device_no" property="deviceNo" />
- <result column="electronic_no" property="electronicNo" />
- <result column="file_no" property="fileNo" />
- <result column="new_meter_start" property="newMeterStart" />
- <result column="old_meter_end" property="oldMeterEnd" />
- <result column="image_url" property="imageUrl" />
- <result column="old_image_url" property="oldImageUrl" />
- <result column="user_name" property="userName" />
- <result column="user_phone" property="userPhone" />
- <result column="is_in_plan" property="isInPlan" />
- <result column="is_installed" property="isInstalled" />
- <result column="is_accepted" property="isAccepted" />
- <result column="plan_time" property="planTime" />
- <result column="install_time" property="installTime" />
- <result column="accept_time" property="acceptTime" />
- <result column="remark" property="remark" />
- <result column="status" property="status" />
- <result column="date_create" property="dateCreate" />
- <result column="date_update" property="dateUpdate" />
- <result column="create_by" property="createBy" />
- <result column="update_by" property="updateBy" />
- <result column="floor" property="floor" />
- </resultMap>
- <resultMap id="BaseResultMapWithAccount" type="com.bz.smart_city.entity.assistant.InstallList">
- <!--@mbg.generated-->
- <id column="id" property="id" />
- <result column="site_id" property="siteId" />
- <result column="install_plan_id" property="installPlanId" />
- <result column="install_plan_data_id" property="installPlanDataId" />
- <result column="building_id" property="buildingId" />
- <result column="accept_plan_id" property="acceptPlanId" />
- <result column="intall_batch_id" property="intallBatchId" />
- <result column="customer_id" property="customerId" />
- <result column="door_no" property="doorNo" />
- <result column="device_id" property="deviceId" />
- <result column="device_type_id" property="deviceTypeId" />
- <result column="device_no" property="deviceNo" />
- <result column="electronic_no" property="electronicNo" />
- <result column="file_no" property="fileNo" />
- <result column="new_meter_start" property="newMeterStart" />
- <result column="old_meter_end" property="oldMeterEnd" />
- <result column="image_url" property="imageUrl" />
- <result column="old_image_url" property="oldImageUrl" />
- <result column="user_name" property="userName" />
- <result column="user_phone" property="userPhone" />
- <result column="is_in_plan" property="isInPlan" />
- <result column="is_installed" property="isInstalled" />
- <result column="is_accepted" property="isAccepted" />
- <result column="plan_time" property="planTime" />
- <result column="install_time" property="installTime" />
- <result column="accept_time" property="acceptTime" />
- <result column="remark" property="remark" />
- <result column="status" property="status" />
- <result column="date_create" property="dateCreate" />
- <result column="date_update" property="dateUpdate" />
- <result column="create_by" property="createBy" />
- <result column="update_by" property="updateBy" />
- <result column="floor" property="floor" />
- <result column="metercode" property="metercode" />
- <result column="account_id" property="accountId" />
- </resultMap>
- <sql id="Base_Column_List">
- <!--@mbg.generated-->
- id, site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id,
- intall_batch_id, customer_id, door_no, device_id, device_type_id, device_no, electronic_no,
- file_no, new_meter_start, old_meter_end, image_url, old_image_url, user_name, user_phone,
- is_in_plan, is_installed, is_accepted, plan_time, install_time, accept_time, remark,
- `status`, date_create, date_update, create_by, update_by, `floor`
- </sql>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.assistant.InstallList" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into sc_install_list
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="siteId != null">
- site_id,
- </if>
- <if test="installPlanId != null">
- install_plan_id,
- </if>
- <if test="installPlanDataId != null">
- install_plan_data_id,
- </if>
- <if test="buildingId != null">
- building_id,
- </if>
- <if test="acceptPlanId != null">
- accept_plan_id,
- </if>
- <if test="intallBatchId != null">
- intall_batch_id,
- </if>
- <if test="customerId != null">
- customer_id,
- </if>
- <if test="doorNo != null">
- door_no,
- </if>
- <if test="deviceId != null">
- device_id,
- </if>
- <if test="deviceTypeId != null">
- device_type_id,
- </if>
- <if test="deviceNo != null">
- device_no,
- </if>
- <if test="electronicNo != null">
- electronic_no,
- </if>
- <if test="fileNo != null">
- file_no,
- </if>
- <if test="newMeterStart != null">
- new_meter_start,
- </if>
- <if test="oldMeterEnd != null">
- old_meter_end,
- </if>
- <if test="imageUrl != null">
- image_url,
- </if>
- <if test="oldImageUrl != null">
- old_image_url,
- </if>
- <if test="userName != null">
- user_name,
- </if>
- <if test="userPhone != null">
- user_phone,
- </if>
- <if test="isInPlan != null">
- is_in_plan,
- </if>
- <if test="isInstalled != null">
- is_installed,
- </if>
- <if test="isAccepted != null">
- is_accepted,
- </if>
- <if test="planTime != null">
- plan_time,
- </if>
- <if test="installTime != null">
- install_time,
- </if>
- <if test="acceptTime != null">
- accept_time,
- </if>
- <if test="remark != null">
- remark,
- </if>
- <if test="status != null">
- `status`,
- </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>
- <if test="floor != null">
- `floor`,
- </if>
- <if test="idCard != null">
- id_card,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="siteId != null">
- #{siteId},
- </if>
- <if test="installPlanId != null">
- #{installPlanId},
- </if>
- <if test="installPlanDataId != null">
- #{installPlanDataId},
- </if>
- <if test="buildingId != null">
- #{buildingId},
- </if>
- <if test="acceptPlanId != null">
- #{acceptPlanId},
- </if>
- <if test="intallBatchId != null">
- #{intallBatchId},
- </if>
- <if test="customerId != null">
- #{customerId},
- </if>
- <if test="doorNo != null">
- #{doorNo},
- </if>
- <if test="deviceId != null">
- #{deviceId},
- </if>
- <if test="deviceTypeId != null">
- #{deviceTypeId},
- </if>
- <if test="deviceNo != null">
- #{deviceNo},
- </if>
- <if test="electronicNo != null">
- #{electronicNo},
- </if>
- <if test="fileNo != null">
- #{fileNo},
- </if>
- <if test="newMeterStart != null">
- #{newMeterStart},
- </if>
- <if test="oldMeterEnd != null">
- #{oldMeterEnd},
- </if>
- <if test="imageUrl != null">
- #{imageUrl},
- </if>
- <if test="oldImageUrl != null">
- #{oldImageUrl},
- </if>
- <if test="userName != null">
- #{userName},
- </if>
- <if test="userPhone != null">
- #{userPhone},
- </if>
- <if test="isInPlan != null">
- #{isInPlan},
- </if>
- <if test="isInstalled != null">
- #{isInstalled},
- </if>
- <if test="isAccepted != null">
- #{isAccepted},
- </if>
- <if test="planTime != null">
- #{planTime},
- </if>
- <if test="installTime != null">
- #{installTime},
- </if>
- <if test="acceptTime != null">
- #{acceptTime},
- </if>
- <if test="remark != null">
- #{remark},
- </if>
- <if test="status != null">
- #{status},
- </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>
- <if test="floor != null">
- #{floor},
- </if>
- <if test="idCard != null">
- #{idCard},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.assistant.InstallList">
- <!--@mbg.generated-->
- update sc_install_list
- <set>
- <if test="siteId != null">
- site_id = #{siteId},
- </if>
- <if test="installPlanId != null">
- install_plan_id = #{installPlanId},
- </if>
- <if test="installPlanDataId != null">
- install_plan_data_id = #{installPlanDataId},
- </if>
- <if test="buildingId != null">
- building_id = #{buildingId},
- </if>
- <if test="acceptPlanId != null">
- accept_plan_id = #{acceptPlanId},
- </if>
- <if test="intallBatchId != null">
- intall_batch_id = #{intallBatchId},
- </if>
- <if test="customerId != null">
- customer_id = #{customerId},
- </if>
- <if test="doorNo != null">
- door_no = #{doorNo},
- </if>
- <if test="deviceId != null">
- device_id = #{deviceId},
- </if>
- <if test="deviceTypeId != null">
- device_type_id = #{deviceTypeId},
- </if>
- <if test="deviceNo != null">
- device_no = #{deviceNo},
- </if>
- <if test="electronicNo != null">
- electronic_no = #{electronicNo},
- </if>
- <if test="fileNo != null">
- file_no = #{fileNo},
- </if>
- <if test="newMeterStart != null">
- new_meter_start = #{newMeterStart},
- </if>
- <if test="oldMeterEnd != null">
- old_meter_end = #{oldMeterEnd},
- </if>
- <if test="imageUrl != null">
- image_url = #{imageUrl},
- </if>
- <if test="oldImageUrl != null">
- old_image_url = #{oldImageUrl},
- </if>
- <if test="userName != null">
- user_name = #{userName},
- </if>
- <if test="userPhone != null">
- user_phone = #{userPhone},
- </if>
- <if test="isInPlan != null">
- is_in_plan = #{isInPlan},
- </if>
- <if test="isInstalled != null">
- is_installed = #{isInstalled},
- </if>
- <if test="isAccepted != null">
- is_accepted = #{isAccepted},
- </if>
- <if test="planTime != null">
- plan_time = #{planTime},
- </if>
- <if test="installTime != null">
- install_time = #{installTime},
- </if>
- <if test="acceptTime != null">
- accept_time = #{acceptTime},
- </if>
- <if test="remark != null">
- remark = #{remark},
- </if>
- <if test="status != null">
- `status` = #{status},
- </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>
- <if test="floor != null">
- `floor` = #{floor},
- </if>
- <if test="idCard != null">
- id_card = #{idCard},
- </if>
- </set>
- where id = #{id}
- </update>
- <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into sc_install_list
- (site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id, intall_batch_id,
- customer_id, door_no, device_id, device_type_id, device_no, electronic_no, file_no,
- new_meter_start, old_meter_end, image_url, old_image_url, user_name, user_phone,
- is_in_plan, is_installed, is_accepted, plan_time, install_time, accept_time, remark,
- `status`, date_create, date_update, create_by, update_by, `floor`,account_id,id_card,metercode)
- values
- <foreach collection="list" item="item" separator=",">
- (#{item.siteId}, #{item.installPlanId}, #{item.installPlanDataId}, #{item.buildingId},
- #{item.acceptPlanId}, #{item.intallBatchId}, #{item.customerId}, #{item.doorNo},
- #{item.deviceId}, #{item.deviceTypeId}, #{item.deviceNo}, #{item.electronicNo},
- #{item.fileNo}, #{item.newMeterStart}, #{item.oldMeterEnd}, #{item.imageUrl}, #{item.oldImageUrl},
- #{item.userName}, #{item.userPhone}, #{item.isInPlan}, #{item.isInstalled}, #{item.isAccepted},
- #{item.planTime}, #{item.installTime}, #{item.acceptTime}, #{item.remark}, #{item.status},
- #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy}, #{item.updateBy}, #{item.floor},#{item.account_id},#{item.idCard}
- ,#{item.fileNo})
- </foreach>
- </insert>
- <select id="queryInstallList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
- SELECT
- n.id as id,
- n.site_id as site_id,
- n.install_plan_id as install_plan_id,
- n.building_id as building_id,
- b.`name` as building_name,
- n.accept_plan_id as accept_plan_id,
- n.intall_batch_id as intall_batch_id,
- n.customer_id as customer_id,
- c.customer_name as customer_name,
- n.door_no as door_no,
- n.device_id as device_id,
- sd.device_type as device_type_id,
- dt.model as model,
- dt.equipment_type as equipment_type,
- dm.id as factory_id,
- dm.`name` as facory_name,
- sd.device_no as device_no,
- sd.water_meter_no as electronic_no,
- sd.water_meter_file_no as file_no,
- sd.seal_no,
- n.new_meter_start as new_meter_start,
- n.old_meter_end as old_meter_end,
- n.image_url as new_image_url,
- n.old_image_url as old_image_url,
- n.user_name as user_name,
- n.user_phone as user_phone,
- n.id_card as id_card,
- n.is_in_plan as is_in_plan,
- n.is_installed as is_installed,
- n.is_accepted as is_accepted,
- n.plan_time as plan_time,
- n.install_time as install_time,
- n.accept_time as accept_time,
- n.remark as remark,
- n.floor as floor,
- com.id as community_id,
- com.name as community_name,
- swmed.meter_reading,
- n.metercode as metercode,
- n.account_id as account_id,
- n.account_id as accountId,
- swrd.concentrator_id,
- swrd.collector_id,
- swrd.channel_number_id,
- swrd.port,
- scon.serial_number as concentrator_name,
- scol.collector_no as collector_name,
- scn.channel_name as channel_number_name
- FROM
- sc_install_list n
- left join sc_device sd on (sd.id = n.device_id)
- left join sc_building b on (b.id = n.building_id)
- left join sc_customer c on (c.id = n.customer_id)
- left join sc_device_type dt on (dt.id = sd.device_type)
- left join sc_device_manufacturer dm on (dm.id = dt.manufacturer_id)
- left join sc_community com on (com.id = b.community)
- left join sc_water_meter_error_days swmed on ( swmed.device_id = n.device_id)
- left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)
- left join sc_concentrator scon on(scon.id = swrd.concentrator_id)
- left join sc_collector scol on(scol.id = swrd.collector_id)
- left join sc_channel_number scn on(scn.id = swrd.channel_number_id)
- WHERE
- n.STATUS = 1
- <if test="siteId != null">
- and n.site_id = #{siteId}
- </if>
- <if test="customerId != null">
- and n.customer_id = #{customerId}
- </if>
- <if test="installPlanId != null">
- and n.install_plan_id = #{installPlanId}
- </if>
- <if test="buildingId != null">
- and n.building_id = #{buildingId}
- </if>
- <if test="acceptPlanId != null">
- and n.accept_plan_id = #{acceptPlanId}
- </if>
- <if test="intallBatchId != null">
- and n.intall_batch_id = #{intallBatchId}
- </if>
- <if test="doorNo != null">
- and n.door_no = #{doorNo}
- </if>
- <if test="deviceId != null">
- and n.device_id = #{deviceId}
- </if>
- <if test="deviceTypeId != null">
- and n.device_type_id = #{deviceTypeId}
- </if>
- <if test="deviceNo != null">
- and n.device_no = #{deviceNo}
- </if>
- <if test="electronicNo != null">
- and n.electronic_no = #{electronicNo}
- </if>
- <if test="fileNo != null">
- and n.file_no = #{fileNo}
- </if>
- <if test="isInstalled != null">
- and n.is_installed = #{isInstalled}
- </if>
- <if test="isAccepted != null">
- and n.is_accepted = #{isAccepted}
- </if>
- <if test="isInPlan != null">
- and n.is_in_plan = #{isInPlan}
- </if>
- <if test="floor != null">
- and n.floor = #{floor}
- </if>
- order by n.date_create desc
- </select>
- <select id="queryPlanBuildingList" resultType="com.bz.smart_city.dto.assistant.PlanBuildingDTO">
- SELECT
- list.buidling_id AS building_id,
- list.building_name AS building_name,
- SUM( IF ( list.`is_installed` = 1, 1, 0 ) ) AS installed_count,
- SUM( IF ( list.`is_installed` = 0, 1, 0 ) ) AS un_install_count
- FROM
- (
- SELECT
- sil.building_id as buidling_id,
- sb.`name` as building_name,
- sil.is_installed
- FROM sc_install_list sil
- LEFT JOIN sc_building sb on (sb.id = sil.building_id and sb.status = 1)
- WHERE sil.`status` = 1
- and sil.is_accepted = 0
- and sil.install_plan_id in (
- SELECT
- ip.id
- FROM
- sc_install_plan ip
- WHERE
- ip.`status` = 1
- <if test="communityId != null and communityId != 0">
- and ip.community_id = #{communityId}
- </if>
- <if test="customerId != null and customerId != 0">
- AND ip.customer_id = #{customerId}
- </if>
- )
- <if test="customerId != null and customerId != 0">
- and sil.customer_id = #{customerId}
- </if>
- <if test="buildingName != null and buildingName != ''">
- and sb.name like concat('%',#{buildingName},'%')
- </if>
- ) list
- GROUP BY
- list.buidling_id,
- list.building_name
- order by building_name
- </select>
- <select id="queryPlanBuildingList1" resultType="com.bz.smart_city.dto.assistant.PlanBuildingDTO">
- SELECT
- list.buidling_id AS building_id,
- list.building_name AS building_name,
- SUM( IF ( list.`is_installed` = 1, 1, 0 ) ) AS installed_count,
- SUM( IF ( list.`is_installed` = 0, 1, 0 ) ) AS un_install_count
- FROM
- (
- SELECT
- tmp.buidling_id,
- tmp.building_name,
- il.is_installed
- FROM
- (
- SELECT
- ip.id,
- ip.community_id,
- cm.`name`,
- ip.buidling_id,
- ip.building_name
- FROM
- sc_install_plan ip
- LEFT JOIN sc_community cm ON ( ip.community_id = cm.id )
- WHERE
- ip.`status` = 1
- <if test="communityId != null and communityId != 0">
- and ip.community_id = #{communityId}
- </if>
- <if test="customerId != null and customerId != 0">
- AND ip.customer_id = #{customerId}
- </if>
- ) tmp
- JOIN sc_install_list il ON ( il.install_plan_id = tmp.id and il.building_id = tmp.buidling_id and il.`status` = 1 )
- ) list
- GROUP BY
- list.buidling_id,
- list.building_name
- order by un_install_count desc
- </select>
- <select id="queryPlanCommunityList" resultType="com.bz.smart_city.dto.assistant.PlanCommunityDTO">
- SELECT
- list.community_id AS community_id,
- list.NAME AS community_name,
- SUM( IF ( list.`is_installed` = 1, 1, 0 ) ) AS installed_count,
- SUM( IF ( list.`is_installed` = 0, 1, 0 ) ) AS un_install_count
- FROM
- (
- SELECT
- tmp.community_id,
- tmp.`name`,
- il.is_installed
- FROM
- (
- SELECT
- ip.id,
- ip.community_id,
- cm.`name`
- FROM
- sc_install_plan ip
- LEFT JOIN sc_community cm ON ( ip.community_id = cm.id )
- WHERE
- ip.`status` = 1
- <if test="customerId != null and customerId != 0">
- AND ip.customer_id = #{customerId}
- </if>
- <if test="communityName != null and communityName != '' ">
- AND cm.`name` LIKE #{communityName}
- </if>
- ) tmp
- JOIN sc_install_list il ON ( il.install_plan_id = tmp.id AND il.`status` = 1 and il.is_accepted = 0 and il.customer_id = #{customerId})
- ) list
- GROUP BY
- list.community_id,
- list.NAME
- order by un_install_count desc
- </select>
- <select id="queryUnPlanList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
- SELECT
- t.id as id,
- t.install_time as install_time,
- t.device_no as device_no,
- t.electronic_no as electronic_no,
- t.new_meter_start as new_meter_start,
- ct.customer_name as customer_name,
- t.customer_id,
- c.`name` as community_name,
- b.community as community_id,
- b.`name` as building_name,
- t.building_id,
- IF(t.accept_plan_id is null,0,1) as is_selected,
- t.door_no as door_no
- FROM
- sc_install_list t
- left join sc_building b on (t.building_id = b.id)
- left join sc_community c on (c.id = b.community)
- left join sc_customer ct on (t.customer_id = ct.id)
- WHERE
- t.is_installed = 1
- AND t.is_accepted = 0
- <if test="siteId != null">
- and t.site_id = #{siteId}
- </if>
- <if test="deviceNo != null and deviceNo != ''">
- and (t.device_no like #{deviceNo} or t.electronic_no like #{deviceNo})
- </if>
- <if test="communityId != null ">
- and c.id = #{communityId}
- </if>
- <if test="buildingId != null">
- and t.building_id = #{buildingId}
- </if>
- <if test="customerId != null">
- and t.customer_id = #{customerId}
- </if>
- AND ( t.accept_plan_id IS NULL OR t.accept_plan_id = #{acceptPlanId} )
- </select>
- <update id="updateBySelective">
- update
- sc_install_list
- <set>
- <if test="record.installPlanId != null">
- install_plan_id = #{record.installPlanId},
- </if>
- <if test="record.intallBatchId != null">
- intall_batch_id = #{record.intallBatchId},
- </if>
- <if test="record.deviceTypeId != null">
- device_type_id = #{record.deviceTypeId},
- </if>
- <if test="record.isInPlan != null">
- is_in_plan = #{record.isInPlan},
- </if>
- <if test="record.isInstalled != null">
- is_installed = #{record.isInstalled},
- </if>
- <if test="record.isAccepted != null">
- is_accepted = #{record.isAccepted},
- </if>
- <if test="record.planTime != null">
- plan_time = #{record.planTime},
- </if>
- <if test="record.installTime != null">
- install_time = #{record.installTime},
- </if>
- <if test="record.acceptTime != null">
- accept_time = #{record.acceptTime},
- </if>
- <if test="record.status != null">
- `status` = #{record.status},
- </if>
- <if test="record.createBy != null">
- create_by = #{record.createBy},
- </if>
- <if test="record.updateBy != null">
- update_by = #{record.updateBy},
- </if>
- </set>
- where
- status = 1
- <if test="param.acceptPlanId != null">
- and accept_plan_id = #{param.acceptPlanId}
- </if>
- </update>
-
- <update id="updateAcceptPlan">
- update
- sc_install_list
- set accept_plan_id = #{record.acceptPlanId}
- where status = 1 and accept_plan_id = #{param.acceptPlanId}
- </update>
- <!--按安装计划id查询已安装数-->
- <select id="countByInstallPlanIdAndIsInstalled" resultType="int">
- SELECT COUNT(1) FROM sc_install_list WHERE status = 1 AND install_plan_id = #{installPlanId} AND is_installed = #{isInstalled}
- </select>
- <!--按安装计划id更新状态(删除)-->
- <update id="delByInstallPlanId">
- update sc_install_list set status=0,date_update=NOW(),update_by=#{username} WHERE status = 1 AND install_plan_id = #{installPlanId}
- </update>
- <!--按安装计划id查询-->
- <select id="getInstallList" resultMap="BaseResultMap">
- select id, site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id, intall_batch_id, customer_id, door_no, device_id, device_no, electronic_no, user_name, user_phone, is_in_plan, is_installed, install_time from sc_install_list WHERE status = 1 AND install_plan_id = #{installPlanId}
- </select>
- <update id="updateByPrimaryKey">
- update sc_install_list
- <set>
- device_id = #{deviceId},
- device_type_id = #{deviceTypeId},
- device_no = #{deviceNo},
- electronic_no = #{electronicNo},
- file_no = #{fileNo},
- new_meter_start = #{newMeterStart},
- old_meter_end = #{oldMeterEnd},
- image_url = #{imageUrl},
- old_image_url = #{oldImageUrl},
- is_installed = #{isInstalled},
- install_time = #{installTime},
- update_by = #{updateBy},
- </set>
- where id = #{id}
- </update>
- <update id="updateByDeviceId2" parameterType="com.bz.smart_city.entity.assistant.InstallList">
- update sc_install_list
- <set>
- <if test="newMeterStart != null">
- new_meter_start = #{newMeterStart},
- </if>
- <if test="oldMeterEnd != null">
- old_meter_end = #{oldMeterEnd},
- </if>
- <if test="dateUpdate != null">
- date_update = #{dateUpdate},
- </if>
- </set>
- where device_id = #{deviceId}
- </update>
-
- <select id="queryUnPlanedList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
- SELECT
- t.id as id,
- t.install_time as install_time,
- t.device_no as device_no,
- t.electronic_no as electronic_no,
- t.new_meter_start as new_meter_start,
- ct.customer_name as customer_name,
- t.customer_id,
- c.`name` as community_name,
- b.community as community_id,
- b.`name` as building_name,
- t.building_id,
- t.door_no as door_no,
- d.device_status
- FROM
- sc_install_list t
- left join sc_building b on (t.building_id = b.id)
- left join sc_community c on (c.id = b.community)
- left join sc_customer ct on (t.customer_id = ct.id)
- left join sc_device d on (t.device_id = d.id)
- WHERE t.status = 1
- and t.is_installed = 1
- AND t.is_accepted = 0
- and t.accept_plan_id is null
- and t.customer_id = #{customerId}
- <if test="meterCode != null and meterCode != ''">
- and (t.device_no like #{meterCode} or t.electronic_no like #{meterCode})
- </if>
- <if test="communityId != null ">
- and c.id = #{communityId}
- </if>
- <if test="buildingId != null">
- and t.building_id = #{buildingId}
- </if>
- <if test="deviceStatus != null and deviceStatus !=''">
- and d.device_status = #{deviceStatus}
- </if>
- order by t.install_time desc
- </select>
- <select id="queryPlanedtList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
- SELECT
- t.id as id,
- t.install_time as install_time,
- t.device_no as device_no,
- t.electronic_no as electronic_no,
- t.new_meter_start as new_meter_start,
- ct.customer_name as customer_name,
- t.customer_id,
- c.`name` as community_name,
- b.community as community_id,
- b.`name` as building_name,
- t.building_id,
- t.door_no as door_no,
- d.device_status
- FROM
- sc_install_list t
- left join sc_building b on (t.building_id = b.id)
- left join sc_community c on (c.id = b.community)
- left join sc_customer ct on (t.customer_id = ct.id)
- left join sc_device d on (t.device_id = d.id)
- WHERE t.status = 1
- and t.is_installed = 1
- and t.accept_plan_id = #{acceptPlanId}
- and t.customer_id = #{customerId}
- <if test="meterCode != null and meterCode != ''">
- and (t.device_no like #{meterCode} or t.electronic_no like #{meterCode})
- </if>
- <if test="communityId != null ">
- and c.id = #{communityId}
- </if>
- <if test="buildingId != null">
- and t.building_id = #{buildingId}
- </if>
- <if test="deviceStatus != null and deviceStatus != '' ">
- and d.device_status = #{deviceStatus}
- </if>
- </select>
- <update id="updateAcceptPlanNull">
- update
- sc_install_list
- set accept_plan_id = null
- where is_accepted = 0
- and id = #{id}
- and accept_plan_id = #{acceptPlanId}
- </update>
- <select id="findById" resultMap="BaseResultMap">
- select * from sc_install_list where id = #{id} and status = 1
- </select>
- <select id="findByIdWithLock" resultMap="BaseResultMapWithAccount">
- select * from sc_install_list where id = #{id} and status = 1 for update
- </select>
- <select id="findByDeviceId" resultMap="BaseResultMap">
- select * from sc_install_list where status = 1 and device_id = #{deviceId}
- </select>
- <select id="getInstallListByBuildIngId" resultMap="BaseResultMap">
- select id, site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id, intall_batch_id, customer_id, door_no, device_id, device_no, electronic_no, file_no, user_name, user_phone, id_card, is_in_plan, is_installed, install_time from sc_install_list WHERE status = 1 AND install_plan_id = #{installPlanId} and building_id = #{buildingId}
- </select>
- <select id="queryFloorList" resultType="java.lang.Integer">
- select floor from sc_install_list where status = 1 and building_id = #{buildingId} group by floor order by floor asc
- </select>
- <update id="updateByDeviceId">
- update
- sc_install_list
- <set>
- <if test="newDeviceNo != null">
- device_no = #{newDeviceNo},
- </if>
- <if test="newWaterMeterNo != null">
- electronic_no = #{newWaterMeterNo}
- </if>
- </set>
- where
- status = 1
- and device_id = #{deviceId}
- </update>
- <select id="meterAccept" resultType="com.bz.smart_city.dto.sync.MeterAcceptDto">
- select
- sd.water_meter_file_no as file_no,
- sil.is_installed as status
- from sc_install_list sil
- inner join sc_device sd on(sd.id = sil.device_id)
- where sil.status = 1 and sd.status = 1
- and sd.customer_id = #{customerId}
- <if test="createDate != null and createDate != ''"> and DATE_FORMAT(sil.accept_time, '%Y%m%d' ) = #{createDate}</if>
- <if test="fileNo != null and fileNo.size() != 0">
- and sd.water_meter_file_no in <foreach collection="fileNo" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </select>
- </mapper>
|