Compare commits
7 Commits
ca54b5f544
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 638ce039a3 | |||
| 9f65048d16 | |||
|
|
4755a327eb | ||
|
|
2a39664c38 | ||
|
|
b26a803aab | ||
| 6261b65040 | |||
| 73a6e881e3 |
12
pom.xml
12
pom.xml
@@ -259,6 +259,18 @@
|
||||
<version>${kaptcha.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- ... existing code ... -->
|
||||
|
||||
<!-- Tess4J OCR 工具 -->
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.tess4j</groupId>
|
||||
<artifactId>tess4j</artifactId>
|
||||
<version>4.5.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 定时任务-->
|
||||
<!-- ... existing code ... -->
|
||||
|
||||
<!-- 定时任务-->
|
||||
<dependency>
|
||||
<groupId>zhyc</groupId>
|
||||
|
||||
@@ -23,7 +23,11 @@
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||
</dependency>
|
||||
|
||||
<!-- Tess4J OCR 识别 -->
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.tess4j</groupId>
|
||||
<artifactId>tess4j</artifactId>
|
||||
</dependency>
|
||||
<!-- swagger3-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
# url: jdbc:mysql://146.56.214.124:3306/zhyc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# url: jdbc:mysql://localhost:3306/zhyc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# username: zhyc
|
||||
# password: zhyc1234
|
||||
url: jdbc:mysql://118.182.97.76:3306/zhyc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
|
||||
@@ -50,6 +50,7 @@ public class DaSheepfoldController extends BaseController
|
||||
/**
|
||||
* 主表格:羊舍级别汇总列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('sheepfold_management:sheepfold_management:list')")
|
||||
@GetMapping("/summaryList")
|
||||
public TableDataInfo summaryList(DaSheepfold daSheepfold) {
|
||||
startPage();
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.zhyc.common.core.page.TableDataInfo;
|
||||
import com.zhyc.common.core.text.Convert;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.service.ISheepFileService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -139,7 +140,7 @@ public class SheepFileController extends BaseController
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
// 调用支持复杂查询的Service方法
|
||||
List<SheepFile> list = sheepFileService.selectSheepFileListByCondition(customParams, sheepFile);
|
||||
List<SheepFile> list = sheepFileService.selectSheepFileListByCondition( sheepFile,customParams);
|
||||
|
||||
return getDataTable(list);
|
||||
}
|
||||
@@ -255,7 +256,7 @@ public class SheepFileController extends BaseController
|
||||
}
|
||||
|
||||
// 3. 获取数据并执行行过滤
|
||||
List<SheepFile> list = sheepFileService.selectSheepFileListByCondition(customParams, sheepFile);
|
||||
List<SheepFile> list = sheepFileService.selectSheepFileListByCondition(sheepFile,customParams);
|
||||
if (StringUtils.isNotBlank(exportIdsStr)) {
|
||||
List<String> exportIdList = Arrays.asList(exportIdsStr.split(","));
|
||||
list = list.stream()
|
||||
@@ -332,28 +333,28 @@ public class SheepFileController extends BaseController
|
||||
|
||||
@GetMapping("/stat/sheepType")
|
||||
public AjaxResult statSheepType() {
|
||||
return success(sheepFileService.countBySheepType());
|
||||
return success(sheepFileService.countBySheepType(new SheepFile()));
|
||||
}
|
||||
|
||||
@GetMapping("/stat/breedStatus")
|
||||
public AjaxResult statBreedStatus() {
|
||||
return success(sheepFileService.countByBreedStatus());
|
||||
return success(sheepFileService.countByBreedStatus(new SheepFile()));
|
||||
}
|
||||
|
||||
@GetMapping("/stat/variety")
|
||||
public AjaxResult statVariety() {
|
||||
return success(sheepFileService.countByVariety());
|
||||
return success(sheepFileService.countByVariety(new SheepFile()));
|
||||
}
|
||||
|
||||
@GetMapping("/stat/lactationParity")
|
||||
public AjaxResult statLactationParity() {
|
||||
return success(sheepFileService.countParityOfLactation());
|
||||
return success(sheepFileService.countParityOfLactation(new SheepFile()));
|
||||
}
|
||||
|
||||
// 在群总数
|
||||
@GetMapping("/stat/inGroupCount")
|
||||
public AjaxResult inGroupCount() {
|
||||
return success(sheepFileService.countInGroup());
|
||||
return success(sheepFileService.countInGroup(new SheepFile()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,70 +19,6 @@ public class DaSheepfold extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getRanchId() {
|
||||
return ranchId;
|
||||
}
|
||||
|
||||
public void setRanchId(Long ranchId) {
|
||||
this.ranchId = ranchId;
|
||||
}
|
||||
|
||||
public String getSheepfoldName() {
|
||||
return sheepfoldName;
|
||||
}
|
||||
|
||||
public void setSheepfoldName(String sheepfoldName) {
|
||||
this.sheepfoldName = sheepfoldName;
|
||||
}
|
||||
|
||||
public Long getSheepfoldTypeId() {
|
||||
return sheepfoldTypeId;
|
||||
}
|
||||
|
||||
public void setSheepfoldTypeId(Long sheepfoldTypeId) {
|
||||
this.sheepfoldTypeId = sheepfoldTypeId;
|
||||
}
|
||||
|
||||
public String getSheepfoldNo() {
|
||||
return sheepfoldNo;
|
||||
}
|
||||
|
||||
public void setSheepfoldNo(String sheepfoldNo) {
|
||||
this.sheepfoldNo = sheepfoldNo;
|
||||
}
|
||||
|
||||
public String getRowNo() {
|
||||
return rowNo;
|
||||
}
|
||||
|
||||
public void setRowNo(String rowNo) {
|
||||
this.rowNo = rowNo;
|
||||
}
|
||||
|
||||
public String getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(String columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
/** 羊舍id */
|
||||
@Excel(name = "羊舍id")
|
||||
private Long id;
|
||||
@@ -127,20 +63,4 @@ public class DaSheepfold extends BaseEntity
|
||||
|
||||
/** 部门编号 */
|
||||
private Long deptId;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.zhyc.module.base.mapper;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.ResultMap;
|
||||
import org.apache.ibatis.annotations.SelectProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -50,19 +48,19 @@ public interface SheepFileMapper
|
||||
SheepFile selectSheepByManageTags(String tags);
|
||||
|
||||
// 在群羊只总数
|
||||
Long countInGroup();
|
||||
Long countInGroup(SheepFile sheep);
|
||||
|
||||
// 羊只类别分布(按 name 分组)
|
||||
List<Map<String,Object>> countBySheepType();
|
||||
List<Map<String,Object>> countBySheepType(SheepFile sheep);
|
||||
|
||||
// 繁育状态分布(按 breed 分组)
|
||||
List<Map<String,Object>> countByBreedStatus();
|
||||
List<Map<String,Object>> countByBreedStatus(SheepFile sheep);
|
||||
|
||||
// 品种分布(按 variety 分组)
|
||||
List<Map<String,Object>> countByVariety();
|
||||
List<Map<String,Object>> countByVariety(SheepFile sheep);
|
||||
|
||||
// 泌乳羊胎次分布(name = '泌乳羊' 时按 parity 分组)
|
||||
List<Map<String,Object>> countParityOfLactation();
|
||||
List<Map<String,Object>> countParityOfLactation(SheepFile sheep);
|
||||
|
||||
/**
|
||||
* 获取指定字段的唯一值列表 (配合 XML 中的 selectFieldValues)
|
||||
@@ -75,22 +73,22 @@ public interface SheepFileMapper
|
||||
* 必须使用 @Param 注解以便 XML 能正确识别两个参数
|
||||
*/
|
||||
List<SheepFile> selectSheepFileListByCondition(
|
||||
@Param("params") Map<String, Object> params,
|
||||
@Param("sheepFile") SheepFile sheepFile
|
||||
);
|
||||
|
||||
/**
|
||||
* 保留原有 Provider 方法 (若项目其他地方有用到)
|
||||
*/
|
||||
@SelectProvider(type = SheepFileSqlProvider.class, method = "selectByCondition")
|
||||
@ResultMap("SheepFileResult")
|
||||
List<SheepFile> selectByCondition(
|
||||
@Param("sheepFile") SheepFile sheepFile,
|
||||
@Param("conditions") Map<String, Object> conditions
|
||||
@Param("params") Map<String, Object> params
|
||||
);
|
||||
|
||||
@SelectProvider(type = SheepFileSqlProvider.class, method = "selectFieldValues")
|
||||
List<String> selectFieldValuesByProvider(@Param("fieldName") String fieldName);
|
||||
// /**
|
||||
// * 保留原有 Provider 方法 (若项目其他地方有用到)
|
||||
// */
|
||||
// @SelectProvider(type = SheepFileSqlProvider.class, method = "selectByCondition")
|
||||
// @ResultMap("SheepFileResult")
|
||||
// List<SheepFile> selectByCondition(
|
||||
// @Param("sheepFile") SheepFile sheepFile,
|
||||
// @Param("conditions") Map<String, Object> conditions
|
||||
// );
|
||||
//
|
||||
// @SelectProvider(type = SheepFileSqlProvider.class, method = "selectFieldValues")
|
||||
// List<String> selectFieldValuesByProvider(@Param("fieldName") String fieldName);
|
||||
|
||||
/**
|
||||
* 查询所有公羊(gender=2)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zhyc.module.base.service;
|
||||
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
@@ -34,26 +35,21 @@ public interface ISheepFileService
|
||||
|
||||
SheepFile selectBasSheepByManageTags(String trim);
|
||||
|
||||
Long countInGroup();
|
||||
Long countInGroup(SheepFile sheepFile);
|
||||
|
||||
List<Map<String,Object>> countBySheepType();
|
||||
List<Map<String,Object>> countByBreedStatus();
|
||||
List<Map<String,Object>> countByVariety();
|
||||
List<Map<String,Object>> countParityOfLactation();
|
||||
List<Map<String,Object>> countBySheepType(SheepFile sheepFile);
|
||||
List<Map<String,Object>> countByBreedStatus(SheepFile sheepFile);
|
||||
List<Map<String,Object>> countByVariety(SheepFile sheepFile);
|
||||
List<Map<String,Object>> countParityOfLactation(SheepFile sheepFile);
|
||||
|
||||
/**
|
||||
* 获取指定字段的唯一值列表
|
||||
*/
|
||||
List<String> getFieldValues(String fieldName);
|
||||
|
||||
/**
|
||||
* 根据复杂条件查询羊只档案列表
|
||||
* @param params 自定义参数Map (用于动态SQL)
|
||||
* @param sheepFile 包含List筛选条件的实体对象
|
||||
*/
|
||||
List<SheepFile> selectSheepFileListByCondition(
|
||||
Map<String, Object> params,
|
||||
SheepFile sheepFile
|
||||
@Param("sheepFile") SheepFile sheepFile,
|
||||
@Param("params") Map<String, Object> params
|
||||
);
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -63,8 +63,10 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
|
||||
* 羊舍级别汇总查询(主表格)
|
||||
*/
|
||||
@DataScope(deptAlias = "ds", userAlias = "ds")
|
||||
@Override
|
||||
public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold) {
|
||||
return daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold);
|
||||
List<DaSheepfold> sheepfoldList = daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold);
|
||||
return sheepfoldList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhyc.module.base.service.impl;
|
||||
|
||||
// 新增这一行导入
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
import com.zhyc.module.base.domain.BreedRamFile;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.mapper.SheepFileMapper;
|
||||
@@ -61,31 +62,33 @@ public class SheepFileServiceImpl implements ISheepFileService {
|
||||
|
||||
@DataScope(deptAlias = "sf", userAlias = "sf")
|
||||
@Override
|
||||
public List<Map<String, Object>> countBySheepType() {
|
||||
return sheepFileMapper.countBySheepType();
|
||||
public List<Map<String, Object>> countBySheepType(SheepFile sheepFile) {
|
||||
return sheepFileMapper.countBySheepType(sheepFile);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "sf", userAlias = "sf")
|
||||
@Override
|
||||
public List<Map<String, Object>> countByBreedStatus() {
|
||||
return sheepFileMapper.countByBreedStatus();
|
||||
public List<Map<String, Object>> countByBreedStatus(SheepFile sheepFile) {
|
||||
return sheepFileMapper.countByBreedStatus(sheepFile);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "sf", userAlias = "sf")
|
||||
@Override
|
||||
public List<Map<String, Object>> countByVariety() {
|
||||
return sheepFileMapper.countByVariety();
|
||||
public List<Map<String, Object>> countByVariety(SheepFile sheepFile) {
|
||||
return sheepFileMapper.countByVariety(sheepFile);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "sf", userAlias = "sf")
|
||||
@Override
|
||||
public List<Map<String, Object>> countParityOfLactation() {
|
||||
return sheepFileMapper.countParityOfLactation();
|
||||
public List<Map<String, Object>> countParityOfLactation(SheepFile sheepFile) {
|
||||
return sheepFileMapper.countParityOfLactation(sheepFile);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "sf", userAlias = "sf")
|
||||
@Override
|
||||
public Long countInGroup() { return sheepFileMapper.countInGroup(); }
|
||||
public Long countInGroup(SheepFile sheepFile) {
|
||||
return sheepFileMapper.countInGroup(sheepFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定字段的唯一值列表
|
||||
@@ -110,13 +113,14 @@ public class SheepFileServiceImpl implements ISheepFileService {
|
||||
*/
|
||||
@DataScope(deptAlias = "sf", userAlias = "sf")
|
||||
@Override
|
||||
public List<SheepFile> selectSheepFileListByCondition(Map<String, Object> params, SheepFile sheepFile) {
|
||||
public List<SheepFile> selectSheepFileListByCondition( SheepFile sheepFile,Map<String, Object> params) {
|
||||
// 1. 验证并处理自定义参数 (驼峰转下划线、安全检查)
|
||||
Map<String, Object> safeConditions = processConditions(params);
|
||||
|
||||
System.out.println("sheepFile.params: " + (sheepFile.getParams() != null ? sheepFile.getParams().get("dataScope") : "null"));
|
||||
// 2. 调用 Mapper
|
||||
// 这里必须使用与 XML 中 <select id="selectSheepFileListByCondition"> 对应的方法
|
||||
return sheepFileMapper.selectSheepFileListByCondition(safeConditions, sheepFile);
|
||||
return sheepFileMapper.selectSheepFileListByCondition(sheepFile,safeConditions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,6 +47,16 @@ public class DewormController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('biosafety:deworm:list')")
|
||||
@GetMapping("/searchEarNumbers")
|
||||
public AjaxResult getSheepNoList(String sheepNo)
|
||||
{
|
||||
Deworm deworm = new Deworm();
|
||||
deworm.setSheepNo(sheepNo);
|
||||
List<String> list = dewormService.selectSheepNoList(deworm);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出驱虫列表
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.biosafety.domain.Deworm;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -114,4 +116,15 @@ public class DiagnosisController extends BaseController
|
||||
{
|
||||
return toAjax(diagnosisService.deleteDiagnosisByIds(ids));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('biosafety:diagnosis:list')")
|
||||
@GetMapping("/searchEarNumbers")
|
||||
public AjaxResult getSheepNoList(String sheepNo)
|
||||
{
|
||||
Diagnosis diagnosis = new Diagnosis();
|
||||
diagnosis.setSheepNo(sheepNo);
|
||||
List<String> list = diagnosisService.selectSheepNoList(diagnosis);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zhyc.module.biosafety.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.biosafety.service.IDisinfectService;
|
||||
@@ -104,4 +106,13 @@ public class DisinfectController extends BaseController
|
||||
{
|
||||
return toAjax(disinfectService.deleteDisinfectByIds(ids));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('biosafety:disinfect:list')")
|
||||
@GetMapping("/searchSheepfold")
|
||||
public AjaxResult getSheepfoldList(String sheepfold){
|
||||
Disinfect disinfect = new Disinfect();
|
||||
disinfect.setSheepfoldName(sheepfold);
|
||||
List<Object[]> list = disinfectService.selectSheepfoldList(disinfect);
|
||||
return success(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.module.biosafety.domain.Deworm;
|
||||
import com.zhyc.module.biosafety.service.IHealthService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -105,4 +106,15 @@ public class HealthController extends BaseController
|
||||
{
|
||||
return toAjax(healthService.deleteHealthByIds(ids));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('biosafety:health:list')")
|
||||
@GetMapping("/searchEarNumbers")
|
||||
public AjaxResult getSheepNoList(String sheepNo)
|
||||
{
|
||||
Health health = new Health();
|
||||
health.setSheepNo(sheepNo);
|
||||
List<String> list = healthService.selectSheepNoList(health);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zhyc.module.biosafety.controller;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.biosafety.domain.Health;
|
||||
import com.zhyc.module.biosafety.service.IImmunityService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -104,4 +105,15 @@ public class ImmunityController extends BaseController
|
||||
{
|
||||
return toAjax(immunityService.deleteImmunityByIds(ids));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('biosafety:immunity:list')")
|
||||
@GetMapping("/searchEarNumbers")
|
||||
public AjaxResult getSheepNoList(String sheepNo)
|
||||
{
|
||||
Immunity immunity = new Immunity();
|
||||
immunity.setSheepNo(sheepNo);
|
||||
List<String> list = immunityService.selectSheepNoList(immunity);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zhyc.module.biosafety.controller;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.biosafety.domain.Health;
|
||||
import com.zhyc.module.biosafety.domain.QuarantineReport;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -104,4 +105,15 @@ public class QuarantineReportController extends BaseController
|
||||
{
|
||||
return toAjax(quarantineReportService.deleteQuarantineReportByIds(ids));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('biosafety:quarantine:list')")
|
||||
@GetMapping("/searchEarNumbers")
|
||||
public AjaxResult getSheepNoList(String sheepNo)
|
||||
{
|
||||
QuarantineReport report = new QuarantineReport();
|
||||
report.setSheepNo(sheepNo);
|
||||
List<String> list = quarantineReportService.selectSheepNoList(report);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.biosafety.domain.Health;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
|
||||
import com.zhyc.module.biosafety.service.ISwMedicineUsageService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -110,4 +111,14 @@ public class SwMedicineUsageController extends BaseController
|
||||
{
|
||||
return toAjax(swMedicineUsageService.deleteSwMedicineUsageByIds(ids));
|
||||
}
|
||||
@PreAuthorize("@ss.hasPermi('biosafety:usageInfo:list')")
|
||||
@GetMapping("/searchEarNumbers")
|
||||
public AjaxResult getSheepNoList(String sheepNo)
|
||||
{
|
||||
SwMedicineUsage usage = new SwMedicineUsage();
|
||||
usage.setSheepNo(sheepNo);
|
||||
List<String> list = swMedicineUsageService.selectSheepNoList(usage);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zhyc.module.biosafety.controller;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.biosafety.domain.Health;
|
||||
import com.zhyc.module.biosafety.domain.Treatment;
|
||||
import com.zhyc.module.biosafety.service.ITreatmentService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -104,4 +105,15 @@ public class TreatmentController extends BaseController
|
||||
{
|
||||
return toAjax(treatmentService.deleteTreatmentByIds(ids));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('biosafety:treatment:list')")
|
||||
@GetMapping("/searchEarNumbers")
|
||||
public AjaxResult getSheepNoList(String sheepNo)
|
||||
{
|
||||
Treatment treatment = new Treatment();
|
||||
treatment.setSheepNo(sheepNo);
|
||||
List<String> list = treatmentService.selectSheepNoList(treatment);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface DewormMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDewormByIds(Long[] ids);
|
||||
|
||||
List<String> selectSheepNoList(Deworm deworm);
|
||||
}
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface DiagnosisMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDiagnosisByIds(Long[] ids);
|
||||
|
||||
List<String> selectSheepNoList(Diagnosis diagnosis);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zhyc.module.biosafety.mapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import com.zhyc.module.biosafety.domain.Disinfect;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -60,4 +61,6 @@ public interface DisinfectMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDisinfectByIds(Long[] ids);
|
||||
|
||||
List<Object[]> selectSheepfoldList(Disinfect disinfect);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface HealthMapper
|
||||
{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询保健
|
||||
*
|
||||
@@ -60,4 +63,6 @@ public interface HealthMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteHealthByIds(Long[] ids);
|
||||
|
||||
List<String> selectSheepNoList(Health health);
|
||||
}
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface ImmunityMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteImmunityByIds(Long[] ids);
|
||||
|
||||
List<String> selectSheepNoList(Immunity immunity);
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface QuarantineReportMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteQuarantineReportByIds(Long[] ids);
|
||||
|
||||
List<String> selectSheepNoList(QuarantineReport report);
|
||||
}
|
||||
|
||||
@@ -89,4 +89,6 @@ public interface SwMedicineUsageMapper
|
||||
public int deleteSwMedicineUsageDetailsByMediUsage(Integer id);
|
||||
|
||||
List<SwMedicineUsageDetails> selectSwMedicineUsageDetailsById(Integer id);
|
||||
|
||||
List<String> selectSheepNoList(SwMedicineUsage usage);
|
||||
}
|
||||
|
||||
@@ -66,4 +66,6 @@ public interface TreatmentMapper
|
||||
|
||||
|
||||
List<Treatment> selectTreatmentStatus(Long sheepId);
|
||||
|
||||
List<String> selectSheepNoList(Treatment treatment);
|
||||
}
|
||||
|
||||
@@ -59,4 +59,6 @@ public interface IDewormService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDewormById(Long id);
|
||||
|
||||
List<String> selectSheepNoList(Deworm deworm);
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface IDiagnosisService
|
||||
public int deleteDiagnosisById(Long id);
|
||||
|
||||
int insertDiagnosisList(Diagnosis diagnosis);
|
||||
|
||||
List<String> selectSheepNoList(Diagnosis diagnosis);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zhyc.module.biosafety.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.module.biosafety.domain.Disinfect;
|
||||
|
||||
/**
|
||||
@@ -58,4 +59,6 @@ public interface IDisinfectService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDisinfectById(Long id);
|
||||
|
||||
List<Object[]> selectSheepfoldList(Disinfect disinfect);
|
||||
}
|
||||
|
||||
@@ -58,4 +58,6 @@ public interface IHealthService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteHealthById(Long id);
|
||||
|
||||
List<String> selectSheepNoList(Health health);
|
||||
}
|
||||
|
||||
@@ -58,4 +58,6 @@ public interface IImmunityService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteImmunityById(Long id);
|
||||
|
||||
List<String> selectSheepNoList(Immunity immunity);
|
||||
}
|
||||
|
||||
@@ -59,4 +59,6 @@ public interface IQuarantineReportService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteQuarantineReportById(Long id);
|
||||
|
||||
List<String> selectSheepNoList(QuarantineReport report);
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface ISwMedicineUsageService
|
||||
public int deleteSwMedicineUsageById(Integer id);
|
||||
|
||||
List<SwMedicineUsageDetails> selectSwMedicineUsageDetailsById(Integer id);
|
||||
|
||||
List<String> selectSheepNoList(SwMedicineUsage usage);
|
||||
}
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface ITreatmentService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTreatmentById(Long id);
|
||||
|
||||
List<String> selectSheepNoList(Treatment treatment);
|
||||
}
|
||||
|
||||
@@ -172,4 +172,10 @@ public class DewormServiceImpl implements IDewormService
|
||||
{
|
||||
return dewormMapper.deleteDewormById(id);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
@Override
|
||||
public List<String> selectSheepNoList(Deworm deworm) {
|
||||
return dewormMapper.selectSheepNoList(deworm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.zhyc.module.base.domain.BasSheep;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.mapper.BasSheepMapper;
|
||||
import com.zhyc.module.base.mapper.SheepFileMapper;
|
||||
import com.zhyc.module.biosafety.domain.Deworm;
|
||||
import com.zhyc.module.biosafety.domain.Treatment;
|
||||
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
|
||||
import com.zhyc.module.biosafety.mapper.TreatmentMapper;
|
||||
@@ -220,4 +221,10 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
return diagnosisMapper.deleteDiagnosisById(id);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
@Override
|
||||
public List<String> selectSheepNoList(Diagnosis diagnosis) {
|
||||
return diagnosisMapper.selectSheepNoList(diagnosis);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -149,4 +149,10 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
{
|
||||
return disinfectMapper.deleteDisinfectById(id);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
@Override
|
||||
public List<Object[]> selectSheepfoldList(Disinfect disinfect) {
|
||||
return disinfectMapper.selectSheepfoldList(disinfect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.mapper.SheepFileMapper;
|
||||
import com.zhyc.module.biosafety.domain.Deworm;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsageDetails;
|
||||
import com.zhyc.module.biosafety.mapper.SwMedicineUsageMapper;
|
||||
@@ -165,4 +166,11 @@ public class HealthServiceImpl implements IHealthService
|
||||
{
|
||||
return healthMapper.deleteHealthById(id);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
@Override
|
||||
public List<String> selectSheepNoList(Health health) {
|
||||
return healthMapper.selectSheepNoList(health);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.mapper.SheepFileMapper;
|
||||
import com.zhyc.module.biosafety.domain.Deworm;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsageDetails;
|
||||
import com.zhyc.module.biosafety.mapper.SwMedicineUsageMapper;
|
||||
@@ -170,4 +171,10 @@ public class ImmunityServiceImpl implements IImmunityService
|
||||
{
|
||||
return immunityMapper.deleteImmunityById(id);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
@Override
|
||||
public List<String> selectSheepNoList(Immunity immunity) {
|
||||
return immunityMapper.selectSheepNoList(immunity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.service.impl.SheepFileServiceImpl;
|
||||
import com.zhyc.module.biosafety.domain.Immunity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.biosafety.mapper.QuarantineReportMapper;
|
||||
@@ -136,4 +137,10 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
|
||||
{
|
||||
return quarantineReportMapper.deleteQuarantineReportById(id);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
@Override
|
||||
public List<String> selectSheepNoList(QuarantineReport report) {
|
||||
return quarantineReportMapper.selectSheepNoList(report);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.module.biosafety.domain.Immunity;
|
||||
import com.zhyc.module.biosafety.service.ISwMedicineUsageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -152,4 +153,10 @@ public class SwMedicineUsageServiceImpl implements ISwMedicineUsageService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
@Override
|
||||
public List<String> selectSheepNoList(SwMedicineUsage usage) {
|
||||
return swMedicineUsageMapper.selectSheepNoList(usage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,12 @@ import com.zhyc.common.utils.bean.BeanUtils;
|
||||
import com.zhyc.module.Exception.BusinessException;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.mapper.SheepFileMapper;
|
||||
import com.zhyc.module.biosafety.domain.Diagnosis;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsageDetails;
|
||||
import com.zhyc.module.biosafety.domain.*;
|
||||
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
|
||||
import com.zhyc.module.biosafety.mapper.SwMedicineUsageMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.biosafety.mapper.TreatmentMapper;
|
||||
import com.zhyc.module.biosafety.domain.Treatment;
|
||||
import com.zhyc.module.biosafety.service.ITreatmentService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -243,6 +240,12 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
return treatmentMapper.deleteTreatmentById(id);
|
||||
}
|
||||
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
@Override
|
||||
public List<String> selectSheepNoList(Treatment treatment) {
|
||||
return treatmentMapper.selectSheepNoList(treatment);
|
||||
}
|
||||
|
||||
public void updateTreatmentStatus(Long sheepId) {
|
||||
List<Treatment> treatments=treatmentMapper.selectTreatmentStatus(sheepId);
|
||||
Diagnosis diagnosis = new Diagnosis();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.zhyc.module.frozen.service.impl;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
@@ -12,9 +11,6 @@ import com.zhyc.module.frozen.service.IDdFsService;
|
||||
import lombok.val;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import com.zhyc.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.zhyc.module.frozen.domain.DdSaleItem;
|
||||
@@ -184,15 +180,33 @@ public class DdSaleServiceImpl implements IDdSaleService {
|
||||
if (ddSaleItem.getItemType().equals("embryo")) {
|
||||
DdFe fe = new DdFe();
|
||||
fe.setCode(ddSaleItem.getItemCode());
|
||||
fe.setId(ddFeService.selectDdFeList(fe).get(0).getId());
|
||||
DdFe originFe = ddFeService.selectDdFeList(fe).get(0);
|
||||
fe.setId(originFe.getId());
|
||||
fe.setStatus(status);
|
||||
/*
|
||||
同时更新出库日期
|
||||
-1 : 更新为当前日期
|
||||
1 : 恢复为创建日期
|
||||
*/
|
||||
if (type == -1) {
|
||||
fe.setCreateTime(new Date());
|
||||
} else {
|
||||
fe.setUpdateTime(originFe.getCreateTime());
|
||||
}
|
||||
ddFeService.updateDdFe(fe);
|
||||
}
|
||||
if (ddSaleItem.getItemType().equals("semen")) {
|
||||
DdFs fs = new DdFs();
|
||||
fs.setCode(ddSaleItem.getItemCode());
|
||||
fs.setId(ddFsService.selectDdFsList(fs).get(0).getId());
|
||||
DdFs originFs = ddFsService.selectDdFsList(fs).get(0);
|
||||
fs.setId(originFs.getId());
|
||||
fs.setStat(status);
|
||||
// 同时更新出库日期
|
||||
if (type == -1) {
|
||||
fs.setOutDt(new Date());
|
||||
} else {
|
||||
fs.setOutDt(originFs.getCreateTime());
|
||||
}
|
||||
ddFsService.updateDdFs(fs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.produce.breed.domain.ScBreedPlanGenerate;
|
||||
import com.zhyc.module.produce.breed.service.IScBreedPlanGenerateService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -50,7 +51,7 @@ public class ScBreedPlanGenerateController extends BaseController
|
||||
@GetMapping("/selectEwe")
|
||||
public AjaxResult selectEligibleEwe(@RequestParam(value = "manageTags", required = false) String manageTags)
|
||||
{
|
||||
List<Map<String, Object>> eligibleEwe = scBreedPlanGenerateService.selectEligibleEwe(manageTags);
|
||||
List<Map<String, Object>> eligibleEwe = scBreedPlanGenerateService.selectEligibleEwe(new SheepFile(),manageTags);
|
||||
return success(eligibleEwe);
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ public class ScBreedPlanGenerateController extends BaseController
|
||||
@GetMapping("/selectRam")
|
||||
public AjaxResult selectEligibleRam(@RequestParam(value = "manageTags", required = false) String manageTags)
|
||||
{
|
||||
List<Map<String, Object>> eligibleRam = scBreedPlanGenerateService.selectEligibleRam(manageTags);
|
||||
List<Map<String, Object>> eligibleRam = scBreedPlanGenerateService.selectEligibleRam(new SheepFile(),manageTags);
|
||||
return success(eligibleRam);
|
||||
}
|
||||
|
||||
@@ -93,6 +94,12 @@ public class ScBreedPlanGenerateController extends BaseController
|
||||
: obj instanceof Long ? (Long) obj : Long.valueOf(obj.toString()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// eweIds 和 ramIds 均为空时,直接导出只含表头的空白模板,不查数据库(避免 IN () 语法错误)
|
||||
if (eweIds.isEmpty() && ramIds.isEmpty()) {
|
||||
scBreedPlanGenerateService.exportEmptyPairTemplate(response);
|
||||
return;
|
||||
}
|
||||
|
||||
scBreedPlanGenerateService.exportSelectedPairs(response, eweIds, ramIds);
|
||||
} catch (Exception e) {
|
||||
logger.error("导出配对表失败", e);
|
||||
|
||||
@@ -12,6 +12,7 @@ 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;
|
||||
@@ -154,9 +155,10 @@ public class ScBreedRecordController extends BaseController
|
||||
return error("技术员不能为空");
|
||||
}
|
||||
|
||||
// 修改后
|
||||
int result = scBreedRecordService.insertScBreedRecord(scBreedRecord);
|
||||
if (result > 0) {
|
||||
return success("配种记录新增成功");
|
||||
return success(scBreedRecord.getId()); // 返回自增主键ID
|
||||
}
|
||||
return error("配种记录新增失败");
|
||||
}
|
||||
@@ -230,10 +232,52 @@ public class ScBreedRecordController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据羊只ID和时间范围查询配种记录
|
||||
* 批量标记胚胎已移植,并同步更新冲胚记录的 transferred / recipient_cnt
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('Breeding_records:Breeding_records:edit')")
|
||||
@Log(title = "批量标记胚胎移植", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/markBatchEmbryoTransferred")
|
||||
public AjaxResult markBatchEmbryoTransferred(@RequestBody Map<String, Object> params)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Integer> idList = (List<Integer>) params.get("ids");
|
||||
Long breedRecordId = Long.valueOf(params.get("breedRecordId").toString());
|
||||
|
||||
if (idList == null || idList.isEmpty()) {
|
||||
return error("胚胎ID列表不能为空");
|
||||
}
|
||||
Long[] ids = idList.stream().map(Long::valueOf).toArray(Long[]::new);
|
||||
|
||||
int result = scBreedRecordService.markBatchEmbryoTransferred(ids, breedRecordId);
|
||||
if (result > 0) {
|
||||
return success("批量标记移植成功,共更新 " + result + " 条");
|
||||
}
|
||||
return error("批量标记失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索耳号(模糊查询,用于前端 autocomplete)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('Breeding_records:Breeding_records:query')")
|
||||
@GetMapping("/getByTimeRange/{sheepId}/{startDate}/{endDate}")
|
||||
@GetMapping("/searchEarNumbers")
|
||||
public AjaxResult searchEarNumbers(@RequestParam("query") String query,
|
||||
@RequestParam(value = "gender", required = false) String gender)
|
||||
{
|
||||
List<Map<String, Object>> result = scBreedRecordService.searchEarNumbers(query, gender);
|
||||
return success(result);
|
||||
}
|
||||
/**
|
||||
* 根据配种记录ID查询已移植的胚胎明细(查看胚胎弹窗使用)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('Breeding_records:Breeding_records:query')")
|
||||
@GetMapping("/embryosByBreedRecord/{breedRecordId}")
|
||||
public AjaxResult getEmbryosByBreedRecord(@PathVariable("breedRecordId") Long breedRecordId)
|
||||
{
|
||||
List<Map<String, Object>> list = scBreedRecordService.getEmbryosByBreedRecord(breedRecordId);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('Breeding_records:Breeding_records:query')")
|
||||
public AjaxResult getBreedRecordsByTimeRange(@PathVariable("sheepId") Long sheepId,
|
||||
@PathVariable("startDate") String startDate,
|
||||
@PathVariable("endDate") String endDate)
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.zhyc.module.produce.breed.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
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.ScEmbryoDetail;
|
||||
import com.zhyc.module.produce.breed.service.IScEmbryoDetailService;
|
||||
|
||||
/**
|
||||
* 胚胎明细记录 Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-11-28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/embryo/detail")
|
||||
public class ScEmbryoDetailController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IScEmbryoDetailService scEmbryoDetailService;
|
||||
|
||||
/**
|
||||
* 根据冲胚记录ID查询胚胎明细列表(含关联冲胚父记录字段)
|
||||
* 供冲胚记录编辑/查看时回显用
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('embryo:flush:query')")
|
||||
@GetMapping("/byFlush/{flushId}")
|
||||
public AjaxResult listByFlushId(@PathVariable("flushId") Long flushId) {
|
||||
return success(scEmbryoDetailService.selectByFlushId(flushId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询可供移植的胚胎明细
|
||||
* 供配种记录-胚胎移植 弹窗选择使用
|
||||
* @param flushId 可选,指定某条冲胚记录;不传则返回所有可移植胚胎
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('embryo:flush:query')")
|
||||
@GetMapping("/available")
|
||||
public AjaxResult listAvailable(@RequestParam(value = "flushId", required = false) Long flushId) {
|
||||
return success(scEmbryoDetailService.selectAvailableForTransfer(flushId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条胚胎明细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('embryo:flush:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(scEmbryoDetailService.selectScEmbryoDetailById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改单条胚胎明细(如修改去向、存储方式)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('embryo:flush:edit')")
|
||||
@Log(title = "胚胎明细", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ScEmbryoDetail scEmbryoDetail) {
|
||||
return toAjax(scEmbryoDetailService.updateScEmbryoDetail(scEmbryoDetail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将某枚胚胎标记为已移植,并关联配种记录ID
|
||||
* 在配种记录新增-胚胎移植 提交成功后调用
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('Breeding_records:Breeding_records:edit')")
|
||||
@Log(title = "胚胎移植标记", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/markTransferred")
|
||||
public AjaxResult markTransferred(@RequestParam("id") Long id,
|
||||
@RequestParam("breedRecordId") Long breedRecordId) {
|
||||
int result = scEmbryoDetailService.markAsTransferred(id, breedRecordId);
|
||||
if (result > 0) {
|
||||
return success("移植标记成功");
|
||||
}
|
||||
return error("移植标记失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除胚胎明细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('embryo:flush:remove')")
|
||||
@Log(title = "胚胎明细", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(scEmbryoDetailService.deleteScEmbryoDetailByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.zhyc.module.produce.breed.controller;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.produce.breed.service.impl.ScEmbryoFlushServiceImpl;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -154,10 +156,11 @@ public class ScEmbryoFlushController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('embryo:flush:query')")
|
||||
@GetMapping("/calculateVariety")
|
||||
public AjaxResult calculateVariety(@RequestParam("maleVariety") String maleVariety,
|
||||
@RequestParam("femaleVariety") String femaleVariety) {
|
||||
String result = scEmbryoFlushService.calculateEmbryoVariety(maleVariety, femaleVariety);
|
||||
public AjaxResult calculateVariety(String maleVariety, String femaleVariety) {
|
||||
// ✅ 通过注入的 service 调用
|
||||
String result = scEmbryoFlushService.calculateEmbryoVarietyByName(maleVariety, femaleVariety);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.zhyc.module.produce.breed.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 胚胎明细记录 sc_embryo_detail
|
||||
* 每次冲胚中每枚胚胎单独一条记录
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-11-28
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ScEmbryoDetail extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 所属冲胚记录ID */
|
||||
private Long flushId;
|
||||
|
||||
/** 胚胎序号(同批次内从1递增) */
|
||||
private Integer embryoNo;
|
||||
|
||||
/**
|
||||
* 胚胎等级:A / B / C / 16细胞 / 未受精 / 退化
|
||||
*/
|
||||
@Excel(name = "胚胎等级")
|
||||
private String embryoGrade;
|
||||
|
||||
/**
|
||||
* 去向:移植 / 遗弃 / 冷冻保存
|
||||
*/
|
||||
@Excel(name = "去向")
|
||||
private String destination;
|
||||
|
||||
/** 存储方式 */
|
||||
@Excel(name = "存储方式")
|
||||
private String storageMethod;
|
||||
|
||||
/** 胚胎品种(继承自父冲胚记录) */
|
||||
@Excel(name = "胚胎品种")
|
||||
private String embryoVariety;
|
||||
|
||||
/** 关联配种记录ID(移植后回填) */
|
||||
private Long breedRecordId;
|
||||
|
||||
/**
|
||||
* 是否已移植:0-否 1-是
|
||||
*/
|
||||
private Integer isTransferred;
|
||||
|
||||
/** 部门ID(数据权限) */
|
||||
private Long deptId;
|
||||
|
||||
/** 创建人ID */
|
||||
private Long userId;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
|
||||
private Date createdAt;
|
||||
|
||||
// ---- 查询时关联冲胚记录的冗余字段(非数据库列)----
|
||||
|
||||
/** 冲胚时间(从父记录关联展示) */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "Asia/Shanghai")
|
||||
private Date flushTime;
|
||||
|
||||
/** 供体母羊耳号(从父记录关联展示) */
|
||||
private String donorFemaleNo;
|
||||
|
||||
/** 供体公羊耳号(从父记录关联展示) */
|
||||
private String donorMaleNo;
|
||||
|
||||
/** 供体公羊品种(从父记录关联展示) */
|
||||
private String donorMaleVariety;
|
||||
|
||||
/** 供体母羊品种(从父记录关联展示) */
|
||||
private String donorFemaleVariety;
|
||||
|
||||
/** 胎龄(从父记录关联展示) */
|
||||
private Integer embryoAge;
|
||||
|
||||
/** 胚胎类型(从父记录关联展示) */
|
||||
private String embryoType;
|
||||
|
||||
/** 胚胎来源(从父记录关联展示) */
|
||||
private String embryoSource;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zhyc.module.produce.breed.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
@@ -8,13 +9,16 @@ import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 冲胚记录-用户录入对象 sc_embryo_flush
|
||||
* 冲胚记录 sc_embryo_flush
|
||||
* 变更说明(v2):
|
||||
* - 新增 embryoDetails 字段(非数据库列),用于前端一次性提交整批胚胎明细
|
||||
* - transferred / recipientCnt 不再由前端直接填写,改为由胚胎明细同步计算
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-11-28
|
||||
*/
|
||||
public class ScEmbryoFlush extends BaseEntity
|
||||
{
|
||||
public class ScEmbryoFlush extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@@ -49,11 +53,15 @@ public class ScEmbryoFlush extends BaseEntity
|
||||
@Excel(name = "胎龄(天)")
|
||||
private Integer embryoAge;
|
||||
|
||||
// ===== 胚胎等级数量(聚合值,从 embryoDetails 计算得出,存入数据库供查询展示) =====
|
||||
/** A+级胚胎数 */
|
||||
@Excel(name = "A+级")
|
||||
private Integer gradeAPlus;
|
||||
|
||||
/** A级胚胎数 */
|
||||
public void setGradeAPlus(Integer gradeAPlus) { this.gradeAPlus = gradeAPlus; }
|
||||
public Integer getGradeAPlus() { return gradeAPlus; }
|
||||
|
||||
/** A级胚胎数(原 grade_a,A+合并入A;前端不再有A+) */
|
||||
@Excel(name = "A级")
|
||||
private Integer gradeA;
|
||||
|
||||
@@ -64,20 +72,18 @@ public class ScEmbryoFlush extends BaseEntity
|
||||
/** C级胚胎数 */
|
||||
@Excel(name = "C级")
|
||||
private Integer gradeC;
|
||||
|
||||
/** D级胚胎数 */
|
||||
@Excel(name = "D级")
|
||||
private Integer gradeD;
|
||||
|
||||
/** 2/4细胞期 */
|
||||
@Excel(name = "2/4细胞")
|
||||
private Integer cell24;
|
||||
|
||||
/** 8细胞期 */
|
||||
public void setCell24(Integer cell24) { this.cell24 = cell24; }
|
||||
public Integer getCell24() { return cell24; }
|
||||
|
||||
@Excel(name = "8细胞")
|
||||
private Integer cell8;
|
||||
|
||||
/** 16细胞期 */
|
||||
public void setCell8(Integer cell8) { this.cell8 = cell8; }
|
||||
public Integer getCell8() { return cell8; }
|
||||
/** 16细胞期(原 grade_d) */
|
||||
@Excel(name = "16细胞")
|
||||
private Integer cell16;
|
||||
|
||||
@@ -93,18 +99,36 @@ public class ScEmbryoFlush extends BaseEntity
|
||||
@Excel(name = "冲胚数")
|
||||
private Integer totalEmbryo;
|
||||
|
||||
/** 有效胚(A+到D级总和) */
|
||||
/** 有效胚(A+B+C+16细胞总和) */
|
||||
@Excel(name = "有效胚")
|
||||
private Integer validEmbryo;
|
||||
|
||||
/** 移胚数 */
|
||||
/**
|
||||
* 移胚数(只读,由 sc_embryo_detail 中已移植的明细数量同步,不可前端直接填写)
|
||||
*/
|
||||
@Excel(name = "移胚数")
|
||||
private Integer transferred;
|
||||
|
||||
/** 移植受体数 */
|
||||
/**
|
||||
* 移植受体数(只读,由 sc_embryo_detail 中不同 breed_record_id 数量同步,不可前端直接填写)
|
||||
*/
|
||||
@Excel(name = "移植受体数")
|
||||
private Integer recipientCnt;
|
||||
|
||||
/** 鲜胚受体数(只读,子查询计算,不持久化到主表) */
|
||||
@Excel(name = "鲜胚受体数")
|
||||
private Integer freshRecipientCnt;
|
||||
|
||||
/** 冻胚受体数(只读,子查询计算,不持久化到主表) */
|
||||
@Excel(name = "冻胚受体数")
|
||||
private Integer frozenRecipientCnt;
|
||||
|
||||
public void setFreshRecipientCnt(Integer v) { this.freshRecipientCnt = v; }
|
||||
public Integer getFreshRecipientCnt() { return freshRecipientCnt; }
|
||||
|
||||
public void setFrozenRecipientCnt(Integer v) { this.frozenRecipientCnt = v; }
|
||||
public Integer getFrozenRecipientCnt() { return frozenRecipientCnt; }
|
||||
|
||||
/** 胚胎类型 */
|
||||
@Excel(name = "胚胎类型")
|
||||
private String embryoType;
|
||||
@@ -113,14 +137,6 @@ public class ScEmbryoFlush extends BaseEntity
|
||||
@Excel(name = "胚胎来源")
|
||||
private String embryoSource;
|
||||
|
||||
/** 去向 */
|
||||
@Excel(name = "去向")
|
||||
private String destination;
|
||||
|
||||
/** 存储方式 */
|
||||
@Excel(name = "存储方式")
|
||||
private String storageMethod;
|
||||
|
||||
/** 冲胚人 */
|
||||
@Excel(name = "冲胚人")
|
||||
private String flushOperator;
|
||||
@@ -136,6 +152,17 @@ public class ScEmbryoFlush extends BaseEntity
|
||||
@Excel(name = "所在牧场")
|
||||
private String ranchName;
|
||||
|
||||
/** 去向(来自关联胚胎明细) */
|
||||
private String destination;
|
||||
|
||||
public void setDestination(String destination) { this.destination = destination; }
|
||||
public String getDestination() { return destination; }
|
||||
|
||||
/** 存储方式 */
|
||||
private String storageMethod;
|
||||
public void setStorageMethod(String storageMethod) { this.storageMethod = storageMethod; }
|
||||
public String getStorageMethod() { return storageMethod; }
|
||||
|
||||
/** 创建人 */
|
||||
private String createdBy;
|
||||
|
||||
@@ -146,378 +173,112 @@ public class ScEmbryoFlush extends BaseEntity
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdAt;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* 胚胎明细列表(非数据库列,仅用于前端一次性提交整批胚胎明细)
|
||||
* 在 Service 层插入冲胚记录后,遍历此列表批量插入 sc_embryo_detail
|
||||
*/
|
||||
private List<ScEmbryoDetail> embryoDetails;
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
// ===================== Getter / Setter =====================
|
||||
|
||||
public void setFlushTime(Date flushTime)
|
||||
{
|
||||
this.flushTime = flushTime;
|
||||
}
|
||||
public void setId(Long id) { this.id = id; }
|
||||
public Long getId() { return id; }
|
||||
|
||||
public Date getFlushTime()
|
||||
{
|
||||
return flushTime;
|
||||
}
|
||||
public void setFlushTime(Date flushTime) { this.flushTime = flushTime; }
|
||||
public Date getFlushTime() { return flushTime; }
|
||||
|
||||
public void setDonorFemaleNo(String donorFemaleNo)
|
||||
{
|
||||
this.donorFemaleNo = donorFemaleNo;
|
||||
}
|
||||
public void setDonorFemaleNo(String donorFemaleNo) { this.donorFemaleNo = donorFemaleNo; }
|
||||
public String getDonorFemaleNo() { return donorFemaleNo; }
|
||||
|
||||
public String getDonorFemaleNo()
|
||||
{
|
||||
return donorFemaleNo;
|
||||
}
|
||||
public void setDonorFemaleVariety(String donorFemaleVariety) { this.donorFemaleVariety = donorFemaleVariety; }
|
||||
public String getDonorFemaleVariety() { return donorFemaleVariety; }
|
||||
|
||||
public void setDonorFemaleVariety(String donorFemaleVariety)
|
||||
{
|
||||
this.donorFemaleVariety = donorFemaleVariety;
|
||||
}
|
||||
public void setDonorMaleNo(String donorMaleNo) { this.donorMaleNo = donorMaleNo; }
|
||||
public String getDonorMaleNo() { return donorMaleNo; }
|
||||
|
||||
public String getDonorFemaleVariety()
|
||||
{
|
||||
return donorFemaleVariety;
|
||||
}
|
||||
public void setDonorMaleVariety(String donorMaleVariety) { this.donorMaleVariety = donorMaleVariety; }
|
||||
public String getDonorMaleVariety() { return donorMaleVariety; }
|
||||
|
||||
public void setDonorMaleNo(String donorMaleNo)
|
||||
{
|
||||
this.donorMaleNo = donorMaleNo;
|
||||
}
|
||||
public void setEmbryoVariety(String embryoVariety) { this.embryoVariety = embryoVariety; }
|
||||
public String getEmbryoVariety() { return embryoVariety; }
|
||||
|
||||
public String getDonorMaleNo()
|
||||
{
|
||||
return donorMaleNo;
|
||||
}
|
||||
public void setEmbryoAge(Integer embryoAge) { this.embryoAge = embryoAge; }
|
||||
public Integer getEmbryoAge() { return embryoAge; }
|
||||
|
||||
public void setDonorMaleVariety(String donorMaleVariety)
|
||||
{
|
||||
this.donorMaleVariety = donorMaleVariety;
|
||||
}
|
||||
public void setGradeA(Integer gradeA) { this.gradeA = gradeA; }
|
||||
public Integer getGradeA() { return gradeA; }
|
||||
|
||||
public String getDonorMaleVariety()
|
||||
{
|
||||
return donorMaleVariety;
|
||||
}
|
||||
public void setGradeB(Integer gradeB) { this.gradeB = gradeB; }
|
||||
public Integer getGradeB() { return gradeB; }
|
||||
|
||||
public void setEmbryoVariety(String embryoVariety)
|
||||
{
|
||||
this.embryoVariety = embryoVariety;
|
||||
}
|
||||
public void setGradeC(Integer gradeC) { this.gradeC = gradeC; }
|
||||
public Integer getGradeC() { return gradeC; }
|
||||
|
||||
public String getEmbryoVariety()
|
||||
{
|
||||
return embryoVariety;
|
||||
}
|
||||
public void setGradeD(Integer gradeD) { this.cell16 = gradeD; }
|
||||
public Integer getGradeD() { return cell16; }
|
||||
|
||||
public void setEmbryoAge(Integer embryoAge)
|
||||
{
|
||||
this.embryoAge = embryoAge;
|
||||
}
|
||||
public void setUnfertilized(Integer unfertilized) { this.unfertilized = unfertilized; }
|
||||
public Integer getUnfertilized() { return unfertilized; }
|
||||
|
||||
public Integer getEmbryoAge()
|
||||
{
|
||||
return embryoAge;
|
||||
}
|
||||
public void setDegenerated(Integer degenerated) { this.degenerated = degenerated; }
|
||||
public Integer getDegenerated() { return degenerated; }
|
||||
|
||||
public void setGradeAPlus(Integer gradeAPlus)
|
||||
{
|
||||
this.gradeAPlus = gradeAPlus;
|
||||
}
|
||||
public void setTotalEmbryo(Integer totalEmbryo) { this.totalEmbryo = totalEmbryo; }
|
||||
public Integer getTotalEmbryo() { return totalEmbryo; }
|
||||
|
||||
public Integer getGradeAPlus()
|
||||
{
|
||||
return gradeAPlus;
|
||||
}
|
||||
public void setValidEmbryo(Integer validEmbryo) { this.validEmbryo = validEmbryo; }
|
||||
public Integer getValidEmbryo() { return validEmbryo; }
|
||||
|
||||
public void setGradeA(Integer gradeA)
|
||||
{
|
||||
this.gradeA = gradeA;
|
||||
}
|
||||
public void setTransferred(Integer transferred) { this.transferred = transferred; }
|
||||
public Integer getTransferred() { return transferred; }
|
||||
|
||||
public Integer getGradeA()
|
||||
{
|
||||
return gradeA;
|
||||
}
|
||||
public void setRecipientCnt(Integer recipientCnt) { this.recipientCnt = recipientCnt; }
|
||||
public Integer getRecipientCnt() { return recipientCnt; }
|
||||
|
||||
public void setGradeB(Integer gradeB)
|
||||
{
|
||||
this.gradeB = gradeB;
|
||||
}
|
||||
public void setEmbryoType(String embryoType) { this.embryoType = embryoType; }
|
||||
public String getEmbryoType() { return embryoType; }
|
||||
|
||||
public Integer getGradeB()
|
||||
{
|
||||
return gradeB;
|
||||
}
|
||||
public void setEmbryoSource(String embryoSource) { this.embryoSource = embryoSource; }
|
||||
public String getEmbryoSource() { return embryoSource; }
|
||||
|
||||
public void setGradeC(Integer gradeC)
|
||||
{
|
||||
this.gradeC = gradeC;
|
||||
}
|
||||
public void setFlushOperator(String flushOperator) { this.flushOperator = flushOperator; }
|
||||
public String getFlushOperator() { return flushOperator; }
|
||||
|
||||
public Integer getGradeC()
|
||||
{
|
||||
return gradeC;
|
||||
}
|
||||
public void setCollectOperator(String collectOperator) { this.collectOperator = collectOperator; }
|
||||
public String getCollectOperator() { return collectOperator; }
|
||||
|
||||
public void setGradeD(Integer gradeD)
|
||||
{
|
||||
this.gradeD = gradeD;
|
||||
}
|
||||
public void setRanchId(Long ranchId) { this.ranchId = ranchId; }
|
||||
public Long getRanchId() { return ranchId; }
|
||||
|
||||
public Integer getGradeD()
|
||||
{
|
||||
return gradeD;
|
||||
}
|
||||
public void setRanchName(String ranchName) { this.ranchName = ranchName; }
|
||||
public String getRanchName() { return ranchName; }
|
||||
|
||||
public void setCell24(Integer cell24)
|
||||
{
|
||||
this.cell24 = cell24;
|
||||
}
|
||||
public void setCreatedBy(String createdBy) { this.createdBy = createdBy; }
|
||||
public String getCreatedBy() { return createdBy; }
|
||||
|
||||
public Integer getCell24()
|
||||
{
|
||||
return cell24;
|
||||
}
|
||||
public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; }
|
||||
public Date getCreatedAt() { return createdAt; }
|
||||
|
||||
public void setCell8(Integer cell8)
|
||||
{
|
||||
this.cell8 = cell8;
|
||||
}
|
||||
public Long getUserId() { return userId; }
|
||||
public void setUserId(Long userId) { this.userId = userId; }
|
||||
|
||||
public Integer getCell8()
|
||||
{
|
||||
return cell8;
|
||||
}
|
||||
public Long getDeptId() { return deptId; }
|
||||
public void setDeptId(Long deptId) { this.deptId = deptId; }
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
public List<ScEmbryoDetail> getEmbryoDetails() { return embryoDetails; }
|
||||
public void setEmbryoDetails(List<ScEmbryoDetail> embryoDetails) { this.embryoDetails = embryoDetails; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.zhyc.module.produce.breed.mapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.zhyc.module.produce.breed.domain.ScBreedPlanGenerate;
|
||||
@@ -38,14 +39,14 @@ public interface ScBreedPlanGenerateMapper
|
||||
*
|
||||
* @return 符合条件的母羊列表
|
||||
*/
|
||||
public List<Map<String, Object>> selectEligibleEwe();
|
||||
public List<Map<String, Object>> selectEligibleEwe(SheepFile sheepFile);
|
||||
|
||||
/**
|
||||
* 筛选符合条件的公羊
|
||||
*
|
||||
* @return 符合条件的公羊列表
|
||||
*/
|
||||
public List<Map<String, Object>> selectEligibleRam();
|
||||
public List<Map<String, Object>> selectEligibleRam(SheepFile sheepFile);
|
||||
|
||||
/**
|
||||
* 新增配种计划生成
|
||||
|
||||
@@ -148,9 +148,47 @@ public interface ScBreedRecordMapper
|
||||
|
||||
/**
|
||||
* 根据受体(母羊)耳号查询最新的冲胚记录信息
|
||||
* 用于胚胎移植时自动填充供体和移胚数
|
||||
* @param manageTags 受体母羊耳号
|
||||
* @return 冲胚记录Map
|
||||
*/
|
||||
public Map<String, Object> getFlushRecordByEweNo(@Param("manageTags") String manageTags);
|
||||
|
||||
/**
|
||||
* 模糊搜索耳号列表(用于 autocomplete)
|
||||
*
|
||||
* @param query 耳号关键字
|
||||
* @param gender 性别过滤:1=母羊 2=公羊 null=不限
|
||||
* @return 耳号+品种列表
|
||||
*/
|
||||
List<Map<String, Object>> searchEarNumbers(@Param("query") String query,
|
||||
@Param("gender") Integer gender);
|
||||
|
||||
/**
|
||||
* 批量标记胚胎明细为已移植,并关联配种记录ID
|
||||
*
|
||||
* @param embryoDetailIds 胚胎明细ID数组
|
||||
* @param breedRecordId 配种记录ID
|
||||
* @return 更新行数
|
||||
*/
|
||||
int markBatchEmbryoDetailTransferred(@Param("embryoDetailIds") Long[] embryoDetailIds,
|
||||
@Param("breedRecordId") Long breedRecordId);
|
||||
|
||||
/**
|
||||
* 根据胚胎明细ID数组,查询其所属的去重 flush_id 列表
|
||||
*
|
||||
* @param embryoDetailIds 胚胎明细ID数组
|
||||
* @return flush_id 列表
|
||||
*/
|
||||
List<Long> selectFlushIdsByEmbryoDetailIds(Long[] embryoDetailIds);
|
||||
|
||||
/**
|
||||
* 同步更新冲胚记录的 transferred / recipient_cnt 统计字段
|
||||
*
|
||||
* @param flushId 冲胚记录ID
|
||||
* @return 更新行数
|
||||
*/
|
||||
int syncFlushTransferredStats(@Param("flushId") Long flushId);
|
||||
|
||||
/**
|
||||
* 根据配种记录ID查询已移植的胚胎明细
|
||||
*/
|
||||
List<Map<String, Object>> selectEmbryoDetailsByBreedRecordId(@Param("breedRecordId") Long breedRecordId);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.zhyc.module.produce.breed.mapper;
|
||||
|
||||
import com.zhyc.module.produce.breed.domain.ScEmbryoDetail;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 胚胎明细记录 Mapper 接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-11-28
|
||||
*/
|
||||
public interface ScEmbryoDetailMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询胚胎明细
|
||||
*/
|
||||
ScEmbryoDetail selectScEmbryoDetailById(Long id);
|
||||
|
||||
/**
|
||||
* 根据冲胚记录ID查询胚胎明细列表(关联冲胚记录基础信息)
|
||||
*/
|
||||
List<ScEmbryoDetail> selectByFlushId(Long flushId);
|
||||
|
||||
/**
|
||||
* 查询指定冲胚记录下指定去向的胚胎明细
|
||||
* 用于在配种记录新增-胚胎移植 中弹窗展示"可移植胚胎"
|
||||
* @param flushId 冲胚记录ID(为null时不过滤)
|
||||
* @param destination 去向过滤(如"移植"),为null时不过滤
|
||||
*/
|
||||
List<ScEmbryoDetail> selectByFlushIdAndDestination(@Param("flushId") Long flushId, @Param("destination") String destination);
|
||||
|
||||
/**
|
||||
* 新增胚胎明细(单条)
|
||||
*/
|
||||
int insertScEmbryoDetail(ScEmbryoDetail scEmbryoDetail);
|
||||
|
||||
/**
|
||||
* 批量新增胚胎明细
|
||||
*/
|
||||
int insertBatch(List<ScEmbryoDetail> list);
|
||||
|
||||
/**
|
||||
* 修改胚胎明细
|
||||
*/
|
||||
int updateScEmbryoDetail(ScEmbryoDetail scEmbryoDetail);
|
||||
|
||||
/**
|
||||
* 回填配种记录ID,并将 is_transferred 置为1
|
||||
* 在配种记录使用某枚胚胎时调用
|
||||
*/
|
||||
int markAsTransferred(@Param("id") Long id, @Param("breedRecordId") Long breedRecordId);
|
||||
|
||||
/**
|
||||
* 根据冲胚记录ID删除全部明细(更新冲胚记录时重建)
|
||||
*/
|
||||
int deleteByFlushId(Long flushId);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
int deleteScEmbryoDetailByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 统计某条冲胚记录中已移植的胚胎数
|
||||
*/
|
||||
int countTransferredByFlushId(Long flushId);
|
||||
|
||||
/**
|
||||
* 统计某条冲胚记录中独立受体(breedRecordId 去重)数量
|
||||
*/
|
||||
int countRecipientsByFlushId(Long flushId);
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.zhyc.module.produce.breed.service;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.produce.breed.domain.ScBreedPlanGenerate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -37,14 +39,14 @@ public interface IScBreedPlanGenerateService
|
||||
*
|
||||
* @return 符合条件的母羊列表
|
||||
*/
|
||||
public List<Map<String, Object>> selectEligibleEwe(@RequestParam(value = "manageTags", required = false) String manageTags);
|
||||
public List<Map<String, Object>> selectEligibleEwe(SheepFile sheepFile, @RequestParam(value = "manageTags", required = false) String manageTags);
|
||||
|
||||
/**
|
||||
* 筛选符合条件的公羊
|
||||
*
|
||||
* @return 符合条件的公羊列表
|
||||
*/
|
||||
public List<Map<String, Object>> selectEligibleRam(@RequestParam(value = "manageTags", required = false) String manageTags);
|
||||
public List<Map<String, Object>> selectEligibleRam(SheepFile sheepFile, @RequestParam(value = "manageTags", required = false) String manageTags);
|
||||
|
||||
void exportSelectedPairs(HttpServletResponse response, List<Long> eweIds, List<Long> ramIds);
|
||||
|
||||
@@ -138,4 +140,6 @@ public interface IScBreedPlanGenerateService
|
||||
* @return 耳号列表
|
||||
*/
|
||||
public List<String> searchEarNumbers(String query);
|
||||
|
||||
void exportEmptyPairTemplate(HttpServletResponse response);
|
||||
}
|
||||
@@ -121,4 +121,30 @@ public interface IScBreedRecordService
|
||||
public List<ScBreedRecord> getBreedRecordsByTimeRange(Long sheepId, String startDate, String endDate);
|
||||
|
||||
ScBreedRecord getAutomaticBreedMatch(String manageTags);
|
||||
|
||||
/**
|
||||
* 批量标记胚胎已移植,并同步更新冲胚记录统计字段
|
||||
*
|
||||
* @param embryoDetailIds 胚胎明细ID数组
|
||||
* @param breedRecordId 关联的配种记录ID
|
||||
* @return 更新行数
|
||||
*/
|
||||
int markBatchEmbryoTransferred(Long[] embryoDetailIds, Long breedRecordId);
|
||||
|
||||
/**
|
||||
* 模糊搜索耳号(用于前端 autocomplete)
|
||||
*
|
||||
* @param query 关键字
|
||||
* @param gender ewe=母羊 ram=公羊 null=不限
|
||||
* @return 耳号+品种列表
|
||||
*/
|
||||
List<Map<String, Object>> searchEarNumbers(String query, String gender);
|
||||
|
||||
/**
|
||||
* 根据配种记录ID查询已移植的胚胎明细
|
||||
*
|
||||
* @param breedRecordId 配种记录ID
|
||||
* @return 胚胎明细列表
|
||||
*/
|
||||
List<Map<String, Object>> getEmbryosByBreedRecord(Long breedRecordId);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.zhyc.module.produce.breed.service;
|
||||
|
||||
import com.zhyc.module.produce.breed.domain.ScEmbryoDetail;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 胚胎明细记录 Service 接口
|
||||
*/
|
||||
public interface IScEmbryoDetailService {
|
||||
|
||||
ScEmbryoDetail selectScEmbryoDetailById(Long id);
|
||||
|
||||
/** 查询某条冲胚记录下的所有胚胎明细(含关联父记录字段) */
|
||||
List<ScEmbryoDetail> selectByFlushId(Long flushId);
|
||||
|
||||
/**
|
||||
* 查询可选择的胚胎明细(未移植 + 去向=移植)用于配种记录-胚胎移植 弹窗
|
||||
* @param flushId 为null时返回所有冲胚记录的可移植胚胎
|
||||
*/
|
||||
List<ScEmbryoDetail> selectAvailableForTransfer(Long flushId);
|
||||
|
||||
/** 批量保存胚胎明细(新增/更新冲胚记录时调用) */
|
||||
int saveDetails(Long flushId, List<ScEmbryoDetail> details, Long deptId, Long userId);
|
||||
|
||||
int updateScEmbryoDetail(ScEmbryoDetail scEmbryoDetail);
|
||||
|
||||
/** 将指定胚胎标记为已移植并关联配种记录ID */
|
||||
int markAsTransferred(Long id, Long breedRecordId);
|
||||
|
||||
int deleteByFlushId(Long flushId);
|
||||
|
||||
int deleteScEmbryoDetailByIds(Long[] ids);
|
||||
|
||||
/** 获取某冲胚记录已移植数量(用于同步更新 sc_embryo_flush.transferred) */
|
||||
int countTransferred(Long flushId);
|
||||
|
||||
/** 获取某冲胚记录受体数(breed_record_id 去重) */
|
||||
int countRecipients(Long flushId);
|
||||
}
|
||||
@@ -92,4 +92,9 @@ public interface IScEmbryoFlushService
|
||||
public List<Map<String, Object>> selectDonorMaleList();
|
||||
|
||||
public Map<String, Object> getSheepInfoByTag(String manageTag);
|
||||
|
||||
/**
|
||||
* 根据品种名称计算胚胎品种
|
||||
*/
|
||||
String calculateEmbryoVarietyByName(String maleVarietyName, String femaleVarietyName);
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.produce.breed.domain.ScBreedPlan;
|
||||
import com.zhyc.module.produce.breed.domain.ScBreedPlanGenerate;
|
||||
import com.zhyc.module.produce.breed.mapper.ScBreedPlanGenerateMapper;
|
||||
@@ -65,21 +62,28 @@ public class ScBreedPlanGenerateServiceImpl implements IScBreedPlanGenerateServi
|
||||
/**
|
||||
* 筛选符合条件的母羊
|
||||
*/
|
||||
@DataScope(deptAlias = "bs", userAlias = "bs")
|
||||
@Override
|
||||
public List<Map<String, Object>> selectEligibleEwe(@RequestParam(value = "manageTags", required = false) String manageTags)
|
||||
public List<Map<String, Object>> selectEligibleEwe(SheepFile sheepFile, @RequestParam(value = "manageTags", required = false) String manageTags)
|
||||
{
|
||||
return scBreedPlanGenerateMapper.selectEligibleEwe();
|
||||
return scBreedPlanGenerateMapper.selectEligibleEwe(sheepFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选符合条件的公羊
|
||||
*/
|
||||
@DataScope(deptAlias = "bs", userAlias = "bs")
|
||||
@Override
|
||||
public List<Map<String, Object>> selectEligibleRam(@RequestParam(value = "manageTags", required = false) String manageTags)
|
||||
public List<Map<String, Object>> selectEligibleRam(SheepFile sheepFile,@RequestParam(value = "manageTags", required = false) String manageTags)
|
||||
{
|
||||
return scBreedPlanGenerateMapper.selectEligibleRam();
|
||||
return scBreedPlanGenerateMapper.selectEligibleRam(sheepFile);
|
||||
}
|
||||
|
||||
public void exportEmptyPairTemplate(HttpServletResponse response) {
|
||||
// 和 exportSelectedPairs 传空 List 一样的逻辑,
|
||||
// 只写表头行,不写数据行
|
||||
exportSelectedPairs(response, Collections.emptyList(), Collections.emptyList());
|
||||
}
|
||||
/**
|
||||
* 导出已选母羊公羊配对表
|
||||
* 按轮询方式将母羊分配给公羊,导出Excel,两列:母羊耳号、公羊耳号
|
||||
@@ -92,19 +96,23 @@ public class ScBreedPlanGenerateServiceImpl implements IScBreedPlanGenerateServi
|
||||
public void exportSelectedPairs(HttpServletResponse response, List<Long> eweIds, List<Long> ramIds)
|
||||
{
|
||||
try {
|
||||
// 查询母羊耳号(gender=1)
|
||||
List<Map<String, Object>> eweList = scBreedPlanGenerateMapper.selectEarNumbersByIds(eweIds, 1);
|
||||
// 查询公羊耳号(gender=2)
|
||||
List<Map<String, Object>> ramList = scBreedPlanGenerateMapper.selectEarNumbersByIds(ramIds, 2);
|
||||
|
||||
// 建立ID->耳号 的快速查找
|
||||
// ✅ 修复代码:检查后再查询
|
||||
Map<Long, String> eweEarMap = new HashMap<>();
|
||||
for (Map<String, Object> e : eweList) {
|
||||
eweEarMap.put(Long.valueOf(e.get("id").toString()), e.get("manage_tags").toString());
|
||||
}
|
||||
Map<Long, String> ramEarMap = new HashMap<>();
|
||||
for (Map<String, Object> r : ramList) {
|
||||
ramEarMap.put(Long.valueOf(r.get("id").toString()), r.get("manage_tags").toString());
|
||||
|
||||
if (!eweIds.isEmpty()) {
|
||||
List<Map<String, Object>> eweList = scBreedPlanGenerateMapper.selectEarNumbersByIds(eweIds, 1);
|
||||
for (Map<String, Object> e : eweList) {
|
||||
eweEarMap.put(Long.valueOf(e.get("id").toString()), e.get("manage_tags").toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (!ramIds.isEmpty()) {
|
||||
List<Map<String, Object>> ramList = scBreedPlanGenerateMapper.selectEarNumbersByIds(ramIds, 2);
|
||||
for (Map<String, Object> r : ramList) {
|
||||
ramEarMap.put(Long.valueOf(r.get("id").toString()), r.get("manage_tags").toString());
|
||||
}
|
||||
}
|
||||
|
||||
// 母羊列、公羊列各自独立写入,行数取两者最大值,不做轮询配对
|
||||
@@ -166,10 +174,10 @@ public class ScBreedPlanGenerateServiceImpl implements IScBreedPlanGenerateServi
|
||||
sheet.setColumnWidth(1, 5000);
|
||||
|
||||
// 响应头
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String fileName = java.net.URLEncoder.encode("配种配对表", "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
String fileName = "配种配对表.xlsx";
|
||||
response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
|
||||
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
@@ -453,7 +461,7 @@ public class ScBreedPlanGenerateServiceImpl implements IScBreedPlanGenerateServi
|
||||
result.put("planInfo", planGenerate);
|
||||
List<Map<String, Object>> planDetails = scBreedPlanGenerateMapper.selectApproveBreedPlanDetails(id);
|
||||
result.put("planDetails", planDetails);
|
||||
List<Map<String, Object>> availableRams = scBreedPlanGenerateMapper.selectEligibleRam();
|
||||
List<Map<String, Object>> availableRams = scBreedPlanGenerateMapper.selectEligibleRam(new SheepFile());
|
||||
result.put("availableRams", availableRams);
|
||||
return result;
|
||||
}
|
||||
@@ -678,10 +686,10 @@ public class ScBreedPlanGenerateServiceImpl implements IScBreedPlanGenerateServi
|
||||
if (sheet.getColumnWidth(i) < 2000) sheet.setColumnWidth(i, 2000);
|
||||
}
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String fileName = java.net.URLEncoder.encode(planGenerate.getPlanName() + "_配种计划详情", "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
String fileName = planGenerate.getPlanName() + "_配种计划详情.xlsx";
|
||||
response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
|
||||
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
|
||||
@@ -320,9 +320,59 @@ public class ScBreedRecordServiceImpl implements IScBreedRecordService
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 批量标记胚胎已移植,同步更新 sc_embryo_flush 的 transferred 和 recipient_cnt
|
||||
*
|
||||
* @param embryoDetailIds 胚胎明细ID数组
|
||||
* @param breedRecordId 配种记录ID(本次受体羊的配种记录)
|
||||
* @return 更新行数
|
||||
*/
|
||||
@Override
|
||||
public ScBreedRecord getAutomaticBreedMatch(String manageTags) {
|
||||
// 1. 尝试从配种计划获取 (breed_type: 1, 2, 3, 4)
|
||||
public int markBatchEmbryoTransferred(Long[] embryoDetailIds, Long breedRecordId) {
|
||||
if (embryoDetailIds == null || embryoDetailIds.length == 0) return 0;
|
||||
try {
|
||||
// 1. 批量标记明细为已移植,并关联配种记录ID
|
||||
int updated = scBreedRecordMapper.markBatchEmbryoDetailTransferred(embryoDetailIds, breedRecordId);
|
||||
|
||||
// 2. 查询这批胚胎所属的 flush_id(可能属于同一冲胚记录)
|
||||
List<Long> flushIds = scBreedRecordMapper.selectFlushIdsByEmbryoDetailIds(embryoDetailIds);
|
||||
for (Long flushId : flushIds) {
|
||||
// 3. 重新统计该冲胚记录下已移植数 transferred
|
||||
// 以及不同 breed_record_id(受体数)
|
||||
scBreedRecordMapper.syncFlushTransferredStats(flushId);
|
||||
}
|
||||
return updated;
|
||||
} catch (Exception e) {
|
||||
log.error("批量标记胚胎移植失败", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模糊搜索耳号
|
||||
*
|
||||
* @param query 关键字
|
||||
* @param gender ewe=母羊 ram=公羊 null=不限
|
||||
* @return 耳号+品种列表
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> searchEarNumbers(String query, String gender) {
|
||||
Integer genderInt = null;
|
||||
if ("ewe".equals(gender)) genderInt = 1;
|
||||
else if ("ram".equals(gender)) genderInt = 2;
|
||||
return scBreedRecordMapper.searchEarNumbers(query, genderInt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配种记录ID查询已移植的胚胎明细
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getEmbryosByBreedRecord(Long breedRecordId) {
|
||||
return scBreedRecordMapper.selectEmbryoDetailsByBreedRecordId(breedRecordId);
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.zhyc.module.produce.breed.mapper.ScEmbryoDetailMapper;
|
||||
import com.zhyc.module.produce.breed.domain.ScEmbryoDetail;
|
||||
import com.zhyc.module.produce.breed.service.IScEmbryoDetailService;
|
||||
|
||||
/**
|
||||
* 胚胎明细记录 Service 实现
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-11-28
|
||||
*/
|
||||
@Service
|
||||
public class ScEmbryoDetailServiceImpl implements IScEmbryoDetailService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ScEmbryoDetailServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ScEmbryoDetailMapper scEmbryoDetailMapper;
|
||||
|
||||
@Override
|
||||
public ScEmbryoDetail selectScEmbryoDetailById(Long id) {
|
||||
return scEmbryoDetailMapper.selectScEmbryoDetailById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScEmbryoDetail> selectByFlushId(Long flushId) {
|
||||
return scEmbryoDetailMapper.selectByFlushId(flushId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询可供移植的胚胎(未移植、去向=移植)
|
||||
*/
|
||||
@Override
|
||||
public List<ScEmbryoDetail> selectAvailableForTransfer(Long flushId) {
|
||||
// 仅返回 is_transferred=0 且 destination='移植' 的记录
|
||||
List<ScEmbryoDetail> all = scEmbryoDetailMapper.selectByFlushIdAndDestination(flushId, "移植");
|
||||
// 再过滤掉已移植
|
||||
List<ScEmbryoDetail> available = new ArrayList<>();
|
||||
for (ScEmbryoDetail d : all) {
|
||||
if (d.getIsTransferred() == null || d.getIsTransferred() == 0) {
|
||||
available.add(d);
|
||||
}
|
||||
}
|
||||
return available;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存胚胎明细
|
||||
* 策略:先删除该冲胚记录下的旧明细,再重新插入(简化乐观锁处理)
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int saveDetails(Long flushId, List<ScEmbryoDetail> details, Long deptId, Long userId) {
|
||||
if (flushId == null || details == null || details.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
// 1. 删除旧明细(仅删除未移植的,已移植的保留历史)
|
||||
scEmbryoDetailMapper.deleteByFlushId(flushId);
|
||||
|
||||
// 2. 重新编号并填充关联字段
|
||||
for (int i = 0; i < details.size(); i++) {
|
||||
ScEmbryoDetail d = details.get(i);
|
||||
d.setFlushId(flushId);
|
||||
d.setEmbryoNo(i + 1);
|
||||
d.setDeptId(deptId);
|
||||
d.setUserId(userId);
|
||||
}
|
||||
|
||||
// 3. 批量插入
|
||||
return scEmbryoDetailMapper.insertBatch(details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateScEmbryoDetail(ScEmbryoDetail scEmbryoDetail) {
|
||||
return scEmbryoDetailMapper.updateScEmbryoDetail(scEmbryoDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int markAsTransferred(Long id, Long breedRecordId) {
|
||||
return scEmbryoDetailMapper.markAsTransferred(id, breedRecordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByFlushId(Long flushId) {
|
||||
return scEmbryoDetailMapper.deleteByFlushId(flushId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteScEmbryoDetailByIds(Long[] ids) {
|
||||
return scEmbryoDetailMapper.deleteScEmbryoDetailByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countTransferred(Long flushId) {
|
||||
return scEmbryoDetailMapper.countTransferredByFlushId(flushId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countRecipients(Long flushId) {
|
||||
return scEmbryoDetailMapper.countRecipientsByFlushId(flushId);
|
||||
}
|
||||
}
|
||||
@@ -5,40 +5,43 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.module.produce.breed.domain.ScEmbryoDetail;
|
||||
import com.zhyc.module.produce.breed.mapper.ScEmbryoDetailMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
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业务层处理
|
||||
* 冲胚记录 Service 实现(v2)
|
||||
* 变更:insertScEmbryoFlush / updateScEmbryoFlush 同步处理 embryoDetails 明细
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-11-28
|
||||
*/
|
||||
@Service
|
||||
public class ScEmbryoFlushServiceImpl implements IScEmbryoFlushService
|
||||
{
|
||||
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世代
|
||||
@Autowired
|
||||
private ScEmbryoDetailMapper scEmbryoDetailMapper;
|
||||
|
||||
// ======= 品种常量 =======
|
||||
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;
|
||||
private static final int VARIETY_SHIDAI_2 = 8;
|
||||
private static final int VARIETY_SHIDAI_3 = 9;
|
||||
private static final int VARIETY_SHIDAI_4 = 10;
|
||||
|
||||
/** 品种ID到名称的映射 */
|
||||
private static final Map<Integer, String> VARIETY_NAME_MAP = new HashMap<>();
|
||||
static {
|
||||
VARIETY_NAME_MAP.put(1, "湖羊");
|
||||
@@ -54,291 +57,273 @@ public class ScEmbryoFlushServiceImpl implements IScEmbryoFlushService
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScEmbryoFlush selectScEmbryoFlushById(Long id)
|
||||
{
|
||||
public ScEmbryoFlush selectScEmbryoFlushById(Long id) {
|
||||
return scEmbryoFlushMapper.selectScEmbryoFlushById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataScope(deptAlias = "f", userAlias = "f") // 别名必须和 XML 中的一致!
|
||||
public List<ScEmbryoFlush> selectScEmbryoFlushList(ScEmbryoFlush scEmbryoFlush)
|
||||
{
|
||||
@DataScope(deptAlias = "f", userAlias = "f")
|
||||
public List<ScEmbryoFlush> selectScEmbryoFlushList(ScEmbryoFlush scEmbryoFlush) {
|
||||
return scEmbryoFlushMapper.selectScEmbryoFlushList(scEmbryoFlush);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增冲胚记录
|
||||
* 1. 从 embryoDetails 计算各等级数量及统计值,写入主表
|
||||
* 2. 批量保存胚胎明细
|
||||
*/
|
||||
@Override
|
||||
public int insertScEmbryoFlush(ScEmbryoFlush scEmbryoFlush)
|
||||
{
|
||||
calculateEmbryoCount(scEmbryoFlush);
|
||||
return scEmbryoFlushMapper.insertScEmbryoFlush(scEmbryoFlush);
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertScEmbryoFlush(ScEmbryoFlush scEmbryoFlush) {
|
||||
// 从明细计算聚合字段
|
||||
if (scEmbryoFlush.getEmbryoDetails() != null && !scEmbryoFlush.getEmbryoDetails().isEmpty()) {
|
||||
calculateFromDetails(scEmbryoFlush);
|
||||
} else {
|
||||
// 兜底:直接计算(编辑时明细可能为空)
|
||||
calculateEmbryoCount(scEmbryoFlush);
|
||||
}
|
||||
|
||||
// 插入主表
|
||||
int result = scEmbryoFlushMapper.insertScEmbryoFlush(scEmbryoFlush);
|
||||
|
||||
// 批量插入明细
|
||||
if (result > 0 && scEmbryoFlush.getEmbryoDetails() != null
|
||||
&& !scEmbryoFlush.getEmbryoDetails().isEmpty()) {
|
||||
saveEmbryoDetails(scEmbryoFlush);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改冲胚记录
|
||||
* 同样重新计算聚合字段,并更新明细(先删后插,已移植的不受影响,因为 deleteByFlushId 全删了历史)
|
||||
* 如需保留已移植明细,可在 Mapper 里改为仅删除 is_transferred=0 的记录
|
||||
*/
|
||||
@Override
|
||||
public int updateScEmbryoFlush(ScEmbryoFlush scEmbryoFlush)
|
||||
{
|
||||
calculateEmbryoCount(scEmbryoFlush);
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateScEmbryoFlush(ScEmbryoFlush scEmbryoFlush) {
|
||||
if (scEmbryoFlush.getEmbryoDetails() != null && !scEmbryoFlush.getEmbryoDetails().isEmpty()) {
|
||||
calculateFromDetails(scEmbryoFlush);
|
||||
// 重建明细(仅删除未移植的)
|
||||
saveEmbryoDetails(scEmbryoFlush);
|
||||
} else {
|
||||
calculateEmbryoCount(scEmbryoFlush);
|
||||
}
|
||||
return scEmbryoFlushMapper.updateScEmbryoFlush(scEmbryoFlush);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteScEmbryoFlushByIds(Long[] ids)
|
||||
{
|
||||
public int deleteScEmbryoFlushByIds(Long[] ids) {
|
||||
// 同步删除明细
|
||||
for (Long id : ids) {
|
||||
scEmbryoDetailMapper.deleteByFlushId(id);
|
||||
}
|
||||
return scEmbryoFlushMapper.deleteScEmbryoFlushByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteScEmbryoFlushById(Long id)
|
||||
{
|
||||
public int deleteScEmbryoFlushById(Long id) {
|
||||
scEmbryoDetailMapper.deleteByFlushId(id);
|
||||
return scEmbryoFlushMapper.deleteScEmbryoFlushById(id);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 内部辅助方法
|
||||
// ============================================================
|
||||
|
||||
/**
|
||||
* 计算冲胚数和有效胚数量
|
||||
* 从 embryoDetails 列表计算各等级数量并回填主表聚合字段
|
||||
*/
|
||||
private void calculateEmbryoCount(ScEmbryoFlush flush)
|
||||
{
|
||||
int gradeAPlus = flush.getGradeAPlus() != null ? flush.getGradeAPlus() : 0;
|
||||
private void calculateFromDetails(ScEmbryoFlush flush) {
|
||||
int gradeAPlus = 0, gradeA = 0, gradeB = 0, gradeC = 0, gradeD = 0,
|
||||
cell24 = 0, cell8 = 0,
|
||||
unfertilized = 0, degenerated = 0;
|
||||
|
||||
for (ScEmbryoDetail d : flush.getEmbryoDetails()) {
|
||||
// 继承胚胎品种
|
||||
if (d.getEmbryoVariety() == null) {
|
||||
d.setEmbryoVariety(flush.getEmbryoVariety());
|
||||
}
|
||||
if (d.getEmbryoGrade() == null) continue;
|
||||
switch (d.getEmbryoGrade()) {
|
||||
case "A+": gradeAPlus++; break;
|
||||
case "A": gradeA++; break;
|
||||
case "B": gradeB++; break;
|
||||
case "C": gradeC++; break;
|
||||
case "16细胞": gradeD++; break;
|
||||
case "2/4细胞": cell24++; break;
|
||||
case "8细胞": cell8++; break;
|
||||
case "未受精": unfertilized++; break;
|
||||
case "退化": degenerated++; break;
|
||||
}
|
||||
}
|
||||
|
||||
flush.setGradeAPlus(gradeAPlus);
|
||||
flush.setGradeA(gradeA);
|
||||
flush.setGradeB(gradeB);
|
||||
flush.setGradeC(gradeC);
|
||||
flush.setGradeD(gradeD);
|
||||
flush.setCell24(cell24);
|
||||
flush.setCell8(cell8);
|
||||
flush.setUnfertilized(unfertilized);
|
||||
flush.setDegenerated(degenerated);
|
||||
|
||||
int valid = gradeAPlus + gradeA + gradeB + gradeC + gradeD;
|
||||
int total = valid + cell24 + cell8 + unfertilized + degenerated;
|
||||
flush.setValidEmbryo(valid);
|
||||
flush.setTotalEmbryo(total);
|
||||
}
|
||||
|
||||
/** 旧逻辑兜底:直接加总 */
|
||||
private void calculateEmbryoCount(ScEmbryoFlush flush) {
|
||||
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(16细胞D级) + 16细胞期
|
||||
flush.setValidEmbryo(gradeAPlus + gradeA + gradeB + gradeC + gradeD);
|
||||
|
||||
// 冲胚数 = 所有数量求和
|
||||
flush.setTotalEmbryo(gradeAPlus + gradeA + gradeB + gradeC + gradeD
|
||||
+ cell24 + cell8 + cell16 + unfertilized + degenerated);
|
||||
flush.setValidEmbryo(gradeA + gradeB + gradeC + gradeD);
|
||||
flush.setTotalEmbryo(gradeA + gradeB + gradeC + gradeD + unfertilized + degenerated);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据供体母羊耳号获取关联信息
|
||||
*/
|
||||
/** 批量保存胚胎明细(先删后插) */
|
||||
private void saveEmbryoDetails(ScEmbryoFlush flush) {
|
||||
scEmbryoDetailMapper.deleteByFlushId(flush.getId());
|
||||
List<ScEmbryoDetail> details = flush.getEmbryoDetails();
|
||||
for (int i = 0; i < details.size(); i++) {
|
||||
ScEmbryoDetail d = details.get(i);
|
||||
d.setFlushId(flush.getId());
|
||||
d.setEmbryoNo(i + 1);
|
||||
d.setDeptId(flush.getDeptId());
|
||||
d.setUserId(flush.getUserId());
|
||||
if (d.getEmbryoVariety() == null) {
|
||||
d.setEmbryoVariety(flush.getEmbryoVariety());
|
||||
}
|
||||
}
|
||||
scEmbryoDetailMapper.insertBatch(details);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 以下方法与原版完全一致,保留不变
|
||||
// ============================================================
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDonorRelatedInfo(String donorFemaleNo)
|
||||
{
|
||||
public Map<String, Object> getDonorRelatedInfo(String donorFemaleNo) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (donorFemaleNo == null || donorFemaleNo.trim().isEmpty()) return result;
|
||||
|
||||
if (donorFemaleNo == null || donorFemaleNo.trim().isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 1. 查询母羊信息
|
||||
Map<String, Object> femaleInfo = scEmbryoFlushMapper.selectSheepInfoByManageTag(donorFemaleNo);
|
||||
if (femaleInfo == null || femaleInfo.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
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 maleNo = (String) breedRecord.get("donorMaleNo"); // 这里的 Key 必须对应 SQL 里的别名
|
||||
String maleNo = (String) breedRecord.get("donorMaleNo");
|
||||
result.put("donorMaleNo", maleNo);
|
||||
result.put("matingDate", breedRecord.get("matingDate"));
|
||||
|
||||
// 3. 查询公羊品种
|
||||
if (maleNo != null && !maleNo.trim().isEmpty()) {
|
||||
Map<String, Object> maleInfo = scEmbryoFlushMapper.selectSheepInfoByManageTag(maleNo);
|
||||
if (maleInfo != null && !maleInfo.isEmpty()) {
|
||||
String maleVariety = (String) maleInfo.get("variety");
|
||||
result.put("donorMaleVariety", maleVariety);
|
||||
|
||||
// 4. 【关键修复】使用品种名称计算胚胎品种
|
||||
// 这样可以确保无论数据库ID是多少,只要名字是对的就能算出结果
|
||||
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", calculateEmbryoVarietyById(mId, fId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
public String calculateEmbryoVariety(String maleVariety, String femaleVariety) {
|
||||
Integer maleId = getVarietyIdByName(maleVariety);
|
||||
Integer femaleId = getVarietyIdByName(femaleVariety);
|
||||
if (maleId == null || femaleId == null) {
|
||||
return null;
|
||||
}
|
||||
if (maleId == null || femaleId == null) return null;
|
||||
return calculateEmbryoVarietyById(maleId, femaleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSheepInfoByTag(String manageTag) {
|
||||
if (manageTag == null || manageTag.trim().isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
if (manageTag == null || manageTag.trim().isEmpty()) return new HashMap<>();
|
||||
return scEmbryoFlushMapper.selectSheepInfoByManageTag(manageTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父母品种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 isMaleCapableOfGeneration = (male >= 3 && male <= 10);
|
||||
|
||||
if (isMaleCapableOfGeneration) {
|
||||
// 级杂二代(母) x 任意合格公羊 -> 一世代
|
||||
if (female == VARIETY_JIZA_2) {
|
||||
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_1);
|
||||
}
|
||||
// 一世代(母) x 任意合格公羊 -> 二世代
|
||||
if (female == VARIETY_SHIDAI_1) {
|
||||
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_2);
|
||||
}
|
||||
// 二世代(母) x 任意合格公羊 -> 三世代
|
||||
if (female == VARIETY_SHIDAI_2) {
|
||||
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_3);
|
||||
}
|
||||
// 三世代(母) x 任意合格公羊 -> 四世代
|
||||
if (female == VARIETY_SHIDAI_3) {
|
||||
return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_4);
|
||||
}
|
||||
}
|
||||
|
||||
// 默认返回null,表示无法计算或规则未覆盖
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> selectDonorFemaleList()
|
||||
{
|
||||
public List<Map<String, Object>> selectDonorFemaleList() {
|
||||
return scEmbryoFlushMapper.selectDonorFemaleList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> selectDonorMaleList()
|
||||
{
|
||||
public List<Map<String, Object>> selectDonorMaleList() {
|
||||
return scEmbryoFlushMapper.selectDonorMaleList();
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static String calculateEmbryoVarietyById(Integer maleVarietyId, Integer femaleVarietyId) {
|
||||
if (maleVarietyId == null || femaleVarietyId == null) return null;
|
||||
int m = maleVarietyId, f = femaleVarietyId;
|
||||
|
||||
if (m == VARIETY_HUYANG && f == VARIETY_HUYANG) return VARIETY_NAME_MAP.get(VARIETY_HUYANG);
|
||||
if (m == VARIETY_DONGFULISHENG && f == VARIETY_DONGFULISHENG) return VARIETY_NAME_MAP.get(VARIETY_DONGFULISHENG);
|
||||
if (m == VARIETY_DONGFULISHENG && f == VARIETY_HUYANG) return VARIETY_NAME_MAP.get(VARIETY_JIZA_1);
|
||||
if (m == VARIETY_DONGFULISHENG && f == VARIETY_JIZA_1) return VARIETY_NAME_MAP.get(VARIETY_JIZA_2);
|
||||
if (m == VARIETY_DONGFULISHENG && f == VARIETY_JIZA_2) return VARIETY_NAME_MAP.get(VARIETY_JIZA_3);
|
||||
if (m == VARIETY_DONGFULISHENG && f == VARIETY_JIZA_3) return VARIETY_NAME_MAP.get(VARIETY_DONGFULISHENG);
|
||||
if (m == VARIETY_HUYANG && f == VARIETY_JIZA_3) return VARIETY_NAME_MAP.get(VARIETY_HUIJIAO);
|
||||
if (m == VARIETY_HUYANG && f == VARIETY_HUIJIAO) return VARIETY_NAME_MAP.get(VARIETY_HUIJIAO);
|
||||
|
||||
boolean isMaleCapable = (m >= 3 && m <= 10);
|
||||
if (isMaleCapable) {
|
||||
if (f == VARIETY_JIZA_2) return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_1);
|
||||
if (f == VARIETY_SHIDAI_1) return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_2);
|
||||
if (f == VARIETY_SHIDAI_2) return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_3);
|
||||
if (f == VARIETY_SHIDAI_3) return VARIETY_NAME_MAP.get(VARIETY_SHIDAI_4);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 添加名称到ID的反向映射
|
||||
private static final Map<String, Integer> NAME_TO_ID_MAP = new HashMap<>();
|
||||
static {
|
||||
VARIETY_NAME_MAP.forEach((id, name) -> NAME_TO_ID_MAP.put(name, id));
|
||||
}
|
||||
|
||||
// 改为实例方法,添加 @Override
|
||||
@Override
|
||||
public String calculateEmbryoVarietyByName(String maleVarietyName, String femaleVarietyName) {
|
||||
if (maleVarietyName == null || femaleVarietyName == null) return null;
|
||||
|
||||
Integer maleId = NAME_TO_ID_MAP.get(maleVarietyName);
|
||||
Integer femaleId = NAME_TO_ID_MAP.get(femaleVarietyName);
|
||||
|
||||
if (maleId == null || femaleId == null) return null;
|
||||
|
||||
return calculateEmbryoVarietyById(maleId, femaleId);
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||
* @param scPregnancyRecord 孕检记录
|
||||
* @return 孕检记录
|
||||
*/
|
||||
@DataScope(deptAlias = "pr", userAlias = "pr")
|
||||
@Override
|
||||
public List<ScPregnancyRecord> selectScPregnancyRecordList(ScPregnancyRecord scPregnancyRecord)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zhyc.module.result;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; // 导入需排除的自动配置类
|
||||
|
||||
// 核心:添加 exclude = DataSourceAutoConfiguration.class,禁用数据源自动配置
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
public class OcrApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OcrApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.zhyc.module.result;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* OCR 识别接口控制器
|
||||
*/
|
||||
@RestController
|
||||
public class OcrController {
|
||||
|
||||
// 注入 OCR 工具类
|
||||
@Autowired
|
||||
private OcrUtils ocrUtils;
|
||||
|
||||
/**
|
||||
* 图片文字识别接口(接收前端上传的图片)
|
||||
* @param file 前端上传的图片文件(支持 jpg、png、jpeg 等格式)
|
||||
* @return 统一格式的响应结果
|
||||
*/
|
||||
@PostMapping("/api/ocr/recognize")
|
||||
public Result recognizeImage(@RequestParam("file") MultipartFile file) {
|
||||
// 1. 校验文件是否为空
|
||||
if (file.isEmpty()) {
|
||||
return Result.error("请上传有效图片文件");
|
||||
}
|
||||
|
||||
// 2. 校验文件格式(可选,仅允许常见图片格式)
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
assert originalFilename != null;
|
||||
String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||
if (!".jpg".equalsIgnoreCase(suffix) && !".png".equalsIgnoreCase(suffix) && !".jpeg".equalsIgnoreCase(suffix)) {
|
||||
return Result.error("仅支持 jpg、png、jpeg 格式的图片");
|
||||
}
|
||||
|
||||
// 3. 将 MultipartFile 转换为 File(Tesseract 需接收 File 类型参数)
|
||||
File tempFile = null;
|
||||
try {
|
||||
// 生成唯一文件名,避免文件覆盖
|
||||
String fileName = UUID.randomUUID().toString() + suffix;
|
||||
// 临时文件存储路径(项目根目录下的 temp 文件夹)
|
||||
String tempPath = System.getProperty("user.dir") + File.separator + "temp";
|
||||
File tempDir = new File(tempPath);
|
||||
if (!tempDir.exists()) {
|
||||
tempDir.mkdirs(); // 创建文件夹(若不存在)
|
||||
}
|
||||
tempFile = new File(tempPath + File.separator + fileName);
|
||||
file.transferTo(tempFile); // 将上传文件写入临时文件
|
||||
|
||||
// 4. 调用 OCR 工具类执行识别
|
||||
String recognizeResult = ocrUtils.recognizeEngAndNumber(tempFile);
|
||||
|
||||
// 5. 返回成功结果(去除结果中的多余空格和换行符)
|
||||
return Result.success(recognizeResult.replaceAll("\\s+", " ").trim());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("图片识别失败:" + e.getMessage());
|
||||
} finally {
|
||||
// 6. 清理临时文件(避免占用磁盘空间)
|
||||
if (tempFile != null && tempFile.exists()) {
|
||||
boolean delete = tempFile.delete();
|
||||
if (!delete) {
|
||||
System.err.println("临时文件清理失败:" + tempFile.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zhyc.module.result;
|
||||
|
||||
import net.sourceforge.tess4j.ITesseract;
|
||||
import net.sourceforge.tess4j.Tesseract;
|
||||
import net.sourceforge.tess4j.TesseractException;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Tesseract-OCR 工具类(封装识别逻辑)
|
||||
*/
|
||||
@Component
|
||||
public class OcrUtils {
|
||||
|
||||
/**
|
||||
* 识别图片中的英文和数字
|
||||
* @param imageFile 上传的图片文件
|
||||
* @return 识别结果字符串
|
||||
* @throws TesseractException OCR 识别异常
|
||||
*/
|
||||
public String recognizeEngAndNumber(File imageFile) throws TesseractException {
|
||||
ITesseract tesseract = new Tesseract();
|
||||
|
||||
// 核心修改:添加 setDatapath(),指定 tessdata 目录的**上级目录**(关键!)
|
||||
// 注意:路径是 tessdata 文件夹的父目录,不是 tessdata 本身!
|
||||
// Windows 示例(替换为你自己的 tessdata 上级目录,注意用 / 或 \\ 转义)
|
||||
tesseract.setDatapath("E:/JAVA/OCR/tessdata");
|
||||
// Linux/Mac 示例(替换为你的实际路径)
|
||||
// tesseract.setDatapath("/usr/share/tesseract-ocr/4.00");
|
||||
|
||||
// 配置语言包(eng 表示英文,此时会从上面指定的路径下加载 tessdata/eng.traineddata)
|
||||
tesseract.setLanguage("eng");
|
||||
|
||||
// 配置字符白名单,提升英文/数字识别精度
|
||||
tesseract.setTessVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
|
||||
// 执行识别并返回结果
|
||||
return tesseract.doOCR(imageFile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// 注意:包名必须与 main 下的主包名一致(例如 com.example.ocr.utils)
|
||||
package com.zhyc.module.result;
|
||||
|
||||
|
||||
import net.sourceforge.tess4j.TesseractException;
|
||||
import org.junit.jupiter.api.Test; // 正确导入 test 注解(来自 junit-jupiter)
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest; // 正确导入 SpringBootTest 注解
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* OcrUtils 工具类单元测试
|
||||
*/
|
||||
// 注解说明:
|
||||
// 1. @SpringBootTest:启动 Spring 容器,扫描并加载所有 Bean,支持 @Autowired 注入
|
||||
// 2. classes = OcrApplication.class:指定启动类,若测试类包名与启动类包名一致,可省略该配置
|
||||
@SpringBootTest(classes = OcrApplication.class)
|
||||
public class OcrUtilsTest {
|
||||
|
||||
// 注入 OCR 工具类(此时 Spring 容器已加载 OcrUtils Bean,可正常注入)
|
||||
@Autowired
|
||||
private OcrUtils ocrUtils;
|
||||
|
||||
// 测试方法:必须添加 @Test 注解,无返回值,无参数
|
||||
@Test
|
||||
public void testRecognizeEngAndNumber() {
|
||||
// 1. 指定本地测试图片路径(替换为你的实际图片路径)
|
||||
String imagePath = "C:\\Users\\Administrator\\Desktop\\test1.png";
|
||||
File imageFile = new File(imagePath);
|
||||
|
||||
// 2. 校验图片文件是否存在
|
||||
if (!imageFile.exists()) {
|
||||
System.err.println("测试失败:图片文件不存在,请检查路径是否正确");
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 调用 OCR 工具类执行识别
|
||||
try {
|
||||
String result = ocrUtils.recognizeEngAndNumber(imageFile);
|
||||
// 4. 打印识别结果
|
||||
System.out.println("===== 单元测试识别结果 =====");
|
||||
System.out.println("格式化结果:" + result.replaceAll("\\s+", " ").trim());
|
||||
} catch (TesseractException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("===== 单元测试失败:OCR 识别异常 =====");
|
||||
}
|
||||
}
|
||||
}
|
||||
30
zhyc-module/src/main/java/com/zhyc/module/result/Result.java
Normal file
30
zhyc-module/src/main/java/com/zhyc/module/result/Result.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.zhyc.module.result;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 接口统一返回结果
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Result {
|
||||
// 响应状态码:200成功,500失败
|
||||
private Integer code;
|
||||
// 响应消息
|
||||
private String msg;
|
||||
// 响应数据(识别结果)
|
||||
private Object data;
|
||||
|
||||
// 静态方法:返回成功结果
|
||||
public static Result success(Object data) {
|
||||
return new Result(200, "识别成功", data);
|
||||
}
|
||||
|
||||
// 静态方法:返回失败结果
|
||||
public static Result error(String msg) {
|
||||
return new Result(500, msg, null);
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSheepFileVo">
|
||||
select id, bs_manage_tags, ranch_id, dr_ranch, sheepfold_id, sheepfold_name, electronic_tags, variety_id, variety, family, name, gender, birthday, day_age, month_age, parity, birth_weight, weaning_date, status_id, weaning_weight, current_weight,weaning_day_age,weaning_daily_gain,breed_status_id, breed, bs_father_id, father_manage_tags, bs_mother_id, mother_manage_tags, receptor_id, receptor_manage_tags, father_father_id, grandfather_manage_tags, father_mother_id, grandmother_manage_tags, father_id, maternal_grandfather_manage_tags, mother_id, maternal_grandmother_manage_tags, mating_date, mating_type_id, preg_date, lambing_date, lambing_day, mating_day, gestation_day, expected_date, post_lambing_day, lactation_day, anestrous_day, mating_counts, mating_total, miscarriage_counts, comment, controlled, body, breast, source, source_date, source_ranch_id, source_ranch, update_by, update_time, create_by, create_time, is_delete from sheep_file
|
||||
select id, bs_manage_tags, ranch_id, dr_ranch, sheepfold_id, sheepfold_name, electronic_tags, variety_id, variety, family, name, gender, birthday, day_age, month_age, parity, birth_weight, weaning_date, status_id, weaning_weight, current_weight,weaning_day_age,weaning_daily_gain,breed_status_id, breed, bs_father_id, father_manage_tags, bs_mother_id, mother_manage_tags, receptor_id, receptor_manage_tags, father_father_id, grandfather_manage_tags, father_mother_id, grandmother_manage_tags, father_id, maternal_grandfather_manage_tags, mother_id, maternal_grandmother_manage_tags, mating_date, mating_type_id, preg_date, lambing_date, lambing_day, mating_day, gestation_day, expected_date, post_lambing_day, lactation_day, anestrous_day, mating_counts, mating_total, miscarriage_counts, comment, controlled, body, breast, source, source_date, source_ranch_id, source_ranch, update_by, update_time, create_by, create_time, is_delete from sheep_file sf
|
||||
</sql>
|
||||
|
||||
<select id="selectSheepFileList" parameterType="SheepFile" resultMap="SheepFileResult">
|
||||
@@ -95,7 +95,7 @@
|
||||
ORDER BY id ASC
|
||||
</select>
|
||||
|
||||
<select id="searchEarNumbers" resultType="String">
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs_manage_tags
|
||||
FROM sheep_file
|
||||
WHERE (is_delete = 0 OR is_delete IS NULL)
|
||||
@@ -116,53 +116,53 @@
|
||||
where bs_manage_tags = #{tags}
|
||||
</select>
|
||||
|
||||
<select id="countInGroup" resultType="java.lang.Long">
|
||||
<select id="countInGroup" resultType="java.lang.Long" parameterType="SheepFile">
|
||||
SELECT COUNT(*)
|
||||
FROM sheep_file sf
|
||||
WHERE sf.status_id = 1
|
||||
AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
|
||||
${params.dataScope}
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="countBySheepType" resultType="java.util.Map">
|
||||
<select id="countBySheepType" resultType="java.util.Map" parameterType="SheepFile">
|
||||
SELECT sf.name AS name, COUNT(*) AS value
|
||||
FROM sheep_file sf
|
||||
WHERE sf.status_id = 1
|
||||
AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
|
||||
${params.dataScope}
|
||||
${params.dataScope}
|
||||
GROUP BY sf.name
|
||||
</select>
|
||||
|
||||
<select id="countByBreedStatus" resultType="java.util.Map">
|
||||
<select id="countByBreedStatus" resultType="java.util.Map" parameterType="SheepFile">
|
||||
SELECT sf.breed AS name, COUNT(*) AS value
|
||||
FROM sheep_file sf
|
||||
WHERE sf.status_id = 1
|
||||
AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
|
||||
${params.dataScope}
|
||||
${params.dataScope}
|
||||
GROUP BY sf.breed
|
||||
</select>
|
||||
|
||||
<select id="countByVariety" resultType="java.util.Map">
|
||||
<select id="countByVariety" resultType="java.util.Map" parameterType="SheepFile">
|
||||
SELECT sf.variety AS name, COUNT(*) AS value
|
||||
FROM sheep_file sf
|
||||
WHERE sf.status_id = 1
|
||||
AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
|
||||
${params.dataScope}
|
||||
${params.dataScope}
|
||||
GROUP BY sf.variety
|
||||
</select>
|
||||
|
||||
<select id="countParityOfLactation" resultType="java.util.Map">
|
||||
<select id="countParityOfLactation" resultType="java.util.Map" parameterType="SheepFile">
|
||||
SELECT sf.parity AS name, COUNT(*) AS value
|
||||
FROM sheep_file sf
|
||||
WHERE sf.status_id = 1
|
||||
AND sf.name = '泌乳羊'
|
||||
AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
|
||||
${params.dataScope}
|
||||
${params.dataScope}
|
||||
GROUP BY sf.parity
|
||||
ORDER BY sf.parity
|
||||
</select>
|
||||
|
||||
<select id="selectFieldValues" parameterType="String" resultType="String">
|
||||
<select id="selectFieldValues" parameterType="String" resultType="java.lang.String">
|
||||
SELECT DISTINCT ${fieldName} as field_value
|
||||
FROM sheep_file
|
||||
WHERE ${fieldName} IS NOT NULL AND ${fieldName} != '' AND ${fieldName} != 'null'
|
||||
@@ -173,7 +173,7 @@
|
||||
<include refid="selectSheepFileVo"/>
|
||||
<where>
|
||||
AND (is_delete = 0 OR is_delete IS NULL)
|
||||
|
||||
${sheepFile.params.dataScope}
|
||||
<if test="sheepFile != null">
|
||||
<if test="sheepFile.allEarNumbers != null and sheepFile.allEarNumbers.size() > 0">
|
||||
AND bs_manage_tags IN
|
||||
@@ -282,7 +282,7 @@
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
${params.dataScope}
|
||||
|
||||
</where>
|
||||
ORDER BY id ASC
|
||||
</select>
|
||||
|
||||
@@ -82,6 +82,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectDewormVo"/>
|
||||
where s.id = #{id}
|
||||
</select>
|
||||
<select id="selectSheepNoList" resultType="java.lang.String" parameterType="Deworm">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM sw_deworm s
|
||||
LEFT JOIN bas_sheep bs ON s.sheep_id = bs.id
|
||||
<where>
|
||||
bs.manage_tags IS NOT NULL AND bs.manage_tags != ''
|
||||
<if test="sheepNo!=null and sheepNo!= ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
|
||||
ORDER BY bs.manage_tags ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertDeworm" parameterType="java.util.List">
|
||||
insert into sw_deworm
|
||||
|
||||
@@ -91,6 +91,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectDiagnosisVo"/>
|
||||
where sd.id = #{id}
|
||||
</select>
|
||||
<select id="selectSheepNoList" resultType="java.lang.String" parameterType="Diagnosis">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM sw_diagnosis s
|
||||
LEFT JOIN bas_sheep bs ON s.sheep_id = bs.id
|
||||
<where>
|
||||
bs.manage_tags IS NOT NULL AND bs.manage_tags != ''
|
||||
<if test="sheepNo!=null and sheepNo!= ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
|
||||
ORDER BY bs.manage_tags ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertDiagnosis" parameterType="Diagnosis" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_diagnosis
|
||||
|
||||
@@ -51,7 +51,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="sheepfoldId != null"> AND sd.sheepfold_id = #{sheepfoldId}</if>
|
||||
<!-- 根据羊舍 id 数组查询 -->
|
||||
<if test="sheepfoldIds != null and sheepfoldIds.length > 0">
|
||||
AND sd.sheepfold_id IN
|
||||
<foreach collection="sheepfoldIds" item="sheepfoldId" open="(" separator="," close=")">
|
||||
#{sheepfoldId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="datetime != null"> AND sd.datetime = #{datetime}</if>
|
||||
<if test="technician != null and technician != ''"> AND sd.technician = #{technician}</if>
|
||||
<if test="way != null and way != ''"> AND sd.way = #{way}</if>
|
||||
@@ -77,6 +83,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectDisinfectVo"/>
|
||||
where sd.id = #{id}
|
||||
</select>
|
||||
<select id="selectSheepfoldList" resultType="java.util.Map">
|
||||
SELECT DISTINCT ds.id AS sheepfoldId, ds.sheepfold_name
|
||||
FROM sw_disinfect s
|
||||
LEFT JOIN da_sheepfold ds ON s.sheepfold_id = ds.id
|
||||
<where>
|
||||
<if test="sheepfoldName != null and sheepfoldName != ''">
|
||||
ds.sheepfold_name like CONCAT('%', #{sheepfoldName}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertDisinfect" parameterType="Disinfect" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_disinfect
|
||||
|
||||
@@ -85,6 +85,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectHealthVo"/>
|
||||
where s.id = #{id}
|
||||
</select>
|
||||
<select id="selectSheepNoList" resultType="java.lang.String" parameterType="Health">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM sw_health s
|
||||
LEFT JOIN bas_sheep bs ON s.sheep_id = bs.id
|
||||
<where>
|
||||
bs.manage_tags IS NOT NULL AND bs.manage_tags != ''
|
||||
<if test="sheepNo!=null and sheepNo!= ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
|
||||
ORDER BY bs.manage_tags ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertHealth" parameterType="Health" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_health
|
||||
|
||||
@@ -83,6 +83,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectImmunityVo"/>
|
||||
where s.id = #{id}
|
||||
</select>
|
||||
<select id="selectSheepNoList" resultType="java.lang.String" parameterType="Immunity">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM sw_immunity s
|
||||
LEFT JOIN bas_sheep bs ON s.sheep_id = bs.id
|
||||
<where>
|
||||
bs.manage_tags IS NOT NULL AND bs.manage_tags != ''
|
||||
<if test="sheepNo!=null and sheepNo!= ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
|
||||
ORDER BY bs.manage_tags ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertImmunity" parameterType="Immunity" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_immunity
|
||||
|
||||
@@ -102,6 +102,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where sqr.id = #{id}
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
<select id="selectSheepNoList" resultType="java.lang.String" parameterType="QuarantineReport">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM sw_quarantine_report s
|
||||
LEFT JOIN bas_sheep bs ON s.sheep_id = bs.id
|
||||
<where>
|
||||
bs.manage_tags IS NOT NULL AND bs.manage_tags != ''
|
||||
<if test="sheepNo!=null and sheepNo!= ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
|
||||
ORDER BY bs.manage_tags ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertQuarantineReport" parameterType="java.util.List">
|
||||
INSERT INTO sw_quarantine_report
|
||||
|
||||
@@ -156,6 +156,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHERE
|
||||
smud.medi_usage = #{id}
|
||||
</select>
|
||||
<select id="selectSheepNoList" resultType="java.lang.String" parameterType="SwMedicineUsage">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM sw_medicine_usage s
|
||||
LEFT JOIN bas_sheep bs ON s.sheep = bs.id
|
||||
<where>
|
||||
bs.manage_tags IS NOT NULL AND bs.manage_tags != ''
|
||||
<if test="sheepNo!=null and sheepNo!= ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
|
||||
ORDER BY bs.manage_tags ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertSwMedicineUsage" parameterType="SwMedicineUsage" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_medicine_usage
|
||||
|
||||
@@ -105,6 +105,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectTreatmentStatus" resultMap="TreatmentResult">
|
||||
select * from sw_treatment where sheep_id = #{sheepId} and status in (0, 1)
|
||||
</select>
|
||||
<select id="selectSheepNoList" resultType="java.lang.String" parameterType="Treatment">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM sw_treatment s
|
||||
LEFT JOIN bas_sheep bs ON s.sheep_id = bs.id
|
||||
<where>
|
||||
bs.manage_tags IS NOT NULL AND bs.manage_tags != ''
|
||||
<if test="sheepNo!=null and sheepNo!= ''">
|
||||
and bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY bs.manage_tags ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertTreatment" parameterType="Treatment" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_treatment
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
<?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.ScEmbryoDetailMapper">
|
||||
|
||||
<!-- ======================================================
|
||||
ResultMap:胚胎明细(含关联冲胚父记录冗余字段)
|
||||
====================================================== -->
|
||||
<resultMap type="ScEmbryoDetail" id="ScEmbryoDetailResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="flushId" column="flush_id"/>
|
||||
<result property="embryoNo" column="embryo_no"/>
|
||||
<result property="embryoGrade" column="embryo_grade"/>
|
||||
<result property="destination" column="destination"/>
|
||||
<result property="storageMethod" column="storage_method"/>
|
||||
<result property="embryoVariety" column="embryo_variety"/>
|
||||
<result property="breedRecordId" column="breed_record_id"/>
|
||||
<result property="isTransferred" column="is_transferred"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="createdAt" column="created_at"/>
|
||||
<!-- 关联父冲胚记录冗余字段 -->
|
||||
<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="embryoAge" column="embryo_age"/>
|
||||
<result property="embryoType" column="embryo_type"/>
|
||||
<result property="embryoSource" column="embryo_source"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- ======================================================
|
||||
SQL 片段
|
||||
====================================================== -->
|
||||
<sql id="selectDetailWithFlush">
|
||||
SELECT
|
||||
d.id, d.flush_id, d.embryo_no, d.embryo_grade, d.destination,
|
||||
d.storage_method, d.embryo_variety, d.breed_record_id,
|
||||
d.is_transferred, d.dept_id, d.user_id, d.remark, d.created_at,
|
||||
f.flush_time, f.donor_female_no, f.donor_female_variety,
|
||||
f.donor_male_no, f.donor_male_variety, f.embryo_age,
|
||||
f.embryo_type, f.embryo_source
|
||||
FROM sc_embryo_detail d
|
||||
LEFT JOIN sc_embryo_flush f ON f.id = d.flush_id
|
||||
</sql>
|
||||
|
||||
<!-- ======================================================
|
||||
查询
|
||||
====================================================== -->
|
||||
<select id="selectScEmbryoDetailById" parameterType="Long" resultMap="ScEmbryoDetailResult">
|
||||
<include refid="selectDetailWithFlush"/>
|
||||
WHERE d.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectByFlushId" parameterType="Long" resultMap="ScEmbryoDetailResult">
|
||||
<include refid="selectDetailWithFlush"/>
|
||||
WHERE d.flush_id = #{flushId}
|
||||
ORDER BY d.embryo_no ASC
|
||||
</select>
|
||||
|
||||
<select id="selectByFlushIdAndDestination" resultMap="ScEmbryoDetailResult">
|
||||
<include refid="selectDetailWithFlush"/>
|
||||
<where>
|
||||
<if test="flushId != null">
|
||||
AND d.flush_id = #{flushId}
|
||||
</if>
|
||||
<if test="destination != null and destination != ''">
|
||||
AND d.destination = #{destination}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY d.flush_id DESC, d.embryo_no ASC
|
||||
</select>
|
||||
|
||||
<!-- ======================================================
|
||||
插入
|
||||
====================================================== -->
|
||||
<insert id="insertScEmbryoDetail" parameterType="ScEmbryoDetail" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO sc_embryo_detail (
|
||||
flush_id, embryo_no, embryo_grade, destination,
|
||||
storage_method, embryo_variety, is_transferred,
|
||||
dept_id, user_id, remark, created_at
|
||||
) VALUES (
|
||||
#{flushId}, #{embryoNo}, #{embryoGrade}, #{destination},
|
||||
#{storageMethod}, #{embryoVariety}, 0,
|
||||
#{deptId}, #{userId}, #{remark}, NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO sc_embryo_detail (
|
||||
flush_id, embryo_no, embryo_grade, destination,
|
||||
storage_method, embryo_variety, is_transferred,
|
||||
dept_id, user_id, remark, created_at
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.flushId}, #{item.embryoNo}, #{item.embryoGrade}, #{item.destination},
|
||||
#{item.storageMethod}, #{item.embryoVariety}, 0,
|
||||
#{item.deptId}, #{item.userId}, #{item.remark}, NOW()
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- ======================================================
|
||||
更新
|
||||
====================================================== -->
|
||||
<update id="updateScEmbryoDetail" parameterType="ScEmbryoDetail">
|
||||
UPDATE sc_embryo_detail
|
||||
<set>
|
||||
<if test="embryoGrade != null and embryoGrade != ''"> embryo_grade = #{embryoGrade},</if>
|
||||
<if test="destination != null and destination != ''"> destination = #{destination},</if>
|
||||
<if test="storageMethod != null"> storage_method = #{storageMethod},</if>
|
||||
<if test="embryoVariety != null"> embryo_variety = #{embryoVariety},</if>
|
||||
<if test="remark != null"> remark = #{remark},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 回填配种记录ID,标记已移植 -->
|
||||
<update id="markAsTransferred">
|
||||
UPDATE sc_embryo_detail
|
||||
SET is_transferred = 1,
|
||||
breed_record_id = #{breedRecordId}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- ======================================================
|
||||
删除
|
||||
====================================================== -->
|
||||
<delete id="deleteByFlushId" parameterType="Long">
|
||||
DELETE FROM sc_embryo_detail WHERE flush_id = #{flushId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteScEmbryoDetailByIds" parameterType="Long">
|
||||
DELETE FROM sc_embryo_detail WHERE id IN
|
||||
<foreach collection="array" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- ======================================================
|
||||
统计
|
||||
====================================================== -->
|
||||
<select id="countTransferredByFlushId" parameterType="Long" resultType="int">
|
||||
SELECT COUNT(*) FROM sc_embryo_detail
|
||||
WHERE flush_id = #{flushId} AND is_transferred = 1
|
||||
</select>
|
||||
|
||||
<select id="countRecipientsByFlushId" parameterType="Long" resultType="int">
|
||||
SELECT COUNT(DISTINCT breed_record_id) FROM sc_embryo_detail
|
||||
WHERE flush_id = #{flushId} AND breed_record_id IS NOT NULL
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -61,7 +61,7 @@
|
||||
</select>
|
||||
|
||||
<!-- 筛选符合条件的母羊:关联bas_sheep,不需要数据权限 -->
|
||||
<select id="selectEligibleEwe" resultType="Map">
|
||||
<select id="selectEligibleEwe" resultType="java.util.Map" >
|
||||
select
|
||||
bs.id,
|
||||
bs.manage_tags as bs_manage_tags,
|
||||
@@ -86,9 +86,10 @@
|
||||
left join da_sheepfold dsf on bs.sheepfold_id = dsf.id
|
||||
where bs.gender = 1
|
||||
and bs.is_delete = 0
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
<if test="bsManageTags != null and bsManageTags != ''">
|
||||
and bs.manage_tags like concat('%', #{bsManageTags}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
and (bs.status_id = 1 or bs.status_id is null)
|
||||
and (
|
||||
(bst.name in ('青年羊', '超龄羊') and (
|
||||
@@ -103,7 +104,7 @@
|
||||
</select>
|
||||
|
||||
<!-- 筛选符合条件的公羊:关联bas_sheep,不需要数据权限 -->
|
||||
<select id="selectEligibleRam" resultType="Map">
|
||||
<select id="selectEligibleRam" resultType="java.util.Map">
|
||||
select
|
||||
bs.id,
|
||||
bs.manage_tags as bs_manage_tags,
|
||||
@@ -121,9 +122,10 @@
|
||||
left join bas_breed_status bbs on bs.breed_status_id = bbs.id
|
||||
where bs.gender = 2
|
||||
and bs.is_delete = 0
|
||||
<if test="manageTags != null and manageTags != ''">
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
<if test="bsManageTags != null and bsManageTags != ''">
|
||||
and bs.manage_tags like concat('%', #{bsManageTags}, '%')
|
||||
</if>
|
||||
${params.dataScope}
|
||||
and bs.status_id = 1
|
||||
and (
|
||||
(bst.name in ('青年羊', '超龄羊') and (
|
||||
@@ -212,7 +214,7 @@
|
||||
</insert>
|
||||
|
||||
<!-- 获取配种计划详情:关联查询,不需要数据权限 -->
|
||||
<select id="selectBreedPlanDetails" parameterType="Long" resultType="Map">
|
||||
<select id="selectBreedPlanDetails" parameterType="Long" resultType="java.util.Map">
|
||||
select
|
||||
temp.id,
|
||||
temp.ram_id,
|
||||
@@ -254,7 +256,7 @@
|
||||
</select>
|
||||
|
||||
<!-- 获取审批详情:关联查询,不需要数据权限 -->
|
||||
<select id="selectApproveBreedPlanDetails" parameterType="Long" resultType="Map">
|
||||
<select id="selectApproveBreedPlanDetails" parameterType="Long" resultType="java.util.Map">
|
||||
select
|
||||
temp.id,
|
||||
temp.ram_id,
|
||||
@@ -352,10 +354,12 @@
|
||||
FROM bas_sheep
|
||||
WHERE gender = #{gender}
|
||||
AND is_delete = 0
|
||||
AND id IN
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
AND id IN
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
|
||||
@@ -270,10 +270,11 @@
|
||||
ram_view.bs_manage_tags as ram_manage_tags,
|
||||
bp.breed_type,
|
||||
CASE bp.breed_type
|
||||
WHEN 1 THEN '同期发情'
|
||||
WHEN 2 THEN '本交'
|
||||
WHEN 3 THEN '冲胚'
|
||||
WHEN 1 THEN '供体母羊配种'
|
||||
WHEN 2 THEN '同期发情人工授精'
|
||||
WHEN 3 THEN '本交'
|
||||
WHEN 4 THEN '自然发情人工授精'
|
||||
WHEN 5 THEN '胚胎移植'
|
||||
ELSE '未知'
|
||||
END as breed_type_name,
|
||||
TIMESTAMPDIFF(HOUR, NOW(), NOW()) as hours_since_plan
|
||||
@@ -295,10 +296,11 @@
|
||||
ram_view.bs_manage_tags as ram_manage_tags,
|
||||
bpt.breed_type,
|
||||
CASE bpt.breed_type
|
||||
WHEN 1 THEN '同期发情'
|
||||
WHEN 2 THEN '本交'
|
||||
WHEN 3 THEN '冲胚'
|
||||
WHEN 1 THEN '供体母羊配种'
|
||||
WHEN 2 THEN '同期发情人工授精'
|
||||
WHEN 3 THEN '本交'
|
||||
WHEN 4 THEN '自然发情人工授精'
|
||||
WHEN 5 THEN '胚胎移植'
|
||||
ELSE '未知'
|
||||
END as breed_type_name,
|
||||
bpg.create_time as plan_create_time
|
||||
@@ -437,11 +439,90 @@
|
||||
and is_delete = 0
|
||||
</update>
|
||||
|
||||
<!-- 统计该公羊配了多少母羊(去重) -->
|
||||
<select id="countMatedEwesByRamId" resultType="Long">
|
||||
SELECT COUNT(DISTINCT ewe_id)
|
||||
FROM sc_breed_record
|
||||
WHERE ram_id = #{ramManageTags} AND is_delete = 0
|
||||
<!-- 模糊搜索耳号(用于前端 autocomplete) -->
|
||||
<select id="searchEarNumbers" resultType="map">
|
||||
SELECT DISTINCT
|
||||
sf.bs_manage_tags AS manageTags,
|
||||
sf.variety
|
||||
FROM sheep_file sf
|
||||
WHERE sf.bs_manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND sf.is_delete = 0
|
||||
<if test="gender != null">AND sf.gender = #{gender}</if>
|
||||
ORDER BY sf.bs_manage_tags
|
||||
LIMIT 30
|
||||
</select>
|
||||
|
||||
<!-- 批量标记胚胎明细为已移植,关联 breed_record_id -->
|
||||
<update id="markBatchEmbryoDetailTransferred">
|
||||
UPDATE sc_embryo_detail
|
||||
SET is_transferred = 1,
|
||||
breed_record_id = #{breedRecordId}
|
||||
WHERE id IN
|
||||
<foreach collection="embryoDetailIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 查询这批胚胎明细所属的 flush_id(去重)-->
|
||||
<select id="selectFlushIdsByEmbryoDetailIds" resultType="Long">
|
||||
SELECT DISTINCT flush_id
|
||||
FROM sc_embryo_detail
|
||||
WHERE id IN
|
||||
<foreach collection="array" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
同步冲胚记录的统计字段:
|
||||
transferred = 该 flush 下已移植明细数
|
||||
recipient_cnt = 按鲜胚/冻胚分开统计不同受体数
|
||||
由于两种类型共用同一张冲胚记录,这里分别用子查询统计:
|
||||
fresh_recipient_cnt = 鲜胚中不同 breed_record_id 的受体数
|
||||
frozen_recipient_cnt = 冻胚中不同 breed_record_id 的受体数
|
||||
recipient_cnt 取二者之和(如只有一种则另一种为0)
|
||||
-->
|
||||
<update id="syncFlushTransferredStats">
|
||||
UPDATE sc_embryo_flush ef
|
||||
SET
|
||||
ef.transferred = (
|
||||
SELECT COUNT(*) FROM sc_embryo_detail ed
|
||||
WHERE ed.flush_id = #{flushId} AND ed.is_transferred = 1
|
||||
),
|
||||
ef.recipient_cnt = (
|
||||
SELECT COUNT(DISTINCT ed2.breed_record_id)
|
||||
FROM sc_embryo_detail ed2
|
||||
WHERE ed2.flush_id = #{flushId}
|
||||
AND ed2.is_transferred = 1
|
||||
AND ed2.breed_record_id IS NOT NULL
|
||||
)
|
||||
WHERE ef.id = #{flushId}
|
||||
</update>
|
||||
|
||||
<select id="selectBreedRecordById" parameterType="Long" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
where br.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据配种记录ID查询已移植的胚胎明细 -->
|
||||
<select id="selectEmbryoDetailsByBreedRecordId" parameterType="Long" resultType="map">
|
||||
SELECT
|
||||
ed.id,
|
||||
ed.embryo_no AS embryoNo,
|
||||
ed.embryo_grade AS embryoGrade,
|
||||
ed.embryo_variety AS embryoVariety,
|
||||
ef.embryo_type AS embryoType,
|
||||
ef.storage_method AS storageMethod,
|
||||
ed.flush_id AS flushId,
|
||||
ed.breed_record_id AS breedRecordId,
|
||||
ef.donor_female_no AS donorFemaleNo,
|
||||
ef.donor_male_no AS donorMaleNo,
|
||||
ed.remark
|
||||
FROM sc_embryo_detail ed
|
||||
LEFT JOIN sc_embryo_flush ef ON ef.id = ed.flush_id
|
||||
WHERE ed.breed_record_id = #{breedRecordId}
|
||||
AND ed.is_transferred = 1
|
||||
ORDER BY ed.embryo_no
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -39,6 +39,9 @@
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<!-- 鲜胚/冻胚分开受体数(只读,由子查询计算) -->
|
||||
<result property="freshRecipientCnt" column="fresh_recipient_cnt" />
|
||||
<result property="frozenRecipientCnt" column="frozen_recipient_cnt" />
|
||||
</resultMap>
|
||||
|
||||
<!-- SQL片段:表加别名 f,新增 user_id, dept_id -->
|
||||
@@ -48,7 +51,21 @@
|
||||
f.cell_2_4, f.cell_8, f.cell_16, f.unfertilized, f.degenerated, f.total_embryo, f.valid_embryo,
|
||||
f.transferred, f.recipient_cnt, f.embryo_type, f.embryo_source, f.destination, f.storage_method,
|
||||
f.flush_operator, f.collect_operator, f.ranch_id, f.ranch_name, f.remark,
|
||||
f.user_id, f.dept_id
|
||||
f.user_id, f.dept_id,
|
||||
/* 鲜胚受体数:鲜胚明细中不重复的 breed_record_id 数 */
|
||||
(SELECT COUNT(DISTINCT ed.breed_record_id)
|
||||
FROM sc_embryo_detail ed
|
||||
WHERE ed.flush_id = f.id
|
||||
AND ed.is_transferred = 1
|
||||
AND ed.breed_record_id IS NOT NULL
|
||||
AND ed.storage_method NOT LIKE '%冻%') AS fresh_recipient_cnt,
|
||||
/* 冻胚受体数 */
|
||||
(SELECT COUNT(DISTINCT ed.breed_record_id)
|
||||
FROM sc_embryo_detail ed
|
||||
WHERE ed.flush_id = f.id
|
||||
AND ed.is_transferred = 1
|
||||
AND ed.breed_record_id IS NOT NULL
|
||||
AND ed.storage_method LIKE '%冻%') AS frozen_recipient_cnt
|
||||
from sc_embryo_flush f
|
||||
</sql>
|
||||
|
||||
@@ -215,14 +232,18 @@
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据母羊耳号查询最近一条配种记录,获取公羊耳号和配种日期 -->
|
||||
<!-- 根据母羊耳号查询最近一条配种记录,获取公羊耳号和配种日期 -->
|
||||
<select id="selectBreedRecordByEwe" resultType="java.util.Map">
|
||||
SELECT
|
||||
donor_ram AS donorMaleNo,
|
||||
create_time AS matingDate
|
||||
FROM sc_breed_record
|
||||
WHERE donor_ewe = #{eweManageTag} AND (is_delete = 0 OR is_delete IS NULL)
|
||||
ORDER BY create_time DESC
|
||||
br.donor_ram AS donorMaleNo,
|
||||
br.create_time AS matingDate,
|
||||
sf.variety AS donorMaleVariety
|
||||
FROM sc_breed_record br
|
||||
LEFT JOIN sheep_file sf ON sf.bs_manage_tags = br.donor_ram
|
||||
WHERE br.donor_ewe = #{eweManageTag}
|
||||
AND (br.is_delete = 0 OR br.is_delete IS NULL)
|
||||
ORDER BY br.create_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user