酸奶检验记录,鲜奶检验记录、生乳检验记录页面导出功能,奶产量分析页面报错修复
This commit is contained in:
parent
3a6dac3130
commit
c8f7b6baff
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 奶产量分析控制器
|
||||||
* 只保留:分页列表(只读) + 单条查询 + 导出
|
* 只保留:分页列表(只读) + 单条查询 + 导出
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@ -49,7 +50,7 @@ public class NpSheepMilkAnalysisController extends BaseController {
|
|||||||
@Log(title = "奶产量分析 导出", businessType = BusinessType.EXPORT)
|
@Log(title = "奶产量分析 导出", businessType = BusinessType.EXPORT)
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(NpSheepMilkAnalysis analysis) {
|
public AjaxResult export(NpSheepMilkAnalysis analysis) {
|
||||||
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(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, "羊奶产量分析数据");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,78 +1,141 @@
|
|||||||
package com.zhyc.module.dairyProducts.domain;
|
package com.zhyc.module.dairyProducts.domain;
|
||||||
|
|
||||||
|
import com.zhyc.common.annotation.Excel;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class NpSheepMilkAnalysis {
|
public class NpSheepMilkAnalysis {
|
||||||
// 唯一键(可用于前端 row-key)
|
// 唯一键(可用于前端 row-key)
|
||||||
|
@Excel(name = "羊只ID")
|
||||||
private String sheepId;
|
private String sheepId;
|
||||||
|
|
||||||
// 耳号(从 sheep_file.bs_manage_tags)
|
// 耳号(从 sheep_file.bs_manage_tags)
|
||||||
|
@Excel(name = "耳号")
|
||||||
private String manageEarTag;
|
private String manageEarTag;
|
||||||
|
|
||||||
|
@Excel(name = "品种")
|
||||||
private String variety;
|
private String variety;
|
||||||
|
|
||||||
// 最高校正胎次的挤奶开始时间 & 干奶时间
|
// 最高校正胎次的挤奶开始时间 & 干奶时间
|
||||||
|
@Excel(name = "挤奶开始时间", dateFormat = "yyyy-MM-dd")
|
||||||
private Date milkingStartTime;
|
private Date milkingStartTime;
|
||||||
|
|
||||||
|
@Excel(name = "干奶时间", dateFormat = "yyyy-MM-dd")
|
||||||
private Date dryEndTime;
|
private Date dryEndTime;
|
||||||
|
|
||||||
// 挤奶天数(该胎次)
|
// 挤奶天数(该胎次)
|
||||||
|
@Excel(name = "挤奶天数")
|
||||||
private Integer milkingDays;
|
private Integer milkingDays;
|
||||||
|
|
||||||
// 前端传入的筛选天数(screenDays)
|
// 前端传入的筛选天数(screenDays)
|
||||||
|
@Excel(name = "筛选天数")
|
||||||
private Integer screenDays;
|
private Integer screenDays;
|
||||||
|
|
||||||
// 分析天数(若你有不同命名,可忽略)
|
// 分析天数(若你有不同命名,可忽略)
|
||||||
private Integer analysisDays;
|
private Integer analysisDays;
|
||||||
|
|
||||||
// 校正后最大胎次(即校正奶量之和最大的胎次)
|
// 校正后最大胎次(即校正奶量之和最大的胎次)
|
||||||
|
@Excel(name = "校正后最大胎次")
|
||||||
private Integer maxParity;
|
private Integer maxParity;
|
||||||
|
|
||||||
// 最高校正胎次区间内的系统奶量与校正奶量(按筛选窗口)
|
// 最高校正胎次区间内的系统奶量与校正奶量(按筛选窗口)
|
||||||
|
@Excel(name = "系统奶量合计")
|
||||||
private Double sumSystemMilk;
|
private Double sumSystemMilk;
|
||||||
|
|
||||||
|
@Excel(name = "校正奶量合计")
|
||||||
private Double sumCorrectedMilk;
|
private Double sumCorrectedMilk;
|
||||||
|
|
||||||
// 校正日平均奶量(按min(挤奶天数,筛选天数))
|
// 校正日平均奶量(按min(挤奶天数,筛选天数))
|
||||||
|
@Excel(name = "校正日平均奶量")
|
||||||
private Double avgCorrectedDaily;
|
private Double avgCorrectedDaily;
|
||||||
|
|
||||||
// 各胎次总奶量(校正)
|
// 各胎次总奶量(校正)
|
||||||
|
@Excel(name = "胎次1总奶量")
|
||||||
private Double sumParity1Milk;
|
private Double sumParity1Milk;
|
||||||
|
|
||||||
|
@Excel(name = "胎次2总奶量")
|
||||||
private Double sumParity2Milk;
|
private Double sumParity2Milk;
|
||||||
|
|
||||||
|
@Excel(name = "胎次3总奶量")
|
||||||
private Double sumParity3Milk;
|
private Double sumParity3Milk;
|
||||||
|
|
||||||
|
@Excel(name = "胎次4总奶量")
|
||||||
private Double sumParity4Milk;
|
private Double sumParity4Milk;
|
||||||
|
|
||||||
// 各胎次日平均(按规则)
|
// 各胎次日平均(按规则)
|
||||||
|
@Excel(name = "胎次1日平均")
|
||||||
private Double avgParity1Daily;
|
private Double avgParity1Daily;
|
||||||
|
|
||||||
|
@Excel(name = "胎次2日平均")
|
||||||
private Double avgParity2Daily;
|
private Double avgParity2Daily;
|
||||||
|
|
||||||
|
@Excel(name = "胎次3日平均")
|
||||||
private Double avgParity3Daily;
|
private Double avgParity3Daily;
|
||||||
|
|
||||||
|
@Excel(name = "胎次4日平均")
|
||||||
private Double avgParity4Daily;
|
private Double avgParity4Daily;
|
||||||
|
|
||||||
// 泌乳天数(sheep_file.lactation_day)
|
// 泌乳天数(sheep_file.lactation_day)
|
||||||
|
@Excel(name = "泌乳天数")
|
||||||
private Integer lactationDays;
|
private Integer lactationDays;
|
||||||
|
|
||||||
// 过去7/14/30日平均(系统奶量)
|
// 过去7/14/30日平均(系统奶量)
|
||||||
|
@Excel(name = "过去7日均奶量")
|
||||||
private Double avgLast7Milk;
|
private Double avgLast7Milk;
|
||||||
private Double avgLast7Corrected; // = avgLast7Milk * weightCoefficient (默认 1.0)
|
|
||||||
|
@Excel(name = "校正过去7日均")
|
||||||
|
private Double avgLast7Corrected;
|
||||||
|
|
||||||
|
@Excel(name = "过去14日均奶量")
|
||||||
private Double avgLast14Milk;
|
private Double avgLast14Milk;
|
||||||
|
|
||||||
|
@Excel(name = "过去30日均奶量")
|
||||||
private Double avgLast30Milk;
|
private Double avgLast30Milk;
|
||||||
|
|
||||||
// 羊只基础信息(来自sheep_file)
|
// 羊只基础信息(来自sheep_file)
|
||||||
|
@Excel(name = "羊只类别")
|
||||||
private String sheepCategory;
|
private String sheepCategory;
|
||||||
|
|
||||||
|
@Excel(name = "生日", dateFormat = "yyyy-MM-dd")
|
||||||
private Date birthday;
|
private Date birthday;
|
||||||
private Integer parity; // 当前胎次
|
|
||||||
|
@Excel(name = "当前胎次")
|
||||||
|
private Integer parity;
|
||||||
|
|
||||||
|
@Excel(name = "月龄")
|
||||||
private Integer monthAge;
|
private Integer monthAge;
|
||||||
|
|
||||||
|
@Excel(name = "当前体重")
|
||||||
private Double currentWeight;
|
private Double currentWeight;
|
||||||
|
|
||||||
|
@Excel(name = "繁育状态")
|
||||||
private String breedStatus;
|
private String breedStatus;
|
||||||
|
|
||||||
|
@Excel(name = "父号")
|
||||||
private String fatherManageTags;
|
private String fatherManageTags;
|
||||||
|
|
||||||
|
@Excel(name = "母号")
|
||||||
private String motherManageTags;
|
private String motherManageTags;
|
||||||
|
|
||||||
|
@Excel(name = "牧场")
|
||||||
private String ranchName;
|
private String ranchName;
|
||||||
|
|
||||||
|
@Excel(name = "家系")
|
||||||
private String family;
|
private String family;
|
||||||
|
|
||||||
// 母亲相关字段(由已计算的母亲分析结果中取值)
|
// 母亲相关字段(由已计算的母亲分析结果中取值)
|
||||||
|
@Excel(name = "母亲挤奶天数")
|
||||||
private Integer motherMilkingDays;
|
private Integer motherMilkingDays;
|
||||||
|
|
||||||
|
@Excel(name = "母亲校正奶量合计")
|
||||||
private Double motherSumCorrected;
|
private Double motherSumCorrected;
|
||||||
|
|
||||||
|
@Excel(name = "母亲校正后最大胎次")
|
||||||
private Integer motherMaxParity;
|
private Integer motherMaxParity;
|
||||||
|
|
||||||
|
@Excel(name = "母亲校正日平均奶量")
|
||||||
private Double motherAvgCorrectedDaily;
|
private Double motherAvgCorrectedDaily;
|
||||||
|
|
||||||
|
@Excel(name = "最后更新时间", dateFormat = "yyyy-MM-dd")
|
||||||
private Date lastUpdate;
|
private Date lastUpdate;
|
||||||
|
|
||||||
// getters and setters
|
// getters and setters
|
||||||
|
|||||||
@ -33,4 +33,9 @@ public interface NpSheepMilkAnalysisMapper {
|
|||||||
*/
|
*/
|
||||||
List<Map<String, Object>> selectMilkRecordsBySheepId(@Param("sheepId") String sheepId);
|
List<Map<String, Object>> selectMilkRecordsBySheepId(@Param("sheepId") String sheepId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出奶产量分析记录
|
||||||
|
*/
|
||||||
|
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisForExport(NpSheepMilkAnalysis analysis);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -9,4 +9,9 @@ public interface INpSheepMilkAnalysisService {
|
|||||||
|
|
||||||
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis);
|
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出奶产量分析记录
|
||||||
|
*/
|
||||||
|
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisForExport(NpSheepMilkAnalysis analysis);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -219,6 +219,12 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
|
|||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisForExport(NpSheepMilkAnalysis analysis) {
|
||||||
|
// 直接调用Mapper的导出方法,避免复杂的业务逻辑
|
||||||
|
return npSheepMilkAnalysisMapper.selectNpSheepMilkAnalysisForExport(analysis);
|
||||||
|
}
|
||||||
|
|
||||||
private static Date convertToDate(Object obj) {
|
private static Date convertToDate(Object obj) {
|
||||||
if (obj == null) return null;
|
if (obj == null) return null;
|
||||||
if (obj instanceof Date) {
|
if (obj instanceof Date) {
|
||||||
|
|||||||
@ -30,7 +30,6 @@
|
|||||||
ORDER BY datetime ASC
|
ORDER BY datetime ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 3) 获取该羊在sheep_file视图中的基础信息 -->
|
<!-- 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 -->
|
<!-- 假设字段名称: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">
|
||||||
@ -59,4 +58,23 @@
|
|||||||
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">
|
||||||
|
<!-- 这里需要根据实际表结构编写SQL查询 -->
|
||||||
|
<!-- 示例SQL,需要根据实际表结构调整 -->
|
||||||
|
SELECT
|
||||||
|
sf.id as sheepId,
|
||||||
|
sf.bs_manage_tags as manageEarTag,
|
||||||
|
sf.variety,
|
||||||
|
<!-- 其他字段 -->
|
||||||
|
FROM sheep_file sf
|
||||||
|
LEFT JOIN np_milk_prod_classes m ON sf.id = m.sheep_id
|
||||||
|
<where>
|
||||||
|
<if test="manageEarTag != null and manageEarTag != ''">
|
||||||
|
AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY sf.id
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user