修改羊只分组功能

This commit is contained in:
wyt 2025-07-18 12:57:42 +08:00
parent a2d5c34995
commit f33bf93714
10 changed files with 152 additions and 155 deletions

View File

@ -23,6 +23,10 @@
<version>1.18.38</version> <!-- 使用最新版本 -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -52,18 +52,21 @@ public class ScAddSheep extends BaseEntity {
@Excel(name = "出生日期", dateFormat = "yyyy-MM-dd")
private Date birthday;
/** 性别 1公 0母 */
@Excel(name = "性别", readConverterExp = "1=公,0=母")
/** 性别 1公 0母 2阉羊 3兼性 */
@Excel(name = "性别", readConverterExp = "1=公,0=母,2=阉羊,3=兼性")
private Integer gender;
/** 胎次 */
@Excel(name = "胎次")
private Integer parity;
/** 品种编号 */
@Excel(name = "品种编号")
/** 品种id */
private Integer varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
/** 入群日期 */
@Excel(name = "入群日期", dateFormat = "yyyy-MM-dd")
private Date joinDate;

View File

@ -66,6 +66,13 @@ public class ScTransGroup extends BaseEntity {
@Excel(name = "品种")
private String varietyName;
/** 品种id */
private Long varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
private Integer reason;
/**
* 转群原因描述 用于导出

View File

@ -51,8 +51,6 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
group.setStatusText(convertStatus(group.getStatus()));
});
return list;
// return scTransGroupMapper.selectScTransGroupList(scTransGroup);
}
/**

View File

@ -1,5 +1,8 @@
package com.zhyc.module.produce.other.castrate.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
@ -11,6 +14,9 @@ import com.zhyc.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2025-07-09
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScCastrate extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -36,6 +42,13 @@ public class ScCastrate extends BaseEntity {
@Excel(name = "羊舍名称")
private String sheepfoldName;
/** 品种id */
private Long varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
/**
* 备注
*/
@ -50,63 +63,5 @@ public class ScCastrate extends BaseEntity {
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setSheepId(String sheepId) {
this.sheepId = sheepId;
}
public String getSheepId() {
return sheepId;
}
public void setSheepfold(Long sheepfold) {
this.sheepfold = sheepfold;
}
public Long getSheepfold() {
return sheepfold;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getComment() {
return comment;
}
public void setTechnician(String technician) {
this.technician = technician;
}
public String getTechnician() {
return technician;
}
public String getSheepfoldName() {
return sheepfoldName;
}
public void setSheepfoldName(String sheepfoldName) {
this.sheepfoldName = sheepfoldName;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("sheepId", getSheepId())
.append("sheepfold", getSheepfold())
.append("comment", getComment())
.append("technician", getTechnician())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.toString();
}
}

View File

@ -38,6 +38,13 @@ public class ScFixHoof extends BaseEntity
@Excel(name = "羊舍名称")
private String sheepfoldName;
/** 品种id */
private Long varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
/** 备注 */
@Excel(name = "备注")
private String comment;

View File

@ -4,12 +4,13 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.manage_sheep.add_sheep.mapper.ScAddSheepMapper">
<!-- 1. 结果映射:包含羊舍名称、品种名称 -->
<resultMap type="com.zhyc.module.produce.manage_sheep.add_sheep.domain.ScAddSheep" id="ScAddSheepResult">
<result property="id" column="id"/>
<result property="earNumber" column="ear_number"/>
<result property="sheepfold" column="sheepfold"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="sheepfoldNameExcel" column="sheepfoldName"/>
<result property="father" column="father"/>
<result property="mother" column="mother"/>
<result property="bornWeight" column="born_weight"/>
@ -17,6 +18,7 @@
<result property="gender" column="gender"/>
<result property="parity" column="parity"/>
<result property="varietyId" column="variety_id"/>
<result property="varietyName" column="varietyName"/>
<result property="joinDate" column="join_date"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
@ -24,29 +26,46 @@
<result property="createTime" column="create_time"/>
</resultMap>
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_add_sheep
(ear_number, sheepfold, father, mother, born_weight, birthday, gender, parity,
variety_id, join_date, comment, technician, create_by, create_time)
VALUES (#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight}, #{birthday},
#{gender}, #{parity}, #{varietyId}, #{joinDate}, #{comment}, #{technician},
#{createBy}, #{createTime})
</insert>
<!-- 2. 查询列表:支持按品种筛选 -->
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
SELECT
sas.*,
sf.sheepfold_name AS sheepfoldName
sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName
FROM sc_add_sheep sas
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
<where>
<if test="earNumber != null and earNumber != ''">
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
</if>
<if test="sheepfold != null">
AND sas.sheepfold = #{sheepfold}
</if>
<if test="varietyId != null">
AND sas.variety_id = #{varietyId}
</if>
</where>
</select>
<!-- 3. 根据耳号精确查询 -->
<select id="selectByEarNumber" parameterType="string" resultMap="ScAddSheepResult">
SELECT * FROM sc_add_sheep WHERE ear_number = #{earNumber}
</select>
<!-- 4. 插入 -->
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_add_sheep
(ear_number, sheepfold, father, mother, born_weight, birthday,
gender, parity, variety_id, join_date, comment, technician,
create_by, create_time)
VALUES
(#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight},
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{joinDate},
#{comment}, #{technician}, #{createBy}, #{createTime})
</insert>
<!-- 5. 更新 -->
<update id="updateScAddSheep" parameterType="ScAddSheep">
UPDATE sc_add_sheep
<set>
@ -68,14 +87,11 @@
WHERE id = #{id}
</update>
<!-- 6. 批量删除 -->
<delete id="deleteScAddSheepByIds">
DELETE FROM sc_add_sheep WHERE id IN
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectByEarNumber" parameterType="string" resultMap="ScAddSheepResult">
SELECT * FROM sc_add_sheep WHERE ear_number = #{earNumber}
</select>
</mapper>

View File

@ -10,6 +10,8 @@
<result property="foldTo" column="fold_to"/>
<result property="foldFrom" column="fold_from"/>
<result property="reason" column="reason"/>
<result property="varietyId" column="variety_id"/>
<result property="varietyName" column="varietyName"/>
<result property="technician" column="technician"/>
<result property="status" column="status"/>
<result property="comment" column="comment"/>
@ -23,6 +25,8 @@
tg.fold_to,
tg.fold_from,
tg.reason,
tg.variety_id,
bv.variety AS varietyName,
tg.technician,
tg.status,
tg.comment,
@ -33,15 +37,17 @@
FROM sc_trans_group tg
LEFT JOIN da_sheepfold sf_from ON tg.fold_from = sf_from.id
LEFT JOIN da_sheepfold sf_to ON tg.fold_to = sf_to.id
LEFT JOIN bas_sheep_variety bv ON tg.variety_id = bv.id
</sql>
<select id="selectScTransGroupList" parameterType="ScTransGroup" resultMap="ScTransGroupResult">
<include refid="selectScTransGroupVo"/>
<where>
<if test="sheepId != null ">and sheep_id = #{sheepId}</if>
<if test="sheepId != null">and sheep_id = #{sheepId}</if>
<if test="foldTo != null and foldTo != ''">and fold_to = #{foldTo}</if>
<if test="foldFrom != null and foldFrom != ''">and fold_from = #{foldFrom}</if>
<if test="status != null ">and status = #{status}</if>
<if test="status != null">and status = #{status}</if>
<if test="varietyId != null">and tg.variety_id = #{varietyId}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
@ -54,13 +60,15 @@
where tg.id = #{id}
</select>
<insert id="insertScTransGroup" parameterType="ScTransGroup" useGeneratedKeys="true" keyProperty="id">
<insert id="insertScTransGroup" parameterType="ScTransGroup"
useGeneratedKeys="true" keyProperty="id">
insert into sc_trans_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="foldTo != null and foldTo != ''">fold_to,</if>
<if test="foldFrom != null and foldFrom != ''">fold_from,</if>
<if test="reason != null and reason != ''">reason,</if>
<if test="varietyId != null">variety_id,</if>
<if test="reason != null">reason,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="status != null">status,</if>
<if test="comment != null">comment,</if>
@ -71,7 +79,8 @@
<if test="sheepId != null">#{sheepId},</if>
<if test="foldTo != null and foldTo != ''">#{foldTo},</if>
<if test="foldFrom != null and foldFrom != ''">#{foldFrom},</if>
<if test="reason != null and reason != ''">#{reason},</if>
<if test="varietyId != null">#{varietyId},</if>
<if test="reason != null">#{reason},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="status != null">#{status},</if>
<if test="comment != null">#{comment},</if>
@ -86,14 +95,15 @@
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="foldTo != null and foldTo != ''">fold_to = #{foldTo},</if>
<if test="foldFrom != null and foldFrom != ''">fold_from = #{foldFrom},</if>
<if test="reason != null and reason != ''">reason = #{reason},</if>
<if test="varietyId != null">variety_id = #{varietyId},</if>
<if test="reason != null">reason = #{reason},</if>
<if test="technician != null and technician != ''">technician = #{technician},</if>
<if test="status != null">status = #{status},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where sc_trans_group.id = #{id}
where id = #{id}
</update>
<delete id="deleteScTransGroupById" parameterType="Integer">

View File

@ -9,6 +9,7 @@
<result property="sheepId" column="sheep_id"/>
<result property="sheepfold" column="sheepfold"/>
<result property="comment" column="comment"/>
<result property="varietyId" column="variety_id"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
@ -19,12 +20,15 @@
sc.sheep_id,
sc.sheepfold,
sf.sheepfold_name as sheepfoldName,
sc.variety_id,
bv.variety as varietyName,
sc.comment,
sc.technician,
sc.create_by,
sc.create_time
from sc_castrate sc
left join da_sheepfold sf on sc.sheepfold = sf.id
left join bas_sheep_variety bv on sc.variety_id = bv.id
</sql>
<select id="selectScCastrateList" parameterType="ScCastrate" resultMap="ScCastrateResult">
@ -32,10 +36,14 @@
<where>
<if test="sheepId != null and sheepId != ''">and sheep_id like concat('%', #{sheepId}, '%')</if>
<if test="sheepfold != null ">and sheepfold like concat('%', #{sheepfold}, '%')</if>
<if test="varietyId != null">
and sc.variety_id = #{varietyId}
</if>
<if test="technician != null and technician != ''">and technician like concat('%', #{technician}, '%')</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
</select>
@ -49,6 +57,7 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="sheepfold != null">sheepfold,</if>
<if test="varietyId != null">variety_id,</if>
<if test="comment != null">comment,</if>
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
@ -57,6 +66,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="sheepfold != null">#{sheepfold},</if>
<if test="varietyId != null">#{varietyId},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
@ -69,6 +79,7 @@
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="sheepfold != null">sheepfold = #{sheepfold},</if>
<if test="varietyId != null">variety_id = #{varietyId},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if>

View File

@ -6,9 +6,8 @@
<resultMap type="ScFixHoof" id="ScFixHoofResult">
<result property="id" column="id"/>
<result property="manageTags" column="manageTags"/>
<result property="sheepId" column="sheep_id"/>
<result property="sheepfold" column="sheepfold"/>
<result property="varietyId" column="variety_id"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
@ -18,19 +17,15 @@
<sql id="selectScFixHoofVo">
select fh.id,
bs.manage_tags AS manageTags,
fh.sheep_id,
fh.sheepfold,
sf.sheepfold_name AS sheepfoldName,
fh.variety_id,
bv.variety AS varietyName,
sf.sheepfold_name as sheepfoldName,
fh.comment,
fh.technician,
fh.create_by,
fh.create_time
from sc_fix_hoof fh
left join bas_sheep bs on fh.sheep_id = bs.id
left join da_sheepfold sf on fh.sheepfold = sf.id
left join bas_sheep_variety bv on fh.variety_id = bv.id
</sql>
<select id="selectScFixHoofList" parameterType="ScFixHoof" resultMap="ScFixHoofResult">
@ -38,15 +33,9 @@
<where>
<if test="sheepId != null ">and sheep_id = #{sheepId}</if>
<if test="sheepfold != null ">and sheepfold = #{sheepfold}</if>
<if test="varietyId != null">
and fh.variety_id = #{varietyId}
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
</where>
</select>
@ -55,24 +44,24 @@
where fh.id = #{id}
</select>
<insert id="insertScFixHoof" parameterType="ScFixHoof"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_fix_hoof
(sheep_id,
sheepfold,
variety_id,
<insert id="insertScFixHoof" parameterType="ScFixHoof" useGeneratedKeys="true" keyProperty="id">
insert into sc_fix_hoof
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null and sheepId != ''">and fh.sheep_id like concat('%', #{sheepId}, '%')</if>
<if test="sheepfold != null">and fh.sheepfold = #{sheepfold}</if>
<if test="comment != null">comment,</if>
<if test="technician != null and technician != ''">technician,</if>
create_by,
create_time)
VALUES
(#{sheepId},
#{sheepfold},
<if test="varietyId != null">#{varietyId},</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="sheepfold != null">#{sheepfold},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null and technician != ''">#{technician},</if>
#{createBy},
#{createTime})
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateScFixHoof" parameterType="ScFixHoof">
@ -80,7 +69,6 @@
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="sheepfold != null">sheepfold = #{sheepfold},</if>
<if test="varietyId != null">variety_id=#{varietyId},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="technician != null and technician != ''">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if>
@ -101,6 +89,4 @@
#{id}
</foreach>
</delete>
</mapper>