配种记录和冲胚记录

This commit is contained in:
zyk 2025-11-30 13:25:48 +08:00
parent 96ac2f2dbf
commit e79d57f6ce
9 changed files with 1549 additions and 13 deletions

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.embryo.mapper.ScEmbryoFlushMapper">
<resultMap type="ScEmbryoFlush" id="ScEmbryoFlushResult">
<result property="id" column="id" />
<result property="flushTime" column="flush_time" />
<result property="donorFemaleNo" column="donor_female_no" />
<result property="donorMaleNo" column="donor_male_no" />
<result property="gradeAPlus" column="grade_a_plus" />
<result property="gradeA" column="grade_a" />
<result property="gradeB" column="grade_b" />
<result property="gradeC" column="grade_c" />
<result property="gradeD" column="grade_d" />
<result property="cell24" column="cell_2_4" />
<result property="cell8" column="cell_8" />
<result property="cell16" column="cell_16" />
<result property="unfertilized" column="unfertilized" />
<result property="degenerated" column="degenerated" />
<result property="transferred" column="transferred" />
<result property="recipientCnt" column="recipient_cnt" />
<result property="embryoType" column="embryo_type" />
<result property="embryoSource" column="embryo_source" />
<result property="destination" column="destination" />
<result property="storageMethod" column="storage_method" />
<result property="flushOperator" column="flush_operator" />
<result property="collectOperator" column="collect_operator" />
<result property="remark" column="remark" />
<result property="createdBy" column="created_by" />
<result property="createdAt" column="created_at" />
</resultMap>
<sql id="selectScEmbryoFlushVo">
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
</sql>
<select id="selectScEmbryoFlushList" parameterType="ScEmbryoFlush" resultMap="ScEmbryoFlushResult">
<include refid="selectScEmbryoFlushVo"/>
<where>
<if test="flushTime != null "> and flush_time = #{flushTime}</if>
<if test="donorFemaleNo != null and donorFemaleNo != ''"> and donor_female_no = #{donorFemaleNo}</if>
<if test="donorMaleNo != null and donorMaleNo != ''"> and donor_male_no = #{donorMaleNo}</if>
<if test="gradeAPlus != null "> and grade_a_plus = #{gradeAPlus}</if>
<if test="gradeA != null "> and grade_a = #{gradeA}</if>
<if test="gradeB != null "> and grade_b = #{gradeB}</if>
<if test="gradeC != null "> and grade_c = #{gradeC}</if>
<if test="gradeD != null "> and grade_d = #{gradeD}</if>
<if test="cell24 != null "> and cell_2_4 = #{cell24}</if>
<if test="cell8 != null "> and cell_8 = #{cell8}</if>
<if test="cell16 != null "> and cell_16 = #{cell16}</if>
<if test="unfertilized != null "> and unfertilized = #{unfertilized}</if>
<if test="degenerated != null "> and degenerated = #{degenerated}</if>
<if test="transferred != null "> and transferred = #{transferred}</if>
<if test="recipientCnt != null "> and recipient_cnt = #{recipientCnt}</if>
<if test="embryoType != null and embryoType != ''"> and embryo_type = #{embryoType}</if>
<if test="embryoSource != null and embryoSource != ''"> and embryo_source = #{embryoSource}</if>
<if test="destination != null and destination != ''"> and destination = #{destination}</if>
<if test="storageMethod != null and storageMethod != ''"> and storage_method = #{storageMethod}</if>
<if test="flushOperator != null and flushOperator != ''"> and flush_operator = #{flushOperator}</if>
<if test="collectOperator != null and collectOperator != ''"> and collect_operator = #{collectOperator}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
</where>
</select>
<select id="selectScEmbryoFlushById" parameterType="Long" resultMap="ScEmbryoFlushResult">
<include refid="selectScEmbryoFlushVo"/>
where id = #{id}
</select>
<insert id="insertScEmbryoFlush" parameterType="ScEmbryoFlush" useGeneratedKeys="true" keyProperty="id">
insert into sc_embryo_flush
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="flushTime != null">flush_time,</if>
<if test="donorFemaleNo != null and donorFemaleNo != ''">donor_female_no,</if>
<if test="donorMaleNo != null and donorMaleNo != ''">donor_male_no,</if>
<if test="gradeAPlus != null">grade_a_plus,</if>
<if test="gradeA != null">grade_a,</if>
<if test="gradeB != null">grade_b,</if>
<if test="gradeC != null">grade_c,</if>
<if test="gradeD != null">grade_d,</if>
<if test="cell24 != null">cell_2_4,</if>
<if test="cell8 != null">cell_8,</if>
<if test="cell16 != null">cell_16,</if>
<if test="unfertilized != null">unfertilized,</if>
<if test="degenerated != null">degenerated,</if>
<if test="transferred != null">transferred,</if>
<if test="recipientCnt != null">recipient_cnt,</if>
<if test="embryoType != null and embryoType != ''">embryo_type,</if>
<if test="embryoSource != null and embryoSource != ''">embryo_source,</if>
<if test="destination != null">destination,</if>
<if test="storageMethod != null">storage_method,</if>
<if test="flushOperator != null and flushOperator != ''">flush_operator,</if>
<if test="collectOperator != null and collectOperator != ''">collect_operator,</if>
<if test="remark != null">remark,</if>
<if test="createdBy != null and createdBy != ''">created_by,</if>
<if test="createdAt != null">created_at,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="flushTime != null">#{flushTime},</if>
<if test="donorFemaleNo != null and donorFemaleNo != ''">#{donorFemaleNo},</if>
<if test="donorMaleNo != null and donorMaleNo != ''">#{donorMaleNo},</if>
<if test="gradeAPlus != null">#{gradeAPlus},</if>
<if test="gradeA != null">#{gradeA},</if>
<if test="gradeB != null">#{gradeB},</if>
<if test="gradeC != null">#{gradeC},</if>
<if test="gradeD != null">#{gradeD},</if>
<if test="cell24 != null">#{cell24},</if>
<if test="cell8 != null">#{cell8},</if>
<if test="cell16 != null">#{cell16},</if>
<if test="unfertilized != null">#{unfertilized},</if>
<if test="degenerated != null">#{degenerated},</if>
<if test="transferred != null">#{transferred},</if>
<if test="recipientCnt != null">#{recipientCnt},</if>
<if test="embryoType != null and embryoType != ''">#{embryoType},</if>
<if test="embryoSource != null and embryoSource != ''">#{embryoSource},</if>
<if test="destination != null">#{destination},</if>
<if test="storageMethod != null">#{storageMethod},</if>
<if test="flushOperator != null and flushOperator != ''">#{flushOperator},</if>
<if test="collectOperator != null and collectOperator != ''">#{collectOperator},</if>
<if test="remark != null">#{remark},</if>
<if test="createdBy != null and createdBy != ''">#{createdBy},</if>
<if test="createdAt != null">#{createdAt},</if>
</trim>
</insert>
<update id="updateScEmbryoFlush" parameterType="ScEmbryoFlush">
update sc_embryo_flush
<trim prefix="SET" suffixOverrides=",">
<if test="flushTime != null">flush_time = #{flushTime},</if>
<if test="donorFemaleNo != null and donorFemaleNo != ''">donor_female_no = #{donorFemaleNo},</if>
<if test="donorMaleNo != null and donorMaleNo != ''">donor_male_no = #{donorMaleNo},</if>
<if test="gradeAPlus != null">grade_a_plus = #{gradeAPlus},</if>
<if test="gradeA != null">grade_a = #{gradeA},</if>
<if test="gradeB != null">grade_b = #{gradeB},</if>
<if test="gradeC != null">grade_c = #{gradeC},</if>
<if test="gradeD != null">grade_d = #{gradeD},</if>
<if test="cell24 != null">cell_2_4 = #{cell24},</if>
<if test="cell8 != null">cell_8 = #{cell8},</if>
<if test="cell16 != null">cell_16 = #{cell16},</if>
<if test="unfertilized != null">unfertilized = #{unfertilized},</if>
<if test="degenerated != null">degenerated = #{degenerated},</if>
<if test="transferred != null">transferred = #{transferred},</if>
<if test="recipientCnt != null">recipient_cnt = #{recipientCnt},</if>
<if test="embryoType != null and embryoType != ''">embryo_type = #{embryoType},</if>
<if test="embryoSource != null and embryoSource != ''">embryo_source = #{embryoSource},</if>
<if test="destination != null">destination = #{destination},</if>
<if test="storageMethod != null">storage_method = #{storageMethod},</if>
<if test="flushOperator != null and flushOperator != ''">flush_operator = #{flushOperator},</if>
<if test="collectOperator != null and collectOperator != ''">collect_operator = #{collectOperator},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createdBy != null and createdBy != ''">created_by = #{createdBy},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScEmbryoFlushById" parameterType="Long">
delete from sc_embryo_flush where id = #{id}
</delete>
<delete id="deleteScEmbryoFlushByIds" parameterType="String">
delete from sc_embryo_flush where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -99,7 +99,7 @@ public class ScBreedRecordController extends BaseController
} }
/** /**
* 根据母羊耳号获取最新配种计划信息优先从配种计划生成表获取 * 根据母羊耳号获取最新配种计划信息(优先从配种计划生成表获取)
*/ */
@PreAuthorize("@ss.hasPermi('Breeding_records:Breeding_records:query')") @PreAuthorize("@ss.hasPermi('Breeding_records:Breeding_records:query')")
@GetMapping(value = "/getLatestBreedPlan/{manageTags}") @GetMapping(value = "/getLatestBreedPlan/{manageTags}")
@ -139,12 +139,12 @@ public class ScBreedRecordController extends BaseController
scBreedRecord.setRamId(ramId.toString()); scBreedRecord.setRamId(ramId.toString());
} }
// 验证配种方式 // 修改验证配种方式 - 增加3-冲胚 4-自然发情人工授精
if (scBreedRecord.getBreedType() == null) { if (scBreedRecord.getBreedType() == null) {
return error("配种方式不能为空"); return error("配种方式不能为空");
} }
if (scBreedRecord.getBreedType() != 1 && scBreedRecord.getBreedType() != 2) { if (scBreedRecord.getBreedType() < 1 || scBreedRecord.getBreedType() > 4) {
return error("配种方式只能是1-同期发情 或 2-本交"); return error("配种方式只能是1-同期发情、2-本交、3-冲胚、4-自然发情人工授精");
} }
// 验证技术员 // 验证技术员
@ -186,10 +186,10 @@ public class ScBreedRecordController extends BaseController
scBreedRecord.setRamId(ramId.toString()); scBreedRecord.setRamId(ramId.toString());
} }
// 验证配种方式 // 修改验证配种方式
if (scBreedRecord.getBreedType() != null) { if (scBreedRecord.getBreedType() != null) {
if (scBreedRecord.getBreedType() != 1 && scBreedRecord.getBreedType() != 2) { if (scBreedRecord.getBreedType() < 1 || scBreedRecord.getBreedType() > 4) {
return error("配种方式只能是1-同期发情 或 2-本交"); return error("配种方式只能是1-同期发情、2-本交、3-冲胚、4-自然发情人工授精");
} }
} }
@ -223,7 +223,7 @@ public class ScBreedRecordController extends BaseController
if (result > 0) { if (result > 0) {
return success("孕检结果同步成功"); return success("孕检结果同步成功");
} else { } else {
return error("孕检结果同步失败可能未找到对应的配种记录"); return error("孕检结果同步失败,可能未找到对应的配种记录");
} }
} }

View File

@ -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<ScEmbryoFlush> 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<ScEmbryoFlush> list = scEmbryoFlushService.selectScEmbryoFlushList(scEmbryoFlush);
ExcelUtil<ScEmbryoFlush> util = new ExcelUtil<ScEmbryoFlush>(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<String, Object> info = scEmbryoFlushService.getDonorRelatedInfo(donorFemaleNo);
return success(info);
}
/**
* 获取供体母羊下拉列表
*/
@PreAuthorize("@ss.hasPermi('embryo:flush:query')")
@GetMapping("/donorFemaleList")
public AjaxResult getDonorFemaleList()
{
List<Map<String, Object>> list = scEmbryoFlushService.selectDonorFemaleList();
return success(list);
}
}

View File

@ -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();
}
}

View File

@ -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<ScEmbryoFlush> 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<String, Object> selectSheepInfoByManageTag(@Param("manageTag") String manageTag);
/**
* 根据母羊耳号查询最近一条配种记录
*
* @param eweManageTag 母羊耳号
* @return 配种记录(ramId公羊耳号, matingDate配种日期)
*/
public Map<String, Object> selectBreedRecordByEwe(@Param("eweManageTag") String eweManageTag);
/**
* 查询所有母羊列表(用于下拉选择)
*
* @return 母羊列表
*/
public List<Map<String, Object>> selectDonorFemaleList();
}

View File

@ -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<ScEmbryoFlush> 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<String, Object> getDonorRelatedInfo(String donorFemaleNo);
/**
* 根据父母品种计算胚胎品种
*
* @param maleVariety 公羊品种
* @param femaleVariety 母羊品种
* @return 胚胎品种
*/
public String calculateEmbryoVariety(String maleVariety, String femaleVariety);
/**
* 查询所有供体母羊列表(用于下拉选择)
*
* @return 母羊列表
*/
public List<Map<String, Object>> selectDonorFemaleList();
}

View File

@ -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<Integer, String> 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<ScEmbryoFlush> 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<String, Object> getDonorRelatedInfo(String donorFemaleNo)
{
Map<String, Object> result = new HashMap<>();
if (donorFemaleNo == null || donorFemaleNo.trim().isEmpty()) {
return result;
}
// 1. 查询母羊信息
Map<String, Object> 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<String, Object> 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<String, Object> 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<Integer, String> 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<Map<String, Object>> selectDonorFemaleList()
{
return scEmbryoFlushMapper.selectDonorFemaleList();
}
}

View File

@ -53,7 +53,7 @@
br.breed_type, br.breed_type,
br.create_by, br.create_by,
br.create_time, br.create_time,
-- 母羊信息(从视图获取) -- 母羊信息(从视图获取)
ewe_view.bs_manage_tags as ewe_manage_tags, ewe_view.bs_manage_tags as ewe_manage_tags,
ewe_view.variety as ewe_variety, ewe_view.variety as ewe_variety,
ewe_view.parity as ewe_parity, ewe_view.parity as ewe_parity,
@ -65,16 +65,18 @@
ewe_view.dr_ranch as ranch_name, ewe_view.dr_ranch as ranch_name,
ewe_view.name as sheep_type, ewe_view.name as sheep_type,
ewe_view.mating_total as mating_count, ewe_view.mating_total as mating_count,
-- 公羊信息(从视图获取) -- 公羊信息(从视图获取)
ram_view.bs_manage_tags as ram_manage_tags, ram_view.bs_manage_tags as ram_manage_tags,
ram_view.variety as ram_variety, ram_view.variety as ram_variety,
-- 配种方式显示 -- 配种方式显示(修改:增加3-冲胚、4-自然发情人工授精)
CASE br.breed_type CASE br.breed_type
WHEN 1 THEN '同期发情' WHEN 1 THEN '同期发情'
WHEN 2 THEN '本交' WHEN 2 THEN '本交'
WHEN 3 THEN '冲胚'
WHEN 4 THEN '自然发情人工授精'
ELSE '未知' ELSE '未知'
END as mating_type, END as mating_type,
-- 发情后配种时间(小时数) -- 发情后配种时间(小时数)
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning, TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,
-- 孕检相关信息 -- 孕检相关信息
pr.datetime as pregnancy_check_date, pr.datetime as pregnancy_check_date,
@ -225,6 +227,8 @@
CASE bp.breed_type CASE bp.breed_type
WHEN 1 THEN '同期发情' WHEN 1 THEN '同期发情'
WHEN 2 THEN '本交' WHEN 2 THEN '本交'
WHEN 3 THEN '冲胚'
WHEN 4 THEN '自然发情人工授精'
ELSE '未知' ELSE '未知'
END as breed_type_name, END as breed_type_name,
TIMESTAMPDIFF(HOUR, NOW(), NOW()) as hours_since_plan TIMESTAMPDIFF(HOUR, NOW(), NOW()) as hours_since_plan
@ -236,7 +240,7 @@
limit 1 limit 1
</select> </select>
<!-- 根据母羊耳号获取最新的配种计划信息(从配种计划生成表) --> <!-- 根据母羊耳号获取最新的配种计划信息(从配种计划生成表) -->
<select id="getLatestBreedPlanByEweTags" parameterType="String" resultType="map"> <select id="getLatestBreedPlanByEweTags" parameterType="String" resultType="map">
select select
bpg.id as plan_generate_id, bpg.id as plan_generate_id,
@ -248,6 +252,8 @@
CASE bpt.breed_type CASE bpt.breed_type
WHEN 1 THEN '同期发情' WHEN 1 THEN '同期发情'
WHEN 2 THEN '本交' WHEN 2 THEN '本交'
WHEN 3 THEN '冲胚'
WHEN 4 THEN '自然发情人工授精'
ELSE '未知' ELSE '未知'
END as breed_type_name, END as breed_type_name,
bpg.create_time as plan_create_time bpg.create_time as plan_create_time

View File

@ -0,0 +1,229 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScEmbryoFlushMapper">
<resultMap type="ScEmbryoFlush" id="ScEmbryoFlushResult">
<result property="id" column="id" />
<result property="flushTime" column="flush_time" />
<result property="donorFemaleNo" column="donor_female_no" />
<result property="donorFemaleVariety" column="donor_female_variety" />
<result property="donorMaleNo" column="donor_male_no" />
<result property="donorMaleVariety" column="donor_male_variety" />
<result property="embryoVariety" column="embryo_variety" />
<result property="embryoAge" column="embryo_age" />
<result property="gradeAPlus" column="grade_a_plus" />
<result property="gradeA" column="grade_a" />
<result property="gradeB" column="grade_b" />
<result property="gradeC" column="grade_c" />
<result property="gradeD" column="grade_d" />
<result property="cell24" column="cell_2_4" />
<result property="cell8" column="cell_8" />
<result property="cell16" column="cell_16" />
<result property="unfertilized" column="unfertilized" />
<result property="degenerated" column="degenerated" />
<result property="totalEmbryo" column="total_embryo" />
<result property="validEmbryo" column="valid_embryo" />
<result property="transferred" column="transferred" />
<result property="recipientCnt" column="recipient_cnt" />
<result property="embryoType" column="embryo_type" />
<result property="embryoSource" column="embryo_source" />
<result property="destination" column="destination" />
<result property="storageMethod" column="storage_method" />
<result property="flushOperator" column="flush_operator" />
<result property="collectOperator" column="collect_operator" />
<result property="ranchId" column="ranch_id" />
<result property="ranchName" column="ranch_name" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectScEmbryoFlushVo">
select id, 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
from sc_embryo_flush
</sql>
<select id="selectScEmbryoFlushList" parameterType="ScEmbryoFlush" resultMap="ScEmbryoFlushResult">
<include refid="selectScEmbryoFlushVo"/>
<where>
<if test="params.beginFlushTime != null and params.beginFlushTime != '' and params.endFlushTime != null and params.endFlushTime != ''">
and flush_time between #{params.beginFlushTime} and #{params.endFlushTime}
</if>
<if test="donorFemaleNo != null and donorFemaleNo != ''"> and donor_female_no like concat('%', #{donorFemaleNo}, '%')</if>
<if test="donorMaleNo != null and donorMaleNo != ''"> and donor_male_no like concat('%', #{donorMaleNo}, '%')</if>
<if test="embryoVariety != null and embryoVariety != ''"> and embryo_variety = #{embryoVariety}</if>
<if test="embryoType != null and embryoType != ''"> and embryo_type = #{embryoType}</if>
<if test="embryoSource != null and embryoSource != ''"> and embryo_source = #{embryoSource}</if>
<if test="flushOperator != null and flushOperator != ''"> and flush_operator like concat('%', #{flushOperator}, '%')</if>
<if test="collectOperator != null and collectOperator != ''"> and collect_operator like concat('%', #{collectOperator}, '%')</if>
<if test="ranchId != null"> and ranch_id = #{ranchId}</if>
</where>
order by flush_time desc
</select>
<select id="selectScEmbryoFlushById" parameterType="Long" resultMap="ScEmbryoFlushResult">
<include refid="selectScEmbryoFlushVo"/>
where id = #{id}
</select>
<insert id="insertScEmbryoFlush" parameterType="ScEmbryoFlush" useGeneratedKeys="true" keyProperty="id">
insert into sc_embryo_flush
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="flushTime != null">flush_time,</if>
<if test="donorFemaleNo != null and donorFemaleNo != ''">donor_female_no,</if>
<if test="donorFemaleVariety != null and donorFemaleVariety != ''">donor_female_variety,</if>
<if test="donorMaleNo != null and donorMaleNo != ''">donor_male_no,</if>
<if test="donorMaleVariety != null and donorMaleVariety != ''">donor_male_variety,</if>
<if test="embryoVariety != null and embryoVariety != ''">embryo_variety,</if>
<if test="embryoAge != null">embryo_age,</if>
<if test="gradeAPlus != null">grade_a_plus,</if>
<if test="gradeA != null">grade_a,</if>
<if test="gradeB != null">grade_b,</if>
<if test="gradeC != null">grade_c,</if>
<if test="gradeD != null">grade_d,</if>
<if test="cell24 != null">cell_2_4,</if>
<if test="cell8 != null">cell_8,</if>
<if test="cell16 != null">cell_16,</if>
<if test="unfertilized != null">unfertilized,</if>
<if test="degenerated != null">degenerated,</if>
<if test="totalEmbryo != null">total_embryo,</if>
<if test="validEmbryo != null">valid_embryo,</if>
<if test="transferred != null">transferred,</if>
<if test="recipientCnt != null">recipient_cnt,</if>
<if test="embryoType != null and embryoType != ''">embryo_type,</if>
<if test="embryoSource != null and embryoSource != ''">embryo_source,</if>
<if test="destination != null and destination != ''">destination,</if>
<if test="storageMethod != null and storageMethod != ''">storage_method,</if>
<if test="flushOperator != null and flushOperator != ''">flush_operator,</if>
<if test="collectOperator != null and collectOperator != ''">collect_operator,</if>
<if test="ranchId != null">ranch_id,</if>
<if test="ranchName != null and ranchName != ''">ranch_name,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="flushTime != null">#{flushTime},</if>
<if test="donorFemaleNo != null and donorFemaleNo != ''">#{donorFemaleNo},</if>
<if test="donorFemaleVariety != null and donorFemaleVariety != ''">#{donorFemaleVariety},</if>
<if test="donorMaleNo != null and donorMaleNo != ''">#{donorMaleNo},</if>
<if test="donorMaleVariety != null and donorMaleVariety != ''">#{donorMaleVariety},</if>
<if test="embryoVariety != null and embryoVariety != ''">#{embryoVariety},</if>
<if test="embryoAge != null">#{embryoAge},</if>
<if test="gradeAPlus != null">#{gradeAPlus},</if>
<if test="gradeA != null">#{gradeA},</if>
<if test="gradeB != null">#{gradeB},</if>
<if test="gradeC != null">#{gradeC},</if>
<if test="gradeD != null">#{gradeD},</if>
<if test="cell24 != null">#{cell24},</if>
<if test="cell8 != null">#{cell8},</if>
<if test="cell16 != null">#{cell16},</if>
<if test="unfertilized != null">#{unfertilized},</if>
<if test="degenerated != null">#{degenerated},</if>
<if test="totalEmbryo != null">#{totalEmbryo},</if>
<if test="validEmbryo != null">#{validEmbryo},</if>
<if test="transferred != null">#{transferred},</if>
<if test="recipientCnt != null">#{recipientCnt},</if>
<if test="embryoType != null and embryoType != ''">#{embryoType},</if>
<if test="embryoSource != null and embryoSource != ''">#{embryoSource},</if>
<if test="destination != null and destination != ''">#{destination},</if>
<if test="storageMethod != null and storageMethod != ''">#{storageMethod},</if>
<if test="flushOperator != null and flushOperator != ''">#{flushOperator},</if>
<if test="collectOperator != null and collectOperator != ''">#{collectOperator},</if>
<if test="ranchId != null">#{ranchId},</if>
<if test="ranchName != null and ranchName != ''">#{ranchName},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateScEmbryoFlush" parameterType="ScEmbryoFlush">
update sc_embryo_flush
<trim prefix="SET" suffixOverrides=",">
<if test="flushTime != null">flush_time = #{flushTime},</if>
<if test="donorFemaleNo != null and donorFemaleNo != ''">donor_female_no = #{donorFemaleNo},</if>
<if test="donorFemaleVariety != null and donorFemaleVariety != ''">donor_female_variety = #{donorFemaleVariety},</if>
<if test="donorMaleNo != null and donorMaleNo != ''">donor_male_no = #{donorMaleNo},</if>
<if test="donorMaleVariety != null and donorMaleVariety != ''">donor_male_variety = #{donorMaleVariety},</if>
<if test="embryoVariety != null and embryoVariety != ''">embryo_variety = #{embryoVariety},</if>
<if test="embryoAge != null">embryo_age = #{embryoAge},</if>
<if test="gradeAPlus != null">grade_a_plus = #{gradeAPlus},</if>
<if test="gradeA != null">grade_a = #{gradeA},</if>
<if test="gradeB != null">grade_b = #{gradeB},</if>
<if test="gradeC != null">grade_c = #{gradeC},</if>
<if test="gradeD != null">grade_d = #{gradeD},</if>
<if test="cell24 != null">cell_2_4 = #{cell24},</if>
<if test="cell8 != null">cell_8 = #{cell8},</if>
<if test="cell16 != null">cell_16 = #{cell16},</if>
<if test="unfertilized != null">unfertilized = #{unfertilized},</if>
<if test="degenerated != null">degenerated = #{degenerated},</if>
<if test="totalEmbryo != null">total_embryo = #{totalEmbryo},</if>
<if test="validEmbryo != null">valid_embryo = #{validEmbryo},</if>
<if test="transferred != null">transferred = #{transferred},</if>
<if test="recipientCnt != null">recipient_cnt = #{recipientCnt},</if>
<if test="embryoType != null and embryoType != ''">embryo_type = #{embryoType},</if>
<if test="embryoSource != null and embryoSource != ''">embryo_source = #{embryoSource},</if>
<if test="destination != null and destination != ''">destination = #{destination},</if>
<if test="storageMethod != null and storageMethod != ''">storage_method = #{storageMethod},</if>
<if test="flushOperator != null and flushOperator != ''">flush_operator = #{flushOperator},</if>
<if test="collectOperator != null and collectOperator != ''">collect_operator = #{collectOperator},</if>
<if test="ranchId != null">ranch_id = #{ranchId},</if>
<if test="ranchName != null and ranchName != ''">ranch_name = #{ranchName},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScEmbryoFlushById" parameterType="Long">
delete from sc_embryo_flush where id = #{id}
</delete>
<delete id="deleteScEmbryoFlushByIds" parameterType="String">
delete from sc_embryo_flush where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 根据耳号查询羊只信息(从sheep_file视图) -->
<select id="selectSheepInfoByManageTag" parameterType="String" resultType="java.util.Map">
SELECT
bs_manage_tags AS manageTag,
variety_id AS varietyId,
variety,
ranch_id AS ranchId,
dr_ranch AS ranchName
FROM sheep_file
WHERE bs_manage_tags = #{manageTag}
LIMIT 1
</select>
<!-- 根据母羊耳号查询最近一条配种记录,获取公羊耳号和配种日期 -->
<!-- ewe_id存的是数字ID需要先根据耳号找到母羊ID再查配种记录再根据公羊ID找到公羊耳号 -->
<select id="selectBreedRecordByEwe" resultType="java.util.Map">
SELECT
ram_sf.bs_manage_tags AS ramId,
br.create_time AS matingDate
FROM sc_breed_record br
INNER JOIN sheep_file ewe_sf ON ewe_sf.id = br.ewe_id
INNER JOIN sheep_file ram_sf ON ram_sf.id = br.ram_id
WHERE ewe_sf.bs_manage_tags = #{eweManageTag}
ORDER BY br.create_time DESC
LIMIT 1
</select>
<!-- 查询所有母羊列表(用于下拉选择) -->
<select id="selectDonorFemaleList" resultType="java.util.Map">
SELECT DISTINCT
sf.bs_manage_tags AS manageTag,
sf.variety,
sf.variety_id AS varietyId,
sf.ranch_id AS ranchId,
sf.dr_ranch AS ranchName
FROM sheep_file sf
WHERE sf.gender = 1
AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
ORDER BY sf.bs_manage_tags
</select>
</mapper>