123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579 |
- <?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.daily.DailyRecordInoutputDao">
- <resultMap type="cn.ourwill.module.house.entity.daily.DailyRecordInoutput" id="baseMap">
- <result column="id" property="id"/>
- <result column="uuid" property="uuid"/>
- <result column="house_id" property="houseId"/>
- <result column="c_id" property="cId"/>
- <result column="c_time" property="cTime"/>
- <result column="u_id" property="uId"/>
- <result column="u_time" property="uTime"/>
- <result column="version" property="version"/>
- <result column="type" property="type"/>
- <result column="htype" property="htype"/>
- <result column="recorder" property="recorder"/>
- <result column="record_date" property="recordDate"/>
- <result column="classes" property="classes"/>
- <result column="record_num" property="recordNum"/>
- <result column="store_num" property="storeNum"/>
- <result column="plan_num" property="planNum"/>
- <result column="details" property="details"/>
- <result column="plan_scale" property="planScale"/>
- <result column="checker" property="checker"/>
- </resultMap>
- <sql id="dailyRecordInoutputColumns">
- id ,
- `type`,
- htype,
- recorder ,
- record_date ,
- `classes` ,
- record_num ,
- store_num ,
- plan_num ,
- details ,
- house_id,
- c_id ,
- c_time ,
- u_id ,
- u_time ,
- version,
- plan_scale,
- checker
- </sql>
- <sql id="dailyRecordInoutputJoins">
- </sql>
- <select id="get" resultMap="baseMap">
- SELECT
- <include refid="dailyRecordInoutputColumns"/>
- FROM daily_record_inoutput a
- <include refid="dailyRecordInoutputJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="getByUuid" resultMap="baseMap">
- SELECT
- <include refid="dailyRecordInoutputColumns"/>
- FROM daily_record_inoutput a
- <include refid="dailyRecordInoutputJoins"/>
- WHERE a.uuid = #{uuid}
- </select>
- <select id="findPlanNumList" resultMap="baseMap">
- SELECT distinct
- dri.plan_num
- FROM daily_record_inoutput dri
- left join house_info hou on dri.house_id = hou.id
- left join sys_grain gra on hou.grain_id = gra.id
- <where>
- <if test="grainId !=null and grainId !=''">
- and gra.id = #{grainId}
- </if>
- <if test="planNum !=null and planNum !=''">
- and dri.plan_num like '%${planNum}%'
- </if>
- </where>
- </select>
- <select id="findList" resultMap="baseMap">
- SELECT
- <include refid="dailyRecordInoutputColumns"/>
- FROM daily_record_inoutput a
- <include refid="dailyRecordInoutputJoins"/>
- <where>
- <if test="id !=null">
- and id = #{id}
- </if>
- <if test="type !=null">
- and `type` = #{type}
- </if>
- <if test="htype !=null">
- and `htype` = #{htype}
- </if>
- <if test="searchStartDate !=null">
- and record_date >= #{searchStartDate}
- </if>
- <if test="searchEndDate !=null">
- and record_date <= #{searchEndDate}
- </if>
- <if test="houseId !=null">
- and house_id = #{houseId}
- </if>
- <if test="checker !=null">
- and checker = #{checker}
- </if>
- <if test="cId !=null">
- and c_id = #{cId}
- </if>
- <if test="cTime !=null">
- and c_time = #{cTime}
- </if>
- <if test="uId !=null">
- and u_id = #{uId}
- </if>
- <if test="uTime !=null">
- and u_time = #{uTime}
- </if>
- <if test="version !=null">
- and version = #{version}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by id desc
- </otherwise>
- </choose>
- </select>
- <select id="findAllList" resultMap="baseMap">
- SELECT
- <include refid="dailyRecordInoutputColumns"/>
- FROM daily_record_inoutput a
- <include refid="dailyRecordInoutputJoins"/>
- <where>
- <if test="id !=null">
- and id = #{id}
- </if>
- <if test="type !=null">
- and `type` = #{type}
- </if>
- <if test="htype !=null">
- and `htype` = #{htype}
- </if>
- <if test="searchStartDate !=null">
- and record_date <![CDATA[ >= ]]> '#{searchStartDate}'
- </if>
- <if test="searchEndDate !=null">
- and record_date <= '#{searchEndDate}'
- </if>
- <if test="houseId !=null">
- and house_id = #{houseId}
- </if>
- <if test="checker !=null">
- and checker = #{checker}
- </if>
- <if test="cId !=null">
- and c_id = #{cId}
- </if>
- <if test="cTime !=null">
- and c_time = #{cTime}
- </if>
- <if test="uId !=null">
- and u_id = #{uId}
- </if>
- <if test="uTime !=null">
- and u_time = #{uTime}
- </if>
- <if test="version !=null">
- and version = #{version}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by id desc
- </otherwise>
- </choose>
- </select>
- <!--轮换统计分析所用字段-->
- <resultMap id="statisticPlanUsed" type="cn.ourwill.module.house.entity.daily.DailyRecordInoutput" extends="baseMap">
- <result column="grainName" property="grainName"/>
- <result column="planName" property="planName"/>
- <result column="planScale" property="planScale"/>
- <result column="number" property="number"/>
- <result column="inputCount" property="inputCount"/>
- <result column="outputCount" property="outputCount"/>
- <result column="houseNames" property="houseNames"/>
- <result column="input_time" property="inputTime"/>
- <result column="first_check_time" property="firstCheckTime"/>
- <result column="apply_check_time" property="applyCheckTime"/>
- <result column="check_time" property="checkTime"/>
- <result column="check_result" property="checkResult"/>
- </resultMap>
- <select id="findStaticOfInoutputByHouse" resultMap="statisticPlanUsed">
- select gra.`name` as grainName,
- dri.plan_num as planName,
- dri.plan_scale as planScale,
- hou.house_name as houseNames,
- drq.number as number,
- sum(case when dri.type = 0 then dri.record_num else 0 END) as outputCount,
- sum(case when dri.type = 1 then dri.record_num else 0 end) as inputCount,
- drq.input_time as input_time,
- drq.check_time as first_check_time,
- drq.apply_check_time as apply_check_time,
- drqa.check_time as check_time,
- drqa.check_result as check_result
- from daily_record_inoutput dri
- left join house_info hou on dri.house_id = hou.id
- left join sys_grain gra on hou.grain_id = gra.id
- left join daily_record_qualitycheck drq
- on drq.id = (select id from daily_record_qualitycheck where house_id = dri.house_id and type = '0' order by check_time desc limit 1)
- left join daily_record_qualitycheck drqa
- on drqa.id = (select id from daily_record_qualitycheck where house_id = dri.house_id and type = '1' order by check_time desc limit 1)
- where gra.`name` is not null
- <if test="grainId!=null and grainId!=''">
- and gra.id = #{grainId}
- </if>
- <if test="cityId!=null and cityId!=''">
- and gra.parentId = #{cityId}
- </if>
- <if test="searchDateStart !=null and searchDateStart!=''">
- and dri.record_date >= str_to_date(#{searchDateStart},'%Y-%m-%d')
- </if>
- <if test="searchDateEnd !=null and searchDateEnd!=''">
- and dri.record_date <str_to_date(#{searchDateEnd},'%Y-%m-%d')
- </if>
- group by gra.`name`,hou.house_name,dri.plan_num
- order by gra.id,dri.plan_num,CONCAT(GetNum(hou.house_name),hou.house_name)+0 asc
- </select>
- <select id="findStaticOfInoutputByGrain" resultMap="statisticPlanUsed">
- select gra.`name` as grainName,
- dri.plan_num as planName,
- dri.plan_scale as planScale,
- sum(case when dri.type = 0 then dri.record_num else 0 END) as outputCount,
- sum(case when dri.type = 1 then dri.record_num else 0 end) as inputCount
- from daily_record_inoutput dri
- left join house_info hou on dri.house_id = hou.id
- left join sys_grain gra on hou.grain_id = gra.id
- where gra.`name` is not null
- <if test="grainId!=null and grainId!=''">
- and gra.id = #{grainId}
- </if>
- <if test="planNum !=null and planNum!=''">
- and dri.plan_num = #{planNum}
- </if>
- group by gra.`name`,dri.plan_num
- order by dri.plan_num,CONCAT(GetNum(hou.house_name),hou.house_name)+0 asc
- </select>
- <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
- parameterType="cn.ourwill.module.house.entity.daily.DailyRecordInoutput">
- INSERT INTO daily_record_inoutput
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test=" id != null">
- id,
- </if>
- <if test=" uuid != null">
- uuid,
- </if>
- <if test="type != null">
- `type`,
- </if>
- <if test="htype != null">
- `htype`,
- </if>
- <if test=" recorder != null">
- recorder,
- </if>
- <if test=" recordDate != null">
- record_date,
- </if>
- <if test=" classes != null">
- classes,
- </if>
- <if test=" recordNum != null">
- record_num,
- </if>
- <if test=" storeNum != null">
- store_num,
- </if>
- <if test=" planNum != null">
- plan_num,
- </if>
- <if test=" details != null">
- details,
- </if>
- <if test="houseId != null">
- house_id,
- </if>
- <if test="checker !=null">
- checker,
- </if>
- <if test=" cId != null">
- c_id,
- </if>
- <if test=" cTime != null">
- c_time,
- </if>
- <if test=" uId != null">
- u_id,
- </if>
- <if test=" uTime != null">
- u_time,
- </if>
- <if test=" version != null">
- version,
- </if>
- <if test="planScale != null and planScale!=''">
- plan_scale
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test=" id != null">
- #{id},
- </if>
- <if test=" uuid != null">
- #{uuid},
- </if>
- <if test="type != null">
- #{type},
- </if>
- <if test="htype != null">
- #{htype},
- </if>
- <if test=" recorder != null">
- #{recorder},
- </if>
- <if test=" recordDate != null">
- #{recordDate},
- </if>
- <if test=" classes != null">
- #{classes},
- </if>
- <if test=" recordNum != null">
- #{recordNum},
- </if>
- <if test=" storeNum != null">
- #{storeNum},
- </if>
- <if test=" planNum != null">
- #{planNum},
- </if>
- <if test=" details != null">
- #{details},
- </if>
- <if test=" houseId != null">
- #{houseId},
- </if>
- <if test="checker !=null">
- #{checker},
- </if>
- <if test=" cId != null">
- #{cId},
- </if>
- <if test=" cTime != null">
- #{cTime},
- </if>
- <if test=" uId != null">
- #{uId},
- </if>
- <if test=" uTime != null">
- #{uTime},
- </if>
- <if test=" version != null">
- #{version},
- </if>
- <if test="planScale !=null and planScale!=''">
- #{planScale}
- </if>
- </trim>
- </insert>
- <update id="updateByUuid" parameterType="cn.ourwill.module.house.entity.daily.DailyRecordInoutput">
- UPDATE daily_record_inoutput <set>
- <if test="uuid != null">
- uuid=#{uuid},
- </if>
- <if test="type != null">
- `type` = #{type},
- </if>
- <if test="htype != null">
- `htype` = #{htype},
- </if>
- <if test="recorder !=null">
- recorder = #{recorder},
- </if>
- <if test="recordDate !=null">
- record_date = #{recordDate},
- </if>
- <if test="classes !=null">
- classes = #{classes},
- </if>
- <if test="recordNum !=null">
- record_num = #{recordNum},
- </if>
- <if test="storeNum !=null">
- store_num = #{storeNum},
- </if>
- <if test="planNum !=null">
- plan_num = #{planNum},
- </if>
- <if test="details !=null">
- details = #{details},
- </if>
- <if test="houseId !=null">
- house_id = #{houseId},
- </if>
- <if test="checker !=null">
- checker = #{checker},
- </if>
- <if test="cId !=null">
- c_id = #{cId},
- </if>
- <if test="cTime !=null">
- c_time = #{cTime},
- </if>
- <if test="uId !=null">
- u_id = #{uId},
- </if>
- <if test="uTime !=null">
- u_time = #{uTime},
- </if>
- <if test="version !=null">
- version = #{version},
- </if>
- <if test="planScale !=null and planScale!=''">
- plan_scale = #{planScale},
- </if>
- <if test="syncFlag !=null">
- sync_flag=#{syncFlag}
- </if>
- </set>
- WHERE uuid = #{uuid}
- </update>
- <update id="update" parameterType="cn.ourwill.module.house.entity.daily.DailyRecordInoutput">
- UPDATE daily_record_inoutput
- <set>
- <if test="type != null">
- `type` = #{type},
- </if>
- <if test="htype != null">
- `htype` = #{htype},
- </if>
- <if test="recorder !=null">
- recorder = #{recorder},
- </if>
- <if test="recordDate !=null">
- record_date = #{recordDate},
- </if>
- <if test="classes !=null">
- classes = #{classes},
- </if>
- <if test="recordNum !=null">
- record_num = #{recordNum},
- </if>
- <if test="storeNum !=null">
- store_num = #{storeNum},
- </if>
- <if test="planNum !=null">
- plan_num = #{planNum},
- </if>
- <if test="details !=null">
- details = #{details},
- </if>
- <if test="houseId !=null">
- house_id = #{houseId},
- </if>
- <if test="checker !=null">
- checker = #{checker},
- </if>
- <if test="cId !=null">
- c_id = #{cId},
- </if>
- <if test="cTime !=null">
- c_time = #{cTime},
- </if>
- <if test="uId !=null">
- u_id = #{uId},
- </if>
- <if test="uTime !=null">
- u_time = #{uTime},
- </if>
- <if test="version !=null">
- version = #{version},
- </if>
- <if test="planScale !=null and planScale!=''">
- plan_scale = #{planScale}
- </if>
- </set>
- WHERE id = #{id}
- </update>
- <update id="updateHistoryRecord" parameterType="cn.ourwill.module.house.entity.daily.DailyRecordInoutput">
- UPDATE daily_record_inoutput
- <set>
- <if test="type != null">
- `type` = #{type},
- </if>
- <if test="htype != null">
- `htype` = #{htype},
- </if>
- <if test="houseId !=null">
- house_id = #{houseId},
- </if>
- <if test="checker !=null">
- checker = #{checker},
- </if>
- <if test="cId !=null">
- c_id = #{cId},
- </if>
- <if test="cTime !=null">
- c_time = #{cTime},
- </if>
- <if test="uId !=null">
- u_id = #{uId},
- </if>
- <if test="uTime !=null">
- u_time = #{uTime},
- </if>
- <if test="version !=null">
- version = #{version}
- </if>
- </set>
- WHERE id <= #{id}
- </update>
- <delete id="deleteById" parameterType="java.lang.Long">
- DELETE FROM daily_record_inoutput
- WHERE id = #{id}
- </delete>
- <delete id="deleteByIds" parameterType="java.util.List">
- DELETE FROM daily_record_inoutput WHERE id IN
- <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </delete>
- <select id="findByHouseIdNoPage" resultMap="baseMap">
- SELECT *
- FROM daily_record_inoutput a
- where house_id=#{houseId}
- <if test="cTime != null">
- AND record_date <![CDATA[ <= ]]> #{cTime}
- </if>
- </select>
- <delete id="deleteInoutputByHouseId">
- DELETE FROM daily_record_inoutput
- WHERE house_id = #{houseId}
- <if test="cTime != null">
- AND record_date <![CDATA[ <= ]]> #{cTime}
- </if>
- </delete>
- <select id="getLastOutYearByHouseId" resultMap="baseMap">
- SELECT *
- FROM daily_record_inoutput a
- where house_id=#{houseId} and type=0
- ORDER by a.record_date DESC,a.id DESC
- limit 1
- </select>
- </mapper>
|