Compare commits
2 Commits
32718378c9
...
13e0f68289
| Author | SHA1 | Date | |
|---|---|---|---|
| 13e0f68289 | |||
| b911a29167 |
@@ -28,16 +28,35 @@ public class NpMilkProdClassesController extends BaseController {
|
|||||||
public TableDataInfo list(
|
public TableDataInfo list(
|
||||||
@RequestParam(required = false) Date datetimeStart,
|
@RequestParam(required = false) Date datetimeStart,
|
||||||
@RequestParam(required = false) Date datetimeEnd,
|
@RequestParam(required = false) Date datetimeEnd,
|
||||||
@RequestParam(required = false) String manageEarNo, // 改为单个字符串,模糊
|
@RequestParam(required = false) List<String> allEarNumbers, // 修改处:接收多耳号数组
|
||||||
@RequestParam(required = false) String factory,
|
@RequestParam(required = false) String factory,
|
||||||
@RequestParam(required = false) Integer classes) {
|
@RequestParam(required = false) Integer classes) {
|
||||||
startPage();
|
startPage();
|
||||||
|
// 修改处:将参数封装进实体,以便 Service 和 Mapper 统一处理
|
||||||
|
NpMilkProdClasses params = new NpMilkProdClasses();
|
||||||
|
params.setAllEarNumbers(allEarNumbers);
|
||||||
|
params.setFactory(factory);
|
||||||
|
params.setClasses(classes);
|
||||||
|
|
||||||
List<NpMilkProdClasses> list = npMilkProdClassesService
|
List<NpMilkProdClasses> list = npMilkProdClassesService
|
||||||
.selectNpMilkProdClassesList(datetimeStart, datetimeEnd,
|
.selectNpMilkProdClassesList(params, datetimeStart, datetimeEnd);
|
||||||
manageEarNo, factory, classes);
|
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改处:新增耳号模糊查询接口
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('milkProdclasses:milkProdclasses:list')")
|
||||||
|
@GetMapping("/search_ear_numbers")
|
||||||
|
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
|
||||||
|
try {
|
||||||
|
List<String> earNumbers = npMilkProdClassesService.searchEarNumbers(query);
|
||||||
|
return success(earNumbers);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("搜索耳号失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('milkProdclasses:milkProdclasses:import')")
|
@PreAuthorize("@ss.hasPermi('milkProdclasses:milkProdclasses:import')")
|
||||||
@Log(title = "班次产奶", businessType = BusinessType.IMPORT)
|
@Log(title = "班次产奶", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/import")
|
@PostMapping("/import")
|
||||||
@@ -58,14 +77,19 @@ public class NpMilkProdClassesController extends BaseController {
|
|||||||
public void export(HttpServletResponse response,
|
public void export(HttpServletResponse response,
|
||||||
@RequestParam(required = false) Date datetimeStart,
|
@RequestParam(required = false) Date datetimeStart,
|
||||||
@RequestParam(required = false) Date datetimeEnd,
|
@RequestParam(required = false) Date datetimeEnd,
|
||||||
@RequestParam(required = false) String manageEarNo,
|
@RequestParam(required = false) List<String> allEarNumbers, // 修改处:接收多耳号
|
||||||
@RequestParam(required = false) String factory,
|
@RequestParam(required = false) String factory,
|
||||||
@RequestParam(required = false) Integer classes) {
|
@RequestParam(required = false) Integer classes) {
|
||||||
|
|
||||||
|
NpMilkProdClasses params = new NpMilkProdClasses();
|
||||||
|
params.setAllEarNumbers(allEarNumbers);
|
||||||
|
params.setFactory(factory);
|
||||||
|
params.setClasses(classes);
|
||||||
|
|
||||||
List<NpMilkProdClasses> list = npMilkProdClassesService.selectNpMilkProdClassesList(
|
List<NpMilkProdClasses> list = npMilkProdClassesService.selectNpMilkProdClassesList(
|
||||||
datetimeStart, datetimeEnd, manageEarNo, factory, classes);
|
params, datetimeStart, datetimeEnd);
|
||||||
|
|
||||||
ExcelUtil<NpMilkProdClasses> util = new ExcelUtil<>(NpMilkProdClasses.class);
|
ExcelUtil<NpMilkProdClasses> util = new ExcelUtil<>(NpMilkProdClasses.class);
|
||||||
util.exportExcel(response, list, "班次产奶数据");
|
util.exportExcel(response, list, "班次产奶数据");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 奶产量分析控制器
|
* 奶产量分析控制器
|
||||||
* 只保留:分页列表(只读) + 单条查询 + 导出
|
* 保留:分页列表(只读) + 单条查询 + 导出 + 耳号模糊查询
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dairyProducts/sheepMilkAnalysis")
|
@RequestMapping("/dairyProducts/sheepMilkAnalysis")
|
||||||
@@ -26,15 +26,36 @@ public class NpSheepMilkAnalysisController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询奶产量分析列表(只读,分页)
|
* 查询奶产量分析列表(只读,分页)
|
||||||
* 支持参数 manageEarTag(耳号模糊) 和 screenDays(筛选天数)
|
* 支持参数 allEarNumbers(多耳号) 和 screenDays(筛选天数)
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(NpSheepMilkAnalysis analysis) {
|
public TableDataInfo list(
|
||||||
startPage(); // 使用PageHelper分页(注意service中第一个DB调用是distinct sheep id)
|
@RequestParam(required = false) List<String> allEarNumbers, // 修改处:接收多耳号参数
|
||||||
|
NpSheepMilkAnalysis analysis) {
|
||||||
|
startPage();
|
||||||
|
|
||||||
|
// 修改处:将接收到的 list 设置进对象
|
||||||
|
if (allEarNumbers != null && !allEarNumbers.isEmpty()) {
|
||||||
|
analysis.setAllEarNumbers(allEarNumbers);
|
||||||
|
}
|
||||||
|
|
||||||
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis);
|
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改处:新增搜索耳号接口
|
||||||
|
*/
|
||||||
|
@GetMapping("/search_ear_numbers")
|
||||||
|
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
|
||||||
|
try {
|
||||||
|
List<String> earNumbers = npSheepMilkAnalysisService.searchEarNumbers(query);
|
||||||
|
return success(earNumbers);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("搜索耳号失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单个分析记录详细信息(按sheepId)
|
* 获取单个分析记录详细信息(按sheepId)
|
||||||
*/
|
*/
|
||||||
@@ -45,11 +66,18 @@ public class NpSheepMilkAnalysisController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出奶产量分析记录(Excel)
|
* 导出奶产量分析记录(Excel)
|
||||||
* 支持manageEarTag与screenDays两个查询条件
|
* 支持 allEarNumbers 与 screenDays 两个查询条件
|
||||||
*/
|
*/
|
||||||
@Log(title = "奶产量分析 导出", businessType = BusinessType.EXPORT)
|
@Log(title = "奶产量分析 导出", businessType = BusinessType.EXPORT)
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(NpSheepMilkAnalysis analysis) {
|
public AjaxResult export(
|
||||||
|
@RequestParam(required = false) List<String> allEarNumbers, // 修改处:接收多耳号参数
|
||||||
|
NpSheepMilkAnalysis analysis) {
|
||||||
|
|
||||||
|
if (allEarNumbers != null && !allEarNumbers.isEmpty()) {
|
||||||
|
analysis.setAllEarNumbers(allEarNumbers);
|
||||||
|
}
|
||||||
|
|
||||||
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisForExport(analysis);
|
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisForExport(analysis);
|
||||||
ExcelUtil<NpSheepMilkAnalysis> util = new ExcelUtil<>(NpSheepMilkAnalysis.class);
|
ExcelUtil<NpSheepMilkAnalysis> util = new ExcelUtil<>(NpSheepMilkAnalysis.class);
|
||||||
return util.exportExcel(list, "羊奶产量分析数据");
|
return util.exportExcel(list, "羊奶产量分析数据");
|
||||||
|
|||||||
@@ -2,20 +2,19 @@ package com.zhyc.module.dairyProducts.domain;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List; // 引入 List
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.zhyc.common.annotation.Excel;
|
import com.zhyc.common.annotation.Excel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class NpMilkProdClasses implements Serializable {
|
public class NpMilkProdClasses implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Long id; // 主键ID
|
private Long id;
|
||||||
private Date createTime; // 创建时间
|
private Date createTime;
|
||||||
private Date updateTime; // 更新时间
|
private Date updateTime;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "日期", dateFormat = "yyyy-MM-dd") // 添加日期格式
|
@Excel(name = "日期", dateFormat = "yyyy-MM-dd")
|
||||||
private Date datetime;
|
private Date datetime;
|
||||||
|
|
||||||
@Excel(name = "管理耳号")
|
@Excel(name = "管理耳号")
|
||||||
@@ -41,7 +40,19 @@ public class NpMilkProdClasses implements Serializable {
|
|||||||
|
|
||||||
private String sheepId;
|
private String sheepId;
|
||||||
|
|
||||||
|
// 修改处:新增字段用于多耳号查询
|
||||||
|
/** 全部羊耳号列表(用于多耳号查询) */
|
||||||
|
private List<String> allEarNumbers;
|
||||||
|
|
||||||
// Getters and Setters
|
// Getters and Setters
|
||||||
|
public List<String> getAllEarNumbers() {
|
||||||
|
return allEarNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllEarNumbers(List<String> allEarNumbers) {
|
||||||
|
this.allEarNumbers = allEarNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() { return id; }
|
public Long getId() { return id; }
|
||||||
public void setId(Long id) { this.id = id; }
|
public void setId(Long id) { this.id = id; }
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.zhyc.module.dairyProducts.domain;
|
|||||||
|
|
||||||
import com.zhyc.common.annotation.Excel;
|
import com.zhyc.common.annotation.Excel;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List; // 导入List
|
||||||
|
|
||||||
public class NpSheepMilkAnalysis {
|
public class NpSheepMilkAnalysis {
|
||||||
// 唯一键(可用于前端 row-key)
|
// 唯一键(可用于前端 row-key)
|
||||||
@@ -12,6 +13,10 @@ public class NpSheepMilkAnalysis {
|
|||||||
@Excel(name = "耳号")
|
@Excel(name = "耳号")
|
||||||
private String manageEarTag;
|
private String manageEarTag;
|
||||||
|
|
||||||
|
// 修改处:新增多耳号字段
|
||||||
|
/** 全部羊耳号列表(用于多耳号查询) */
|
||||||
|
private List<String> allEarNumbers;
|
||||||
|
|
||||||
@Excel(name = "品种")
|
@Excel(name = "品种")
|
||||||
private String variety;
|
private String variety;
|
||||||
|
|
||||||
@@ -139,6 +144,16 @@ public class NpSheepMilkAnalysis {
|
|||||||
private Date lastUpdate;
|
private Date lastUpdate;
|
||||||
|
|
||||||
// getters and setters
|
// getters and setters
|
||||||
|
|
||||||
|
// 修改处:添加 allEarNumbers 的 getter/setter
|
||||||
|
public List<String> getAllEarNumbers() {
|
||||||
|
return allEarNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllEarNumbers(List<String> allEarNumbers) {
|
||||||
|
this.allEarNumbers = allEarNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSheepId() { return sheepId; }
|
public String getSheepId() { return sheepId; }
|
||||||
public void setSheepId(String sheepId) { this.sheepId = sheepId; }
|
public void setSheepId(String sheepId) { this.sheepId = sheepId; }
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface NpMilkProdClassesMapper {
|
public interface NpMilkProdClassesMapper {
|
||||||
|
// 修改处:参数改为接收实体类
|
||||||
List<NpMilkProdClasses> selectNpMilkProdClassesList(
|
List<NpMilkProdClasses> selectNpMilkProdClassesList(
|
||||||
|
@Param("npMilkProdClasses") NpMilkProdClasses npMilkProdClasses,
|
||||||
@Param("datetimeStart") Date datetimeStart,
|
@Param("datetimeStart") Date datetimeStart,
|
||||||
@Param("datetimeEnd") Date datetimeEnd,
|
@Param("datetimeEnd") Date datetimeEnd);
|
||||||
@Param("manageEarNo") String manageEarNo,
|
|
||||||
@Param("factory") String factory,
|
// 修改处:新增搜索方法
|
||||||
@Param("classes") Integer classes);
|
List<String> searchEarNumbers(@Param("query") String query);
|
||||||
|
|
||||||
int insertNpMilkProdClasses(NpMilkProdClasses row);
|
int insertNpMilkProdClasses(NpMilkProdClasses row);
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,14 @@ public interface NpSheepMilkAnalysisMapper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据管理耳标筛选,返回distinct的sheepId列表
|
* 根据管理耳标筛选,返回distinct的sheepId列表
|
||||||
|
* 修改处:参数改为对象,支持 allEarNumbers
|
||||||
*/
|
*/
|
||||||
List<String> selectDistinctSheepIds(@Param("manageEarTag") String manageEarTag);
|
List<String> selectDistinctSheepIds(NpSheepMilkAnalysis analysis);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改处:新增耳号模糊查询接口
|
||||||
|
*/
|
||||||
|
List<String> searchEarNumbers(@Param("query") String query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据羊只ID查询羊只档案信息,返回Map结构
|
* 根据羊只ID查询羊只档案信息,返回Map结构
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ import java.util.List;
|
|||||||
import com.zhyc.module.dairyProducts.domain.NpMilkProdClasses;
|
import com.zhyc.module.dairyProducts.domain.NpMilkProdClasses;
|
||||||
|
|
||||||
public interface INpMilkProdClassesService {
|
public interface INpMilkProdClassesService {
|
||||||
|
// 修改处:参数改为接收实体类,以包含多耳号列表
|
||||||
List<NpMilkProdClasses> selectNpMilkProdClassesList(
|
List<NpMilkProdClasses> selectNpMilkProdClassesList(
|
||||||
|
NpMilkProdClasses npMilkProdClasses,
|
||||||
Date datetimeStart,
|
Date datetimeStart,
|
||||||
Date datetimeEnd,
|
Date datetimeEnd);
|
||||||
String manageEarNo, // 改为单个 String
|
|
||||||
String factory,
|
// 修改处:新增耳号搜索方法
|
||||||
Integer classes);
|
List<String> searchEarNumbers(String query);
|
||||||
|
|
||||||
int importMilkProdClasses(List<NpMilkProdClasses> list);
|
int importMilkProdClasses(List<NpMilkProdClasses> list);
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,9 @@ public interface INpSheepMilkAnalysisService {
|
|||||||
|
|
||||||
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis);
|
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis);
|
||||||
|
|
||||||
|
// 修改处:新增模糊查询方法定义
|
||||||
|
List<String> searchEarNumbers(String query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出奶产量分析记录
|
* 导出奶产量分析记录
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,26 +16,29 @@ public class NpMilkProdClassesServiceImpl implements INpMilkProdClassesService {
|
|||||||
private NpMilkProdClassesMapper mapper;
|
private NpMilkProdClassesMapper mapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NpMilkProdClasses> selectNpMilkProdClassesList(Date datetimeStart, Date datetimeEnd,
|
public List<NpMilkProdClasses> selectNpMilkProdClassesList(NpMilkProdClasses npMilkProdClasses, Date datetimeStart, Date datetimeEnd) {
|
||||||
String manageEarNo, String factory, Integer classes) {
|
// 修改处:传递实体对象
|
||||||
return mapper.selectNpMilkProdClassesList(datetimeStart, datetimeEnd, manageEarNo, factory, classes);
|
return mapper.selectNpMilkProdClassesList(npMilkProdClasses, datetimeStart, datetimeEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改处:实现搜索方法
|
||||||
|
@Override
|
||||||
|
public List<String> searchEarNumbers(String query) {
|
||||||
|
return mapper.searchEarNumbers(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int importMilkProdClasses(List<NpMilkProdClasses> list) {
|
public int importMilkProdClasses(List<NpMilkProdClasses> list) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (NpMilkProdClasses item : list) {
|
for (NpMilkProdClasses item : list) {
|
||||||
// 根据管理耳号查 sheep_id
|
|
||||||
String sheepId = mapper.selectSheepIdByManageEarNo(item.getManageEarNo());
|
String sheepId = mapper.selectSheepIdByManageEarNo(item.getManageEarNo());
|
||||||
if (sheepId == null) continue;
|
if (sheepId == null) continue;
|
||||||
|
|
||||||
item.setSheepId(sheepId);
|
item.setSheepId(sheepId);
|
||||||
|
|
||||||
// 计算校正奶量
|
|
||||||
Double correctedMilk = calculateCorrectedMilk(item);
|
Double correctedMilk = calculateCorrectedMilk(item);
|
||||||
item.setCorrectedMilk(correctedMilk);
|
item.setCorrectedMilk(correctedMilk);
|
||||||
|
|
||||||
// 插入数据
|
|
||||||
count += mapper.insertNpMilkProdClasses(item);
|
count += mapper.insertNpMilkProdClasses(item);
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
@@ -45,15 +48,12 @@ public class NpMilkProdClassesServiceImpl implements INpMilkProdClassesService {
|
|||||||
Double milk = item.getMilk();
|
Double milk = item.getMilk();
|
||||||
if (milk == null) return null;
|
if (milk == null) return null;
|
||||||
|
|
||||||
// 1. 称重矫正系数
|
|
||||||
Double weightCorrection = mapper.getWeightCorrection(item.getDatetime(), item.getFactory());
|
Double weightCorrection = mapper.getWeightCorrection(item.getDatetime(), item.getFactory());
|
||||||
if (weightCorrection == null) weightCorrection = 1.0;
|
if (weightCorrection == null) weightCorrection = 1.0;
|
||||||
|
|
||||||
// 2. 胎次矫正系数
|
|
||||||
Double parityCorrection = mapper.getParityCorrection(item.getParity());
|
Double parityCorrection = mapper.getParityCorrection(item.getParity());
|
||||||
if (parityCorrection == null) parityCorrection = 1.0;
|
if (parityCorrection == null) parityCorrection = 1.0;
|
||||||
|
|
||||||
// 3. 干物质矫正系数
|
|
||||||
Double dryMatterCorrection = mapper.getDryMatterCorrection(item.getDatetime(), item.getFactory());
|
Double dryMatterCorrection = mapper.getDryMatterCorrection(item.getDatetime(), item.getFactory());
|
||||||
if (dryMatterCorrection == null) dryMatterCorrection = 1.0;
|
if (dryMatterCorrection == null) dryMatterCorrection = 1.0;
|
||||||
|
|
||||||
|
|||||||
@@ -47,12 +47,19 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
|
|||||||
return ana;
|
return ana;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 修改处:新增模糊查询实现
|
||||||
|
@Override
|
||||||
|
public List<String> searchEarNumbers(String query) {
|
||||||
|
return npSheepMilkAnalysisMapper.searchEarNumbers(query);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis) {
|
public List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis) {
|
||||||
int screenDays = (analysis != null && analysis.getScreenDays() != null) ? analysis.getScreenDays() : 100;
|
int screenDays = (analysis != null && analysis.getScreenDays() != null) ? analysis.getScreenDays() : 100;
|
||||||
String manageEarTagFilter = (analysis != null) ? analysis.getManageEarTag() : null;
|
|
||||||
|
|
||||||
List<String> sheepIds = npSheepMilkAnalysisMapper.selectDistinctSheepIds(manageEarTagFilter);
|
// 修改处:这里改为直接传 analysis 对象,以便 mapper 可以处理 allEarNumbers
|
||||||
|
List<String> sheepIds = npSheepMilkAnalysisMapper.selectDistinctSheepIds(analysis);
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(sheepIds)) return Collections.emptyList();
|
if (CollectionUtils.isEmpty(sheepIds)) return Collections.emptyList();
|
||||||
|
|
||||||
List<NpSheepMilkAnalysis> resultList = new ArrayList<>();
|
List<NpSheepMilkAnalysis> resultList = new ArrayList<>();
|
||||||
|
|||||||
@@ -19,14 +19,13 @@
|
|||||||
SELECT
|
SELECT
|
||||||
mpc.id,
|
mpc.id,
|
||||||
mpc.datetime,
|
mpc.datetime,
|
||||||
v.bs_manage_tags, <!-- 取消别名,使用原列名 -->
|
v.bs_manage_tags,
|
||||||
v.electronic_tags,
|
v.electronic_tags,
|
||||||
v.parity,
|
v.parity,
|
||||||
v.dr_ranch,
|
v.dr_ranch,
|
||||||
mpc.classes,
|
mpc.classes,
|
||||||
mpc.milk,
|
mpc.milk,
|
||||||
mpc.corrected_milk AS corrected_milk
|
mpc.corrected_milk AS corrected_milk
|
||||||
<!-- 修改为与 resultMap 对应的列名 -->
|
|
||||||
FROM np_milk_prod_classes mpc
|
FROM np_milk_prod_classes mpc
|
||||||
JOIN sheep_file v ON mpc.sheep_id = v.id
|
JOIN sheep_file v ON mpc.sheep_id = v.id
|
||||||
LEFT JOIN xz_wegih_correction wc ON DATE(mpc.datetime) = DATE(wc.datetime) AND v.dr_ranch = wc.factory
|
LEFT JOIN xz_wegih_correction wc ON DATE(mpc.datetime) = DATE(wc.datetime) AND v.dr_ranch = wc.factory
|
||||||
@@ -39,19 +38,34 @@
|
|||||||
<if test="datetimeEnd != null">
|
<if test="datetimeEnd != null">
|
||||||
AND mpc.datetime <= #{datetimeEnd}
|
AND mpc.datetime <= #{datetimeEnd}
|
||||||
</if>
|
</if>
|
||||||
<if test="manageEarNo != null and manageEarNo != ''">
|
|
||||||
AND v.bs_manage_tags LIKE CONCAT('%', #{manageEarNo}, '%')
|
<if test="npMilkProdClasses.allEarNumbers != null and npMilkProdClasses.allEarNumbers.size() > 0">
|
||||||
|
AND (
|
||||||
|
v.bs_manage_tags IN
|
||||||
|
<foreach collection="npMilkProdClasses.allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||||
|
#{earNumber}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="factory != null and factory != ''">
|
|
||||||
AND v.dr_ranch = #{factory}
|
<if test="npMilkProdClasses.factory != null and npMilkProdClasses.factory != ''">
|
||||||
|
AND v.dr_ranch = #{npMilkProdClasses.factory}
|
||||||
</if>
|
</if>
|
||||||
<if test="classes != null">
|
<if test="npMilkProdClasses.classes != null">
|
||||||
AND mpc.classes = #{classes}
|
AND mpc.classes = #{npMilkProdClasses.classes}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 称重矫正系数 -->
|
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||||
|
SELECT DISTINCT sf.bs_manage_tags
|
||||||
|
FROM sheep_file sf
|
||||||
|
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||||
|
AND sf.is_delete = 0
|
||||||
|
ORDER BY sf.bs_manage_tags
|
||||||
|
LIMIT 50
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getWeightCorrection" resultType="java.lang.Double">
|
<select id="getWeightCorrection" resultType="java.lang.Double">
|
||||||
SELECT actual / system_milk
|
SELECT actual / system_milk
|
||||||
FROM xz_wegih_correction
|
FROM xz_wegih_correction
|
||||||
@@ -60,7 +74,6 @@
|
|||||||
AND system_milk > 0
|
AND system_milk > 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 胎次矫正系数 -->
|
|
||||||
<select id="getParityCorrection" resultType="java.lang.Double">
|
<select id="getParityCorrection" resultType="java.lang.Double">
|
||||||
SELECT
|
SELECT
|
||||||
CASE
|
CASE
|
||||||
@@ -72,7 +85,6 @@
|
|||||||
WHERE parity = #{parity}
|
WHERE parity = #{parity}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 干物质矫正系数 -->
|
|
||||||
<select id="getDryMatterCorrection" resultType="java.lang.Double">
|
<select id="getDryMatterCorrection" resultType="java.lang.Double">
|
||||||
SELECT coefficient
|
SELECT coefficient
|
||||||
FROM xz_dry_matter_correction
|
FROM xz_dry_matter_correction
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhyc.module.dairyProducts.mapper.NpSheepMilkAnalysisMapper">
|
<mapper namespace="com.zhyc.module.dairyProducts.mapper.NpSheepMilkAnalysisMapper">
|
||||||
|
|
||||||
<!-- 1) 获取distinct sheep_id(支持按sheep_file.bs_manage_tags模糊搜索) -->
|
<select id="selectDistinctSheepIds" resultType="string" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||||
<select id="selectDistinctSheepIds" resultType="string" parameterType="map">
|
|
||||||
SELECT DISTINCT a.sheep_id
|
SELECT DISTINCT a.sheep_id
|
||||||
FROM np_milk_prod_classes a
|
FROM np_milk_prod_classes a
|
||||||
LEFT JOIN sheep_file sf ON a.sheep_id = sf.id
|
LEFT JOIN sheep_file sf ON a.sheep_id = sf.id
|
||||||
@@ -13,12 +12,27 @@
|
|||||||
<if test="manageEarTag != null and manageEarTag != ''">
|
<if test="manageEarTag != null and manageEarTag != ''">
|
||||||
AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%')
|
AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||||
|
AND (
|
||||||
|
sf.bs_manage_tags IN
|
||||||
|
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||||
|
#{earNumber}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
ORDER BY a.sheep_id
|
ORDER BY a.sheep_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 2) 获取某只羊的所有班次记录(按班次日期升序) -->
|
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||||
<!-- 假设表中字段:class_date, system_milk, corrected_milk, parity -->
|
SELECT DISTINCT sf.bs_manage_tags
|
||||||
|
FROM sheep_file sf
|
||||||
|
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||||
|
AND sf.is_delete = 0
|
||||||
|
ORDER BY sf.bs_manage_tags
|
||||||
|
LIMIT 50
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectMilkRecordsBySheepId" resultType="map" parameterType="string">
|
<select id="selectMilkRecordsBySheepId" resultType="map" parameterType="string">
|
||||||
SELECT
|
SELECT
|
||||||
datetime AS classDate,
|
datetime AS classDate,
|
||||||
@@ -30,8 +44,6 @@
|
|||||||
ORDER BY datetime ASC
|
ORDER BY datetime ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 3) 获取该羊在sheep_file视图中的基础信息 -->
|
|
||||||
<!-- 假设字段名称:bs_manage_tags、variety、lactation_day、name、birthday、parity、month_age、current_weight、breed、father_manage_tags、mother_manage_tags、dr_ranch、family -->
|
|
||||||
<select id="selectSheepFileBySheepId" resultType="map" parameterType="string">
|
<select id="selectSheepFileBySheepId" resultType="map" parameterType="string">
|
||||||
SELECT
|
SELECT
|
||||||
id AS sheep_id,
|
id AS sheep_id,
|
||||||
@@ -52,27 +64,30 @@
|
|||||||
WHERE id = #{sheepId}
|
WHERE id = #{sheepId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 4) 兼容旧list查询(返回domain对象列表),但在我们的实现中service会构造最终的NpSheepMilkAnalysis列表 -->
|
|
||||||
<select id="selectNpSheepMilkAnalysisList" resultType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
<select id="selectNpSheepMilkAnalysisList" resultType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||||
<!-- 如果你仍需基于某张表的简单映射,可在此实现;当前我们在ServiceImpl中组装对象,所以该查询不做复杂实现 -->
|
|
||||||
SELECT 1 FROM dual WHERE 1=0
|
SELECT 1 FROM dual WHERE 1=0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 5) 导出奶产量分析记录 -->
|
|
||||||
<select id="selectNpSheepMilkAnalysisForExport" resultType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
<select id="selectNpSheepMilkAnalysisForExport" resultType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||||
<!-- 这里需要根据实际表结构编写SQL查询 -->
|
|
||||||
<!-- 示例SQL,需要根据实际表结构调整 -->
|
|
||||||
SELECT
|
SELECT
|
||||||
sf.id as sheepId,
|
sf.id as sheepId,
|
||||||
sf.bs_manage_tags as manageEarTag,
|
sf.bs_manage_tags as manageEarTag,
|
||||||
sf.variety,
|
sf.variety,
|
||||||
<!-- 其他字段 -->
|
m.datetime as milkingStartTime
|
||||||
FROM sheep_file sf
|
FROM sheep_file sf
|
||||||
LEFT JOIN np_milk_prod_classes m ON sf.id = m.sheep_id
|
LEFT JOIN np_milk_prod_classes m ON sf.id = m.sheep_id
|
||||||
<where>
|
<where>
|
||||||
<if test="manageEarTag != null and manageEarTag != ''">
|
<if test="manageEarTag != null and manageEarTag != ''">
|
||||||
AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%')
|
AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||||
|
AND (
|
||||||
|
sf.bs_manage_tags IN
|
||||||
|
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||||
|
#{earNumber}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY sf.id
|
GROUP BY sf.id
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user