From e79d57f6ce73f62aeeaf9949f1d8b31636877dfe Mon Sep 17 00:00:00 2001 From: zyk Date: Sun, 30 Nov 2025 13:25:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=A7=8D=E8=AE=B0=E5=BD=95=E5=92=8C?= =?UTF-8?q?=E5=86=B2=E8=83=9A=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/embryo/ScEmbryoFlushMapper.xml | 170 ++++++ .../controller/ScBreedRecordController.java | 16 +- .../controller/ScEmbryoFlushController.java | 129 +++++ .../produce/breed/domain/ScEmbryoFlush.java | 504 ++++++++++++++++++ .../breed/mapper/ScEmbryoFlushMapper.java | 86 +++ .../breed/service/IScEmbryoFlushService.java | 86 +++ .../impl/ScEmbryoFlushServiceImpl.java | 326 +++++++++++ .../produce/breed/ScBreedRecordMapper.xml | 16 +- .../produce/breed/ScEmbryoFlushMapper.xml | 229 ++++++++ 9 files changed, 1549 insertions(+), 13 deletions(-) create mode 100644 zhyc-common/src/main/resources/mapper/embryo/ScEmbryoFlushMapper.xml create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScEmbryoFlushController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScEmbryoFlush.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScEmbryoFlushMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScEmbryoFlushService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScEmbryoFlushServiceImpl.java create mode 100644 zhyc-module/src/main/resources/mapper/produce/breed/ScEmbryoFlushMapper.xml diff --git a/zhyc-common/src/main/resources/mapper/embryo/ScEmbryoFlushMapper.xml b/zhyc-common/src/main/resources/mapper/embryo/ScEmbryoFlushMapper.xml new file mode 100644 index 0000000..448874e --- /dev/null +++ b/zhyc-common/src/main/resources/mapper/embryo/ScEmbryoFlushMapper.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, flush_time, donor_female_no, donor_male_no, grade_a_plus, grade_a, grade_b, grade_c, grade_d, cell_2_4, cell_8, cell_16, unfertilized, degenerated, transferred, recipient_cnt, embryo_type, embryo_source, destination, storage_method, flush_operator, collect_operator, remark, created_by, created_at from sc_embryo_flush + + + + + + + + insert into sc_embryo_flush + + flush_time, + donor_female_no, + donor_male_no, + grade_a_plus, + grade_a, + grade_b, + grade_c, + grade_d, + cell_2_4, + cell_8, + cell_16, + unfertilized, + degenerated, + transferred, + recipient_cnt, + embryo_type, + embryo_source, + destination, + storage_method, + flush_operator, + collect_operator, + remark, + created_by, + created_at, + + + #{flushTime}, + #{donorFemaleNo}, + #{donorMaleNo}, + #{gradeAPlus}, + #{gradeA}, + #{gradeB}, + #{gradeC}, + #{gradeD}, + #{cell24}, + #{cell8}, + #{cell16}, + #{unfertilized}, + #{degenerated}, + #{transferred}, + #{recipientCnt}, + #{embryoType}, + #{embryoSource}, + #{destination}, + #{storageMethod}, + #{flushOperator}, + #{collectOperator}, + #{remark}, + #{createdBy}, + #{createdAt}, + + + + + update sc_embryo_flush + + flush_time = #{flushTime}, + donor_female_no = #{donorFemaleNo}, + donor_male_no = #{donorMaleNo}, + grade_a_plus = #{gradeAPlus}, + grade_a = #{gradeA}, + grade_b = #{gradeB}, + grade_c = #{gradeC}, + grade_d = #{gradeD}, + cell_2_4 = #{cell24}, + cell_8 = #{cell8}, + cell_16 = #{cell16}, + unfertilized = #{unfertilized}, + degenerated = #{degenerated}, + transferred = #{transferred}, + recipient_cnt = #{recipientCnt}, + embryo_type = #{embryoType}, + embryo_source = #{embryoSource}, + destination = #{destination}, + storage_method = #{storageMethod}, + flush_operator = #{flushOperator}, + collect_operator = #{collectOperator}, + remark = #{remark}, + created_by = #{createdBy}, + created_at = #{createdAt}, + + where id = #{id} + + + + delete from sc_embryo_flush where id = #{id} + + + + delete from sc_embryo_flush where id in + + #{id} + + + \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScBreedRecordController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScBreedRecordController.java index 50c37c2..499be05 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScBreedRecordController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScBreedRecordController.java @@ -99,7 +99,7 @@ public class ScBreedRecordController extends BaseController } /** - * 根据母羊耳号获取最新配种计划信息(优先从配种计划生成表获取) + * 根据母羊耳号获取最新配种计划信息(优先从配种计划生成表获取) */ @PreAuthorize("@ss.hasPermi('Breeding_records:Breeding_records:query')") @GetMapping(value = "/getLatestBreedPlan/{manageTags}") @@ -139,12 +139,12 @@ public class ScBreedRecordController extends BaseController scBreedRecord.setRamId(ramId.toString()); } - // 验证配种方式 + // 修改:验证配种方式 - 增加3-冲胚 和 4-自然发情人工授精 if (scBreedRecord.getBreedType() == null) { return error("配种方式不能为空"); } - if (scBreedRecord.getBreedType() != 1 && scBreedRecord.getBreedType() != 2) { - return error("配种方式只能是:1-同期发情 或 2-本交"); + if (scBreedRecord.getBreedType() < 1 || scBreedRecord.getBreedType() > 4) { + return error("配种方式只能是:1-同期发情、2-本交、3-冲胚、4-自然发情人工授精"); } // 验证技术员 @@ -186,10 +186,10 @@ public class ScBreedRecordController extends BaseController scBreedRecord.setRamId(ramId.toString()); } - // 验证配种方式 + // 修改:验证配种方式 if (scBreedRecord.getBreedType() != null) { - if (scBreedRecord.getBreedType() != 1 && scBreedRecord.getBreedType() != 2) { - return error("配种方式只能是:1-同期发情 或 2-本交"); + if (scBreedRecord.getBreedType() < 1 || scBreedRecord.getBreedType() > 4) { + return error("配种方式只能是:1-同期发情、2-本交、3-冲胚、4-自然发情人工授精"); } } @@ -223,7 +223,7 @@ public class ScBreedRecordController extends BaseController if (result > 0) { return success("孕检结果同步成功"); } else { - return error("孕检结果同步失败,可能未找到对应的配种记录"); + return error("孕检结果同步失败,可能未找到对应的配种记录"); } } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScEmbryoFlushController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScEmbryoFlushController.java new file mode 100644 index 0000000..d5d5426 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScEmbryoFlushController.java @@ -0,0 +1,129 @@ +package com.zhyc.module.produce.breed.controller; + +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import com.zhyc.common.annotation.Log; +import com.zhyc.common.core.controller.BaseController; +import com.zhyc.common.core.domain.AjaxResult; +import com.zhyc.common.enums.BusinessType; +import com.zhyc.module.produce.breed.domain.ScEmbryoFlush; +import com.zhyc.module.produce.breed.service.IScEmbryoFlushService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 冲胚记录Controller + * + * @author ruoyi + * @date 2025-11-28 + */ +@RestController +@RequestMapping("/embryo/flush") +public class ScEmbryoFlushController extends BaseController +{ + @Autowired + private IScEmbryoFlushService scEmbryoFlushService; + + /** + * 查询冲胚记录列表 + */ + @PreAuthorize("@ss.hasPermi('embryo:flush:list')") + @GetMapping("/list") + public TableDataInfo list(ScEmbryoFlush scEmbryoFlush) + { + startPage(); + List list = scEmbryoFlushService.selectScEmbryoFlushList(scEmbryoFlush); + return getDataTable(list); + } + + /** + * 导出冲胚记录列表 + */ + @PreAuthorize("@ss.hasPermi('embryo:flush:export')") + @Log(title = "冲胚记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ScEmbryoFlush scEmbryoFlush) + { + List list = scEmbryoFlushService.selectScEmbryoFlushList(scEmbryoFlush); + ExcelUtil util = new ExcelUtil(ScEmbryoFlush.class); + util.exportExcel(response, list, "冲胚记录数据"); + } + + /** + * 获取冲胚记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('embryo:flush:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(scEmbryoFlushService.selectScEmbryoFlushById(id)); + } + + /** + * 新增冲胚记录 + */ + @PreAuthorize("@ss.hasPermi('embryo:flush:add')") + @Log(title = "冲胚记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ScEmbryoFlush scEmbryoFlush) + { + return toAjax(scEmbryoFlushService.insertScEmbryoFlush(scEmbryoFlush)); + } + + /** + * 修改冲胚记录 + */ + @PreAuthorize("@ss.hasPermi('embryo:flush:edit')") + @Log(title = "冲胚记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ScEmbryoFlush scEmbryoFlush) + { + return toAjax(scEmbryoFlushService.updateScEmbryoFlush(scEmbryoFlush)); + } + + /** + * 删除冲胚记录 + */ + @PreAuthorize("@ss.hasPermi('embryo:flush:remove')") + @Log(title = "冲胚记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(scEmbryoFlushService.deleteScEmbryoFlushByIds(ids)); + } + + /** + * 根据供体母羊耳号获取关联信息 + * 返回:母羊品种、父号、父号品种、胚胎品种、牧场信息、配种日期等 + */ + @PreAuthorize("@ss.hasPermi('embryo:flush:query')") + @GetMapping("/getDonorInfo") + public AjaxResult getDonorRelatedInfo(@RequestParam("donorFemaleNo") String donorFemaleNo) + { + Map info = scEmbryoFlushService.getDonorRelatedInfo(donorFemaleNo); + return success(info); + } + + /** + * 获取供体母羊下拉列表 + */ + @PreAuthorize("@ss.hasPermi('embryo:flush:query')") + @GetMapping("/donorFemaleList") + public AjaxResult getDonorFemaleList() + { + List> list = scEmbryoFlushService.selectDonorFemaleList(); + return success(list); + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScEmbryoFlush.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScEmbryoFlush.java new file mode 100644 index 0000000..a02cead --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScEmbryoFlush.java @@ -0,0 +1,504 @@ +package com.zhyc.module.produce.breed.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +/** + * 冲胚记录-用户录入对象 sc_embryo_flush + * + * @author ruoyi + * @date 2025-11-28 + */ +public class ScEmbryoFlush extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private Long id; + + /** 冲胚时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "冲胚时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date flushTime; + + /** 供体母号 */ + @Excel(name = "供体母号") + private String donorFemaleNo; + + /** 供体母羊品种 */ + @Excel(name = "供体母羊品种") + private String donorFemaleVariety; + + /** 供体父号 */ + @Excel(name = "供体父号") + private String donorMaleNo; + + /** 供体公羊品种 */ + @Excel(name = "供体公羊品种") + private String donorMaleVariety; + + /** 胚胎品种 */ + @Excel(name = "胚胎品种") + private String embryoVariety; + + /** 胎龄(天) */ + @Excel(name = "胎龄(天)") + private Integer embryoAge; + + /** A+级胚胎数 */ + @Excel(name = "A+级") + private Integer gradeAPlus; + + /** A级胚胎数 */ + @Excel(name = "A级") + private Integer gradeA; + + /** B级胚胎数 */ + @Excel(name = "B级") + private Integer gradeB; + + /** C级胚胎数 */ + @Excel(name = "C级") + private Integer gradeC; + + /** D级胚胎数 */ + @Excel(name = "D级") + private Integer gradeD; + + /** 2/4细胞期 */ + @Excel(name = "2/4细胞") + private Integer cell24; + + /** 8细胞期 */ + @Excel(name = "8细胞") + private Integer cell8; + + /** 16细胞期 */ + @Excel(name = "16细胞") + private Integer cell16; + + /** 未受精数 */ + @Excel(name = "未受精") + private Integer unfertilized; + + /** 退化数 */ + @Excel(name = "退化") + private Integer degenerated; + + /** 冲胚数(总和) */ + @Excel(name = "冲胚数") + private Integer totalEmbryo; + + /** 有效胚(A+到D级总和) */ + @Excel(name = "有效胚") + private Integer validEmbryo; + + /** 移胚数 */ + @Excel(name = "移胚数") + private Integer transferred; + + /** 移植受体数 */ + @Excel(name = "移植受体数") + private Integer recipientCnt; + + /** 胚胎类型 */ + @Excel(name = "胚胎类型") + private String embryoType; + + /** 胚胎来源 */ + @Excel(name = "胚胎来源") + private String embryoSource; + + /** 去向 */ + @Excel(name = "去向") + private String destination; + + /** 存储方式 */ + @Excel(name = "存储方式") + private String storageMethod; + + /** 冲胚人 */ + @Excel(name = "冲胚人") + private String flushOperator; + + /** 捡胚人 */ + @Excel(name = "捡胚人") + private String collectOperator; + + /** 所在牧场ID */ + private Long ranchId; + + /** 所在牧场名称 */ + @Excel(name = "所在牧场") + private String ranchName; + + /** 创建人 */ + private String createdBy; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createdAt; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setFlushTime(Date flushTime) + { + this.flushTime = flushTime; + } + + public Date getFlushTime() + { + return flushTime; + } + + public void setDonorFemaleNo(String donorFemaleNo) + { + this.donorFemaleNo = donorFemaleNo; + } + + public String getDonorFemaleNo() + { + return donorFemaleNo; + } + + public void setDonorFemaleVariety(String donorFemaleVariety) + { + this.donorFemaleVariety = donorFemaleVariety; + } + + public String getDonorFemaleVariety() + { + return donorFemaleVariety; + } + + public void setDonorMaleNo(String donorMaleNo) + { + this.donorMaleNo = donorMaleNo; + } + + public String getDonorMaleNo() + { + return donorMaleNo; + } + + public void setDonorMaleVariety(String donorMaleVariety) + { + this.donorMaleVariety = donorMaleVariety; + } + + public String getDonorMaleVariety() + { + return donorMaleVariety; + } + + public void setEmbryoVariety(String embryoVariety) + { + this.embryoVariety = embryoVariety; + } + + public String getEmbryoVariety() + { + return embryoVariety; + } + + public void setEmbryoAge(Integer embryoAge) + { + this.embryoAge = embryoAge; + } + + public Integer getEmbryoAge() + { + return embryoAge; + } + + public void setGradeAPlus(Integer gradeAPlus) + { + this.gradeAPlus = gradeAPlus; + } + + public Integer getGradeAPlus() + { + return gradeAPlus; + } + + public void setGradeA(Integer gradeA) + { + this.gradeA = gradeA; + } + + public Integer getGradeA() + { + return gradeA; + } + + public void setGradeB(Integer gradeB) + { + this.gradeB = gradeB; + } + + public Integer getGradeB() + { + return gradeB; + } + + public void setGradeC(Integer gradeC) + { + this.gradeC = gradeC; + } + + public Integer getGradeC() + { + return gradeC; + } + + public void setGradeD(Integer gradeD) + { + this.gradeD = gradeD; + } + + public Integer getGradeD() + { + return gradeD; + } + + public void setCell24(Integer cell24) + { + this.cell24 = cell24; + } + + public Integer getCell24() + { + return cell24; + } + + public void setCell8(Integer cell8) + { + this.cell8 = cell8; + } + + public Integer getCell8() + { + return cell8; + } + + public void setCell16(Integer cell16) + { + this.cell16 = cell16; + } + + public Integer getCell16() + { + return cell16; + } + + public void setUnfertilized(Integer unfertilized) + { + this.unfertilized = unfertilized; + } + + public Integer getUnfertilized() + { + return unfertilized; + } + + public void setDegenerated(Integer degenerated) + { + this.degenerated = degenerated; + } + + public Integer getDegenerated() + { + return degenerated; + } + + public void setTotalEmbryo(Integer totalEmbryo) + { + this.totalEmbryo = totalEmbryo; + } + + public Integer getTotalEmbryo() + { + return totalEmbryo; + } + + public void setValidEmbryo(Integer validEmbryo) + { + this.validEmbryo = validEmbryo; + } + + public Integer getValidEmbryo() + { + return validEmbryo; + } + + public void setTransferred(Integer transferred) + { + this.transferred = transferred; + } + + public Integer getTransferred() + { + return transferred; + } + + public void setRecipientCnt(Integer recipientCnt) + { + this.recipientCnt = recipientCnt; + } + + public Integer getRecipientCnt() + { + return recipientCnt; + } + + public void setEmbryoType(String embryoType) + { + this.embryoType = embryoType; + } + + public String getEmbryoType() + { + return embryoType; + } + + public void setEmbryoSource(String embryoSource) + { + this.embryoSource = embryoSource; + } + + public String getEmbryoSource() + { + return embryoSource; + } + + public void setDestination(String destination) + { + this.destination = destination; + } + + public String getDestination() + { + return destination; + } + + public void setStorageMethod(String storageMethod) + { + this.storageMethod = storageMethod; + } + + public String getStorageMethod() + { + return storageMethod; + } + + public void setFlushOperator(String flushOperator) + { + this.flushOperator = flushOperator; + } + + public String getFlushOperator() + { + return flushOperator; + } + + public void setCollectOperator(String collectOperator) + { + this.collectOperator = collectOperator; + } + + public String getCollectOperator() + { + return collectOperator; + } + + public void setRanchId(Long ranchId) + { + this.ranchId = ranchId; + } + + public Long getRanchId() + { + return ranchId; + } + + public void setRanchName(String ranchName) + { + this.ranchName = ranchName; + } + + public String getRanchName() + { + return ranchName; + } + + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + public String getCreatedBy() + { + return createdBy; + } + + public void setCreatedAt(Date createdAt) + { + this.createdAt = createdAt; + } + + public Date getCreatedAt() + { + return createdAt; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("flushTime", getFlushTime()) + .append("donorFemaleNo", getDonorFemaleNo()) + .append("donorFemaleVariety", getDonorFemaleVariety()) + .append("donorMaleNo", getDonorMaleNo()) + .append("donorMaleVariety", getDonorMaleVariety()) + .append("embryoVariety", getEmbryoVariety()) + .append("embryoAge", getEmbryoAge()) + .append("gradeAPlus", getGradeAPlus()) + .append("gradeA", getGradeA()) + .append("gradeB", getGradeB()) + .append("gradeC", getGradeC()) + .append("gradeD", getGradeD()) + .append("cell24", getCell24()) + .append("cell8", getCell8()) + .append("cell16", getCell16()) + .append("unfertilized", getUnfertilized()) + .append("degenerated", getDegenerated()) + .append("totalEmbryo", getTotalEmbryo()) + .append("validEmbryo", getValidEmbryo()) + .append("transferred", getTransferred()) + .append("recipientCnt", getRecipientCnt()) + .append("embryoType", getEmbryoType()) + .append("embryoSource", getEmbryoSource()) + .append("destination", getDestination()) + .append("storageMethod", getStorageMethod()) + .append("flushOperator", getFlushOperator()) + .append("collectOperator", getCollectOperator()) + .append("ranchId", getRanchId()) + .append("ranchName", getRanchName()) + .append("remark", getRemark()) + .append("createdBy", getCreatedBy()) + .append("createdAt", getCreatedAt()) + .toString(); + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScEmbryoFlushMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScEmbryoFlushMapper.java new file mode 100644 index 0000000..1ddd6e0 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScEmbryoFlushMapper.java @@ -0,0 +1,86 @@ +package com.zhyc.module.produce.breed.mapper; + +import java.util.List; +import java.util.Map; +import com.zhyc.module.produce.breed.domain.ScEmbryoFlush; +import org.apache.ibatis.annotations.Param; + +/** + * 冲胚记录-用户录入Mapper接口 + * + * @author ruoyi + * @date 2025-11-28 + */ +public interface ScEmbryoFlushMapper +{ + /** + * 查询冲胚记录-用户录入 + * + * @param id 冲胚记录-用户录入主键 + * @return 冲胚记录-用户录入 + */ + public ScEmbryoFlush selectScEmbryoFlushById(Long id); + + /** + * 查询冲胚记录-用户录入列表 + * + * @param scEmbryoFlush 冲胚记录-用户录入 + * @return 冲胚记录-用户录入集合 + */ + public List selectScEmbryoFlushList(ScEmbryoFlush scEmbryoFlush); + + /** + * 新增冲胚记录-用户录入 + * + * @param scEmbryoFlush 冲胚记录-用户录入 + * @return 结果 + */ + public int insertScEmbryoFlush(ScEmbryoFlush scEmbryoFlush); + + /** + * 修改冲胚记录-用户录入 + * + * @param scEmbryoFlush 冲胚记录-用户录入 + * @return 结果 + */ + public int updateScEmbryoFlush(ScEmbryoFlush scEmbryoFlush); + + /** + * 删除冲胚记录-用户录入 + * + * @param id 冲胚记录-用户录入主键 + * @return 结果 + */ + public int deleteScEmbryoFlushById(Long id); + + /** + * 批量删除冲胚记录-用户录入 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteScEmbryoFlushByIds(Long[] ids); + + /** + * 根据耳号查询羊只信息(从sheep_file视图) + * + * @param manageTag 管理耳号 + * @return 羊只信息Map(variety品种, varietyId品种ID, ranchId牧场ID, ranchName牧场名称) + */ + public Map selectSheepInfoByManageTag(@Param("manageTag") String manageTag); + + /** + * 根据母羊耳号查询最近一条配种记录 + * + * @param eweManageTag 母羊耳号 + * @return 配种记录(ramId公羊耳号, matingDate配种日期) + */ + public Map selectBreedRecordByEwe(@Param("eweManageTag") String eweManageTag); + + /** + * 查询所有母羊列表(用于下拉选择) + * + * @return 母羊列表 + */ + public List> selectDonorFemaleList(); +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScEmbryoFlushService.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScEmbryoFlushService.java new file mode 100644 index 0000000..a02fd99 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScEmbryoFlushService.java @@ -0,0 +1,86 @@ +package com.zhyc.module.produce.breed.service; + +import java.util.List; +import java.util.Map; +import com.zhyc.module.produce.breed.domain.ScEmbryoFlush; + +/** + * 冲胚记录-用户录入Service接口 + * + * @author ruoyi + * @date 2025-11-28 + */ +public interface IScEmbryoFlushService +{ + /** + * 查询冲胚记录-用户录入 + * + * @param id 冲胚记录-用户录入主键 + * @return 冲胚记录-用户录入 + */ + public ScEmbryoFlush selectScEmbryoFlushById(Long id); + + /** + * 查询冲胚记录-用户录入列表 + * + * @param scEmbryoFlush 冲胚记录-用户录入 + * @return 冲胚记录-用户录入集合 + */ + public List selectScEmbryoFlushList(ScEmbryoFlush scEmbryoFlush); + + /** + * 新增冲胚记录-用户录入 + * + * @param scEmbryoFlush 冲胚记录-用户录入 + * @return 结果 + */ + public int insertScEmbryoFlush(ScEmbryoFlush scEmbryoFlush); + + /** + * 修改冲胚记录-用户录入 + * + * @param scEmbryoFlush 冲胚记录-用户录入 + * @return 结果 + */ + public int updateScEmbryoFlush(ScEmbryoFlush scEmbryoFlush); + + /** + * 批量删除冲胚记录-用户录入 + * + * @param ids 需要删除的冲胚记录-用户录入主键集合 + * @return 结果 + */ + public int deleteScEmbryoFlushByIds(Long[] ids); + + /** + * 删除冲胚记录-用户录入信息 + * + * @param id 冲胚记录-用户录入主键 + * @return 结果 + */ + public int deleteScEmbryoFlushById(Long id); + + /** + * 根据供体母羊耳号获取关联信息 + * + * @param donorFemaleNo 供体母羊耳号 + * @return 关联信息(母羊品种、父号、父号品种、牧场信息、配种日期等) + */ + public Map getDonorRelatedInfo(String donorFemaleNo); + + /** + * 根据父母品种计算胚胎品种 + * + * @param maleVariety 公羊品种 + * @param femaleVariety 母羊品种 + * @return 胚胎品种 + */ + public String calculateEmbryoVariety(String maleVariety, String femaleVariety); + + /** + * 查询所有供体母羊列表(用于下拉选择) + * + * @return 母羊列表 + */ + public List> selectDonorFemaleList(); +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScEmbryoFlushServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScEmbryoFlushServiceImpl.java new file mode 100644 index 0000000..3af35d8 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScEmbryoFlushServiceImpl.java @@ -0,0 +1,326 @@ +package com.zhyc.module.produce.breed.service.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhyc.module.produce.breed.mapper.ScEmbryoFlushMapper; +import com.zhyc.module.produce.breed.domain.ScEmbryoFlush; +import com.zhyc.module.produce.breed.service.IScEmbryoFlushService; + +/** + * 冲胚记录Service业务层处理 + * + * @author ruoyi + * @date 2025-11-28 + */ +@Service +public class ScEmbryoFlushServiceImpl implements IScEmbryoFlushService +{ + @Autowired + private ScEmbryoFlushMapper scEmbryoFlushMapper; + + /** + * 品种ID常量 + * 1-湖羊, 2-东佛里生, 3-回交, 4-级杂一代, 5-级杂二代, 6-级杂三代, 7-1世代, 8-2世代, 9-3世代, 10-4世代 + */ + private static final int VARIETY_HUYANG = 1; // 湖羊 + private static final int VARIETY_DONGFULISHENG = 2; // 东佛里生 + private static final int VARIETY_HUIJIAO = 3; // 回交 + private static final int VARIETY_JIZA_1 = 4; // 级杂一代 + private static final int VARIETY_JIZA_2 = 5; // 级杂二代 + private static final int VARIETY_JIZA_3 = 6; // 级杂三代 + private static final int VARIETY_SHIDAI_1 = 7; // 1世代 + private static final int VARIETY_SHIDAI_2 = 8; // 2世代 + private static final int VARIETY_SHIDAI_3 = 9; // 3世代 + private static final int VARIETY_SHIDAI_4 = 10; // 4世代 + + /** 品种ID到名称的映射 */ + private static final Map VARIETY_NAME_MAP = new HashMap<>(); + static { + VARIETY_NAME_MAP.put(1, "湖羊"); + VARIETY_NAME_MAP.put(2, "东佛里生"); + VARIETY_NAME_MAP.put(3, "回交"); + VARIETY_NAME_MAP.put(4, "级杂一代"); + VARIETY_NAME_MAP.put(5, "级杂二代"); + VARIETY_NAME_MAP.put(6, "级杂三代"); + VARIETY_NAME_MAP.put(7, "1世代"); + VARIETY_NAME_MAP.put(8, "2世代"); + VARIETY_NAME_MAP.put(9, "3世代"); + VARIETY_NAME_MAP.put(10, "4世代"); + } + + @Override + public ScEmbryoFlush selectScEmbryoFlushById(Long id) + { + return scEmbryoFlushMapper.selectScEmbryoFlushById(id); + } + + @Override + public List selectScEmbryoFlushList(ScEmbryoFlush scEmbryoFlush) + { + return scEmbryoFlushMapper.selectScEmbryoFlushList(scEmbryoFlush); + } + + @Override + public int insertScEmbryoFlush(ScEmbryoFlush scEmbryoFlush) + { + calculateEmbryoCount(scEmbryoFlush); + return scEmbryoFlushMapper.insertScEmbryoFlush(scEmbryoFlush); + } + + @Override + public int updateScEmbryoFlush(ScEmbryoFlush scEmbryoFlush) + { + calculateEmbryoCount(scEmbryoFlush); + return scEmbryoFlushMapper.updateScEmbryoFlush(scEmbryoFlush); + } + + @Override + public int deleteScEmbryoFlushByIds(Long[] ids) + { + return scEmbryoFlushMapper.deleteScEmbryoFlushByIds(ids); + } + + @Override + public int deleteScEmbryoFlushById(Long id) + { + return scEmbryoFlushMapper.deleteScEmbryoFlushById(id); + } + + /** + * 计算冲胚数和有效胚数量 + */ + private void calculateEmbryoCount(ScEmbryoFlush flush) + { + int gradeAPlus = flush.getGradeAPlus() != null ? flush.getGradeAPlus() : 0; + int gradeA = flush.getGradeA() != null ? flush.getGradeA() : 0; + int gradeB = flush.getGradeB() != null ? flush.getGradeB() : 0; + int gradeC = flush.getGradeC() != null ? flush.getGradeC() : 0; + int gradeD = flush.getGradeD() != null ? flush.getGradeD() : 0; + int cell24 = flush.getCell24() != null ? flush.getCell24() : 0; + int cell8 = flush.getCell8() != null ? flush.getCell8() : 0; + int cell16 = flush.getCell16() != null ? flush.getCell16() : 0; + int unfertilized = flush.getUnfertilized() != null ? flush.getUnfertilized() : 0; + int degenerated = flush.getDegenerated() != null ? flush.getDegenerated() : 0; + + // 有效胚 = A+ + A + B + C + D + flush.setValidEmbryo(gradeAPlus + gradeA + gradeB + gradeC + gradeD); + + // 冲胚数 = 所有数量求和 + flush.setTotalEmbryo(gradeAPlus + gradeA + gradeB + gradeC + gradeD + + cell24 + cell8 + cell16 + unfertilized + degenerated); + } + + /** + * 根据供体母羊耳号获取关联信息 + */ + @Override + public Map getDonorRelatedInfo(String donorFemaleNo) + { + Map result = new HashMap<>(); + + if (donorFemaleNo == null || donorFemaleNo.trim().isEmpty()) { + return result; + } + + // 1. 查询母羊信息 + Map femaleInfo = scEmbryoFlushMapper.selectSheepInfoByManageTag(donorFemaleNo); + if (femaleInfo == null || femaleInfo.isEmpty()) { + return result; + } + + String femaleVariety = (String) femaleInfo.get("variety"); + Integer femaleVarietyId = getIntValue(femaleInfo.get("varietyId")); + + result.put("donorFemaleVariety", femaleVariety); + result.put("donorFemaleVarietyId", femaleVarietyId); + result.put("ranchId", femaleInfo.get("ranchId")); + result.put("ranchName", femaleInfo.get("ranchName")); + + // 2. 查询配种记录获取公羊信息 + Map breedRecord = scEmbryoFlushMapper.selectBreedRecordByEwe(donorFemaleNo); + if (breedRecord != null && !breedRecord.isEmpty()) { + String ramId = (String) breedRecord.get("ramId"); + result.put("donorMaleNo", ramId); + result.put("matingDate", breedRecord.get("matingDate")); + + // 3. 查询公羊品种 + if (ramId != null && !ramId.trim().isEmpty()) { + Map maleInfo = scEmbryoFlushMapper.selectSheepInfoByManageTag(ramId); + if (maleInfo != null && !maleInfo.isEmpty()) { + String maleVariety = (String) maleInfo.get("variety"); + Integer maleVarietyId = getIntValue(maleInfo.get("varietyId")); + + result.put("donorMaleVariety", maleVariety); + result.put("donorMaleVarietyId", maleVarietyId); + + // 4. 根据品种ID计算胚胎品种 + if (maleVarietyId != null && femaleVarietyId != null) { + String embryoVariety = calculateEmbryoVarietyById(maleVarietyId, femaleVarietyId); + result.put("embryoVariety", embryoVariety); + } + } + } + } + + return result; + } + + /** + * 安全获取Integer值 + */ + private Integer getIntValue(Object obj) { + if (obj == null) { + return null; + } + if (obj instanceof Integer) { + return (Integer) obj; + } + if (obj instanceof Long) { + return ((Long) obj).intValue(); + } + if (obj instanceof Number) { + return ((Number) obj).intValue(); + } + try { + return Integer.parseInt(obj.toString()); + } catch (NumberFormatException e) { + return null; + } + } + + /** + * 根据品种名称获取ID + */ + private Integer getVarietyIdByName(String name) { + if (name == null) return null; + for (Map.Entry entry : VARIETY_NAME_MAP.entrySet()) { + if (entry.getValue().equals(name)) { + return entry.getKey(); + } + } + return null; + } + + /** + * 根据父母品种名称计算胚胎品种(接口方法) + */ + @Override + public String calculateEmbryoVariety(String maleVariety, String femaleVariety) + { + Integer maleId = getVarietyIdByName(maleVariety); + Integer femaleId = getVarietyIdByName(femaleVariety); + if (maleId == null || femaleId == null) { + return null; + } + return calculateEmbryoVarietyById(maleId, femaleId); + } + + /** + * 根据父母品种ID计算胚胎品种(核心计算方法) + * + * 品种规则: + * 1-湖羊, 2-东佛里生, 3-回交, 4-级杂一代, 5-级杂二代, 6-级杂三代, 7-1世代, 8-2世代, 9-3世代, 10-4世代 + * + * 计算规则(根据图片): + * - 湖羊(公) × 湖羊(母) → 湖羊 + * - 东佛里生(公) × 东佛里生(母) → 东佛里生 + * - 东佛里生(公) × 湖羊(母) → 级杂一代 + * - 东佛里生(公) × 级杂一代(母) → 级杂二代 + * - 东佛里生(公) × 级杂二代(母) → 级杂三代 + * - 东佛里生(公) × 级杂三代(母) → 东佛里生 + * - 湖羊(公) × 级杂三代(母) → 回交 + * - 湖羊(公) × 回交(母) → 回交 + * - 世代计算... + * + * @param maleVarietyId 公羊品种ID + * @param femaleVarietyId 母羊品种ID + * @return 胚胎品种名称 + */ + public String calculateEmbryoVarietyById(Integer maleVarietyId, Integer femaleVarietyId) + { + if (maleVarietyId == null || femaleVarietyId == null) { + return null; + } + + int male = maleVarietyId; + int female = femaleVarietyId; + + // 湖羊(公) × 湖羊(母) → 湖羊 + if (male == VARIETY_HUYANG && female == VARIETY_HUYANG) { + return VARIETY_NAME_MAP.get(VARIETY_HUYANG); + } + + // 东佛里生(公) × 东佛里生(母) → 东佛里生 + if (male == VARIETY_DONGFULISHENG && female == VARIETY_DONGFULISHENG) { + return VARIETY_NAME_MAP.get(VARIETY_DONGFULISHENG); + } + + // 东佛里生(公) × 湖羊(母) → 级杂一代 + if (male == VARIETY_DONGFULISHENG && female == VARIETY_HUYANG) { + return VARIETY_NAME_MAP.get(VARIETY_JIZA_1); + } + + // 东佛里生(公) × 级杂一代(母) → 级杂二代 + if (male == VARIETY_DONGFULISHENG && female == VARIETY_JIZA_1) { + return VARIETY_NAME_MAP.get(VARIETY_JIZA_2); + } + + // 东佛里生(公) × 级杂二代(母) → 级杂三代 + if (male == VARIETY_DONGFULISHENG && female == VARIETY_JIZA_2) { + return VARIETY_NAME_MAP.get(VARIETY_JIZA_3); + } + + // 东佛里生(公) × 级杂三代(母) → 东佛里生 + if (male == VARIETY_DONGFULISHENG && female == VARIETY_JIZA_3) { + return VARIETY_NAME_MAP.get(VARIETY_DONGFULISHENG); + } + + // 湖羊(公) × 级杂三代(母) → 回交 + if (male == VARIETY_HUYANG && female == VARIETY_JIZA_3) { + return VARIETY_NAME_MAP.get(VARIETY_HUIJIAO); + } + + // 湖羊(公) × 回交(母) → 回交 + if (male == VARIETY_HUYANG && female == VARIETY_HUIJIAO) { + return VARIETY_NAME_MAP.get(VARIETY_HUIJIAO); + } + + // ========== 世代计算规则 ========== + // 级杂二代(BM)或n世代(SM) × 级杂一代/级杂二代/级杂三代/回交(公) → 世代 + + // 判断公羊是否为可产生世代的品种(级杂一代/二代/三代/回交) + boolean isMaleForShidai = (male == VARIETY_JIZA_1 || male == VARIETY_JIZA_2 || + male == VARIETY_JIZA_3 || male == VARIETY_HUIJIAO); + + if (isMaleForShidai) { + // 级杂二代(母) × 以上公羊 → 1世代 + if (female == VARIETY_JIZA_2) { + return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_1); + } + // 1世代(母) × 以上公羊 → 2世代 + if (female == VARIETY_SHIDAI_1) { + return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_2); + } + // 2世代(母) × 以上公羊 → 3世代 + if (female == VARIETY_SHIDAI_2) { + return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_3); + } + // 3世代(母) × 以上公羊 → 4世代 + if (female == VARIETY_SHIDAI_3) { + return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_4); + } + } + + // 默认返回null,表示无法计算或规则未覆盖 + return null; + } + + @Override + public List> selectDonorFemaleList() + { + return scEmbryoFlushMapper.selectDonorFemaleList(); + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/breed/ScBreedRecordMapper.xml b/zhyc-module/src/main/resources/mapper/produce/breed/ScBreedRecordMapper.xml index c03c285..639480d 100644 --- a/zhyc-module/src/main/resources/mapper/produce/breed/ScBreedRecordMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/breed/ScBreedRecordMapper.xml @@ -53,7 +53,7 @@ br.breed_type, br.create_by, br.create_time, - -- 母羊信息(从视图获取) + -- 母羊信息(从视图获取) ewe_view.bs_manage_tags as ewe_manage_tags, ewe_view.variety as ewe_variety, ewe_view.parity as ewe_parity, @@ -65,16 +65,18 @@ ewe_view.dr_ranch as ranch_name, ewe_view.name as sheep_type, ewe_view.mating_total as mating_count, - -- 公羊信息(从视图获取) + -- 公羊信息(从视图获取) ram_view.bs_manage_tags as ram_manage_tags, ram_view.variety as ram_variety, - -- 配种方式显示 + -- 配种方式显示(修改:增加3-冲胚、4-自然发情人工授精) CASE br.breed_type WHEN 1 THEN '同期发情' WHEN 2 THEN '本交' + WHEN 3 THEN '冲胚' + WHEN 4 THEN '自然发情人工授精' ELSE '未知' END as mating_type, - -- 发情后配种时间(小时数) + -- 发情后配种时间(小时数) TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning, -- 孕检相关信息 pr.datetime as pregnancy_check_date, @@ -225,6 +227,8 @@ CASE bp.breed_type WHEN 1 THEN '同期发情' WHEN 2 THEN '本交' + WHEN 3 THEN '冲胚' + WHEN 4 THEN '自然发情人工授精' ELSE '未知' END as breed_type_name, TIMESTAMPDIFF(HOUR, NOW(), NOW()) as hours_since_plan @@ -236,7 +240,7 @@ limit 1 - + + + + + and flush_time between #{params.beginFlushTime} and #{params.endFlushTime} + + and donor_female_no like concat('%', #{donorFemaleNo}, '%') + and donor_male_no like concat('%', #{donorMaleNo}, '%') + and embryo_variety = #{embryoVariety} + and embryo_type = #{embryoType} + and embryo_source = #{embryoSource} + and flush_operator like concat('%', #{flushOperator}, '%') + and collect_operator like concat('%', #{collectOperator}, '%') + and ranch_id = #{ranchId} + + order by flush_time desc + + + + + + insert into sc_embryo_flush + + flush_time, + donor_female_no, + donor_female_variety, + donor_male_no, + donor_male_variety, + embryo_variety, + embryo_age, + grade_a_plus, + grade_a, + grade_b, + grade_c, + grade_d, + cell_2_4, + cell_8, + cell_16, + unfertilized, + degenerated, + total_embryo, + valid_embryo, + transferred, + recipient_cnt, + embryo_type, + embryo_source, + destination, + storage_method, + flush_operator, + collect_operator, + ranch_id, + ranch_name, + remark, + + + #{flushTime}, + #{donorFemaleNo}, + #{donorFemaleVariety}, + #{donorMaleNo}, + #{donorMaleVariety}, + #{embryoVariety}, + #{embryoAge}, + #{gradeAPlus}, + #{gradeA}, + #{gradeB}, + #{gradeC}, + #{gradeD}, + #{cell24}, + #{cell8}, + #{cell16}, + #{unfertilized}, + #{degenerated}, + #{totalEmbryo}, + #{validEmbryo}, + #{transferred}, + #{recipientCnt}, + #{embryoType}, + #{embryoSource}, + #{destination}, + #{storageMethod}, + #{flushOperator}, + #{collectOperator}, + #{ranchId}, + #{ranchName}, + #{remark}, + + + + + update sc_embryo_flush + + flush_time = #{flushTime}, + donor_female_no = #{donorFemaleNo}, + donor_female_variety = #{donorFemaleVariety}, + donor_male_no = #{donorMaleNo}, + donor_male_variety = #{donorMaleVariety}, + embryo_variety = #{embryoVariety}, + embryo_age = #{embryoAge}, + grade_a_plus = #{gradeAPlus}, + grade_a = #{gradeA}, + grade_b = #{gradeB}, + grade_c = #{gradeC}, + grade_d = #{gradeD}, + cell_2_4 = #{cell24}, + cell_8 = #{cell8}, + cell_16 = #{cell16}, + unfertilized = #{unfertilized}, + degenerated = #{degenerated}, + total_embryo = #{totalEmbryo}, + valid_embryo = #{validEmbryo}, + transferred = #{transferred}, + recipient_cnt = #{recipientCnt}, + embryo_type = #{embryoType}, + embryo_source = #{embryoSource}, + destination = #{destination}, + storage_method = #{storageMethod}, + flush_operator = #{flushOperator}, + collect_operator = #{collectOperator}, + ranch_id = #{ranchId}, + ranch_name = #{ranchName}, + remark = #{remark}, + + where id = #{id} + + + + delete from sc_embryo_flush where id = #{id} + + + + delete from sc_embryo_flush where id in + + #{id} + + + + + + + + + + + + + \ No newline at end of file