1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?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="com.huimv.admin.system.mapper.FeedEggDetailMapper">
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, date, unit_name, stock, egg_production, lay_egg_rate, total_egg_weight, avg_weight, total_feed_consume, feed_egg_ratio
- </sql>
- <select id="listPrint" resultType="com.huimv.admin.system.entity.FeedEggVo">
- SELECT
- e.date,
- e.total_egg_weight AS 'totalEggWeight',
- COALESCE(ROUND(u.total_feed_consume / 1000, 2), 0) AS 'totalFeedConsume',
- ROUND(CASE WHEN e.egg_production = 0 THEN 0 ELSE u.total_feed_consume / e.egg_production END, 2) AS 'totalFeedEggRate'
- FROM
- (SELECT
- DATE AS DATE,
- SUM(total_weight) AS total_egg_weight,
- SUM(egg_production) AS egg_production
- FROM
- `lay_egg`
- GROUP BY
- DATE) e
- LEFT JOIN
- (SELECT
- used_date AS DATE,
- SUM(total_consume) AS total_feed_consume
- FROM
- `feed_usage`
- GROUP BY
- used_date) u
- ON
- e.date = u.date
- <if test="startDate != null and startDate != ''">
- WHERE e.date BETWEEN '${startDate}' AND '${endDate}'
- </if>
- ORDER BY
- e.date ASC
- </select>
- </mapper>
|