123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?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.vber.breeding.mapper.CoopBatchReportDetailMapper">
- <resultMap id="statisticResultVo" type="cn.vber.breeding.domain.vo.statistic.CoopBatchChickenStatisticResultVo">
- <id property="coopId" column="coop_id"/>
- <result property="batchNum" column="batch_num"/>
- <result property="chickenCount" column="chicken_count"/>
- </resultMap>
- <resultMap id="statisticEggResultVo" type="cn.vber.breeding.domain.vo.statistic.CoopBatchEggStatisticResultVo">
- <id property="coopId" column="coop_id"/>
- <result property="batchNum" column="batch_num"/>
- <result property="eggCount" column="egg_count"/>
- <result property="eggType" column="egg_type"/>
- </resultMap>
- <resultMap id="statisticDayResultVo" type="cn.vber.breeding.domain.vo.statistic.ChickenStatisticDayResultVo">
- <id property="coopId" column="coop_id"/>
- <result property="batchNum" column="batch_num"/>
- <result property="reportDate" column="report_date"/>
- <result property="reportCycle" column="report_cycle"/>
- </resultMap>
- <resultMap id="CoopBatchReportDetailView" type="cn.vber.breeding.domain.vo.report.CoopBatchReportDetailView">
- <result property="reportId" column="report_id"/>
- <result property="coopId" column="coop_id"/>
- <result property="batchNum" column="batch_num"/>
- <result property="lastSave0" column="last_save0"/>
- <result property="lastSave1" column="last_save1"/>
- <result property="qualifiedEgg" column="qualified_egg"/>
- <result property="deformedEgg" column="deformed_egg"/>
- <result property="breakEgg" column="break_egg"/>
- <result property="eggProductionRate" column="egg_production_rate"/>
- <result property="eggPassRate" column="egg_pass_rate"/>
- <result property="cullRate" column="cull_rate"/>
- <result property="lifeRate" column="life_rate"/>
- <result property="reportDate" column="report_date"/>
- <result property="reportCycle" column="report_cycle"/>
- <result property="batchName" column="batch_name"/>
- <result property="hatchDate" column="hatch_date"/>
- <result property="coopNum" column="coop_num"/>
- <result property="coopName" column="coop_name"/>
- <result property="coopType" column="coop_type"/>
- </resultMap>
- <select id="selectCullCount"
- resultMap="statisticResultVo">
- SELECT
- coop.id AS coop_id,
- fc.batch_num,
- fc.gender,
- count(fc.id) as chicken_count
- FROM
- f_chicken AS fc
- LEFT JOIN
- f_chicken_cage AS fcc
- ON
- fc.cage_id = fcc.id
- LEFT JOIN
- f_chicken_coop AS coop
- ON
- fcc.chicken_coop_id = coop.id
- WHERE
- fc.`status` = 1 and fc.cull_time between #{startDate} and #{endDate} and coop.coop_type = #{coopType}
- GROUP BY
- fc.batch_num,
- coop.id,
- fc.gender
- </select>
- <select id="selectChickenCount"
- resultMap="statisticResultVo">
- SELECT
- coop.id AS coop_id,
- fc.batch_num,
- fc.gender,
- count(fc.id) as chicken_count
- FROM
- f_chicken AS fc
- LEFT JOIN
- f_chicken_cage AS fcc
- ON
- fc.cage_id = fcc.id
- LEFT JOIN
- f_chicken_coop AS coop
- ON
- fcc.chicken_coop_id = coop.id
- WHERE
- fc.`status` = 0 and (fc.cage_id != NULL or fc.cage_id !='') and coop.coop_type = #{coopType}
- GROUP BY
- fc.batch_num,
- coop.id,
- fc.gender
- </select>
- <select id="selectChickenCountDay"
- resultMap="statisticDayResultVo">
- SELECT
- fcbre.coop_id,
- fcbre.batch_num,
- fcbre.save_0 as save0,
- fcbre.save_1 as save1,
- fcbre.chicken_0 as chicken0,
- fcbre.chicken_1 as chicken1,
- fcbre.report_date,
- fcbre.report_cycle
- FROM
- f_coop_batch_report_detail AS fcbre
- INNER JOIN
- f_chicken_coop AS coop
- ON
- fcbre.coop_id = coop.id
- WHERE
- fcbre.del_flag = 0 AND
- fcbre.report_cycle = 'D' AND
- fcbre.report_date BETWEEN #{startDate} AND #{endDate} and coop.coop_type = #{coopType}
- </select>
- <select id="selectChickenIn"
- resultMap="statisticResultVo">
- SELECT
- fc.batch_num AS batch_num,
- fc.gender AS gender,
- count(fcc.chicken_id) AS chicken_count,
- coop.id as coop_id
- FROM
- (SELECT f_cage_change.target_cage_id AS target_cage_id, f_cage_change.chicken_id AS chicken_id
- FROM f_cage_change WHERE f_cage_change.bind_time BETWEEN #{startDate} and #{endDate}
- and f_cage_change.status = 1 and f_cage_change.cross_coop = 1) as fcc
- LEFT JOIN f_chicken AS fc ON fcc.chicken_id = fc.id
- LEFT JOIN f_chicken_cage AS fca ON fcc.target_cage_id = fca.id
- LEFT JOIN f_chicken_coop AS coop ON fca.chicken_coop_id = coop.id
- where coop.coop_type = #{coopType}
- GROUP BY
- fc.batch_num,
- coop.id,
- fc.gender
- </select>
- <select id="selectChickenOut"
- resultMap="statisticResultVo">
- SELECT
- fc.batch_num AS batch_num,
- fc.gender AS gender,
- count(fcc.chicken_id) AS chicken_count,
- coop.id as coop_id
- FROM
- (SELECT f_cage_change.source_cage_id AS source_cage_id, f_cage_change.chicken_id AS chicken_id
- FROM f_cage_change WHERE f_cage_change.bind_time BETWEEN #{startDate} and #{endDate}
- and f_cage_change.status = 1 and f_cage_change.cross_coop=1
- and (source_cage_id != NULL or source_cage_id>0)) as fcc
- LEFT JOIN f_chicken AS fc ON fcc.chicken_id = fc.id
- LEFT JOIN f_chicken_cage AS fca ON fcc.source_cage_id = fca.id
- LEFT JOIN f_chicken_coop AS coop ON fca.chicken_coop_id = coop.id
- where coop.coop_type = #{coopType}
- GROUP BY
- fc.batch_num,
- coop.id,
- fc.gender
- </select>
- <select id="selectStatisticEgg" resultMap="statisticEggResultVo">
- SELECT
- cage.chicken_coop_id as coop_id,
- fc.batch_num,
- egg.egg_type,
- SUM(egg.egg_count) as egg_count
- FROM
- f_breeding_egg AS egg
- INNER JOIN
- f_chicken_cage AS cage
- ON
- egg.cage_id = cage.id
- INNER JOIN
- f_chicken AS fc
- ON
- egg.female_chicken_id = fc.id
- INNER JOIN
- f_chicken_coop AS coop
- ON
- cage.chicken_coop_id = coop.id
- WHERE
- egg.del_flag = '0' AND
- egg.lay_date BETWEEN #{startDate} AND #{endDate}
- and coop.coop_type = #{coopType}
- GROUP BY
- fc.batch_num,
- cage.chicken_coop_id,
- egg.egg_type
- </select>
- <select id="selectCoopBatchReportDetail" resultMap="CoopBatchReportDetailView">
- SELECT
- detail.id,
- detail.report_id,
- detail.coop_id,
- detail.batch_num,
- detail.last_save0,
- detail.last_save1,
- detail.save0,
- detail.save1,
- detail.cull0,
- detail.cull1,
- detail.in0,
- detail.in1,
- detail.out0,
- detail.out1,
- detail.qualified_egg,
- detail.deformed_egg,
- detail.break_egg,
- detail.egg_production_rate,
- detail.egg_pass_rate,
- detail.chicken0,
- detail.chicken1,
- detail.cull_rate,
- detail.life_rate,
- detail.report_date,
- detail.report_cycle,
- batch.batch_name,
- batch.hatch_date,
- coop.coop_num,
- coop.coop_name,
- coop.coop_type
- FROM
- f_coop_batch_report_detail AS detail
- LEFT JOIN
- f_batch AS batch
- ON
- detail.batch_num = batch.batch_num
- LEFT JOIN
- f_chicken_coop AS coop
- ON
- detail.coop_id = coop.id
- WHERE
- detail.del_flag = '0'
- AND detail.report_id = #{report_id}
- <if test="coop_type != null">
- and coop.coop_type = #{coop_type}
- </if>
- </select>
- </mapper>
|