|
@@ -46,41 +46,23 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="breedingRank" resultType="com.huimv.guowei.admin.group.entity.vo.BreedingVo">
|
|
|
- SELECT
|
|
|
- z.device_code deviceCode,
|
|
|
- COALESCE(q.eggMonth, 0) AS eggMonth,
|
|
|
- CAST(COALESCE(w.feedingMonth, 0) AS DECIMAL(10,2)) AS feedingMonth
|
|
|
-FROM group_duck_info z
|
|
|
-LEFT JOIN (
|
|
|
- SELECT
|
|
|
- device_code,
|
|
|
- SUM(CASE WHEN egg_date >= #{month} THEN egg_num ELSE 0 END) AS eggMonth
|
|
|
- FROM group_egg
|
|
|
- WHERE farm_id = #{farmId}
|
|
|
- GROUP BY device_code
|
|
|
-) q ON z.device_code = q.device_code
|
|
|
-LEFT JOIN (
|
|
|
- SELECT
|
|
|
- device_code,
|
|
|
- SUM(CASE WHEN eating_date >= #{month} THEN eating_value ELSE 0 END) AS feedingMonth
|
|
|
- FROM group_eating_generate
|
|
|
- WHERE farm_id = #{farmId}
|
|
|
- GROUP BY device_code
|
|
|
-) w ON z.device_code = w.device_code
|
|
|
-WHERE z.farm_id = #{farmId}
|
|
|
-GROUP BY z.device_code;
|
|
|
+ select c.device_code,SUM(CASE WHEN a.egg_date >= #{month} THEN egg_num ELSE 0 END) AS eggMonth
|
|
|
+ ,convert(SUM(CASE WHEN b.eating_date >= #{month} THEN eating_value ELSE 0 END),decimal(10,2)) AS feedingMonth from group_duck_info c
|
|
|
+ INNER JOIN group_egg a ON c.device_code=a.device_code
|
|
|
+ INNER JOIN group_eating_generate b ON c.device_code=b.device_code
|
|
|
+GROUP BY c.device_code
|
|
|
|
|
|
</select>
|
|
|
<select id="breedingRank1" resultType="com.huimv.guowei.admin.group.entity.vo.BreedingVo">
|
|
|
- select IFNULL(q.eggDay,'0') 'eggDay',IFNULL(w.feedingDay,'0') 'feedingDay',z.deviceCode 'deviceCode',IFNULL(q.eggCount,'0') 'eggCount',IFNULL(q.eggMonth,'0')
|
|
|
+ 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
|
|
|
+ ,z.dayAge 'dayAge',z.unitId 'unitId',z.unitName 'unitName',z.batchNum 'batchNum' 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}
|
|
|
+ IFNULL(sum(case when g.egg_date >=#{month} then g.egg_num else 0 END),'0') as 'eggMonth' from
|
|
|
+ group_egg g
|
|
|
GROUP BY device_code) q
|
|
|
|
|
|
RIGHT JOIN
|
|
@@ -90,14 +72,14 @@ GROUP BY z.device_code;
|
|
|
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_generate b WHERE farm_id=#{farmId}
|
|
|
+ FROM group_eating_generate b
|
|
|
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
|
|
|
+ (select device_code 'deviceCode',unit_id 'unitId',unit_name 'unitName',day_num 'dayAge',batch_num
|
|
|
+ 'batchNum' FROM group_duck_info GROUP BY device_code) z
|
|
|
|
|
|
on w.deviceCode=z.deviceCode
|
|
|
|