From 3443f080fbf510f83fb183af5a8b0ca5b6fce8e9 Mon Sep 17 00:00:00 2001 From: zyh <2066096076@qq.com> Date: Sun, 1 Mar 2026 14:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BE=8A=E5=8F=AA=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E7=BE=8A=E5=8F=AA=E7=B1=BB=E5=9E=8B=EF=BC=8C=E5=90=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD=E9=9C=80?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E6=94=B9=E5=93=81=E7=A7=8D=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=9A=84=E5=8E=9F=E5=93=81=E7=A7=8D=E5=9B=9E=E6=98=BE=E9=9C=80?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/controller/BasSheepController.java | 4 +- .../com/zhyc/module/frozen/domain/DdFe.java | 208 +----------------- .../com/zhyc/module/frozen/domain/DdFs.java | 152 +------------ .../bodyManage/domain/ScBodyMeasure.java | 2 +- .../bodyManage/domain/ScBodyScore.java | 2 +- .../bodyManage/domain/ScBreastRating.java | 2 +- .../manage_sheep/domain/ScChangeComment.java | 2 +- .../manage_sheep/domain/ScChangeEar.java | 2 +- .../manage_sheep/domain/ScChangeVariety.java | 2 +- .../manage_sheep/domain/ScTransGroup.java | 2 +- .../manage_sheep/domain/ScTransitionInfo.java | 2 +- .../mapper/ScChangeCommentMapper.java | 11 +- .../service/impl/ScAddSheepServiceImpl.java | 121 ++++++++-- .../impl/ScChangeVarietyServiceImpl.java | 8 +- .../produce/other/domain/ScCastrate.java | 2 +- .../produce/other/domain/ScFixHoof.java | 2 +- .../resources/mapper/frozen/DdFeMapper.xml | 6 + .../resources/mapper/frozen/DdFsMapper.xml | 14 +- .../bodyManage/ScBodyMeasureMapper.xml | 176 ++++++++------- .../produce/bodyManage/ScBodyScoreMapper.xml | 44 ++-- .../bodyManage/ScBreastRatingMapper.xml | 46 ++-- .../manage_sheep/ScChangeCommentMapper.xml | 54 +++-- .../manage_sheep/ScChangeEarMapper.xml | 50 +++-- .../manage_sheep/ScChangeVarietyMapper.xml | 52 +++-- .../manage_sheep/ScTransGroupMapper.xml | 46 ++-- .../manage_sheep/ScTransitionInfoMapper.xml | 127 ++++++----- .../mapper/produce/other/ScCastrateMapper.xml | 42 ++-- .../mapper/produce/other/ScFixHoofMapper.xml | 40 ++-- 28 files changed, 531 insertions(+), 690 deletions(-) diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java b/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java index f2722a1..20fbe9a 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java @@ -133,7 +133,9 @@ public class BasSheepController extends BaseController { // 查询所有存在的羊只 List existingSheep = basSheepService.selectBasSheepByManageTagsList(validTags); - + if (validTags.size() == 1 && existingSheep.size() == 1) { + return success(existingSheep.get(0)); //直接返回羊只对象 + } Set existingTagSet = existingSheep.stream() .map(BasSheep::getManageTags) .collect(Collectors.toSet()); diff --git a/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdFe.java b/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdFe.java index 1d8a3c7..0f40c36 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdFe.java +++ b/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdFe.java @@ -2,6 +2,9 @@ package com.zhyc.module.frozen.domain; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; +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; @@ -13,13 +16,16 @@ import com.zhyc.common.core.domain.BaseEntity; * @author ruoyi * @date 2025-11-29 */ +@Data +@AllArgsConstructor +@NoArgsConstructor public class DdFe extends BaseEntity { private static final long serialVersionUID = 1L; /** 主键 */ private Long id; - + private Long[] ids; /** 胚胎编号 YS+日期+序号 */ @Excel(name = "胚胎编号") private String code; @@ -95,205 +101,5 @@ public class DdFe extends BaseEntity this.id = id; } - public Long getId() - { - return id; - } - public void setCode(String code) - { - this.code = code; - } - - public String getCode() - { - return code; - } - - public void setFreezeDate(Date freezeDate) - { - this.freezeDate = freezeDate; - } - - public Date getFreezeDate() - { - return freezeDate; - } - - public void setDrId(String drId) - { - this.drId = drId; - } - - public String getDrId() - { - return drId; - } - - public void setDrBreed(String drBreed) - { - this.drBreed = drBreed; - } - - public String getDrBreed() - { - return drBreed; - } - - public void setDeId(String deId) - { - this.deId = deId; - } - - public String getDeId() - { - return deId; - } - - public void setDeBreed(String deBreed) - { - this.deBreed = deBreed; - } - - public String getDeBreed() - { - return deBreed; - } - - public void setEmbBreed(String embBreed) - { - this.embBreed = embBreed; - } - - public String getEmbBreed() - { - return embBreed; - } - - public void setGrade(String grade) - { - this.grade = grade; - } - - public String getGrade() - { - return grade; - } - - public void setQty(Long qty) - { - this.qty = qty; - } - - public Long getQty() - { - return qty; - } - - public void setSexCtl(Integer sexCtl) - { - this.sexCtl = sexCtl; - } - - public Integer getSexCtl() - { - return sexCtl; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - - public void setTech(String tech) - { - this.tech = tech; - } - - public String getTech() - { - return tech; - } - - public void setTankId(Long tankId) - { - this.tankId = tankId; - } - - public Long getTankId() - { - return tankId; - } - - public void setBucketId(Long bucketId) - { - this.bucketId = bucketId; - } - - public Long getBucketId() - { - return bucketId; - } - - public void setRackId(Long rackId) - { - this.rackId = rackId; - } - - public Long getRackId() - { - return rackId; - } - - public void setOutDate(Date outDate) - { - this.outDate = outDate; - } - - public Date getOutDate() - { - return outDate; - } - - public void setDiscardTxt(String discardTxt) - { - this.discardTxt = discardTxt; - } - - public String getDiscardTxt() - { - return discardTxt; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("code", getCode()) - .append("freezeDate", getFreezeDate()) - .append("drId", getDrId()) - .append("drBreed", getDrBreed()) - .append("deId", getDeId()) - .append("deBreed", getDeBreed()) - .append("embBreed", getEmbBreed()) - .append("grade", getGrade()) - .append("qty", getQty()) - .append("sexCtl", getSexCtl()) - .append("status", getStatus()) - .append("tech", getTech()) - .append("tankId", getTankId()) - .append("bucketId", getBucketId()) - .append("rackId", getRackId()) - .append("outDate", getOutDate()) - .append("discardTxt", getDiscardTxt()) - .append("remark", getRemark()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .toString(); - } } diff --git a/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdFs.java b/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdFs.java index 50e7c1b..83ecc71 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdFs.java +++ b/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdFs.java @@ -3,6 +3,9 @@ package com.zhyc.module.frozen.domain; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; +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; @@ -14,6 +17,9 @@ import com.zhyc.common.core.domain.BaseEntity; * @author ruoyi * @date 2025-11-29 */ +@Data +@AllArgsConstructor +@NoArgsConstructor public class DdFs extends BaseEntity { private static final long serialVersionUID = 1L; @@ -21,7 +27,7 @@ public class DdFs extends BaseEntity { * 主键 */ private Long id; - + private Long[] ids; /** * 冻精号/公羊耳号 */ @@ -107,148 +113,4 @@ public class DdFs extends BaseEntity { */ @Excel(name = "废弃原因") private String discardTxt; - - public void setId(Long id) { - this.id = id; - } - - public Long getId() { - return id; - } - - public void setCode(String code) { - this.code = code; - } - - public String getCode() { - return code; - } - - public void setFreezeDt(Date freezeDt) { - this.freezeDt = freezeDt; - } - - public Date getFreezeDt() { - return freezeDt; - } - - public void setBreed(String breed) { - this.breed = breed; - } - - public String getBreed() { - return breed; - } - - public void setBatch(String batch) { - this.batch = batch; - } - - public String getBatch() { - return batch; - } - - public void setSpec(String spec) { - this.spec = spec; - } - - public String getSpec() { - return spec; - } - - public void setQty(Long qty) { - this.qty = qty; - } - - public Long getQty() { - return qty; - } - - public void setSexCtl(Integer sexCtl) { - this.sexCtl = sexCtl; - } - - public Integer getSexCtl() { - return sexCtl; - } - - public void setStat(String stat) { - this.stat = stat; - } - - public String getStat() { - return stat; - } - - public void setTech(String tech) { - this.tech = tech; - } - - public String getTech() { - return tech; - } - - public void setTankId(Long tankId) { - this.tankId = tankId; - } - - public Long getTankId() { - return tankId; - } - - public void setBucketId(Long bucketId) { - this.bucketId = bucketId; - } - - public Long getBucketId() { - return bucketId; - } - - public void setRackId(Long rackId) { - this.rackId = rackId; - } - - public Long getRackId() { - return rackId; - } - - public void setOutDt(Date outDt) { - this.outDt = outDt; - } - - public Date getOutDt() { - return outDt; - } - - public void setDiscardTxt(String discardTxt) { - this.discardTxt = discardTxt; - } - - public String getDiscardTxt() { - return discardTxt; - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("code", getCode()) - .append("freezeDt", getFreezeDt()) - .append("breed", getBreed()) - .append("batch", getBatch()) - .append("spec", getSpec()) - .append("qty", getQty()) - .append("sexCtl", getSexCtl()) - .append("stat", getStat()) - .append("tech", getTech()) - .append("tankId", getTankId()) - .append("bucketId", getBucketId()) - .append("rackId", getRackId()) - .append("outDt", getOutDt()) - .append("discardTxt", getDiscardTxt()) - .append("remark", getRemark()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .toString(); - } } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java index 4a1ae39..57e1620 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java @@ -29,7 +29,7 @@ public class ScBodyMeasure extends BaseEntity { * $column.columnComment */ private Long id; - + private Long[] ids; /** * 耳号 */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java index 9035967..08729b4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java @@ -26,7 +26,7 @@ public class ScBodyScore extends BaseEntity { * $column.columnComment */ private Long id; - + private Long[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java index e366749..a2da538 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java @@ -26,7 +26,7 @@ public class ScBreastRating extends BaseEntity { * $column.columnComment */ private Long id; - + private Long[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java index 66c7247..76b8e32 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java @@ -26,7 +26,7 @@ public class ScChangeComment extends BaseEntity { * $column.columnComment */ private Long id; - + private Long[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java index 9db0c0d..fb0887d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java @@ -26,7 +26,7 @@ public class ScChangeEar extends BaseEntity { * id */ private Integer id; - + private Integer[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java index 92cdd55..54651f6 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java @@ -26,7 +26,7 @@ public class ScChangeVariety extends BaseEntity { * $column.columnComment */ private Integer id; - + private Integer[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java index c106749..a603801 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java @@ -24,7 +24,7 @@ public class ScTransGroup extends BaseEntity { * $column.columnComment */ private Integer id; - + private Integer[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java index d1d3a4e..5fba386 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java @@ -25,7 +25,7 @@ public class ScTransitionInfo extends BaseEntity { *主键 */ private Integer id; - + private Integer[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java index 7f04ca2..accd718 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java @@ -22,11 +22,10 @@ public interface ScChangeCommentMapper /** * 查询改备注列表 - * - * @param scChangeComment 改备注 - * @return 改备注集合 */ -// public List selectScChangeCommentList(ScChangeComment scChangeComment); + List selectScChangeCommentList( + @Param("sc") ScChangeComment sc, + @Param("manageTagsList") List manageTagsList); /** * 新增改备注 @@ -60,10 +59,6 @@ public interface ScChangeCommentMapper */ public int deleteScChangeCommentByIds(Long[] ids); - List selectScChangeCommentList( - @Param("sc") ScChangeComment sc, - @Param("manageTagsList") List manageTagsList); - /** * 模糊搜索耳号 */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java index 23949e0..23424e2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java @@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.Calendar; import java.util.Date; import java.util.List; @@ -122,6 +124,61 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { return scAddSheepMapper.deleteScAddSheepByIds(ids) > 0; } + /** + * 根据出生日期计算月龄 + */ + private int calculateMonthAge(Date birthday) { + if (birthday == null) return 0; + + Calendar birthCal = Calendar.getInstance(); + birthCal.setTime(birthday); + + Calendar nowCal = Calendar.getInstance(); + + int yearDiff = nowCal.get(Calendar.YEAR) - birthCal.get(Calendar.YEAR); + int monthDiff = nowCal.get(Calendar.MONTH) - birthCal.get(Calendar.MONTH); + + return yearDiff * 12 + monthDiff; + } + + /** + * 根据月龄、断奶体重、性别自动判断羊只类别ID + */ + private Long determineSheepType(BigDecimal weaningWeight, int monthAge, Integer gender) { + // 1. 断奶体重为空 -> 哺乳羊 + if (weaningWeight == null) { + return 1L; // 哺乳羊 + } + + // 2. 断奶体重不为空 且 月龄 0-4 -> 断奶羊 + if (monthAge >= 0 && monthAge <= 4) { + return 2L; // 断奶羊 + } + + // 3. 断奶体重不为空 且 月龄 4-7 -> 育成羊 + if (monthAge > 4 && monthAge <= 7) { + return 3L; // 育成羊 + } + + // 4. 月龄 7-12 且 母羊 -> 青年羊 + if (monthAge > 7 && monthAge < 12 && gender != null && gender == 1) { // 1=母 + return 4L; // 青年羊 + } + + // 5. 月龄 >=12 且 公羊 -> 成年公羊 + if (monthAge >= 12 && gender != null && gender == 2) { // 2=公 + return 8L; // 成年公羊 + } + + // 6. 月龄 >=12 且 母羊 -> 超龄羊 + if (monthAge >= 12 && gender != null && gender == 1) { // 1=母 + return 5L; // 超龄羊 + } + + // 默认返回哺乳羊 + return 1L; + } + //导入羊只 @Override @Transactional(rollbackFor = Exception.class) @@ -136,6 +193,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { for (int i = 0; i < list.size(); i++) { ScAddSheep sheep = list.get(i); try { + // 校验牧场名称 if (StringUtils.isBlank(sheep.getRanchName())) { failure++; failureMsg.append("
第").append(i + 1).append("行:牧场名称不能为空"); @@ -153,6 +211,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { } sheep.setRanchId(ranchList.get(0).getId().intValue()); + // 校验品种名称 if (StringUtils.isNotBlank(sheep.getVarietyName())) { Long varietyId = basSheepVarietyMapper.selectIdByName(sheep.getVarietyName()); if (varietyId == null) { @@ -173,6 +232,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { continue; } + // 校验羊舍名称 if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) { DaSheepfold param = new DaSheepfold(); param.setSheepfoldName(sheep.getSheepfoldNameExcel()); @@ -190,23 +250,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { sheep.setSheepfold(foldList.get(0).getId().intValue()); } - if (StringUtils.isNotBlank(sheep.getTypeName())) { - BasSheepType typeQuery = new BasSheepType(); - typeQuery.setName(sheep.getTypeName().trim()); - List typeList = basSheepTypeService.selectBasSheepTypeList(typeQuery); - - if (typeList == null || typeList.isEmpty()) { - failure++; - failureMsg.append("
第") - .append(i + 1) - .append("行:羊只类型名称不存在【") - .append(sheep.getTypeName()) - .append("】"); - continue; - } - sheep.setTypeId(typeList.get(0).getId().longValue()); - } - + // 校验耳号 if (StringUtils.isBlank(sheep.getEarNumber())) { failure++; failureMsg.append("
第") @@ -225,6 +269,8 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { .append("】"); continue; } + + // 校验父号(如果填写了) if (StringUtils.isNotBlank(sheep.getFather())) { BasSheep father = basSheepService.selectBasSheepByManageTags(sheep.getFather().trim()); if (father == null) { @@ -234,6 +280,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { } } + // 校验母号(如果填写了) if (StringUtils.isNotBlank(sheep.getMother())) { BasSheep mother = basSheepService.selectBasSheepByManageTags(sheep.getMother().trim()); if (mother == null) { @@ -242,6 +289,46 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { continue; } } + + // 校验出生日期必填 + if (sheep.getBirthday() == null) { + failure++; + failureMsg.append("
第").append(i + 1).append("行:出生日期不能为空"); + continue; + } + + // 校验性别必填 + if (sheep.getGender() == null) { + failure++; + failureMsg.append("
第").append(i + 1).append("行:性别不能为空"); + continue; + } + + // 自动判断羊只类别 + int monthAge = calculateMonthAge(sheep.getBirthday()); + Long autoTypeId = determineSheepType(sheep.getWeaningWeight(), monthAge, sheep.getGender()); + + // 如果Excel中填写了typeName,以Excel为准 + if (StringUtils.isNotBlank(sheep.getTypeName())) { + BasSheepType typeQuery = new BasSheepType(); + typeQuery.setName(sheep.getTypeName().trim()); + List typeList = basSheepTypeService.selectBasSheepTypeList(typeQuery); + + if (typeList == null || typeList.isEmpty()) { + failure++; + failureMsg.append("
第") + .append(i + 1) + .append("行:羊只类型名称不存在【") + .append(sheep.getTypeName()) + .append("】"); + continue; + } + sheep.setTypeId(typeList.get(0).getId().longValue()); + } else { + // 使用自动判断的类别 + sheep.setTypeId(autoTypeId); + } + // 数据分离:设置用户和部门 sheep.setUserId(userId); sheep.setDeptId(deptId); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java index e8fac47..762688b 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java @@ -68,19 +68,15 @@ public class ScChangeVarietyServiceImpl implements IScChangeVarietyService @Transactional(rollbackFor = Exception.class) public int insertScChangeVariety(ScChangeVariety scChangeVariety) { - // ✅ 第1步:先查羊只(移到 insert 之前!) String manageTags = scChangeVariety.getManageTags(); BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags); if (sheep == null) { throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只,无法更新品种"); } - // ✅ 第2步:设置所有字段(关键!) - scChangeVariety.setSheepId(sheep.getId().intValue()); // 设置羊只ID + scChangeVariety.setSheepId(sheep.getId().intValue()); - // 查询当前品种作为旧品种(如果前端没传) if (StringUtils.isBlank(scChangeVariety.getVarietyOld())) { - // ✅ 修正:使用正确的方法名 selectBasSheepVarietyById BasSheepVariety oldVariety = varietyService.selectBasSheepVarietyById(sheep.getVarietyId()); if (oldVariety != null) { scChangeVariety.setVarietyOld(oldVariety.getVariety()); @@ -98,13 +94,11 @@ public class ScChangeVarietyServiceImpl implements IScChangeVarietyService throw new RuntimeException("事件日期不能为空"); } - // ✅ 第3步:再执行 insert(此时所有字段都有值了) int rows = scChangeVarietyMapper.insertScChangeVariety(scChangeVariety); if (rows <= 0) { return rows; } - // 第4步:更新羊只品种(保持你的原逻辑) String newVarietyName = scChangeVariety.getVarietyNew(); BasSheepVariety newVariety = varietyService.selectByVarietyName(newVarietyName); if (newVariety == null) { diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java index f97a8a2..39ea449 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java @@ -25,7 +25,7 @@ public class ScCastrate extends BaseEntity { * $column.columnComment */ private Long id; - + private Long[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java index 0329a66..df6edf8 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java @@ -25,7 +25,7 @@ public class ScFixHoof extends BaseEntity { * $column.columnComment */ private Integer id; - + private Integer[] ids; /** * 羊只id */ diff --git a/zhyc-module/src/main/resources/mapper/frozen/DdFeMapper.xml b/zhyc-module/src/main/resources/mapper/frozen/DdFeMapper.xml index 8dd5084..2a875ec 100644 --- a/zhyc-module/src/main/resources/mapper/frozen/DdFeMapper.xml +++ b/zhyc-module/src/main/resources/mapper/frozen/DdFeMapper.xml @@ -56,6 +56,12 @@ - + + + AND id IN + + #{id} + + and code like concat('%', #{code}, '%') and stat = #{stat} and tech like concat('%', #{tech}, '%') @@ -44,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and stat = #{stat} - + - - - bs.manage_tags like concat('%', #{tag}, '%') + + AND sm.id IN + + #{id} - and sm.sheep_id = #{sc.sheepId} - and bs.sheepfold_id = #{sc.sheepfoldId} - and bsv.id = #{sc.varietyId} - and bs.type_id = #{sc.sheepTypeId} - - and sm.measure_date between #{sc.params.beginMeasureDate} and #{sc.params.endMeasureDate} - - - and sm.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} - - - and bs.gender = #{sc.gender} - - - and sm.technician like concat('%', #{sc.technician}, '%') - - - and bs.is_delete = #{sc.isDelete} - - - and = #{sc.monthAgeStart} ]]> - - - and - - - and bbs.breed = #{sc.breedStatusName} - - - and sm.dept_id = #{sc.deptId} - - - and sm.user_id = #{sc.userId} + + + + bs.manage_tags like concat('%', #{tag}, '%') + + + and sm.sheep_id = #{sc.sheepId} + and bs.sheepfold_id = #{sc.sheepfoldId} + and bsv.id = #{sc.varietyId} + and bs.type_id = #{sc.sheepTypeId} + + and sm.measure_date between #{sc.params.beginMeasureDate} and #{sc.params.endMeasureDate} + + + and sm.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} + + + and bs.gender = #{sc.gender} + + + and sm.technician like concat('%', #{sc.technician}, '%') + + + and bs.is_delete = #{sc.isDelete} + + + and = #{sc.monthAgeStart} ]]> + + + and + + + and bbs.breed = #{sc.breedStatusName} + + + and sm.dept_id = #{sc.deptId} + + + and sm.user_id = #{sc.userId} + ${sc.params.dataScope} @@ -272,7 +280,7 @@ SELECT DISTINCT bs.manage_tags FROM bas_sheep bs WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') - AND bs.is_delete = 0 + AND bs.is_delete = 0 ORDER BY bs.manage_tags diff --git a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml index 6500661..d11793d 100644 --- a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml @@ -46,26 +46,34 @@ - - - bs.manage_tags like concat('%', #{tag}, '%') + + AND sbr.id IN + + #{id} - and bsv.id = #{sc.varietyId} - and sf.id = #{sc.sheepfoldId} - - and sbr.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate} - - - and sbr.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} - - - and bs.is_delete = #{sc.isDelete} - - - and sbr.technician = #{sc.technician} - - - and sbr.score = #{sc.score} + + + + bs.manage_tags like concat('%', #{tag}, '%') + + + and bsv.id = #{sc.varietyId} + and sf.id = #{sc.sheepfoldId} + + and sbr.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate} + + + and sbr.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} + + + and bs.is_delete = #{sc.isDelete} + + + and sbr.technician = #{sc.technician} + + + and sbr.score = #{sc.score} + ${sc.params.dataScope} diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml index a574a3e..32748e5 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml @@ -40,33 +40,41 @@ - and sce.sheep_id = #{sc.sheepId} - - - (bs.manage_tags like concat('%', #{tag}, '%') - or bs.electronic_tags like concat('%', #{tag}, '%')) + + AND sce.id IN + + #{id} - and sce.technician like concat('%', #{sc.technician}, '%') - and sce.ear_type = #{sc.earType} - and sce.newTag like concat('%', #{sc.newTag}, '%') - and sce.oldTag like concat('%', #{sc.oldTag}, '%') - + and sce.sheep_id = #{sc.sheepId} + + + (bs.manage_tags like concat('%', #{tag}, '%') + or bs.electronic_tags like concat('%', #{tag}, '%')) + + + and sce.technician like concat('%', + #{sc.technician}, '%') + + and sce.ear_type = #{sc.earType} + and sce.newTag like concat('%', #{sc.newTag}, '%') + and sce.oldTag like concat('%', #{sc.oldTag}, '%') + - and sce.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} - - - and sce.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate} - - - - and bs.is_delete = 0 - and bs.is_delete = 1 - + and sce.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate} + + + + and bs.is_delete = 0 + and bs.is_delete = 1 + + ${sc.params.dataScope} diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml index c3b9bf4..11bef91 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml @@ -40,30 +40,38 @@ - - - s.manage_tags LIKE CONCAT('%', #{tag}, '%') + + and tg.id IN + + #{id} - and tg.sheep_id = #{sc.sheepId} - and tg.fold_to = #{sc.foldTo} - and tg.fold_from = #{sc.foldFrom} - and tg.variety_id = #{sc.varietyId} - and st.id = #{sc.sheepTypeId} - - and tg.trans_date between #{sc.params.beginTransDate} and #{sc.params.endTransDate} - - - and tg.event_type like concat('%', #{sc.eventType}, '%') - - - and tg.technician like concat('%', #{sc.technician}, '%') - - - and s.is_delete = #{sc.isDelete} + + + + s.manage_tags LIKE CONCAT('%', #{tag}, '%') + + + and tg.sheep_id = #{sc.sheepId} + and tg.fold_to = #{sc.foldTo} + and tg.fold_from = #{sc.foldFrom} + and tg.variety_id = #{sc.varietyId} + and st.id = #{sc.sheepTypeId} + + and tg.trans_date between #{sc.params.beginTransDate} and #{sc.params.endTransDate} + + + and tg.event_type like concat('%', #{sc.eventType}, '%') + + + and tg.technician like concat('%', #{sc.technician}, '%') + + + and s.is_delete = #{sc.isDelete} + ${sc.params.dataScope} diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml index 103a98d..8f39fa9 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml @@ -55,31 +55,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO sc_transition_info ( @@ -135,7 +143,8 @@ ) VALUES ( - #{item.sheepId},#{item.sheepfoldId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, #{item.eventType}, + #{item.sheepId},#{item.sheepfoldId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, + #{item.eventType}, #{item.transType},#{item.transitionDate}, #{item.technician}, #{item.status}, #{item.comment}, #{item.createBy}, now(), #{item.userId}, #{item.deptId} diff --git a/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml b/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml index 66d31e2..fee83f9 100644 --- a/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml @@ -24,7 +24,7 @@ select sc.id, sc.sheep_id, bs.manage_tags as manageTags, - '去势' as event_type, + '去势' as event_type, bs.sheepfold_id as sheepfold, sf.sheepfold_name as sheepfoldName, bs.variety_id as varietyId, @@ -43,24 +43,32 @@ - - - bs.manage_tags like concat('%', #{tag}, '%') + + and fh.id IN + + #{id} - and bs.sheepfold_id = #{sc.sheepfold} - and bs.variety_id = #{sc.varietyId} - and fh.technician like concat('%', - #{sc.technician}, '%') - - - and fh.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} - - - and fh.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate} - - - and bs.is_delete = #{sc.isDelete} + + + + bs.manage_tags like concat('%', #{tag}, '%') + + + and bs.sheepfold_id = #{sc.sheepfold} + and bs.variety_id = #{sc.varietyId} + and fh.technician like concat('%', + #{sc.technician}, '%') + + + and fh.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} + + + and fh.event_date between #{sc.params.beginEventDate} and #{sc.params.endEventDate} + + + and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope}