123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680 |
- <?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="cn.ourwill.module.house.dao.elect.ElectRecordDao">
- <resultMap type="cn.ourwill.module.house.entity.elect.ElectRecord" id="baseMap">
- <result column="id" property="id"/>
- <result column="grain_id" property="grainId"/>
- <result column="house_id" property="houseId"/>
- <result column="type" property="type"/>
- <result column="elect_name" property="electName"/>
- <result column="elect_period" property="electPeriod"/>
- <result column="elect_num" property="electNum"/>
- <result column="money_num" property="moneyNum"/>
- <result column="c_id" property="cId" />
- <result column="c_time" property="cTime" />
- <result column="u_time" property="uTime" />
- <result column="u_id" property="uId" />
- <result column="version" property="version"/>
- <result column="uuid" property="uuid"/>
- <result column="sync_flag" property="syncFlag"/>
- </resultMap>
- <resultMap id="messageMap" type="cn.ourwill.module.house.entity.elect.ElectMessage">
- <result column="id" property="id"/>
- <result column="grain_id" property="grainId"/>
- <result column="house_id" property="houseId"/>
- <result column="elect_name" property="electName"/>
- <result column="type" property="type"/>
- <result column="c_id" property="cId" />
- <result column="c_time" property="cTime" />
- <result column="u_time" property="uTime" />
- <result column="u_id" property="uId" />
- <result column="err_count" property="errCount"/>
- <result column="err_state" property="errState"/>
- </resultMap>
- <sql id="columns">
- id,
- grain_id,
- house_id,
- `type`,
- elect_name,
- elect_period,
- elect_num,
- money_num,
- sync_flag,
- c_id,
- c_time,
- u_time,
- u_id,
- version,
- uuid,
- sync_flag
- </sql>
- <sql id="joinCols">
- </sql>
- <insert id="saveRecordTemp" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
- parameterType="cn.ourwill.module.house.entity.elect.ElectRecord">
- INSERT INTO elect_record_day
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test=" id != null">
- id,
- </if>
- <if test=" grainId != null">
- grain_id,
- </if>
- <if test=" houseId != null and houseId != ''">
- house_id,
- </if>
- <if test=" type != null">
- `type`,
- </if>
- <if test="electName !=null">
- elect_name,
- </if>
- <if test="electPeriod !=null">
- elect_period,
- </if>
- <if test="electNum !=null">
- elect_num,
- </if>
- <if test="moneyNum !=null">
- money_num,
- </if>
- <if test="uuid !=null">
- uuid,
- </if>
- <if test="syncFlag !=null">
- sync_flag,
- </if>
- <if test=" cTime != null">
- c_time,
- </if>
- <if test=" cId != null">
- c_id,
- </if>
- <if test=" uTime != null">
- u_time,
- </if>
- <if test=" uId != null">
- u_id,
- </if>
- <if test=" version != null">
- version
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test=" id != null">
- #{id},
- </if>
- <if test=" grainId != null">
- #{grainId},
- </if>
- <if test=" houseId != null and houseId != ''">
- #{houseId},
- </if>
- <if test=" type != null">
- #{type},
- </if>
- <if test="electName !=null">
- #{electName},
- </if>
- <if test="electPeriod !=null">
- #{electPeriod},
- </if>
- <if test="electNum !=null">
- #{electNum},
- </if>
- <if test="moneyNum !=null">
- #{moneyNum},
- </if>
- <if test="uuid !=null">
- #{uuid},
- </if>
- <if test="syncFlag !=null">
- #{syncFlag},
- </if>
- <if test=" cTime != null">
- #{cTime},
- </if>
- <if test=" cId != null">
- #{cId},
- </if>
- <if test=" uTime != null">
- #{uTime},
- </if>
- <if test=" uId != null">
- #{uId},
- </if>
- <if test=" version != null">
- #{version}
- </if>
- </trim>
- </insert>
- <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
- parameterType="cn.ourwill.module.house.entity.elect.ElectRecord">
- INSERT INTO elect_record
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test=" grainId != null">
- grain_id,
- </if>
- <if test=" houseId != null and houseId != ''">
- house_id,
- </if>
- <if test=" type != null">
- `type`,
- </if>
- <if test="electName !=null">
- elect_name,
- </if>
- <if test="electPeriod !=null">
- elect_period,
- </if>
- <if test="electNum !=null">
- elect_num,
- </if>
- <if test="moneyNum !=null">
- money_num,
- </if>
- <if test="uuid !=null">
- uuid,
- </if>
- <if test="syncFlag !=null">
- sync_flag,
- </if>
- <if test=" cTime != null">
- c_time,
- </if>
- <if test=" cId != null">
- c_id,
- </if>
- <if test=" uTime != null">
- u_time,
- </if>
- <if test=" uId != null">
- u_id,
- </if>
- <if test=" version != null">
- version
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test=" grainId != null">
- #{grainId},
- </if>
- <if test=" houseId != null and houseId != ''">
- #{houseId},
- </if>
- <if test=" type != null">
- #{type},
- </if>
- <if test="electName !=null">
- #{electName},
- </if>
- <if test="electPeriod !=null">
- #{electPeriod},
- </if>
- <if test="electNum !=null">
- #{electNum},
- </if>
- <if test="moneyNum !=null">
- #{moneyNum},
- </if>
- <if test="uuid !=null">
- #{uuid},
- </if>
- <if test="syncFlag !=null">
- #{syncFlag},
- </if>
- <if test=" cTime != null">
- #{cTime},
- </if>
- <if test=" cId != null">
- #{cId},
- </if>
- <if test=" uTime != null">
- #{uTime},
- </if>
- <if test=" uId != null">
- #{uId},
- </if>
- <if test=" version != null">
- #{version}
- </if>
- </trim>
- </insert>
- <select id="getByDistinctElectNameTemp" resultMap="baseMap" >
- SELECT
- DISTINCT a.elect_name,a.house_id,a.grain_id,a.`type`,a.elect_num
- FROM
- elect_record_day a
- <where>
- <if test="grainList !=null">
- and a.grain_id in
- <foreach item="item" index="index" collection="grainList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="type !=null">
- and a.`type` = #{type}
- </if>
- <if test="electName !=null">
- and a.elect_name like CONCAT('%',#{electName},'%')
- </if>
- </where>
- GROUP BY a.elect_name
- <choose>
- <when test="page !=null and page.count != null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="getByDistinctElectName" resultMap="baseMap" >
- SELECT
- DISTINCT a.elect_name,a.house_id,a.grain_id,a.`type`,a.elect_num
- FROM
- elect_record a
- <where>
- <if test="grainList !=null">
- and a.grain_id in
- <foreach item="item" index="index" collection="grainList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="houseList !=null">
- and a.house_id <!--in
- <foreach item="items" index="index" collection="houseList" open="(" separator="," close=")">
- #{items}
- </foreach>-->
- </if>
- <if test="type !=null">
- and a.`type` = #{type}
- </if>
- <if test="electName !=null">
- and a.elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="grainId !=null">
- and a.grain_id =#{grainId}
- </if>
- </where>
- GROUP BY a.elect_name
- <choose>
- <when test="page !=null and page.count != null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="getByDistinctElects" resultMap="baseMap" >
- SELECT
- DISTINCT a.elect_name,a.house_id,a.grain_id,a.`type`,a.elect_num
- FROM
- elect_record_day a
- <where>
- <if test="grainList !=null">
- and a.grain_id in
- <foreach item="item" index="index" collection="grainList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="houseList !=null">
- and a.house_id in
- <foreach item="items" index="index" collection="houseList" open="(" separator="," close=")">
- #{items}
- </foreach>
- </if>
- <if test="type !=null">
- and a.`type` = #{type}
- </if>
- <if test="electName !=null">
- and a.elect_name like CONCAT('%',#{electName},'%')
- </if>
- <!-- <if test="electPeriod !=null">
- and a.elect_period like CONCAT('%',#{electPeriod},'%')
- </if>-->
- </where>
- GROUP BY a.elect_name
- <choose>
- <when test="page !=null and page.count != null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="getListBySearchDate" resultMap="baseMap" >
- SELECT
- DISTINCT a.elect_name,a.house_id,a.grain_id,a.`type`
- FROM
- elect_record_day a
- <where>
- <if test="grainList !=null">
- and a.grain_id in
- <foreach item="item" index="index" collection="grainList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="type !=null">
- and a.`type` = #{type}
- </if>
- <if test="searchStartDate !=null">
- and a.elect_period <![CDATA[ >= ]]> #{searchStartDate}
- </if>
- <if test="searchEndDate !=null">
- and a.elect_period <= #{searchEndDate}
- </if>
- </where>
- GROUP BY a.elect_name
- <choose>
- <when test="page !=null and page.count != null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="getMonthElectPay" resultType="java.lang.Double" parameterType="java.lang.String" >
- SELECT
- sum(money_num) money_nums
- FROM
- elect_record_day
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="electName !=null">
- and elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="electPeriod !=null">
- and elect_period like CONCAT('%',#{electPeriod},'%')
- </if>
- </where>
- GROUP BY elect_name
- </select>
- <select id="getSearchDateElectPay" resultType="java.lang.Double" parameterType="java.lang.String" >
- SELECT
- sum(money_num) money_nums
- FROM
- elect_record_day
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="electName !=null">
- and elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="searchStartDate !=null and searchStartDate != ''">
- and elect_period <![CDATA[ >= ]]> #{searchStartDate}
- </if>
- <if test="searchEndDate !=null and searchEndDate != ''">
- and elect_period <= #{searchEndDate}
- </if>
- </where>
- GROUP BY elect_name
- </select>
- <select id="getMonthElect" resultType="java.lang.Double" parameterType="java.lang.String" >
- SELECT
- elect_num
- FROM
- elect_record_day
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="electName !=null">
- and elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="electPeriod !=null">
- and elect_period like CONCAT('%',#{electPeriod},'%')
- </if>
- </where>
- order by elect_period
- </select>
- <select id="getMonthList" resultMap="baseMap">
- SELECT
- *
- FROM
- elect_record_day
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="electName !=null">
- and elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="electPeriod !=null">
- and elect_period like CONCAT('%',#{electPeriod},'%')
- </if>
- </where>
- order by elect_period
- </select>
- <select id="getElectPeriodList" resultMap="baseMap" >
- SELECT
- elect_period,elect_num
- FROM
- elect_record
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="type !=null">
- and `type` = #{type}
- </if>
- <if test="electName !=null">
- and elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="electPeriod !=null">
- and elect_period like CONCAT('%',#{electPeriod},'%')
- </if>
- </where>
- ORDER BY elect_period asc
- </select>
- <select id="getElectPeriods" resultMap="baseMap" >
- SELECT
- elect_period,elect_num
- FROM
- elect_record_day
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="type !=null">
- and `type` = #{type}
- </if>
- <if test="electName !=null">
- and elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="electPeriod !=null">
- and elect_period like CONCAT('%',#{electPeriod},'%')
- </if>
- </where>
- ORDER BY elect_period asc
- </select>
- <select id="getElectSearchDateList" resultMap="baseMap" >
- SELECT
- elect_period,elect_num
- FROM
- elect_record
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="type !=null">
- and `type` = #{type}
- </if>
- <if test="electName !=null">
- and elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="searchStartDate !=null and searchStartDate != ''">
- and elect_period <![CDATA[ >= ]]> #{searchStartDate}
- </if>
- <if test="searchEndDate !=null and searchEndDate != ''">
- and elect_period <= #{searchEndDate}
- </if>
- </where>
- ORDER BY elect_period asc
- </select>
- <select id="getElectSearchDateLists" resultMap="baseMap" >
- SELECT
- elect_period,elect_num
- FROM
- elect_record_day
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="type !=null">
- and `type` = #{type}
- </if>
- <if test="electName !=null">
- and elect_name like CONCAT('%',#{electName},'%')
- </if>
- <if test="searchStartDate !=null and searchStartDate != ''">
- and elect_period <![CDATA[ >= ]]> #{searchStartDate}
- </if>
- <if test="searchEndDate !=null and searchEndDate != ''">
- and elect_period <= #{searchEndDate}
- </if>
- </where>
- ORDER BY elect_period asc
- </select>
- <select id="getEveryoneMonthChartBudget" resultMap="baseMap" >
- SELECT
- elect_period,elect_num
- FROM
- elect_record_day
- <where>
- <if test="grainId !=null">
- and grain_id = #{grainId}
- </if>
- <if test="electName !=null">
- and elect_name = #{electName}
- </if>
- <if test="electPeriod !=null and electPeriod != ''">
- and elect_period like CONCAT('%',#{electPeriod},'%')
- </if>
- </where>
- ORDER BY elect_period asc
- </select>
- <delete id="deleteAll">
- DELETE FROM elect_record where id not in (select a.id from (select MAX(id) id from elect_record GROUP BY elect_name) a)
- </delete>
- <update id="updateVersion">
- UPDATE elect_record SET sync_flag='1'
- </update>
- <!-- 智能电表消息提醒表操作-start-->
- <select id="getMessageList" resultMap="messageMap">
- SELECT * FROM elect_message WHERE err_count>3
- <if test="grainId !=null and grainId != ''">
- and grain_id = #{grainId}
- </if>
- <if test="houseList !=null">
- and house_id in
- <foreach item="item" index="index" collection="houseList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getAllMessageList" resultMap="messageMap">
- SELECT elect_name,id,err_count FROM elect_message
- </select>
- <select id="getElectMessageByName" resultMap="messageMap">
- SELECT * FROM elect_message where elect_name=#{electName}
- </select>
- <select id="getElectName" resultType="cn.ourwill.module.house.entity.elect.ElectRecord">
- SELECT DISTINCT elect_name FROM elect_record_day
- </select>
- <insert id="saveElectMessage" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
- parameterType="cn.ourwill.module.house.entity.elect.ElectMessage">
- INSERT INTO elect_message
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test=" grainId != null">
- grain_id,
- </if>
- <if test=" houseId != null and houseId != ''">
- house_id,
- </if>
- <if test=" type != null">
- `type`,
- </if>
- <if test="electName !=null">
- elect_name,
- </if>
- <if test="errCount !=null">
- err_count,
- </if>
- <if test="errState !=null">
- err_state,
- </if>
- <if test="uuid !=null">
- uuid,
- </if>
- <if test=" cTime != null">
- c_time,
- </if>
- <if test=" cId != null">
- c_id,
- </if>
- <if test=" uTime != null">
- u_time,
- </if>
- <if test=" uId != null">
- u_id
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test=" grainId != null">
- #{grainId},
- </if>
- <if test=" houseId != null and houseId != ''">
- #{houseId},
- </if>
- <if test=" type != null">
- #{type},
- </if>
- <if test="electName !=null">
- #{electName},
- </if>
- <if test="errCount !=null">
- #{errCount},
- </if>
- <if test="errState !=null">
- #{errState},
- </if>
- <if test="uuid !=null">
- #{uuid},
- </if>
- <if test=" cTime != null">
- #{cTime},
- </if>
- <if test=" cId != null">
- #{cId},
- </if>
- <if test=" uTime != null">
- #{uTime},
- </if>
- <if test=" uId != null">
- #{uId}
- </if>
- </trim>
- </insert>
- <update id="updateElectMessage">
- UPDATE elect_message SET err_count =#{errCount} where elect_name=#{electName}
- </update>
- <update id="updateByElectName">
- UPDATE elect_record SET house_id =#{houseId} where elect_name=#{electName}
- </update>
- <update id="updateByElectNameDay">
- UPDATE elect_record_day SET house_id =#{houseId} where elect_name=#{electName}
- </update>
- <delete id="deleteByName">
- DELETE FROM elect_message where elect_name=#{electName}
- </delete>
- <!-- 智能电表消息提醒表操作-end-->
- </mapper>
|