<?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="vip.xiaonuo.modular.feed.feedinglist.mapper.FeedingListMapper">

    <select id="listFeed" resultType="vip.xiaonuo.modular.feed.feedinglist.vo.FeedingListVo">
SELECT a.unit_id 'unitId',a.unit_name 'unitName',a.margin_value 'value' FROM `feeding_list` a
INNER JOIN(
select unit_id,max(upload_time) upload_time FROM feeding_list
${ew.customSqlSegment}
GROUP BY unit_id
) b
ON a.upload_time=b.upload_time
</select>

    <select id="feedList" resultType="vip.xiaonuo.modular.feed.feedinglist.vo.FeedingListVo2">
 SELECT unit_id 'unitId',unit_name 'unitName',IFNULL(sum(feed_value),'0') 'feedValue',IFNULL(sum(margin_value),'0') 'marginValue',create_time 'createTime' FROM feeding_list
    ${ew.customSqlSegment}
    group BY DATE_FORMAT(create_time,'%Y-%m-%d')
    ORDER BY create_time ASC
</select>
</mapper>