|
@@ -3,61 +3,142 @@
|
|
|
<mapper namespace="com.huimv.guowei.admin.group.mapper.GroupDuckInfoMapper">
|
|
|
|
|
|
<select id="breedingList" resultType="com.huimv.guowei.admin.group.entity.vo.BreedingVo">
|
|
|
- select a.id 'id',a.deviceCode 'deviceCode',a.dayAge 'dayAge',a.unitId 'unitId',a.unitName 'unitName',a.batchNum 'batchNum',IFNULL(g.egg_count,'0') 'eggCount'
|
|
|
- ,CONVERT(IFNULL(sum(case when b.eating_date >= #{today} then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingDay',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date >= #{month} then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingMonth'
|
|
|
- ,IFNULL(sum(case when g.egg_date >= #{today} then g.egg_num else 0 END),'0') as 'eggDay',
|
|
|
- IFNULL(sum(case when g.egg_date >= #{month} then g.egg_num else 0 END),'0') as 'eggMonth',
|
|
|
- IFNULL(sum(b.eating_value),'0') 'feedingCount'
|
|
|
- FROM group_eating b RIGHT JOIN
|
|
|
-(select id 'id',device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num 'batchNum' FROM group_duck_info where farm_id=#{farmId}
|
|
|
+ select IFNULL(q.eggDay,'0') 'eggDay',IFNULL(w.feedingDay,'0') 'feedingDay',z.deviceCode
|
|
|
+ 'deviceCode',IFNULL(q.eggCount,'0') 'eggCount',IFNULL(q.eggMonth,'0')
|
|
|
+ 'eggMonth',
|
|
|
+ convert(IFNULL(w.feedingCount,'0'),decimal(10,2)) 'feedingCount',convert(IFNULL(w.feedingMonth,'0'),decimal(10,2)) 'feedingMonth'
|
|
|
+ ,z.dayAge 'dayAge',z.unitId 'unitId',z.unitName 'unitName',z.batchNum 'batchNum',z.id 'id' FROM
|
|
|
+
|
|
|
+ (select g.device_code 'deviceCode', max(g.egg_count) 'eggCount',
|
|
|
+ IFNULL(sum(case when g.egg_date >= #{today} then g.egg_num else 0 END),'0') as 'eggDay',
|
|
|
+ IFNULL(sum(case when g.egg_date >= #{month} then g.egg_num else 0 END),'0') as 'eggMonth' from
|
|
|
+ group_egg g where farm_id=#{farmId}
|
|
|
+ <if test="deviceCode!=null and deviceCode!=''">
|
|
|
+ and device_code like '%${deviceCode}'
|
|
|
+ </if>
|
|
|
+ GROUP BY device_code) q
|
|
|
+
|
|
|
+ RIGHT JOIN
|
|
|
+
|
|
|
+ (select b.device_code 'deviceCode',CONVERT(IFNULL(sum(case when b.eating_date >= #{today} then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingDay',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date >= #{month} then b.eating_value else 0
|
|
|
+ END),'0'),DECIMAL(10,2)) as 'feedingMonth'
|
|
|
+ ,IFNULL(sum(b.eating_value),'0') 'feedingCount'
|
|
|
+ FROM group_eating b WHERE farm_id=#{farmId}
|
|
|
+ <if test="deviceCode!=null and deviceCode!=''">
|
|
|
+ and device_code like '%${deviceCode}'
|
|
|
+ </if>
|
|
|
+ GROUP BY device_code) w
|
|
|
+ on q.deviceCode=w.deviceCode
|
|
|
+
|
|
|
+ RIGHT JOIN
|
|
|
+
|
|
|
+ (select id 'id', device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num
|
|
|
+ 'batchNum' FROM group_duck_info where farm_id=#{farmId}
|
|
|
<if test="deviceCode!=null and deviceCode!=''">
|
|
|
- and device_code like '%${deviceCode}%'
|
|
|
+ and device_code like '%${deviceCode}'
|
|
|
</if>
|
|
|
- ) a ON a.deviceCode=b.device_code and a.batchNum=b.batch_num
|
|
|
-LEFT JOIN group_egg g ON a.deviceCode=g.device_code and a.batchNum=g.batch_num
|
|
|
-GROUP BY a.id
|
|
|
+ GROUP BY device_code) z
|
|
|
+
|
|
|
+ on w.deviceCode=z.deviceCode
|
|
|
+
|
|
|
</select>
|
|
|
|
|
|
<select id="breedingRank" resultType="com.huimv.guowei.admin.group.entity.vo.BreedingVo">
|
|
|
- select a.id 'id',a.deviceCode 'deviceCode',a.dayAge 'dayAge',a.unitId 'unitId',a.unitName 'unitName',a.batchNum 'batchNum',IFNULL(g.egg_count,'0') 'eggCount'
|
|
|
- ,CONVERT(IFNULL(sum(case when b.eating_date >= #{today} then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingDay',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date >= #{month} then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingMonth'
|
|
|
- ,IFNULL(sum(case when g.egg_date >= #{today} then g.egg_num else 0 END),'0') as 'eggDay',
|
|
|
- IFNULL(sum(case when g.egg_date >= #{month} then g.egg_num else 0 END),'0') as 'eggMonth',
|
|
|
- IFNULL(sum(b.eating_value),'0') 'feedingCount'
|
|
|
- FROM group_eating b RIGHT JOIN
|
|
|
- (select id 'id',device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num 'batchNum' FROM group_duck_info
|
|
|
- ) a ON a.deviceCode=b.device_code
|
|
|
- LEFT JOIN group_egg g ON a.deviceCode=g.device_code
|
|
|
- GROUP BY a.id
|
|
|
+ select IFNULL(q.eggDay,'0') 'eggDay',IFNULL(w.feedingDay,'0') 'feedingDay',z.deviceCode 'deviceCode',IFNULL(q.eggCount,'0') 'eggCount',IFNULL(q.eggMonth,'0')
|
|
|
+ 'eggMonth',
|
|
|
+ convert(IFNULL(w.feedingCount,'0'),decimal(10,2)) 'feedingCount',convert(IFNULL(w.feedingMonth,'0'),decimal(10,2)) 'feedingMonth'
|
|
|
+ ,z.dayAge 'dayAge',z.unitId 'unitId',z.unitName 'unitName',z.batchNum 'batchNum',z.id 'id',z.deviceCode 'deviceCode' FROM
|
|
|
+
|
|
|
+ (select g.device_code 'deviceCode', max(g.egg_count) 'eggCount',
|
|
|
+ IFNULL(sum(case when g.egg_date >= #{today} then g.egg_num else 0 END),'0') as 'eggDay',
|
|
|
+ IFNULL(sum(case when g.egg_date >= #{month} then g.egg_num else 0 END),'0') as 'eggMonth' from
|
|
|
+ group_egg g where farm_id=#{farmId}
|
|
|
+ GROUP BY device_code) q
|
|
|
+
|
|
|
+ RIGHT JOIN
|
|
|
+
|
|
|
+ (select b.device_code 'deviceCode',CONVERT(IFNULL(sum(case when b.eating_date >= #{today} then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingDay',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date >= #{month} then b.eating_value else 0
|
|
|
+ END),'0'),DECIMAL(10,2)) as 'feedingMonth'
|
|
|
+ ,IFNULL(sum(b.eating_value),'0') 'feedingCount'
|
|
|
+ FROM group_eating b WHERE farm_id=#{farmId}
|
|
|
+ GROUP BY device_code) w
|
|
|
+ on q.deviceCode=w.deviceCode
|
|
|
+
|
|
|
+ RIGHT JOIN
|
|
|
+
|
|
|
+ (select id 'id', device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num
|
|
|
+ 'batchNum' FROM group_duck_info where farm_id=#{farmId} GROUP BY device_code) z
|
|
|
+
|
|
|
+ on w.deviceCode=z.deviceCode
|
|
|
+
|
|
|
</select>
|
|
|
|
|
|
<select id="breedingList1" resultType="com.huimv.guowei.admin.group.entity.vo.BreedingVo">
|
|
|
- select a.id 'id',a.deviceCode 'deviceCode',a.dayAge 'dayAge',a.unitId 'unitId',a.unitName 'unitName',a.batchNum 'batchNum',IFNULL(g.egg_count,'0') 'eggCount'
|
|
|
- ,CONVERT(IFNULL(sum(case when b.eating_date >= #{today} then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingDay',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date >= #{month} then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingMonth'
|
|
|
- ,IFNULL(sum(case when g.egg_date >= #{today} then g.egg_num else 0 END),'0') as 'eggDay',
|
|
|
- IFNULL(sum(case when g.egg_date >= #{month} then g.egg_num else 0 END),'0') as 'eggMonth',
|
|
|
- IFNULL(sum(b.eating_value),'0') 'feedingCount'
|
|
|
- FROM group_eating b RIGHT JOIN
|
|
|
-(select id 'id',device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num 'batchNum' FROM group_duck_info where farm_id=#{farmId}
|
|
|
-and device_code like '%${deviceCode}%') a ON a.deviceCode=b.device_code
|
|
|
-LEFT JOIN group_egg g ON a.deviceCode=g.device_code
|
|
|
-GROUP BY a.id
|
|
|
+ select IFNULL(q.eggDay,'0') 'eggDay',IFNULL(w.feedingDay,'0') 'feedingDay',z.deviceCode 'deviceCode',IFNULL(q.eggCount,'0') 'eggCount',IFNULL(q.eggMonth,'0')
|
|
|
+ 'eggMonth',
|
|
|
+ convert(IFNULL(w.feedingCount,'0'),decimal(10,2)) 'feedingCount',convert(IFNULL(w.feedingMonth,'0'),decimal(10,2)) 'feedingMonth'
|
|
|
+ ,z.dayAge 'dayAge',z.unitId 'unitId',z.unitName 'unitName',z.batchNum 'batchNum',z.id 'id' FROM
|
|
|
+
|
|
|
+ (select g.device_code 'deviceCode', max(g.egg_count) 'eggCount',
|
|
|
+ IFNULL(sum(case when g.egg_date >= #{today} then g.egg_num else 0 END),'0') as 'eggDay',
|
|
|
+ IFNULL(sum(case when g.egg_date >= #{month} then g.egg_num else 0 END),'0') as 'eggMonth' from
|
|
|
+ group_egg g where farm_id=#{farmId} and device_code = '${deviceCode}'
|
|
|
+ GROUP BY device_code) q
|
|
|
+
|
|
|
+ RIGHT JOIN
|
|
|
+
|
|
|
+ (select b.device_code 'deviceCode',CONVERT(IFNULL(sum(case when b.eating_date >= #{today} then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingDay',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date >= #{month} then b.eating_value else 0
|
|
|
+ END),'0'),DECIMAL(10,2)) as 'feedingMonth'
|
|
|
+ ,IFNULL(sum(b.eating_value),'0') 'feedingCount'
|
|
|
+ FROM group_eating b WHERE farm_id=#{farmId} and device_code = '${deviceCode}'
|
|
|
+ GROUP BY device_code) w
|
|
|
+ on q.deviceCode=w.deviceCode
|
|
|
+
|
|
|
+ RIGHT JOIN
|
|
|
+
|
|
|
+ (select id 'id', device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num
|
|
|
+ 'batchNum' FROM group_duck_info where farm_id=#{farmId} and device_code = '${deviceCode}' GROUP BY device_code) z
|
|
|
+
|
|
|
+ on w.deviceCode=z.deviceCode
|
|
|
+
|
|
|
</select>
|
|
|
<select id="breedingList2" resultType="com.huimv.guowei.admin.group.entity.vo.BreedingVo">
|
|
|
- select a.id 'id',a.deviceCode 'deviceCode',a.dayAge 'dayAge',a.unitId 'unitId',a.unitName 'unitName',a.batchNum 'batchNum',IFNULL(g.egg_count,'0') 'eggCount'
|
|
|
- ,CONVERT(IFNULL(sum(case when b.eating_date >= #{today} then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingDay',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date >= #{month} then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingMonth'
|
|
|
- ,IFNULL(sum(case when g.egg_date >= #{today} then g.egg_num else 0 END),'0') as 'eggDay',
|
|
|
- IFNULL(sum(case when g.egg_date >= #{month} then g.egg_num else 0 END),'0') as 'eggMonth',
|
|
|
- IFNULL(sum(b.eating_value),'0') 'feedingCount'
|
|
|
- FROM group_eating b RIGHT JOIN
|
|
|
-(select id 'id', device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num 'batchNum' FROM group_duck_info where farm_id=#{farmId}
|
|
|
-and device_code like '%${deviceCode}%') a ON a.deviceCode=b.device_code
|
|
|
-LEFT JOIN group_egg g ON a.deviceCode=g.device_code
|
|
|
-GROUP BY a.id
|
|
|
+ select IFNULL(q.eggDay,'0') 'eggDay',convert(IFNULL(w.feedingDay,'0'),decimal(10,2)) 'feedingDay',z.deviceCode 'deviceCode',IFNULL(q.eggCount,'0') 'eggCount',IFNULL(q.eggMonth,'0')
|
|
|
+ 'eggMonth',
|
|
|
+ convert(IFNULL(w.feedingCount,'0'),decimal(10,2)) 'feedingCount',convert(IFNULL(w.feedingMonth,'0'),decimal(10,2)) 'feedingMonth'
|
|
|
+ ,z.dayAge 'dayAge',z.unitId 'unitId',z.unitName 'unitName',z.batchNum 'batchNum',z.id 'id' FROM
|
|
|
+
|
|
|
+ (select g.device_code 'deviceCode', max(g.egg_count) 'eggCount',
|
|
|
+ IFNULL(sum(case when g.egg_date >= #{today} then g.egg_num else 0 END),'0') as 'eggDay',
|
|
|
+ IFNULL(sum(case when g.egg_date >= #{month} then g.egg_num else 0 END),'0') as 'eggMonth' from
|
|
|
+ group_egg g where farm_id=#{farmId} and device_code = '${deviceCode}'
|
|
|
+ GROUP BY device_code) q
|
|
|
+
|
|
|
+ RIGHT JOIN
|
|
|
+
|
|
|
+ (select b.device_code 'deviceCode',CONVERT(IFNULL(sum(case when b.eating_date >= #{today} then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingDay',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date >= #{month} then b.eating_value else 0
|
|
|
+ END),'0'),DECIMAL(10,2)) as 'feedingMonth'
|
|
|
+ ,IFNULL(sum(b.eating_value),'0') 'feedingCount'
|
|
|
+ FROM group_eating b WHERE farm_id=#{farmId} and device_code = '${deviceCode}'
|
|
|
+ GROUP BY device_code) w
|
|
|
+ on q.deviceCode=w.deviceCode
|
|
|
+
|
|
|
+ RIGHT JOIN
|
|
|
+
|
|
|
+ (select id 'id', device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num
|
|
|
+ 'batchNum' FROM group_duck_info where farm_id=#{farmId} and device_code = '${deviceCode}' GROUP BY device_code) z
|
|
|
+
|
|
|
+ on w.deviceCode=z.deviceCode
|
|
|
+
|
|
|
+
|
|
|
</select>
|
|
|
|
|
|
<update id="updateDayAge">
|
|
@@ -65,42 +146,69 @@ GROUP BY a.id
|
|
|
</update>
|
|
|
|
|
|
<select id="getOutDuckInfo" resultType="com.huimv.guowei.admin.group.entity.vo.GroupDuckInfoOutVo">
|
|
|
- select a.deviceCode 'deviceCode',a.batchNum 'batchNum',a.duckBreed 'duckBreed',a.sex 'sex',a.birthDate 'birthDate'
|
|
|
- ,a.weight 'weight',a.unitName 'unitName',CONVERT(IFNULL(sum(b.eating_value),'0'),decimal(10,2)) as 'feedingCount',
|
|
|
+ select a.deviceCode 'deviceCode',a.batchNum 'batchNum',a.duckBreed 'duckBreed',a.sex 'sex',a.birthDate
|
|
|
+ 'birthDate'
|
|
|
+ ,a.weight 'weight',a.unitName 'unitName',CONVERT(IFNULL(sum(b.eating_value),'0'),decimal(10,2)) as
|
|
|
+ 'feedingCount',
|
|
|
IFNULL(sum(d.egg_num),'0') as 'eggCount',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month1}-01 00:00:00' and '${month1}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue1',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month2}-01 00:00:00' and '${month2}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue2',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month3}-01 00:00:00' and '${month3}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue3',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month4}-01 00:00:00' and '${month4}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue4',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month5}-01 00:00:00' and '${month5}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue5',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month6}-01 00:00:00' and '${month6}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue6',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month7}-01 00:00:00' and '${month7}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue7',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month8}-01 00:00:00' and '${month8}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue8',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month9}-01 00:00:00' and '${month9}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue9',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month10}-01 00:00:00' and '${month10}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue10',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month11}-01 00:00:00' and '${month11}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue11',
|
|
|
- CONVERT(IFNULL(sum(case when b.eating_date between '${month12}-01 00:00:00' and '${month12}-31 23:59:59' then b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue12',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month1}-01 00:00:00' and '${month1}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue1',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month2}-01 00:00:00' and '${month2}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue2',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month3}-01 00:00:00' and '${month3}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue3',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month4}-01 00:00:00' and '${month4}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue4',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month5}-01 00:00:00' and '${month5}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue5',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month6}-01 00:00:00' and '${month6}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue6',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month7}-01 00:00:00' and '${month7}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue7',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month8}-01 00:00:00' and '${month8}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue8',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month9}-01 00:00:00' and '${month9}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue9',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month10}-01 00:00:00' and '${month10}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue10',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month11}-01 00:00:00' and '${month11}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue11',
|
|
|
- IFNULL(sum(case when d.egg_date between '${month12}-01 00:00:00' and '${month12}-31 23:59:59' then d.egg_num else 0 END),'0') as 'eggValue12'
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month1}-01 00:00:00' and '${month1}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue1',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month2}-01 00:00:00' and '${month2}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue2',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month3}-01 00:00:00' and '${month3}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue3',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month4}-01 00:00:00' and '${month4}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue4',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month5}-01 00:00:00' and '${month5}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue5',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month6}-01 00:00:00' and '${month6}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue6',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month7}-01 00:00:00' and '${month7}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue7',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month8}-01 00:00:00' and '${month8}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue8',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month9}-01 00:00:00' and '${month9}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue9',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month10}-01 00:00:00' and '${month10}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue10',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month11}-01 00:00:00' and '${month11}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue11',
|
|
|
+ CONVERT(IFNULL(sum(case when b.eating_date between '${month12}-01 00:00:00' and '${month12}-31 23:59:59' then
|
|
|
+ b.eating_value else 0 END),'0'),DECIMAL(10,2)) as 'feedingValue12',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month1}-01 00:00:00' and '${month1}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue1',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month2}-01 00:00:00' and '${month2}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue2',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month3}-01 00:00:00' and '${month3}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue3',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month4}-01 00:00:00' and '${month4}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue4',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month5}-01 00:00:00' and '${month5}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue5',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month6}-01 00:00:00' and '${month6}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue6',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month7}-01 00:00:00' and '${month7}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue7',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month8}-01 00:00:00' and '${month8}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue8',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month9}-01 00:00:00' and '${month9}-31 23:59:59' then d.egg_num else
|
|
|
+ 0 END),'0') as 'eggValue9',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month10}-01 00:00:00' and '${month10}-31 23:59:59' then d.egg_num
|
|
|
+ else 0 END),'0') as 'eggValue10',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month11}-01 00:00:00' and '${month11}-31 23:59:59' then d.egg_num
|
|
|
+ else 0 END),'0') as 'eggValue11',
|
|
|
+ IFNULL(sum(case when d.egg_date between '${month12}-01 00:00:00' and '${month12}-31 23:59:59' then d.egg_num
|
|
|
+ else 0 END),'0') as 'eggValue12'
|
|
|
FROM group_eating b RIGHT JOIN
|
|
|
-(select device_code 'deviceCode',chi_code 'chiCode',batch_num 'batchNum',unit_name 'unitName',duck_breed 'duckBreed',sex 'sex',birth_date 'birthDate',weight 'weight'
|
|
|
-FROM group_duck_info
|
|
|
-where farm_id=#{farmId} and id IN
|
|
|
- <foreach collection="deviceCode" item="farmMenu" open="(" separator="," close=")">
|
|
|
+ (select device_code 'deviceCode',chi_code 'chiCode',batch_num 'batchNum',unit_name 'unitName',duck_breed
|
|
|
+ 'duckBreed',sex 'sex',birth_date 'birthDate',weight 'weight'
|
|
|
+ FROM group_duck_info
|
|
|
+ where farm_id=#{farmId} and id IN
|
|
|
+ <foreach collection="deviceCode" item="farmMenu" open="(" separator="," close=")">
|
|
|
#{farmMenu}
|
|
|
</foreach>) a ON a.deviceCode=b.device_code
|
|
|
-LEFT JOIN group_egg d ON a.deviceCode=d.device_code
|
|
|
-GROUP BY a.deviceCode
|
|
|
+ LEFT JOIN group_egg d ON a.deviceCode=d.device_code
|
|
|
+ GROUP BY a.deviceCode
|
|
|
</select>
|
|
|
|
|
|
|