配种计划页面修复,功能加强
This commit is contained in:
@@ -239,4 +239,6 @@ public class ScBreedRecordController extends BaseController
|
|||||||
List<ScBreedRecord> records = scBreedRecordService.getBreedRecordsByTimeRange(sheepId, startDate, endDate);
|
List<ScBreedRecord> records = scBreedRecordService.getBreedRecordsByTimeRange(sheepId, startDate, endDate);
|
||||||
return success(records);
|
return success(records);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,135 +20,133 @@ public class ScBreedRecord extends BaseEntity
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键ID */
|
// ===================== 基础主键/关联ID字段 =====================
|
||||||
|
// 基础关联ID
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 羊只id */
|
|
||||||
@Excel(name = "羊只id")
|
|
||||||
private Long sheepId;
|
private Long sheepId;
|
||||||
|
|
||||||
/** 配种公羊id */
|
|
||||||
@Excel(name = "配种公羊id")
|
|
||||||
private String ramId;
|
private String ramId;
|
||||||
|
|
||||||
/** 配种母羊id */
|
|
||||||
@Excel(name = "配种母羊id")
|
|
||||||
private String eweId;
|
private String eweId;
|
||||||
|
|
||||||
/** 技术员 */
|
// --- 导出及表单顺序 ---
|
||||||
@Excel(name = "技术员")
|
|
||||||
private String technician;
|
|
||||||
|
|
||||||
/** 繁殖用药/耗精量 */
|
|
||||||
@Excel(name = "耗精量")
|
|
||||||
private String breedDrugs;
|
|
||||||
|
|
||||||
/** 配种方式 1-同期发情 2-本交 */
|
|
||||||
@Excel(name = "配种方式", readConverterExp = "1=同期发情,2=本交")
|
|
||||||
private Integer breedType;
|
|
||||||
|
|
||||||
// ============ 显示字段 ============
|
|
||||||
|
|
||||||
/** 母羊耳号 */
|
|
||||||
@Excel(name = "耳号")
|
@Excel(name = "耳号")
|
||||||
private String eweManageTags;
|
private String eweManageTags; // 母羊耳号
|
||||||
|
|
||||||
/** 母羊品种 */
|
|
||||||
@Excel(name = "品种")
|
@Excel(name = "品种")
|
||||||
private String eweVariety;
|
private String eweVariety;
|
||||||
|
|
||||||
/** 公羊耳号 */
|
@Excel(name = "事件类型")
|
||||||
|
private String eventType = "配种";
|
||||||
|
|
||||||
|
@Excel(name = "配种日期", dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
@Excel(name = "配种公羊")
|
@Excel(name = "配种公羊")
|
||||||
private String ramManageTags;
|
private String ramManageTags;
|
||||||
|
|
||||||
/** 公羊品种 */
|
|
||||||
@Excel(name = "配种公羊品种")
|
@Excel(name = "配种公羊品种")
|
||||||
private String ramVariety;
|
private String ramVariety;
|
||||||
|
|
||||||
/** 胎次 */
|
@Excel(name = "供体母羊")
|
||||||
@Excel(name = "胎次")
|
private String donorEweNo;
|
||||||
private Integer eweParity;
|
|
||||||
|
@Excel(name = "供体母羊品种")
|
||||||
|
private String donorEweVariety;
|
||||||
|
|
||||||
|
@Excel(name = "供体公羊")
|
||||||
|
private String donorRamNo;
|
||||||
|
|
||||||
|
@Excel(name = "供体公羊品种")
|
||||||
|
private String donorRamVariety;
|
||||||
|
|
||||||
|
@Excel(name = "移胚数")
|
||||||
|
private Integer embryoCount;
|
||||||
|
|
||||||
|
/** 1-同期发情, 2-本交, 3-自然发情, 4-胚胎移植 */
|
||||||
|
@Excel(name = "配种方式", readConverterExp = "1=同期发情,2=本交,3=自然发情,4=胚胎移植")
|
||||||
|
private Integer breedType;
|
||||||
|
|
||||||
|
@Excel(name = "配种子类型")
|
||||||
|
private String embryoSubType; // 体内/体外 + 冻胚/鲜胚
|
||||||
|
|
||||||
/** 月龄 */
|
|
||||||
@Excel(name = "月龄")
|
@Excel(name = "月龄")
|
||||||
private Integer eweMonthAge;
|
private Integer eweMonthAge;
|
||||||
|
|
||||||
/** 羊舍名称 */
|
|
||||||
@Excel(name = "当前羊舍")
|
|
||||||
private String eweSheepfoldName;
|
|
||||||
|
|
||||||
/** 繁育状态 */
|
|
||||||
@Excel(name = "繁育状态")
|
|
||||||
private String eweBreedStatus;
|
|
||||||
|
|
||||||
/** 是否性控 */
|
|
||||||
@Excel(name = "是否性控", readConverterExp = "0=否,1=是")
|
|
||||||
private Integer eweControlled;
|
|
||||||
|
|
||||||
/** 羊只备注 */
|
|
||||||
@Excel(name = "羊只备注")
|
|
||||||
private String eweComment;
|
|
||||||
|
|
||||||
/** 牧场名称 */
|
|
||||||
@Excel(name = "所在牧场")
|
|
||||||
private String ranchName;
|
|
||||||
|
|
||||||
/** 配种方式显示 */
|
|
||||||
@Excel(name = "配种方式")
|
|
||||||
private String matingType;
|
|
||||||
|
|
||||||
/** 羊只类别 */
|
|
||||||
@Excel(name = "配种时羊只类别")
|
@Excel(name = "配种时羊只类别")
|
||||||
private String sheepType;
|
private String sheepType;
|
||||||
|
|
||||||
/** 配次 */
|
@Excel(name = "胎次")
|
||||||
|
private Integer eweParity;
|
||||||
|
|
||||||
|
@Excel(name = "孕检记录id")
|
||||||
|
private Integer pregnancyRecordId;
|
||||||
|
|
||||||
@Excel(name = "配次")
|
@Excel(name = "配次")
|
||||||
private Integer matingCount;
|
private Integer matingCount;
|
||||||
|
|
||||||
/** 发情后配种时间 */
|
@Excel(name = "发情后配种时间")
|
||||||
@Excel(name = "发情后配种时间(小时)")
|
|
||||||
private Long timeSincePlanning;
|
private Long timeSincePlanning;
|
||||||
|
|
||||||
/** 牧场ID */
|
@Excel(name = "当前羊舍")
|
||||||
private Long ranchId;
|
private String eweSheepfoldName;
|
||||||
|
|
||||||
/** 配种计划ID */
|
@Excel(name = "技术员")
|
||||||
private Long planId;
|
private String technician;
|
||||||
|
|
||||||
// ============ 新增孕检相关字段 ============
|
@Excel(name = "繁殖用药")
|
||||||
|
private String breedDrugs;
|
||||||
|
|
||||||
|
@Excel(name = "羊只备注")
|
||||||
|
private String eweComment;
|
||||||
|
|
||||||
|
@Excel(name = "繁育状态")
|
||||||
|
private String eweBreedStatus;
|
||||||
|
|
||||||
/** 孕检日期 */
|
|
||||||
@Excel(name = "孕检日期")
|
@Excel(name = "孕检日期")
|
||||||
private Date pregnancyCheckDate;
|
private Date pregnancyCheckDate;
|
||||||
|
|
||||||
/** 孕检结果 */
|
|
||||||
@Excel(name = "孕检结果")
|
@Excel(name = "孕检结果")
|
||||||
private String pregnancyResult;
|
private String pregnancyResult;
|
||||||
|
|
||||||
/** 孕检方式 */
|
|
||||||
@Excel(name = "孕检方式")
|
|
||||||
private String pregnancyWay;
|
|
||||||
|
|
||||||
/** 胎数 */
|
|
||||||
@Excel(name = "胎数")
|
|
||||||
private Integer fetusCount;
|
|
||||||
|
|
||||||
/** 孕检技术员 */
|
|
||||||
@Excel(name = "孕检技术员")
|
|
||||||
private String pregnancyTechnician;
|
|
||||||
|
|
||||||
/** 孕检备注 */
|
|
||||||
@Excel(name = "孕检备注")
|
|
||||||
private String pregnancyRemark;
|
|
||||||
|
|
||||||
/** 孕检记录ID */
|
|
||||||
private Long pregnancyRecordId;
|
|
||||||
|
|
||||||
/** 配种到孕检间隔天数 */
|
|
||||||
@Excel(name = "配种到孕检间隔(天)")
|
@Excel(name = "配种到孕检间隔(天)")
|
||||||
private Integer daysToPregnancyCheck;
|
private Integer daysToPregnancyCheck;
|
||||||
|
|
||||||
/** 是否已孕检 */
|
|
||||||
@Excel(name = "是否已孕检", readConverterExp = "0=否,1=是")
|
@Excel(name = "预产日期")
|
||||||
private Integer isPregnancyChecked;
|
private Date expectedDate;
|
||||||
|
|
||||||
|
@Excel(name = "实产日期")
|
||||||
|
private Date actualLambingDate;
|
||||||
|
|
||||||
|
@Excel(name = "配种时产后天数")
|
||||||
|
private Long daysPostLambing; // 距离上一次产羔
|
||||||
|
|
||||||
|
@Excel(name = "配种时泌乳天数")
|
||||||
|
private Long daysLactation; // 距离上一次孕检且怀孕
|
||||||
|
|
||||||
|
@Excel(name = "配种时配后天数")
|
||||||
|
private Long daysPostMating; // 距离上一次配种
|
||||||
|
|
||||||
|
@Excel(name = "上次配种日期")
|
||||||
|
private Date lastMatingDate;
|
||||||
|
|
||||||
|
@Excel(name = "冻精号")
|
||||||
|
private String frozenSemenNo; // 新增字段:自行输入
|
||||||
|
|
||||||
|
@Excel(name = "是否性控", readConverterExp = "0=否,1=是")
|
||||||
|
private Integer eweControlled;
|
||||||
|
|
||||||
|
@Excel(name = "耗精量")
|
||||||
|
private String spermConsumption;
|
||||||
|
|
||||||
|
@Excel(name = "创建人")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@Excel(name = "创建日期")
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
|
@Excel(name = "所在牧场")
|
||||||
|
private String ranchName;
|
||||||
|
|
||||||
|
@Excel(name = "备注")
|
||||||
|
private String comment;
|
||||||
}
|
}
|
||||||
@@ -145,4 +145,12 @@ public interface ScBreedRecordMapper
|
|||||||
* @return 配种母羊数
|
* @return 配种母羊数
|
||||||
*/
|
*/
|
||||||
Long countMatedEwesByRamId(String ramManageTags);
|
Long countMatedEwesByRamId(String ramManageTags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据受体(母羊)耳号查询最新的冲胚记录信息
|
||||||
|
* 用于胚胎移植时自动填充供体和移胚数
|
||||||
|
* @param manageTags 受体母羊耳号
|
||||||
|
* @return 冲胚记录Map
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getFlushRecordByEweNo(@Param("manageTags") String manageTags);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zhyc.module.produce.breed.service.impl;
|
package com.zhyc.module.produce.breed.service.impl;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.zhyc.common.utils.DateUtils;
|
import com.zhyc.common.utils.DateUtils;
|
||||||
@@ -44,31 +45,47 @@ public class ScBreedRecordServiceImpl implements IScBreedRecordService
|
|||||||
* @param scBreedRecord 配种记录
|
* @param scBreedRecord 配种记录
|
||||||
* @return 配种记录
|
* @return 配种记录
|
||||||
*/
|
*/
|
||||||
|
// @Override
|
||||||
|
// public List<ScBreedRecord> selectScBreedRecordList(ScBreedRecord scBreedRecord)
|
||||||
|
// {
|
||||||
|
// // 如果查询条件中有耳号,需要先转换为ID
|
||||||
|
// if (StringUtils.isNotEmpty(scBreedRecord.getEweManageTags()))
|
||||||
|
// {
|
||||||
|
// Long eweId = scBreedRecordMapper.getSheepIdByManageTags(scBreedRecord.getEweManageTags());
|
||||||
|
// if (eweId != null)
|
||||||
|
// {
|
||||||
|
// scBreedRecord.setEweId(eweId.toString());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (StringUtils.isNotEmpty(scBreedRecord.getRamManageTags()))
|
||||||
|
// {
|
||||||
|
// Long ramId = scBreedRecordMapper.getRamIdByManageTags(scBreedRecord.getRamManageTags());
|
||||||
|
// if (ramId != null)
|
||||||
|
// {
|
||||||
|
// scBreedRecord.setRamId(ramId.toString());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return scBreedRecordMapper.selectScBreedRecordList(scBreedRecord);
|
||||||
|
// }
|
||||||
@Override
|
@Override
|
||||||
public List<ScBreedRecord> selectScBreedRecordList(ScBreedRecord scBreedRecord)
|
public List<ScBreedRecord> selectScBreedRecordList(ScBreedRecord scBreedRecord) {
|
||||||
{
|
// ... (耳号转ID逻辑保持不变) ...
|
||||||
// 如果查询条件中有耳号,需要先转换为ID
|
// 如果查询条件中有耳号,需要先转换为ID (注意:供体母羊/公羊是直接存字符串的,不需要转ID,只有作为受体的eweId需要转)
|
||||||
if (StringUtils.isNotEmpty(scBreedRecord.getEweManageTags()))
|
if (StringUtils.isNotEmpty(scBreedRecord.getEweManageTags()))
|
||||||
{
|
{
|
||||||
Long eweId = scBreedRecordMapper.getSheepIdByManageTags(scBreedRecord.getEweManageTags());
|
Long eweId = scBreedRecordMapper.getSheepIdByManageTags(scBreedRecord.getEweManageTags());
|
||||||
if (eweId != null)
|
if (eweId != null)
|
||||||
{
|
{
|
||||||
|
// 注意:这里仅设置eweId用于查询作为受体的记录
|
||||||
|
// 如果用户想搜"供体母羊"是xxx,Mapper XML中的 OR 逻辑会处理
|
||||||
scBreedRecord.setEweId(eweId.toString());
|
scBreedRecord.setEweId(eweId.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ...
|
||||||
if (StringUtils.isNotEmpty(scBreedRecord.getRamManageTags()))
|
|
||||||
{
|
|
||||||
Long ramId = scBreedRecordMapper.getRamIdByManageTags(scBreedRecord.getRamManageTags());
|
|
||||||
if (ramId != null)
|
|
||||||
{
|
|
||||||
scBreedRecord.setRamId(ramId.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return scBreedRecordMapper.selectScBreedRecordList(scBreedRecord);
|
return scBreedRecordMapper.selectScBreedRecordList(scBreedRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增配种记录
|
* 新增配种记录
|
||||||
*
|
*
|
||||||
@@ -172,34 +189,89 @@ public class ScBreedRecordServiceImpl implements IScBreedRecordService
|
|||||||
* @param manageTags 母羊管理耳号
|
* @param manageTags 母羊管理耳号
|
||||||
* @return 配种计划信息
|
* @return 配种计划信息
|
||||||
*/
|
*/
|
||||||
|
// @Override
|
||||||
|
// public Map<String, Object> getLatestBreedPlanByEweTags(String manageTags)
|
||||||
|
// {
|
||||||
|
// try {
|
||||||
|
// // 优先从配种计划生成表获取最新计划
|
||||||
|
// Map<String, Object> latestPlan = scBreedRecordMapper.getLatestBreedPlanByEweTags(manageTags);
|
||||||
|
//
|
||||||
|
// if (latestPlan != null && !latestPlan.isEmpty()) {
|
||||||
|
// log.info("从配种计划生成表获取到配种计划: {}", latestPlan);
|
||||||
|
// return latestPlan;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 如果生成表中没有,则从普通配种计划表获取
|
||||||
|
// Map<String, Object> normalPlan = scBreedRecordMapper.getBreedPlanByEweTags(manageTags);
|
||||||
|
// if (normalPlan != null && !normalPlan.isEmpty()) {
|
||||||
|
// log.info("从配种计划表获取到配种计划: {}", normalPlan);
|
||||||
|
// return normalPlan;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// log.warn("未找到母羊耳号 {} 的配种计划信息", manageTags);
|
||||||
|
// return null;
|
||||||
|
//
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// log.error("获取配种计划信息时发生异常,母羊耳号: {}", manageTags, e);
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
/**
|
||||||
|
* 根据母羊耳号获取最新的配种计划信息
|
||||||
|
* 修改逻辑:优先查配种计划 -> 其次查冲胚记录(作为受体)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getLatestBreedPlanByEweTags(String manageTags)
|
public Map<String, Object> getLatestBreedPlanByEweTags(String manageTags)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// 优先从配种计划生成表获取最新计划
|
// 1. 优先从配种计划生成表获取最新计划 (同期发情/本交等)
|
||||||
Map<String, Object> latestPlan = scBreedRecordMapper.getLatestBreedPlanByEweTags(manageTags);
|
Map<String, Object> latestPlan = scBreedRecordMapper.getLatestBreedPlanByEweTags(manageTags);
|
||||||
|
|
||||||
if (latestPlan != null && !latestPlan.isEmpty()) {
|
if (latestPlan != null && !latestPlan.isEmpty()) {
|
||||||
log.info("从配种计划生成表获取到配种计划: {}", latestPlan);
|
log.info("从配种计划生成表获取到配种计划: {}", latestPlan);
|
||||||
return latestPlan;
|
return latestPlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果生成表中没有,则从普通配种计划表获取
|
// 2. 如果生成表中没有,从普通配种计划表获取
|
||||||
Map<String, Object> normalPlan = scBreedRecordMapper.getBreedPlanByEweTags(manageTags);
|
Map<String, Object> normalPlan = scBreedRecordMapper.getBreedPlanByEweTags(manageTags);
|
||||||
if (normalPlan != null && !normalPlan.isEmpty()) {
|
if (normalPlan != null && !normalPlan.isEmpty()) {
|
||||||
log.info("从配种计划表获取到配种计划: {}", normalPlan);
|
log.info("从配种计划表获取到配种计划: {}", normalPlan);
|
||||||
return normalPlan;
|
return normalPlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.warn("未找到母羊耳号 {} 的配种计划信息", manageTags);
|
// 3. 【新增逻辑】如果都没有,尝试从冲胚记录中查找(该羊是否作为受体)
|
||||||
|
// 这里的业务逻辑是:如果这只羊在冲胚记录的"受体列表"中,且是最近的操作,则认为它是去做胚胎移植
|
||||||
|
Map<String, Object> flushRecord = scBreedRecordMapper.getFlushRecordByEweNo(manageTags);
|
||||||
|
if (flushRecord != null && !flushRecord.isEmpty()) {
|
||||||
|
log.info("从冲胚记录获取到移植信息: {}", flushRecord);
|
||||||
|
|
||||||
|
// 构造一个符合前端预期的Map结构
|
||||||
|
Map<String, Object> etPlan = new HashMap<>();
|
||||||
|
etPlan.put("breed_type", 5); // 设定 5 为胚胎移植
|
||||||
|
etPlan.put("breedType", 5); // 驼峰兼容
|
||||||
|
etPlan.put("breed_type_name", "胚胎移植");
|
||||||
|
|
||||||
|
// 填充冲胚记录带来的数据
|
||||||
|
etPlan.put("donorEweNo", flushRecord.get("donor_female_no")); // 供体母羊
|
||||||
|
etPlan.put("donorRamNo", flushRecord.get("donor_male_no")); // 供体公羊
|
||||||
|
etPlan.put("embryoCount", flushRecord.get("transferred")); // 移胚数
|
||||||
|
|
||||||
|
// 拼接配种子类型 (例如: 体内供体 鲜胚)
|
||||||
|
String subType = "";
|
||||||
|
if (flushRecord.get("embryo_type") != null) subType += flushRecord.get("embryo_type");
|
||||||
|
if (flushRecord.get("storage_method") != null) subType += " " + flushRecord.get("storage_method");
|
||||||
|
etPlan.put("embryoSubType", subType.trim());
|
||||||
|
|
||||||
|
return etPlan;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.warn("未找到母羊耳号 {} 的配种或移植计划信息", manageTags);
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取配种计划信息时发生异常,母羊耳号: {}", manageTags, e);
|
log.error("获取配种/移植计划信息时发生异常,母羊耳号: {}", manageTags, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步孕检结果到配种记录
|
* 同步孕检结果到配种记录
|
||||||
*
|
*
|
||||||
@@ -246,47 +318,102 @@ public class ScBreedRecordServiceImpl implements IScBreedRecordService
|
|||||||
return scBreedRecordMapper.selectBreedRecordByMatingTime(sheepId, startDate, endDate);
|
return scBreedRecordMapper.selectBreedRecordByMatingTime(sheepId, startDate, endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 新增配种记录
|
// * 新增配种记录
|
||||||
*
|
// *
|
||||||
* @param scBreedRecord 配种记录
|
// * @param scBreedRecord 配种记录
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public int insertScBreedRecord(ScBreedRecord scBreedRecord)
|
// public int insertScBreedRecord(ScBreedRecord scBreedRecord)
|
||||||
{
|
// {
|
||||||
// 设置创建时间
|
// // 设置创建时间
|
||||||
scBreedRecord.setCreateTime(DateUtils.getNowDate());
|
// scBreedRecord.setCreateTime(DateUtils.getNowDate());
|
||||||
|
//
|
||||||
// 插入配种记录
|
// // 插入配种记录
|
||||||
int result = scBreedRecordMapper.insertScBreedRecord(scBreedRecord);
|
// int result = scBreedRecordMapper.insertScBreedRecord(scBreedRecord);
|
||||||
|
//
|
||||||
// 如果插入成功,同步更新羊只的配种日期
|
// // 如果插入成功,同步更新羊只的配种日期
|
||||||
if (result > 0 && scBreedRecord.getEweId() != null) {
|
// if (result > 0 && scBreedRecord.getEweId() != null) {
|
||||||
try {
|
// try {
|
||||||
Long eweId = Long.parseLong(scBreedRecord.getEweId());
|
// Long eweId = Long.parseLong(scBreedRecord.getEweId());
|
||||||
|
//
|
||||||
// // 方案1:只更新配种日期(推荐)
|
//// // 方案1:只更新配种日期(推荐)
|
||||||
// scBreedRecordMapper.updateSheepMatingDate(
|
//// scBreedRecordMapper.updateSheepMatingDate(
|
||||||
|
//// eweId,
|
||||||
|
//// scBreedRecord.getCreateTime(),
|
||||||
|
//// scBreedRecord.getCreateBy()
|
||||||
|
//// );
|
||||||
|
//
|
||||||
|
//// 方案2:同时更新配种日期和配种次数(如果需要的话,取消下面注释)
|
||||||
|
// scBreedRecordMapper.incrementSheepMatingCount(
|
||||||
// eweId,
|
// eweId,
|
||||||
// scBreedRecord.getCreateTime(),
|
// scBreedRecord.getCreateTime(),
|
||||||
// scBreedRecord.getCreateBy()
|
// scBreedRecord.getCreateBy()
|
||||||
// );
|
// );
|
||||||
|
//
|
||||||
|
// log.info("同步更新羊只 {} 的配种日期成功", eweId);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// log.error("同步更新羊只配种日期失败", e);
|
||||||
|
// // 不影响主流程,只记录日志
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
/**
|
||||||
|
* 新增配种记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertScBreedRecord(ScBreedRecord scBreedRecord)
|
||||||
|
{
|
||||||
|
scBreedRecord.setCreateTime(DateUtils.getNowDate());
|
||||||
|
|
||||||
// 方案2:同时更新配种日期和配种次数(如果需要的话,取消下面注释)
|
// 如果是胚胎移植(5),且前端没有传移胚数等信息,可以在这里做一次兜底查询
|
||||||
|
// 但通常前端 form 表单提交时应该已经通过 getLatestBreedPlanByEweTags 填好了
|
||||||
|
|
||||||
|
// 插入记录
|
||||||
|
int result = scBreedRecordMapper.insertScBreedRecord(scBreedRecord);
|
||||||
|
|
||||||
|
// 同步更新羊只的基础信息(配种次数、配种日期)
|
||||||
|
if (result > 0 && scBreedRecord.getEweId() != null) {
|
||||||
|
try {
|
||||||
|
Long eweId = Long.parseLong(scBreedRecord.getEweId());
|
||||||
scBreedRecordMapper.incrementSheepMatingCount(
|
scBreedRecordMapper.incrementSheepMatingCount(
|
||||||
eweId,
|
eweId,
|
||||||
scBreedRecord.getCreateTime(),
|
scBreedRecord.getCreateTime(),
|
||||||
scBreedRecord.getCreateBy()
|
scBreedRecord.getCreateBy()
|
||||||
);
|
);
|
||||||
|
|
||||||
log.info("同步更新羊只 {} 的配种日期成功", eweId);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("同步更新羊只配种日期失败", e);
|
log.error("同步更新羊只配种日期失败", e);
|
||||||
// 不影响主流程,只记录日志
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public ScBreedRecord getAutomaticBreedMatch(String manageTags) {
|
||||||
|
// 1. 尝试从配种计划获取 (breed_type: 1, 2, 3, 4)
|
||||||
|
Map<String, Object> plan = scBreedRecordMapper.getLatestBreedPlanByEweTags(manageTags);
|
||||||
|
if (plan != null) {
|
||||||
|
ScBreedRecord record = new ScBreedRecord();
|
||||||
|
record.setBreedType(Integer.parseInt(plan.get("breed_type").toString()));
|
||||||
|
record.setRamManageTags((String) plan.get("ram_manage_tags"));
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 尝试从冲胚记录获取
|
||||||
|
Map<String, Object> flushRecord = scBreedRecordMapper.getFlushRecordByEweNo(manageTags);
|
||||||
|
if (flushRecord != null) {
|
||||||
|
ScBreedRecord record = new ScBreedRecord();
|
||||||
|
record.setBreedType(5); // 设定 5 为胚胎移植(您可根据实际调整枚举)
|
||||||
|
record.setEmbryoCount(Integer.parseInt(flushRecord.get("transferred").toString()));
|
||||||
|
record.setDonorEweNo((String) flushRecord.get("donor_female_no"));
|
||||||
|
record.setDonorRamNo((String) flushRecord.get("donor_male_no"));
|
||||||
|
// 根据冲胚记录的存储方式和类型拼接“配种子类型”
|
||||||
|
record.setEmbryoSubType(flushRecord.get("embryo_type") + " " + flushRecord.get("storage_method"));
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null; // 均未找到
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,43 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScBreedRecordMapper">
|
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScBreedRecordMapper">
|
||||||
|
|
||||||
|
<!-- <resultMap type="ScBreedRecord" id="ScBreedRecordResult">-->
|
||||||
|
<!-- <result property="id" column="id" />-->
|
||||||
|
<!-- <result property="sheepId" column="sheep_id" />-->
|
||||||
|
<!-- <result property="ramId" column="ram_id" />-->
|
||||||
|
<!-- <result property="eweId" column="ewe_id" />-->
|
||||||
|
<!-- <result property="technician" column="technician" />-->
|
||||||
|
<!-- <result property="breedDrugs" column="breed_drugs" />-->
|
||||||
|
<!-- <result property="breedType" column="breed_type" />-->
|
||||||
|
<!-- <result property="createBy" column="create_by" / >-->
|
||||||
|
<!-- <result property="createTime" column="create_time" />-->
|
||||||
|
<!-- <!– 显示字段 –>-->
|
||||||
|
<!-- <result property="eweManageTags" column="ewe_manage_tags" />-->
|
||||||
|
<!-- <result property="eweVariety" column="ewe_variety" />-->
|
||||||
|
<!-- <result property="ramManageTags" column="ram_manage_tags" />-->
|
||||||
|
<!-- <result property="ramVariety" column="ram_variety" />-->
|
||||||
|
<!-- <result property="eweParity" column="ewe_parity" />-->
|
||||||
|
<!-- <result property="eweMonthAge" column="ewe_month_age" />-->
|
||||||
|
<!-- <result property="eweSheepfoldName" column="ewe_sheepfold_name" />-->
|
||||||
|
<!-- <result property="eweBreedStatus" column="ewe_breed_status" />-->
|
||||||
|
<!-- <result property="eweControlled" column="ewe_controlled" />-->
|
||||||
|
<!-- <result property="eweComment" column="ewe_comment" />-->
|
||||||
|
<!-- <result property="ranchName" column="ranch_name" />-->
|
||||||
|
<!-- <result property="matingType" column="mating_type" />-->
|
||||||
|
<!-- <result property="sheepType" column="sheep_type" />-->
|
||||||
|
<!-- <result property="matingCount" column="mating_count" />-->
|
||||||
|
<!-- <result property="timeSincePlanning" column="time_since_planning" />-->
|
||||||
|
<!-- <!– 孕检相关字段 –>-->
|
||||||
|
<!-- <result property="pregnancyCheckDate" column="pregnancy_check_date" />-->
|
||||||
|
<!-- <result property="pregnancyResult" column="pregnancy_result" />-->
|
||||||
|
<!-- <result property="pregnancyWay" column="pregnancy_way" />-->
|
||||||
|
<!-- <result property="fetusCount" column="fetus_count" />-->
|
||||||
|
<!-- <result property="pregnancyTechnician" column="pregnancy_technician" />-->
|
||||||
|
<!-- <result property="pregnancyRemark" column="pregnancy_remark" />-->
|
||||||
|
<!-- <result property="pregnancyRecordId" column="pregnancy_record_id" />-->
|
||||||
|
<!-- <result property="daysToPregnancyCheck" column="days_to_pregnancy_check" />-->
|
||||||
|
<!-- <result property="isPregnancyChecked" column="is_pregnancy_checked" />-->
|
||||||
|
<!-- </resultMap>-->
|
||||||
<resultMap type="ScBreedRecord" id="ScBreedRecordResult">
|
<resultMap type="ScBreedRecord" id="ScBreedRecordResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="sheepId" column="sheep_id" />
|
<result property="sheepId" column="sheep_id" />
|
||||||
@@ -12,9 +49,14 @@
|
|||||||
<result property="technician" column="technician" />
|
<result property="technician" column="technician" />
|
||||||
<result property="breedDrugs" column="breed_drugs" />
|
<result property="breedDrugs" column="breed_drugs" />
|
||||||
<result property="breedType" column="breed_type" />
|
<result property="breedType" column="breed_type" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="frozenSemenNo" column="frozen_semen_no" /> <result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<!-- 显示字段 -->
|
<result property="comment" column="comment" />
|
||||||
|
|
||||||
|
<result property="embryoCount" column="embryo_count" />
|
||||||
|
<result property="donorEweNo" column="donor_ewe" />
|
||||||
|
<result property="donorRamNo" column="donor_ram" />
|
||||||
|
|
||||||
<result property="eweManageTags" column="ewe_manage_tags" />
|
<result property="eweManageTags" column="ewe_manage_tags" />
|
||||||
<result property="eweVariety" column="ewe_variety" />
|
<result property="eweVariety" column="ewe_variety" />
|
||||||
<result property="ramManageTags" column="ram_manage_tags" />
|
<result property="ramManageTags" column="ram_manage_tags" />
|
||||||
@@ -26,24 +68,26 @@
|
|||||||
<result property="eweControlled" column="ewe_controlled" />
|
<result property="eweControlled" column="ewe_controlled" />
|
||||||
<result property="eweComment" column="ewe_comment" />
|
<result property="eweComment" column="ewe_comment" />
|
||||||
<result property="ranchName" column="ranch_name" />
|
<result property="ranchName" column="ranch_name" />
|
||||||
<result property="matingType" column="mating_type" />
|
|
||||||
<result property="sheepType" column="sheep_type" />
|
<result property="sheepType" column="sheep_type" />
|
||||||
<result property="matingCount" column="mating_count" />
|
<result property="matingCount" column="mating_count" />
|
||||||
|
|
||||||
<result property="timeSincePlanning" column="time_since_planning" />
|
<result property="timeSincePlanning" column="time_since_planning" />
|
||||||
<!-- 孕检相关字段 -->
|
<result property="daysPostLambing" column="days_post_lambing" />
|
||||||
|
<result property="daysLactation" column="days_lactation" />
|
||||||
|
<result property="daysPostMating" column="days_post_mating" />
|
||||||
|
<result property="lastMatingDate" column="last_mating_date" />
|
||||||
|
|
||||||
<result property="pregnancyCheckDate" column="pregnancy_check_date" />
|
<result property="pregnancyCheckDate" column="pregnancy_check_date" />
|
||||||
<result property="pregnancyResult" column="pregnancy_result" />
|
<result property="pregnancyResult" column="pregnancy_result" />
|
||||||
<result property="pregnancyWay" column="pregnancy_way" />
|
<result property="eweParity" column="eweParity" />
|
||||||
<result property="fetusCount" column="fetus_count" />
|
|
||||||
<result property="pregnancyTechnician" column="pregnancy_technician" />
|
|
||||||
<result property="pregnancyRemark" column="pregnancy_remark" />
|
|
||||||
<result property="pregnancyRecordId" column="pregnancy_record_id" />
|
<result property="pregnancyRecordId" column="pregnancy_record_id" />
|
||||||
<result property="daysToPregnancyCheck" column="days_to_pregnancy_check" />
|
<result property="daysToPregnancyCheck" column="days_to_pregnancy_check" />
|
||||||
<result property="isPregnancyChecked" column="is_pregnancy_checked" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
<!-- <sql id="selectScBreedRecordVo">-->
|
<!-- <sql id="selectScBreedRecordVo">-->
|
||||||
<!-- select-->
|
<!-- select DISTINCT-->
|
||||||
<!-- br.id,-->
|
<!-- br.id,-->
|
||||||
<!-- br.sheep_id,-->
|
<!-- br.sheep_id,-->
|
||||||
<!-- br.ram_id,-->
|
<!-- br.ram_id,-->
|
||||||
@@ -68,7 +112,8 @@
|
|||||||
<!-- -- 公羊信息(从视图获取)-->
|
<!-- -- 公羊信息(从视图获取)-->
|
||||||
<!-- 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 '本交'-->
|
||||||
@@ -99,15 +144,15 @@
|
|||||||
<!-- from sc_breed_record br-->
|
<!-- from sc_breed_record br-->
|
||||||
<!-- left join sheep_file ewe_view on br.ewe_id = ewe_view.id-->
|
<!-- left join sheep_file ewe_view on br.ewe_id = ewe_view.id-->
|
||||||
<!-- left join sheep_file ram_view on br.ram_id = ram_view.id-->
|
<!-- left join sheep_file ram_view on br.ram_id = ram_view.id-->
|
||||||
<!-- left join sc_pregnancy_record pr on pr.sheep_id = br.ewe_id-->
|
<!-- -- 修复:使用子查询确保只返回一条孕检记录-->
|
||||||
<!-- and pr.is_delete = 0-->
|
<!-- left join sc_pregnancy_record pr on pr.id = (-->
|
||||||
<!-- and pr.datetime >= br.create_time-->
|
<!-- select pr2.id-->
|
||||||
<!-- and pr.datetime = (-->
|
|
||||||
<!-- select min(pr2.datetime)-->
|
|
||||||
<!-- from sc_pregnancy_record pr2-->
|
<!-- from sc_pregnancy_record pr2-->
|
||||||
<!-- where pr2.sheep_id = br.ewe_id-->
|
<!-- where pr2.sheep_id = br.ewe_id-->
|
||||||
<!-- and pr2.is_delete = 0-->
|
<!-- and pr2.is_delete = 0-->
|
||||||
<!-- and pr2.datetime >= br.create_time-->
|
<!-- and pr2.datetime >= br.create_time-->
|
||||||
|
<!-- order by pr2.datetime asc, pr2.id asc-->
|
||||||
|
<!-- limit 1-->
|
||||||
<!-- )-->
|
<!-- )-->
|
||||||
<!-- </sql>-->
|
<!-- </sql>-->
|
||||||
<sql id="selectScBreedRecordVo">
|
<sql id="selectScBreedRecordVo">
|
||||||
@@ -119,9 +164,19 @@
|
|||||||
br.technician,
|
br.technician,
|
||||||
br.breed_drugs,
|
br.breed_drugs,
|
||||||
br.breed_type,
|
br.breed_type,
|
||||||
|
br.frozen_sperm_no, -- 冻精号
|
||||||
|
br.comment,
|
||||||
br.create_by,
|
br.create_by,
|
||||||
br.create_time,
|
br.create_time,
|
||||||
-- 母羊信息(从视图获取)
|
|
||||||
|
-- 胚胎移植相关字段 (如果不存表里,需要join sc_embryo_flush,这里假设存表或已有字段,如需Join请参考下方注释)
|
||||||
|
-- 假设表里已有这些列,或者我们通过Join sheep_file 拿(但sheep_file没有donor信息)
|
||||||
|
-- 这里按照最佳实践,应在插入时将Donor信息固化在breed_record表中
|
||||||
|
br.donor_ewe,
|
||||||
|
br.donor_ram,
|
||||||
|
br.embryo_count,
|
||||||
|
|
||||||
|
-- 母羊信息
|
||||||
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,
|
||||||
@@ -133,19 +188,51 @@
|
|||||||
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,
|
||||||
-- 配种方式显示
|
|
||||||
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,
|
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,
|
||||||
|
|
||||||
|
-- ================= 计算字段实现 =================
|
||||||
|
|
||||||
|
-- 1. 配种时产后天数 (距离上一次产羔: 找最近一次小于配种时间的产羔日期)
|
||||||
|
DATEDIFF(br.create_time, (
|
||||||
|
SELECT lambing_date
|
||||||
|
FROM sheep_file
|
||||||
|
WHERE id = br.ewe_id
|
||||||
|
)) as days_post_lambing,
|
||||||
|
|
||||||
|
-- 2. 配种时泌乳天数 (距离上一次孕检且怀孕)
|
||||||
|
DATEDIFF(br.create_time, (
|
||||||
|
SELECT MAX(pr_sub.datetime)
|
||||||
|
FROM sc_pregnancy_record pr_sub
|
||||||
|
WHERE pr_sub.sheep_id = br.ewe_id
|
||||||
|
AND pr_sub.result = '怀孕'
|
||||||
|
AND pr_sub.is_delete = 0
|
||||||
|
AND pr_sub.datetime < br.create_time
|
||||||
|
)) as days_lactation,
|
||||||
|
|
||||||
|
-- 3. 配种时配后天数 (距离上一次配种)
|
||||||
|
DATEDIFF(br.create_time, (
|
||||||
|
SELECT MAX(br_sub.create_time)
|
||||||
|
FROM sc_breed_record br_sub
|
||||||
|
WHERE br_sub.ewe_id = br.ewe_id
|
||||||
|
AND br_sub.create_time < br.create_time
|
||||||
|
)) as days_post_mating,
|
||||||
|
|
||||||
|
-- 4. 上次配种日期
|
||||||
|
(
|
||||||
|
SELECT MAX(br_sub.create_time)
|
||||||
|
FROM sc_breed_record br_sub
|
||||||
|
WHERE br_sub.ewe_id = br.ewe_id
|
||||||
|
AND br_sub.create_time < br.create_time
|
||||||
|
) as last_mating_date,
|
||||||
|
|
||||||
|
-- ===============================================
|
||||||
|
|
||||||
-- 孕检相关信息
|
-- 孕检相关信息
|
||||||
pr.datetime as pregnancy_check_date,
|
pr.datetime as pregnancy_check_date,
|
||||||
pr.result as pregnancy_result,
|
pr.result as pregnancy_result,
|
||||||
@@ -164,10 +251,10 @@
|
|||||||
WHEN pr.id IS NOT NULL THEN 1
|
WHEN pr.id IS NOT NULL THEN 1
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END as is_pregnancy_checked
|
END as is_pregnancy_checked
|
||||||
|
|
||||||
from sc_breed_record br
|
from sc_breed_record br
|
||||||
left join sheep_file ewe_view on br.ewe_id = ewe_view.id
|
left join sheep_file ewe_view on br.ewe_id = ewe_view.id
|
||||||
left join sheep_file ram_view on br.ram_id = ram_view.id
|
left join sheep_file ram_view on br.ram_id = ram_view.id
|
||||||
-- 修复:使用子查询确保只返回一条孕检记录
|
|
||||||
left join sc_pregnancy_record pr on pr.id = (
|
left join sc_pregnancy_record pr on pr.id = (
|
||||||
select pr2.id
|
select pr2.id
|
||||||
from sc_pregnancy_record pr2
|
from sc_pregnancy_record pr2
|
||||||
@@ -178,6 +265,32 @@
|
|||||||
limit 1
|
limit 1
|
||||||
)
|
)
|
||||||
</sql>
|
</sql>
|
||||||
|
<!-- <select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">-->
|
||||||
|
<!-- <include refid="selectScBreedRecordVo"/>-->
|
||||||
|
<!-- <where>-->
|
||||||
|
<!-- <if test="sheepId != null "> and br.sheep_id = #{sheepId}</if>-->
|
||||||
|
<!-- <if test="ramId != null and ramId != ''"> and br.ram_id = #{ramId}</if>-->
|
||||||
|
<!-- <if test="eweId != null and eweId != ''"> and br.ewe_id = #{eweId}</if>-->
|
||||||
|
<!-- <if test="breedType != null"> and br.breed_type = #{breedType}</if>-->
|
||||||
|
<!-- <if test="technician != null and technician != ''"> and br.technician like concat('%', #{technician}, '%')</if>-->
|
||||||
|
<!-- <if test="breedDrugs != null and breedDrugs != ''"> and br.breed_drugs like concat('%', #{breedDrugs}, '%')</if>-->
|
||||||
|
<!-- <if test="createBy != null and createBy != ''"> and br.create_by like concat('%', #{createBy}, '%')</if>-->
|
||||||
|
<!-- <if test="createTime != null "> and date_format(br.create_time,'%y-%m-%d') = date_format(#{createTime},'%y-%m-%d')</if>-->
|
||||||
|
<!-- <!– 新增耳号查询条件 –>-->
|
||||||
|
<!-- <if test="eweManageTags != null and eweManageTags != ''"> and ewe_view.bs_manage_tags like concat('%', #{eweManageTags}, '%')</if>-->
|
||||||
|
<!-- <if test="ramManageTags != null and ramManageTags != ''"> and ram_view.bs_manage_tags like concat('%', #{ramManageTags}, '%')</if>-->
|
||||||
|
<!-- <if test="eweVariety != null and eweVariety != ''"> and ewe_view.variety like concat('%', #{eweVariety}, '%')</if>-->
|
||||||
|
<!-- <if test="ramVariety != null and ramVariety != ''"> and ram_view.variety like concat('%', #{ramVariety}, '%')</if>-->
|
||||||
|
<!-- <if test="ranchId != null"> and ewe_view.ranch_id = #{ranchId}</if>-->
|
||||||
|
<!-- <!– 孕检相关查询条件 –>-->
|
||||||
|
<!-- <if test="pregnancyResult != null and pregnancyResult != ''"> and pr.result like concat('%', #{pregnancyResult}, '%')</if>-->
|
||||||
|
<!-- <if test="isPregnancyChecked != null">-->
|
||||||
|
<!-- <if test="isPregnancyChecked == 1"> and pr.id IS NOT NULL</if>-->
|
||||||
|
<!-- <if test="isPregnancyChecked == 0"> and pr.id IS NULL</if>-->
|
||||||
|
<!-- </if>-->
|
||||||
|
<!-- </where>-->
|
||||||
|
<!-- order by br.create_time desc-->
|
||||||
|
<!-- </select>-->
|
||||||
<select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">
|
<select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">
|
||||||
<include refid="selectScBreedRecordVo"/>
|
<include refid="selectScBreedRecordVo"/>
|
||||||
<where>
|
<where>
|
||||||
@@ -185,22 +298,20 @@
|
|||||||
<if test="ramId != null and ramId != ''"> and br.ram_id = #{ramId}</if>
|
<if test="ramId != null and ramId != ''"> and br.ram_id = #{ramId}</if>
|
||||||
<if test="eweId != null and eweId != ''"> and br.ewe_id = #{eweId}</if>
|
<if test="eweId != null and eweId != ''"> and br.ewe_id = #{eweId}</if>
|
||||||
<if test="breedType != null"> and br.breed_type = #{breedType}</if>
|
<if test="breedType != null"> and br.breed_type = #{breedType}</if>
|
||||||
<if test="technician != null and technician != ''"> and br.technician like concat('%', #{technician}, '%')</if>
|
|
||||||
<if test="breedDrugs != null and breedDrugs != ''"> and br.breed_drugs like concat('%', #{breedDrugs}, '%')</if>
|
|
||||||
<if test="createBy != null and createBy != ''"> and br.create_by like concat('%', #{createBy}, '%')</if>
|
|
||||||
<if test="createTime != null "> and date_format(br.create_time,'%y-%m-%d') = date_format(#{createTime},'%y-%m-%d')</if>
|
<if test="createTime != null "> and date_format(br.create_time,'%y-%m-%d') = date_format(#{createTime},'%y-%m-%d')</if>
|
||||||
<!-- 新增耳号查询条件 -->
|
<if test="eweManageTags != null and eweManageTags != ''">
|
||||||
<if test="eweManageTags != null and eweManageTags != ''"> and ewe_view.bs_manage_tags like concat('%', #{eweManageTags}, '%')</if>
|
and (
|
||||||
<if test="ramManageTags != null and ramManageTags != ''"> and ram_view.bs_manage_tags like concat('%', #{ramManageTags}, '%')</if>
|
ewe_view.bs_manage_tags like concat('%', #{eweManageTags}, '%')
|
||||||
<if test="eweVariety != null and eweVariety != ''"> and ewe_view.variety like concat('%', #{eweVariety}, '%')</if>
|
OR br.donor_ewe_no like concat('%', #{eweManageTags}, '%') -- Also search donor
|
||||||
<if test="ramVariety != null and ramVariety != ''"> and ram_view.variety like concat('%', #{ramVariety}, '%')</if>
|
)
|
||||||
<if test="ranchId != null"> and ewe_view.ranch_id = #{ranchId}</if>
|
|
||||||
<!-- 孕检相关查询条件 -->
|
|
||||||
<if test="pregnancyResult != null and pregnancyResult != ''"> and pr.result like concat('%', #{pregnancyResult}, '%')</if>
|
|
||||||
<if test="isPregnancyChecked != null">
|
|
||||||
<if test="isPregnancyChecked == 1"> and pr.id IS NOT NULL</if>
|
|
||||||
<if test="isPregnancyChecked == 0"> and pr.id IS NULL</if>
|
|
||||||
</if>
|
</if>
|
||||||
|
<if test="ramManageTags != null and ramManageTags != ''">
|
||||||
|
and (
|
||||||
|
ram_view.bs_manage_tags like concat('%', #{ramManageTags}, '%')
|
||||||
|
OR br.donor_ram like concat('%', #{ramManageTags}, '%') -- Also search donor
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="frozenSemenNo != null and frozenSemenNo != ''"> and br.frozen_sperm_no like concat('%', #{frozenSemenNo}, '%')</if>
|
||||||
</where>
|
</where>
|
||||||
order by br.create_time desc
|
order by br.create_time desc
|
||||||
</select>
|
</select>
|
||||||
@@ -334,6 +445,29 @@
|
|||||||
limit 1
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- <insert id="insertScBreedRecord" parameterType="ScBreedRecord" useGeneratedKeys="true" keyProperty="id">-->
|
||||||
|
<!-- insert into sc_breed_record-->
|
||||||
|
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
|
||||||
|
<!-- <if test="sheepId != null">sheep_id,</if>-->
|
||||||
|
<!-- <if test="ramId != null">ram_id,</if>-->
|
||||||
|
<!-- <if test="eweId != null">ewe_id,</if>-->
|
||||||
|
<!-- <if test="technician != null">technician,</if>-->
|
||||||
|
<!-- <if test="breedDrugs != null">breed_drugs,</if>-->
|
||||||
|
<!-- <if test="breedType != null">breed_type,</if>-->
|
||||||
|
<!-- <if test="createBy != null">create_by,</if>-->
|
||||||
|
<!-- <if test="createTime != null">create_time,</if>-->
|
||||||
|
<!-- </trim>-->
|
||||||
|
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
|
||||||
|
<!-- <if test="sheepId != null">#{sheepId},</if>-->
|
||||||
|
<!-- <if test="ramId != null">#{ramId},</if>-->
|
||||||
|
<!-- <if test="eweId != null">#{eweId},</if>-->
|
||||||
|
<!-- <if test="technician != null">#{technician},</if>-->
|
||||||
|
<!-- <if test="breedDrugs != null">#{breedDrugs},</if>-->
|
||||||
|
<!-- <if test="breedType != null">#{breedType},</if>-->
|
||||||
|
<!-- <if test="createBy != null">#{createBy},</if>-->
|
||||||
|
<!-- <if test="createTime != null">#{createTime},</if>-->
|
||||||
|
<!-- </trim>-->
|
||||||
|
<!-- </insert>-->
|
||||||
<insert id="insertScBreedRecord" parameterType="ScBreedRecord" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertScBreedRecord" parameterType="ScBreedRecord" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into sc_breed_record
|
insert into sc_breed_record
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
@@ -343,8 +477,13 @@
|
|||||||
<if test="technician != null">technician,</if>
|
<if test="technician != null">technician,</if>
|
||||||
<if test="breedDrugs != null">breed_drugs,</if>
|
<if test="breedDrugs != null">breed_drugs,</if>
|
||||||
<if test="breedType != null">breed_type,</if>
|
<if test="breedType != null">breed_type,</if>
|
||||||
|
<if test="frozenSemenNo != null">frozen_semen_no,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="comment != null">comment,</if>
|
||||||
|
<if test="embryoCount != null">embryo_count,</if>
|
||||||
|
<if test="donorEweNo != null">donor_ewe,</if>
|
||||||
|
<if test="donorRamNo != null">donor_ram,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="sheepId != null">#{sheepId},</if>
|
<if test="sheepId != null">#{sheepId},</if>
|
||||||
@@ -353,11 +492,31 @@
|
|||||||
<if test="technician != null">#{technician},</if>
|
<if test="technician != null">#{technician},</if>
|
||||||
<if test="breedDrugs != null">#{breedDrugs},</if>
|
<if test="breedDrugs != null">#{breedDrugs},</if>
|
||||||
<if test="breedType != null">#{breedType},</if>
|
<if test="breedType != null">#{breedType},</if>
|
||||||
|
<if test="frozenSemenNo != null">#{frozenSemenNo},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="comment != null">#{comment},</if>
|
||||||
|
<if test="embryoCount != null">#{embryoCount},</if>
|
||||||
|
<if test="donorEweNo != null">#{donorEweNo},</if>
|
||||||
|
<if test="donorRamNo != null">#{donorRamNo},</if>
|
||||||
|
<if test="embryoSubType != null">#{embryoSubType},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<!-- <update id="updateScBreedRecord" parameterType="ScBreedRecord">-->
|
||||||
|
<!-- update sc_breed_record-->
|
||||||
|
<!-- <trim prefix="SET" suffixOverrides=",">-->
|
||||||
|
<!-- <if test="sheepId != null">sheep_id = #{sheepId},</if>-->
|
||||||
|
<!-- <if test="ramId != null">ram_id = #{ramId},</if>-->
|
||||||
|
<!-- <if test="eweId != null">ewe_id = #{eweId},</if>-->
|
||||||
|
<!-- <if test="technician != null">technician = #{technician},</if>-->
|
||||||
|
<!-- <if test="breedDrugs != null">breed_drugs = #{breedDrugs},</if>-->
|
||||||
|
<!-- <if test="breedType != null">breed_type = #{breedType},</if>-->
|
||||||
|
<!-- <if test="createBy != null">create_by = #{createBy},</if>-->
|
||||||
|
<!-- <if test="createTime != null">create_time = #{createTime},</if>-->
|
||||||
|
<!-- </trim>-->
|
||||||
|
<!-- where id = #{id}-->
|
||||||
|
<!-- </update>-->
|
||||||
<update id="updateScBreedRecord" parameterType="ScBreedRecord">
|
<update id="updateScBreedRecord" parameterType="ScBreedRecord">
|
||||||
update sc_breed_record
|
update sc_breed_record
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
@@ -367,12 +526,34 @@
|
|||||||
<if test="technician != null">technician = #{technician},</if>
|
<if test="technician != null">technician = #{technician},</if>
|
||||||
<if test="breedDrugs != null">breed_drugs = #{breedDrugs},</if>
|
<if test="breedDrugs != null">breed_drugs = #{breedDrugs},</if>
|
||||||
<if test="breedType != null">breed_type = #{breedType},</if>
|
<if test="breedType != null">breed_type = #{breedType},</if>
|
||||||
|
<if test="frozenSemenNo != null">frozen_semen_no = #{frozenSemenNo},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="comment != null">comment = #{comment},</if>
|
||||||
|
<if test="embryoCount != null">embryo_count = #{embryoCount},</if>
|
||||||
|
<if test="donorEweNo != null">donor_ewe = #{donorEweNo},</if>
|
||||||
|
<if test="donorRamNo != null">donor_ram = #{donorRamNo},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
<select id="getFlushRecordByEweNo" parameterType="String" resultType="map">
|
||||||
|
SELECT
|
||||||
|
transferred,
|
||||||
|
donor_female_no,
|
||||||
|
donor_male_no,
|
||||||
|
embryo_type,
|
||||||
|
storage_method
|
||||||
|
FROM sc_embryo_flush
|
||||||
|
WHERE id = (
|
||||||
|
-- Assuming linking via recipient tags is complicated,
|
||||||
|
-- usually this is done by matching a recent flush record
|
||||||
|
-- For now, this mimics the logic in your ServiceImpl
|
||||||
|
SELECT id FROM sc_embryo_flush WHERE recipient_list LIKE concat('%', #{manageTags}, '%')
|
||||||
|
ORDER BY created_at DESC LIMIT 1
|
||||||
|
)
|
||||||
|
-- Note: If your sc_embryo_flush structure is different (one row per recipient), adjust accordingly.
|
||||||
|
-- Based on provided file, it has `recipient_cnt`.
|
||||||
|
</select>
|
||||||
<delete id="deleteScBreedRecordById" parameterType="Long">
|
<delete id="deleteScBreedRecordById" parameterType="Long">
|
||||||
delete from sc_breed_record where id = #{id}
|
delete from sc_breed_record where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|||||||
Reference in New Issue
Block a user