feat(module): 饲喂量统计

+ 添加量饲喂量统计功能
+ 解决了其他两个页面的若干逻辑错误
+ 优化了配料清单的缓存结构:
    + 将缓存和同步过程移动到Service层, 以便其他模块调用
This commit is contained in:
2025-08-24 23:40:21 +08:00
parent 02634eb7b6
commit 02d95fc51f
14 changed files with 881 additions and 125 deletions

View File

@@ -20,6 +20,7 @@
<include refid="selectSgFeedListVo"/>
<where>
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
<if test="formulaBatchId != null and formulaBatchId != ''"> and formula_batch_id = #{formulaBatchId}</if>
<if test="zookeeper != null and zookeeper != ''"> and zookeeper = #{zookeeper}</if>
<if test="deployDate != null "> and deploy_date = #{deployDate}</if>
</where>

View File

@@ -0,0 +1,100 @@
<?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.zhyc.module.feed.mapper.SgFeedStatisticMapper">
<resultMap type="SgFeedStatistic" id="SgFeedStatisticResult">
<result property="id" column="id" />
<result property="formulaId" column="formula_id" />
<result property="formulaBatchId" column="formula_batch_id" />
<result property="sheepFoldCount" column="sheep_fold_count" />
<result property="silageLossRate" column="silage_loss_rate" />
<result property="feedTotalSize" column="feed_total_size" />
<result property="feedDailySize" column="feed_daily_size" />
<!--
适配泛型TypeHandler
弃用: XML中无法使用"<>"
-->
<!-- <result property="materialList" column="material_list"-->
<!-- typeHandler="com.zhyc.module.feed.mapper.TypeHandler.JsonTypeHandler<java.util.List<com.zhyc.module.feed.domain.SgFormulaList>>" />-->
<!-- 分别使用两个TypeHandler完成实体类List<T> 到 数据库 JSON串的映射转换 -->
<result property="materialList" column="material_list" typeHandler="com.zhyc.module.feed.mapper.TypeHandler.SgFormulaListHandler"/>
<result property="sheepFoldList" column="sheep_fold_list" typeHandler="com.zhyc.module.feed.mapper.TypeHandler.DaSheepfoldHandler"/>
<result property="feedDate" column="feed_date" />
</resultMap>
<sql id="selectSgFeedStatisticVo">
select id, formula_id, formula_batch_id, sheep_fold_count, silage_loss_rate, feed_total_size, feed_daily_size, material_list, sheep_fold_list,feed_date from sg_feed_statistic
</sql>
<select id="selectSgFeedStatisticList" parameterType="SgFeedStatistic" resultMap="SgFeedStatisticResult">
<include refid="selectSgFeedStatisticVo"/>
<where>
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
<if test="formulaBatchId != null and formulaBatchId != ''"> and formula_batch_id = #{formulaBatchId}</if>
<if test="silageLossRate != null and silageLossRate != ''"> and silage_loss_rate = #{silageLossRate}</if>
</where>
</select>
<select id="selectSgFeedStatisticById" parameterType="String" resultMap="SgFeedStatisticResult">
<include refid="selectSgFeedStatisticVo"/>
where id = #{id}
</select>
<insert id="insertSgFeedStatistic" parameterType="SgFeedStatistic">
insert into sg_feed_statistic
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="formulaId != null and formulaId != ''">formula_id,</if>
<if test="formulaBatchId != null and formulaBatchId != ''">formula_batch_id,</if>
<if test="sheepFoldCount != null">sheep_fold_count,</if>
<if test="silageLossRate != null">silage_loss_rate,</if>
<if test="feedTotalSize != null">feed_total_size,</if>
<if test="feedDailySize != null">feed_daily_size,</if>
<if test="materialList != null">material_list,</if>
<if test="sheepFoldList != null">sheep_fold_list,</if>
<if test="feedDate != null">feed_date,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="formulaId != null and formulaId != ''">#{formulaId},</if>
<if test="formulaBatchId != null and formulaBatchId != ''">#{formulaBatchId},</if>
<if test="sheepFoldCount != null">#{sheepFoldCount},</if>
<if test="silageLossRate != null">#{silageLossRate},</if>
<if test="feedTotalSize != null">#{feedTotalSize},</if>
<if test="feedDailySize != null">#{feedDailySize},</if>
# 写入操作需要手动指定 TypeHandler 参数
<if test="materialList != null">#{materialList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.SgFormulaListHandler},</if>
<if test="sheepFoldList != null">#{sheepFoldList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.DaSheepfoldHandler},</if>
<if test="feedDate != null">#{feedDate},</if>
</trim>
</insert>
<update id="updateSgFeedStatistic" parameterType="SgFeedStatistic">
update sg_feed_statistic
<trim prefix="SET" suffixOverrides=",">
<if test="formulaId != null and formulaId != ''">formula_id = #{formulaId},</if>
<if test="formulaBatchId != null and formulaBatchId != ''">formula_batch_id = #{formulaBatchId},</if>
<if test="sheepFoldCount != null">sheep_fold_count = #{sheepFoldCount},</if>
<if test="silageLossRate != null">silage_loss_rate = #{silageLossRate},</if>
<if test="feedTotalSize != null">feed_total_size = #{feedTotalSize},</if>
<if test="feedDailySize != null">feed_daily_size = #{feedDailySize},</if>
<if test="materialList != null">material_list = #{materialList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.SgFormulaListHandler},</if>
<if test="sheepFoldList != null">sheep_fold_list = #{sheepFoldList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.DaSheepfoldHandler},</if>
<if test="feedDate != null">feed_date = #{feedDate},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSgFeedStatisticById" parameterType="String">
delete from sg_feed_statistic where id = #{id}
</delete>
<delete id="deleteSgFeedStatisticByIds" parameterType="String">
delete from sg_feed_statistic where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>