Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -201,6 +201,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-test</artifactId>
|
<artifactId>spring-boot-test</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -44,6 +44,17 @@ public class DaSheepfoldController extends BaseController
|
|||||||
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldList(daSheepfold);
|
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldList(daSheepfold);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主表格:羊舍级别汇总列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/summaryList")
|
||||||
|
public TableDataInfo summaryList(DaSheepfold daSheepfold) {
|
||||||
|
startPage();
|
||||||
|
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldSummaryList(daSheepfold);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* 根据羊舍ids查询羊只id
|
* 根据羊舍ids查询羊只id
|
||||||
* */
|
* */
|
||||||
|
|||||||
@@ -115,5 +115,10 @@ public class DaSheepfold extends BaseEntity
|
|||||||
@Excel(name = "备注")
|
@Excel(name = "备注")
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
// 非数据库字段:单栏位羊数(子表格用)
|
||||||
|
private Integer sheepCount;
|
||||||
|
// 非数据库字段:羊舍总羊数(主表格用)
|
||||||
|
private Integer totalSheepCount;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// 创建文件:ExportConfig.java
|
||||||
|
package com.zhyc.module.base.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出配置类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ExportConfig {
|
||||||
|
/**
|
||||||
|
* 要导出的列名列表(前端传递的驼峰命名)
|
||||||
|
*/
|
||||||
|
private List<String> columnNames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询条件
|
||||||
|
*/
|
||||||
|
private Map<String, Object> queryParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义筛选条件
|
||||||
|
*/
|
||||||
|
private Map<String, Object> customFilterParams;
|
||||||
|
}
|
||||||
@@ -30,6 +30,12 @@ public interface DaSheepfoldMapper
|
|||||||
*/
|
*/
|
||||||
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold);
|
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 羊舍级别汇总查询(主表格)
|
||||||
|
*/
|
||||||
|
List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增羊舍管理
|
* 新增羊舍管理
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ public interface IDaSheepfoldService
|
|||||||
*/
|
*/
|
||||||
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold);
|
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold);
|
||||||
|
|
||||||
|
public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增羊舍管理
|
* 新增羊舍管理
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import com.zhyc.module.base.domain.DaSheepfold;
|
|||||||
import com.zhyc.module.base.mapper.BasSheepMapper;
|
import com.zhyc.module.base.mapper.BasSheepMapper;
|
||||||
import com.zhyc.module.base.mapper.DaSheepfoldMapper;
|
import com.zhyc.module.base.mapper.DaSheepfoldMapper;
|
||||||
import com.zhyc.module.base.service.IDaSheepfoldService;
|
import com.zhyc.module.base.service.IDaSheepfoldService;
|
||||||
|
import org.slf4j.Logger; // 核心修正:导入SLF4J的Logger
|
||||||
|
import org.slf4j.LoggerFactory; // 核心修正:导入SLF4J的LoggerFactory
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -24,6 +26,11 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BasSheepMapper basSheepMapper;
|
private BasSheepMapper basSheepMapper;
|
||||||
|
|
||||||
|
|
||||||
|
// 新增:创建日志对象
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(DaSheepfoldServiceImpl.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询羊舍管理
|
* 查询羊舍管理
|
||||||
*
|
*
|
||||||
@@ -45,9 +52,44 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
|
|||||||
@Override
|
@Override
|
||||||
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold)
|
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
List<DaSheepfold> sheepfoldList = daSheepfoldMapper.selectDaSheepfoldList(daSheepfold);
|
||||||
|
|
||||||
|
// 新增调试打印:输出每个栏位的羊数
|
||||||
|
log.info("===== 栏位羊数调试 =====");
|
||||||
|
log.info("查询条件:牧场ID={}, 羊舍类型ID={}, 羊舍编号={}",
|
||||||
|
daSheepfold.getRanchId(), daSheepfold.getSheepfoldTypeId(), daSheepfold.getSheepfoldNo());
|
||||||
|
log.info("共查询到{}个栏位", sheepfoldList.size());
|
||||||
|
|
||||||
|
for (DaSheepfold fold : sheepfoldList) {
|
||||||
|
log.info("栏位ID={}, 羊舍编号={}, 排号={}, 栏数={}, 羊数={}",
|
||||||
|
fold.getId(), fold.getSheepfoldNo(), fold.getRowNo(), fold.getColumns(), fold.getSheepCount());
|
||||||
|
}
|
||||||
|
log.info("===== 调试结束 =====\n");
|
||||||
return daSheepfoldMapper.selectDaSheepfoldList(daSheepfold);
|
return daSheepfoldMapper.selectDaSheepfoldList(daSheepfold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 羊舍级别汇总查询(主表格)
|
||||||
|
*/
|
||||||
|
public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold) {
|
||||||
|
// List<DaSheepfold> summaryList = daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold);
|
||||||
|
//
|
||||||
|
// // 新增调试打印:输出羊舍汇总羊数
|
||||||
|
// log.info("===== 羊舍汇总羊数调试 =====");
|
||||||
|
// log.info("查询条件:牧场ID={}, 羊舍类型ID={}",
|
||||||
|
// daSheepfold.getRanchId(), daSheepfold.getSheepfoldTypeId());
|
||||||
|
// log.info("共查询到{}个羊舍", summaryList.size());
|
||||||
|
//
|
||||||
|
// for (DaSheepfold fold : summaryList) {
|
||||||
|
// log.info("羊舍编号={}, 羊舍名称={}, 总羊数={}",
|
||||||
|
// fold.getSheepfoldNo(), fold.getSheepfoldName(), fold.getTotalSheepCount());
|
||||||
|
// }
|
||||||
|
// log.info("===== 汇总调试结束 =====\n");
|
||||||
|
return daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增羊舍管理
|
* 新增羊舍管理
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -143,8 +143,8 @@ public class ScBreedRecordController extends BaseController
|
|||||||
if (scBreedRecord.getBreedType() == null) {
|
if (scBreedRecord.getBreedType() == null) {
|
||||||
return error("配种方式不能为空");
|
return error("配种方式不能为空");
|
||||||
}
|
}
|
||||||
if (scBreedRecord.getBreedType() < 1 || scBreedRecord.getBreedType() > 4) {
|
if (scBreedRecord.getBreedType() < 1 || scBreedRecord.getBreedType() > 5) {
|
||||||
return error("配种方式只能是:1-同期发情、2-本交、3-冲胚、4-自然发情人工授精");
|
return error("配种方式只能是:1-供体母羊配种、2-同期发情人工授精、3-本交、4-自然发情人工授精、5-胚胎移植");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证技术员
|
// 验证技术员
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zhyc.module.produce.breed.domain;
|
package com.zhyc.module.produce.breed.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -37,6 +38,8 @@ public class ScBreedRecord extends BaseEntity
|
|||||||
@Excel(name = "事件类型")
|
@Excel(name = "事件类型")
|
||||||
private String eventType = "配种";
|
private String eventType = "配种";
|
||||||
|
|
||||||
|
// 核心注解:指定JSON解析/序列化的日期格式,时区指定为东八区(Asia/Shanghai)
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "Asia/Shanghai")
|
||||||
@Excel(name = "配种日期", dateFormat = "yyyy-MM-dd")
|
@Excel(name = "配种日期", dateFormat = "yyyy-MM-dd")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
@@ -62,7 +65,7 @@ public class ScBreedRecord extends BaseEntity
|
|||||||
private Integer embryoCount;
|
private Integer embryoCount;
|
||||||
|
|
||||||
/** 1-同期发情, 2-本交, 3-自然发情, 4-胚胎移植 */
|
/** 1-同期发情, 2-本交, 3-自然发情, 4-胚胎移植 */
|
||||||
@Excel(name = "配种方式", readConverterExp = "1=同期发情,2=本交,3=自然发情,4=胚胎移植")
|
@Excel(name = "配种方式", readConverterExp = "1=供体母羊配种,2=同期发情人工授精,3=本交,4=胚胎移植,5=自然发情人工授精")
|
||||||
private Integer breedType;
|
private Integer breedType;
|
||||||
|
|
||||||
@Excel(name = "配种子类型")
|
@Excel(name = "配种子类型")
|
||||||
|
|||||||
@@ -217,58 +217,28 @@ public class ScBreedRecordServiceImpl implements IScBreedRecordService
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
/**
|
/**
|
||||||
* 根据母羊耳号获取最新的配种计划信息
|
* 简化后的获取配种计划方法:移除冲胚记录自动关联
|
||||||
* 修改逻辑:优先查配种计划 -> 其次查冲胚记录(作为受体)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getLatestBreedPlanByEweTags(String manageTags)
|
public Map<String, Object> getLatestBreedPlanByEweTags(String manageTags) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
// 1. 优先从配种计划生成表获取最新计划 (同期发情/本交等)
|
// 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);
|
|
||||||
return latestPlan;
|
return latestPlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 如果生成表中没有,从普通配种计划表获取
|
// 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);
|
|
||||||
return normalPlan;
|
return normalPlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 【新增逻辑】如果都没有,尝试从冲胚记录中查找(该羊是否作为受体)
|
// 胚胎移植逻辑已移至前端手动输入,此处不再查询 sc_embryo_flush
|
||||||
// 这里的业务逻辑是:如果这只羊在冲胚记录的"受体列表"中,且是最近的操作,则认为它是去做胚胎移植
|
log.info("未找到母羊 {} 的普通配种计划", manageTags);
|
||||||
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("获取配种计划异常", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ public class ScEmbryoFlushServiceImpl implements IScEmbryoFlushService
|
|||||||
VARIETY_NAME_MAP.put(4, "级杂一代");
|
VARIETY_NAME_MAP.put(4, "级杂一代");
|
||||||
VARIETY_NAME_MAP.put(5, "级杂二代");
|
VARIETY_NAME_MAP.put(5, "级杂二代");
|
||||||
VARIETY_NAME_MAP.put(6, "级杂三代");
|
VARIETY_NAME_MAP.put(6, "级杂三代");
|
||||||
VARIETY_NAME_MAP.put(7, "1世代");
|
VARIETY_NAME_MAP.put(7, "一世代");
|
||||||
VARIETY_NAME_MAP.put(8, "2世代");
|
VARIETY_NAME_MAP.put(8, "二世代");
|
||||||
VARIETY_NAME_MAP.put(9, "3世代");
|
VARIETY_NAME_MAP.put(9, "三世代");
|
||||||
VARIETY_NAME_MAP.put(10, "4世代");
|
VARIETY_NAME_MAP.put(10, "四世代");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,23 +142,24 @@ public class ScEmbryoFlushServiceImpl implements IScEmbryoFlushService
|
|||||||
// 2. 查询配种记录获取公羊信息
|
// 2. 查询配种记录获取公羊信息
|
||||||
Map<String, Object> breedRecord = scEmbryoFlushMapper.selectBreedRecordByEwe(donorFemaleNo);
|
Map<String, Object> breedRecord = scEmbryoFlushMapper.selectBreedRecordByEwe(donorFemaleNo);
|
||||||
if (breedRecord != null && !breedRecord.isEmpty()) {
|
if (breedRecord != null && !breedRecord.isEmpty()) {
|
||||||
String ramId = (String) breedRecord.get("ramId");
|
String maleNo = (String) breedRecord.get("donorMaleNo"); // 这里的 Key 必须对应 SQL 里的别名
|
||||||
result.put("donorMaleNo", ramId);
|
result.put("donorMaleNo", maleNo);
|
||||||
result.put("matingDate", breedRecord.get("matingDate"));
|
result.put("matingDate", breedRecord.get("matingDate"));
|
||||||
|
|
||||||
// 3. 查询公羊品种
|
// 3. 查询公羊品种
|
||||||
if (ramId != null && !ramId.trim().isEmpty()) {
|
if (maleNo != null && !maleNo.trim().isEmpty()) {
|
||||||
Map<String, Object> maleInfo = scEmbryoFlushMapper.selectSheepInfoByManageTag(ramId);
|
Map<String, Object> maleInfo = scEmbryoFlushMapper.selectSheepInfoByManageTag(maleNo);
|
||||||
if (maleInfo != null && !maleInfo.isEmpty()) {
|
if (maleInfo != null && !maleInfo.isEmpty()) {
|
||||||
String maleVariety = (String) maleInfo.get("variety");
|
String maleVariety = (String) maleInfo.get("variety");
|
||||||
Integer maleVarietyId = getIntValue(maleInfo.get("varietyId"));
|
|
||||||
|
|
||||||
result.put("donorMaleVariety", maleVariety);
|
result.put("donorMaleVariety", maleVariety);
|
||||||
result.put("donorMaleVarietyId", maleVarietyId);
|
|
||||||
|
|
||||||
// 4. 根据品种ID计算胚胎品种
|
// 4. 【关键修复】使用品种名称计算胚胎品种
|
||||||
if (maleVarietyId != null && femaleVarietyId != null) {
|
// 这样可以确保无论数据库ID是多少,只要名字是对的就能算出结果
|
||||||
String embryoVariety = calculateEmbryoVarietyById(maleVarietyId, femaleVarietyId);
|
Integer mId = getVarietyIdByName(maleVariety);
|
||||||
|
Integer fId = getVarietyIdByName(femaleVariety);
|
||||||
|
|
||||||
|
if (mId != null && fId != null) {
|
||||||
|
String embryoVariety = calculateEmbryoVarietyById(mId, fId);
|
||||||
result.put("embryoVariety", embryoVariety);
|
result.put("embryoVariety", embryoVariety);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,6 +169,7 @@ public class ScEmbryoFlushServiceImpl implements IScEmbryoFlushService
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全获取Integer值
|
* 安全获取Integer值
|
||||||
*/
|
*/
|
||||||
@@ -292,23 +294,22 @@ public class ScEmbryoFlushServiceImpl implements IScEmbryoFlushService
|
|||||||
// 级杂二代(BM)或n世代(SM) × 级杂一代/级杂二代/级杂三代/回交(公) → 世代
|
// 级杂二代(BM)或n世代(SM) × 级杂一代/级杂二代/级杂三代/回交(公) → 世代
|
||||||
|
|
||||||
// 判断公羊是否为可产生世代的品种(级杂一代/二代/三代/回交)
|
// 判断公羊是否为可产生世代的品种(级杂一代/二代/三代/回交)
|
||||||
boolean isMaleForShidai = (male == VARIETY_JIZA_1 || male == VARIETY_JIZA_2 ||
|
boolean isMaleCapableOfGeneration = (male >= 3 && male <= 10);
|
||||||
male == VARIETY_JIZA_3 || male == VARIETY_HUIJIAO);
|
|
||||||
|
|
||||||
if (isMaleForShidai) {
|
if (isMaleCapableOfGeneration) {
|
||||||
// 级杂二代(母) × 以上公羊 → 1世代
|
// 级杂二代(母) x 任意合格公羊 -> 一世代
|
||||||
if (female == VARIETY_JIZA_2) {
|
if (female == VARIETY_JIZA_2) {
|
||||||
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_1);
|
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_1);
|
||||||
}
|
}
|
||||||
// 1世代(母) × 以上公羊 → 2世代
|
// 一世代(母) x 任意合格公羊 -> 二世代
|
||||||
if (female == VARIETY_SHIDAI_1) {
|
if (female == VARIETY_SHIDAI_1) {
|
||||||
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_2);
|
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_2);
|
||||||
}
|
}
|
||||||
// 2世代(母) × 以上公羊 → 3世代
|
// 二世代(母) x 任意合格公羊 -> 三世代
|
||||||
if (female == VARIETY_SHIDAI_2) {
|
if (female == VARIETY_SHIDAI_2) {
|
||||||
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_3);
|
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_3);
|
||||||
}
|
}
|
||||||
// 3世代(母) × 以上公羊 → 4世代
|
// 三世代(母) x 任意合格公羊 -> 四世代
|
||||||
if (female == VARIETY_SHIDAI_3) {
|
if (female == VARIETY_SHIDAI_3) {
|
||||||
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_4);
|
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_4);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,33 +13,93 @@
|
|||||||
<result property="rowNo" column="row_no"/>
|
<result property="rowNo" column="row_no"/>
|
||||||
<result property="columns" column="columns"/>
|
<result property="columns" column="columns"/>
|
||||||
<result property="comment" column="comment"/>
|
<result property="comment" column="comment"/>
|
||||||
|
<!-- 新增羊只数量映射 -->
|
||||||
|
<result property="sheepCount" column="sheep_count"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 基础栏位表查询字段 -->
|
||||||
<sql id="selectDaSheepfoldVo">
|
<sql id="selectDaSheepfoldVo">
|
||||||
select id,
|
SELECT
|
||||||
ranch_id,
|
ds.id,
|
||||||
sheepfold_name,
|
ds.ranch_id,
|
||||||
sheepfold_type_id,
|
ds.sheepfold_name,
|
||||||
sheepfold_no,
|
ds.sheepfold_type_id,
|
||||||
row_no,
|
ds.sheepfold_no,
|
||||||
columns,
|
ds.row_no,
|
||||||
comment
|
ds.columns,
|
||||||
from da_sheepfold
|
ds.comment
|
||||||
|
FROM da_sheepfold ds
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectDaSheepfoldList" parameterType="DaSheepfold" resultMap="DaSheepfoldResult">
|
|
||||||
<include refid="selectDaSheepfoldVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="ranchId != null ">and ranch_id = #{ranchId}</if>
|
|
||||||
<if test="sheepfoldTypeId != null ">and sheepfold_type_id = #{sheepfoldTypeId}</if>
|
|
||||||
</where>
|
|
||||||
|
|
||||||
order by
|
<!-- 1. 主表格:羊舍级别汇总查询(统计每个羊舍的总羊数) -->
|
||||||
SUBSTRING_INDEX(row_no, '-', 1),
|
<select id="selectDaSheepfoldSummaryList" parameterType="DaSheepfold" resultMap="DaSheepfoldSummaryResult">
|
||||||
CAST(columns AS UNSIGNED)
|
SELECT
|
||||||
|
ds.ranch_id,
|
||||||
|
ds.sheepfold_type_id,
|
||||||
|
ds.sheepfold_no,
|
||||||
|
-- 提取羊舍名称(截取栏位名称的羊舍部分,保证唯一)
|
||||||
|
CONCAT(ds.sheepfold_no, '号', (SELECT dict_label FROM sys_dict_data WHERE dict_value = ds.sheepfold_type_id AND dict_type = 'bas_sheepfold_type')) as sheepfoldName,
|
||||||
|
MAX(ds.comment) as comment,
|
||||||
|
-- 汇总该羊舍下所有栏位的羊数总和
|
||||||
|
SUM(IFNULL(sheep_group.sheep_count, 0)) as totalSheepCount
|
||||||
|
FROM da_sheepfold ds
|
||||||
|
-- 左关联羊只表,统计每个栏位的羊数
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT sheepfold_id, COUNT(id) as sheep_count
|
||||||
|
FROM bas_sheep -- 羊只表
|
||||||
|
GROUP BY sheepfold_id -- 按栏位ID分组统计羊数
|
||||||
|
) sheep_group ON ds.id = sheep_group.sheepfold_id -- 关联字段修正为sheepfold_id
|
||||||
|
<where>
|
||||||
|
<if test="ranchId != null ">and ds.ranch_id = #{ranchId}</if>
|
||||||
|
<if test="sheepfoldTypeId != null ">and ds.sheepfold_type_id = #{sheepfoldTypeId}</if>
|
||||||
|
</where>
|
||||||
|
-- 按羊舍维度分组(牧场+羊舍类型+羊舍编号 唯一标识一个羊舍)
|
||||||
|
GROUP BY ds.ranch_id, ds.sheepfold_type_id, ds.sheepfold_no
|
||||||
|
ORDER BY ds.sheepfold_no
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 2. 子表格:栏位级别明细查询(统计单个栏位的羊数) -->
|
||||||
|
<select id="selectDaSheepfoldList" parameterType="DaSheepfold" resultMap="DaSheepfoldResult">
|
||||||
|
SELECT
|
||||||
|
ds.id,
|
||||||
|
ds.ranch_id,
|
||||||
|
ds.sheepfold_name,
|
||||||
|
ds.sheepfold_type_id,
|
||||||
|
ds.sheepfold_no,
|
||||||
|
ds.row_no,
|
||||||
|
ds.columns,
|
||||||
|
ds.comment,
|
||||||
|
-- 统计当前栏位的羊数(关联羊只表)
|
||||||
|
IFNULL(sheep_group.sheep_count, 0) as sheep_count
|
||||||
|
FROM da_sheepfold ds
|
||||||
|
-- 左关联羊只表,避免无羊的栏位被过滤
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT sheepfold_id, COUNT(id) as sheep_count
|
||||||
|
FROM bas_sheep -- 羊只表
|
||||||
|
GROUP BY sheepfold_id
|
||||||
|
) sheep_group ON ds.id = sheep_group.sheepfold_id -- 关联字段修正为sheepfold_id
|
||||||
|
<where>
|
||||||
|
<if test="ranchId != null ">and ds.ranch_id = #{ranchId}</if>
|
||||||
|
<if test="sheepfoldTypeId != null ">and ds.sheepfold_type_id = #{sheepfoldTypeId}</if>
|
||||||
|
<if test="sheepfoldNo != null and sheepfoldNo != '' ">and ds.sheepfold_no = #{sheepfoldNo}</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY ds.id,ds.ranch_id,ds.sheepfold_name,ds.sheepfold_type_id,ds.sheepfold_no,ds.row_no,ds.columns,ds.comment
|
||||||
|
ORDER BY SUBSTRING_INDEX(ds.row_no, '-', 1), CAST(ds.columns AS UNSIGNED)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 汇总结果映射(主表格用) -->
|
||||||
|
<resultMap id="DaSheepfoldSummaryResult" type="DaSheepfold">
|
||||||
|
<result property="ranchId" column="ranch_id"/>
|
||||||
|
<result property="sheepfoldTypeId" column="sheepfold_type_id"/>
|
||||||
|
<result property="sheepfoldNo" column="sheepfold_no"/>
|
||||||
|
<result property="sheepfoldName" column="sheepfoldName"/>
|
||||||
|
<result property="comment" column="comment"/>
|
||||||
|
<result property="totalSheepCount" column="totalSheepCount"/> <!-- 羊舍总羊数 -->
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectDaSheepfoldById" parameterType="Long" resultMap="DaSheepfoldResult">
|
<select id="selectDaSheepfoldById" parameterType="Long" resultMap="DaSheepfoldResult">
|
||||||
<include refid="selectDaSheepfoldVo"/>
|
<include refid="selectDaSheepfoldVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
|
|||||||
@@ -49,11 +49,12 @@
|
|||||||
<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="frozenSemenNo" column="frozen_semen_no" /> <result property="createBy" column="create_by" />
|
<result property="frozenSemenNo" column="frozen_sperm_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="comment" column="comment" />
|
||||||
|
|
||||||
<result property="embryoCount" column="embryo_count" />
|
<result property="embryoCount" column="embryo_count" />
|
||||||
|
<result property="embryoSubType" column="embryoSubType" />
|
||||||
<result property="donorEweNo" column="donor_ewe" />
|
<result property="donorEweNo" column="donor_ewe" />
|
||||||
<result property="donorRamNo" column="donor_ram" />
|
<result property="donorRamNo" column="donor_ram" />
|
||||||
|
|
||||||
@@ -165,6 +166,7 @@
|
|||||||
br.breed_drugs,
|
br.breed_drugs,
|
||||||
br.breed_type,
|
br.breed_type,
|
||||||
br.frozen_sperm_no, -- 冻精号
|
br.frozen_sperm_no, -- 冻精号
|
||||||
|
br.embryoSubType,
|
||||||
br.comment,
|
br.comment,
|
||||||
br.create_by,
|
br.create_by,
|
||||||
br.create_time,
|
br.create_time,
|
||||||
@@ -192,7 +194,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,
|
||||||
|
(SELECT variety FROM sheep_file WHERE bs_manage_tags = br.donor_ewe LIMIT 1) as donorEweVariety,
|
||||||
|
(SELECT variety FROM sheep_file WHERE bs_manage_tags = br.donor_ram LIMIT 1) as donorRamVariety,
|
||||||
-- 发情后配种时间(小时数)
|
-- 发情后配种时间(小时数)
|
||||||
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,
|
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,
|
||||||
|
|
||||||
@@ -321,6 +324,8 @@
|
|||||||
where br.id = #{id}
|
where br.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 根据母羊耳号查询羊只ID -->
|
<!-- 根据母羊耳号查询羊只ID -->
|
||||||
<select id="getSheepIdByManageTags" parameterType="String" resultType="Long">
|
<select id="getSheepIdByManageTags" parameterType="String" resultType="Long">
|
||||||
select id from sheep_file where bs_manage_tags = #{manageTags} and is_delete = 0
|
select id from sheep_file where bs_manage_tags = #{manageTags} and is_delete = 0
|
||||||
@@ -477,13 +482,14 @@
|
|||||||
<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="frozenSemenNo != null">frozen_sperm_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="comment != null">comment,</if>
|
||||||
<if test="embryoCount != null">embryo_count,</if>
|
<if test="embryoCount != null">embryo_count,</if>
|
||||||
<if test="donorEweNo != null">donor_ewe,</if>
|
<if test="donorEweNo != null">donor_ewe,</if>
|
||||||
<if test="donorRamNo != null">donor_ram,</if>
|
<if test="donorRamNo != null">donor_ram,</if>
|
||||||
|
<if test="embryoSubType != null">embryoSubType,</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>
|
||||||
@@ -526,13 +532,14 @@
|
|||||||
<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="frozenSemenNo != null">frozen_sperm_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="comment != null">comment = #{comment},</if>
|
||||||
<if test="embryoCount != null">embryo_count = #{embryoCount},</if>
|
<if test="embryoCount != null">embryo_count = #{embryoCount},</if>
|
||||||
<if test="donorEweNo != null">donor_ewe = #{donorEweNo},</if>
|
<if test="donorEweNo != null">donor_ewe = #{donorEweNo},</if>
|
||||||
<if test="donorRamNo != null">donor_ram = #{donorRamNo},</if>
|
<if test="donorRamNo != null">donor_ram = #{donorRamNo},</if>
|
||||||
|
<if test="embryoSubType != null">embryoSubType = #{embryoSubType},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
@@ -548,8 +555,8 @@
|
|||||||
-- Assuming linking via recipient tags is complicated,
|
-- Assuming linking via recipient tags is complicated,
|
||||||
-- usually this is done by matching a recent flush record
|
-- usually this is done by matching a recent flush record
|
||||||
-- For now, this mimics the logic in your ServiceImpl
|
-- For now, this mimics the logic in your ServiceImpl
|
||||||
SELECT id FROM sc_embryo_flush WHERE recipient_list LIKE concat('%', #{manageTags}, '%')
|
SELECT id FROM sc_embryo_flush WHERE donor_female_no LIKE concat('%', #{manageTags}, '%')
|
||||||
ORDER BY created_at DESC LIMIT 1
|
ORDER BY flush_time DESC LIMIT 1
|
||||||
)
|
)
|
||||||
-- Note: If your sc_embryo_flush structure is different (one row per recipient), adjust accordingly.
|
-- Note: If your sc_embryo_flush structure is different (one row per recipient), adjust accordingly.
|
||||||
-- Based on provided file, it has `recipient_cnt`.
|
-- Based on provided file, it has `recipient_cnt`.
|
||||||
|
|||||||
@@ -203,13 +203,9 @@
|
|||||||
<!-- ewe_id存的是数字ID,需要先根据耳号找到母羊ID,再查配种记录,再根据公羊ID找到公羊耳号 -->
|
<!-- ewe_id存的是数字ID,需要先根据耳号找到母羊ID,再查配种记录,再根据公羊ID找到公羊耳号 -->
|
||||||
<select id="selectBreedRecordByEwe" resultType="java.util.Map">
|
<select id="selectBreedRecordByEwe" resultType="java.util.Map">
|
||||||
SELECT
|
SELECT
|
||||||
ram_sf.bs_manage_tags AS ramId,
|
donor_ram AS donorMaleNo, create_time AS matingDate FROM sc_breed_record
|
||||||
br.create_time AS matingDate
|
WHERE donor_ewe = #{eweManageTag} AND (is_delete = 0 OR is_delete IS NULL)
|
||||||
FROM sc_breed_record br
|
ORDER BY create_time DESC
|
||||||
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
|
LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user