Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
6ec984c510
@ -33,6 +33,11 @@ public @interface Excel
|
||||
*/
|
||||
public String dateFormat() default "";
|
||||
|
||||
/**
|
||||
* 数字格式, 如: 0.00
|
||||
*/
|
||||
public String numFormat() default ""; // 新增数字格式属性
|
||||
|
||||
/**
|
||||
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||
*/
|
||||
|
||||
@ -8,6 +8,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ import com.zhyc.common.utils.reflect.ReflectUtils;
|
||||
|
||||
/**
|
||||
* Excel相关处理
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class ExcelUtil<T>
|
||||
@ -307,7 +307,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对excel表单默认第一个索引名转换成list
|
||||
*
|
||||
*
|
||||
* @param is 输入流
|
||||
* @return 转换后集合
|
||||
*/
|
||||
@ -318,7 +318,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对excel表单默认第一个索引名转换成list
|
||||
*
|
||||
*
|
||||
* @param is 输入流
|
||||
* @param titleNum 标题占用行数
|
||||
* @return 转换后集合
|
||||
@ -344,7 +344,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对excel表单指定表格索引名转换成list
|
||||
*
|
||||
*
|
||||
* @param sheetName 表格索引名
|
||||
* @param titleNum 标题占用行数
|
||||
* @param is 输入流
|
||||
@ -527,7 +527,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
* @return 结果
|
||||
@ -539,7 +539,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
* @param title 标题
|
||||
@ -553,7 +553,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param response 返回数据
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
@ -566,7 +566,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param response 返回数据
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
@ -583,7 +583,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param sheetName 工作表的名称
|
||||
* @return 结果
|
||||
*/
|
||||
@ -594,7 +594,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param sheetName 工作表的名称
|
||||
* @param title 标题
|
||||
* @return 结果
|
||||
@ -607,7 +607,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param sheetName 工作表的名称
|
||||
* @return 结果
|
||||
*/
|
||||
@ -618,7 +618,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param sheetName 工作表的名称
|
||||
* @param title 标题
|
||||
* @return 结果
|
||||
@ -633,7 +633,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public void exportExcel(HttpServletResponse response)
|
||||
@ -655,7 +655,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public AjaxResult exportExcel()
|
||||
@ -723,7 +723,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 填充excel数据
|
||||
*
|
||||
*
|
||||
* @param index 序号
|
||||
* @param row 单元格行
|
||||
*/
|
||||
@ -821,7 +821,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 创建表格样式
|
||||
*
|
||||
*
|
||||
* @param wb 工作薄对象
|
||||
* @return 样式列表
|
||||
*/
|
||||
@ -876,7 +876,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 根据Excel注解创建表格头样式
|
||||
*
|
||||
*
|
||||
* @param wb 工作薄对象
|
||||
* @return 自定义样式列表
|
||||
*/
|
||||
@ -912,7 +912,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 根据Excel注解创建表格列样式
|
||||
*
|
||||
*
|
||||
* @param wb 工作薄对象
|
||||
* @return 自定义样式列表
|
||||
*/
|
||||
@ -944,7 +944,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 根据Excel注解创建表格列样式
|
||||
*
|
||||
*
|
||||
* @param styles 自定义样式列表
|
||||
* @param field 属性列信息
|
||||
* @param excel 注解信息
|
||||
@ -1007,7 +1007,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 设置单元格信息
|
||||
*
|
||||
*
|
||||
* @param value 单元格值
|
||||
* @param attr 注解相关
|
||||
* @param cell 单元格信息
|
||||
@ -1142,7 +1142,6 @@ public class ExcelUtil<T>
|
||||
sheet.addMergedRegion(new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column));
|
||||
}
|
||||
}
|
||||
cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())));
|
||||
|
||||
// 用于读取对象中的属性
|
||||
Object value = getTargetValue(vo, field, attr);
|
||||
@ -1150,14 +1149,33 @@ public class ExcelUtil<T>
|
||||
String readConverterExp = attr.readConverterExp();
|
||||
String separator = attr.separator();
|
||||
String dictType = attr.dictType();
|
||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||
String numFormat = attr.numFormat(); // 获取数字格式
|
||||
|
||||
// 创建单元格样式
|
||||
CellStyle cellStyle = wb.createCellStyle();
|
||||
cellStyle.cloneStyleFrom(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}",
|
||||
attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())));
|
||||
|
||||
// 处理日期格式
|
||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value) && value instanceof Date)
|
||||
{
|
||||
cell.getCellStyle().setDataFormat(this.wb.getCreationHelper().createDataFormat().getFormat(dateFormat));
|
||||
cell.setCellValue(parseDateToStr(dateFormat, value));
|
||||
DataFormat format = wb.createDataFormat();
|
||||
cellStyle.setDataFormat(format.getFormat(dateFormat));
|
||||
cell.setCellValue((Date) value);
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
// 处理数字格式
|
||||
else if (StringUtils.isNotEmpty(numFormat) && StringUtils.isNotNull(value) && value instanceof Number)
|
||||
{
|
||||
DataFormat format = wb.createDataFormat();
|
||||
cellStyle.setDataFormat(format.getFormat(numFormat));
|
||||
cell.setCellValue(((Number) value).doubleValue());
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value))
|
||||
{
|
||||
@ -1167,20 +1185,32 @@ public class ExcelUtil<T>
|
||||
sysDictMap.put(dictType + value, lable);
|
||||
}
|
||||
cell.setCellValue(sysDictMap.get(dictType + value));
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
else if (value instanceof BigDecimal && -1 != attr.scale())
|
||||
{
|
||||
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).doubleValue());
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
||||
{
|
||||
cell.setCellValue(dataFormatHandlerAdapter(value, attr, cell));
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 设置列类型
|
||||
setCellVo(value, attr, cell);
|
||||
// 对于日期类型,确保应用日期格式
|
||||
if (value instanceof Date && StringUtils.isNotEmpty(dateFormat)) {
|
||||
DataFormat format = wb.createDataFormat();
|
||||
CellStyle dateStyle = wb.createCellStyle();
|
||||
dateStyle.cloneStyleFrom(cell.getCellStyle());
|
||||
dateStyle.setDataFormat(format.getFormat(dateFormat));
|
||||
cell.setCellStyle(dateStyle);
|
||||
}
|
||||
}
|
||||
|
||||
addStatisticsData(column, Convert.toStr(value), attr);
|
||||
}
|
||||
}
|
||||
@ -1193,7 +1223,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 设置 POI XSSFSheet 单元格提示或选择框
|
||||
*
|
||||
*
|
||||
* @param sheet 表单
|
||||
* @param textlist 下拉框显示的内容
|
||||
* @param promptContent 提示内容
|
||||
@ -1203,7 +1233,7 @@ public class ExcelUtil<T>
|
||||
* @param endCol 结束列
|
||||
*/
|
||||
public void setPromptOrValidation(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow,
|
||||
int firstCol, int endCol)
|
||||
int firstCol, int endCol)
|
||||
{
|
||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||
DataValidationConstraint constraint = textlist.length > 0 ? helper.createExplicitListConstraint(textlist) : helper.createCustomConstraint("DD1");
|
||||
@ -1230,7 +1260,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 设置某些列的值只能输入预制的数据,显示下拉框(兼容超出一定数量的下拉框).
|
||||
*
|
||||
*
|
||||
* @param sheet 要设置的sheet.
|
||||
* @param textlist 下拉框显示的内容
|
||||
* @param promptContent 提示内容
|
||||
@ -1254,7 +1284,7 @@ public class ExcelUtil<T>
|
||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||
// 加载下拉列表内容
|
||||
DataValidationConstraint constraint = helper.createFormulaListConstraint(hideSheetName + "_data");
|
||||
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
|
||||
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
|
||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
||||
// 数据有效性对象
|
||||
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
||||
@ -1282,7 +1312,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 解析导出值 0=男,1=女,2=未知
|
||||
*
|
||||
*
|
||||
* @param propertyValue 参数值
|
||||
* @param converterExp 翻译注解
|
||||
* @param separator 分隔符
|
||||
@ -1319,7 +1349,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 反向解析值 男=0,女=1,未知=2
|
||||
*
|
||||
*
|
||||
* @param propertyValue 参数值
|
||||
* @param converterExp 翻译注解
|
||||
* @param separator 分隔符
|
||||
@ -1356,7 +1386,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 解析字典值
|
||||
*
|
||||
*
|
||||
* @param dictValue 字典值
|
||||
* @param dictType 字典类型
|
||||
* @param separator 分隔符
|
||||
@ -1369,7 +1399,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 反向解析值字典值
|
||||
*
|
||||
*
|
||||
* @param dictLabel 字典标签
|
||||
* @param dictType 字典类型
|
||||
* @param separator 分隔符
|
||||
@ -1382,7 +1412,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 数据处理器
|
||||
*
|
||||
*
|
||||
* @param value 数据值
|
||||
* @param excel 数据注解
|
||||
* @return
|
||||
@ -1458,7 +1488,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 获取下载路径
|
||||
*
|
||||
*
|
||||
* @param filename 文件名称
|
||||
*/
|
||||
public String getAbsoluteFile(String filename)
|
||||
@ -1474,7 +1504,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 获取bean中的属性值
|
||||
*
|
||||
*
|
||||
* @param vo 实体对象
|
||||
* @param field 字段
|
||||
* @param excel 注解
|
||||
@ -1506,7 +1536,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 以类的属性的get方法方法形式获取值
|
||||
*
|
||||
*
|
||||
* @param o
|
||||
* @param name
|
||||
* @return value
|
||||
@ -1649,7 +1679,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 创建工作表
|
||||
*
|
||||
*
|
||||
* @param sheetNo sheet数量
|
||||
* @param index 序号
|
||||
*/
|
||||
@ -1666,7 +1696,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 获取单元格值
|
||||
*
|
||||
*
|
||||
* @param row 获取的行
|
||||
* @param column 获取单元格列号
|
||||
* @return 单元格值
|
||||
@ -1726,7 +1756,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 判断是否是空行
|
||||
*
|
||||
*
|
||||
* @param row 判断的行
|
||||
* @return
|
||||
*/
|
||||
@ -1754,7 +1784,7 @@ public class ExcelUtil<T>
|
||||
* @param workbook 工作簿对象
|
||||
* @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
|
||||
*/
|
||||
public static Map<String, List<PictureData>> getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook)
|
||||
public static Map<String, List<PictureData> > getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook)
|
||||
{
|
||||
Map<String, List<PictureData>> sheetIndexPicMap = new HashMap<>();
|
||||
List<HSSFPictureData> pictures = workbook.getAllPictures();
|
||||
@ -1807,7 +1837,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 格式化不同类型的日期对象
|
||||
*
|
||||
*
|
||||
* @param dateFormat 日期格式
|
||||
* @param val 被格式化的日期对象
|
||||
* @return 格式化后的日期字符
|
||||
@ -1873,7 +1903,7 @@ public class ExcelUtil<T>
|
||||
|
||||
/**
|
||||
* 获取对象的子列表方法
|
||||
*
|
||||
*
|
||||
* @param name 名称
|
||||
* @param pojoClass 类对象
|
||||
* @return 子列表方法
|
||||
@ -1894,4 +1924,4 @@ public class ExcelUtil<T>
|
||||
}
|
||||
return method;
|
||||
}
|
||||
}
|
||||
}
|
||||
0
zhyc-module/src/main/java/com/zhyc/module/base/1
Normal file
0
zhyc-module/src/main/java/com/zhyc/module/base/1
Normal file
@ -3,6 +3,7 @@ package com.zhyc.module.base.mapper;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
@ -11,6 +12,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
* @author ruoyi
|
||||
* @date 2025-07-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface BasSheepMapper
|
||||
{
|
||||
/**
|
||||
|
||||
@ -80,6 +80,17 @@ public class DiagnosisController extends BaseController
|
||||
return toAjax(diagnosisService.insertDiagnosis(diagnosis));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增批量诊疗结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('diagnosis:diagnosis:add')")
|
||||
@Log(title = "诊疗结果", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/adds")
|
||||
public AjaxResult adds(@RequestBody Diagnosis diagnosis)
|
||||
{
|
||||
return toAjax(diagnosisService.insertDiagnosisList(diagnosis));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改诊疗结果
|
||||
*/
|
||||
|
||||
@ -27,6 +27,7 @@ public class Diagnosis extends BaseEntity
|
||||
/** 治疗记录id */
|
||||
@Excel(name = "治疗记录")
|
||||
private Long treatId;
|
||||
private Integer[] treatIds;
|
||||
|
||||
/** 羊只id */
|
||||
@Excel(name = "羊只耳号")
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.zhyc.module.biosafety.domain;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -28,6 +30,18 @@ public class SwMedicineUsage extends BaseEntity
|
||||
@Excel(name = "使用名称")
|
||||
private String name;
|
||||
|
||||
/** 羊舍名称 */
|
||||
@Excel(name = "使用名称")
|
||||
private String sheepfoldName;
|
||||
private Integer sheepfoldId;
|
||||
/** 耳号 */
|
||||
@Excel(name = "耳号")
|
||||
private String sheepNo;
|
||||
private Integer sheepId;
|
||||
/** 使用时间 */
|
||||
@Excel(name = "使用时间")
|
||||
private Date datetime;
|
||||
|
||||
/** 使用类型 */
|
||||
@Excel(name = "使用类型")
|
||||
private String useType;
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package com.zhyc.module.biosafety.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 药品使用记录详情对象 sw_medicine_usage_details
|
||||
*
|
||||
@ -46,6 +49,11 @@ public class SwMedicineUsageDetails extends BaseEntity
|
||||
@Excel(name = "使用方法")
|
||||
private String usageId;
|
||||
|
||||
/** 使用时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "使用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date usetime;
|
||||
|
||||
/** 生产厂家 */
|
||||
@Excel(name = "生产厂家")
|
||||
private String manufacturer;
|
||||
|
||||
@ -89,6 +89,10 @@ public class Treatment extends BaseEntity
|
||||
/** 兽医 */
|
||||
@Excel(name = "兽医")
|
||||
private String veterinary;
|
||||
/** 治疗状态 */
|
||||
@Excel(name = "治疗状态")
|
||||
private String status;
|
||||
|
||||
|
||||
/** 药品使用记录id */
|
||||
@Excel(name = "药品使用记录id")
|
||||
|
||||
@ -63,4 +63,7 @@ public interface TreatmentMapper
|
||||
public int deleteTreatmentByIds(Long[] ids);
|
||||
|
||||
int insertTreatmentList(List<Treatment> treatments);
|
||||
|
||||
|
||||
List<Treatment> selectTreatmentStatus(Long sheepId);
|
||||
}
|
||||
|
||||
@ -59,4 +59,6 @@ public interface IDiagnosisService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDiagnosisById(Long id);
|
||||
|
||||
int insertDiagnosisList(Diagnosis diagnosis);
|
||||
}
|
||||
|
||||
@ -78,6 +78,7 @@ public class DewormServiceImpl implements IDewormService
|
||||
medicineUsage.setSwMedicineUsageDetailsList(deworm.getUsageDetails());
|
||||
medicineUsage.setName("羊只驱虫");
|
||||
medicineUsage.setUseType("1");
|
||||
medicineUsage.setDatetime(deworm.getDatetime());
|
||||
|
||||
List<Deworm> deworms = new ArrayList<>();
|
||||
|
||||
@ -95,6 +96,8 @@ public class DewormServiceImpl implements IDewormService
|
||||
dew.setGender(String.valueOf(sheepFile.getGender()));
|
||||
dew.setBreed(sheepFile.getBreed());
|
||||
dew.setParity(sheepFile.getParity());
|
||||
|
||||
medicineUsage.setSheepId(sheepId);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
dew.setUsageId(usageId);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -9,13 +10,18 @@ import com.zhyc.module.base.domain.BasSheep;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.mapper.BasSheepMapper;
|
||||
import com.zhyc.module.base.mapper.SheepFileMapper;
|
||||
import com.zhyc.module.biosafety.domain.Treatment;
|
||||
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
|
||||
import com.zhyc.module.biosafety.mapper.TreatmentMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.biosafety.domain.Diagnosis;
|
||||
import com.zhyc.module.biosafety.service.IDiagnosisService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 诊疗结果Service业务层处理
|
||||
*
|
||||
@ -31,6 +37,8 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
private SheepFileMapper sheepFileMapper;
|
||||
@Autowired
|
||||
private BasSheepMapper sheepMapper;
|
||||
@Autowired
|
||||
private TreatmentMapper treatmentMapper;
|
||||
|
||||
/**
|
||||
* 查询诊疗结果
|
||||
@ -75,16 +83,87 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
diagnosis.setCreateBy(username);
|
||||
diagnosis.setCreateTime(DateUtils.getNowDate());
|
||||
if (!Objects.equals(sheepFile.getSheepfoldId(), diagnosis.getSheepfoldId())){
|
||||
BasSheep basSheep = new BasSheep();
|
||||
basSheep.setId(diagnosis.getSheepId());
|
||||
basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
|
||||
sheepMapper.updateBasSheep(basSheep);
|
||||
|
||||
if (diagnosis.getSheepfoldId() != null)
|
||||
if (!Objects.equals(sheepFile.getSheepfoldId(), diagnosis.getSheepfoldId())) {
|
||||
BasSheep basSheep = new BasSheep();
|
||||
basSheep.setId(diagnosis.getSheepId());
|
||||
basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
|
||||
sheepMapper.updateBasSheep(basSheep);
|
||||
}
|
||||
|
||||
// 更改治疗记录的状态
|
||||
Treatment treatment = new Treatment();
|
||||
treatment.setId(diagnosis.getTreatId());
|
||||
if (diagnosis.getResult().equals("0")){
|
||||
treatment.setStatus("-1");
|
||||
treatmentMapper.updateTreatment(treatment);
|
||||
}else if (diagnosis.getResult().equals("1")){
|
||||
treatment.setStatus("2");
|
||||
treatmentMapper.updateTreatment(treatment);
|
||||
}
|
||||
// 转入其他羊舍
|
||||
return diagnosisMapper.insertDiagnosis(diagnosis);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertDiagnosisList(Diagnosis diagnosis) {
|
||||
if (diagnosis.getTreatIds() != null && diagnosis.getTreatIds().length > 0){
|
||||
for (Integer treatId : diagnosis.getTreatIds()) {
|
||||
System.out.println(treatId);
|
||||
Treatment treatment = treatmentMapper.selectTreatmentById(Long.valueOf(treatId));
|
||||
System.out.println(treatment);
|
||||
// BasSheep basSheep = sheepMapper.selectBasSheepById(treatment.getSheepId());
|
||||
|
||||
Diagnosis diag = new Diagnosis();
|
||||
BeanUtils.copyProperties(treatment,diag);
|
||||
diag.setResult(diagnosis.getResult());
|
||||
diag.setParity(String.valueOf(treatment.getParity()));
|
||||
|
||||
|
||||
// treatment 和 diagnosis 是你的两个实体对象
|
||||
Date start = treatment.getDatetime(); // 已经是 Date
|
||||
Date end = diagnosis.getDatetime(); // 已经是 Date
|
||||
diag.setBegindate(start);
|
||||
diag.setEnddate(end);
|
||||
long oneDayMillis = 24 * 60 * 60 * 1000L;
|
||||
long days = (end.getTime() / oneDayMillis) - (start.getTime() / oneDayMillis);
|
||||
if (days<0){
|
||||
days=0;
|
||||
}
|
||||
|
||||
diag.setTreatDay(days);
|
||||
diag.setTreatId(treatment.getId());
|
||||
|
||||
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
diag.setCreateBy(username);
|
||||
diag.setCreateTime(DateUtils.getNowDate());
|
||||
diagnosisMapper.insertDiagnosis(diag);
|
||||
treatment.setDiagId(diag.getId());
|
||||
|
||||
// 更改治疗记录的状态
|
||||
if (diagnosis.getResult().equals("0")){
|
||||
treatment.setStatus("-1");
|
||||
treatmentMapper.updateTreatment(treatment);
|
||||
}else if (diagnosis.getResult().equals("1")){
|
||||
treatment.setStatus("2");
|
||||
treatmentMapper.updateTreatment(treatment);
|
||||
}
|
||||
if (diagnosis.getSheepfoldId() != null){
|
||||
BasSheep basSheep = new BasSheep();
|
||||
basSheep.setId(diagnosis.getSheepId());
|
||||
basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
|
||||
sheepMapper.updateBasSheep(basSheep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改诊疗结果
|
||||
*
|
||||
@ -130,4 +209,5 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
{
|
||||
return diagnosisMapper.deleteDiagnosisById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -79,6 +79,7 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
medicineUsage.setSwMedicineUsageDetailsList(disinfect.getUsageDetails());
|
||||
medicineUsage.setName("羊舍消毒");
|
||||
medicineUsage.setUseType("3");
|
||||
medicineUsage.setDatetime(disinfect.getDatetime());
|
||||
|
||||
|
||||
List<Disinfect> disinfects = new ArrayList<>();
|
||||
@ -90,6 +91,8 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
Disinfect dis = new Disinfect();
|
||||
BeanUtils.copyProperties(disinfect,dis);
|
||||
dis.setSheepfoldId(sheepfold);
|
||||
|
||||
medicineUsage.setSheepfoldId(sheepfold);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
dis.setUsageId(usageId);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.beans.Transient;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
@ -70,6 +71,7 @@ public class HealthServiceImpl implements IHealthService
|
||||
* @param health 保健
|
||||
* @return 结果
|
||||
*/
|
||||
@Transient
|
||||
@Override
|
||||
public int insertHealth(Health health)
|
||||
{
|
||||
@ -80,6 +82,7 @@ public class HealthServiceImpl implements IHealthService
|
||||
medicineUsage.setSwMedicineUsageDetailsList(health.getUsageDetails());
|
||||
medicineUsage.setName("羊只保健");
|
||||
medicineUsage.setUseType("2");
|
||||
medicineUsage.setDatetime(health.getDatetime());
|
||||
|
||||
List<Health> healths = new ArrayList<>();
|
||||
health.setCreateBy(username);
|
||||
@ -96,6 +99,7 @@ public class HealthServiceImpl implements IHealthService
|
||||
heal.setBreed(sheepFile.getBreed());
|
||||
heal.setParity(sheepFile.getParity());
|
||||
|
||||
medicineUsage.setSheepId(sheepId);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
|
||||
|
||||
@ -82,8 +82,10 @@ public class ImmunityServiceImpl implements IImmunityService
|
||||
medicineUsage.setSwMedicineUsageDetailsList(immunity.getUsageDetails());
|
||||
medicineUsage.setName("羊只免疫");
|
||||
medicineUsage.setUseType("0");
|
||||
medicineUsage.setDatetime(immunity.getDatetime());
|
||||
medicineUsage.setCreateBy(username);
|
||||
|
||||
|
||||
List<Immunity> immunities = new ArrayList<>();
|
||||
|
||||
immunity.setUpdateBy(username);
|
||||
@ -101,6 +103,8 @@ public class ImmunityServiceImpl implements IImmunityService
|
||||
imm.setGender(String.valueOf(sheepFile.getGender()));
|
||||
imm.setBreed(sheepFile.getBreed());
|
||||
imm.setParity(sheepFile.getParity());
|
||||
|
||||
medicineUsage.setSheepId(sheepId);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
|
||||
|
||||
@ -7,8 +7,10 @@ import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
import com.zhyc.module.base.domain.SheepFile;
|
||||
import com.zhyc.module.base.mapper.SheepFileMapper;
|
||||
import com.zhyc.module.biosafety.domain.Diagnosis;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
|
||||
import com.zhyc.module.biosafety.domain.SwMedicineUsageDetails;
|
||||
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
|
||||
import com.zhyc.module.biosafety.mapper.SwMedicineUsageMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -34,6 +36,8 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
private SwMedicineUsageMapper medicineUsageMapper;
|
||||
@Autowired
|
||||
private SheepFileMapper sheepFileMapper;
|
||||
@Autowired
|
||||
private DiagnosisMapper diagnosisMapper;
|
||||
|
||||
/**
|
||||
* 查询治疗记录
|
||||
@ -47,7 +51,9 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
Treatment treatment = treatmentMapper.selectTreatmentById(id);
|
||||
// 获取药品使用记录
|
||||
SwMedicineUsage swMedicineUsage = medicineUsageService.selectSwMedicineUsageById(treatment.getUsageId());
|
||||
treatment.setUsageDetails(swMedicineUsage.getSwMedicineUsageDetailsList());
|
||||
if (swMedicineUsage!=null){
|
||||
treatment.setUsageDetails(swMedicineUsage.getSwMedicineUsageDetailsList());
|
||||
}
|
||||
return treatment;
|
||||
}
|
||||
|
||||
@ -79,10 +85,12 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
medicineUsage.setSwMedicineUsageDetailsList(treatment.getUsageDetails());
|
||||
medicineUsage.setName("羊只治疗");
|
||||
medicineUsage.setUseType("4");
|
||||
medicineUsage.setDatetime(treatment.getDatetime());
|
||||
medicineUsage.setCreateBy(username);
|
||||
medicineUsage.setCreateTime(DateUtils.getNowDate());
|
||||
// 新增单挑数据
|
||||
if (treatment.getSheepId()!=null){
|
||||
medicineUsage.setSheepId(Math.toIntExact(treatment.getSheepId()));
|
||||
// 药品使用记录
|
||||
Integer id=medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
// 药品使用记录id
|
||||
@ -108,6 +116,8 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
treat.setParity(sheepFile.getParity());
|
||||
treat.setLactDay(sheepFile.getLactationDay());
|
||||
treat.setGestDay(sheepFile.getGestationDay());
|
||||
|
||||
medicineUsage.setSheepId(Integer.valueOf(sheepId));
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
System.out.println(medicineUsage);
|
||||
@ -172,4 +182,21 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
{
|
||||
return treatmentMapper.deleteTreatmentById(id);
|
||||
}
|
||||
|
||||
public void updateTreatmentStatus(Long sheepId) {
|
||||
List<Treatment> treatments=treatmentMapper.selectTreatmentStatus(sheepId);
|
||||
Diagnosis diagnosis = new Diagnosis();
|
||||
for (Treatment treatment : treatments) {
|
||||
if (treatment.getDiagId()!=null){
|
||||
diagnosis.setId(treatment.getDiagId());
|
||||
diagnosis.setResult("-1");
|
||||
diagnosisMapper.updateDiagnosis(diagnosis);
|
||||
if (treatment.getDiagId()!=null){
|
||||
Treatment treat = new Treatment();
|
||||
treat.setId(treatment.getId());
|
||||
treatmentMapper.updateTreatment(treat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,10 +58,12 @@ public class NpMilkProdClassesController extends BaseController {
|
||||
public void export(HttpServletResponse response,
|
||||
@RequestParam(required = false) Date datetimeStart,
|
||||
@RequestParam(required = false) Date datetimeEnd,
|
||||
@RequestParam(required = false) String manageEarNos,
|
||||
@RequestParam(required = false) String manageEarNo,
|
||||
@RequestParam(required = false) String factory,
|
||||
@RequestParam(required = false) Integer classes) {
|
||||
List<NpMilkProdClasses> list = npMilkProdClassesService.selectNpMilkProdClassesList(datetimeStart, datetimeEnd, manageEarNos, factory, classes);
|
||||
List<NpMilkProdClasses> list = npMilkProdClassesService.selectNpMilkProdClassesList(
|
||||
datetimeStart, datetimeEnd, manageEarNo, factory, classes);
|
||||
|
||||
ExcelUtil<NpMilkProdClasses> util = new ExcelUtil<>(NpMilkProdClasses.class);
|
||||
util.exportExcel(response, list, "班次产奶数据");
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 奶产量分析控制器
|
||||
* 只保留:分页列表(只读) + 单条查询 + 导出
|
||||
*/
|
||||
@RestController
|
||||
@ -29,13 +30,13 @@ public class NpSheepMilkAnalysisController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(NpSheepMilkAnalysis analysis) {
|
||||
startPage(); // 使用 PageHelper 分页(注意 service 中第一个 DB 调用是 distinct sheep id)
|
||||
startPage(); // 使用PageHelper分页(注意service中第一个DB调用是distinct sheep id)
|
||||
List<NpSheepMilkAnalysis> list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个分析记录详细信息(按 sheepId)
|
||||
* 获取单个分析记录详细信息(按sheepId)
|
||||
*/
|
||||
@GetMapping(value = "/{sheepId}")
|
||||
public AjaxResult getInfo(@PathVariable("sheepId") String sheepId) {
|
||||
@ -44,13 +45,13 @@ public class NpSheepMilkAnalysisController extends BaseController {
|
||||
|
||||
/**
|
||||
* 导出奶产量分析记录(Excel)
|
||||
* 支持 manageEarTag 与 screenDays 两个查询条件
|
||||
* 支持manageEarTag与screenDays两个查询条件
|
||||
*/
|
||||
@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, "羊奶产量分析数据");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,12 +19,13 @@ import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
|
||||
import com.zhyc.module.dairyProducts.service.IXzParityCorrectionService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 胎次校正Controller
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-14
|
||||
* @date 2025-08-24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/parityCorrection/parityCorrection")
|
||||
@ -37,20 +38,12 @@ public class XzParityCorrectionController extends BaseController
|
||||
* 查询胎次校正列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:list')")
|
||||
// @GetMapping("/list")
|
||||
// public TableDataInfo list(XzParityCorrection xzParityCorrection)
|
||||
// {
|
||||
// startPage();
|
||||
// List<XzParityCorrection> list = xzParityCorrectionService.selectXzParityCorrectionList(xzParityCorrection);
|
||||
// return getDataTable(list);
|
||||
// }
|
||||
/**
|
||||
* 获取全部胎次校正(无需分页,供下拉/列表直接显示)
|
||||
*/
|
||||
@GetMapping("/listAll")
|
||||
public AjaxResult listAll(XzParityCorrection xzParityCorrection){
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(XzParityCorrection xzParityCorrection)
|
||||
{
|
||||
startPage();
|
||||
List<XzParityCorrection> list = xzParityCorrectionService.selectXzParityCorrectionList(xzParityCorrection);
|
||||
return success(list); // 直接返回数组
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +96,7 @@ public class XzParityCorrectionController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:remove')")
|
||||
@Log(title = "胎次校正", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(xzParityCorrectionService.deleteXzParityCorrectionByIds(ids));
|
||||
|
||||
@ -15,7 +15,7 @@ public class NpMilkProdClasses implements Serializable {
|
||||
private Date updateTime; // 更新时间
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "日期")
|
||||
@Excel(name = "日期", dateFormat = "yyyy-MM-dd") // 添加日期格式
|
||||
private Date datetime;
|
||||
|
||||
@Excel(name = "管理耳号")
|
||||
@ -33,10 +33,10 @@ public class NpMilkProdClasses implements Serializable {
|
||||
@Excel(name = "班次")
|
||||
private Integer classes;
|
||||
|
||||
@Excel(name = "班次产奶量")
|
||||
@Excel(name = "班次产奶量", numFormat = "0.00")
|
||||
private Double milk;
|
||||
|
||||
@Excel(name = "班次校正奶量")
|
||||
@Excel(name = "班次校正奶量", numFormat = "0.00")
|
||||
private Double correctedMilk;
|
||||
|
||||
private String sheepId;
|
||||
|
||||
@ -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(挤奶天数, 筛选天数))
|
||||
// 校正日平均奶量(按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 日平均(系统奶量)
|
||||
// 过去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)
|
||||
// 羊只基础信息(来自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
|
||||
@ -195,4 +258,4 @@ public class NpSheepMilkAnalysis {
|
||||
|
||||
public Date getLastUpdate() { return lastUpdate; }
|
||||
public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; }
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,16 @@
|
||||
package com.zhyc.module.dairyProducts.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 胎次校正对象 xz_parity_correction
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-14
|
||||
* @date 2025-08-24
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class XzParityCorrection extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -30,4 +26,42 @@ public class XzParityCorrection extends BaseEntity
|
||||
@Excel(name = "系数")
|
||||
private Double coef;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setParity(Integer parity)
|
||||
{
|
||||
this.parity = parity;
|
||||
}
|
||||
|
||||
public Integer getParity()
|
||||
{
|
||||
return parity;
|
||||
}
|
||||
|
||||
public void setCoef(Double coef)
|
||||
{
|
||||
this.coef = coef;
|
||||
}
|
||||
|
||||
public Double getCoef()
|
||||
{
|
||||
return coef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("parity", getParity())
|
||||
.append("coef", getCoef())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import java.util.Map;
|
||||
public interface NpSheepMilkAnalysisMapper {
|
||||
|
||||
/**
|
||||
* 按筛选天数 screenDays 统计并返回所有羊只的奶产量分析
|
||||
* 按筛选天数screenDays统计并返回所有羊只的奶产量分析
|
||||
*/
|
||||
List<NpSheepMilkAnalysis> selectAnalysisForExport(@Param("screenDays") Integer screenDays);
|
||||
|
||||
@ -33,4 +33,9 @@ public interface NpSheepMilkAnalysisMapper {
|
||||
*/
|
||||
List<Map<String, Object>> selectMilkRecordsBySheepId(@Param("sheepId") String sheepId);
|
||||
|
||||
}
|
||||
/**
|
||||
* 导出奶产量分析记录
|
||||
*/
|
||||
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisForExport(NpSheepMilkAnalysis analysis);
|
||||
|
||||
}
|
||||
@ -2,20 +2,18 @@ package com.zhyc.module.dairyProducts.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 胎次校正Mapper接口
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-14
|
||||
* @date 2025-08-24
|
||||
*/
|
||||
@Mapper
|
||||
public interface XzParityCorrectionMapper
|
||||
public interface XzParityCorrectionMapper
|
||||
{
|
||||
/**
|
||||
* 查询胎次校正
|
||||
*
|
||||
*
|
||||
* @param id 胎次校正主键
|
||||
* @return 胎次校正
|
||||
*/
|
||||
@ -23,7 +21,7 @@ public interface XzParityCorrectionMapper
|
||||
|
||||
/**
|
||||
* 查询胎次校正列表
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 胎次校正集合
|
||||
*/
|
||||
@ -31,7 +29,7 @@ public interface XzParityCorrectionMapper
|
||||
|
||||
/**
|
||||
* 新增胎次校正
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 结果
|
||||
*/
|
||||
@ -39,7 +37,7 @@ public interface XzParityCorrectionMapper
|
||||
|
||||
/**
|
||||
* 修改胎次校正
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 结果
|
||||
*/
|
||||
@ -47,7 +45,7 @@ public interface XzParityCorrectionMapper
|
||||
|
||||
/**
|
||||
* 删除胎次校正
|
||||
*
|
||||
*
|
||||
* @param id 胎次校正主键
|
||||
* @return 结果
|
||||
*/
|
||||
@ -55,7 +53,7 @@ public interface XzParityCorrectionMapper
|
||||
|
||||
/**
|
||||
* 批量删除胎次校正
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
@ -9,4 +9,9 @@ public interface INpSheepMilkAnalysisService {
|
||||
|
||||
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis);
|
||||
|
||||
}
|
||||
/**
|
||||
* 导出奶产量分析记录
|
||||
*/
|
||||
List<NpSheepMilkAnalysis> selectNpSheepMilkAnalysisForExport(NpSheepMilkAnalysis analysis);
|
||||
|
||||
}
|
||||
@ -1,20 +1,19 @@
|
||||
package com.zhyc.module.dairyProducts.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
|
||||
|
||||
/**
|
||||
* 胎次校正Service接口
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-14
|
||||
* @date 2025-08-24
|
||||
*/
|
||||
public interface IXzParityCorrectionService
|
||||
public interface IXzParityCorrectionService
|
||||
{
|
||||
/**
|
||||
* 查询胎次校正
|
||||
*
|
||||
*
|
||||
* @param id 胎次校正主键
|
||||
* @return 胎次校正
|
||||
*/
|
||||
@ -22,7 +21,7 @@ public interface IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 查询胎次校正列表
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 胎次校正集合
|
||||
*/
|
||||
@ -30,7 +29,7 @@ public interface IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 新增胎次校正
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 结果
|
||||
*/
|
||||
@ -38,7 +37,7 @@ public interface IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 修改胎次校正
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 结果
|
||||
*/
|
||||
@ -46,7 +45,7 @@ public interface IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 批量删除胎次校正
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的胎次校正主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
@ -54,7 +53,7 @@ public interface IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 删除胎次校正信息
|
||||
*
|
||||
*
|
||||
* @param id 胎次校正主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
@ -19,7 +19,7 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
|
||||
@Autowired
|
||||
private NpSheepMilkAnalysisMapper npSheepMilkAnalysisMapper;
|
||||
|
||||
// 将 Rec 定义为静态内部类
|
||||
// 将Rec定义为静态内部类
|
||||
private static class Rec {
|
||||
LocalDate date;
|
||||
double systemMilk;
|
||||
@ -27,7 +27,7 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
|
||||
int parity;
|
||||
}
|
||||
|
||||
// 将 ParityStat 定义为静态内部类
|
||||
// 将ParityStat定义为静态内部类
|
||||
private static class ParityStat {
|
||||
int parity;
|
||||
double sumCorrected;
|
||||
@ -85,7 +85,7 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
|
||||
continue;
|
||||
}
|
||||
|
||||
// 使用静态内部类 Rec
|
||||
// 使用静态内部类Rec
|
||||
List<Rec> recs = new ArrayList<>();
|
||||
for (Map<String, Object> r : records) {
|
||||
Rec rr = new Rec();
|
||||
@ -98,7 +98,7 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
|
||||
|
||||
Map<Integer, List<Rec>> byParity = recs.stream().collect(Collectors.groupingBy(r -> r.parity));
|
||||
|
||||
// 使用静态内部类 ParityStat
|
||||
// 使用静态内部类ParityStat
|
||||
List<ParityStat> parityStats = new ArrayList<>();
|
||||
for (Map.Entry<Integer, List<Rec>> e : byParity.entrySet()) {
|
||||
List<Rec> list = e.getValue();
|
||||
@ -142,7 +142,7 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
|
||||
double sumParity3 = parityStats.stream().filter(p -> p.parity == 3).mapToDouble(p -> p.sumCorrected).sum();
|
||||
double sumParity4 = parityStats.stream().filter(p -> p.parity == 4).mapToDouble(p -> p.sumCorrected).sum();
|
||||
|
||||
// 你之前的 computeParityAvg 方法里没实现,保留调用0
|
||||
// 你之前的computeParityAvg方法里没实现,保留调用0
|
||||
double avgP1 = computeParityAvg(parityStats, 1, screenDays);
|
||||
double avgP2 = computeParityAvg(parityStats, 2, screenDays);
|
||||
double avgP3 = computeParityAvg(parityStats, 3, screenDays);
|
||||
@ -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) {
|
||||
@ -283,4 +289,4 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi
|
||||
}
|
||||
return (count > 0) ? (sum / count) : 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,29 +44,62 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增干物质校正
|
||||
*
|
||||
* @param xzDryMatterCorrection 干物质校正
|
||||
* @return 结果
|
||||
* 新增干物质校正 - 添加默认值和重复校验
|
||||
*/
|
||||
@Override
|
||||
public int insertXzDryMatterCorrection(XzDryMatterCorrection xzDryMatterCorrection)
|
||||
{
|
||||
// 设置干物质标准默认值为18(如果未提供)
|
||||
if (xzDryMatterCorrection.getStandard() == null) {
|
||||
xzDryMatterCorrection.setStandard(18.0);
|
||||
}
|
||||
|
||||
// 检查同年月同厂区是否已存在
|
||||
if (isDuplicateRecord(xzDryMatterCorrection)) {
|
||||
throw new RuntimeException("该厂区在同一年月已存在记录,不能重复添加");
|
||||
}
|
||||
|
||||
return xzDryMatterCorrectionMapper.insertXzDryMatterCorrection(xzDryMatterCorrection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改干物质校正
|
||||
*
|
||||
* @param xzDryMatterCorrection 干物质校正
|
||||
* @return 结果
|
||||
* 修改干物质校正 - 添加重复校验
|
||||
*/
|
||||
@Override
|
||||
public int updateXzDryMatterCorrection(XzDryMatterCorrection xzDryMatterCorrection)
|
||||
{
|
||||
// 检查同年月同厂区是否已存在(排除当前记录)
|
||||
if (isDuplicateRecord(xzDryMatterCorrection)) {
|
||||
throw new RuntimeException("该厂区在同一年月已存在记录,不能重复添加");
|
||||
}
|
||||
|
||||
return xzDryMatterCorrectionMapper.updateXzDryMatterCorrection(xzDryMatterCorrection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查是否存在重复记录(同年月同厂区)
|
||||
*/
|
||||
private boolean isDuplicateRecord(XzDryMatterCorrection xzDryMatterCorrection) {
|
||||
// 查询相同年月和厂区的记录
|
||||
XzDryMatterCorrection query = new XzDryMatterCorrection();
|
||||
query.setDatetime(xzDryMatterCorrection.getDatetime());
|
||||
query.setFactory(xzDryMatterCorrection.getFactory());
|
||||
|
||||
List<XzDryMatterCorrection> existingRecords = xzDryMatterCorrectionMapper.selectXzDryMatterCorrectionList(query);
|
||||
|
||||
// 如果是更新操作,需要排除当前记录
|
||||
if (xzDryMatterCorrection.getId() != null) {
|
||||
return existingRecords.stream()
|
||||
.anyMatch(record ->
|
||||
!record.getId().equals(xzDryMatterCorrection.getId())
|
||||
);
|
||||
}
|
||||
|
||||
// 如果是新增操作,只要存在记录就返回true
|
||||
return !existingRecords.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除干物质校正
|
||||
*
|
||||
|
||||
@ -1,28 +1,27 @@
|
||||
package com.zhyc.module.dairyProducts.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.module.dairyProducts.mapper.XzParityCorrectionMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.dairyProducts.mapper.XzParityCorrectionMapper;
|
||||
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
|
||||
import com.zhyc.module.dairyProducts.service.IXzParityCorrectionService;
|
||||
|
||||
/**
|
||||
* 胎次校正Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-14
|
||||
* @date 2025-08-24
|
||||
*/
|
||||
@Service
|
||||
public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
|
||||
public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
|
||||
{
|
||||
@Autowired
|
||||
private XzParityCorrectionMapper xzParityCorrectionMapper;
|
||||
|
||||
/**
|
||||
* 查询胎次校正
|
||||
*
|
||||
*
|
||||
* @param id 胎次校正主键
|
||||
* @return 胎次校正
|
||||
*/
|
||||
@ -34,7 +33,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 查询胎次校正列表
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 胎次校正
|
||||
*/
|
||||
@ -46,7 +45,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 新增胎次校正
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 结果
|
||||
*/
|
||||
@ -58,7 +57,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 修改胎次校正
|
||||
*
|
||||
*
|
||||
* @param xzParityCorrection 胎次校正
|
||||
* @return 结果
|
||||
*/
|
||||
@ -70,7 +69,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 批量删除胎次校正
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的胎次校正主键
|
||||
* @return 结果
|
||||
*/
|
||||
@ -82,7 +81,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
|
||||
|
||||
/**
|
||||
* 删除胎次校正信息
|
||||
*
|
||||
*
|
||||
* @param id 胎次校正主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package com.zhyc.module.dairyProducts.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import com.zhyc.module.dairyProducts.domain.XzWegihCorrection;
|
||||
import com.zhyc.module.dairyProducts.mapper.XzWegihCorrectionMapper;
|
||||
import com.zhyc.module.dairyProducts.service.IXzWegihCorrectionService;
|
||||
@ -44,27 +47,60 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
|
||||
return xzWegihCorrectionMapper.selectXzWegihCorrectionList(xzWegihCorrection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否已存在相同日期和厂区的记录
|
||||
* @param datetime 日期
|
||||
* @param factory 厂区
|
||||
* @param excludeId 需要排除的ID(用于更新操作时排除自身)
|
||||
* @return 如果存在返回true,否则返回false
|
||||
*/
|
||||
private boolean existsSameDateAndFactory(Date datetime, String factory, Long excludeId) {
|
||||
// 创建一个查询条件对象
|
||||
XzWegihCorrection query = new XzWegihCorrection();
|
||||
query.setDatetime(datetime);
|
||||
query.setFactory(factory);
|
||||
|
||||
// 查询符合条件的记录
|
||||
List<XzWegihCorrection> existingRecords = xzWegihCorrectionMapper.selectXzWegihCorrectionList(query);
|
||||
|
||||
// 如果有需要排除的ID(更新操作),则过滤掉自身
|
||||
if (excludeId != null) {
|
||||
existingRecords = existingRecords.stream()
|
||||
.filter(record -> !record.getId().equals(excludeId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 如果找到记录,返回true
|
||||
return !existingRecords.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增称重校正
|
||||
*
|
||||
* @param xzWegihCorrection 称重校正
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertXzWegihCorrection(XzWegihCorrection xzWegihCorrection)
|
||||
{
|
||||
// 新增前检查是否已存在相同日期和厂区的记录
|
||||
if (existsSameDateAndFactory(xzWegihCorrection.getDatetime(), xzWegihCorrection.getFactory(), null)) {
|
||||
// 抛出异常,提示用户已存在相同记录
|
||||
throw new ServiceException("已存在相同日期和厂区的记录,请勿重复添加");
|
||||
}
|
||||
|
||||
return xzWegihCorrectionMapper.insertXzWegihCorrection(xzWegihCorrection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改称重校正
|
||||
*
|
||||
* @param xzWegihCorrection 称重校正
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateXzWegihCorrection(XzWegihCorrection xzWegihCorrection)
|
||||
{
|
||||
// 更新前检查是否已存在相同日期和厂区的记录(排除自身)
|
||||
if (existsSameDateAndFactory(xzWegihCorrection.getDatetime(), xzWegihCorrection.getFactory(), xzWegihCorrection.getId())) {
|
||||
// 抛出异常,提示用户已存在相同记录
|
||||
throw new ServiceException("已存在相同日期和厂区的记录,无法修改");
|
||||
}
|
||||
|
||||
return xzWegihCorrectionMapper.updateXzWegihCorrection(xzWegihCorrection);
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
package com.zhyc.module.feed.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.feed.domain.SgFeedPlan;
|
||||
import com.zhyc.module.feed.domain.SgFormulaManagement;
|
||||
import com.zhyc.module.feed.service.ISgFeedPlanService;
|
||||
import com.zhyc.module.feed.service.ISgFormulaManagementService;
|
||||
import com.zhyc.module.feed.service.impl.SgFeedListServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -41,19 +38,12 @@ import com.zhyc.common.core.page.TableDataInfo;
|
||||
public class SgFeedListController extends BaseController {
|
||||
private final ISgFeedListService sgFeedListService;
|
||||
|
||||
private final ISgFormulaManagementService sgFormulaManagementService;
|
||||
|
||||
private final ISgFeedPlanService sgFeedPlanService;
|
||||
|
||||
private final Map<String, SgFeedList> sgFeedListMap = new HashMap<>();
|
||||
|
||||
public static boolean refresh = true;
|
||||
|
||||
@Autowired
|
||||
public SgFeedListController(ISgFeedListService sgFeedListService, ISgFormulaManagementService sgFormulaManagementService, ISgFeedPlanService sgFeedPlanService) {
|
||||
public SgFeedListController(ISgFeedListService sgFeedListService) {
|
||||
this.sgFeedListService = sgFeedListService;
|
||||
this.sgFormulaManagementService = sgFormulaManagementService;
|
||||
this.sgFeedPlanService = sgFeedPlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,26 +58,26 @@ public class SgFeedListController extends BaseController {
|
||||
当配方管理表出现更新 或 饲喂计划表出现增删改时会将refresh置为true 通知此处进行刷新
|
||||
*/
|
||||
if (refresh) {
|
||||
SyncFeedList();
|
||||
sgFeedListService.SyncFeedList();
|
||||
refresh = false;
|
||||
}
|
||||
startPage();
|
||||
List<SgFeedList> list = sgFeedListService.selectSgFeedListList(sgFeedList);
|
||||
// 用 map 中已有的数据替换 list 中的元素
|
||||
List<SgFeedList> replacedList = new ArrayList<>();
|
||||
for (SgFeedList item : list) {
|
||||
String key = item.getFormulaId() + "_" + item.getFormulaBatchId();
|
||||
// 从缓存中取出完整对象
|
||||
SgFeedList itemInCache = sgFeedListMap.getOrDefault(key, item);
|
||||
// 将数据库查询的基本信息替换掉缓存中去除的内容 - 前端展示与修改需要
|
||||
itemInCache.setId(item.getId());
|
||||
itemInCache.setFormulaBatchId(item.getFormulaBatchId());
|
||||
itemInCache.setFormulaId(item.getFormulaId());
|
||||
itemInCache.setZookeeper(item.getZookeeper());
|
||||
itemInCache.setDeployDate(item.getDeployDate());
|
||||
// 替换为 map 中的对象
|
||||
replacedList.add(itemInCache);
|
||||
}
|
||||
for (SgFeedList item : list) {
|
||||
String key = item.getFormulaId() + "_" + item.getFormulaBatchId() + "_" + item.getDeployDate();
|
||||
// 从缓存中取出完整对象
|
||||
SgFeedList itemInCache = SgFeedListServiceImpl.getSgFeedListMap().getOrDefault(key, item);
|
||||
// 将数据库查询的基本信息替换掉缓存中去除的内容 - 前端展示与修改需要
|
||||
itemInCache.setId(item.getId());
|
||||
itemInCache.setFormulaBatchId(item.getFormulaBatchId());
|
||||
itemInCache.setFormulaId(item.getFormulaId());
|
||||
itemInCache.setZookeeper(item.getZookeeper());
|
||||
itemInCache.setDeployDate(item.getDeployDate());
|
||||
// 替换为 map 中的对象
|
||||
replacedList.add(itemInCache);
|
||||
}
|
||||
return getDataTable(replacedList);
|
||||
}
|
||||
|
||||
@ -129,6 +119,7 @@ public class SgFeedListController extends BaseController {
|
||||
@Log(title = "配料清单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SgFeedList sgFeedList) {
|
||||
|
||||
return toAjax(sgFeedListService.updateSgFeedList(sgFeedList));
|
||||
}
|
||||
|
||||
@ -143,94 +134,4 @@ public class SgFeedListController extends BaseController {
|
||||
return toAjax(sgFeedListService.deleteSgFeedListByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
public void SyncFeedList() {
|
||||
// 清空旧缓存
|
||||
sgFeedListMap.clear();
|
||||
// 获取配方管理和现有配料清单内容
|
||||
List<SgFormulaManagement> formulaManagementList = sgFormulaManagementService.selectSgFormulaManagementList(new SgFormulaManagement());
|
||||
List<SgFeedList> feedLists = sgFeedListService.selectSgFeedListList(new SgFeedList());
|
||||
// 将最新查询的配料清单加入缓存
|
||||
for (SgFeedList sgFeedList : feedLists) {
|
||||
sgFeedListMap.put(sgFeedList.getFormulaId() + "_" + sgFeedList.getFormulaBatchId(), sgFeedList);
|
||||
}
|
||||
// 与新的配方管理列表同步 - 如果配料清单没有对应数据则加入
|
||||
for (SgFormulaManagement sgFormulaManagement : formulaManagementList) {
|
||||
// 匹配 但忽略模板配方
|
||||
if (sgFormulaManagement.getFormulaId() != null && sgFormulaManagement.getBatchId() != null && !sgFormulaManagement.getBatchId().equals("0")) {
|
||||
// 查询当前配方管理项是否存在现有配料计划中 (不论是否存在都要设置,因为缓存被清空,存在则更新,不存在则插入)
|
||||
boolean isExist = sgFeedListMap.containsKey(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId());
|
||||
// 标志位 : 如果当前配方不在饲喂计划中则不生成配量清单
|
||||
boolean isPlan = true;
|
||||
// 设置缓存对象具体值
|
||||
SgFeedList sgFeedList = new SgFeedList();
|
||||
sgFeedList.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
sgFeedList.setFormulaBatchId(sgFormulaManagement.getBatchId());
|
||||
sgFeedList.setFormulaList(sgFormulaManagement.getSgFormulaList());
|
||||
sgFeedList.setRootFormula(sgFormulaManagement);
|
||||
|
||||
|
||||
// 从饲喂计划列表中查出对应值(饲喂量需要计划中的比例计算)
|
||||
SgFeedPlan rootPlanQuery = new SgFeedPlan();
|
||||
rootPlanQuery.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
rootPlanQuery.setBatchId(sgFormulaManagement.getBatchId());
|
||||
List<SgFeedPlan> sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(rootPlanQuery);
|
||||
// 为空则标识当前配方不在饲喂计划中 && 不在缓存中设置
|
||||
if (sgFeedPlans.isEmpty()) {
|
||||
isPlan = false;
|
||||
} else {
|
||||
// rootPlan中存储的是该配方批号的总量
|
||||
SgFeedPlan rootPlan = computePlanTotal(sgFeedPlans);
|
||||
|
||||
// 将计划实体对象设置到配料清单中
|
||||
sgFeedList.setRootPlan(rootPlan);
|
||||
|
||||
// 完整的配料清单对象加入缓存
|
||||
sgFeedListMap.put(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId(), sgFeedList);
|
||||
}
|
||||
|
||||
// 不存在则插入
|
||||
if (!isExist && isPlan) {
|
||||
sgFeedListService.insertSgFeedList(sgFeedList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算某个配方某个批次的总和值
|
||||
*
|
||||
* @param sgFeedPlans 配方计划列表
|
||||
* @return 各个值总和
|
||||
*/
|
||||
private static SgFeedPlan computePlanTotal(List<SgFeedPlan> sgFeedPlans) {
|
||||
SgFeedPlan rootPlan = new SgFeedPlan();
|
||||
if (!sgFeedPlans.isEmpty()) {
|
||||
int sheepCountTotal = 0;
|
||||
double sheepDailySize = 0.0;
|
||||
double planFeedMorningSize = 0.0;
|
||||
double planFeedNoonSize = 0.0;
|
||||
double planFeedAfternoonSize = 0.0;
|
||||
double planFeedTotalSize = 0.0;
|
||||
for (SgFeedPlan sgFeedPlan : sgFeedPlans) {
|
||||
sheepCountTotal += sgFeedPlan.getSheepCount();
|
||||
sheepDailySize += sgFeedPlan.getPlanDailySize();
|
||||
planFeedMorningSize += sgFeedPlan.getPlanMorningSize();
|
||||
planFeedNoonSize += sgFeedPlan.getPlanNoonSize();
|
||||
planFeedAfternoonSize += sgFeedPlan.getPlanAfternoonSize();
|
||||
planFeedTotalSize += sgFeedPlan.getPlanFeedTotal();
|
||||
}
|
||||
|
||||
rootPlan.setSheepCount(sheepCountTotal);
|
||||
rootPlan.setPlanDailySize(sheepDailySize);
|
||||
rootPlan.setPlanMorningSize(planFeedMorningSize);
|
||||
rootPlan.setPlanNoonSize(planFeedNoonSize);
|
||||
rootPlan.setPlanAfternoonSize(planFeedAfternoonSize);
|
||||
rootPlan.setPlanFeedTotal(planFeedTotalSize);
|
||||
|
||||
// 设置计划日期
|
||||
rootPlan.setPlanDate(sgFeedPlans.get(0).getPlanDate());
|
||||
}
|
||||
return rootPlan;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,129 @@
|
||||
package com.zhyc.module.feed.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.common.utils.uuid.UUID;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.zhyc.common.annotation.Log;
|
||||
import com.zhyc.common.core.controller.BaseController;
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.module.feed.domain.SgFeedStatistic;
|
||||
import com.zhyc.module.feed.service.ISgFeedStatisticService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 饲喂量统计Controller
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/feed/FeedStatistic")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SgFeedStatisticController extends BaseController {
|
||||
private final ISgFeedStatisticService sgFeedStatisticService;
|
||||
|
||||
|
||||
|
||||
public SgFeedStatisticController(ISgFeedStatisticService sgFeedStatisticService) {
|
||||
this.sgFeedStatisticService = sgFeedStatisticService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询饲喂量统计列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedStatistic:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SgFeedStatistic sgFeedStatistic) {
|
||||
startPage();
|
||||
List<SgFeedStatistic> list = sgFeedStatisticService.selectSgFeedStatisticList(sgFeedStatistic);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出饲喂量统计列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedStatistic:export')")
|
||||
@Log(title = "饲喂量统计", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SgFeedStatistic sgFeedStatistic) {
|
||||
List<SgFeedStatistic> list = sgFeedStatisticService.selectSgFeedStatisticList(sgFeedStatistic);
|
||||
ExcelUtil<SgFeedStatistic> util = new ExcelUtil<>(SgFeedStatistic.class);
|
||||
util.exportExcel(response, list, "饲喂量统计数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取饲喂量统计详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedStatistic:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id) {
|
||||
return success(sgFeedStatisticService.selectSgFeedStatisticById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增饲喂量统计
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedStatistic:add')")
|
||||
@Log(title = "饲喂量统计", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SgFeedStatistic sgFeedStatistic) {
|
||||
if (null == sgFeedStatistic.getFormulaId() && null == sgFeedStatistic.getFormulaBatchId()) {
|
||||
throw new RuntimeException("ERROR: 数据为空");
|
||||
}
|
||||
List<SgFeedStatistic> isExist = sgFeedStatisticService.selectSgFeedStatisticList(sgFeedStatistic);
|
||||
if (null != isExist && !isExist.isEmpty()) {
|
||||
throw new RuntimeException("WARNING: 数据重复");
|
||||
}
|
||||
// 设定唯一标识符主键
|
||||
sgFeedStatistic.setId(UUID.randomUUID().toString());
|
||||
/*
|
||||
* 初始化数据
|
||||
* 弃用: 此处不再需要初始化,前端选定批号后会触发预载, 此处再初始化会覆盖前端后续的自定义数据
|
||||
*/
|
||||
// sgFeedStatisticService.getInitSgFeedStatistic(sgFeedStatistic);
|
||||
return toAjax(sgFeedStatisticService.insertSgFeedStatistic(sgFeedStatistic));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改饲喂量统计
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedStatistic:edit')")
|
||||
@Log(title = "饲喂量统计", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SgFeedStatistic sgFeedStatistic) {
|
||||
return toAjax(sgFeedStatisticService.updateSgFeedStatistic(sgFeedStatistic));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除饲喂量统计
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedStatistic:remove')")
|
||||
@Log(title = "饲喂量统计", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids) {
|
||||
return toAjax(sgFeedStatisticService.deleteSgFeedStatisticByIds(ids));
|
||||
}
|
||||
|
||||
@GetMapping("/init")
|
||||
public TableDataInfo getInitData(SgFeedStatistic sgFeedStatistic){
|
||||
sgFeedStatisticService.getInitSgFeedStatistic(sgFeedStatistic);
|
||||
// 兼容写法 - 实际只是为了返回一个 sgFeedStatistic
|
||||
List<SgFeedStatistic> list = new ArrayList<>();
|
||||
list.add(sgFeedStatistic);
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
@ -53,6 +53,8 @@ public class SgFeedList extends BaseEntity
|
||||
|
||||
private List<SgFormulaList> formulaList;
|
||||
|
||||
private List<SgFeedPlan> planList;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@ -0,0 +1,98 @@
|
||||
package com.zhyc.module.feed.domain;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.zhyc.module.base.domain.DaSheepfold;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 饲喂量统计对象 sg_feed_statistic
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class SgFeedStatistic extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 配方编号
|
||||
*/
|
||||
@Excel(name = "配方编号")
|
||||
private String formulaId;
|
||||
|
||||
/**
|
||||
* 配方批号
|
||||
*/
|
||||
@Excel(name = "配方批号")
|
||||
private String formulaBatchId;
|
||||
|
||||
/**
|
||||
* 羊只数量
|
||||
*/
|
||||
@Excel(name = "羊只数量")
|
||||
private Long sheepFoldCount;
|
||||
|
||||
/**
|
||||
* 青贮损耗比例
|
||||
*/
|
||||
@Excel(name = "青贮损耗比例")
|
||||
private String silageLossRate;
|
||||
|
||||
/**
|
||||
* 总饲喂量
|
||||
*/
|
||||
@Excel(name = "总饲喂量")
|
||||
private Double feedTotalSize;
|
||||
|
||||
/**
|
||||
* 日均饲喂量
|
||||
*/
|
||||
@Excel(name = "日均饲喂量")
|
||||
private Double feedDailySize;
|
||||
|
||||
/**
|
||||
* 配方列表
|
||||
*/
|
||||
@Excel(name = "配方列表")
|
||||
private List<SgFormulaList> materialList;
|
||||
|
||||
/**
|
||||
* 羊舍列表
|
||||
*/
|
||||
@Excel(name = "羊舍列表")
|
||||
private List<DaSheepfold> sheepFoldList;
|
||||
|
||||
@Excel(name = "日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date feedDate;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("formulaId", getFormulaId())
|
||||
.append("formulaBatchId", getFormulaBatchId())
|
||||
.append("sheepFoldCount", getSheepFoldCount())
|
||||
.append("silageLossRate", getSilageLossRate())
|
||||
.append("feedTotalSize", getFeedTotalSize())
|
||||
.append("feedDailySize", getFeedDailySize())
|
||||
.append("materialList", getMaterialList())
|
||||
.append("sheepFoldList", getSheepFoldList())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -39,14 +39,25 @@ public class SgFormulaList extends BaseEntity
|
||||
@Excel(name = "比例")
|
||||
private Long ratio;
|
||||
|
||||
/** 颗粒原料 */
|
||||
/**
|
||||
* 颗粒原料
|
||||
* 当前不局限于 "是否颗粒原料" 而且多种类型的标识符
|
||||
*/
|
||||
@Excel(name = "颗粒原料")
|
||||
private String isGranular;
|
||||
|
||||
/** 补饲 */
|
||||
/**
|
||||
* 补饲
|
||||
* 当前用作饲喂类型标识
|
||||
*/
|
||||
@Excel(name = "补饲")
|
||||
private String isSupplement;
|
||||
|
||||
/**
|
||||
* 添加量 - 供其他一些统计模块使用
|
||||
*/
|
||||
private Double feedSize;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
||||
@ -60,4 +60,7 @@ public interface SgFeedListMapper
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListByIds(Long[] ids);
|
||||
|
||||
// 清空所有
|
||||
int deleteAll();
|
||||
}
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
package com.zhyc.module.feed.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.feed.domain.SgFeedStatistic;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 饲喂量统计Mapper接口
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
@Mapper
|
||||
public interface SgFeedStatisticMapper
|
||||
{
|
||||
/**
|
||||
* 查询饲喂量统计
|
||||
*
|
||||
* @param id 饲喂量统计主键
|
||||
* @return 饲喂量统计
|
||||
*/
|
||||
SgFeedStatistic selectSgFeedStatisticById(String id);
|
||||
|
||||
/**
|
||||
* 查询饲喂量统计列表
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 饲喂量统计集合
|
||||
*/
|
||||
List<SgFeedStatistic> selectSgFeedStatisticList(SgFeedStatistic sgFeedStatistic);
|
||||
|
||||
/**
|
||||
* 新增饲喂量统计
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
|
||||
|
||||
/**
|
||||
* 修改饲喂量统计
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
|
||||
|
||||
/**
|
||||
* 删除饲喂量统计
|
||||
*
|
||||
* @param id 饲喂量统计主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedStatisticById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除饲喂量统计
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedStatisticByIds(String[] ids);
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.zhyc.module.feed.mapper.TypeHandler;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.zhyc.module.base.domain.DaSheepfold;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
@MappedTypes(List.class)
|
||||
public class DaSheepfoldHandler extends BaseTypeHandler<List<DaSheepfold>> {
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i,
|
||||
List<DaSheepfold> parameter, JdbcType jdbcType) throws SQLException {
|
||||
ps.setString(i, JSON.toJSONString(parameter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DaSheepfold> getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return JSON.parseArray(rs.getString(columnName), DaSheepfold.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DaSheepfold> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return JSON.parseArray(rs.getString(columnIndex), DaSheepfold.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DaSheepfold> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return JSON.parseArray(cs.getString(columnIndex), DaSheepfold.class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
package com.zhyc.module.feed.mapper.TypeHandler;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class JsonTypeHandler<T> extends BaseTypeHandler<T> {
|
||||
private final Class<T> type;
|
||||
|
||||
public JsonTypeHandler(Class<T> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
|
||||
ps.setString(i, JSON.toJSONString(parameter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String json = rs.getString(columnName);
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String json = rs.getString(columnIndex);
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String json = cs.getString(columnIndex);
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.zhyc.module.feed.mapper.TypeHandler;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.zhyc.module.feed.domain.SgFormulaList;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
@MappedTypes(List.class)
|
||||
public class SgFormulaListHandler extends BaseTypeHandler<List<SgFormulaList>> {
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i,
|
||||
List<SgFormulaList> parameter, JdbcType jdbcType) throws SQLException {
|
||||
ps.setString(i, JSON.toJSONString(parameter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SgFormulaList> getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return JSON.parseArray(rs.getString(columnName), SgFormulaList.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SgFormulaList> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return JSON.parseArray(rs.getString(columnIndex), SgFormulaList.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SgFormulaList> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return JSON.parseArray(cs.getString(columnIndex), SgFormulaList.class);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.zhyc.module.feed.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
|
||||
/**
|
||||
@ -9,8 +10,7 @@ import com.zhyc.module.feed.domain.SgFeedList;
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
public interface ISgFeedListService
|
||||
{
|
||||
public interface ISgFeedListService {
|
||||
/**
|
||||
* 查询配料清单
|
||||
*
|
||||
@ -58,4 +58,6 @@ public interface ISgFeedListService
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListById(Long id);
|
||||
|
||||
void SyncFeedList();
|
||||
}
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
package com.zhyc.module.feed.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.feed.domain.SgFeedStatistic;
|
||||
|
||||
/**
|
||||
* 饲喂量统计Service接口
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
public interface ISgFeedStatisticService
|
||||
{
|
||||
/**
|
||||
* 查询饲喂量统计
|
||||
*
|
||||
* @param id 饲喂量统计主键
|
||||
* @return 饲喂量统计
|
||||
*/
|
||||
SgFeedStatistic selectSgFeedStatisticById(String id);
|
||||
|
||||
/**
|
||||
* 查询饲喂量统计列表
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 饲喂量统计集合
|
||||
*/
|
||||
List<SgFeedStatistic> selectSgFeedStatisticList(SgFeedStatistic sgFeedStatistic);
|
||||
|
||||
/**
|
||||
* 新增饲喂量统计
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
|
||||
|
||||
/**
|
||||
* 修改饲喂量统计
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
|
||||
|
||||
/**
|
||||
* 批量删除饲喂量统计
|
||||
*
|
||||
* @param ids 需要删除的饲喂量统计主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedStatisticByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除饲喂量统计信息
|
||||
*
|
||||
* @param id 饲喂量统计主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedStatisticById(String id);
|
||||
|
||||
void getInitSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
|
||||
|
||||
|
||||
}
|
||||
@ -1,7 +1,12 @@
|
||||
package com.zhyc.module.feed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import com.zhyc.module.feed.domain.SgFeedPlan;
|
||||
import com.zhyc.module.feed.domain.SgFormulaManagement;
|
||||
import com.zhyc.module.feed.service.ISgFeedPlanService;
|
||||
import com.zhyc.module.feed.service.ISgFormulaManagementService;
|
||||
import lombok.Getter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.feed.mapper.SgFeedListMapper;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
@ -14,12 +19,23 @@ import com.zhyc.module.feed.service.ISgFeedListService;
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Service
|
||||
public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
{
|
||||
public class SgFeedListServiceImpl implements ISgFeedListService {
|
||||
private final SgFeedListMapper sgFeedListMapper;
|
||||
private final ISgFormulaManagementService sgFormulaManagementService;
|
||||
private final ISgFeedPlanService sgFeedPlanService;
|
||||
@Getter
|
||||
private final static Map<String, SgFeedList> sgFeedListMap = new HashMap<>();
|
||||
|
||||
public SgFeedListServiceImpl(SgFeedListMapper sgFeedListMapper) {
|
||||
public SgFeedListServiceImpl(SgFeedListMapper sgFeedListMapper, ISgFormulaManagementService sgFormulaManagementService, ISgFeedPlanService sgFeedPlanService) {
|
||||
this.sgFeedListMapper = sgFeedListMapper;
|
||||
this.sgFormulaManagementService = sgFormulaManagementService;
|
||||
this.sgFeedPlanService = sgFeedPlanService;
|
||||
// 构造时将数据库初始数据写入缓存
|
||||
List<SgFeedList> feedListsFromDataBase = this.selectSgFeedListList(new SgFeedList());
|
||||
for (SgFeedList sgFeedListItem : feedListsFromDataBase) {
|
||||
String key = sgFeedListItem.getFormulaId() + "_" + sgFeedListItem.getFormulaBatchId() + "_" + sgFeedListItem.getDeployDate();
|
||||
sgFeedListMap.put(key, sgFeedListItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,8 +45,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
* @return 配料清单
|
||||
*/
|
||||
@Override
|
||||
public SgFeedList selectSgFeedListById(Long id)
|
||||
{
|
||||
public SgFeedList selectSgFeedListById(Long id) {
|
||||
return sgFeedListMapper.selectSgFeedListById(id);
|
||||
}
|
||||
|
||||
@ -41,8 +56,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
* @return 配料清单
|
||||
*/
|
||||
@Override
|
||||
public List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList)
|
||||
{
|
||||
public List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList) {
|
||||
return sgFeedListMapper.selectSgFeedListList(sgFeedList);
|
||||
}
|
||||
|
||||
@ -53,8 +67,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSgFeedList(SgFeedList sgFeedList)
|
||||
{
|
||||
public int insertSgFeedList(SgFeedList sgFeedList) {
|
||||
return sgFeedListMapper.insertSgFeedList(sgFeedList);
|
||||
}
|
||||
|
||||
@ -65,8 +78,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSgFeedList(SgFeedList sgFeedList)
|
||||
{
|
||||
public int updateSgFeedList(SgFeedList sgFeedList) {
|
||||
return sgFeedListMapper.updateSgFeedList(sgFeedList);
|
||||
}
|
||||
|
||||
@ -77,8 +89,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgFeedListByIds(Long[] ids)
|
||||
{
|
||||
public int deleteSgFeedListByIds(Long[] ids) {
|
||||
return sgFeedListMapper.deleteSgFeedListByIds(ids);
|
||||
}
|
||||
|
||||
@ -89,8 +100,166 @@ public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgFeedListById(Long id)
|
||||
{
|
||||
public int deleteSgFeedListById(Long id) {
|
||||
return sgFeedListMapper.deleteSgFeedListById(id);
|
||||
}
|
||||
|
||||
public void SyncFeedList_old() {
|
||||
// 清空旧缓存
|
||||
sgFeedListMap.clear();
|
||||
// 获取配方管理和现有配料清单内容
|
||||
List<SgFormulaManagement> formulaManagementList = sgFormulaManagementService.selectSgFormulaManagementList(new SgFormulaManagement());
|
||||
List<SgFeedList> feedLists = this.selectSgFeedListList(new SgFeedList());
|
||||
// 将最新查询的配料清单加入缓存
|
||||
for (SgFeedList sgFeedList : feedLists) {
|
||||
sgFeedListMap.put(sgFeedList.getFormulaId() + "_" + sgFeedList.getFormulaBatchId(), sgFeedList);
|
||||
}
|
||||
// 与新的配方管理列表同步 - 如果配料清单没有对应数据则加入
|
||||
for (SgFormulaManagement sgFormulaManagement : formulaManagementList) {
|
||||
// 匹配 但忽略模板配方
|
||||
if (sgFormulaManagement.getFormulaId() != null && sgFormulaManagement.getBatchId() != null && !sgFormulaManagement.getBatchId().equals("0")) {
|
||||
// 查询当前配方管理项是否存在现有配料计划中 (不论是否存在都要设置,因为缓存被清空,存在则更新,不存在则插入)
|
||||
boolean isExist = sgFeedListMap.containsKey(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId());
|
||||
// 标志位 : 如果当前配方不在饲喂计划中则不生成配量清单
|
||||
boolean isPlan = true;
|
||||
// 设置缓存对象具体值
|
||||
SgFeedList sgFeedList = new SgFeedList();
|
||||
sgFeedList.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
sgFeedList.setFormulaBatchId(sgFormulaManagement.getBatchId());
|
||||
sgFeedList.setFormulaList(sgFormulaManagement.getSgFormulaList());
|
||||
sgFeedList.setRootFormula(sgFormulaManagement);
|
||||
|
||||
|
||||
// 从饲喂计划列表中查出对应值(饲喂量需要计划中的比例计算)
|
||||
SgFeedPlan rootPlanQuery = new SgFeedPlan();
|
||||
rootPlanQuery.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
rootPlanQuery.setBatchId(sgFormulaManagement.getBatchId());
|
||||
List<SgFeedPlan> sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(rootPlanQuery);
|
||||
// 为空则标识当前配方不在饲喂计划中 && 不在缓存中设置
|
||||
if (sgFeedPlans.isEmpty()) {
|
||||
isPlan = false;
|
||||
} else {
|
||||
// rootPlan中存储的是该配方批号的总量
|
||||
SgFeedPlan rootPlan = computePlanTotal(sgFeedPlans);
|
||||
|
||||
// 将计划实体对象设置到配料清单中
|
||||
sgFeedList.setRootPlan(rootPlan);
|
||||
|
||||
// 完整的配料清单对象加入缓存
|
||||
sgFeedListMap.put(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId(), sgFeedList);
|
||||
}
|
||||
|
||||
// 不存在则插入
|
||||
if (!isExist && isPlan) {
|
||||
this.insertSgFeedList(sgFeedList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SyncFeedList() {
|
||||
HashMap<String, SgFeedList> cacheTemp = new HashMap<>(sgFeedListMap);
|
||||
// 清空旧缓存
|
||||
sgFeedListMap.clear();
|
||||
List<SgFeedPlan> sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(new SgFeedPlan());
|
||||
List<List<SgFeedPlan>> planGroups = new ArrayList<>();
|
||||
List<SgFeedPlan> currentFeedPlan = new ArrayList<>();
|
||||
if (!sgFeedPlans.isEmpty()) {
|
||||
String currentFormulaId = sgFeedPlans.get(0).getFormulaId();
|
||||
String currentBatchId = sgFeedPlans.get(0).getBatchId();
|
||||
Date currentDate = sgFeedPlans.get(0).getPlanDate();
|
||||
// 对饲喂计划进行分组
|
||||
for (SgFeedPlan sgFeedPlan : sgFeedPlans) {
|
||||
if (sgFeedPlan.getBatchId() != null && !sgFeedPlan.getBatchId().equals("0")) {
|
||||
if (sgFeedPlan.getFormulaId().equals(currentFormulaId) && sgFeedPlan.getBatchId().equals(currentBatchId) && sgFeedPlan.getPlanDate().equals(currentDate)) {
|
||||
currentFeedPlan.add(sgFeedPlan);
|
||||
} else {
|
||||
currentDate = sgFeedPlan.getPlanDate();
|
||||
currentBatchId = sgFeedPlan.getBatchId();
|
||||
currentFormulaId = sgFeedPlan.getFormulaId();
|
||||
planGroups.add(currentFeedPlan);
|
||||
currentFeedPlan = new ArrayList<>();
|
||||
// 立即插入否则会丢失该元素
|
||||
currentFeedPlan.add(sgFeedPlan);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 插入最后一个列表 - 否则该列表会丢失
|
||||
planGroups.add(currentFeedPlan);
|
||||
// 注册数据 - 每一个List为一个清单
|
||||
for (List<SgFeedPlan> sgFeedPlanList : planGroups) {
|
||||
SgFeedList sgFeedList = new SgFeedList();
|
||||
// 计算饲喂总和
|
||||
SgFeedPlan rootPlan = computePlanTotal(sgFeedPlanList);
|
||||
sgFeedList.setRootPlan(rootPlan);
|
||||
sgFeedList.setPlanList(sgFeedPlanList);
|
||||
// 写入信息
|
||||
sgFeedList.setFormulaId(sgFeedPlanList.get(0).getFormulaId());
|
||||
sgFeedList.setFormulaBatchId(sgFeedPlanList.get(0).getBatchId());
|
||||
sgFeedList.setDeployDate(sgFeedPlanList.get(0).getPlanDate());
|
||||
// 写入配方管理信息
|
||||
SgFormulaManagement formulaManagementQuery = new SgFormulaManagement();
|
||||
formulaManagementQuery.setFormulaId(sgFeedList.getFormulaId());
|
||||
formulaManagementQuery.setBatchId(sgFeedList.getFormulaBatchId());
|
||||
List<SgFormulaManagement> formulaManagements = sgFormulaManagementService.selectSgFormulaManagementList(formulaManagementQuery);
|
||||
if (!formulaManagements.isEmpty()) {
|
||||
sgFeedList.setRootFormula(formulaManagements.get(0));
|
||||
sgFeedList.setFormulaList(formulaManagements.get(0).getSgFormulaList());
|
||||
}
|
||||
String cacheKey = sgFeedList.getFormulaId() + "_" + sgFeedList.getFormulaBatchId() + "_" + sgFeedList.getDeployDate();
|
||||
// 从就缓存中查找,如果存在则更新可修改的值
|
||||
if (cacheTemp.containsKey(cacheKey)) {
|
||||
SgFeedList cacheItem = cacheTemp.get(cacheKey);
|
||||
sgFeedList.setZookeeper(cacheItem.getZookeeper());
|
||||
}
|
||||
sgFeedListMap.put(cacheKey, sgFeedList);
|
||||
}
|
||||
|
||||
List<SgFeedList> toDataBase = new ArrayList<>(sgFeedListMap.values());
|
||||
// 清空再写入
|
||||
this.sgFeedListMapper.deleteAll();
|
||||
// 处理结果写入数据库
|
||||
for (SgFeedList recordItem : toDataBase) {
|
||||
this.insertSgFeedList(recordItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算某个配方某个批次的总和值
|
||||
*
|
||||
* @param sgFeedPlans 配方计划列表
|
||||
* @return 各个值总和
|
||||
*/
|
||||
private static SgFeedPlan computePlanTotal(List<SgFeedPlan> sgFeedPlans) {
|
||||
SgFeedPlan rootPlan = new SgFeedPlan();
|
||||
if (!sgFeedPlans.isEmpty()) {
|
||||
int sheepCountTotal = 0;
|
||||
double sheepDailySize = 0.0;
|
||||
double planFeedMorningSize = 0.0;
|
||||
double planFeedNoonSize = 0.0;
|
||||
double planFeedAfternoonSize = 0.0;
|
||||
double planFeedTotalSize = 0.0;
|
||||
for (SgFeedPlan sgFeedPlan : sgFeedPlans) {
|
||||
sheepCountTotal += sgFeedPlan.getSheepCount();
|
||||
sheepDailySize += sgFeedPlan.getPlanDailySize();
|
||||
planFeedMorningSize += sgFeedPlan.getPlanMorningSize();
|
||||
planFeedNoonSize += sgFeedPlan.getPlanNoonSize();
|
||||
planFeedAfternoonSize += sgFeedPlan.getPlanAfternoonSize();
|
||||
planFeedTotalSize += sgFeedPlan.getPlanFeedTotal();
|
||||
}
|
||||
rootPlan.setFormulaId(sgFeedPlans.get(0).getFormulaId());
|
||||
rootPlan.setBatchId(sgFeedPlans.get(0).getBatchId());
|
||||
rootPlan.setSheepCount(sheepCountTotal);
|
||||
rootPlan.setPlanDailySize(sheepDailySize);
|
||||
rootPlan.setPlanMorningSize(planFeedMorningSize);
|
||||
rootPlan.setPlanNoonSize(planFeedNoonSize);
|
||||
rootPlan.setPlanAfternoonSize(planFeedAfternoonSize);
|
||||
rootPlan.setPlanFeedTotal(planFeedTotalSize);
|
||||
|
||||
// 设置计划日期
|
||||
rootPlan.setPlanDate(sgFeedPlans.get(0).getPlanDate());
|
||||
}
|
||||
return rootPlan;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,176 @@
|
||||
package com.zhyc.module.feed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.zhyc.module.base.domain.DaSheepfold;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
import com.zhyc.module.feed.domain.SgFeedPlan;
|
||||
import com.zhyc.module.feed.domain.SgFormulaList;
|
||||
import com.zhyc.module.feed.service.ISgFeedListService;
|
||||
import com.zhyc.module.feed.service.ISgFeedPlanService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.feed.mapper.SgFeedStatisticMapper;
|
||||
import com.zhyc.module.feed.domain.SgFeedStatistic;
|
||||
import com.zhyc.module.feed.service.ISgFeedStatisticService;
|
||||
|
||||
/**
|
||||
* 饲喂量统计Service业务层处理
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
@Service
|
||||
public class SgFeedStatisticServiceImpl implements ISgFeedStatisticService {
|
||||
private final SgFeedStatisticMapper sgFeedStatisticMapper;
|
||||
|
||||
private final ISgFeedListService sgFeedListService;
|
||||
private final ISgFeedPlanService sgFeedPlanService;
|
||||
|
||||
public SgFeedStatisticServiceImpl(SgFeedStatisticMapper sgFeedStatisticMapper, ISgFeedListService sgFeedListService, ISgFeedPlanService sgFeedPlanService) {
|
||||
this.sgFeedStatisticMapper = sgFeedStatisticMapper;
|
||||
this.sgFeedListService = sgFeedListService;
|
||||
this.sgFeedPlanService = sgFeedPlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询饲喂量统计
|
||||
*
|
||||
* @param id 饲喂量统计主键
|
||||
* @return 饲喂量统计
|
||||
*/
|
||||
@Override
|
||||
public SgFeedStatistic selectSgFeedStatisticById(String id) {
|
||||
return sgFeedStatisticMapper.selectSgFeedStatisticById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询饲喂量统计列表
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 饲喂量统计
|
||||
*/
|
||||
@Override
|
||||
public List<SgFeedStatistic> selectSgFeedStatisticList(SgFeedStatistic sgFeedStatistic) {
|
||||
return sgFeedStatisticMapper.selectSgFeedStatisticList(sgFeedStatistic);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增饲喂量统计
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSgFeedStatistic(SgFeedStatistic sgFeedStatistic) {
|
||||
return sgFeedStatisticMapper.insertSgFeedStatistic(sgFeedStatistic);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改饲喂量统计
|
||||
*
|
||||
* @param sgFeedStatistic 饲喂量统计
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSgFeedStatistic(SgFeedStatistic sgFeedStatistic) {
|
||||
return sgFeedStatisticMapper.updateSgFeedStatistic(sgFeedStatistic);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除饲喂量统计
|
||||
*
|
||||
* @param ids 需要删除的饲喂量统计主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgFeedStatisticByIds(String[] ids) {
|
||||
return sgFeedStatisticMapper.deleteSgFeedStatisticByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除饲喂量统计信息
|
||||
*
|
||||
* @param id 饲喂量统计主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgFeedStatisticById(String id) {
|
||||
return sgFeedStatisticMapper.deleteSgFeedStatisticById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向待插入数据表单提供数据预载服务
|
||||
*
|
||||
* @param sgFeedStatistic 待填充的初始化数据
|
||||
* @author ShiHan Wang
|
||||
*/
|
||||
@Override
|
||||
public void getInitSgFeedStatistic(SgFeedStatistic sgFeedStatistic) {
|
||||
// 1. 查找饲料清单
|
||||
SgFeedList sgFeedListQuery = new SgFeedList();
|
||||
sgFeedListQuery.setFormulaId(sgFeedStatistic.getFormulaId());
|
||||
sgFeedListQuery.setFormulaBatchId(sgFeedStatistic.getFormulaBatchId());
|
||||
|
||||
List<SgFeedList> feedLists = sgFeedListService.selectSgFeedListList(sgFeedListQuery);
|
||||
|
||||
if (!feedLists.isEmpty()) {
|
||||
// 刷新缓存
|
||||
sgFeedListService.SyncFeedList();
|
||||
|
||||
// 从缓存获取完整配方清单
|
||||
String cacheKey = sgFeedStatistic.getFormulaId() + "_" + sgFeedStatistic.getFormulaBatchId() + "_" + sgFeedStatistic.getFeedDate();
|
||||
SgFeedList sgFeedList = SgFeedListServiceImpl.getSgFeedListMap().get(cacheKey);
|
||||
|
||||
if (sgFeedList != null && sgFeedList.getFormulaList() != null) {
|
||||
// 并行流式计算 提高性能
|
||||
sgFeedList.getFormulaList().parallelStream().forEach(item -> {
|
||||
double ratio = item.getRatio() / 100.0;
|
||||
double feedSize = sgFeedList.getRootPlan().getPlanMorningSize() * ratio
|
||||
+ sgFeedList.getRootPlan().getPlanNoonSize() * ratio
|
||||
+ sgFeedList.getRootPlan().getPlanAfternoonSize() * ratio;
|
||||
item.setFeedSize(feedSize);
|
||||
});
|
||||
|
||||
// 统计总和
|
||||
double totalFeedSize = sgFeedList.getFormulaList()
|
||||
.parallelStream()
|
||||
.mapToDouble(SgFormulaList::getFeedSize)
|
||||
.sum();
|
||||
sgFeedStatistic.setMaterialList(sgFeedList.getFormulaList());
|
||||
sgFeedStatistic.setFeedTotalSize(totalFeedSize);
|
||||
} else {
|
||||
throw new RuntimeException("WARNING: 原料数据为空");
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 查找饲喂计划并填充羊舍信息
|
||||
SgFeedPlan sgFeedPlanQuery = new SgFeedPlan();
|
||||
sgFeedPlanQuery.setFormulaId(sgFeedStatistic.getFormulaId());
|
||||
sgFeedPlanQuery.setBatchId(sgFeedStatistic.getFormulaBatchId());
|
||||
sgFeedPlanQuery.setPlanDate(sgFeedStatistic.getFeedDate());
|
||||
List<SgFeedPlan> sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(sgFeedPlanQuery);
|
||||
|
||||
if (!sgFeedPlans.isEmpty()) {
|
||||
// 并行计算提高查询性能
|
||||
List<DaSheepfold> sheepfolds = sgFeedPlans.parallelStream()
|
||||
.map(plan -> {
|
||||
DaSheepfold sheepfold = new DaSheepfold();
|
||||
sheepfold.setId((long) plan.getSheepHouseId());
|
||||
return sheepfold;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
long sheepCount = sgFeedPlans.parallelStream()
|
||||
.mapToLong(SgFeedPlan::getSheepCount)
|
||||
.sum();
|
||||
sgFeedStatistic.setSheepFoldList(sheepfolds);
|
||||
sgFeedStatistic.setSheepFoldCount(sheepCount);
|
||||
// 计算日均饲喂量
|
||||
sgFeedStatistic.setFeedDailySize(sgFeedStatistic.getFeedTotalSize() / sgFeedStatistic.getSheepFoldCount());
|
||||
} else {
|
||||
throw new RuntimeException("WARNING: 不存在该计划");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -31,7 +31,7 @@ public class ScBreastRating extends BaseEntity {
|
||||
*/
|
||||
|
||||
private String sheepId;
|
||||
@Excel(name = "羊只id")
|
||||
@Excel(name = "管理耳号")
|
||||
private String manageTags;
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,134 @@
|
||||
package com.zhyc.module.produce.breed.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.zhyc.common.annotation.Log;
|
||||
import com.zhyc.common.core.controller.BaseController;
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.module.produce.breed.domain.ScMiscarriageRecord;
|
||||
import com.zhyc.module.produce.breed.service.IScMiscarriageRecordService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 流产记录Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/miscarriage/miscarriage")
|
||||
public class ScMiscarriageRecordController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IScMiscarriageRecordService scMiscarriageRecordService;
|
||||
|
||||
/**
|
||||
* 查询流产记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('miscarriage:miscarriage:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
startPage();
|
||||
List<ScMiscarriageRecord> list = scMiscarriageRecordService.selectScMiscarriageRecordList(scMiscarriageRecord);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出流产记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('miscarriage:miscarriage:export')")
|
||||
@Log(title = "流产记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
List<ScMiscarriageRecord> list = scMiscarriageRecordService.selectScMiscarriageRecordList(scMiscarriageRecord);
|
||||
ExcelUtil<ScMiscarriageRecord> util = new ExcelUtil<ScMiscarriageRecord>(ScMiscarriageRecord.class);
|
||||
util.exportExcel(response, list, "流产记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流产记录详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('miscarriage:miscarriage:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(scMiscarriageRecordService.selectScMiscarriageRecordById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据耳号查询羊只信息
|
||||
*/
|
||||
@GetMapping(value = "/sheep/{manageTags}")
|
||||
public AjaxResult getSheepInfo(@PathVariable("manageTags") String manageTags)
|
||||
{
|
||||
Map<String, Object> sheepInfo = scMiscarriageRecordService.selectSheepByManageTags(manageTags);
|
||||
return success(sheepInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流产原因字典
|
||||
*/
|
||||
@GetMapping("/reasonOptions")
|
||||
public AjaxResult getReasonOptions()
|
||||
{
|
||||
// 返回流产原因选项
|
||||
return success(new String[]{
|
||||
"利斯特氏菌病",
|
||||
"子宫积脓",
|
||||
"布鲁氏菌",
|
||||
"弧菌性流产传染性流产",
|
||||
"未知",
|
||||
"滴虫病",
|
||||
"细螺旋体病",
|
||||
"霉菌性流产"
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流产记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('miscarriage:miscarriage:add')")
|
||||
@Log(title = "流产记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
return toAjax(scMiscarriageRecordService.insertScMiscarriageRecord(scMiscarriageRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流产记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('miscarriage:miscarriage:edit')")
|
||||
@Log(title = "流产记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
return toAjax(scMiscarriageRecordService.updateScMiscarriageRecord(scMiscarriageRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流产记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('miscarriage:miscarriage:remove')")
|
||||
@Log(title = "流产记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(scMiscarriageRecordService.deleteScMiscarriageRecordByIds(ids));
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,7 @@ import com.zhyc.common.annotation.Log;
|
||||
import com.zhyc.common.core.controller.BaseController;
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import com.zhyc.module.produce.breed.domain.ScPregnancyRecord;
|
||||
import com.zhyc.module.produce.breed.service.IScPregnancyRecordService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
@ -43,9 +44,14 @@ public class ScPregnancyRecordController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ScPregnancyRecord scPregnancyRecord)
|
||||
{
|
||||
startPage();
|
||||
List<ScPregnancyRecord> list = scPregnancyRecordService.selectScPregnancyRecordList(scPregnancyRecord);
|
||||
return getDataTable(list);
|
||||
try {
|
||||
startPage();
|
||||
List<ScPregnancyRecord> list = scPregnancyRecordService.selectScPregnancyRecordList(scPregnancyRecord);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询孕检记录列表失败", e);
|
||||
return getDataTable(new java.util.ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,9 +62,13 @@ public class ScPregnancyRecordController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ScPregnancyRecord scPregnancyRecord)
|
||||
{
|
||||
List<ScPregnancyRecord> list = scPregnancyRecordService.selectScPregnancyRecordList(scPregnancyRecord);
|
||||
ExcelUtil<ScPregnancyRecord> util = new ExcelUtil<ScPregnancyRecord>(ScPregnancyRecord.class);
|
||||
util.exportExcel(response, list, "孕检记录数据");
|
||||
try {
|
||||
List<ScPregnancyRecord> list = scPregnancyRecordService.selectScPregnancyRecordList(scPregnancyRecord);
|
||||
ExcelUtil<ScPregnancyRecord> util = new ExcelUtil<ScPregnancyRecord>(ScPregnancyRecord.class);
|
||||
util.exportExcel(response, list, "孕检记录数据");
|
||||
} catch (Exception e) {
|
||||
logger.error("导出孕检记录失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,7 +78,21 @@ public class ScPregnancyRecordController extends BaseController
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(scPregnancyRecordService.selectScPregnancyRecordById(id));
|
||||
try {
|
||||
if (id == null) {
|
||||
return error("记录ID不能为空");
|
||||
}
|
||||
|
||||
ScPregnancyRecord result = scPregnancyRecordService.selectScPregnancyRecordById(id);
|
||||
if (result == null) {
|
||||
return error("记录不存在");
|
||||
}
|
||||
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
logger.error("获取孕检记录详细信息失败,ID: " + id, e);
|
||||
return error("获取记录详细信息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +103,46 @@ public class ScPregnancyRecordController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScPregnancyRecord scPregnancyRecord)
|
||||
{
|
||||
return toAjax(scPregnancyRecordService.insertScPregnancyRecord(scPregnancyRecord));
|
||||
try {
|
||||
// 基础参数校验
|
||||
if (scPregnancyRecord == null) {
|
||||
return error("请求参数不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getManageTags() == null || scPregnancyRecord.getManageTags().trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getDatetime() == null) {
|
||||
return error("孕检日期不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getResult() == null || scPregnancyRecord.getResult().trim().isEmpty()) {
|
||||
return error("孕检结果不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getTechnician() == null || scPregnancyRecord.getTechnician().trim().isEmpty()) {
|
||||
return error("技术员不能为空");
|
||||
}
|
||||
|
||||
// 如果孕检方式为空,默认设置为B超
|
||||
if (scPregnancyRecord.getWay() == null || scPregnancyRecord.getWay().trim().isEmpty()) {
|
||||
scPregnancyRecord.setWay("B超");
|
||||
}
|
||||
|
||||
int result = scPregnancyRecordService.insertScPregnancyRecord(scPregnancyRecord);
|
||||
if (result > 0) {
|
||||
return success("新增成功");
|
||||
} else {
|
||||
return error("新增失败");
|
||||
}
|
||||
} catch (ServiceException e) {
|
||||
logger.warn("新增孕检记录业务异常: " + e.getMessage());
|
||||
return error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("新增孕检记录失败", e);
|
||||
return error("新增失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +153,45 @@ public class ScPregnancyRecordController extends BaseController
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ScPregnancyRecord scPregnancyRecord)
|
||||
{
|
||||
return toAjax(scPregnancyRecordService.updateScPregnancyRecord(scPregnancyRecord));
|
||||
try {
|
||||
// 基础参数校验
|
||||
if (scPregnancyRecord == null) {
|
||||
return error("请求参数不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getId() == null) {
|
||||
return error("记录ID不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getManageTags() == null || scPregnancyRecord.getManageTags().trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getDatetime() == null) {
|
||||
return error("孕检日期不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getResult() == null || scPregnancyRecord.getResult().trim().isEmpty()) {
|
||||
return error("孕检结果不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getTechnician() == null || scPregnancyRecord.getTechnician().trim().isEmpty()) {
|
||||
return error("技术员不能为空");
|
||||
}
|
||||
|
||||
int result = scPregnancyRecordService.updateScPregnancyRecord(scPregnancyRecord);
|
||||
if (result > 0) {
|
||||
return success("修改成功");
|
||||
} else {
|
||||
return error("修改失败,记录可能不存在");
|
||||
}
|
||||
} catch (ServiceException e) {
|
||||
logger.warn("修改孕检记录业务异常: " + e.getMessage());
|
||||
return error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("修改孕检记录失败", e);
|
||||
return error("修改失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +202,24 @@ public class ScPregnancyRecordController extends BaseController
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(scPregnancyRecordService.deleteScPregnancyRecordByIds(ids));
|
||||
try {
|
||||
if (ids == null || ids.length == 0) {
|
||||
return error("删除的记录ID不能为空");
|
||||
}
|
||||
|
||||
int result = scPregnancyRecordService.deleteScPregnancyRecordByIds(ids);
|
||||
if (result > 0) {
|
||||
return success("删除成功");
|
||||
} else {
|
||||
return error("删除失败,记录可能不存在");
|
||||
}
|
||||
} catch (ServiceException e) {
|
||||
logger.warn("删除孕检记录业务异常: " + e.getMessage());
|
||||
return error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("删除孕检记录失败", e);
|
||||
return error("删除失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +228,47 @@ public class ScPregnancyRecordController extends BaseController
|
||||
@GetMapping("/getSheepByManageTags")
|
||||
public AjaxResult getSheepByManageTags(@RequestParam("manageTags") String manageTags)
|
||||
{
|
||||
Map<String, Object> sheepInfo = scPregnancyRecordService.getSheepByManageTags(manageTags);
|
||||
return success(sheepInfo);
|
||||
try {
|
||||
if (manageTags == null || manageTags.trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
}
|
||||
|
||||
Map<String, Object> sheepInfo = scPregnancyRecordService.getSheepByManageTags(manageTags.trim());
|
||||
if (sheepInfo == null) {
|
||||
return error("未找到该耳号的羊只信息");
|
||||
}
|
||||
|
||||
return success(sheepInfo);
|
||||
} catch (ServiceException e) {
|
||||
return error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("查询羊只信息失败,管理耳号: " + manageTags, e);
|
||||
return error("查询羊只信息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据耳号获取配种信息
|
||||
*/
|
||||
@GetMapping("/getBreedInfoByManageTags")
|
||||
public AjaxResult getBreedInfoByManageTags(@RequestParam("manageTags") String manageTags)
|
||||
{
|
||||
try {
|
||||
if (manageTags == null || manageTags.trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
}
|
||||
|
||||
Map<String, Object> breedInfo = scPregnancyRecordService.getBreedInfoByManageTags(manageTags.trim());
|
||||
if (breedInfo == null) {
|
||||
return error("未找到该耳号的配种信息");
|
||||
}
|
||||
|
||||
return success(breedInfo);
|
||||
} catch (ServiceException e) {
|
||||
return error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("查询配种信息失败,管理耳号: " + manageTags, e);
|
||||
return error("查询配种信息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,7 @@ import com.zhyc.common.annotation.Log;
|
||||
import com.zhyc.common.core.controller.BaseController;
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import com.zhyc.module.produce.breed.domain.ScSheepDeath;
|
||||
import com.zhyc.module.produce.breed.service.IScSheepDeathService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
@ -42,9 +43,14 @@ public class ScSheepDeathController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ScSheepDeath scSheepDeath)
|
||||
{
|
||||
startPage();
|
||||
List<ScSheepDeath> list = scSheepDeathService.selectScSheepDeathList(scSheepDeath);
|
||||
return getDataTable(list);
|
||||
try {
|
||||
startPage();
|
||||
List<ScSheepDeath> list = scSheepDeathService.selectScSheepDeathList(scSheepDeath);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询羊只死淘记录列表失败", e);
|
||||
return getDataTable(new java.util.ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,11 +60,20 @@ public class ScSheepDeathController extends BaseController
|
||||
@GetMapping("/sheepInfo/{manageTags}")
|
||||
public AjaxResult getSheepInfo(@PathVariable("manageTags") String manageTags)
|
||||
{
|
||||
Map<String, Object> sheepInfo = scSheepDeathService.selectSheepFileByManageTags(manageTags);
|
||||
if (sheepInfo != null) {
|
||||
return success(sheepInfo);
|
||||
} else {
|
||||
return error("未找到该耳号对应的羊只信息");
|
||||
try {
|
||||
if (manageTags == null || manageTags.trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
}
|
||||
|
||||
Map<String, Object> sheepInfo = scSheepDeathService.selectSheepFileByManageTags(manageTags.trim());
|
||||
if (sheepInfo != null) {
|
||||
return success(sheepInfo);
|
||||
} else {
|
||||
return error("未找到该耳号对应的羊只信息");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("查询羊只信息失败,管理耳号: " + manageTags, e);
|
||||
return error("查询羊只信息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,9 +85,14 @@ public class ScSheepDeathController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ScSheepDeath scSheepDeath)
|
||||
{
|
||||
List<ScSheepDeath> list = scSheepDeathService.selectScSheepDeathList(scSheepDeath);
|
||||
ExcelUtil<ScSheepDeath> util = new ExcelUtil<ScSheepDeath>(ScSheepDeath.class);
|
||||
util.exportExcel(response, list, "羊只死淘记录数据");
|
||||
try {
|
||||
List<ScSheepDeath> list = scSheepDeathService.selectScSheepDeathList(scSheepDeath);
|
||||
ExcelUtil<ScSheepDeath> util = new ExcelUtil<ScSheepDeath>(ScSheepDeath.class);
|
||||
util.exportExcel(response, list, "羊只死淘记录数据");
|
||||
} catch (Exception e) {
|
||||
logger.error("导出羊只死淘记录失败", e);
|
||||
// 可以在这里返回错误响应
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +102,21 @@ public class ScSheepDeathController extends BaseController
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(scSheepDeathService.selectScSheepDeathById(id));
|
||||
try {
|
||||
if (id == null) {
|
||||
return error("记录ID不能为空");
|
||||
}
|
||||
|
||||
ScSheepDeath result = scSheepDeathService.selectScSheepDeathById(id);
|
||||
if (result == null) {
|
||||
return error("记录不存在");
|
||||
}
|
||||
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
logger.error("获取羊只死淘记录详细信息失败,ID: " + id, e);
|
||||
return error("获取记录详细信息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +127,33 @@ public class ScSheepDeathController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ScSheepDeath scSheepDeath)
|
||||
{
|
||||
return toAjax(scSheepDeathService.insertScSheepDeath(scSheepDeath));
|
||||
try {
|
||||
// 基础参数校验
|
||||
if (scSheepDeath == null) {
|
||||
return error("请求参数不能为空");
|
||||
}
|
||||
|
||||
if (scSheepDeath.getManageTags() == null || scSheepDeath.getManageTags().trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
}
|
||||
|
||||
if (scSheepDeath.getDeathDate() == null) {
|
||||
return error("死淘日期不能为空");
|
||||
}
|
||||
|
||||
int result = scSheepDeathService.insertScSheepDeath(scSheepDeath);
|
||||
if (result > 0) {
|
||||
return success("新增成功");
|
||||
} else {
|
||||
return error("新增失败");
|
||||
}
|
||||
} catch (ServiceException e) {
|
||||
logger.warn("新增羊只死淘记录业务异常: " + e.getMessage());
|
||||
return error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("新增羊只死淘记录失败", e);
|
||||
return error("新增失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +164,37 @@ public class ScSheepDeathController extends BaseController
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ScSheepDeath scSheepDeath)
|
||||
{
|
||||
return toAjax(scSheepDeathService.updateScSheepDeath(scSheepDeath));
|
||||
try {
|
||||
// 基础参数校验
|
||||
if (scSheepDeath == null) {
|
||||
return error("请求参数不能为空");
|
||||
}
|
||||
|
||||
if (scSheepDeath.getId() == null) {
|
||||
return error("记录ID不能为空");
|
||||
}
|
||||
|
||||
if (scSheepDeath.getManageTags() == null || scSheepDeath.getManageTags().trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
}
|
||||
|
||||
if (scSheepDeath.getDeathDate() == null) {
|
||||
return error("死淘日期不能为空");
|
||||
}
|
||||
|
||||
int result = scSheepDeathService.updateScSheepDeath(scSheepDeath);
|
||||
if (result > 0) {
|
||||
return success("修改成功");
|
||||
} else {
|
||||
return error("修改失败,记录可能不存在");
|
||||
}
|
||||
} catch (ServiceException e) {
|
||||
logger.warn("修改羊只死淘记录业务异常: " + e.getMessage());
|
||||
return error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("修改羊只死淘记录失败", e);
|
||||
return error("修改失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,6 +205,23 @@ public class ScSheepDeathController extends BaseController
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(scSheepDeathService.deleteScSheepDeathByIds(ids));
|
||||
try {
|
||||
if (ids == null || ids.length == 0) {
|
||||
return error("删除的记录ID不能为空");
|
||||
}
|
||||
|
||||
int result = scSheepDeathService.deleteScSheepDeathByIds(ids);
|
||||
if (result > 0) {
|
||||
return success("删除成功");
|
||||
} else {
|
||||
return error("删除失败,记录可能不存在");
|
||||
}
|
||||
} catch (ServiceException e) {
|
||||
logger.warn("删除羊只死淘记录业务异常: " + e.getMessage());
|
||||
return error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("删除羊只死淘记录失败", e);
|
||||
return error("删除失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,308 @@
|
||||
package com.zhyc.module.produce.breed.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 流产记录对象 sc_miscarriage_record
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
public class ScMiscarriageRecord extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 羊只id */
|
||||
private String sheepId;
|
||||
|
||||
/** 事件日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "事件日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date datetime;
|
||||
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
private String comment;
|
||||
|
||||
/** 技术员 */
|
||||
@Excel(name = "技术员")
|
||||
private String technician;
|
||||
|
||||
/** 流产原因 */
|
||||
@Excel(name = "流产原因")
|
||||
private String reason;
|
||||
|
||||
/** 是否见胎 (1-是, 2-复检无胎, 3-返情) */
|
||||
@Excel(name = "是否见胎", readConverterExp = "1=是,2=复检无胎,3=返情")
|
||||
private Long exposeType;
|
||||
|
||||
/** 是否列胎次 (1-是, 0-否) */
|
||||
@Excel(name = "是否列胎次", readConverterExp = "1=是,0=否")
|
||||
private Long status;
|
||||
|
||||
/** 流产羔羊数 */
|
||||
@Excel(name = "流产羔羊数")
|
||||
private Long miscaLamb;
|
||||
|
||||
// 以下是关联查询字段,不存储到数据库
|
||||
/** 管理耳号 */
|
||||
@Excel(name = "耳号")
|
||||
private String bsManageTags;
|
||||
|
||||
/** 品种 */
|
||||
@Excel(name = "品种")
|
||||
private String variety;
|
||||
|
||||
/** 事件类型 */
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType = "流产";
|
||||
|
||||
/** 配种类型ID */
|
||||
private Integer matingTypeId;
|
||||
|
||||
/** 配种类型 */
|
||||
@Excel(name = "配种类型")
|
||||
private String matingTypeName;
|
||||
|
||||
/** 配种日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "配种日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date matingDate;
|
||||
|
||||
/** 胎次 */
|
||||
@Excel(name = "胎次")
|
||||
private Integer parity;
|
||||
|
||||
/** 配种公羊品种 */
|
||||
@Excel(name = "配种公羊品种")
|
||||
private String ramVariety;
|
||||
|
||||
/** 月龄 */
|
||||
@Excel(name = "月龄")
|
||||
private Long monthAge;
|
||||
|
||||
/** 流产时怀孕天数 */
|
||||
@Excel(name = "流产时怀孕天数")
|
||||
private Integer pregnantDays;
|
||||
|
||||
/** 当前羊舍 */
|
||||
@Excel(name = "当前羊舍")
|
||||
private String sheepfoldName;
|
||||
|
||||
/** 所在牧场 */
|
||||
@Excel(name = "所在牧场")
|
||||
private String drRanch;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setSheepId(String sheepId)
|
||||
{
|
||||
this.sheepId = sheepId;
|
||||
}
|
||||
|
||||
public String getSheepId()
|
||||
{
|
||||
return sheepId;
|
||||
}
|
||||
|
||||
public void setDatetime(Date datetime)
|
||||
{
|
||||
this.datetime = datetime;
|
||||
}
|
||||
|
||||
public Date getDatetime()
|
||||
{
|
||||
return datetime;
|
||||
}
|
||||
|
||||
public void setComment(String comment)
|
||||
{
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getComment()
|
||||
{
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setTechnician(String technician)
|
||||
{
|
||||
this.technician = technician;
|
||||
}
|
||||
|
||||
public String getTechnician()
|
||||
{
|
||||
return technician;
|
||||
}
|
||||
|
||||
public void setReason(String reason)
|
||||
{
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setExposeType(Long exposeType)
|
||||
{
|
||||
this.exposeType = exposeType;
|
||||
}
|
||||
|
||||
public Long getExposeType()
|
||||
{
|
||||
return exposeType;
|
||||
}
|
||||
|
||||
public void setStatus(Long status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setMiscaLamb(Long miscaLamb)
|
||||
{
|
||||
this.miscaLamb = miscaLamb;
|
||||
}
|
||||
|
||||
public Long getMiscaLamb()
|
||||
{
|
||||
return miscaLamb;
|
||||
}
|
||||
|
||||
public String getBsManageTags() {
|
||||
return bsManageTags;
|
||||
}
|
||||
|
||||
public void setBsManageTags(String bsManageTags) {
|
||||
this.bsManageTags = bsManageTags;
|
||||
}
|
||||
|
||||
public String getVariety() {
|
||||
return variety;
|
||||
}
|
||||
|
||||
public void setVariety(String variety) {
|
||||
this.variety = variety;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public void setEventType(String eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public Integer getMatingTypeId() {
|
||||
return matingTypeId;
|
||||
}
|
||||
|
||||
public void setMatingTypeId(Integer matingTypeId) {
|
||||
this.matingTypeId = matingTypeId;
|
||||
}
|
||||
|
||||
public String getMatingTypeName() {
|
||||
return matingTypeName;
|
||||
}
|
||||
|
||||
public void setMatingTypeName(String matingTypeName) {
|
||||
this.matingTypeName = matingTypeName;
|
||||
}
|
||||
|
||||
public Date getMatingDate() {
|
||||
return matingDate;
|
||||
}
|
||||
|
||||
public void setMatingDate(Date matingDate) {
|
||||
this.matingDate = matingDate;
|
||||
}
|
||||
|
||||
public Integer getParity() {
|
||||
return parity;
|
||||
}
|
||||
|
||||
public void setParity(Integer parity) {
|
||||
this.parity = parity;
|
||||
}
|
||||
|
||||
public String getRamVariety() {
|
||||
return ramVariety;
|
||||
}
|
||||
|
||||
public void setRamVariety(String ramVariety) {
|
||||
this.ramVariety = ramVariety;
|
||||
}
|
||||
|
||||
public Long getMonthAge() {
|
||||
return monthAge;
|
||||
}
|
||||
|
||||
public void setMonthAge(Long monthAge) {
|
||||
this.monthAge = monthAge;
|
||||
}
|
||||
|
||||
public Integer getPregnantDays() {
|
||||
return pregnantDays;
|
||||
}
|
||||
|
||||
public void setPregnantDays(Integer pregnantDays) {
|
||||
this.pregnantDays = pregnantDays;
|
||||
}
|
||||
|
||||
public String getSheepfoldName() {
|
||||
return sheepfoldName;
|
||||
}
|
||||
|
||||
public void setSheepfoldName(String sheepfoldName) {
|
||||
this.sheepfoldName = sheepfoldName;
|
||||
}
|
||||
|
||||
public String getDrRanch() {
|
||||
return drRanch;
|
||||
}
|
||||
|
||||
public void setDrRanch(String drRanch) {
|
||||
this.drRanch = drRanch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("sheepId", getSheepId())
|
||||
.append("datetime", getDatetime())
|
||||
.append("comment", getComment())
|
||||
.append("technician", getTechnician())
|
||||
.append("reason", getReason())
|
||||
.append("exposeType", getExposeType())
|
||||
.append("status", getStatus())
|
||||
.append("miscaLamb", getMiscaLamb())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("bsManageTags", getBsManageTags())
|
||||
.append("variety", getVariety())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -116,4 +116,7 @@ public class ScPregnancyRecord extends BaseEntity
|
||||
@Excel(name = "所在牧场")
|
||||
private String ranchName;
|
||||
|
||||
/** 配后天数 */
|
||||
@Excel(name = "配后天数")
|
||||
private Integer daysAfterMating;
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.zhyc.module.produce.breed.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.zhyc.module.produce.breed.domain.ScMiscarriageRecord;
|
||||
|
||||
/**
|
||||
* 流产记录Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
public interface ScMiscarriageRecordMapper
|
||||
{
|
||||
/**
|
||||
* 查询流产记录
|
||||
*
|
||||
* @param id 流产记录主键
|
||||
* @return 流产记录
|
||||
*/
|
||||
public ScMiscarriageRecord selectScMiscarriageRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 查询流产记录列表
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 流产记录集合
|
||||
*/
|
||||
public List<ScMiscarriageRecord> selectScMiscarriageRecordList(ScMiscarriageRecord scMiscarriageRecord);
|
||||
|
||||
/**
|
||||
* 新增流产记录
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertScMiscarriageRecord(ScMiscarriageRecord scMiscarriageRecord);
|
||||
|
||||
/**
|
||||
* 修改流产记录
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateScMiscarriageRecord(ScMiscarriageRecord scMiscarriageRecord);
|
||||
|
||||
/**
|
||||
* 删除流产记录
|
||||
*
|
||||
* @param id 流产记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteScMiscarriageRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除流产记录
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteScMiscarriageRecordByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据耳号查询羊只信息
|
||||
*
|
||||
* @param manageTags 管理耳号
|
||||
* @return 羊只信息
|
||||
*/
|
||||
public Map<String, Object> selectSheepByManageTags(String manageTags);
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.zhyc.module.produce.breed.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.zhyc.module.produce.breed.domain.ScPregnancyRecord;
|
||||
|
||||
/**
|
||||
@ -68,6 +69,14 @@ public interface ScPregnancyRecordMapper
|
||||
*/
|
||||
public Map<String, Object> selectSheepByManageTags(String manageTags);
|
||||
|
||||
/**
|
||||
* 根据耳号获取配种信息
|
||||
*
|
||||
* @param manageTags 耳号
|
||||
* @return 配种信息
|
||||
*/
|
||||
public Map<String, Object> selectBreedInfoByManageTags(String manageTags);
|
||||
|
||||
/**
|
||||
* 更新羊只基础表中的孕检相关字段
|
||||
*
|
||||
|
||||
@ -2,6 +2,7 @@ package com.zhyc.module.produce.breed.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.zhyc.module.produce.breed.domain.ScSheepDeath;
|
||||
|
||||
/**
|
||||
@ -67,4 +68,22 @@ public interface ScSheepDeathMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteScSheepDeathByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 更新羊只繁育状态
|
||||
*
|
||||
* @param sheepId 羊只ID
|
||||
* @param status 繁育状态
|
||||
* @return 更新结果
|
||||
*/
|
||||
public int updateSheepFileStatus(@Param("sheepId") Long sheepId, @Param("status") String status);
|
||||
|
||||
/**
|
||||
* 新增:更新羊只在群状态
|
||||
*
|
||||
* @param sheepId 羊只ID
|
||||
* @param status 在群状态(1-在群,2-不在群)
|
||||
* @return 更新结果
|
||||
*/
|
||||
public int updateSheepStatus(@Param("sheepId") Long sheepId, @Param("status") String status);
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.zhyc.module.produce.breed.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.zhyc.module.produce.breed.domain.ScMiscarriageRecord;
|
||||
|
||||
/**
|
||||
* 流产记录Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
public interface IScMiscarriageRecordService
|
||||
{
|
||||
/**
|
||||
* 查询流产记录
|
||||
*
|
||||
* @param id 流产记录主键
|
||||
* @return 流产记录
|
||||
*/
|
||||
public ScMiscarriageRecord selectScMiscarriageRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 查询流产记录列表
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 流产记录集合
|
||||
*/
|
||||
public List<ScMiscarriageRecord> selectScMiscarriageRecordList(ScMiscarriageRecord scMiscarriageRecord);
|
||||
|
||||
/**
|
||||
* 新增流产记录
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertScMiscarriageRecord(ScMiscarriageRecord scMiscarriageRecord);
|
||||
|
||||
/**
|
||||
* 修改流产记录
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateScMiscarriageRecord(ScMiscarriageRecord scMiscarriageRecord);
|
||||
|
||||
/**
|
||||
* 批量删除流产记录
|
||||
*
|
||||
* @param ids 需要删除的流产记录主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteScMiscarriageRecordByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除流产记录信息
|
||||
*
|
||||
* @param id 流产记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteScMiscarriageRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 根据耳号查询羊只信息
|
||||
*
|
||||
* @param manageTags 管理耳号
|
||||
* @return 羊只信息
|
||||
*/
|
||||
public Map<String, Object> selectSheepByManageTags(String manageTags);
|
||||
}
|
||||
@ -67,4 +67,12 @@ public interface IScPregnancyRecordService
|
||||
* @return 羊只信息
|
||||
*/
|
||||
public Map<String, Object> getSheepByManageTags(String manageTags);
|
||||
|
||||
/**
|
||||
* 根据耳号获取配种信息
|
||||
*
|
||||
* @param manageTags 耳号
|
||||
* @return 配种信息
|
||||
*/
|
||||
public Map<String, Object> getBreedInfoByManageTags(String manageTags);
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.produce.breed.mapper.ScMiscarriageRecordMapper;
|
||||
import com.zhyc.module.produce.breed.domain.ScMiscarriageRecord;
|
||||
import com.zhyc.module.produce.breed.service.IScMiscarriageRecordService;
|
||||
|
||||
/**
|
||||
* 流产记录Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-23
|
||||
*/
|
||||
@Service
|
||||
public class ScMiscarriageRecordServiceImpl implements IScMiscarriageRecordService
|
||||
{
|
||||
@Autowired
|
||||
private ScMiscarriageRecordMapper scMiscarriageRecordMapper;
|
||||
|
||||
/**
|
||||
* 查询流产记录
|
||||
*
|
||||
* @param id 流产记录主键
|
||||
* @return 流产记录
|
||||
*/
|
||||
@Override
|
||||
public ScMiscarriageRecord selectScMiscarriageRecordById(Long id)
|
||||
{
|
||||
return scMiscarriageRecordMapper.selectScMiscarriageRecordById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流产记录列表
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 流产记录
|
||||
*/
|
||||
@Override
|
||||
public List<ScMiscarriageRecord> selectScMiscarriageRecordList(ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
return scMiscarriageRecordMapper.selectScMiscarriageRecordList(scMiscarriageRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流产记录
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertScMiscarriageRecord(ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
scMiscarriageRecord.setCreateTime(DateUtils.getNowDate());
|
||||
return scMiscarriageRecordMapper.insertScMiscarriageRecord(scMiscarriageRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流产记录
|
||||
*
|
||||
* @param scMiscarriageRecord 流产记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateScMiscarriageRecord(ScMiscarriageRecord scMiscarriageRecord)
|
||||
{
|
||||
return scMiscarriageRecordMapper.updateScMiscarriageRecord(scMiscarriageRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除流产记录
|
||||
*
|
||||
* @param ids 需要删除的流产记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteScMiscarriageRecordByIds(Long[] ids)
|
||||
{
|
||||
return scMiscarriageRecordMapper.deleteScMiscarriageRecordByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流产记录信息
|
||||
*
|
||||
* @param id 流产记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteScMiscarriageRecordById(Long id)
|
||||
{
|
||||
return scMiscarriageRecordMapper.deleteScMiscarriageRecordById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据耳号查询羊只信息
|
||||
*
|
||||
* @param manageTags 管理耳号
|
||||
* @return 羊只信息
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> selectSheepByManageTags(String manageTags)
|
||||
{
|
||||
return scMiscarriageRecordMapper.selectSheepByManageTags(manageTags);
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -56,24 +57,50 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertScPregnancyRecord(ScPregnancyRecord scPregnancyRecord)
|
||||
{
|
||||
// 参数校验
|
||||
if (scPregnancyRecord.getManageTags() == null || scPregnancyRecord.getManageTags().trim().isEmpty()) {
|
||||
throw new ServiceException("管理耳号不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getDatetime() == null) {
|
||||
throw new ServiceException("孕检日期不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getResult() == null || scPregnancyRecord.getResult().trim().isEmpty()) {
|
||||
throw new ServiceException("孕检结果不能为空");
|
||||
}
|
||||
|
||||
// 根据耳号获取羊只信息并验证
|
||||
Map<String, Object> sheepInfo = scPregnancyRecordMapper.selectSheepByManageTags(scPregnancyRecord.getManageTags().trim());
|
||||
if (sheepInfo == null) {
|
||||
throw new ServiceException("管理耳号[" + scPregnancyRecord.getManageTags() + "]对应的羊只不存在");
|
||||
}
|
||||
|
||||
Long sheepId = sheepInfo.get("id") != null ? Long.valueOf(sheepInfo.get("id").toString()) : null;
|
||||
if (sheepId == null) {
|
||||
throw new ServiceException("无法获取羊只ID,请检查数据完整性");
|
||||
}
|
||||
scPregnancyRecord.setSheepId(sheepId);
|
||||
|
||||
// 验证孕检结果和胎儿数量的一致性
|
||||
validatePregnancyResult(scPregnancyRecord);
|
||||
|
||||
// 设置默认值
|
||||
scPregnancyRecord.setCreateTime(DateUtils.getNowDate());
|
||||
scPregnancyRecord.setIsDelete(0);
|
||||
|
||||
// 根据耳号获取羊只ID
|
||||
if (scPregnancyRecord.getManageTags() != null) {
|
||||
Map<String, Object> sheepInfo = scPregnancyRecordMapper.selectSheepByManageTags(scPregnancyRecord.getManageTags());
|
||||
if (sheepInfo != null && sheepInfo.get("id") != null) {
|
||||
scPregnancyRecord.setSheepId(Long.valueOf(sheepInfo.get("id").toString()));
|
||||
}
|
||||
// 如果孕检方式为空,默认设置为B超
|
||||
if (scPregnancyRecord.getWay() == null || scPregnancyRecord.getWay().trim().isEmpty()) {
|
||||
scPregnancyRecord.setWay("B超");
|
||||
}
|
||||
|
||||
int result = scPregnancyRecordMapper.insertScPregnancyRecord(scPregnancyRecord);
|
||||
|
||||
// 如果孕检结果为怀孕,更新羊只基础表相关字段
|
||||
if ("怀孕".equals(scPregnancyRecord.getResult()) && scPregnancyRecord.getSheepId() != null) {
|
||||
if ("怀孕".equals(scPregnancyRecord.getResult()) && result > 0) {
|
||||
updateSheepPregnancyStatus(scPregnancyRecord);
|
||||
}
|
||||
|
||||
@ -87,29 +114,67 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateScPregnancyRecord(ScPregnancyRecord scPregnancyRecord)
|
||||
{
|
||||
scPregnancyRecord.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
// 根据耳号获取羊只ID
|
||||
if (scPregnancyRecord.getManageTags() != null) {
|
||||
Map<String, Object> sheepInfo = scPregnancyRecordMapper.selectSheepByManageTags(scPregnancyRecord.getManageTags());
|
||||
if (sheepInfo != null && sheepInfo.get("id") != null) {
|
||||
scPregnancyRecord.setSheepId(Long.valueOf(sheepInfo.get("id").toString()));
|
||||
}
|
||||
// 参数校验
|
||||
if (scPregnancyRecord.getId() == null) {
|
||||
throw new ServiceException("记录ID不能为空");
|
||||
}
|
||||
|
||||
if (scPregnancyRecord.getManageTags() == null || scPregnancyRecord.getManageTags().trim().isEmpty()) {
|
||||
throw new ServiceException("管理耳号不能为空");
|
||||
}
|
||||
|
||||
// 根据耳号获取羊只信息并验证
|
||||
Map<String, Object> sheepInfo = scPregnancyRecordMapper.selectSheepByManageTags(scPregnancyRecord.getManageTags().trim());
|
||||
if (sheepInfo == null) {
|
||||
throw new ServiceException("管理耳号[" + scPregnancyRecord.getManageTags() + "]对应的羊只不存在");
|
||||
}
|
||||
|
||||
Long sheepId = sheepInfo.get("id") != null ? Long.valueOf(sheepInfo.get("id").toString()) : null;
|
||||
if (sheepId == null) {
|
||||
throw new ServiceException("无法获取羊只ID,请检查数据完整性");
|
||||
}
|
||||
scPregnancyRecord.setSheepId(sheepId);
|
||||
|
||||
// 验证孕检结果和胎儿数量的一致性
|
||||
validatePregnancyResult(scPregnancyRecord);
|
||||
|
||||
scPregnancyRecord.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
int result = scPregnancyRecordMapper.updateScPregnancyRecord(scPregnancyRecord);
|
||||
|
||||
// 如果孕检结果为怀孕,更新羊只基础表相关字段
|
||||
if ("怀孕".equals(scPregnancyRecord.getResult()) && scPregnancyRecord.getSheepId() != null) {
|
||||
if ("怀孕".equals(scPregnancyRecord.getResult()) && result > 0) {
|
||||
updateSheepPregnancyStatus(scPregnancyRecord);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证孕检结果和胎儿数量的一致性
|
||||
*
|
||||
* @param scPregnancyRecord 孕检记录
|
||||
*/
|
||||
private void validatePregnancyResult(ScPregnancyRecord scPregnancyRecord) {
|
||||
String result = scPregnancyRecord.getResult();
|
||||
Integer fetusCount = scPregnancyRecord.getFetusCount();
|
||||
|
||||
if ("怀孕".equals(result)) {
|
||||
if (fetusCount == null || fetusCount <= 0) {
|
||||
throw new ServiceException("孕检结果为怀孕时,胎儿数量必须填写且大于0");
|
||||
}
|
||||
if (fetusCount > 10) {
|
||||
throw new ServiceException("胎儿数量不能超过10个");
|
||||
}
|
||||
} else if ("未孕".equals(result) || "流产".equals(result)) {
|
||||
// 未孕或流产时,胎儿数量应为0或null
|
||||
scPregnancyRecord.setFetusCount(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除孕检记录
|
||||
*
|
||||
@ -117,8 +182,12 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteScPregnancyRecordByIds(Long[] ids)
|
||||
{
|
||||
if (ids == null || ids.length == 0) {
|
||||
throw new ServiceException("删除的记录ID不能为空");
|
||||
}
|
||||
return scPregnancyRecordMapper.deleteScPregnancyRecordByIds(ids);
|
||||
}
|
||||
|
||||
@ -129,8 +198,12 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteScPregnancyRecordById(Long id)
|
||||
{
|
||||
if (id == null) {
|
||||
throw new ServiceException("删除的记录ID不能为空");
|
||||
}
|
||||
return scPregnancyRecordMapper.deleteScPregnancyRecordById(id);
|
||||
}
|
||||
|
||||
@ -143,7 +216,25 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||
@Override
|
||||
public Map<String, Object> getSheepByManageTags(String manageTags)
|
||||
{
|
||||
return scPregnancyRecordMapper.selectSheepByManageTags(manageTags);
|
||||
if (manageTags == null || manageTags.trim().isEmpty()) {
|
||||
throw new ServiceException("管理耳号不能为空");
|
||||
}
|
||||
return scPregnancyRecordMapper.selectSheepByManageTags(manageTags.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据耳号获取配种信息
|
||||
*
|
||||
* @param manageTags 耳号
|
||||
* @return 配种信息
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getBreedInfoByManageTags(String manageTags)
|
||||
{
|
||||
if (manageTags == null || manageTags.trim().isEmpty()) {
|
||||
throw new ServiceException("管理耳号不能为空");
|
||||
}
|
||||
return scPregnancyRecordMapper.selectBreedInfoByManageTags(manageTags.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,27 +243,32 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||
* @param scPregnancyRecord 孕检记录
|
||||
*/
|
||||
private void updateSheepPregnancyStatus(ScPregnancyRecord scPregnancyRecord) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("sheepId", scPregnancyRecord.getSheepId());
|
||||
params.put("pregDate", scPregnancyRecord.getDatetime());
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("sheepId", scPregnancyRecord.getSheepId());
|
||||
params.put("pregDate", scPregnancyRecord.getDatetime());
|
||||
|
||||
// 设置繁育状态为怀孕状态(假设怀孕状态ID为2)
|
||||
params.put("breedStatusId", 2);
|
||||
// 设置繁育状态为怀孕状态(假设怀孕状态ID为2)
|
||||
params.put("breedStatusId", 2);
|
||||
|
||||
// 计算预产日期(羊的妊娠期大约150天)
|
||||
if (scPregnancyRecord.getDatetime() != null) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(scPregnancyRecord.getDatetime());
|
||||
cal.add(Calendar.DAY_OF_YEAR, 150);
|
||||
params.put("expectedDate", cal.getTime());
|
||||
// 计算预产日期(羊的妊娠期大约150天)
|
||||
if (scPregnancyRecord.getDatetime() != null) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(scPregnancyRecord.getDatetime());
|
||||
cal.add(Calendar.DAY_OF_YEAR, 150);
|
||||
params.put("expectedDate", cal.getTime());
|
||||
}
|
||||
|
||||
// 计算怀孕天数
|
||||
if (scPregnancyRecord.getDatetime() != null) {
|
||||
long days = (System.currentTimeMillis() - scPregnancyRecord.getDatetime().getTime()) / (1000 * 60 * 60 * 24);
|
||||
params.put("gestationDay", (int) days);
|
||||
}
|
||||
|
||||
scPregnancyRecordMapper.updateSheepPregnancyInfo(params);
|
||||
} catch (Exception e) {
|
||||
// 记录日志但不影响主流程
|
||||
System.err.println("更新羊只怀孕状态失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
// 计算怀孕天数
|
||||
if (scPregnancyRecord.getDatetime() != null) {
|
||||
long days = (System.currentTimeMillis() - scPregnancyRecord.getDatetime().getTime()) / (1000 * 60 * 60 * 24);
|
||||
params.put("gestationDay", (int) days);
|
||||
}
|
||||
|
||||
scPregnancyRecordMapper.updateSheepPregnancyInfo(params);
|
||||
}
|
||||
}
|
||||
@ -3,11 +3,17 @@ package com.zhyc.module.produce.breed.service.impl;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.module.biosafety.domain.Diagnosis;
|
||||
import com.zhyc.module.biosafety.domain.Treatment;
|
||||
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
|
||||
import com.zhyc.module.biosafety.mapper.TreatmentMapper;
|
||||
import com.zhyc.module.biosafety.service.impl.TreatmentServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.produce.breed.mapper.ScSheepDeathMapper;
|
||||
import com.zhyc.module.produce.breed.domain.ScSheepDeath;
|
||||
import com.zhyc.module.produce.breed.service.IScSheepDeathService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 羊只死淘记录Service业务层处理
|
||||
@ -20,6 +26,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
{
|
||||
@Autowired
|
||||
private ScSheepDeathMapper scSheepDeathMapper;
|
||||
@Autowired
|
||||
private DiagnosisMapper diagnosisMapper;
|
||||
@Autowired
|
||||
private TreatmentServiceImpl treatmentService;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询羊只死淘记录
|
||||
@ -100,6 +113,7 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertScSheepDeath(ScSheepDeath scSheepDeath)
|
||||
{
|
||||
// 设置事件类型默认为"死亡"
|
||||
@ -111,11 +125,20 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
if (scSheepDeath.getManageTags() != null && !scSheepDeath.getManageTags().isEmpty()) {
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags());
|
||||
if (sheepInfo != null) {
|
||||
scSheepDeath.setSheepId(sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null);
|
||||
Long sheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null;
|
||||
scSheepDeath.setSheepId(sheepId);
|
||||
|
||||
// 插入死淘记录后,同时更新羊只在群状态为"不在群"(字典值为2)
|
||||
if (sheepId != null) {
|
||||
scSheepDeathMapper.updateSheepStatus(sheepId, "2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
treatmentService.updateTreatmentStatus(scSheepDeath.getSheepId());
|
||||
|
||||
scSheepDeath.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
return scSheepDeathMapper.insertScSheepDeath(scSheepDeath);
|
||||
}
|
||||
|
||||
@ -132,10 +155,15 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
if (scSheepDeath.getManageTags() != null && !scSheepDeath.getManageTags().isEmpty()) {
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags());
|
||||
if (sheepInfo != null) {
|
||||
scSheepDeath.setSheepId(sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null);
|
||||
Long sheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null;
|
||||
scSheepDeath.setSheepId(sheepId);
|
||||
|
||||
// 修改死淘记录时,同时更新羊只在群状态为"不在群"(字典值为2)
|
||||
if (sheepId != null) {
|
||||
scSheepDeathMapper.updateSheepStatus(sheepId, "2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scSheepDeath.setUpdateTime(DateUtils.getNowDate());
|
||||
return scSheepDeathMapper.updateScSheepDeath(scSheepDeath);
|
||||
}
|
||||
@ -149,6 +177,15 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
@Override
|
||||
public int deleteScSheepDeathByIds(Long[] ids)
|
||||
{
|
||||
// 可选:删除死淘记录前,将对应羊只在群状态改回"在群"
|
||||
for (Long id : ids) {
|
||||
ScSheepDeath scSheepDeath = scSheepDeathMapper.selectScSheepDeathById(id);
|
||||
if (scSheepDeath != null && scSheepDeath.getSheepId() != null) {
|
||||
// 恢复羊只在群状态为"在群"(字典值为1)
|
||||
scSheepDeathMapper.updateSheepStatus(scSheepDeath.getSheepId(), "1");
|
||||
}
|
||||
}
|
||||
|
||||
return scSheepDeathMapper.deleteScSheepDeathByIds(ids);
|
||||
}
|
||||
|
||||
@ -161,6 +198,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
@Override
|
||||
public int deleteScSheepDeathById(Long id)
|
||||
{
|
||||
// 可选:删除死淘记录前,将对应羊只在群状态改回"在群"
|
||||
ScSheepDeath scSheepDeath = scSheepDeathMapper.selectScSheepDeathById(id);
|
||||
if (scSheepDeath != null && scSheepDeath.getSheepId() != null) {
|
||||
// 恢复羊只在群状态为"在群"(字典值为1)
|
||||
scSheepDeathMapper.updateSheepStatus(scSheepDeath.getSheepId(), "1");
|
||||
}
|
||||
|
||||
return scSheepDeathMapper.deleteScSheepDeathById(id);
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@ public class ScChangeComment extends BaseEntity {
|
||||
* 羊只id
|
||||
*/
|
||||
private String sheepId;
|
||||
|
||||
@Excel(name = "管理耳号")
|
||||
private String manageTags;
|
||||
|
||||
/** 羊舍 */
|
||||
|
||||
@ -0,0 +1,117 @@
|
||||
package com.zhyc.module.sale.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.zhyc.common.annotation.Log;
|
||||
import com.zhyc.common.core.controller.BaseController;
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.module.sale.domain.SxSheepSale;
|
||||
import com.zhyc.module.sale.service.ISxSheepSaleService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 羊只销售记录Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/saleRecord/saleRecord")
|
||||
public class SxSheepSaleController extends BaseController {
|
||||
@Autowired
|
||||
private ISxSheepSaleService sxSheepSaleService;
|
||||
|
||||
/**
|
||||
* 查询羊只销售记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SxSheepSale sxSheepSale) {
|
||||
startPage();
|
||||
List<SxSheepSale> list = sxSheepSaleService.selectSxSheepSaleList(sxSheepSale);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出羊只销售记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:export')")
|
||||
@Log(title = "羊只销售记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SxSheepSale sxSheepSale) {
|
||||
List<SxSheepSale> list = sxSheepSaleService.selectSxSheepSaleList(sxSheepSale);
|
||||
ExcelUtil<SxSheepSale> util = new ExcelUtil<SxSheepSale>(SxSheepSale.class);
|
||||
util.exportExcel(response, list, "羊只销售记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取羊只销售记录详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
SxSheepSale sxSheepSale = sxSheepSaleService.selectSxSheepSaleById(id);
|
||||
// 将数据库中的逗号分隔的耳号字符串转换为列表
|
||||
if (sxSheepSale.getBsManageTags() != null && !sxSheepSale.getBsManageTags().isEmpty()) {
|
||||
sxSheepSale.setBsManageTagsList(java.util.Arrays.asList(sxSheepSale.getBsManageTags().split(",")));
|
||||
}
|
||||
return success(sxSheepSale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增羊只销售记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:add')")
|
||||
@Log(title = "羊只销售记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SxSheepSale sxSheepSale) {
|
||||
return toAjax(sxSheepSaleService.insertSxSheepSale(sxSheepSale));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改羊只销售记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:edit')")
|
||||
@Log(title = "羊只销售记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SxSheepSale sxSheepSale) {
|
||||
return toAjax(sxSheepSaleService.updateSxSheepSale(sxSheepSale));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除羊只销售记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:remove')")
|
||||
@Log(title = "羊只销售记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(sxSheepSaleService.deleteSxSheepSaleByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 【新增】根据耳号查询羊只信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:add')" + "|| @ss.hasPermi('saleRecord:saleRecord:edit')")
|
||||
@GetMapping("/getSheepInfo")
|
||||
public AjaxResult getSheepInfo(@RequestParam String bsManageTags) {
|
||||
// 调用Service方法查询信息
|
||||
SxSheepSale sheepInfo = sxSheepSaleService.selectSheepInfoByTag(bsManageTags);
|
||||
if (sheepInfo == null) {
|
||||
return AjaxResult.error("未找到耳号为 [" + bsManageTags + "] 的羊只信息");
|
||||
}
|
||||
return AjaxResult.success(sheepInfo);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package com.zhyc.module.sale.domain;
|
||||
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
|
||||
public class SxCustomerExport {
|
||||
@Excel(name = "客户名称")
|
||||
private String name;
|
||||
|
||||
@Excel(name = "客户电话")
|
||||
private String phone;
|
||||
|
||||
@Excel(name = "客户地址")
|
||||
private String fullAddress;
|
||||
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getFullAddress() {
|
||||
return fullAddress;
|
||||
}
|
||||
|
||||
public void setFullAddress(String fullAddress) {
|
||||
this.fullAddress = fullAddress;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,545 @@
|
||||
package com.zhyc.module.sale.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 羊只销售记录对象 sx_sheep_sale
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
public class SxSheepSale extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 耳号 */
|
||||
@Excel(name = "耳号")
|
||||
private String bsManageTags;
|
||||
|
||||
/** 羊舍ID(当时销售的羊舍) */
|
||||
@Excel(name = "羊舍ID", readConverterExp = "当=时销售的羊舍")
|
||||
private Long sheepfoldId;
|
||||
|
||||
/** 品种快照 */
|
||||
@Excel(name = "品种快照")
|
||||
private String variety;
|
||||
|
||||
/** 羊只类别快照 */
|
||||
@Excel(name = "羊只类别快照")
|
||||
private String sheepName;
|
||||
|
||||
/** 性别快照 */
|
||||
@Excel(name = "性别快照")
|
||||
private String gender;
|
||||
|
||||
/** 月龄快照 */
|
||||
@Excel(name = "月龄快照")
|
||||
private Long monthAge;
|
||||
|
||||
/** 胎次快照 */
|
||||
@Excel(name = "胎次快照")
|
||||
private Long parity;
|
||||
|
||||
/** 繁育状态快照 */
|
||||
@Excel(name = "繁育状态快照")
|
||||
private String breed;
|
||||
|
||||
/** 产后天数快照 */
|
||||
@Excel(name = "产后天数快照")
|
||||
private Long postLambingDay;
|
||||
|
||||
/** 泌乳天数快照 */
|
||||
@Excel(name = "泌乳天数快照")
|
||||
private Long lactationDay;
|
||||
|
||||
/** 怀孕天数快照 */
|
||||
@Excel(name = "怀孕天数快照")
|
||||
private Long lambingDay;
|
||||
|
||||
/** 事件类型 */
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType;
|
||||
|
||||
/** 销售日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "销售日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date saleDate;
|
||||
|
||||
/** 计价方式 */
|
||||
@Excel(name = "计价方式")
|
||||
private String pricingMethod;
|
||||
|
||||
/** 单价 */
|
||||
@Excel(name = "单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/** 总价(自动计算) */
|
||||
@Excel(name = "总价", readConverterExp = "自=动计算")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
/** 总体重(按体重时输入) */
|
||||
@Excel(name = "总体重", readConverterExp = "按=体重时输入")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
/** 平均体重(自动) */
|
||||
@Excel(name = "平均体重", readConverterExp = "自=动")
|
||||
private BigDecimal avgWeight;
|
||||
|
||||
/** 平均单只价格(自动) */
|
||||
@Excel(name = "平均单只价格", readConverterExp = "自=动")
|
||||
private BigDecimal avgPricePerSheep;
|
||||
|
||||
/** 销售类别(dict_type = sale_type) */
|
||||
@Excel(name = "销售类别", readConverterExp = "d=ict_type,==,s=ale_type")
|
||||
private String saleType;
|
||||
|
||||
/** 疾病类型(dict_type = disea_type) */
|
||||
@Excel(name = "疾病类型", readConverterExp = "d=ict_type,==,d=isea_type")
|
||||
private String diseaseType;
|
||||
|
||||
/** 次要原因 */
|
||||
@Excel(name = "次要原因")
|
||||
private String secondaryReason;
|
||||
|
||||
/** 班组(dict_type = group) */
|
||||
@Excel(name = "班组", readConverterExp = "d=ict_type,==,g=roup")
|
||||
private String groupCode;
|
||||
|
||||
/** 客户ID(sx_customer.id) */
|
||||
@Excel(name = "客户ID", readConverterExp = "s=x_customer.id")
|
||||
private Long customerId;
|
||||
|
||||
/** 销售人员ID(sys_user.id) */
|
||||
@Excel(name = "销售人员ID", readConverterExp = "s=ys_user.id")
|
||||
private Long salesPersonId;
|
||||
|
||||
/** 检疫证号 */
|
||||
@Excel(name = "检疫证号")
|
||||
private String quarantineNo;
|
||||
|
||||
/** 审批编号 */
|
||||
@Excel(name = "审批编号")
|
||||
private String approvalNo;
|
||||
|
||||
/** 技术员ID(sys_user.id) */
|
||||
@Excel(name = "技术员ID", readConverterExp = "s=ys_user.id")
|
||||
private Long technicianId;
|
||||
|
||||
/** 处理人ID(sys_user.id) */
|
||||
@Excel(name = "处理人ID", readConverterExp = "s=ys_user.id")
|
||||
private Long handlerId;
|
||||
|
||||
/** 创建人ID(sys_user.id) */
|
||||
@Excel(name = "创建人ID", readConverterExp = "s=ys_user.id")
|
||||
private Long createdBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date createdAt;
|
||||
|
||||
// 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号
|
||||
private List<String> bsManageTagsList;
|
||||
|
||||
// 【新增】非数据库字段:客户名称(从客户表查询)
|
||||
private String customerName;
|
||||
// 【新增】非数据库字段:客户电话
|
||||
private String customerPhone;
|
||||
// 【新增】非数据库字段:客户地址
|
||||
private String customerAddress;
|
||||
// 【新增】非数据库字段:销售人员姓名
|
||||
private String salesPersonName;
|
||||
// 【新增】非数据库字段:技术员姓名
|
||||
private String technicianName;
|
||||
// 【新增】非数据库字段:处理人姓名
|
||||
private String handlerName;
|
||||
// 【新增】非数据库字段:创建人姓名
|
||||
private String createdByName;
|
||||
// 【新增】非数据库字段:羊舍名称
|
||||
private String sheepfoldName;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setBsManageTags(String bsManageTags) {
|
||||
this.bsManageTags = bsManageTags;
|
||||
}
|
||||
|
||||
public String getBsManageTags() {
|
||||
return bsManageTags;
|
||||
}
|
||||
|
||||
public void setSheepfoldId(Long sheepfoldId) {
|
||||
this.sheepfoldId = sheepfoldId;
|
||||
}
|
||||
|
||||
public Long getSheepfoldId() {
|
||||
return sheepfoldId;
|
||||
}
|
||||
|
||||
public void setVariety(String variety) {
|
||||
this.variety = variety;
|
||||
}
|
||||
|
||||
public String getVariety() {
|
||||
return variety;
|
||||
}
|
||||
|
||||
public void setSheepName(String sheepName) {
|
||||
this.sheepName = sheepName;
|
||||
}
|
||||
|
||||
public String getSheepName() {
|
||||
return sheepName;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setMonthAge(Long monthAge) {
|
||||
this.monthAge = monthAge;
|
||||
}
|
||||
|
||||
public Long getMonthAge() {
|
||||
return monthAge;
|
||||
}
|
||||
|
||||
public void setParity(Long parity) {
|
||||
this.parity = parity;
|
||||
}
|
||||
|
||||
public Long getParity() {
|
||||
return parity;
|
||||
}
|
||||
|
||||
public void setBreed(String breed) {
|
||||
this.breed = breed;
|
||||
}
|
||||
|
||||
public String getBreed() {
|
||||
return breed;
|
||||
}
|
||||
|
||||
public void setPostLambingDay(Long postLambingDay) {
|
||||
this.postLambingDay = postLambingDay;
|
||||
}
|
||||
|
||||
public Long getPostLambingDay() {
|
||||
return postLambingDay;
|
||||
}
|
||||
|
||||
public void setLactationDay(Long lactationDay) {
|
||||
this.lactationDay = lactationDay;
|
||||
}
|
||||
|
||||
public Long getLactationDay() {
|
||||
return lactationDay;
|
||||
}
|
||||
|
||||
public void setLambingDay(Long lambingDay) {
|
||||
this.lambingDay = lambingDay;
|
||||
}
|
||||
|
||||
public Long getLambingDay() {
|
||||
return lambingDay;
|
||||
}
|
||||
|
||||
public void setEventType(String eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public void setSaleDate(Date saleDate) {
|
||||
this.saleDate = saleDate;
|
||||
}
|
||||
|
||||
public Date getSaleDate() {
|
||||
return saleDate;
|
||||
}
|
||||
|
||||
public void setPricingMethod(String pricingMethod) {
|
||||
this.pricingMethod = pricingMethod;
|
||||
}
|
||||
|
||||
public String getPricingMethod() {
|
||||
return pricingMethod;
|
||||
}
|
||||
|
||||
public void setUnitPrice(BigDecimal unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setTotalPrice(BigDecimal totalPrice) {
|
||||
this.totalPrice = totalPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalPrice() {
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
public void setTotalWeight(BigDecimal totalWeight) {
|
||||
this.totalWeight = totalWeight;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalWeight() {
|
||||
return totalWeight;
|
||||
}
|
||||
|
||||
public void setAvgWeight(BigDecimal avgWeight) {
|
||||
this.avgWeight = avgWeight;
|
||||
}
|
||||
|
||||
public BigDecimal getAvgWeight() {
|
||||
return avgWeight;
|
||||
}
|
||||
|
||||
public void setAvgPricePerSheep(BigDecimal avgPricePerSheep) {
|
||||
this.avgPricePerSheep = avgPricePerSheep;
|
||||
}
|
||||
|
||||
public BigDecimal getAvgPricePerSheep() {
|
||||
return avgPricePerSheep;
|
||||
}
|
||||
|
||||
public void setSaleType(String saleType) {
|
||||
this.saleType = saleType;
|
||||
}
|
||||
|
||||
public String getSaleType() {
|
||||
return saleType;
|
||||
}
|
||||
|
||||
public void setDiseaseType(String diseaseType) {
|
||||
this.diseaseType = diseaseType;
|
||||
}
|
||||
|
||||
public String getDiseaseType() {
|
||||
return diseaseType;
|
||||
}
|
||||
|
||||
public void setSecondaryReason(String secondaryReason) {
|
||||
this.secondaryReason = secondaryReason;
|
||||
}
|
||||
|
||||
public String getSecondaryReason() {
|
||||
return secondaryReason;
|
||||
}
|
||||
|
||||
public void setGroupCode(String groupCode) {
|
||||
this.groupCode = groupCode;
|
||||
}
|
||||
|
||||
public String getGroupCode() {
|
||||
return groupCode;
|
||||
}
|
||||
|
||||
public void setCustomerId(Long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public Long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setSalesPersonId(Long salesPersonId) {
|
||||
this.salesPersonId = salesPersonId;
|
||||
}
|
||||
|
||||
public Long getSalesPersonId() {
|
||||
return salesPersonId;
|
||||
}
|
||||
|
||||
public void setQuarantineNo(String quarantineNo) {
|
||||
this.quarantineNo = quarantineNo;
|
||||
}
|
||||
|
||||
public String getQuarantineNo() {
|
||||
return quarantineNo;
|
||||
}
|
||||
|
||||
public void setApprovalNo(String approvalNo) {
|
||||
this.approvalNo = approvalNo;
|
||||
}
|
||||
|
||||
public String getApprovalNo() {
|
||||
return approvalNo;
|
||||
}
|
||||
|
||||
public void setTechnicianId(Long technicianId) {
|
||||
this.technicianId = technicianId;
|
||||
}
|
||||
|
||||
public Long getTechnicianId() {
|
||||
return technicianId;
|
||||
}
|
||||
|
||||
public void setHandlerId(Long handlerId) {
|
||||
this.handlerId = handlerId;
|
||||
}
|
||||
|
||||
public Long getHandlerId() {
|
||||
return handlerId;
|
||||
}
|
||||
|
||||
public void setCreatedBy(Long createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public Long getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
// 【新增】getter 和 setter 方法
|
||||
public List<String> getBsManageTagsList() {
|
||||
return bsManageTagsList;
|
||||
}
|
||||
|
||||
public void setBsManageTagsList(List<String> bsManageTagsList) {
|
||||
this.bsManageTagsList = bsManageTagsList;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public String getCustomerPhone() {
|
||||
return customerPhone;
|
||||
}
|
||||
|
||||
public void setCustomerPhone(String customerPhone) {
|
||||
this.customerPhone = customerPhone;
|
||||
}
|
||||
|
||||
public String getCustomerAddress() {
|
||||
return customerAddress;
|
||||
}
|
||||
|
||||
public void setCustomerAddress(String customerAddress) {
|
||||
this.customerAddress = customerAddress;
|
||||
}
|
||||
|
||||
public String getSalesPersonName() {
|
||||
return salesPersonName;
|
||||
}
|
||||
|
||||
public void setSalesPersonName(String salesPersonName) {
|
||||
this.salesPersonName = salesPersonName;
|
||||
}
|
||||
|
||||
public String getTechnicianName() {
|
||||
return technicianName;
|
||||
}
|
||||
|
||||
public void setTechnicianName(String technicianName) {
|
||||
this.technicianName = technicianName;
|
||||
}
|
||||
|
||||
public String getHandlerName() {
|
||||
return handlerName;
|
||||
}
|
||||
|
||||
public void setHandlerName(String handlerName) {
|
||||
this.handlerName = handlerName;
|
||||
}
|
||||
|
||||
public String getCreatedByName() {
|
||||
return createdByName;
|
||||
}
|
||||
|
||||
public void setCreatedByName(String createdByName) {
|
||||
this.createdByName = createdByName;
|
||||
}
|
||||
|
||||
public String getSheepfoldName() {
|
||||
return sheepfoldName;
|
||||
}
|
||||
|
||||
public void setSheepfoldName(String sheepfoldName) {
|
||||
this.sheepfoldName = sheepfoldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("bsManageTags", getBsManageTags())
|
||||
.append("sheepfoldId", getSheepfoldId())
|
||||
.append("variety", getVariety())
|
||||
.append("sheepName", getSheepName())
|
||||
.append("gender", getGender())
|
||||
.append("monthAge", getMonthAge())
|
||||
.append("parity", getParity())
|
||||
.append("breed", getBreed())
|
||||
.append("postLambingDay", getPostLambingDay())
|
||||
.append("lactationDay", getLactationDay())
|
||||
.append("lambingDay", getLambingDay())
|
||||
.append("eventType", getEventType())
|
||||
.append("saleDate", getSaleDate())
|
||||
.append("pricingMethod", getPricingMethod())
|
||||
.append("unitPrice", getUnitPrice())
|
||||
.append("totalPrice", getTotalPrice())
|
||||
.append("totalWeight", getTotalWeight())
|
||||
.append("avgWeight", getAvgWeight())
|
||||
.append("avgPricePerSheep", getAvgPricePerSheep())
|
||||
.append("saleType", getSaleType())
|
||||
.append("diseaseType", getDiseaseType())
|
||||
.append("secondaryReason", getSecondaryReason())
|
||||
.append("groupCode", getGroupCode())
|
||||
.append("customerId", getCustomerId())
|
||||
.append("salesPersonId", getSalesPersonId())
|
||||
.append("quarantineNo", getQuarantineNo())
|
||||
.append("approvalNo", getApprovalNo())
|
||||
.append("technicianId", getTechnicianId())
|
||||
.append("handlerId", getHandlerId())
|
||||
.append("createdBy", getCreatedBy())
|
||||
.append("createdAt", getCreatedAt())
|
||||
.append("remark", getRemark())
|
||||
.append("customerName", getCustomerName())
|
||||
.append("customerPhone", getCustomerPhone())
|
||||
.append("customerAddress", getCustomerAddress())
|
||||
.append("salesPersonName", getSalesPersonName())
|
||||
.append("technicianName", getTechnicianName())
|
||||
.append("handlerName", getHandlerName())
|
||||
.append("createdByName", getCreatedByName())
|
||||
.append("sheepfoldName", getSheepfoldName())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.zhyc.module.sale.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.sale.domain.SxSheepSale;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 羊只销售记录Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
public interface SxSheepSaleMapper {
|
||||
/**
|
||||
* 查询羊只销售记录
|
||||
*
|
||||
* @param id 羊只销售记录主键
|
||||
* @return 羊只销售记录
|
||||
*/
|
||||
public SxSheepSale selectSxSheepSaleById(Long id);
|
||||
|
||||
/**
|
||||
* 查询羊只销售记录列表
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 羊只销售记录集合
|
||||
*/
|
||||
public List<SxSheepSale> selectSxSheepSaleList(SxSheepSale sxSheepSale);
|
||||
|
||||
/**
|
||||
* 新增羊只销售记录
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSxSheepSale(SxSheepSale sxSheepSale);
|
||||
|
||||
/**
|
||||
* 修改羊只销售记录
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSxSheepSale(SxSheepSale sxSheepSale);
|
||||
|
||||
/**
|
||||
* 删除羊只销售记录
|
||||
*
|
||||
* @param id 羊只销售记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSxSheepSaleById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除羊只销售记录
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSxSheepSaleByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 【新增】从sheep_file视图查询羊只信息
|
||||
* @param bsManageTags 耳号
|
||||
* @return 羊只信息 (只包含视图中的字段)
|
||||
*/
|
||||
public SxSheepSale selectSheepInfoByTag(@Param("bsManageTags") String bsManageTags);
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.zhyc.module.sale.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.sale.domain.SxSheepSale;
|
||||
|
||||
/**
|
||||
* 羊只销售记录Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
public interface ISxSheepSaleService {
|
||||
/**
|
||||
* 查询羊只销售记录
|
||||
*
|
||||
* @param id 羊只销售记录主键
|
||||
* @return 羊只销售记录
|
||||
*/
|
||||
public SxSheepSale selectSxSheepSaleById(Long id);
|
||||
|
||||
/**
|
||||
* 查询羊只销售记录列表
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 羊只销售记录集合
|
||||
*/
|
||||
public List<SxSheepSale> selectSxSheepSaleList(SxSheepSale sxSheepSale);
|
||||
|
||||
/**
|
||||
* 新增羊只销售记录
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSxSheepSale(SxSheepSale sxSheepSale);
|
||||
|
||||
/**
|
||||
* 修改羊只销售记录
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSxSheepSale(SxSheepSale sxSheepSale);
|
||||
|
||||
/**
|
||||
* 批量删除羊只销售记录
|
||||
*
|
||||
* @param ids 需要删除的羊只销售记录主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSxSheepSaleByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除羊只销售记录信息
|
||||
*
|
||||
* @param id 羊只销售记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSxSheepSaleById(Long id);
|
||||
|
||||
/**
|
||||
* 【新增】根据耳号查询羊只信息
|
||||
* @param bsManageTags 耳号
|
||||
* @return 羊只信息
|
||||
*/
|
||||
public SxSheepSale selectSheepInfoByTag(String bsManageTags);
|
||||
}
|
||||
@ -0,0 +1,194 @@
|
||||
package com.zhyc.module.sale.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.sale.mapper.SxSheepSaleMapper;
|
||||
import com.zhyc.module.sale.domain.SxSheepSale;
|
||||
import com.zhyc.module.sale.service.ISxSheepSaleService;
|
||||
|
||||
/**
|
||||
* 羊只销售记录Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Service
|
||||
public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
|
||||
@Autowired
|
||||
private SxSheepSaleMapper sxSheepSaleMapper;
|
||||
|
||||
/**
|
||||
* 查询羊只销售记录
|
||||
*
|
||||
* @param id 羊只销售记录主键
|
||||
* @return 羊只销售记录
|
||||
*/
|
||||
@Override
|
||||
public SxSheepSale selectSxSheepSaleById(Long id) {
|
||||
return sxSheepSaleMapper.selectSxSheepSaleById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询羊只销售记录列表
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 羊只销售记录
|
||||
*/
|
||||
@Override
|
||||
public List<SxSheepSale> selectSxSheepSaleList(SxSheepSale sxSheepSale) {
|
||||
return sxSheepSaleMapper.selectSxSheepSaleList(sxSheepSale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增羊只销售记录
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSxSheepSale(SxSheepSale sxSheepSale) {
|
||||
// 1. 业务验证 (例如:销售日期不能为空,淘汰销售必须填写疾病类型等)
|
||||
validateSalesFields(sxSheepSale);
|
||||
|
||||
// 2. 自动计算逻辑
|
||||
calculateSalesFields(sxSheepSale);
|
||||
|
||||
// 3. 设置默认事件类型
|
||||
if (sxSheepSale.getEventType() == null) {
|
||||
sxSheepSale.setEventType("销售");
|
||||
}
|
||||
|
||||
// 4. 处理耳号列表(多个耳号用逗号分隔)
|
||||
if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) {
|
||||
sxSheepSale.setBsManageTags(String.join(",", sxSheepSale.getBsManageTagsList()));
|
||||
}
|
||||
|
||||
// 5. 调用Mapper插入数据
|
||||
return sxSheepSaleMapper.insertSxSheepSale(sxSheepSale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改羊只销售记录
|
||||
*
|
||||
* @param sxSheepSale 羊只销售记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSxSheepSale(SxSheepSale sxSheepSale) {
|
||||
// 1. 业务验证
|
||||
validateSalesFields(sxSheepSale);
|
||||
|
||||
// 2. 自动计算逻辑
|
||||
calculateSalesFields(sxSheepSale);
|
||||
|
||||
// 3. 处理耳号列表(多个耳号用逗号分隔)
|
||||
if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) {
|
||||
sxSheepSale.setBsManageTags(String.join(",", sxSheepSale.getBsManageTagsList()));
|
||||
}
|
||||
|
||||
// 4. 调用Mapper更新数据
|
||||
return sxSheepSaleMapper.updateSxSheepSale(sxSheepSale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除羊只销售记录
|
||||
*
|
||||
* @param ids 需要删除的羊只销售记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSxSheepSaleByIds(Long[] ids) {
|
||||
return sxSheepSaleMapper.deleteSxSheepSaleByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除羊只销售记录信息
|
||||
*
|
||||
* @param id 羊只销售记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSxSheepSaleById(Long id) {
|
||||
return sxSheepSaleMapper.deleteSxSheepSaleById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【新增】根据耳号查询羊只信息
|
||||
*/
|
||||
@Override
|
||||
public SxSheepSale selectSheepInfoByTag(String bsManageTags) {
|
||||
return sxSheepSaleMapper.selectSheepInfoByTag(bsManageTags);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【新增】自动计算总价、平均体重、平均单只价格
|
||||
*/
|
||||
private void calculateSalesFields(SxSheepSale sxSheepSale) {
|
||||
String pricingMethod = sxSheepSale.getPricingMethod();
|
||||
BigDecimal unitPrice = sxSheepSale.getUnitPrice();
|
||||
|
||||
// 获取羊只数量
|
||||
int sheepCount = 1;
|
||||
if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) {
|
||||
sheepCount = sxSheepSale.getBsManageTagsList().size();
|
||||
} else if (sxSheepSale.getBsManageTags() != null && !sxSheepSale.getBsManageTags().isEmpty()) {
|
||||
// 如果前端没有传递列表,但有逗号分隔的字符串,也计算数量
|
||||
sheepCount = sxSheepSale.getBsManageTags().split(",").length;
|
||||
}
|
||||
|
||||
if ("按个体".equals(pricingMethod)) {
|
||||
// 总价 = 单价 * 数量
|
||||
if (unitPrice != null) {
|
||||
sxSheepSale.setTotalPrice(unitPrice.multiply(new BigDecimal(sheepCount)));
|
||||
}
|
||||
// 平均单只价格就是单价
|
||||
sxSheepSale.setAvgPricePerSheep(unitPrice);
|
||||
|
||||
} else if ("按体重".equals(pricingMethod)) {
|
||||
BigDecimal totalWeight = sxSheepSale.getTotalWeight();
|
||||
// 总价 = 单价 * 总重量
|
||||
if (unitPrice != null && totalWeight != null) {
|
||||
sxSheepSale.setTotalPrice(unitPrice.multiply(totalWeight));
|
||||
}
|
||||
// 平均体重 = 总重量 / 数量
|
||||
if (totalWeight != null && sheepCount > 0) {
|
||||
sxSheepSale.setAvgWeight(totalWeight.divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP));
|
||||
}
|
||||
// 平均单只价格 = 总价 / 数量
|
||||
if (sxSheepSale.getTotalPrice() != null && sheepCount > 0) {
|
||||
sxSheepSale.setAvgPricePerSheep(sxSheepSale.getTotalPrice().divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
// 可以添加其他计价方式的逻辑
|
||||
}
|
||||
|
||||
/**
|
||||
* 【新增】业务字段验证
|
||||
*/
|
||||
private void validateSalesFields(SxSheepSale sxSheepSale) {
|
||||
// 验证销售日期不能为空
|
||||
if (sxSheepSale.getSaleDate() == null) {
|
||||
throw new RuntimeException("销售日期不能为空!");
|
||||
}
|
||||
|
||||
String saleType = sxSheepSale.getSaleType();
|
||||
// 如果销售类别是"淘汰销售"或"淘汰屠宰",则疾病类型和班组不能为空
|
||||
if ("淘汰销售".equals(saleType) || "淘汰屠宰".equals(saleType)) {
|
||||
if (sxSheepSale.getDiseaseType() == null) {
|
||||
throw new RuntimeException("淘汰销售或淘汰屠宰必须选择疾病类型!");
|
||||
}
|
||||
if (sxSheepSale.getGroupCode() == null) {
|
||||
throw new RuntimeException("淘汰销售或淘汰屠宰必须选择班组!");
|
||||
}
|
||||
}
|
||||
// 如果疾病类型是"病残羊",则次要原因不能为空
|
||||
if ("病残羊".equals(sxSheepSale.getDiseaseType())) {
|
||||
if (sxSheepSale.getSecondaryReason() == null || sxSheepSale.getSecondaryReason().trim().isEmpty()) {
|
||||
throw new RuntimeException("疾病类型为病残羊时,必须填写次要原因!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -47,6 +47,7 @@ public class WzStockInController extends BaseController
|
||||
{
|
||||
startPage();
|
||||
List<WzStockIn> list = wzStockInService.selectWzStockInList(wzStockIn);
|
||||
logger.debug(wzStockIn.toString());
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@ -35,9 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectDewormVo"/>
|
||||
<where>
|
||||
<if test="sheepId != null "> and sheep_id = #{sheepId}</if>
|
||||
<if test="sheepNo != null and sheepNo != ''">and bs.manage_tags like concat('%',#{sheepNo},'%')</if>
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectDewormById" parameterType="Long" resultMap="DewormResult">
|
||||
|
||||
@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="treatDay != null "> and treat_day = #{treatDay}</if>
|
||||
<if test="sheepfoldId != null "> and sd.sheepfold_id = #{sheepfoldId}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectDiagnosisById" parameterType="Long" resultMap="DiagnosisResult">
|
||||
|
||||
@ -61,6 +61,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND sm.name like concat('%',#{mediName},'%')
|
||||
)
|
||||
</if>
|
||||
ORDER BY datetime DESC
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectDisinfectById" parameterType="Long" resultMap="DisinfectResult">
|
||||
|
||||
@ -34,11 +34,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</sql>
|
||||
|
||||
<select id="selectHealthList" parameterType="Health" resultMap="HealthResult">
|
||||
<include refid="selectHealthVo"/>
|
||||
select s.id, datetime, sheep_id, usage_id, variety, sheep_type, s.gender, month_age, s.parity, breed, technical,
|
||||
s.comment, s.update_by, s.update_time, s.create_by, s.create_time,
|
||||
bs.manage_tags sheep_no
|
||||
from sw_health s
|
||||
left join bas_sheep bs on s.sheep_id = bs.id
|
||||
|
||||
<where>
|
||||
<if test="datetime != null "> and datetime = #{datetime}</if>
|
||||
<if test="sheepNo != null and sheepNo != ''">and bs.manage_tags like concat('%',#{sheepNo},'%')</if>
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectHealthById" parameterType="Long" resultMap="HealthResult">
|
||||
|
||||
@ -32,13 +32,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</sql>
|
||||
|
||||
<select id="selectImmunityList" parameterType="Immunity" resultMap="ImmunityResult">
|
||||
<include refid="selectImmunityVo"/>
|
||||
select s.id, datetime, sheep_id, usage_id, variety, sheep_type, s.gender, month_age, s.parity, breed, technical,
|
||||
s.comment, s.update_by, s.update_time, s.create_by, s.create_time,
|
||||
bs.manage_tags sheep_no
|
||||
from sw_immunity s
|
||||
left join bas_sheep bs on s.sheep_id = bs.id
|
||||
<where>
|
||||
<if test="sheepId != null "> and sheep_id = #{sheepId}</if>
|
||||
<if test="sheepType != null "> and sheep_type = #{sheepType}</if>
|
||||
<if test="sheepNo != null and sheepNo != ''">and bs.manage_tags like concat('%',#{sheepNo},'%')</if>
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectImmunityById" parameterType="Long" resultMap="ImmunityResult">
|
||||
|
||||
@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join sw_quarantine_sample sqs on sqr.sample_type = sqs.id
|
||||
left join sheep_file sf on sqr.sheep_id = sf.id
|
||||
where sqr.id = #{id}
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<insert id="insertQuarantineReport" parameterType="java.util.List">
|
||||
|
||||
@ -7,6 +7,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="SwMedicineUsage" id="SwMedicineUsageResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="sheepfoldId" column="sheepfold_id"/>
|
||||
<result property="sheepfoldName" column="sheepfold_name"/>
|
||||
<result property="sheepId" column="sheep_id"/>
|
||||
<result property="sheepNo" column="sheep_no"/>
|
||||
<result property="datetime" column="datetime"/>
|
||||
<result property="useType" column="use_type" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
@ -26,12 +31,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="dosage" column="dosage" />
|
||||
<result property="unit" column="unit" />
|
||||
<result property="usageId" column="usageId" />
|
||||
<result property="usetime" column="usetime" />
|
||||
<result property="manufacturer" column="manufacturer" />
|
||||
<result property="batchNumber" column="batch_number" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSwMedicineUsageVo">
|
||||
select id, name, use_type, update_by, update_time, create_by, create_time from sw_medicine_usage
|
||||
select smu.id, sheepfold as sheepfold_id,sheep sheep_id,name, datetime,use_type, smu.update_by, smu.update_time, smu.create_by, smu.create_time,
|
||||
ds.sheepfold_name,
|
||||
bs.manage_tags sheep_no
|
||||
from sw_medicine_usage smu
|
||||
left join da_sheepfold ds on ds.id = smu.sheepfold
|
||||
left join bas_sheep bs on bs.id = smu.sheep
|
||||
</sql>
|
||||
|
||||
<select id="selectSwMedicineUsageList" parameterType="SwMedicineUsage" resultMap="SwMedicineUsageResult">
|
||||
@ -39,8 +50,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="useType != null and useType != ''"> and use_type = #{useType}</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||
<if test="sheepNo != null and sheepNo != ''"> and bs.manage_tags like concat('%', #{sheepNo}, '%')</if>
|
||||
<if test="params.beginUseTime != null and params.beginUseTime != '' and params.endUseTime != null and params.endUseTime != ''"> and smu.datetime between #{params.beginUseTime} and #{params.endUseTime}</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and smu.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if> <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and smu.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectSwMedicineUsageById" parameterType="Integer" resultMap="SwMedicineUsageSwMedicineUsageDetailsResult">
|
||||
@ -50,11 +64,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectSwMedicineUsageDetailsList" resultMap="SwMedicineUsageDetailsResult">
|
||||
select smud.id, medi_usage, medi_id, dosage, unit, usageId, manufacturer, batch_number,
|
||||
select smud.id, medi_usage, medi_id, dosage, unit, usageId,usetime, manufacturer, batch_number,
|
||||
sm.name
|
||||
from sw_medicine_usage_details smud
|
||||
join sw_medicine sm on smud.medi_id = sm.id
|
||||
where medi_usage = #{medi_usage}
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="insertSwMedicineUsage" parameterType="SwMedicineUsage" useGeneratedKeys="true" keyProperty="id">
|
||||
@ -62,6 +77,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
<if test="useType != null">use_type,</if>
|
||||
<if test="sheepfoldId != null">sheepfold,</if>
|
||||
<if test="sheepId != null">sheep,</if>
|
||||
<if test="datetime != null">datetime,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
@ -70,6 +88,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="useType != null">#{useType},</if>
|
||||
<if test="sheepfoldId != null">#{sheepfoldId},</if>
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="datetime != null">#{datetime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
@ -113,9 +134,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<insert id="batchSwMedicineUsageDetails">
|
||||
insert into sw_medicine_usage_details( id, medi_usage, medi_id, dosage, unit, usageId, manufacturer, batch_number) values
|
||||
insert into sw_medicine_usage_details( id, medi_usage, medi_id, dosage, unit, usageId,usetime, manufacturer, batch_number) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
( #{item.id}, #{item.mediUsage}, #{item.mediId}, #{item.dosage}, #{item.unit}, #{item.usageId}, #{item.manufacturer}, #{item.batchNumber})
|
||||
( #{item.id}, #{item.mediUsage}, #{item.mediId}, #{item.dosage}, #{item.unit}, #{item.usageId}, #{item.usetime},#{item.manufacturer}, #{item.batchNumber})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@ -24,6 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="diseasePName" column="disease_pname"/>
|
||||
<result property="veterinary" column="veterinary" />
|
||||
<result property="usageId" column="usage_id" />
|
||||
<result property="status" column="status"/>
|
||||
<result property="comment" column="comment" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
@ -32,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTreatmentVo">
|
||||
select t.id, diag_id, sheep_id, variety, sheep_type, month_age, t.gender, t.parity, breed, lact_day, gest_day, datetime, disease_id, disease_pid, veterinary, usage_id, t.comment, t.update_by, t.update_time, t.create_by, t.create_time,
|
||||
select t.id, diag_id, sheep_id, variety, sheep_type, month_age, t.gender, t.parity, breed, lact_day, gest_day, datetime, disease_id, disease_pid, veterinary, usage_id,status, t.comment, t.update_by, t.update_time, t.create_by, t.create_time,
|
||||
bs.manage_tags,
|
||||
sd.name disease_name,
|
||||
sd2.name disease_pname
|
||||
@ -43,19 +44,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</sql>
|
||||
|
||||
<select id="selectTreatmentList" parameterType="Treatment" resultMap="TreatmentResult">
|
||||
<include refid="selectTreatmentVo"/>
|
||||
select t.id, diag_id, sheep_id, variety, sheep_type, month_age, t.gender, t.parity, breed, lact_day, gest_day, datetime, disease_id, disease_pid, veterinary, usage_id,status, t.comment, t.update_by, t.update_time, t.create_by, t.create_time,
|
||||
bs.manage_tags,
|
||||
sd.name disease_name,
|
||||
sd2.name disease_pname
|
||||
from sw_treatment t
|
||||
left join bas_sheep bs on t.sheep_id = bs.id
|
||||
left join sw_disease sd on t.disease_id = sd.id
|
||||
left join sw_disease sd2 on t.disease_pid = sd2.id
|
||||
<where>
|
||||
<if test="sheepId != null "> and sheep_id = #{sheepId}</if>
|
||||
<if test="sheepNo != null and sheepNo != ''">and bs.manage_tags like concat('%',#{sheepNo},'%')</if>
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="diseaseId != null "> and disease_id = #{diseaseId}</if>
|
||||
<if test="status != null and status !=''"> and status = #{status}</if>
|
||||
<if test="veterinary != null and veterinary != ''"> and veterinary = #{veterinary}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectTreatmentById" parameterType="Long" resultMap="TreatmentResult">
|
||||
<include refid="selectTreatmentVo"/>
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
<select id="selectTreatmentStatus" resultMap="TreatmentResult">
|
||||
select * from sw_treatment where sheep_id = #{sheepId} and status in (0, 1)
|
||||
</select>
|
||||
|
||||
<insert id="insertTreatment" parameterType="Treatment" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_treatment
|
||||
@ -75,6 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="diseasePid != null">disease_pid,</if>
|
||||
<if test="veterinary != null">veterinary,</if>
|
||||
<if test="usageId != null">usage_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
@ -97,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="diseasePid != null">#{diseasePid},</if>
|
||||
<if test="veterinary != null">#{veterinary},</if>
|
||||
<if test="usageId != null">#{usageId},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
@ -109,14 +125,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into sw_treatment
|
||||
(diag_id, sheep_id, variety, sheep_type, month_age, gender,
|
||||
parity, breed, lact_day, gest_day, datetime,
|
||||
disease_id, disease_pid, veterinary, usage_id,
|
||||
disease_id, disease_pid, veterinary, usage_id,status ,
|
||||
comment, update_by, update_time, create_by, create_time)
|
||||
values
|
||||
<foreach collection="list" item="t" separator=",">
|
||||
(#{t.diagId}, #{t.sheepId}, #{t.variety}, #{t.sheepType},
|
||||
#{t.monthAge}, #{t.gender}, #{t.parity}, #{t.breed},
|
||||
#{t.lactDay}, #{t.gestDay}, #{t.datetime}, #{t.diseaseId},
|
||||
#{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.comment},
|
||||
#{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.status}, #{t.comment},
|
||||
#{t.updateBy}, #{t.updateTime},#{t.createBy}, #{t.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
@ -139,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="diseasePid != null">disease_pid = #{diseasePid},</if>
|
||||
<if test="veterinary != null">veterinary = #{veterinary},</if>
|
||||
<if test="usageId != null">usage_id = #{usageId},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="comment != null">comment = #{comment},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.dairyProducts.mapper.NpSheepMilkAnalysisMapper">
|
||||
|
||||
<!-- 1) 获取 distinct sheep_id(支持按 sheep_file.bs_manage_tags 模糊搜索) -->
|
||||
<!-- 1) 获取distinct sheep_id(支持按sheep_file.bs_manage_tags模糊搜索) -->
|
||||
<select id="selectDistinctSheepIds" resultType="string" parameterType="map">
|
||||
SELECT DISTINCT a.sheep_id
|
||||
FROM np_milk_prod_classes a
|
||||
@ -30,8 +30,7 @@
|
||||
ORDER BY datetime ASC
|
||||
</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 -->
|
||||
<select id="selectSheepFileBySheepId" resultType="map" parameterType="string">
|
||||
SELECT
|
||||
@ -53,10 +52,29 @@
|
||||
WHERE id = #{sheepId}
|
||||
</select>
|
||||
|
||||
<!-- 4) 兼容旧 list 查询(返回 domain 对象列表),但在我们的实现中 service 会构造最终的 NpSheepMilkAnalysis 列表 -->
|
||||
<!-- 4) 兼容旧list查询(返回domain对象列表),但在我们的实现中service会构造最终的NpSheepMilkAnalysis列表 -->
|
||||
<select id="selectNpSheepMilkAnalysisList" resultType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis" parameterType="com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis">
|
||||
<!-- 如果你仍需基于某张表的简单映射,可在此实现;当前我们在 ServiceImpl 中组装对象,所以该查询不做复杂实现 -->
|
||||
<!-- 如果你仍需基于某张表的简单映射,可在此实现;当前我们在ServiceImpl中组装对象,所以该查询不做复杂实现 -->
|
||||
SELECT 1 FROM dual WHERE 1=0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
<!-- 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>
|
||||
@ -13,17 +13,18 @@
|
||||
<result property="coefficient" column="coefficient"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 修改SQL片段,系数保留两位小数 -->
|
||||
<sql id="selectXzDryMatterCorrectionVo">
|
||||
SELECT
|
||||
id,
|
||||
datetime,
|
||||
factory,
|
||||
content,
|
||||
standard,
|
||||
CASE
|
||||
WHEN standard = 0 OR standard IS NULL THEN NULL
|
||||
ELSE content / standard
|
||||
END AS coefficient
|
||||
id,
|
||||
datetime,
|
||||
factory,
|
||||
content,
|
||||
COALESCE(standard, 18) as standard, <!-- 设置默认值为18 -->
|
||||
CASE
|
||||
WHEN standard = 0 OR standard IS NULL THEN NULL
|
||||
ELSE ROUND(content / standard, 2) <!-- 系数保留两位小数 -->
|
||||
END AS coefficient
|
||||
FROM xz_dry_matter_correction
|
||||
</sql>
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.dairyProducts.mapper.XzParityCorrectionMapper">
|
||||
|
||||
|
||||
<resultMap type="XzParityCorrection" id="XzParityCorrectionResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="parity" column="parity" />
|
||||
@ -16,12 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectXzParityCorrectionList" parameterType="XzParityCorrection" resultMap="XzParityCorrectionResult">
|
||||
<include refid="selectXzParityCorrectionVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="parity != null "> and parity = #{parity}</if>
|
||||
<if test="coef != null "> and coef = #{coef}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectXzParityCorrectionById" parameterType="Long" resultMap="XzParityCorrectionResult">
|
||||
<include refid="selectXzParityCorrectionVo"/>
|
||||
where id = #{id}
|
||||
@ -32,11 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="parity != null">parity,</if>
|
||||
<if test="coef != null">coef,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="parity != null">#{parity},</if>
|
||||
<if test="coef != null">#{coef},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateXzParityCorrection" parameterType="XzParityCorrection">
|
||||
@ -53,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deleteXzParityCorrectionByIds" parameterType="String">
|
||||
delete from xz_parity_correction where id in
|
||||
delete from xz_parity_correction where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
@ -20,9 +20,11 @@
|
||||
<include refid="selectSgFeedListVo"/>
|
||||
<where>
|
||||
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
|
||||
<if test="formulaBatchId != null and formulaBatchId != ''"> and formula_batch_id = #{formulaBatchId}</if>
|
||||
<if test="zookeeper != null and zookeeper != ''"> and zookeeper = #{zookeeper}</if>
|
||||
<if test="deployDate != null "> and deploy_date = #{deployDate}</if>
|
||||
</where>
|
||||
ORDER BY deploy_date ASC, formula_id ASC, formula_batch_id ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedListById" parameterType="Long" resultMap="SgFeedListResult">
|
||||
@ -67,4 +69,8 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAll">
|
||||
DELETE FROM sg_feed_list;
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -37,9 +37,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectSgFeedPlanVo"/>
|
||||
<where>
|
||||
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
|
||||
<if test="batchId != null and batchId != ''"> and batch_id = #{batchId}</if>
|
||||
<if test="sheepHouseId != null "> and sheep_house_id = #{sheepHouseId}</if>
|
||||
<if test="planDate != null "> and plan_date = #{planDate}</if>
|
||||
</where>
|
||||
ORDER BY formula_id ASC, plan_date ASC
|
||||
ORDER BY plan_date ASC, formula_id ASC , batch_id ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedPlanByCreateDate" parameterType="Date" resultMap="SgFeedPlanResult">
|
||||
|
||||
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.feed.mapper.SgFeedStatisticMapper">
|
||||
|
||||
<resultMap type="SgFeedStatistic" id="SgFeedStatisticResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="formulaId" column="formula_id" />
|
||||
<result property="formulaBatchId" column="formula_batch_id" />
|
||||
<result property="sheepFoldCount" column="sheep_fold_count" />
|
||||
<result property="silageLossRate" column="silage_loss_rate" />
|
||||
<result property="feedTotalSize" column="feed_total_size" />
|
||||
<result property="feedDailySize" column="feed_daily_size" />
|
||||
<!--
|
||||
适配泛型TypeHandler
|
||||
弃用: XML中无法使用"<>"
|
||||
-->
|
||||
<!-- <result property="materialList" column="material_list"-->
|
||||
<!-- typeHandler="com.zhyc.module.feed.mapper.TypeHandler.JsonTypeHandler<java.util.List<com.zhyc.module.feed.domain.SgFormulaList>>" />-->
|
||||
<!-- 分别使用两个TypeHandler完成实体类List<T> 到 数据库 JSON串的映射转换 -->
|
||||
<result property="materialList" column="material_list" typeHandler="com.zhyc.module.feed.mapper.TypeHandler.SgFormulaListHandler"/>
|
||||
<result property="sheepFoldList" column="sheep_fold_list" typeHandler="com.zhyc.module.feed.mapper.TypeHandler.DaSheepfoldHandler"/>
|
||||
<result property="feedDate" column="feed_date" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSgFeedStatisticVo">
|
||||
select id, formula_id, formula_batch_id, sheep_fold_count, silage_loss_rate, feed_total_size, feed_daily_size, material_list, sheep_fold_list,feed_date from sg_feed_statistic
|
||||
</sql>
|
||||
|
||||
<select id="selectSgFeedStatisticList" parameterType="SgFeedStatistic" resultMap="SgFeedStatisticResult">
|
||||
<include refid="selectSgFeedStatisticVo"/>
|
||||
<where>
|
||||
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
|
||||
<if test="formulaBatchId != null and formulaBatchId != ''"> and formula_batch_id = #{formulaBatchId}</if>
|
||||
<if test="silageLossRate != null and silageLossRate != ''"> and silage_loss_rate = #{silageLossRate}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedStatisticById" parameterType="String" resultMap="SgFeedStatisticResult">
|
||||
<include refid="selectSgFeedStatisticVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSgFeedStatistic" parameterType="SgFeedStatistic">
|
||||
insert into sg_feed_statistic
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="formulaId != null and formulaId != ''">formula_id,</if>
|
||||
<if test="formulaBatchId != null and formulaBatchId != ''">formula_batch_id,</if>
|
||||
<if test="sheepFoldCount != null">sheep_fold_count,</if>
|
||||
<if test="silageLossRate != null">silage_loss_rate,</if>
|
||||
<if test="feedTotalSize != null">feed_total_size,</if>
|
||||
<if test="feedDailySize != null">feed_daily_size,</if>
|
||||
<if test="materialList != null">material_list,</if>
|
||||
<if test="sheepFoldList != null">sheep_fold_list,</if>
|
||||
<if test="feedDate != null">feed_date,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="formulaId != null and formulaId != ''">#{formulaId},</if>
|
||||
<if test="formulaBatchId != null and formulaBatchId != ''">#{formulaBatchId},</if>
|
||||
<if test="sheepFoldCount != null">#{sheepFoldCount},</if>
|
||||
<if test="silageLossRate != null">#{silageLossRate},</if>
|
||||
<if test="feedTotalSize != null">#{feedTotalSize},</if>
|
||||
<if test="feedDailySize != null">#{feedDailySize},</if>
|
||||
# 写入操作需要手动指定 TypeHandler 参数
|
||||
<if test="materialList != null">#{materialList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.SgFormulaListHandler},</if>
|
||||
<if test="sheepFoldList != null">#{sheepFoldList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.DaSheepfoldHandler},</if>
|
||||
<if test="feedDate != null">#{feedDate},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSgFeedStatistic" parameterType="SgFeedStatistic">
|
||||
update sg_feed_statistic
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="formulaId != null and formulaId != ''">formula_id = #{formulaId},</if>
|
||||
<if test="formulaBatchId != null and formulaBatchId != ''">formula_batch_id = #{formulaBatchId},</if>
|
||||
<if test="sheepFoldCount != null">sheep_fold_count = #{sheepFoldCount},</if>
|
||||
<if test="silageLossRate != null">silage_loss_rate = #{silageLossRate},</if>
|
||||
<if test="feedTotalSize != null">feed_total_size = #{feedTotalSize},</if>
|
||||
<if test="feedDailySize != null">feed_daily_size = #{feedDailySize},</if>
|
||||
<if test="materialList != null">material_list = #{materialList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.SgFormulaListHandler},</if>
|
||||
<if test="sheepFoldList != null">sheep_fold_list = #{sheepFoldList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.DaSheepfoldHandler},</if>
|
||||
<if test="feedDate != null">feed_date = #{feedDate},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSgFeedStatisticById" parameterType="String">
|
||||
delete from sg_feed_statistic where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSgFeedStatisticByIds" parameterType="String">
|
||||
delete from sg_feed_statistic where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScMiscarriageRecordMapper">
|
||||
|
||||
<resultMap type="ScMiscarriageRecord" id="ScMiscarriageRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="datetime" column="datetime" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="technician" column="technician" />
|
||||
<result property="reason" column="reason" />
|
||||
<result property="exposeType" column="expose_type" />
|
||||
<result property="status" column="status" />
|
||||
<result property="miscaLamb" column="misca_lamb" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<!-- 关联查询字段 -->
|
||||
<result property="bsManageTags" column="bs_manage_tags" />
|
||||
<result property="variety" column="variety" />
|
||||
<result property="matingTypeId" column="mating_type_id" />
|
||||
<result property="matingTypeName" column="mating_type_name" />
|
||||
<result property="matingDate" column="mating_date" />
|
||||
<result property="parity" column="parity" />
|
||||
<result property="ramVariety" column="ram_variety" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
<result property="pregnantDays" column="pregnant_days" />
|
||||
<result property="sheepfoldName" column="sheepfold_name" />
|
||||
<result property="drRanch" column="dr_ranch" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectScMiscarriageRecordVo">
|
||||
select
|
||||
smr.id,
|
||||
smr.sheep_id,
|
||||
smr.datetime,
|
||||
smr.comment,
|
||||
smr.technician,
|
||||
smr.reason,
|
||||
smr.expose_type,
|
||||
smr.status,
|
||||
smr.misca_lamb,
|
||||
smr.create_by,
|
||||
smr.create_time,
|
||||
sf.bs_manage_tags,
|
||||
sf.variety,
|
||||
sf.mating_type_id,
|
||||
CASE sf.mating_type_id
|
||||
WHEN 1 THEN '人工授精'
|
||||
WHEN 2 THEN '自然配种'
|
||||
WHEN 3 THEN '胚胎移植'
|
||||
ELSE '未知'
|
||||
END as mating_type_name,
|
||||
sf.mating_date,
|
||||
sf.parity,
|
||||
sf.variety as ram_variety, -- 这里需要根据实际配种公羊信息调整
|
||||
sf.month_age,
|
||||
CASE
|
||||
WHEN sf.mating_date IS NOT NULL AND smr.datetime IS NOT NULL
|
||||
THEN DATEDIFF(smr.datetime, sf.mating_date)
|
||||
ELSE NULL
|
||||
END as pregnant_days,
|
||||
sf.sheepfold_name,
|
||||
sf.dr_ranch
|
||||
from sc_miscarriage_record smr
|
||||
left join sheep_file sf on smr.sheep_id = sf.bs_manage_tags
|
||||
</sql>
|
||||
|
||||
<select id="selectScMiscarriageRecordList" parameterType="ScMiscarriageRecord" resultMap="ScMiscarriageRecordResult">
|
||||
<include refid="selectScMiscarriageRecordVo"/>
|
||||
<where>
|
||||
<if test="sheepId != null and sheepId != ''"> and smr.sheep_id = #{sheepId}</if>
|
||||
<if test="bsManageTags != null and bsManageTags != ''"> and sf.bs_manage_tags like concat('%', #{bsManageTags}, '%')</if>
|
||||
<if test="datetime != null"> and smr.datetime = #{datetime}</if>
|
||||
<if test="comment != null and comment != ''"> and smr.comment like concat('%', #{comment}, '%')</if>
|
||||
<if test="technician != null and technician != ''"> and smr.technician like concat('%', #{technician}, '%')</if>
|
||||
<if test="reason != null and reason != ''"> and smr.reason = #{reason}</if>
|
||||
<if test="exposeType != null"> and smr.expose_type = #{exposeType}</if>
|
||||
<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>
|
||||
</where>
|
||||
order by smr.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectScMiscarriageRecordById" parameterType="Long" resultMap="ScMiscarriageRecordResult">
|
||||
<include refid="selectScMiscarriageRecordVo"/>
|
||||
where smr.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertScMiscarriageRecord" parameterType="ScMiscarriageRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_miscarriage_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="datetime != null">datetime,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="technician != null">technician,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
<if test="exposeType != null">expose_type,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="miscaLamb != null">misca_lamb,</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="datetime != null">#{datetime},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="technician != null">#{technician},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
<if test="exposeType != null">#{exposeType},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="miscaLamb != null">#{miscaLamb},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateScMiscarriageRecord" parameterType="ScMiscarriageRecord">
|
||||
update sc_miscarriage_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
||||
<if test="datetime != null">datetime = #{datetime},</if>
|
||||
<if test="comment != null">comment = #{comment},</if>
|
||||
<if test="technician != null">technician = #{technician},</if>
|
||||
<if test="reason != null">reason = #{reason},</if>
|
||||
<if test="exposeType != null">expose_type = #{exposeType},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="miscaLamb != null">misca_lamb = #{miscaLamb},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScMiscarriageRecordById" parameterType="Long">
|
||||
delete from sc_miscarriage_record where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteScMiscarriageRecordByIds" parameterType="String">
|
||||
delete from sc_miscarriage_record where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 根据耳号查询羊只信息 -->
|
||||
<select id="selectSheepByManageTags" parameterType="String" resultType="map">
|
||||
select bs_manage_tags, variety, parity, month_age, sheepfold_name, dr_ranch
|
||||
from sheep_file
|
||||
where bs_manage_tags = #{manageTags}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -102,6 +102,7 @@
|
||||
and sm.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sm.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScBodyMeasureById" parameterType="Long" resultMap="ScBodyMeasureResult">
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sbs.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScBodyScoreById" parameterType="Long" resultMap="ScBodyScoreResult">
|
||||
|
||||
@ -56,6 +56,7 @@
|
||||
and sbr.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sbr.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScBreastRatingById" parameterType="Long" resultMap="ScBreastRatingResult">
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="create_by" />
|
||||
<result property="updateTime" column="create_time" />
|
||||
<!-- 关联羊只信息字段 -->
|
||||
<result property="variety" column="variety" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
@ -32,6 +30,7 @@
|
||||
<result property="expectedDate" column="expected_date" />
|
||||
<result property="lastEventDate" column="last_event_date" />
|
||||
<result property="ranchName" column="ranch" />
|
||||
<result property="daysAfterMating" column="days_after_mating" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectScPregnancyRecordVo">
|
||||
@ -46,8 +45,6 @@
|
||||
pr.remark,
|
||||
pr.create_by,
|
||||
pr.create_time,
|
||||
pr.create_by,
|
||||
pr.create_time,
|
||||
sf.bs_manage_tags as manage_tags,
|
||||
sf.variety,
|
||||
sf.month_age,
|
||||
@ -55,18 +52,37 @@
|
||||
sf.mating_counts,
|
||||
sf.sheepfold_name,
|
||||
sf.breed,
|
||||
sf.father_manage_tags,
|
||||
father_sf.variety as father_variety,
|
||||
mating_type.dict_label as mating_type_name,
|
||||
sf.mating_date,
|
||||
sf.expected_date,
|
||||
sf.lambing_date as last_event_date,
|
||||
r.ranch as ranch
|
||||
sf.dr_ranch as ranch,
|
||||
-- 关联配种信息
|
||||
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
|
||||
left join sheep_file sf on pr.sheep_id = 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'
|
||||
left join da_ranch r on sf.ranch_id = r.id
|
||||
left join sheep_file father_sf on sf.bs_father_id = father_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>
|
||||
|
||||
<select id="selectScPregnancyRecordList" parameterType="ScPregnancyRecord" resultMap="ScPregnancyRecordResult">
|
||||
@ -86,7 +102,7 @@
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="datetime != null "> and pr.datetime = #{datetime}</if>
|
||||
<if test="datetime != null "> and DATE(pr.datetime) = DATE(#{datetime})</if>
|
||||
<if test="result != null and result != ''"> and pr.result = #{result}</if>
|
||||
<if test="technician != null and technician != ''"> and pr.technician like concat('%', #{technician}, '%')</if>
|
||||
<if test="way != null and way != ''"> and pr.way = #{way}</if>
|
||||
@ -116,6 +132,28 @@
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 根据耳号获取配种信息 -->
|
||||
<select id="selectBreedInfoByManageTags" parameterType="String" resultType="map">
|
||||
SELECT
|
||||
sf.bs_manage_tags as manageTags,
|
||||
-- 从配种记录表获取公羊耳号
|
||||
ram_sf.bs_manage_tags as fatherManageTags,
|
||||
ram_sf.variety as fatherVariety,
|
||||
br.create_time as matingDate,
|
||||
mating_type.dict_label as matingTypeName,
|
||||
br.technician as breedTechnician,
|
||||
br.create_time as breedCreateTime
|
||||
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 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'
|
||||
WHERE sf.bs_manage_tags = #{manageTags}
|
||||
AND sf.is_delete = 0
|
||||
ORDER BY br.create_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insertScPregnancyRecord" parameterType="ScPregnancyRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sc_pregnancy_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@ -153,8 +191,6 @@
|
||||
<if test="technician != null">technician = #{technician},</if>
|
||||
<if test="way != null">way = #{way},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null">create_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">create_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@ -178,7 +214,6 @@
|
||||
<if test="breedStatusId != null">breed_status_id = #{breedStatusId},</if>
|
||||
<if test="expectedDate != null">expected_date = #{expectedDate},</if>
|
||||
<if test="gestationDay != null">gestation_day = #{gestationDay},</if>
|
||||
create_time = now()
|
||||
</set>
|
||||
where id = #{sheepId}
|
||||
</update>
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
<if test="comment != null and comment != ''"> and comment = #{comment}</if>
|
||||
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectScSheepDeathById" parameterType="Long" resultMap="ScSheepDeathResult">
|
||||
@ -53,9 +54,21 @@
|
||||
|
||||
<!-- 根据管理耳号查询sheep_file视图信息 -->
|
||||
<select id="selectSheepFileByManageTags" parameterType="String" resultType="java.util.Map">
|
||||
select id as sheepId, variety, name as sheepType, gender, day_age as dayAge, parity, sheepfold_name as sheepfoldName, breed as breedStatus, post_lambing_day as postLambingDay, lactation_day as lactationDay, gestation_day as gestationDay
|
||||
select
|
||||
id as sheepId,
|
||||
variety,
|
||||
name as sheepType,
|
||||
gender,
|
||||
day_age as dayAge,
|
||||
parity,
|
||||
sheepfold_name as sheepfoldName,
|
||||
breed as breedStatus,
|
||||
post_lambing_day as postLambingDay,
|
||||
lactation_day as lactationDay,
|
||||
gestation_day as gestationDay
|
||||
from sheep_file
|
||||
where bs_manage_tags = #{manageTags} and is_delete = 0
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertScSheepDeath" parameterType="ScSheepDeath" useGeneratedKeys="true" keyProperty="id">
|
||||
@ -131,4 +144,23 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 更新羊只繁育状态 - 保留原有功能 -->
|
||||
<update id="updateSheepFileStatus">
|
||||
UPDATE sheep_file
|
||||
SET breed = #{status},
|
||||
update_time = NOW()
|
||||
WHERE id = #{sheepId}
|
||||
AND is_delete = 0
|
||||
</update>
|
||||
|
||||
<!-- 新增:更新羊只在群状态 -->
|
||||
<update id="updateSheepStatus">
|
||||
UPDATE sheep_file
|
||||
SET status = #{status},
|
||||
update_time = NOW()
|
||||
WHERE id = #{sheepId}
|
||||
AND is_delete = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@ -49,6 +49,7 @@
|
||||
and scc.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY scc.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScChangeCommentById" parameterType="Long" resultMap="ScChangeCommentResult">
|
||||
|
||||
@ -61,6 +61,7 @@
|
||||
and sce.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sce.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScChangeEarById" parameterType="Integer" resultMap="ScChangeEarResult">
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
and scv.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY scv.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScChangeVarietyById" parameterType="Integer" resultMap="ScChangeVarietyResult">
|
||||
|
||||
@ -71,6 +71,7 @@
|
||||
and tg.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY tg.create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@
|
||||
and t.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScTransitionInfoById" parameterType="Integer" resultMap="ScTransitionInfoResult">
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
and sc.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sc.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScCastrateById" parameterType="Long" resultMap="ScCastrateResult">
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY fh.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScFixHoofById" parameterType="java.lang.Integer" resultMap="ScFixHoofResult">
|
||||
|
||||
207
zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml
Normal file
207
zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml
Normal file
@ -0,0 +1,207 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.sale.mapper.SxSheepSaleMapper">
|
||||
|
||||
<resultMap type="SxSheepSale" id="SxSheepSaleResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="bsManageTags" column="bs_manage_tags" />
|
||||
<result property="sheepfoldId" column="sheepfold_id" />
|
||||
<result property="variety" column="variety" />
|
||||
<result property="sheepName" column="sheep_name" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
<result property="parity" column="parity" />
|
||||
<result property="breed" column="breed" />
|
||||
<result property="postLambingDay" column="post_lambing_day" />
|
||||
<result property="lactationDay" column="lactation_day" />
|
||||
<result property="lambingDay" column="lambing_day" />
|
||||
<result property="eventType" column="event_type" />
|
||||
<result property="saleDate" column="sale_date" />
|
||||
<result property="pricingMethod" column="pricing_method" />
|
||||
<result property="unitPrice" column="unit_price" />
|
||||
<result property="totalPrice" column="total_price" />
|
||||
<result property="totalWeight" column="total_weight" />
|
||||
<result property="avgWeight" column="avg_weight" />
|
||||
<result property="avgPricePerSheep" column="avg_price_per_sheep" />
|
||||
<result property="saleType" column="sale_type" />
|
||||
<result property="diseaseType" column="disease_type" />
|
||||
<result property="secondaryReason" column="secondary_reason" />
|
||||
<result property="groupCode" column="group_code" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="salesPersonId" column="sales_person_id" />
|
||||
<result property="quarantineNo" column="quarantine_no" />
|
||||
<result property="approvalNo" column="approval_no" />
|
||||
<result property="technicianId" column="technician_id" />
|
||||
<result property="handlerId" column="handler_id" />
|
||||
<result property="createdBy" column="created_by" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSxSheepSaleVo">
|
||||
select id, bs_manage_tags, sheepfold_id, variety, sheep_name, gender, month_age, parity, breed, post_lambing_day, lactation_day, lambing_day, event_type, sale_date, pricing_method, unit_price, total_price, total_weight, avg_weight, avg_price_per_sheep, sale_type, disease_type, secondary_reason, group_code, customer_id, sales_person_id, quarantine_no, approval_no, technician_id, handler_id, created_by, created_at, remark from sx_sheep_sale
|
||||
</sql>
|
||||
|
||||
<!-- 【新增】根据耳号查询羊只信息的SQL片段 -->
|
||||
<sql id="selectSheepFileVo">
|
||||
select
|
||||
bs_manage_tags,
|
||||
variety,
|
||||
name as sheep_name,
|
||||
gender,
|
||||
month_age,
|
||||
parity,
|
||||
breed,
|
||||
post_lambing_day,
|
||||
lactation_day,
|
||||
lambing_day,
|
||||
sheepfold_id
|
||||
from sheep_file
|
||||
</sql>
|
||||
|
||||
<!-- 【新增】根据耳号查询羊只信息 -->
|
||||
<select id="selectSheepInfoByTag" parameterType="String" resultMap="SxSheepSaleResult">
|
||||
<include refid="selectSheepFileVo"/>
|
||||
where bs_manage_tags = #{bsManageTags}
|
||||
</select>
|
||||
|
||||
<select id="selectSxSheepSaleList" parameterType="SxSheepSale" resultMap="SxSheepSaleResult">
|
||||
<include refid="selectSxSheepSaleVo"/>
|
||||
<where>
|
||||
<if test="bsManageTags != null and bsManageTags != ''"> and bs_manage_tags = #{bsManageTags}</if>
|
||||
<if test="sheepfoldId != null "> and sheepfold_id = #{sheepfoldId}</if>
|
||||
<if test="variety != null and variety != ''"> and variety = #{variety}</if>
|
||||
<if test="sheepName != null and sheepName != ''"> and sheep_name = #{sheepName}</if>
|
||||
<if test="saleDate != null"> and sale_date = #{saleDate}</if>
|
||||
<if test="saleType != null and saleType != ''"> and sale_type = #{saleType}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSxSheepSaleById" parameterType="Long" resultMap="SxSheepSaleResult">
|
||||
<include refid="selectSxSheepSaleVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSxSheepSale" parameterType="SxSheepSale" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sx_sheep_sale
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="bsManageTags != null and bsManageTags != ''">bs_manage_tags,</if>
|
||||
<if test="sheepfoldId != null">sheepfold_id,</if>
|
||||
<if test="variety != null and variety != ''">variety,</if>
|
||||
<if test="sheepName != null and sheepName != ''">sheep_name,</if>
|
||||
<if test="gender != null and gender != ''">gender,</if>
|
||||
<if test="monthAge != null">month_age,</if>
|
||||
<if test="parity != null">parity,</if>
|
||||
<if test="breed != null and breed != ''">breed,</if>
|
||||
<if test="postLambingDay != null">post_lambing_day,</if>
|
||||
<if test="lactationDay != null">lactation_day,</if>
|
||||
<if test="lambingDay != null">lambing_day,</if>
|
||||
<if test="eventType != null and eventType != ''">event_type,</if>
|
||||
<if test="saleDate != null">sale_date,</if>
|
||||
<if test="pricingMethod != null and pricingMethod != ''">pricing_method,</if>
|
||||
<if test="unitPrice != null">unit_price,</if>
|
||||
<if test="totalPrice != null">total_price,</if>
|
||||
<if test="totalWeight != null">total_weight,</if>
|
||||
<if test="avgWeight != null">avg_weight,</if>
|
||||
<if test="avgPricePerSheep != null">avg_price_per_sheep,</if>
|
||||
<if test="saleType != null and saleType != ''">sale_type,</if>
|
||||
<if test="diseaseType != null and diseaseType != ''">disease_type,</if>
|
||||
<if test="secondaryReason != null and secondaryReason != ''">secondary_reason,</if>
|
||||
<if test="groupCode != null and groupCode != ''">group_code,</if>
|
||||
<if test="customerId != null">customer_id,</if>
|
||||
<if test="salesPersonId != null">sales_person_id,</if>
|
||||
<if test="quarantineNo != null and quarantineNo != ''">quarantine_no,</if>
|
||||
<if test="approvalNo != null and approvalNo != ''">approval_no,</if>
|
||||
<if test="technicianId != null">technician_id,</if>
|
||||
<if test="handlerId != null">handler_id,</if>
|
||||
<if test="createdBy != null">created_by,</if>
|
||||
<if test="createdAt != null">created_at,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="bsManageTags != null and bsManageTags != ''">#{bsManageTags},</if>
|
||||
<if test="sheepfoldId != null">#{sheepfoldId},</if>
|
||||
<if test="variety != null and variety != ''">#{variety},</if>
|
||||
<if test="sheepName != null and sheepName != ''">#{sheepName},</if>
|
||||
<if test="gender != null and gender != ''">#{gender},</if>
|
||||
<if test="monthAge != null">#{monthAge},</if>
|
||||
<if test="parity != null">#{parity},</if>
|
||||
<if test="breed != null and breed != ''">#{breed},</if>
|
||||
<if test="postLambingDay != null">#{postLambingDay},</if>
|
||||
<if test="lactationDay != null">#{lactationDay},</if>
|
||||
<if test="lambingDay != null">#{lambingDay},</if>
|
||||
<if test="eventType != null and eventType != ''">#{eventType},</if>
|
||||
<if test="saleDate != null">#{saleDate},</if>
|
||||
<if test="pricingMethod != null and pricingMethod != ''">#{pricingMethod},</if>
|
||||
<if test="unitPrice != null">#{unitPrice},</if>
|
||||
<if test="totalPrice != null">#{totalPrice},</if>
|
||||
<if test="totalWeight != null">#{totalWeight},</if>
|
||||
<if test="avgWeight != null">#{avgWeight},</if>
|
||||
<if test="avgPricePerSheep != null">#{avgPricePerSheep},</if>
|
||||
<if test="saleType != null and saleType != ''">#{saleType},</if>
|
||||
<if test="diseaseType != null and diseaseType != ''">#{diseaseType},</if>
|
||||
<if test="secondaryReason != null and secondaryReason != ''">#{secondaryReason},</if>
|
||||
<if test="groupCode != null and groupCode != ''">#{groupCode},</if>
|
||||
<if test="customerId != null">#{customerId},</if>
|
||||
<if test="salesPersonId != null">#{salesPersonId},</if>
|
||||
<if test="quarantineNo != null and quarantineNo != ''">#{quarantineNo},</if>
|
||||
<if test="approvalNo != null and approvalNo != ''">#{approvalNo},</if>
|
||||
<if test="technicianId != null">#{technicianId},</if>
|
||||
<if test="handlerId != null">#{handlerId},</if>
|
||||
<if test="createdBy != null">#{createdBy},</if>
|
||||
<if test="createdAt != null">#{createdAt},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSxSheepSale" parameterType="SxSheepSale">
|
||||
update sx_sheep_sale
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="bsManageTags != null and bsManageTags != ''">bs_manage_tags = #{bsManageTags},</if>
|
||||
<if test="sheepfoldId != null">sheepfold_id = #{sheepfoldId},</if>
|
||||
<if test="variety != null and variety != ''">variety = #{variety},</if>
|
||||
<if test="sheepName != null and sheepName != ''">sheep_name = #{sheepName},</if>
|
||||
<if test="gender != null and gender != ''">gender = #{gender},</if>
|
||||
<if test="monthAge != null">month_age = #{monthAge},</if>
|
||||
<if test="parity != null">parity = #{parity},</if>
|
||||
<if test="breed != null and breed != ''">breed = #{breed},</if>
|
||||
<if test="postLambingDay != null">post_lambing_day = #{postLambingDay},</if>
|
||||
<if test="lactationDay != null">lactation_day = #{lactationDay},</if>
|
||||
<if test="lambingDay != null">lambing_day = #{lambingDay},</if>
|
||||
<if test="eventType != null and eventType != ''">event_type = #{eventType},</if>
|
||||
<if test="saleDate != null">sale_date = #{saleDate},</if>
|
||||
<if test="pricingMethod != null and pricingMethod != ''">pricing_method = #{pricingMethod},</if>
|
||||
<if test="unitPrice != null">unit_price = #{unitPrice},</if>
|
||||
<if test="totalPrice != null">total_price = #{totalPrice},</if>
|
||||
<if test="totalWeight != null">total_weight = #{totalWeight},</if>
|
||||
<if test="avgWeight != null">avg_weight = #{avgWeight},</if>
|
||||
<if test="avgPricePerSheep != null">avg_price_per_sheep = #{avgPricePerSheep},</if>
|
||||
<if test="saleType != null and saleType != ''">sale_type = #{saleType},</if>
|
||||
<if test="diseaseType != null and diseaseType != ''">disease_type = #{diseaseType},</if>
|
||||
<if test="secondaryReason != null and secondaryReason != ''">secondary_reason = #{secondaryReason},</if>
|
||||
<if test="groupCode != null and groupCode != ''">group_code = #{groupCode},</if>
|
||||
<if test="customerId != null">customer_id = #{customerId},</if>
|
||||
<if test="salesPersonId != null">sales_person_id = #{salesPersonId},</if>
|
||||
<if test="quarantineNo != null and quarantineNo != ''">quarantine_no = #{quarantineNo},</if>
|
||||
<if test="approvalNo != null and approvalNo != ''">approval_no = #{approvalNo},</if>
|
||||
<if test="technicianId != null">technician_id = #{technicianId},</if>
|
||||
<if test="handlerId != null">handler_id = #{handlerId},</if>
|
||||
<if test="createdBy != null">created_by = #{createdBy},</if>
|
||||
<if test="createdAt != null">created_at = #{createdAt},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSxSheepSaleById" parameterType="Long">
|
||||
delete from sx_sheep_sale where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSxSheepSaleByIds" parameterType="String">
|
||||
delete from sx_sheep_sale where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@ -26,7 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectWzMaterialsManagementVo"/>
|
||||
<where>
|
||||
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
|
||||
<if test="params.beginProductionDate != null and params.beginProductionDate != '' and params.endProductionDate != null and params.endProductionDate != ''"> and production_date between #{params.beginProductionDate} and #{params.endProductionDate}</if>
|
||||
<if test="params.beginProductionDate != null and params.endProductionDate != null"> and production_date between #{params.beginProductionDate} and #{params.endProductionDate}</if>
|
||||
<if test="productionDate != null"> and production_date = #{productionDate}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="businessType != null and businessType != ''"> and business_type = #{businessType}</if>
|
||||
<if test="repositoryName != null and repositoryName != ''"> and repository_name like concat('%', #{repositoryName}, '%')</if>
|
||||
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
|
||||
<if test="docDate != null"> and doc_date = #{docDate}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user