酸奶检验记录,鲜奶检验记录、生乳检验记录页面导出功能,奶产量分析页面报错修复

This commit is contained in:
ll 2025-08-29 17:24:43 +08:00
parent 3a6dac3130
commit c8f7b6baff
6 changed files with 124 additions and 26 deletions

View File

@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 奶产量分析控制器
* 只保留分页列表只读 + 单条查询 + 导出
*/
@RestController
@ -49,7 +50,7 @@ public class NpSheepMilkAnalysisController extends BaseController {
@Log(title = "奶产量分析 导出", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(NpSheepMilkAnalysis analysis) {
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis);
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisForExport(analysis);
ExcelUtil<NpSheepMilkAnalysis> util = new ExcelUtil<>(NpSheepMilkAnalysis.class);
return util.exportExcel(list, "羊奶产量分析数据");
}

View File

@ -1,78 +1,141 @@
package com.zhyc.module.dairyProducts.domain;
import com.zhyc.common.annotation.Excel;
import java.util.Date;
public class NpSheepMilkAnalysis {
// 唯一键可用于前端 row-key
@Excel(name = "羊只ID")
private String sheepId;
// 耳号 sheep_file.bs_manage_tags
@Excel(name = "耳号")
private String manageEarTag;
@Excel(name = "品种")
private String variety;
// 最高校正胎次的挤奶开始时间 & 干奶时间
@Excel(name = "挤奶开始时间", dateFormat = "yyyy-MM-dd")
private Date milkingStartTime;
@Excel(name = "干奶时间", dateFormat = "yyyy-MM-dd")
private Date dryEndTime;
// 挤奶天数该胎次
@Excel(name = "挤奶天数")
private Integer milkingDays;
// 前端传入的筛选天数screenDays
@Excel(name = "筛选天数")
private Integer screenDays;
// 分析天数若你有不同命名可忽略
private Integer analysisDays;
// 校正后最大胎次即校正奶量之和最大的胎次
@Excel(name = "校正后最大胎次")
private Integer maxParity;
// 最高校正胎次区间内的系统奶量与校正奶量按筛选窗口
@Excel(name = "系统奶量合计")
private Double sumSystemMilk;
@Excel(name = "校正奶量合计")
private Double sumCorrectedMilk;
// 校正日平均奶量按min(挤奶天数,筛选天数)
@Excel(name = "校正日平均奶量")
private Double avgCorrectedDaily;
// 各胎次总奶量校正
@Excel(name = "胎次1总奶量")
private Double sumParity1Milk;
@Excel(name = "胎次2总奶量")
private Double sumParity2Milk;
@Excel(name = "胎次3总奶量")
private Double sumParity3Milk;
@Excel(name = "胎次4总奶量")
private Double sumParity4Milk;
// 各胎次日平均按规则
@Excel(name = "胎次1日平均")
private Double avgParity1Daily;
@Excel(name = "胎次2日平均")
private Double avgParity2Daily;
@Excel(name = "胎次3日平均")
private Double avgParity3Daily;
@Excel(name = "胎次4日平均")
private Double avgParity4Daily;
// 泌乳天数sheep_file.lactation_day
@Excel(name = "泌乳天数")
private Integer lactationDays;
// 过去7/14/30日平均系统奶量
@Excel(name = "过去7日均奶量")
private Double avgLast7Milk;
private Double avgLast7Corrected; // = avgLast7Milk * weightCoefficient 默认 1.0
@Excel(name = "校正过去7日均")
private Double avgLast7Corrected;
@Excel(name = "过去14日均奶量")
private Double avgLast14Milk;
@Excel(name = "过去30日均奶量")
private Double avgLast30Milk;
// 羊只基础信息来自sheep_file
@Excel(name = "羊只类别")
private String sheepCategory;
@Excel(name = "生日", dateFormat = "yyyy-MM-dd")
private Date birthday;
private Integer parity; // 当前胎次
@Excel(name = "当前胎次")
private Integer parity;
@Excel(name = "月龄")
private Integer monthAge;
@Excel(name = "当前体重")
private Double currentWeight;
@Excel(name = "繁育状态")
private String breedStatus;
@Excel(name = "父号")
private String fatherManageTags;
@Excel(name = "母号")
private String motherManageTags;
@Excel(name = "牧场")
private String ranchName;
@Excel(name = "家系")
private String family;
// 母亲相关字段由已计算的母亲分析结果中取值
@Excel(name = "母亲挤奶天数")
private Integer motherMilkingDays;
@Excel(name = "母亲校正奶量合计")
private Double motherSumCorrected;
@Excel(name = "母亲校正后最大胎次")
private Integer motherMaxParity;
@Excel(name = "母亲校正日平均奶量")
private Double motherAvgCorrectedDaily;
@Excel(name = "最后更新时间", dateFormat = "yyyy-MM-dd")
private Date lastUpdate;
// getters and setters

View File

@ -33,4 +33,9 @@ public interface NpSheepMilkAnalysisMapper {
*/
List<Map<String, Object>> selectMilkRecordsBySheepId(@Param("sheepId") String sheepId);
/**
* 导出奶产量分析记录
*/
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisForExport(NpSheepMilkAnalysis analysis);
}

View File

@ -9,4 +9,9 @@ public interface INpSheepMilkAnalysisService {
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis);
/**
* 导出奶产量分析记录
*/
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisForExport(NpSheepMilkAnalysis analysis);
}

View File

@ -219,6 +219,12 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
return resultList;
}
@Override
public List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisForExport(NpSheepMilkAnalysis analysis) {
// 直接调用Mapper的导出方法避免复杂的业务逻辑
return npSheepMilkAnalysisMapper.selectNpSheepMilkAnalysisForExport(analysis);
}
private static Date convertToDate(Object obj) {
if (obj == null) return null;
if (obj instanceof Date) {

View File

@ -30,7 +30,6 @@
ORDER BY datetime ASC
</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">
@ -59,4 +58,23 @@
SELECT 1 FROM dual WHERE 1=0
</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>