Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -47,6 +47,7 @@ public class ScBreedPlanController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出配种计划列表
|
||||
*/
|
||||
@@ -79,6 +80,8 @@ public class ScBreedPlanController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScBreedPlan scBreedPlan)
|
||||
{
|
||||
scBreedPlan.setDeptId(getDeptId());
|
||||
scBreedPlan.setUserId(getUserId());
|
||||
return toAjax(scBreedPlanService.insertScBreedPlan(scBreedPlan));
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,8 @@ public class ScBreedPlanGenerateController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScBreedPlanGenerate scBreedPlanGenerate)
|
||||
{
|
||||
scBreedPlanGenerate.setDeptId(getDeptId());
|
||||
scBreedPlanGenerate.setUserId(getUserId());
|
||||
return toAjax(scBreedPlanGenerateService.insertScBreedPlanGenerate(scBreedPlanGenerate));
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ public class ScBreedRecordController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScBreedRecord scBreedRecord)
|
||||
{
|
||||
scBreedRecord.setDeptId(getDeptId());
|
||||
scBreedRecord.setUserId(getUserId());
|
||||
// 处理母羊耳号转换
|
||||
if (scBreedRecord.getEweManageTags() != null && !scBreedRecord.getEweManageTags().isEmpty()) {
|
||||
Long eweId = scBreedRecordService.getSheepIdByTags(scBreedRecord.getEweManageTags());
|
||||
|
||||
@@ -159,6 +159,8 @@ public class ScDryMilkController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScDryMilk scDryMilk)
|
||||
{
|
||||
scDryMilk.setDeptId(getDeptId());
|
||||
scDryMilk.setUserId(getUserId());
|
||||
try {
|
||||
if (scDryMilk == null || scDryMilk.getManageTags() == null) {
|
||||
return error("耳号不能为空");
|
||||
|
||||
@@ -80,6 +80,8 @@ public class ScEmbryoFlushController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScEmbryoFlush scEmbryoFlush)
|
||||
{
|
||||
scEmbryoFlush.setDeptId(getDeptId());
|
||||
scEmbryoFlush.setUserId(getUserId());
|
||||
return toAjax(scEmbryoFlushService.insertScEmbryoFlush(scEmbryoFlush));
|
||||
}
|
||||
|
||||
|
||||
@@ -116,22 +116,41 @@ public class ScLambingRecordController extends BaseController {
|
||||
// 普通单元格样式
|
||||
CellStyle dataStyle = createDataStyle(workbook);
|
||||
|
||||
// 品种名称映射表
|
||||
Map<Integer, String> varietyMap = new java.util.HashMap<>();
|
||||
varietyMap.put(1, "湖羊"); varietyMap.put(2, "东佛里生"); varietyMap.put(3, "回交");
|
||||
varietyMap.put(4, "级杂一代"); varietyMap.put(5, "级杂二代"); varietyMap.put(6, "级杂三代");
|
||||
varietyMap.put(7, "一世代"); varietyMap.put(8, "二世代"); varietyMap.put(9, "三世代");
|
||||
varietyMap.put(10, "四世代");
|
||||
|
||||
// 产羔记录表头(与界面完全一致)
|
||||
String[] headers1 = {
|
||||
"母羊耳号", "母羊品种", "配种日期", "胎次", "公羊耳号", "公羊品种",
|
||||
"产羔数量", "活羔数量", "折损数", "技术员", "月龄", "产羔评分",
|
||||
"母羊耳号", "母羊品种", "事件类型", "产羔日期", "配种类型", "配种日期", "胎次", "公羊耳号", "公羊品种",
|
||||
"供体母羊", "供体母羊品种", "供体公羊", "供体公羊品种",
|
||||
"产羔数量", "活羔数量", "折损数",
|
||||
"羔羊品种",
|
||||
"羔羊耳号1", "羔羊1出生重", "羔羊耳号2", "羔羊2出生重",
|
||||
"羔羊耳号3", "羔羊3出生重", "羔羊耳号4", "羔羊4出生重",
|
||||
"羔羊耳号5", "羔羊5出生重", "羔羊耳号6", "羔羊6出生重",
|
||||
"羔羊耳号7", "羔羊7出生重", "羔羊耳号8", "羔羊8出生重",
|
||||
"技术员", "月龄", "产羔评分",
|
||||
"公羔数量", "母羔数量", "留养公羔数量", "留养母羔数量",
|
||||
"未留养公羔数量", "未留养母羔数量", "产羔时怀孕天数",
|
||||
"当前羊舍", "创建人", "创建日期", "所在牧场", "备注"
|
||||
"当前羊舍", "创建人", "所在牧场", "备注"
|
||||
};
|
||||
|
||||
// 列宽(字符数 * 256)
|
||||
int[] colWidths1 = {
|
||||
14, 12, 13, 8, 14, 12,
|
||||
10, 10, 8, 10, 8, 10,
|
||||
14, 12, 10, 13, 18, 13, 8, 14, 12,
|
||||
14, 12, 14, 12,
|
||||
10, 10, 8,
|
||||
12,
|
||||
14, 12, 14, 12, 14, 12, 14, 12,
|
||||
14, 12, 14, 12, 14, 12, 14, 12,
|
||||
10, 8, 10,
|
||||
10, 10, 14, 14,
|
||||
16, 16, 16,
|
||||
12, 10, 12, 12, 20
|
||||
12, 10, 12, 20
|
||||
};
|
||||
|
||||
Row headerRow1 = sheet1.createRow(0);
|
||||
@@ -151,16 +170,41 @@ public class ScLambingRecordController extends BaseController {
|
||||
int col = 0;
|
||||
setCellValue(row, col++, r.getFemaleEarNumber(), dataStyle);
|
||||
setCellValue(row, col++, r.getFemaleBreed(), dataStyle);
|
||||
setCellValue(row, col++, "产羔", dataStyle);
|
||||
setCellValue(row, col++, r.getCreateTime() != null ? dateFmt.format(r.getCreateTime()) : "", dataStyle);
|
||||
setCellValue(row, col++, getBreedTypeLabel(r.getBreedType()), dataStyle);
|
||||
setCellValue(row, col++, r.getBreedingDate() != null ? dateFmt.format(r.getBreedingDate()) : "", dataStyle);
|
||||
setCellValue(row, col++, r.getParity(), dataStyle);
|
||||
setCellValue(row, col++, r.getMaleEarNumber(), dataStyle);
|
||||
setCellValue(row, col++, r.getMaleBreed(), dataStyle);
|
||||
// 供体信息(非胚胎移植时为空)
|
||||
setCellValue(row, col++, r.getDonorEwe(), dataStyle);
|
||||
setCellValue(row, col++, r.getDonorEweBreed(), dataStyle);
|
||||
setCellValue(row, col++, r.getDonorRam(), dataStyle);
|
||||
setCellValue(row, col++, r.getDonorRamBreed(), dataStyle);
|
||||
setCellValue(row, col++, r.getLambsBorn(), dataStyle);
|
||||
setCellValue(row, col++, r.getSurvival(), dataStyle);
|
||||
// 折损数 = 产羔数 - 活羔数
|
||||
int loss = (int) ((r.getLambsBorn() != null ? r.getLambsBorn() : 0)
|
||||
- (r.getSurvival() != null ? r.getSurvival() : 0));
|
||||
setCellValue(row, col++, loss, dataStyle);
|
||||
// 羔羊品种(取第一只羔羊品种名)
|
||||
String lambBreedName = "";
|
||||
if (r.getLambDetails() != null && !r.getLambDetails().isEmpty() && r.getLambDetails().get(0).getLambBreed() != null) {
|
||||
lambBreedName = varietyMap.getOrDefault(r.getLambDetails().get(0).getLambBreed(), "");
|
||||
}
|
||||
setCellValue(row, col++, lambBreedName, dataStyle);
|
||||
// 羔羊耳号1-8 及出生重
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (r.getLambDetails() != null && i < r.getLambDetails().size()) {
|
||||
ScLambDetail d = r.getLambDetails().get(i);
|
||||
setCellValue(row, col++, d.getLambEarNumber(), dataStyle);
|
||||
setCellValue(row, col++, d.getBirthWeight() != null ? d.getBirthWeight().toPlainString() : "", dataStyle);
|
||||
} else {
|
||||
setCellValue(row, col++, "", dataStyle);
|
||||
setCellValue(row, col++, "", dataStyle);
|
||||
}
|
||||
}
|
||||
setCellValue(row, col++, r.getTechnician(), dataStyle);
|
||||
setCellValue(row, col++, r.getMonthAge(), dataStyle);
|
||||
setCellValue(row, col++, r.getScore(), dataStyle);
|
||||
@@ -173,7 +217,6 @@ public class ScLambingRecordController extends BaseController {
|
||||
setCellValue(row, col++, r.getPregnancyDays(), dataStyle);
|
||||
setCellValue(row, col++, r.getCurrentShed(), dataStyle);
|
||||
setCellValue(row, col++, r.getCreateBy(), dataStyle);
|
||||
setCellValue(row, col++, r.getCreateTime() != null ? dateFmt.format(r.getCreateTime()) : "", dataStyle);
|
||||
setCellValue(row, col++, r.getFarm(), dataStyle);
|
||||
setCellValue(row, col++, r.getComment(), dataStyle);
|
||||
}
|
||||
@@ -230,6 +273,19 @@ public class ScLambingRecordController extends BaseController {
|
||||
return workbook;
|
||||
}
|
||||
|
||||
/** 配种类型编码转文字 */
|
||||
private String getBreedTypeLabel(String breedType) {
|
||||
if (breedType == null || breedType.trim().isEmpty()) return "";
|
||||
switch (breedType.trim()) {
|
||||
case "1": return "供体母羊配种";
|
||||
case "2": return "同期发情人工授精";
|
||||
case "3": return "本交";
|
||||
case "4": return "自然发情人工授精";
|
||||
case "5": return "胚胎移植";
|
||||
default: return breedType;
|
||||
}
|
||||
}
|
||||
|
||||
/** 创建表头样式 */
|
||||
private CellStyle createHeaderStyle(XSSFWorkbook workbook) {
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
|
||||
@@ -100,6 +100,8 @@ public class ScMiscarriageRecordController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
scMiscarriageRecord.setDeptId(getDeptId());
|
||||
scMiscarriageRecord.setUserId(getUserId());
|
||||
return toAjax(scMiscarriageRecordService.insertScMiscarriageRecord(scMiscarriageRecord));
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,8 @@ public class ScPregnancyRecordController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScPregnancyRecord scPregnancyRecord)
|
||||
{
|
||||
scPregnancyRecord.setDeptId(getDeptId());
|
||||
scPregnancyRecord.setUserId(getUserId());
|
||||
try {
|
||||
// 基础参数校验
|
||||
if (scPregnancyRecord == null) {
|
||||
|
||||
@@ -140,6 +140,8 @@ public class ScSheepDeathController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScSheepDeath scSheepDeath)
|
||||
{
|
||||
scSheepDeath.setDeptId(getDeptId());
|
||||
scSheepDeath.setUserId(getUserId());
|
||||
try {
|
||||
if (scSheepDeath == null || scSheepDeath.getManageTags() == null || scSheepDeath.getManageTags().trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
|
||||
@@ -79,6 +79,8 @@ public class ScWeanRecordController extends BaseController {
|
||||
@Log(title = "断奶记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScWeanRecord scWeanRecord) {
|
||||
scWeanRecord.setDeptId(getDeptId());
|
||||
scWeanRecord.setUserId(getUserId());
|
||||
if (scWeanRecord.getEarNumber() != null) {
|
||||
Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
|
||||
if (sheepId == null) {
|
||||
|
||||
@@ -34,4 +34,7 @@ public class ScBreedPlan extends BaseEntity
|
||||
@Excel(name = "配种类型")
|
||||
private Long breedType;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ public class ScBreedPlanGenerate extends BaseEntity
|
||||
/** 审批意见 */
|
||||
private String approveRemark;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 全部羊耳号列表(用于多耳号查询) */
|
||||
private List<String> allEarNumbers;
|
||||
|
||||
@@ -67,5 +67,6 @@ public class ScBreedPlanTemp extends BaseEntity
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
}
|
||||
@@ -27,6 +27,8 @@ public class ScBreedRecord extends BaseEntity
|
||||
private Long sheepId;
|
||||
private String ramId;
|
||||
private String eweId;
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
// --- 导出及表单顺序 ---
|
||||
@Excel(name = "耳号")
|
||||
|
||||
@@ -18,6 +18,9 @@ public class ScDryMilk extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 全部羊耳号列表(用于多耳号查询) */
|
||||
private List<String> allEarNumbers;
|
||||
|
||||
@@ -130,6 +133,22 @@ public class ScDryMilk extends BaseEntity
|
||||
this.tecahnician = tecahnician;
|
||||
}
|
||||
|
||||
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 String getTecahnician()
|
||||
{
|
||||
return tecahnician;
|
||||
|
||||
@@ -139,6 +139,9 @@ public class ScEmbryoFlush extends BaseEntity
|
||||
/** 创建人 */
|
||||
private String createdBy;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdAt;
|
||||
@@ -463,6 +466,22 @@ public class ScEmbryoFlush extends BaseEntity
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
||||
@@ -135,6 +135,8 @@ public class ScLambDetail extends BaseEntity
|
||||
@Excel(name = "性别")
|
||||
private Integer gender;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
/** 出生重量 */
|
||||
@Excel(name = "出生重量")
|
||||
private BigDecimal birthWeight;
|
||||
|
||||
@@ -121,6 +121,32 @@ public class ScLambingRecord extends BaseEntity
|
||||
@Excel(name = "未留养母羔数量")
|
||||
private Integer unretainedFemaleCount;
|
||||
|
||||
/** 供体母羊耳号 */
|
||||
@Excel(name = "供体母羊")
|
||||
private String donorEwe;
|
||||
|
||||
/** 供体母羊品种 */
|
||||
@Excel(name = "供体母羊品种")
|
||||
private String donorEweBreed;
|
||||
|
||||
/** 供体公羊耳号 */
|
||||
@Excel(name = "供体公羊")
|
||||
private String donorRam;
|
||||
|
||||
/** 供体公羊品种 */
|
||||
@Excel(name = "供体公羊品种")
|
||||
private String donorRamBreed;
|
||||
|
||||
/** 移胚数 */
|
||||
@Excel(name = "移胚数")
|
||||
private Integer embryoCount;
|
||||
|
||||
/** 配种方式(用于判断是否为胚胎移植) */
|
||||
private String breedType;
|
||||
|
||||
/** 羔羊品种ID(从第一只羔羊取得,用于界面展示) */
|
||||
private Integer lambBreedId;
|
||||
|
||||
/** 全部羊耳号列表(用于多耳号查询) */
|
||||
private List<String> allEarNumbers;
|
||||
|
||||
@@ -376,6 +402,27 @@ public class ScLambingRecord extends BaseEntity
|
||||
this.lambDetails = lambDetails;
|
||||
}
|
||||
|
||||
public String getDonorEwe() { return donorEwe; }
|
||||
public void setDonorEwe(String donorEwe) { this.donorEwe = donorEwe; }
|
||||
|
||||
public String getDonorEweBreed() { return donorEweBreed; }
|
||||
public void setDonorEweBreed(String donorEweBreed) { this.donorEweBreed = donorEweBreed; }
|
||||
|
||||
public String getDonorRam() { return donorRam; }
|
||||
public void setDonorRam(String donorRam) { this.donorRam = donorRam; }
|
||||
|
||||
public String getDonorRamBreed() { return donorRamBreed; }
|
||||
public void setDonorRamBreed(String donorRamBreed) { this.donorRamBreed = donorRamBreed; }
|
||||
|
||||
public Integer getEmbryoCount() { return embryoCount; }
|
||||
public void setEmbryoCount(Integer embryoCount) { this.embryoCount = embryoCount; }
|
||||
|
||||
public String getBreedType() { return breedType; }
|
||||
public void setBreedType(String breedType) { this.breedType = breedType; }
|
||||
|
||||
public Integer getLambBreedId() { return lambBreedId; }
|
||||
public void setLambBreedId(Integer lambBreedId) { this.lambBreedId = lambBreedId; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
@@ -395,4 +442,3 @@ public class ScLambingRecord extends BaseEntity
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ public class ScMiscarriageRecord extends BaseEntity
|
||||
|
||||
/** 羊只id */
|
||||
private String sheepId;
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 事件日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@@ -289,6 +291,22 @@ public class ScMiscarriageRecord extends BaseEntity
|
||||
this.drRanch = drRanch;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
||||
@@ -25,6 +25,8 @@ public class ScPregnancyRecord extends BaseEntity
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 羊只ID */
|
||||
@Excel(name = "羊只ID")
|
||||
|
||||
@@ -17,7 +17,8 @@ import com.zhyc.common.core.domain.BaseEntity;
|
||||
public class ScSheepDeath extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
@@ -220,6 +221,21 @@ public class ScSheepDeath extends BaseEntity
|
||||
public List<String> getWorkGroupList() { return workGroupList; }
|
||||
public void setWorkGroupList(List<String> workGroupList) { this.workGroupList = workGroupList; }
|
||||
|
||||
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;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
||||
@@ -21,6 +21,8 @@ public class ScWeanRecord extends BaseEntity {
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 全部羊耳号列表(用于多耳号查询) */
|
||||
private List<String> allEarNumbers;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.module.produce.breed.domain.ScBreedPlan;
|
||||
import com.zhyc.module.produce.breed.domain.ScBreedPlanGenerate;
|
||||
import com.zhyc.module.produce.breed.mapper.ScBreedPlanGenerateMapper;
|
||||
@@ -54,8 +55,10 @@ public class ScBreedPlanGenerateServiceImpl implements IScBreedPlanGenerateServi
|
||||
* 查询配种计划生成列表
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "g", userAlias = "g") // 别名必须和 XML 中的一致!
|
||||
public List<ScBreedPlanGenerate> selectScBreedPlanGenerateList(ScBreedPlanGenerate scBreedPlanGenerate)
|
||||
{
|
||||
|
||||
return scBreedPlanGenerateMapper.selectScBreedPlanGenerateList(scBreedPlanGenerate);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.module.produce.breed.domain.ScBreedPlan;
|
||||
import com.zhyc.module.produce.breed.mapper.ScBreedPlanMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -39,6 +40,7 @@ public class ScBreedPlanServiceImpl implements IScBreedPlanService
|
||||
* @return 配种计划
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
public List<ScBreedPlan> selectScBreedPlanList(ScBreedPlan scBreedPlan)
|
||||
{
|
||||
return scBreedPlanMapper.selectScBreedPlanList(scBreedPlan);
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.zhyc.module.produce.breed.service.impl;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -70,6 +72,7 @@ public class ScBreedRecordServiceImpl implements IScBreedRecordService
|
||||
// return scBreedRecordMapper.selectScBreedRecordList(scBreedRecord);
|
||||
// }
|
||||
@Override
|
||||
@DataScope(deptAlias = "br", userAlias = "br") // 别名必须和 XML 中的一致!
|
||||
public List<ScBreedRecord> selectScBreedRecordList(ScBreedRecord scBreedRecord) {
|
||||
// ... (耳号转ID逻辑保持不变) ...
|
||||
// 如果查询条件中有耳号,需要先转换为ID (注意:供体母羊/公羊是直接存字符串的,不需要转ID,只有作为受体的eweId需要转)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -36,6 +38,7 @@ public class ScDryMilkServiceImpl implements IScDryMilkService
|
||||
* @return 干奶记录
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "d")
|
||||
public List<ScDryMilk> selectScDryMilkList(ScDryMilk scDryMilk)
|
||||
{
|
||||
return scDryMilkMapper.selectScDryMilkList(scDryMilk);
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.zhyc.module.produce.breed.service.impl;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.produce.breed.mapper.ScEmbryoFlushMapper;
|
||||
@@ -58,6 +60,7 @@ public class ScEmbryoFlushServiceImpl implements IScEmbryoFlushService
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataScope(deptAlias = "f", userAlias = "f") // 别名必须和 XML 中的一致!
|
||||
public List<ScEmbryoFlush> selectScEmbryoFlushList(ScEmbryoFlush scEmbryoFlush)
|
||||
{
|
||||
return scEmbryoFlushMapper.selectScEmbryoFlushList(scEmbryoFlush);
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.zhyc.module.produce.breed.service.impl;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -28,6 +30,7 @@ public class ScLambingRecordServiceImpl implements IScLambingRecordService {
|
||||
* 查询产羔记录列表
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "lr", userAlias = "lr") // 别名必须和 XML 中的一致!
|
||||
public List<ScLambingRecord> selectScLambingRecordList(ScLambingRecord scLambingRecord) {
|
||||
return scLambingRecordMapper.selectScLambingRecordList(scLambingRecord);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -41,6 +43,7 @@ public class ScMiscarriageRecordServiceImpl implements IScMiscarriageRecordServi
|
||||
* @return 流产记录
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "smr", userAlias = "smr") // 别名必须和 XML 中的一致!
|
||||
public List<ScMiscarriageRecord> selectScMiscarriageRecordList(ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
return scMiscarriageRecordMapper.selectScMiscarriageRecordList(scMiscarriageRecord);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,6 +34,7 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||
* @return 孕检记录
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "pr", userAlias = "pr") // 别名必须和 XML 中的一致!
|
||||
public ScPregnancyRecord selectScPregnancyRecordById(Long id)
|
||||
{
|
||||
return scPregnancyRecordMapper.selectScPregnancyRecordById(id);
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
import com.zhyc.module.biosafety.domain.Diagnosis;
|
||||
@@ -39,6 +41,7 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "d") // 别名必须和 XML 中的一致!
|
||||
public List<ScSheepDeath> selectScSheepDeathList(ScSheepDeath scSheepDeath)
|
||||
{
|
||||
return scSheepDeathMapper.selectScSheepDeathList(scSheepDeath);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -39,6 +41,7 @@ public class ScWeanRecordServiceImpl implements IScWeanRecordService
|
||||
* @return 断奶记录
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "wr", userAlias = "wr") // 别名必须和 XML 中的一致!
|
||||
public List<ScWeanRecord> selectScWeanRecordList(ScWeanRecord scWeanRecord)
|
||||
{
|
||||
return scWeanRecordMapper.selectScWeanRecordList(scWeanRecord);
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<result property="miscaLamb" column="misca_lamb" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<!-- 关联查询字段 -->
|
||||
<result property="bsManageTags" column="bs_manage_tags" />
|
||||
<result property="variety" column="variety" />
|
||||
@@ -30,6 +33,7 @@
|
||||
<result property="drRanch" column="dr_ranch" />
|
||||
</resultMap>
|
||||
|
||||
<!-- SQL片段:新增 smr.user_id, smr.dept_id -->
|
||||
<sql id="selectScMiscarriageRecordVo">
|
||||
select
|
||||
smr.id,
|
||||
@@ -43,6 +47,8 @@
|
||||
smr.misca_lamb,
|
||||
smr.create_by,
|
||||
smr.create_time,
|
||||
smr.user_id,
|
||||
smr.dept_id,
|
||||
sf.bs_manage_tags,
|
||||
sf.variety,
|
||||
sf.mating_type_id,
|
||||
@@ -67,6 +73,7 @@
|
||||
left join sheep_file sf on smr.sheep_id = sf.bs_manage_tags
|
||||
</sql>
|
||||
|
||||
<!-- 查询列表:条件已有 smr. 前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScMiscarriageRecordList" parameterType="ScMiscarriageRecord" resultMap="ScMiscarriageRecordResult">
|
||||
<include refid="selectScMiscarriageRecordVo"/>
|
||||
<where>
|
||||
@@ -80,15 +87,19 @@
|
||||
<if test="status != null"> and smr.status = #{status}</if>
|
||||
<if test="miscaLamb != null"> and smr.misca_lamb = #{miscaLamb}</if>
|
||||
<if test="variety != null and variety != ''"> and sf.variety like concat('%', #{variety}, '%')</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by smr.create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectScMiscarriageRecordById" parameterType="Long" resultMap="ScMiscarriageRecordResult">
|
||||
<include refid="selectScMiscarriageRecordVo"/>
|
||||
where smr.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 插入:新增 user_id, dept_id -->
|
||||
<insert id="insertScMiscarriageRecord" parameterType="ScMiscarriageRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_miscarriage_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -102,6 +113,9 @@
|
||||
<if test="miscaLamb != null">misca_lamb,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
@@ -114,6 +128,9 @@
|
||||
<if test="miscaLamb != null">#{miscaLamb},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -278,9 +278,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_body_measure sm
|
||||
LEFT JOIN bas_sheep bs ON sm.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
|
||||
|
||||
@@ -143,9 +143,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_body_score sbs
|
||||
LEFT JOIN bas_sheep bs ON sbs.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -155,11 +155,12 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_breast_rating sbr
|
||||
LEFT JOIN bas_sheep bs ON sbr.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
|
||||
|
||||
@@ -20,38 +20,47 @@
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
</resultMap>
|
||||
|
||||
<!-- SQL片段:加别名 g(generate的首字母) -->
|
||||
<sql id="selectScBreedPlanGenerateVo">
|
||||
select id, plan_name, plan_type, plan_date, total_ewe_count, total_ram_count,
|
||||
breed_ratio, status, approver, approve_time, approve_remark,
|
||||
create_by, create_time, update_by, update_time
|
||||
from sc_breed_plan_generate
|
||||
select g.id, g.plan_name, g.plan_type, g.plan_date, g.total_ewe_count, g.total_ram_count,
|
||||
g.breed_ratio, g.status, g.approver, g.approve_time, g.approve_remark,
|
||||
g.create_by, g.create_time, g.update_by, g.update_time,
|
||||
g.user_id, g.dept_id
|
||||
from sc_breed_plan_generate g
|
||||
</sql>
|
||||
|
||||
<!-- 查询列表:主表查询,需要加数据权限 -->
|
||||
<select id="selectScBreedPlanGenerateList" parameterType="ScBreedPlanGenerate" resultMap="ScBreedPlanGenerateResult">
|
||||
<include refid="selectScBreedPlanGenerateVo"/>
|
||||
<where>
|
||||
<if test="planName != null and planName != ''"> and plan_name like concat('%', #{planName}, '%')</if>
|
||||
<if test="planType != null"> and plan_type = #{planType}</if>
|
||||
<if test="planDate != null"> and DATE(plan_date) = DATE(#{planDate})</if>
|
||||
<if test="status != null"> and status = #{status}</if>
|
||||
<if test="planName != null and planName != ''"> and g.plan_name like concat('%', #{planName}, '%')</if>
|
||||
<if test="planType != null"> and g.plan_type = #{planType}</if>
|
||||
<if test="planDate != null"> and DATE(g.plan_date) = DATE(#{planDate})</if>
|
||||
<if test="status != null"> and g.status = #{status}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
and DATE(plan_date) >= DATE(#{params.beginTime})
|
||||
and DATE(g.plan_date) >= DATE(#{params.beginTime})
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
and DATE(plan_date) <= DATE(#{params.endTime})
|
||||
and DATE(g.plan_date) <= DATE(#{params.endTime})
|
||||
</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by create_time desc
|
||||
order by g.create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询:单条记录,也需要加别名 -->
|
||||
<select id="selectScBreedPlanGenerateById" parameterType="Long" resultMap="ScBreedPlanGenerateResult">
|
||||
<include refid="selectScBreedPlanGenerateVo"/>
|
||||
where id = #{id}
|
||||
where g.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 筛选符合条件的母羊 -->
|
||||
<!-- 筛选符合条件的母羊:关联bas_sheep,不需要数据权限 -->
|
||||
<select id="selectEligibleEwe" resultType="Map">
|
||||
select
|
||||
bs.id,
|
||||
@@ -93,7 +102,7 @@
|
||||
order by bv.variety, TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) desc
|
||||
</select>
|
||||
|
||||
<!-- 筛选符合条件的公羊 -->
|
||||
<!-- 筛选符合条件的公羊:关联bas_sheep,不需要数据权限 -->
|
||||
<select id="selectEligibleRam" resultType="Map">
|
||||
select
|
||||
bs.id,
|
||||
@@ -128,6 +137,7 @@
|
||||
order by bv.variety, TIMESTAMPDIFF(MONTH, bs.birthday, NOW()) desc
|
||||
</select>
|
||||
|
||||
<!-- 插入:新增 user_id, dept_id -->
|
||||
<insert id="insertScBreedPlanGenerate" parameterType="ScBreedPlanGenerate" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_breed_plan_generate
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -145,6 +155,8 @@
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="planName != null">#{planName},</if>
|
||||
@@ -161,13 +173,15 @@
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 插入临时配种计划 -->
|
||||
<!-- 插入临时配种计划:sc_breed_plan_temp 也需要加数据权限字段 -->
|
||||
<insert id="insertTempBreedPlan">
|
||||
insert into sc_breed_plan_temp (plan_generate_id, ram_id, ewe_id, breed_type, create_time)
|
||||
values (#{planGenerateId}, #{breedPlan.ramId}, #{breedPlan.eweId}, #{breedPlan.breedType}, now())
|
||||
insert into sc_breed_plan_temp (plan_generate_id, ram_id, ewe_id, breed_type, create_time, user_id, dept_id)
|
||||
values (#{planGenerateId}, #{breedPlan.ramId}, #{breedPlan.eweId}, #{breedPlan.breedType}, now(), #{breedPlan.userId}, #{breedPlan.deptId})
|
||||
</insert>
|
||||
|
||||
<update id="updateScBreedPlanGenerate" parameterType="ScBreedPlanGenerate">
|
||||
@@ -189,15 +203,15 @@
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 将临时配种计划转为正式配种计划 -->
|
||||
<!-- 将临时配种计划转为正式配种计划:sc_breed_plan 也需要 user_id, dept_id -->
|
||||
<insert id="transferTempToFormal">
|
||||
insert into sc_breed_plan (ram_id, ewe_id, breed_type)
|
||||
select ram_id, ewe_id, breed_type
|
||||
insert into sc_breed_plan (ram_id, ewe_id, breed_type, user_id, dept_id)
|
||||
select ram_id, ewe_id, breed_type, user_id, dept_id
|
||||
from sc_breed_plan_temp
|
||||
where plan_generate_id = #{planGenerateId}
|
||||
</insert>
|
||||
|
||||
<!-- 获取配种计划详情 - 显示完整字段信息 -->
|
||||
<!-- 获取配种计划详情:关联查询,不需要数据权限 -->
|
||||
<select id="selectBreedPlanDetails" parameterType="Long" resultType="Map">
|
||||
select
|
||||
temp.id,
|
||||
@@ -239,7 +253,7 @@
|
||||
order by temp.ewe_id, temp.ram_id
|
||||
</select>
|
||||
|
||||
<!-- 获取审批详情 - 包含完整的母羊和公羊信息 -->
|
||||
<!-- 获取审批详情:关联查询,不需要数据权限 -->
|
||||
<select id="selectApproveBreedPlanDetails" parameterType="Long" resultType="Map">
|
||||
select
|
||||
temp.id,
|
||||
@@ -316,6 +330,7 @@
|
||||
<delete id="deleteTempBreedPlanByPlanId" parameterType="Long">
|
||||
delete from sc_breed_plan_temp where plan_generate_id = #{planGenerateId}
|
||||
</delete>
|
||||
|
||||
<!-- 模糊查询耳号列表 -->
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT sf.bs_manage_tags
|
||||
|
||||
@@ -12,15 +12,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectScBreedPlanVo">
|
||||
select id, ram_id, ewe_id, breed_type from sc_breed_plan
|
||||
select s.id, s.ram_id, s.ewe_id, s.breed_type, s.user_id, s.dept_id
|
||||
from sc_breed_plan s
|
||||
</sql>
|
||||
|
||||
<!-- 修改为:条件里加别名前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScBreedPlanList" parameterType="ScBreedPlan" resultMap="ScBreedPlanResult">
|
||||
<include refid="selectScBreedPlanVo"/>
|
||||
<where>
|
||||
<if test="ramId != null and ramId != ''"> and ram_id = #{ramId}</if>
|
||||
<if test="eweId != null and eweId != ''"> and ewe_id = #{eweId}</if>
|
||||
<if test="breedType != null "> and breed_type = #{breedType}</if>
|
||||
<if test="ramId != null and ramId != ''"> and s.ram_id = #{ramId}</if>
|
||||
<if test="eweId != null and eweId != ''"> and s.ewe_id = #{eweId}</if>
|
||||
<if test="breedType != null "> and s.breed_type = #{breedType}</if>
|
||||
<!-- 数据权限控制,必须加在where末尾 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -35,11 +39,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ramId != null">ram_id,</if>
|
||||
<if test="eweId != null">ewe_id,</if>
|
||||
<if test="breedType != null">breed_type,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="ramId != null">#{ramId},</if>
|
||||
<if test="eweId != null">#{eweId},</if>
|
||||
<if test="breedType != null">#{breedType},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -49,10 +57,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ramId != null">ram_id = #{ramId},</if>
|
||||
<if test="eweId != null">ewe_id = #{eweId},</if>
|
||||
<if test="breedType != null">breed_type = #{breedType},</if>
|
||||
<!-- 通常不更新 user_id 和 dept_id,保持创建时的值 -->
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScBreedPlanById" parameterType="Long">
|
||||
delete from sc_breed_plan where id = #{id}
|
||||
</delete>
|
||||
|
||||
@@ -4,43 +4,6 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScBreedRecordMapper">
|
||||
|
||||
<!-- <resultMap type="ScBreedRecord" id="ScBreedRecordResult">-->
|
||||
<!-- <result property="id" column="id" />-->
|
||||
<!-- <result property="sheepId" column="sheep_id" />-->
|
||||
<!-- <result property="ramId" column="ram_id" />-->
|
||||
<!-- <result property="eweId" column="ewe_id" />-->
|
||||
<!-- <result property="technician" column="technician" />-->
|
||||
<!-- <result property="breedDrugs" column="breed_drugs" />-->
|
||||
<!-- <result property="breedType" column="breed_type" />-->
|
||||
<!-- <result property="createBy" column="create_by" / >-->
|
||||
<!-- <result property="createTime" column="create_time" />-->
|
||||
<!-- <!– 显示字段 –>-->
|
||||
<!-- <result property="eweManageTags" column="ewe_manage_tags" />-->
|
||||
<!-- <result property="eweVariety" column="ewe_variety" />-->
|
||||
<!-- <result property="ramManageTags" column="ram_manage_tags" />-->
|
||||
<!-- <result property="ramVariety" column="ram_variety" />-->
|
||||
<!-- <result property="eweParity" column="ewe_parity" />-->
|
||||
<!-- <result property="eweMonthAge" column="ewe_month_age" />-->
|
||||
<!-- <result property="eweSheepfoldName" column="ewe_sheepfold_name" />-->
|
||||
<!-- <result property="eweBreedStatus" column="ewe_breed_status" />-->
|
||||
<!-- <result property="eweControlled" column="ewe_controlled" />-->
|
||||
<!-- <result property="eweComment" column="ewe_comment" />-->
|
||||
<!-- <result property="ranchName" column="ranch_name" />-->
|
||||
<!-- <result property="matingType" column="mating_type" />-->
|
||||
<!-- <result property="sheepType" column="sheep_type" />-->
|
||||
<!-- <result property="matingCount" column="mating_count" />-->
|
||||
<!-- <result property="timeSincePlanning" column="time_since_planning" />-->
|
||||
<!-- <!– 孕检相关字段 –>-->
|
||||
<!-- <result property="pregnancyCheckDate" column="pregnancy_check_date" />-->
|
||||
<!-- <result property="pregnancyResult" column="pregnancy_result" />-->
|
||||
<!-- <result property="pregnancyWay" column="pregnancy_way" />-->
|
||||
<!-- <result property="fetusCount" column="fetus_count" />-->
|
||||
<!-- <result property="pregnancyTechnician" column="pregnancy_technician" />-->
|
||||
<!-- <result property="pregnancyRemark" column="pregnancy_remark" />-->
|
||||
<!-- <result property="pregnancyRecordId" column="pregnancy_record_id" />-->
|
||||
<!-- <result property="daysToPregnancyCheck" column="days_to_pregnancy_check" />-->
|
||||
<!-- <result property="isPregnancyChecked" column="is_pregnancy_checked" />-->
|
||||
<!-- </resultMap>-->
|
||||
<resultMap type="ScBreedRecord" id="ScBreedRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
@@ -49,15 +12,19 @@
|
||||
<result property="technician" column="technician" />
|
||||
<result property="breedDrugs" column="breed_drugs" />
|
||||
<result property="breedType" column="breed_type" />
|
||||
<result property="frozenSemenNo" column="frozen_sperm_no" /> <result property="createBy" column="create_by" />
|
||||
<result property="frozenSemenNo" column="frozen_sperm_no" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="comment" column="comment" />
|
||||
|
||||
<result property="embryoCount" column="embryo_count" />
|
||||
<result property="embryoSubType" column="embryoSubType" />
|
||||
<result property="donorEweNo" column="donor_ewe" />
|
||||
<result property="donorRamNo" column="donor_ram" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
|
||||
<!-- 显示字段 -->
|
||||
<result property="eweManageTags" column="ewe_manage_tags" />
|
||||
<result property="eweVariety" column="ewe_variety" />
|
||||
<result property="ramManageTags" column="ram_manage_tags" />
|
||||
@@ -71,91 +38,18 @@
|
||||
<result property="ranchName" column="ranch_name" />
|
||||
<result property="sheepType" column="sheep_type" />
|
||||
<result property="matingCount" column="mating_count" />
|
||||
|
||||
<result property="timeSincePlanning" column="time_since_planning" />
|
||||
<result property="daysPostLambing" column="days_post_lambing" />
|
||||
<result property="daysLactation" column="days_lactation" />
|
||||
<result property="daysPostMating" column="days_post_mating" />
|
||||
<result property="lastMatingDate" column="last_mating_date" />
|
||||
|
||||
<result property="pregnancyCheckDate" column="pregnancy_check_date" />
|
||||
<result property="pregnancyResult" column="pregnancy_result" />
|
||||
<result property="eweParity" column="eweParity" />
|
||||
|
||||
|
||||
<result property="pregnancyRecordId" column="pregnancy_record_id" />
|
||||
<result property="daysToPregnancyCheck" column="days_to_pregnancy_check" />
|
||||
|
||||
</resultMap>
|
||||
<!-- <sql id="selectScBreedRecordVo">-->
|
||||
<!-- select DISTINCT-->
|
||||
<!-- br.id,-->
|
||||
<!-- br.sheep_id,-->
|
||||
<!-- br.ram_id,-->
|
||||
<!-- br.ewe_id,-->
|
||||
<!-- br.technician,-->
|
||||
<!-- br.breed_drugs,-->
|
||||
<!-- br.breed_type,-->
|
||||
<!-- br.create_by,-->
|
||||
<!-- br.create_time,-->
|
||||
<!-- -- 母羊信息(从视图获取)-->
|
||||
<!-- ewe_view.bs_manage_tags as ewe_manage_tags,-->
|
||||
<!-- ewe_view.variety as ewe_variety,-->
|
||||
<!-- ewe_view.parity as ewe_parity,-->
|
||||
<!-- ewe_view.month_age as ewe_month_age,-->
|
||||
<!-- ewe_view.sheepfold_name as ewe_sheepfold_name,-->
|
||||
<!-- ewe_view.breed as ewe_breed_status,-->
|
||||
<!-- ewe_view.controlled as ewe_controlled,-->
|
||||
<!-- ewe_view.comment as ewe_comment,-->
|
||||
<!-- ewe_view.dr_ranch as ranch_name,-->
|
||||
<!-- ewe_view.name as sheep_type,-->
|
||||
<!-- ewe_view.mating_total as mating_count,-->
|
||||
<!-- -- 公羊信息(从视图获取)-->
|
||||
<!-- ram_view.bs_manage_tags as ram_manage_tags,-->
|
||||
<!-- ram_view.variety as ram_variety,-->
|
||||
|
||||
<!-- -- 配种方式显示-->
|
||||
<!-- CASE br.breed_type-->
|
||||
<!-- WHEN 1 THEN '同期发情'-->
|
||||
<!-- WHEN 2 THEN '本交'-->
|
||||
<!-- WHEN 3 THEN '冲胚'-->
|
||||
<!-- WHEN 4 THEN '自然发情人工授精'-->
|
||||
<!-- ELSE '未知'-->
|
||||
<!-- END as mating_type,-->
|
||||
<!-- -- 发情后配种时间(小时数)-->
|
||||
<!-- TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,-->
|
||||
<!-- -- 孕检相关信息-->
|
||||
<!-- pr.datetime as pregnancy_check_date,-->
|
||||
<!-- pr.result as pregnancy_result,-->
|
||||
<!-- pr.way as pregnancy_way,-->
|
||||
<!-- pr.fetus_count,-->
|
||||
<!-- pr.technician as pregnancy_technician,-->
|
||||
<!-- pr.remark as pregnancy_remark,-->
|
||||
<!-- pr.id as pregnancy_record_id,-->
|
||||
<!-- -- 配种到孕检间隔天数-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN pr.datetime IS NOT NULL THEN DATEDIFF(pr.datetime, br.create_time)-->
|
||||
<!-- ELSE NULL-->
|
||||
<!-- END as days_to_pregnancy_check,-->
|
||||
<!-- -- 是否已孕检-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN pr.id IS NOT NULL THEN 1-->
|
||||
<!-- ELSE 0-->
|
||||
<!-- END as is_pregnancy_checked-->
|
||||
<!-- from sc_breed_record br-->
|
||||
<!-- left join sheep_file ewe_view on br.ewe_id = ewe_view.id-->
|
||||
<!-- left join sheep_file ram_view on br.ram_id = ram_view.id-->
|
||||
<!-- -- 修复:使用子查询确保只返回一条孕检记录-->
|
||||
<!-- left join sc_pregnancy_record pr on pr.id = (-->
|
||||
<!-- select pr2.id-->
|
||||
<!-- from sc_pregnancy_record pr2-->
|
||||
<!-- where pr2.sheep_id = br.ewe_id-->
|
||||
<!-- and pr2.is_delete = 0-->
|
||||
<!-- and pr2.datetime >= br.create_time-->
|
||||
<!-- order by pr2.datetime asc, pr2.id asc-->
|
||||
<!-- limit 1-->
|
||||
<!-- )-->
|
||||
<!-- </sql>-->
|
||||
<!-- SQL片段:主表 sc_breed_record 加别名 br,新增 user_id, dept_id -->
|
||||
<sql id="selectScBreedRecordVo">
|
||||
select DISTINCT
|
||||
br.id,
|
||||
@@ -165,18 +59,17 @@
|
||||
br.technician,
|
||||
br.breed_drugs,
|
||||
br.breed_type,
|
||||
br.frozen_sperm_no, -- 冻精号
|
||||
br.frozen_sperm_no,
|
||||
br.embryoSubType,
|
||||
br.comment,
|
||||
br.create_by,
|
||||
br.create_time,
|
||||
|
||||
-- 胚胎移植相关字段 (如果不存表里,需要join sc_embryo_flush,这里假设存表或已有字段,如需Join请参考下方注释)
|
||||
-- 假设表里已有这些列,或者我们通过Join sheep_file 拿(但sheep_file没有donor信息)
|
||||
-- 这里按照最佳实践,应在插入时将Donor信息固化在breed_record表中
|
||||
br.donor_ewe,
|
||||
br.donor_ram,
|
||||
br.embryo_count,
|
||||
-- 新增数据权限字段
|
||||
br.user_id,
|
||||
br.dept_id,
|
||||
|
||||
-- 母羊信息
|
||||
ewe_view.bs_manage_tags as ewe_manage_tags,
|
||||
@@ -196,19 +89,17 @@
|
||||
ram_view.variety as ram_variety,
|
||||
(SELECT variety FROM sheep_file WHERE bs_manage_tags = br.donor_ewe LIMIT 1) as donorEweVariety,
|
||||
(SELECT variety FROM sheep_file WHERE bs_manage_tags = br.donor_ram LIMIT 1) as donorRamVariety,
|
||||
|
||||
-- 发情后配种时间(小时数)
|
||||
TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,
|
||||
|
||||
-- ================= 计算字段实现 =================
|
||||
|
||||
-- 1. 配种时产后天数 (距离上一次产羔: 找最近一次小于配种时间的产羔日期)
|
||||
-- 计算字段
|
||||
DATEDIFF(br.create_time, (
|
||||
SELECT lambing_date
|
||||
FROM sheep_file
|
||||
WHERE id = br.ewe_id
|
||||
)) as days_post_lambing,
|
||||
|
||||
-- 2. 配种时泌乳天数 (距离上一次孕检且怀孕)
|
||||
DATEDIFF(br.create_time, (
|
||||
SELECT MAX(pr_sub.datetime)
|
||||
FROM sc_pregnancy_record pr_sub
|
||||
@@ -218,7 +109,6 @@
|
||||
AND pr_sub.datetime < br.create_time
|
||||
)) as days_lactation,
|
||||
|
||||
-- 3. 配种时配后天数 (距离上一次配种)
|
||||
DATEDIFF(br.create_time, (
|
||||
SELECT MAX(br_sub.create_time)
|
||||
FROM sc_breed_record br_sub
|
||||
@@ -226,7 +116,6 @@
|
||||
AND br_sub.create_time < br.create_time
|
||||
)) as days_post_mating,
|
||||
|
||||
-- 4. 上次配种日期
|
||||
(
|
||||
SELECT MAX(br_sub.create_time)
|
||||
FROM sc_breed_record br_sub
|
||||
@@ -234,8 +123,6 @@
|
||||
AND br_sub.create_time < br.create_time
|
||||
) as last_mating_date,
|
||||
|
||||
-- ===============================================
|
||||
|
||||
-- 孕检相关信息
|
||||
pr.datetime as pregnancy_check_date,
|
||||
pr.result as pregnancy_result,
|
||||
@@ -244,12 +131,10 @@
|
||||
pr.technician as pregnancy_technician,
|
||||
pr.remark as pregnancy_remark,
|
||||
pr.id as pregnancy_record_id,
|
||||
-- 配种到孕检间隔天数
|
||||
CASE
|
||||
WHEN pr.datetime IS NOT NULL THEN DATEDIFF(pr.datetime, br.create_time)
|
||||
ELSE NULL
|
||||
END as days_to_pregnancy_check,
|
||||
-- 是否已孕检
|
||||
CASE
|
||||
WHEN pr.id IS NOT NULL THEN 1
|
||||
ELSE 0
|
||||
@@ -268,32 +153,8 @@
|
||||
limit 1
|
||||
)
|
||||
</sql>
|
||||
<!-- <select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">-->
|
||||
<!-- <include refid="selectScBreedRecordVo"/>-->
|
||||
<!-- <where>-->
|
||||
<!-- <if test="sheepId != null "> and br.sheep_id = #{sheepId}</if>-->
|
||||
<!-- <if test="ramId != null and ramId != ''"> and br.ram_id = #{ramId}</if>-->
|
||||
<!-- <if test="eweId != null and eweId != ''"> and br.ewe_id = #{eweId}</if>-->
|
||||
<!-- <if test="breedType != null"> and br.breed_type = #{breedType}</if>-->
|
||||
<!-- <if test="technician != null and technician != ''"> and br.technician like concat('%', #{technician}, '%')</if>-->
|
||||
<!-- <if test="breedDrugs != null and breedDrugs != ''"> and br.breed_drugs like concat('%', #{breedDrugs}, '%')</if>-->
|
||||
<!-- <if test="createBy != null and createBy != ''"> and br.create_by like concat('%', #{createBy}, '%')</if>-->
|
||||
<!-- <if test="createTime != null "> and date_format(br.create_time,'%y-%m-%d') = date_format(#{createTime},'%y-%m-%d')</if>-->
|
||||
<!-- <!– 新增耳号查询条件 –>-->
|
||||
<!-- <if test="eweManageTags != null and eweManageTags != ''"> and ewe_view.bs_manage_tags like concat('%', #{eweManageTags}, '%')</if>-->
|
||||
<!-- <if test="ramManageTags != null and ramManageTags != ''"> and ram_view.bs_manage_tags like concat('%', #{ramManageTags}, '%')</if>-->
|
||||
<!-- <if test="eweVariety != null and eweVariety != ''"> and ewe_view.variety like concat('%', #{eweVariety}, '%')</if>-->
|
||||
<!-- <if test="ramVariety != null and ramVariety != ''"> and ram_view.variety like concat('%', #{ramVariety}, '%')</if>-->
|
||||
<!-- <if test="ranchId != null"> and ewe_view.ranch_id = #{ranchId}</if>-->
|
||||
<!-- <!– 孕检相关查询条件 –>-->
|
||||
<!-- <if test="pregnancyResult != null and pregnancyResult != ''"> and pr.result like concat('%', #{pregnancyResult}, '%')</if>-->
|
||||
<!-- <if test="isPregnancyChecked != null">-->
|
||||
<!-- <if test="isPregnancyChecked == 1"> and pr.id IS NOT NULL</if>-->
|
||||
<!-- <if test="isPregnancyChecked == 0"> and pr.id IS NULL</if>-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- order by br.create_time desc-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- 查询列表:条件加 br. 前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
<where>
|
||||
@@ -305,27 +166,28 @@
|
||||
<if test="eweManageTags != null and eweManageTags != ''">
|
||||
and (
|
||||
ewe_view.bs_manage_tags like concat('%', #{eweManageTags}, '%')
|
||||
OR br.donor_ewe_no like concat('%', #{eweManageTags}, '%') -- Also search donor
|
||||
OR br.donor_ewe like concat('%', #{eweManageTags}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="ramManageTags != null and ramManageTags != ''">
|
||||
and (
|
||||
ram_view.bs_manage_tags like concat('%', #{ramManageTags}, '%')
|
||||
OR br.donor_ram like concat('%', #{ramManageTags}, '%') -- Also search donor
|
||||
OR br.donor_ram like concat('%', #{ramManageTags}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="frozenSemenNo != null and frozenSemenNo != ''"> and br.frozen_sperm_no like concat('%', #{frozenSemenNo}, '%')</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by br.create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectScBreedRecordById" parameterType="Long" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
where br.id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<!-- 根据母羊耳号查询羊只ID -->
|
||||
<select id="getSheepIdByManageTags" parameterType="String" resultType="Long">
|
||||
select id from sheep_file where bs_manage_tags = #{manageTags} and is_delete = 0
|
||||
@@ -445,34 +307,12 @@
|
||||
left join sheep_file ewe_view on bpt.ewe_id = ewe_view.id
|
||||
left join sheep_file ram_view on bpt.ram_id = ram_view.id
|
||||
where ewe_view.bs_manage_tags = #{manageTags}
|
||||
and bpg.status = 1 -- 已审批的计划
|
||||
and bpg.status = 1
|
||||
order by bpg.create_time desc, bpt.id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- <insert id="insertScBreedRecord" parameterType="ScBreedRecord" useGeneratedKeys="true" keyProperty="id">-->
|
||||
<!-- insert into sc_breed_record-->
|
||||
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
|
||||
<!-- <if test="sheepId != null">sheep_id,</if>-->
|
||||
<!-- <if test="ramId != null">ram_id,</if>-->
|
||||
<!-- <if test="eweId != null">ewe_id,</if>-->
|
||||
<!-- <if test="technician != null">technician,</if>-->
|
||||
<!-- <if test="breedDrugs != null">breed_drugs,</if>-->
|
||||
<!-- <if test="breedType != null">breed_type,</if>-->
|
||||
<!-- <if test="createBy != null">create_by,</if>-->
|
||||
<!-- <if test="createTime != null">create_time,</if>-->
|
||||
<!-- </trim>-->
|
||||
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
|
||||
<!-- <if test="sheepId != null">#{sheepId},</if>-->
|
||||
<!-- <if test="ramId != null">#{ramId},</if>-->
|
||||
<!-- <if test="eweId != null">#{eweId},</if>-->
|
||||
<!-- <if test="technician != null">#{technician},</if>-->
|
||||
<!-- <if test="breedDrugs != null">#{breedDrugs},</if>-->
|
||||
<!-- <if test="breedType != null">#{breedType},</if>-->
|
||||
<!-- <if test="createBy != null">#{createBy},</if>-->
|
||||
<!-- <if test="createTime != null">#{createTime},</if>-->
|
||||
<!-- </trim>-->
|
||||
<!-- </insert>-->
|
||||
<!-- 插入:新增 user_id, dept_id -->
|
||||
<insert id="insertScBreedRecord" parameterType="ScBreedRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_breed_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -490,6 +330,9 @@
|
||||
<if test="donorEweNo != null">donor_ewe,</if>
|
||||
<if test="donorRamNo != null">donor_ram,</if>
|
||||
<if test="embryoSubType != null">embryoSubType,</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
@@ -506,23 +349,12 @@
|
||||
<if test="donorEweNo != null">#{donorEweNo},</if>
|
||||
<if test="donorRamNo != null">#{donorRamNo},</if>
|
||||
<if test="embryoSubType != null">#{embryoSubType},</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- <update id="updateScBreedRecord" parameterType="ScBreedRecord">-->
|
||||
<!-- update sc_breed_record-->
|
||||
<!-- <trim prefix="SET" suffixOverrides=",">-->
|
||||
<!-- <if test="sheepId != null">sheep_id = #{sheepId},</if>-->
|
||||
<!-- <if test="ramId != null">ram_id = #{ramId},</if>-->
|
||||
<!-- <if test="eweId != null">ewe_id = #{eweId},</if>-->
|
||||
<!-- <if test="technician != null">technician = #{technician},</if>-->
|
||||
<!-- <if test="breedDrugs != null">breed_drugs = #{breedDrugs},</if>-->
|
||||
<!-- <if test="breedType != null">breed_type = #{breedType},</if>-->
|
||||
<!-- <if test="createBy != null">create_by = #{createBy},</if>-->
|
||||
<!-- <if test="createTime != null">create_time = #{createTime},</if>-->
|
||||
<!-- </trim>-->
|
||||
<!-- where id = #{id}-->
|
||||
<!-- </update>-->
|
||||
<update id="updateScBreedRecord" parameterType="ScBreedRecord">
|
||||
update sc_breed_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
@@ -543,6 +375,7 @@
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getFlushRecordByEweNo" parameterType="String" resultType="map">
|
||||
SELECT
|
||||
transferred,
|
||||
@@ -552,15 +385,11 @@
|
||||
storage_method
|
||||
FROM sc_embryo_flush
|
||||
WHERE id = (
|
||||
-- Assuming linking via recipient tags is complicated,
|
||||
-- usually this is done by matching a recent flush record
|
||||
-- For now, this mimics the logic in your ServiceImpl
|
||||
SELECT id FROM sc_embryo_flush WHERE donor_female_no LIKE concat('%', #{manageTags}, '%')
|
||||
ORDER BY flush_time DESC LIMIT 1
|
||||
)
|
||||
-- Note: If your sc_embryo_flush structure is different (one row per recipient), adjust accordingly.
|
||||
-- Based on provided file, it has `recipient_cnt`.
|
||||
</select>
|
||||
|
||||
<delete id="deleteScBreedRecordById" parameterType="Long">
|
||||
delete from sc_breed_record where id = #{id}
|
||||
</delete>
|
||||
@@ -572,7 +401,7 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 根据羊只ID和配种时间查询配种记录 -->
|
||||
<!-- 根据羊只ID和配种时间查询配种记录:也需要加数据权限 -->
|
||||
<select id="selectBreedRecordByMatingTime" resultMap="ScBreedRecordResult">
|
||||
<include refid="selectScBreedRecordVo"/>
|
||||
<where>
|
||||
@@ -583,6 +412,8 @@
|
||||
<if test="matingDateEnd != null and matingDateEnd != ''">
|
||||
and br.create_time <= #{matingDateEnd}
|
||||
</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by br.create_time desc
|
||||
</select>
|
||||
@@ -594,7 +425,7 @@
|
||||
where id = #{breedRecordId}
|
||||
</update>
|
||||
|
||||
<!-- 如果还需要更新配种次数(可选) -->
|
||||
<!-- 更新配种次数 -->
|
||||
<update id="incrementSheepMatingCount">
|
||||
update bas_sheep
|
||||
set mating_counts = IFNULL(mating_counts, 0) + 1,
|
||||
@@ -605,7 +436,7 @@
|
||||
where id = #{sheepId}
|
||||
and is_delete = 0
|
||||
</update>
|
||||
<!-- ====================== ScBreedRecordMapper.xml 需要添加 ====================== -->
|
||||
|
||||
<!-- 统计该公羊配了多少母羊(去重) -->
|
||||
<select id="countMatedEwesByRamId" resultType="Long">
|
||||
SELECT COUNT(DISTINCT ewe_id)
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="comment" column="comment" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<!-- 联表查询字段 -->
|
||||
<result property="manageTags" column="bs_manage_tags" />
|
||||
<result property="variety" column="variety" />
|
||||
@@ -21,22 +24,24 @@
|
||||
<result property="eventType" column="event_type" />
|
||||
</resultMap>
|
||||
|
||||
<!-- SQL片段:主表 sc_dry_milk 已有别名 d,新增 user_id, dept_id -->
|
||||
<sql id="selectScDryMilkVo">
|
||||
select d.id, d.sheep_id, d.datetime, d.status, d.sheepfold, d.tecahnician,
|
||||
d.create_by, d.create_time, d.comment,
|
||||
d.user_id, d.dept_id,
|
||||
s.bs_manage_tags, s.variety, s.sheepfold_name,
|
||||
'干奶' as event_type
|
||||
from sc_dry_milk d
|
||||
left join sheep_file s on d.sheep_id = s.id
|
||||
</sql>
|
||||
|
||||
<!-- 查询列表:条件加 d. 前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScDryMilkList" parameterType="ScDryMilk" resultMap="ScDryMilkResult">
|
||||
<include refid="selectScDryMilkVo"/>
|
||||
<where>
|
||||
<!-- 全部羊多耳号查询 -->
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
AND (
|
||||
<!-- 注意:s 代表 sheep_file 表的别名,根据实际 SQL 别名修改 -->
|
||||
s.bs_manage_tags IN
|
||||
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||
#{earNumber}
|
||||
@@ -73,6 +78,8 @@
|
||||
<if test="status != null "> and d.status = #{status}</if>
|
||||
<if test="sheepfold != null "> and d.sheepfold = #{sheepfold}</if>
|
||||
<if test="variety != null and variety != ''"> and s.variety like concat('%', #{variety}, '%')</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by d.datetime desc
|
||||
</select>
|
||||
@@ -91,17 +98,18 @@
|
||||
LIMIT 20
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectScDryMilkById" parameterType="Long" resultMap="ScDryMilkResult">
|
||||
<include refid="selectScDryMilkVo"/>
|
||||
where d.id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 根据耳号查询羊只ID -->
|
||||
<select id="selectSheepIdByManageTags" parameterType="String" resultType="Long">
|
||||
select id from sheep_file where bs_manage_tags = #{manageTags} limit 1
|
||||
</select>
|
||||
|
||||
<!-- 插入:新增 user_id, dept_id -->
|
||||
<insert id="insertScDryMilk" parameterType="ScDryMilk" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_dry_milk
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -113,6 +121,9 @@
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
@@ -123,6 +134,9 @@
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -36,40 +36,50 @@
|
||||
<result property="ranchId" column="ranch_id" />
|
||||
<result property="ranchName" column="ranch_name" />
|
||||
<result property="remark" column="remark" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
</resultMap>
|
||||
|
||||
<!-- SQL片段:表加别名 f,新增 user_id, dept_id -->
|
||||
<sql id="selectScEmbryoFlushVo">
|
||||
select id, flush_time, donor_female_no, donor_female_variety, donor_male_no, donor_male_variety,
|
||||
embryo_variety, embryo_age, grade_a_plus, grade_a, grade_b, grade_c, grade_d,
|
||||
cell_2_4, cell_8, cell_16, unfertilized, degenerated, total_embryo, valid_embryo,
|
||||
transferred, recipient_cnt, embryo_type, embryo_source, destination, storage_method,
|
||||
flush_operator, collect_operator, ranch_id, ranch_name, remark
|
||||
from sc_embryo_flush
|
||||
select f.id, f.flush_time, f.donor_female_no, f.donor_female_variety, f.donor_male_no, f.donor_male_variety,
|
||||
f.embryo_variety, f.embryo_age, f.grade_a_plus, f.grade_a, f.grade_b, f.grade_c, f.grade_d,
|
||||
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
|
||||
from sc_embryo_flush f
|
||||
</sql>
|
||||
|
||||
<!-- 查询列表:条件加 f. 前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScEmbryoFlushList" parameterType="ScEmbryoFlush" resultMap="ScEmbryoFlushResult">
|
||||
<include refid="selectScEmbryoFlushVo"/>
|
||||
<where>
|
||||
<if test="params.beginFlushTime != null and params.beginFlushTime != '' and params.endFlushTime != null and params.endFlushTime != ''">
|
||||
and flush_time between #{params.beginFlushTime} and #{params.endFlushTime}
|
||||
and f.flush_time between #{params.beginFlushTime} and #{params.endFlushTime}
|
||||
</if>
|
||||
<if test="donorFemaleNo != null and donorFemaleNo != ''"> and donor_female_no like concat('%', #{donorFemaleNo}, '%')</if>
|
||||
<if test="donorMaleNo != null and donorMaleNo != ''"> and donor_male_no like concat('%', #{donorMaleNo}, '%')</if>
|
||||
<if test="embryoVariety != null and embryoVariety != ''"> and embryo_variety = #{embryoVariety}</if>
|
||||
<if test="embryoType != null and embryoType != ''"> and embryo_type = #{embryoType}</if>
|
||||
<if test="embryoSource != null and embryoSource != ''"> and embryo_source = #{embryoSource}</if>
|
||||
<if test="flushOperator != null and flushOperator != ''"> and flush_operator like concat('%', #{flushOperator}, '%')</if>
|
||||
<if test="collectOperator != null and collectOperator != ''"> and collect_operator like concat('%', #{collectOperator}, '%')</if>
|
||||
<if test="ranchId != null"> and ranch_id = #{ranchId}</if>
|
||||
<if test="donorFemaleNo != null and donorFemaleNo != ''"> and f.donor_female_no like concat('%', #{donorFemaleNo}, '%')</if>
|
||||
<if test="donorMaleNo != null and donorMaleNo != ''"> and f.donor_male_no like concat('%', #{donorMaleNo}, '%')</if>
|
||||
<if test="embryoVariety != null and embryoVariety != ''"> and f.embryo_variety = #{embryoVariety}</if>
|
||||
<if test="embryoType != null and embryoType != ''"> and f.embryo_type = #{embryoType}</if>
|
||||
<if test="embryoSource != null and embryoSource != ''"> and f.embryo_source = #{embryoSource}</if>
|
||||
<if test="flushOperator != null and flushOperator != ''"> and f.flush_operator like concat('%', #{flushOperator}, '%')</if>
|
||||
<if test="collectOperator != null and collectOperator != ''"> and f.collect_operator like concat('%', #{collectOperator}, '%')</if>
|
||||
<if test="ranchId != null"> and f.ranch_id = #{ranchId}</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by flush_time desc
|
||||
order by f.flush_time desc
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectScEmbryoFlushById" parameterType="Long" resultMap="ScEmbryoFlushResult">
|
||||
<include refid="selectScEmbryoFlushVo"/>
|
||||
where id = #{id}
|
||||
where f.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 插入:新增 user_id, dept_id -->
|
||||
<insert id="insertScEmbryoFlush" parameterType="ScEmbryoFlush" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_embryo_flush
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -103,6 +113,9 @@
|
||||
<if test="ranchId != null">ranch_id,</if>
|
||||
<if test="ranchName != null and ranchName != ''">ranch_name,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="flushTime != null">#{flushTime},</if>
|
||||
@@ -135,6 +148,9 @@
|
||||
<if test="ranchId != null">#{ranchId},</if>
|
||||
<if test="ranchName != null and ranchName != ''">#{ranchName},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -200,10 +216,11 @@
|
||||
</select>
|
||||
|
||||
<!-- 根据母羊耳号查询最近一条配种记录,获取公羊耳号和配种日期 -->
|
||||
<!-- ewe_id存的是数字ID,需要先根据耳号找到母羊ID,再查配种记录,再根据公羊ID找到公羊耳号 -->
|
||||
<select id="selectBreedRecordByEwe" resultType="java.util.Map">
|
||||
SELECT
|
||||
donor_ram AS donorMaleNo, create_time AS matingDate FROM sc_breed_record
|
||||
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
|
||||
LIMIT 1
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
<result property="score" column="score" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<!-- 修复:数据库字段是create_tme,不是create_time -->
|
||||
<result property="createTime" column="create_tme" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 详细结果映射(包含关联信息) -->
|
||||
@@ -31,6 +33,9 @@
|
||||
<result property="comment" column="comment" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_tme" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
|
||||
<!-- 母羊信息 -->
|
||||
<result property="femaleEarNumber" column="female_ear_number" />
|
||||
@@ -54,18 +59,32 @@
|
||||
<result property="retainedFemaleCount" column="retained_female_count" />
|
||||
<result property="unretainedMaleCount" column="unretained_male_count" />
|
||||
<result property="unretainedFemaleCount" column="unretained_female_count" />
|
||||
|
||||
<!-- 供体信息(胚胎移植时有值) -->
|
||||
<result property="donorEwe" column="donor_ewe" />
|
||||
<result property="donorEweBreed" column="donor_ewe_breed" />
|
||||
<result property="donorRam" column="donor_ram" />
|
||||
<result property="donorRamBreed" column="donor_ram_breed" />
|
||||
<result property="embryoCount" column="embryo_count" />
|
||||
<result property="breedType" column="breed_type" />
|
||||
|
||||
<!-- 羔羊品种(取第一只羔羊的品种ID,前端转换为名称) -->
|
||||
<result property="lambBreedId" column="lamb_breed_id" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础查询SQL -->
|
||||
<!-- 基础查询SQL:加别名 lr,新增 user_id, dept_id -->
|
||||
<sql id="selectScLambingRecordVo">
|
||||
select id, sheep_id, parity, lambs_born, survival, technician, score, comment, create_by, create_tme from sc_lambing_record
|
||||
select lr.id, lr.sheep_id, lr.parity, lr.lambs_born, lr.survival, lr.technician, lr.score, lr.comment, lr.create_by, lr.create_tme,
|
||||
lr.user_id, lr.dept_id
|
||||
from sc_lambing_record lr
|
||||
</sql>
|
||||
|
||||
<!-- 详细查询SQL(包含关联信息) -->
|
||||
<!-- 详细查询SQL(包含关联信息):加别名 lr,新增 user_id, dept_id -->
|
||||
<sql id="selectScLambingRecordDetailVo">
|
||||
SELECT
|
||||
lr.id, lr.sheep_id, lr.parity, lr.lambs_born, lr.survival,
|
||||
lr.technician, lr.score, lr.comment, lr.create_by, lr.create_tme,
|
||||
lr.user_id, lr.dept_id,
|
||||
|
||||
-- 从sheep_file视图获取母羊信息
|
||||
mother.bs_manage_tags as female_ear_number,
|
||||
@@ -82,6 +101,17 @@
|
||||
father.bs_manage_tags as male_ear_number,
|
||||
father.variety as male_breed,
|
||||
|
||||
-- 供体信息(胚胎移植时有值)
|
||||
br.breed_type as breed_type,
|
||||
br.donor_ewe as donor_ewe,
|
||||
donor_ewe_sf.variety as donor_ewe_breed,
|
||||
br.donor_ram as donor_ram,
|
||||
donor_ram_sf.variety as donor_ram_breed,
|
||||
br.embryo_count as embryo_count,
|
||||
|
||||
-- 羔羊品种(取第一只羔羊的品种ID)
|
||||
(SELECT sld.lamb_breed FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id ORDER BY sld.id ASC LIMIT 1) as lamb_breed_id,
|
||||
|
||||
-- 统计羔羊信息(从sc_lamb_detail表统计)
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1) as male_count,
|
||||
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0) as female_count,
|
||||
@@ -99,16 +129,17 @@
|
||||
AND br2.create_time <= lr.create_tme
|
||||
)
|
||||
LEFT JOIN sheep_file father ON br.ram_id = father.id
|
||||
LEFT JOIN sheep_file donor_ewe_sf ON br.donor_ewe = donor_ewe_sf.bs_manage_tags AND donor_ewe_sf.is_delete = 0
|
||||
LEFT JOIN sheep_file donor_ram_sf ON br.donor_ram = donor_ram_sf.bs_manage_tags AND donor_ram_sf.is_delete = 0
|
||||
</sql>
|
||||
|
||||
<!-- 查询产羔记录列表(包含关联信息) -->
|
||||
<!-- 查询产羔记录列表(包含关联信息):条件加 lr. 前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScLambingRecordList" parameterType="ScLambingRecord" resultMap="ScLambingRecordDetailResult">
|
||||
<include refid="selectScLambingRecordDetailVo"/>
|
||||
<where>
|
||||
<!-- 全部羊多耳号查询 -->
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
AND (
|
||||
<!-- 注意:s 代表 sheep_file 表的别名,根据实际 SQL 别名修改 -->
|
||||
mother.bs_manage_tags IN
|
||||
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||
#{earNumber}
|
||||
@@ -133,6 +164,8 @@
|
||||
and DATE(br.create_time) <= #{params.endBreedingDate}
|
||||
</if>
|
||||
and mother.is_delete = 0
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY lr.create_tme DESC
|
||||
</select>
|
||||
@@ -140,7 +173,7 @@
|
||||
<!-- 查询产羔记录基础信息 -->
|
||||
<select id="selectScLambingRecordById" parameterType="Long" resultMap="ScLambingRecordResult">
|
||||
<include refid="selectScLambingRecordVo"/>
|
||||
where id = #{id}
|
||||
where lr.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 查询产羔记录详细信息(包含关联信息) -->
|
||||
@@ -162,10 +195,19 @@
|
||||
ram.family as male_lineage,
|
||||
br.create_time as breeding_date,
|
||||
DATEDIFF(CURDATE(), br.create_time) as pregnancy_days,
|
||||
br.technician as technician
|
||||
br.technician as technician,
|
||||
br.breed_type as breed_type,
|
||||
br.breed_sub_type as breed_sub_type,
|
||||
br.donor_ewe as donor_ewe,
|
||||
br.donor_ram as donor_ram,
|
||||
br.embryo_count as embryo_count,
|
||||
donor_ewe_sf.variety as donor_ewe_breed,
|
||||
donor_ram_sf.variety as donor_ram_breed
|
||||
FROM sheep_file sf
|
||||
LEFT JOIN sc_breed_record br ON sf.id = br.ewe_id
|
||||
LEFT JOIN sheep_file ram ON br.ram_id = ram.id
|
||||
LEFT JOIN sheep_file donor_ewe_sf ON br.donor_ewe = donor_ewe_sf.bs_manage_tags AND donor_ewe_sf.is_delete = 0
|
||||
LEFT JOIN sheep_file donor_ram_sf ON br.donor_ram = donor_ram_sf.bs_manage_tags AND donor_ram_sf.is_delete = 0
|
||||
WHERE sf.bs_manage_tags = #{earNumber}
|
||||
AND sf.is_delete = 0
|
||||
AND br.create_time = (
|
||||
@@ -175,7 +217,7 @@
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 新增产羔记录 -->
|
||||
<!-- 新增产羔记录:新增 user_id, dept_id -->
|
||||
<insert id="insertScLambingRecord" parameterType="ScLambingRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_lambing_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -188,6 +230,9 @@
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_tme,</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
@@ -199,6 +244,9 @@
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -230,15 +278,14 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- ====================== ScLambingRecordMapper.xml 需要添加 ====================== -->
|
||||
<!-- 统计公羊的后代数量 -->
|
||||
<select id="countOffspringByRamId" resultType="Long">
|
||||
SELECT IFNULL(SUM(lr.lambs_born), 0)
|
||||
FROM sc_breed_record br
|
||||
JOIN sc_lambing_record lr ON br.ewe_id = lr.sheep_id
|
||||
WHERE br.ram_id = #{ramManageTags} AND br.is_delete = 0
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 模糊查询耳号列表 -->
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT sf.bs_manage_tags
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<!-- 关联羊只信息字段 -->
|
||||
<result property="variety" column="variety" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
@@ -39,99 +42,11 @@
|
||||
<result property="donorRamVariety" column="donor_ram_variety" />
|
||||
</resultMap>
|
||||
|
||||
<!-- <sql id="selectScPregnancyRecordVo">-->
|
||||
<!-- select-->
|
||||
<!-- pr.id,-->
|
||||
<!-- pr.sheep_id,-->
|
||||
<!-- pr.datetime,-->
|
||||
<!-- pr.result,-->
|
||||
<!-- pr.fetus_count,-->
|
||||
<!-- pr.technician,-->
|
||||
<!-- pr.way,-->
|
||||
<!-- pr.remark,-->
|
||||
<!-- pr.create_by,-->
|
||||
<!-- pr.create_time,-->
|
||||
<!-- sf.bs_manage_tags as manage_tags,-->
|
||||
<!-- sf.variety,-->
|
||||
<!-- sf.month_age,-->
|
||||
<!-- sf.parity,-->
|
||||
<!-- sf.mating_counts,-->
|
||||
<!-- sf.sheepfold_name,-->
|
||||
<!-- sf.breed,-->
|
||||
<!-- sf.expected_date,-->
|
||||
<!-- sf.lambing_date as last_event_date,-->
|
||||
<!-- sf.dr_ranch as sysRanch,-->
|
||||
|
||||
<!-- -- 1. 上次孕检日期逻辑-->
|
||||
<!-- (SELECT MAX(datetime) FROM sc_pregnancy_record-->
|
||||
<!-- WHERE sheep_id = pr.sheep_id AND datetime < pr.datetime AND is_delete = 0) as last_event_date,-->
|
||||
<!-- -- 2. 配种基础信息-->
|
||||
<!-- br.create_time as mating_date,-->
|
||||
<!-- br.embryo_count,-->
|
||||
<!-- br.donor_ewe,-->
|
||||
<!-- br.donor_ram,-->
|
||||
<!-- -- 3. 配种类型映射逻辑-->
|
||||
<!-- CASE br.breed_type-->
|
||||
<!-- WHEN 1 THEN '供体母羊配种'-->
|
||||
<!-- WHEN 2 THEN '同期发情人工授精'-->
|
||||
<!-- WHEN 3 THEN '本交'-->
|
||||
<!-- WHEN 4 THEN '自然发情人工授精'-->
|
||||
<!-- WHEN 5 THEN '胚胎移植'-->
|
||||
<!-- ELSE '' END as mating_type_name,-->
|
||||
<!-- -- 4. 配种公羊品种-->
|
||||
<!-- ram_sf.bs_manage_tags as father_manage_tags,-->
|
||||
<!-- ram_sf.variety as father_variety,-->
|
||||
<!-- -- 5. 供体品种逻辑 (再次关联羊档案)-->
|
||||
<!-- donor_e_sf.variety as donor_ewe_variety,-->
|
||||
<!-- donor_r_sf.variety as donor_ram_variety-->
|
||||
<!-- FROM sc_pregnancy_record pr-->
|
||||
<!-- LEFT JOIN sheep_file sf ON pr.sheep_id = sf.id-->
|
||||
<!-- -- 关联最新的配种记录-->
|
||||
<!-- LEFT JOIN (-->
|
||||
<!-- SELECT t1.* FROM sc_breed_record t1-->
|
||||
<!-- INNER JOIN (SELECT ewe_id, MAX(create_time) as mt FROM sc_breed_record GROUP BY ewe_id) t2-->
|
||||
<!-- ON t1.ewe_id = t2.ewe_id AND t1.create_time = t2.mt-->
|
||||
<!-- ) br ON pr.sheep_id = br.ewe_id-->
|
||||
<!-- -- 关联配种公羊品种-->
|
||||
<!-- LEFT JOIN sheep_file ram_sf ON br.ram_id = ram_sf.id-->
|
||||
<!-- -- 关联供体母羊品种 (基于耳号)-->
|
||||
<!-- LEFT JOIN sheep_file donor_e_sf ON br.donor_ewe = donor_e_sf.bs_manage_tags-->
|
||||
<!-- -- 关联供体公羊品种 (基于耳号)-->
|
||||
<!-- LEFT JOIN sheep_file donor_r_sf ON br.donor_ram = donor_r_sf.bs_manage_tags-->
|
||||
<!-- -- 关联配种信息-->
|
||||
<!-- ram_sf.bs_manage_tags as father_manage_tags,-->
|
||||
<!-- ram_sf.variety as father_variety,-->
|
||||
<!-- mating_type.dict_label as mating_type_name,-->
|
||||
<!-- COALESCE(br.create_time, sf.mating_date) as mating_date,-->
|
||||
<!-- -- 计算配后天数:孕检日期 - 配种日期-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN COALESCE(br.create_time, sf.mating_date) IS NOT NULL-->
|
||||
<!-- THEN DATEDIFF(pr.datetime, COALESCE(br.create_time, sf.mating_date))-->
|
||||
<!-- ELSE NULL-->
|
||||
<!-- END as days_after_mating-->
|
||||
<!-- from sc_pregnancy_record pr-->
|
||||
<!-- INNER JOIN sheep_file sf on pr.sheep_id = sf.id-->
|
||||
<!-- -- 关联配种记录表,获取最新的配种记录-->
|
||||
<!-- left join (-->
|
||||
<!-- select br1.*-->
|
||||
<!-- from sc_breed_record br1-->
|
||||
<!-- inner join (-->
|
||||
<!-- select ewe_id, max(create_time) as max_time-->
|
||||
<!-- from sc_breed_record-->
|
||||
<!-- group by ewe_id-->
|
||||
<!-- ) br2 on br1.ewe_id = br2.ewe_id and br1.create_time = br2.max_time-->
|
||||
<!-- ) br on sf.id = br.ewe_id-->
|
||||
<!-- -- 关联公羊信息-->
|
||||
<!-- left join sheep_file ram_sf on br.ram_id = ram_sf.id-->
|
||||
<!-- -- 关联配种类型字典-->
|
||||
<!-- left join sys_dict_data mating_type on sf.mating_type_id = mating_type.dict_value-->
|
||||
<!-- and mating_type.dict_type = 'breed_type' and mating_type.status = '0'-->
|
||||
<!-- </sql>-->
|
||||
|
||||
|
||||
<!-- SQL片段:新增 pr.user_id, pr.dept_id -->
|
||||
<sql id="selectScPregnancyRecordVo">
|
||||
select
|
||||
pr.id, pr.sheep_id, pr.datetime, pr.result, pr.fetus_count, pr.technician, pr.way, pr.remark, pr.create_by, pr.create_time,pr.reason,
|
||||
pr.id, pr.sheep_id, pr.datetime, pr.result, pr.fetus_count, pr.technician, pr.way, pr.remark, pr.create_by, pr.create_time, pr.reason,
|
||||
pr.user_id, pr.dept_id,
|
||||
sf.bs_manage_tags as manage_tags, sf.variety, sf.month_age, sf.parity, sf.mating_counts, sf.sheepfold_name, sf.breed, sf.expected_date, sf.dr_ranch as sysRanch,
|
||||
(SELECT MAX(datetime) FROM sc_pregnancy_record WHERE sheep_id = pr.sheep_id AND datetime < pr.datetime AND is_delete = 0) as last_event_date,
|
||||
br.create_time as mating_date,
|
||||
@@ -156,14 +71,12 @@
|
||||
LEFT JOIN sheep_file donor_r_sf on br.donor_ram = donor_r_sf.bs_manage_tags
|
||||
</sql>
|
||||
|
||||
<!-- 重写的查询列表方法 -->
|
||||
<!-- 查询列表:条件加 pr. 前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScPregnancyRecordList" parameterType="ScPregnancyRecord" resultMap="ScPregnancyRecordResult">
|
||||
<include refid="selectScPregnancyRecordVo"/>
|
||||
|
||||
<where>
|
||||
pr.is_delete = 0
|
||||
|
||||
<!-- 正确:sf.bs_manage_tags,sf是sheep_file的别名 -->
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
AND (sf.bs_manage_tags IN
|
||||
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||
@@ -184,10 +97,13 @@
|
||||
<if test="way != null and way != ''">
|
||||
AND pr.way = #{way}
|
||||
</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by pr.create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectScPregnancyRecordById" parameterType="Long" resultMap="ScPregnancyRecordResult">
|
||||
<include refid="selectScPregnancyRecordVo"/>
|
||||
where pr.id = #{id} and pr.is_delete = 0
|
||||
@@ -218,12 +134,10 @@
|
||||
br.donor_ram as donorRam,
|
||||
donor_e_sf.variety as donorEweVariety,
|
||||
donor_r_sf.variety as donorRamVariety,
|
||||
-- 核心修改:如果是胚胎移植(5),显示供体公羊;否则显示普通配种公羊
|
||||
CASE
|
||||
WHEN br.breed_type = 5 THEN br.donor_ram
|
||||
ELSE ram_sf.bs_manage_tags
|
||||
END as fatherManageTags,
|
||||
-- 品种也需要同步切换
|
||||
CASE
|
||||
WHEN br.breed_type = 5 THEN donor_r_sf.variety
|
||||
ELSE ram_sf.variety
|
||||
@@ -234,7 +148,6 @@
|
||||
FROM sheep_file sf
|
||||
LEFT JOIN sc_breed_record br ON sf.id = br.ewe_id
|
||||
LEFT JOIN sheep_file ram_sf ON br.ram_id = ram_sf.id
|
||||
-- 新增关联:通过耳号获取供体公羊的品种信息
|
||||
LEFT JOIN sheep_file donor_r_sf ON br.donor_ram = donor_r_sf.bs_manage_tags
|
||||
LEFT JOIN sheep_file donor_e_sf ON br.donor_ewe = donor_e_sf.bs_manage_tags
|
||||
LEFT JOIN sys_dict_data mating_type ON CAST(br.breed_type AS CHAR) = mating_type.dict_value
|
||||
@@ -243,6 +156,7 @@
|
||||
ORDER BY br.create_time DESC LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 插入:新增 user_id, dept_id -->
|
||||
<insert id="insertScPregnancyRecord" parameterType="ScPregnancyRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_pregnancy_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -256,6 +170,9 @@
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
is_delete
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
@@ -269,6 +186,9 @@
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
@@ -310,7 +230,6 @@
|
||||
where id = #{sheepId}
|
||||
</update>
|
||||
|
||||
<!-- ====================== ScPregnancyRecordMapper.xml 需要添加 ====================== -->
|
||||
<!-- 统计孕检有胎的母羊数(按配种方式) -->
|
||||
<select id="countPregnantEwesByRamIdAndBreedType" resultType="Long">
|
||||
SELECT COUNT(DISTINCT pr.sheep_id)
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="isDelete" column="is_delete" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
|
||||
<result property="variety" column="variety" />
|
||||
<result property="sheepType" column="sheep_type_name" />
|
||||
@@ -35,10 +38,12 @@
|
||||
<result property="gestationDay" column="gestation_day" />
|
||||
</resultMap>
|
||||
|
||||
<!-- SQL片段:新增 d.user_id, d.dept_id -->
|
||||
<sql id="selectScSheepDeathVo">
|
||||
select d.id, d.sheep_id, d.manage_tags, d.event_type, d.death_date, d.disease_type_id, d.disease_subtype_id,
|
||||
d.disposal_direction, d.technician, d.handler, d.work_group, d.create_by, d.create_time, d.comment,
|
||||
d.update_by, d.update_time, d.is_delete,
|
||||
d.user_id, d.dept_id,
|
||||
|
||||
/* --- 关联数据获取 --- */
|
||||
/* 1. 品种名称 (假设品种表是 bas_variety) */
|
||||
@@ -68,11 +73,10 @@
|
||||
s.gestation_day
|
||||
|
||||
from sc_sheep_death d
|
||||
/* 关键修改:直接关联 bas_sheep 表,而不是视图 */
|
||||
/* 同时只通过 manage_tags 关联,忽略 status_id 的限制 */
|
||||
left join bas_sheep s on d.manage_tags = s.manage_tags AND s.is_delete = 0
|
||||
</sql>
|
||||
|
||||
<!-- 查询列表:条件已有 d. 前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScSheepDeathList" parameterType="ScSheepDeath" resultMap="ScSheepDeathResult">
|
||||
<include refid="selectScSheepDeathVo"/>
|
||||
<where>
|
||||
@@ -159,6 +163,8 @@
|
||||
AND dict_label LIKE concat('%', #{sheepType}, '%')
|
||||
)
|
||||
</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by d.create_time desc
|
||||
</select>
|
||||
@@ -181,6 +187,7 @@
|
||||
LIMIT 20
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectScSheepDeathById" parameterType="Long" resultMap="ScSheepDeathResult">
|
||||
<include refid="selectScSheepDeathVo"/>
|
||||
where d.id = #{id}
|
||||
@@ -205,6 +212,7 @@
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 插入:新增 user_id, dept_id -->
|
||||
<insert id="insertScSheepDeath" parameterType="ScSheepDeath" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_sheep_death
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -224,6 +232,9 @@
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="isDelete != null">is_delete,</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
@@ -242,6 +253,9 @@
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="isDelete != null">#{isDelete},</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="electronicTags" column="electronic_tags" />
|
||||
<!-- 新增数据权限字段映射 -->
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
|
||||
<result property="earNumber" column="bs_manage_tags" />
|
||||
<result property="breed" column="variety" />
|
||||
@@ -28,10 +31,12 @@
|
||||
<result property="breedingStatus" column="breed" />
|
||||
</resultMap>
|
||||
|
||||
<!-- SQL片段:新增 wr.user_id, wr.dept_id -->
|
||||
<sql id="selectScWeanRecordVo">
|
||||
select
|
||||
wr.id, wr.sheep_id, wr.datetime, wr.weight, wr.status, wr.technician,
|
||||
wr.comment, wr.create_by, wr.create_time, wr.electronic_tags,
|
||||
wr.user_id, wr.dept_id,
|
||||
sf.bs_manage_tags, sf.variety, sf.gender, sf.father_manage_tags, sf.mother_manage_tags,
|
||||
sf.birth_weight, sf.sheepfold_name, sf.breed, sf.month_age,
|
||||
'断奶' as event_type
|
||||
@@ -39,15 +44,13 @@
|
||||
left join sheep_file sf on wr.sheep_id = sf.id
|
||||
</sql>
|
||||
|
||||
<!-- 查询列表:条件已有 wr. 前缀,末尾加 ${params.dataScope} -->
|
||||
<select id="selectScWeanRecordList" parameterType="ScWeanRecord" resultMap="ScWeanRecordResult">
|
||||
<include refid="selectScWeanRecordVo"/>
|
||||
<where>
|
||||
<!-- 全部羊多耳号查询 -->
|
||||
<!-- 正确:sf.bs_manage_tags,sf是sheep_file的别名 -->
|
||||
<!-- 全部羊多耳号查询 -->
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
AND (
|
||||
<!-- 注意:s 代表 sheep_file 表的别名,根据实际 SQL 别名修改 -->
|
||||
sf.bs_manage_tags IN
|
||||
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||
#{earNumber}
|
||||
@@ -56,12 +59,6 @@
|
||||
</if>
|
||||
<if test="sheepId != null "> and wr.sheep_id = #{sheepId}</if>
|
||||
|
||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||
AND sf.bs_manage_tags IN
|
||||
<foreach collection="allEarNumbers" item="ear" open="(" separator="," close=")">
|
||||
#{ear}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="(allEarNumbers == null or allEarNumbers.size() == 0) and earNumber != null and earNumber != ''">
|
||||
and sf.bs_manage_tags like concat('%', #{earNumber}, '%')
|
||||
</if>
|
||||
@@ -93,6 +90,8 @@
|
||||
<if test="fatherNumber != null and fatherNumber != ''"> and sf.father_manage_tags like concat('%', #{fatherNumber}, '%')</if>
|
||||
<if test="motherNumber != null and motherNumber != ''"> and sf.mother_manage_tags like concat('%', #{motherNumber}, '%')</if>
|
||||
<if test="sheepPen != null and sheepPen != ''"> and sf.sheepfold_name like concat('%', #{sheepPen}, '%')</if>
|
||||
<!-- 数据权限控制 -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by wr.create_time desc
|
||||
</select>
|
||||
@@ -107,6 +106,7 @@
|
||||
LIMIT 50
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectScWeanRecordById" parameterType="Long" resultMap="ScWeanRecordResult">
|
||||
<include refid="selectScWeanRecordVo"/>
|
||||
where wr.id = #{id}
|
||||
@@ -116,6 +116,7 @@
|
||||
select id from sheep_file where bs_manage_tags = #{earNumber}
|
||||
</select>
|
||||
|
||||
<!-- 插入:新增 user_id, dept_id -->
|
||||
<insert id="insertScWeanRecord" parameterType="ScWeanRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_wean_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -128,6 +129,9 @@
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="electronicTags != null">electronic_tags,</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
@@ -139,6 +143,9 @@
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="electronicTags != null">#{electronicTags},</if>
|
||||
<!-- 新增数据权限字段 -->
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -139,9 +139,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_change_comment scc
|
||||
LEFT JOIN bas_sheep bs ON scc.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -152,9 +152,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_change_ear sce
|
||||
LEFT JOIN bas_sheep bs ON sce.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -139,9 +139,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_change_variety scv
|
||||
LEFT JOIN bas_sheep bs ON scv.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -163,9 +163,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT s.manage_tags
|
||||
FROM bas_sheep s
|
||||
FROM sc_trans_group tg
|
||||
LEFT JOIN bas_sheep s ON tg.sheep_id = s.id
|
||||
WHERE s.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND s.is_delete = 0
|
||||
ORDER BY s.manage_tags
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -187,9 +187,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_transition_info t
|
||||
LEFT JOIN bas_sheep bs ON t.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -137,9 +137,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_castrate sc
|
||||
LEFT JOIN bas_sheep bs ON sc.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -134,9 +134,9 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs.manage_tags
|
||||
FROM bas_sheep bs
|
||||
FROM sc_fix_hoof fh
|
||||
LEFT JOIN bas_sheep bs ON fh.sheep_id = bs.id
|
||||
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
|
||||
AND bs.is_delete = 0
|
||||
ORDER BY bs.manage_tags
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user