From 54f7df70ca67cafd7b8c5bdb7f24662971f62bf5 Mon Sep 17 00:00:00 2001 From: zyk Date: Thu, 25 Dec 2025 19:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=8D=E5=85=AC=E7=BE=8A=E6=A1=A3=E6=A1=88?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../produce/breed/domain/ScLambDetail.java | 113 +++++++++++++++--- .../impl/ScLambingRecordServiceImpl.java | 13 +- 2 files changed, 105 insertions(+), 21 deletions(-) diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambDetail.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambDetail.java index 4c71d76..33cd66d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambDetail.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambDetail.java @@ -1,3 +1,95 @@ +//package com.zhyc.module.produce.breed.domain; +// +//import java.math.BigDecimal; +//import java.util.Date; +//import java.util.List; +// +//import com.fasterxml.jackson.annotation.JsonFormat; +//import lombok.AllArgsConstructor; +//import lombok.Data; +//import lombok.NoArgsConstructor; +//import com.zhyc.common.annotation.Excel; +//import com.zhyc.common.core.domain.BaseEntity; +// +///** +// * 羔羊详情对象 sc_lamb_detail +// * +// * @author ruoyi +// * @date 2025-07-11 +// */ +//@Data +//@NoArgsConstructor +//@AllArgsConstructor +//public class ScLambDetail extends BaseEntity +//{ +// private static final long serialVersionUID = 1L; +// +// /** 主键ID */ +// private Long id; +// +// /** 产羔记录ID */ +// @Excel(name = "产羔记录ID") +// private Long lambingRecordId; +// +// /** 羔羊耳号 */ +// @Excel(name = "羔羊耳号") +// private String lambEarNumber; +// +// /** 羔羊品种ID */ +// @Excel(name = "羔羊品种ID") +// private Integer lambBreed; // 改为Integer类型,存储品种ID +// +// /** 性别 */ +// @Excel(name = "性别") +// private Integer gender; +// +// /** 出生重量 */ +// @Excel(name = "出生重量") +// private BigDecimal birthWeight; +// +// /** 是否留养 */ +// @Excel(name = "是否留养") +// private Boolean isRetained; +// +// /** 家系 */ +// @Excel(name = "家系") +// private String lineage; +// +// /** 生日 */ +// @JsonFormat(pattern = "yyyy-MM-dd") +// @Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd") +// private Date birthday; +// +// private List lambDetails; +// +// /** 母羊ID */ +// private Long motherId; +// +// /** 父羊ID */ +// private Long fatherId; +// +// /** 牧场ID */ +// private Integer ranchId; +// +// /** 羊舍ID */ +// private Integer sheepfoldId; +// +// /** 胎次 */ +// private Integer parity; +// +// // getter和setter方法 +// public void setId(Long id) +// { +// this.id = id; +// } +// +// public Long getId() +// { +// return id; +// } +// +// +//} package com.zhyc.module.produce.breed.domain; import java.math.BigDecimal; @@ -37,9 +129,9 @@ public class ScLambDetail extends BaseEntity /** 羔羊品种ID */ @Excel(name = "羔羊品种ID") - private Integer lambBreed; // 改为Integer类型,存储品种ID + private Integer lambBreed; - /** 性别 */ + /** 性别:1-母,2-公,3-阉羊,4-兼性 */ @Excel(name = "性别") private Integer gender; @@ -47,9 +139,9 @@ public class ScLambDetail extends BaseEntity @Excel(name = "出生重量") private BigDecimal birthWeight; - /** 是否留养 */ + /** 是否留养:0-否,1-是 */ @Excel(name = "是否留养") - private Boolean isRetained; + private Integer isRetained; /** 家系 */ @Excel(name = "家系") @@ -76,17 +168,4 @@ public class ScLambDetail extends BaseEntity /** 胎次 */ private Integer parity; - - // getter和setter方法 - public void setId(Long id) - { - this.id = id; - } - - public Long getId() - { - return id; - } - - } \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScLambingRecordServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScLambingRecordServiceImpl.java index 659cd78..3bdef87 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScLambingRecordServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScLambingRecordServiceImpl.java @@ -92,9 +92,9 @@ public class ScLambingRecordServiceImpl implements IScLambingRecordService { throw new RuntimeException("羔羊性别不能为空"); } - // 验证性别值的有效性(假设0=母羊,1=公羊) - if (lambDetail.getGender() < 0 || lambDetail.getGender() > 1) { - throw new RuntimeException("羔羊性别值无效,请使用0(母羊)或1(公羊)"); + // 验证性别值的有效性:1-母,2-公,3-阉羊,4-兼性 + if (lambDetail.getGender() < 1 || lambDetail.getGender() > 4) { + throw new RuntimeException("羔羊性别值无效,请使用1(母)、2(公)、3(阉羊)或4(兼性)"); } // 检查耳号是否已存在 @@ -105,7 +105,12 @@ public class ScLambingRecordServiceImpl implements IScLambingRecordService { // 设置默认值 if (lambDetail.getIsRetained() == null) { - lambDetail.setIsRetained(false); + lambDetail.setIsRetained(0); // 默认为0(否) + } + + // 验证是否留养值的有效性:0-否,1-是 + if (lambDetail.getIsRetained() != 0 && lambDetail.getIsRetained() != 1) { + throw new RuntimeException("是否留养值无效,请使用0(否)或1(是)"); } if (lambDetail.getBirthday() == null) {