Compare commits

..

3 Commits

Author SHA1 Message Date
zyk
1ddc0419f8 zyk 更新依赖 2025-07-13 14:00:59 +08:00
zyk
c7ad83addf zyk 更新依赖 2025-07-13 13:57:43 +08:00
zyk
3f4647e08d 完成了产羔记录页面,缺乏界面上的表同步,因为很多表没信息无法联查 2025-07-13 13:56:30 +08:00
9 changed files with 1261 additions and 0 deletions

View File

@ -20,6 +20,8 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.38</version> <!-- 使用最新版本 -->
<scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -0,0 +1,137 @@
package com.zhyc.module.produce.breed.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.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.ScLambingRecord;
import com.zhyc.module.produce.breed.domain.ScLambDetail;
import com.zhyc.module.produce.breed.service.IScLambingRecordService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 产羔记录Controller
*
* @author ruoyi
* @date 2025-07-11
*/
@RestController
@RequestMapping("/breed/lambing_records")
public class ScLambingRecordController extends BaseController
{
@Autowired
private IScLambingRecordService scLambingRecordService;
/**
* 查询产羔记录列表包含关联信息
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:list')")
@GetMapping("/list")
public TableDataInfo list(ScLambingRecord scLambingRecord)
{
startPage();
List<ScLambingRecord> list = scLambingRecordService.selectScLambingRecordList(scLambingRecord);
return getDataTable(list);
}
/**
* 导出产羔记录列表
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:export')")
@Log(title = "产羔记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScLambingRecord scLambingRecord)
{
List<ScLambingRecord> list = scLambingRecordService.selectScLambingRecordList(scLambingRecord);
ExcelUtil<ScLambingRecord> util = new ExcelUtil<ScLambingRecord>(ScLambingRecord.class);
util.exportExcel(response, list, "产羔记录数据");
}
/**
* 获取产羔记录详细信息
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(scLambingRecordService.selectScLambingRecordById(id));
}
/**
* 获取产羔记录详细信息包含关联信息
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')")
@GetMapping(value = "/detail/{id}")
public AjaxResult getDetailInfo(@PathVariable("id") Long id)
{
return success(scLambingRecordService.selectScLambingRecordDetailById(id));
}
/**
* 查询产羔详情羔羊信息列表
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')")
@GetMapping("/lamb_detail/{lambingRecordId}")
public AjaxResult getLambDetail(@PathVariable("lambingRecordId") Long lambingRecordId)
{
List<ScLambDetail> list = scLambingRecordService.selectLambDetailByLambingRecordId(lambingRecordId);
return success(list);
}
/**
* 新增产羔记录包含羔羊详情
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:add')")
@Log(title = "产羔记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScLambingRecord scLambingRecord)
{
return toAjax(scLambingRecordService.insertScLambingRecord(scLambingRecord));
}
/**
* 修改产羔记录
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:edit')")
@Log(title = "产羔记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScLambingRecord scLambingRecord)
{
return toAjax(scLambingRecordService.updateScLambingRecord(scLambingRecord));
}
/**
* 删除产羔记录
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:remove')")
@Log(title = "产羔记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(scLambingRecordService.deleteScLambingRecordByIds(ids));
}
/**
* 批量新增羔羊详情
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:add')")
@Log(title = "羔羊详情", businessType = BusinessType.INSERT)
@PostMapping("/lamb_details/batch")
public AjaxResult addLambDetailsBatch(@RequestBody List<ScLambDetail> lambDetails)
{
return toAjax(scLambingRecordService.insertLambDetailsBatch(lambDetails));
}
}

View File

@ -0,0 +1,163 @@
package com.zhyc.module.produce.breed.domain;
import java.math.BigDecimal;
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_lamb_detail
*
* @author ruoyi
* @date 2025-07-11
*/
public class ScLambDetail extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 产羔记录ID */
@Excel(name = "产羔记录ID")
private Long lambingRecordId;
/** 羔羊耳号 */
@Excel(name = "羔羊耳号")
private String lambEarNumber;
/** 羔羊品种 */
@Excel(name = "羔羊品种")
private String lambBreed;
/** 性别 */
@Excel(name = "性别")
private String gender;
/** 出生重量 */
@Excel(name = "出生重量")
private BigDecimal birthWeight;
/** 是否留养 */
@Excel(name = "是否留养")
private Boolean isRetained;
/** 家系 */
@Excel(name = "家系")
private String lineage;
/** 生日 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday;
// getter和setter方法
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setLambingRecordId(Long lambingRecordId)
{
this.lambingRecordId = lambingRecordId;
}
public Long getLambingRecordId()
{
return lambingRecordId;
}
public void setLambEarNumber(String lambEarNumber)
{
this.lambEarNumber = lambEarNumber;
}
public String getLambEarNumber()
{
return lambEarNumber;
}
public void setLambBreed(String lambBreed)
{
this.lambBreed = lambBreed;
}
public String getLambBreed()
{
return lambBreed;
}
public void setGender(String gender)
{
this.gender = gender;
}
public String getGender()
{
return gender;
}
public void setBirthWeight(BigDecimal birthWeight)
{
this.birthWeight = birthWeight;
}
public BigDecimal getBirthWeight()
{
return birthWeight;
}
public void setIsRetained(Boolean isRetained)
{
this.isRetained = isRetained;
}
public Boolean getIsRetained()
{
return isRetained;
}
public void setLineage(String lineage)
{
this.lineage = lineage;
}
public String getLineage()
{
return lineage;
}
public void setBirthday(Date birthday)
{
this.birthday = birthday;
}
public Date getBirthday()
{
return birthday;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("lambingRecordId", getLambingRecordId())
.append("lambEarNumber", getLambEarNumber())
.append("lambBreed", getLambBreed())
.append("gender", getGender())
.append("birthWeight", getBirthWeight())
.append("isRetained", getIsRetained())
.append("lineage", getLineage())
.append("birthday", getBirthday())
.append("createTime", getCreateTime())
.toString();
}
}

View File

@ -0,0 +1,390 @@
package com.zhyc.module.produce.breed.domain;
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;
/**
* 产羔记录对象 sc_lambing_record
*
* @author ruoyi
* @date 2025-07-11
*/
public class ScLambingRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 羊只id */
@Excel(name = "羊只id")
private String sheepId;
/** 胎次 */
@Excel(name = "胎次")
private Long parity;
/** 产羔数量 */
@Excel(name = "产羔数量")
private Long lambsBorn;
/** 活羔数量 */
@Excel(name = "活羔数量")
private Long survival;
/** 技术员 */
@Excel(name = "技术员")
private String technician;
/** 产羔评分 */
@Excel(name = "产羔评分")
private Long score;
/** 备注 */
@Excel(name = "备注")
private String comment;
/** 创建日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date createTme;
// ========== 关联查询字段简化版 ==========
/** 母羊耳号 */
@Excel(name = "母羊耳号")
private String femaleEarNumber;
/** 母羊品种 */
@Excel(name = "母羊品种")
private String femaleBreed;
/** 月龄 */
@Excel(name = "月龄")
private Integer monthAge;
/** 当前羊舍 */
@Excel(name = "当前羊舍")
private String currentShed;
/** 所在牧场 */
@Excel(name = "所在牧场")
private String farm;
/** 配种日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "配种日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date breedingDate;
/** 公羊耳号 */
@Excel(name = "公羊耳号")
private String maleEarNumber;
/** 公羊品种 */
@Excel(name = "公羊品种")
private String maleBreed;
/** 产羔时怀孕天数 */
@Excel(name = "产羔时怀孕天数")
private Integer pregnancyDays;
/** 折损数(计算字段) */
@Excel(name = "折损数")
private Integer loss;
/** 公羔数量(从羊只信息表统计) */
@Excel(name = "公羔数量")
private Integer maleCount;
/** 母羔数量(从羊只信息表统计) */
@Excel(name = "母羔数量")
private Integer femaleCount;
/** 留养公羔数量 */
@Excel(name = "留养公羔数量")
private Integer retainedMaleCount;
/** 留养母羔数量 */
@Excel(name = "留养母羔数量")
private Integer retainedFemaleCount;
/** 未留养公羔数量 */
@Excel(name = "未留养公羔数量")
private Integer unretainedMaleCount;
/** 未留养母羔数量 */
@Excel(name = "未留养母羔数量")
private Integer unretainedFemaleCount;
/** 羔羊信息列表(从羊只信息表查询) */
private List<SheepLambInfo> lambInfoList;
// ========== 原有getter和setter方法 ==========
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 setParity(Long parity)
{
this.parity = parity;
}
public Long getParity()
{
return parity;
}
public void setLambsBorn(Long lambsBorn)
{
this.lambsBorn = lambsBorn;
}
public Long getLambsBorn()
{
return lambsBorn;
}
public void setSurvival(Long survival)
{
this.survival = survival;
}
public Long getSurvival()
{
return survival;
}
public void setTechnician(String technician)
{
this.technician = technician;
}
public String getTechnician()
{
return technician;
}
public void setScore(Long score)
{
this.score = score;
}
public Long getScore()
{
return score;
}
public void setComment(String comment)
{
this.comment = comment;
}
public String getComment()
{
return comment;
}
public void setCreateTme(Date createTme)
{
this.createTme = createTme;
}
public Date getCreateTme()
{
return createTme;
}
// ========== 简化版关联字段的getter和setter方法 ==========
public String getFemaleEarNumber() {
return femaleEarNumber;
}
public void setFemaleEarNumber(String femaleEarNumber) {
this.femaleEarNumber = femaleEarNumber;
}
public String getFemaleBreed() {
return femaleBreed;
}
public void setFemaleBreed(String femaleBreed) {
this.femaleBreed = femaleBreed;
}
public Integer getMonthAge() {
return monthAge;
}
public void setMonthAge(Integer monthAge) {
this.monthAge = monthAge;
}
public String getCurrentShed() {
return currentShed;
}
public void setCurrentShed(String currentShed) {
this.currentShed = currentShed;
}
public String getFarm() {
return farm;
}
public void setFarm(String farm) {
this.farm = farm;
}
public Date getBreedingDate() {
return breedingDate;
}
public void setBreedingDate(Date breedingDate) {
this.breedingDate = breedingDate;
}
public String getMaleEarNumber() {
return maleEarNumber;
}
public void setMaleEarNumber(String maleEarNumber) {
this.maleEarNumber = maleEarNumber;
}
public String getMaleBreed() {
return maleBreed;
}
public void setMaleBreed(String maleBreed) {
this.maleBreed = maleBreed;
}
public Integer getPregnancyDays() {
return pregnancyDays;
}
public void setPregnancyDays(Integer pregnancyDays) {
this.pregnancyDays = pregnancyDays;
}
public Integer getLoss() {
return loss;
}
public void setLoss(Integer loss) {
this.loss = loss;
}
public Integer getMaleCount() {
return maleCount;
}
public void setMaleCount(Integer maleCount) {
this.maleCount = maleCount;
}
public Integer getFemaleCount() {
return femaleCount;
}
public void setFemaleCount(Integer femaleCount) {
this.femaleCount = femaleCount;
}
public Integer getRetainedMaleCount() {
return retainedMaleCount;
}
public void setRetainedMaleCount(Integer retainedMaleCount) {
this.retainedMaleCount = retainedMaleCount;
}
public Integer getRetainedFemaleCount() {
return retainedFemaleCount;
}
public void setRetainedFemaleCount(Integer retainedFemaleCount) {
this.retainedFemaleCount = retainedFemaleCount;
}
public Integer getUnretainedMaleCount() {
return unretainedMaleCount;
}
public void setUnretainedMaleCount(Integer unretainedMaleCount) {
this.unretainedMaleCount = unretainedMaleCount;
}
public Integer getUnretainedFemaleCount() {
return unretainedFemaleCount;
}
public void setUnretainedFemaleCount(Integer unretainedFemaleCount) {
this.unretainedFemaleCount = unretainedFemaleCount;
}
public List<SheepLambInfo> getLambInfoList() {
return lambInfoList;
}
public void setLambInfoList(List<SheepLambInfo> lambInfoList) {
this.lambInfoList = lambInfoList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("sheepId", getSheepId())
.append("parity", getParity())
.append("lambsBorn", getLambsBorn())
.append("survival", getSurvival())
.append("technician", getTechnician())
.append("score", getScore())
.append("comment", getComment())
.append("createBy", getCreateBy())
.append("createTme", getCreateTme())
.append("femaleEarNumber", getFemaleEarNumber())
.append("femaleBreed", getFemaleBreed())
.append("farm", getFarm())
.toString();
}
}
/**
* 羊只羔羊信息对象用于产羔详情显示
*/
class SheepLambInfo {
private String lambEarNumber; // 羔羊耳号
private String lambBreed; // 羔羊品种
private String gender; // 性别
private Double birthWeight; // 出生重量
private Boolean isRetained; // 是否留养
private String lineage; // 家系
private Date birthday; // 生日
// getter和setter方法...
}

View File

@ -0,0 +1,85 @@
package com.zhyc.module.produce.breed.mapper;
import java.util.List;
import com.zhyc.module.produce.breed.domain.ScLambDetail;
/**
* 羔羊详情Mapper接口
*
* @author ruoyi
* @date 2025-07-11
*/
public interface ScLambDetailMapper
{
/**
* 查询羔羊详情
*
* @param id 羔羊详情主键
* @return 羔羊详情
*/
public ScLambDetail selectScLambDetailById(Long id);
/**
* 查询羔羊详情列表
*
* @param scLambDetail 羔羊详情
* @return 羔羊详情集合
*/
public List<ScLambDetail> selectScLambDetailList(ScLambDetail scLambDetail);
/**
* 根据产羔记录ID查询羔羊详情列表
*
* @param lambingRecordId 产羔记录ID
* @return 羔羊详情集合
*/
public List<ScLambDetail> selectScLambDetailByLambingRecordId(Long lambingRecordId);
/**
* 新增羔羊详情
*
* @param scLambDetail 羔羊详情
* @return 结果
*/
public int insertScLambDetail(ScLambDetail scLambDetail);
/**
* 批量新增羔羊详情
*
* @param lambDetails 羔羊详情列表
* @return 结果
*/
public int insertScLambDetailBatch(List<ScLambDetail> lambDetails);
/**
* 修改羔羊详情
*
* @param scLambDetail 羔羊详情
* @return 结果
*/
public int updateScLambDetail(ScLambDetail scLambDetail);
/**
* 删除羔羊详情
*
* @param id 羔羊详情主键
* @return 结果
*/
public int deleteScLambDetailById(Long id);
/**
* 批量删除羔羊详情
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScLambDetailByIds(Long[] ids);
/**
* 根据产羔记录ID删除羔羊详情
*
* @param lambingRecordId 产羔记录ID
* @return 结果
*/
public int deleteScLambDetailByLambingRecordId(Long lambingRecordId);
}

View File

@ -0,0 +1,70 @@
package com.zhyc.module.produce.breed.mapper;
import java.util.List;
import com.zhyc.module.produce.breed.domain.ScLambingRecord;
import com.zhyc.module.produce.breed.domain.ScLambDetail;
/**
* 产羔记录Mapper接口
*
* @author ruoyi
* @date 2025-07-11
*/
public interface ScLambingRecordMapper
{
/**
* 查询产羔记录
*
* @param id 产羔记录主键
* @return 产羔记录
*/
public ScLambingRecord selectScLambingRecordById(Long id);
/**
* 查询产羔记录列表包含关联信息
*
* @param scLambingRecord 产羔记录
* @return 产羔记录集合
*/
public List<ScLambingRecord> selectScLambingRecordList(ScLambingRecord scLambingRecord);
/**
* 查询产羔记录详细信息包含关联信息
*
* @param id 产羔记录主键
* @return 产羔记录
*/
public ScLambingRecord selectScLambingRecordDetailById(Long id);
/**
* 新增产羔记录
*
* @param scLambingRecord 产羔记录
* @return 结果
*/
public int insertScLambingRecord(ScLambingRecord scLambingRecord);
/**
* 修改产羔记录
*
* @param scLambingRecord 产羔记录
* @return 结果
*/
public int updateScLambingRecord(ScLambingRecord scLambingRecord);
/**
* 删除产羔记录
*
* @param id 产羔记录主键
* @return 结果
*/
public int deleteScLambingRecordById(Long id);
/**
* 批量删除产羔记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScLambingRecordByIds(Long[] ids);
}

View File

@ -0,0 +1,86 @@
package com.zhyc.module.produce.breed.service;
import java.util.List;
import com.zhyc.module.produce.breed.domain.ScLambingRecord;
import com.zhyc.module.produce.breed.domain.ScLambDetail;
/**
* 产羔记录Service接口
*
* @author ruoyi
* @date 2025-07-11
*/
public interface IScLambingRecordService
{
/**
* 查询产羔记录
*
* @param id 产羔记录主键
* @return 产羔记录
*/
public ScLambingRecord selectScLambingRecordById(Long id);
/**
* 查询产羔记录列表包含关联信息
*
* @param scLambingRecord 产羔记录
* @return 产羔记录集合
*/
public List<ScLambingRecord> selectScLambingRecordList(ScLambingRecord scLambingRecord);
/**
* 查询产羔记录详细信息包含关联信息
*
* @param id 产羔记录主键
* @return 产羔记录
*/
public ScLambingRecord selectScLambingRecordDetailById(Long id);
/**
* 新增产羔记录包含羔羊详情
*
* @param scLambingRecord 产羔记录
* @return 结果
*/
public int insertScLambingRecord(ScLambingRecord scLambingRecord);
/**
* 修改产羔记录
*
* @param scLambingRecord 产羔记录
* @return 结果
*/
public int updateScLambingRecord(ScLambingRecord scLambingRecord);
/**
* 批量删除产羔记录
*
* @param ids 需要删除的产羔记录主键集合
* @return 结果
*/
public int deleteScLambingRecordByIds(Long[] ids);
/**
* 删除产羔记录信息
*
* @param id 产羔记录主键
* @return 结果
*/
public int deleteScLambingRecordById(Long id);
/**
* 根据产羔记录ID查询羔羊详情列表
*
* @param lambingRecordId 产羔记录ID
* @return 羔羊详情列表
*/
public List<ScLambDetail> selectLambDetailByLambingRecordId(Long lambingRecordId);
/**
* 批量新增羔羊详情
*
* @param lambDetails 羔羊详情列表
* @return 结果
*/
public int insertLambDetailsBatch(List<ScLambDetail> lambDetails);
}

View File

@ -0,0 +1,112 @@
package com.zhyc.module.produce.breed.service.impl;
import java.util.List;
import com.zhyc.module.produce.breed.domain.ScLambDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.breed.mapper.ScLambingRecordMapper;
import com.zhyc.module.produce.breed.domain.ScLambingRecord;
import com.zhyc.module.produce.breed.service.IScLambingRecordService;
import java.util.Collections;
/**
* 产羔记录Service业务层处理
*
* @author ruoyi
* @date 2025-07-11
*/
@Service
public class ScLambingRecordServiceImpl implements IScLambingRecordService
{
@Autowired
private ScLambingRecordMapper scLambingRecordMapper;
/**
* 查询产羔记录
*
* @param id 产羔记录主键
* @return 产羔记录
*/
@Override
public ScLambingRecord selectScLambingRecordById(Long id)
{
return scLambingRecordMapper.selectScLambingRecordById(id);
}
/**
* 查询产羔记录列表
*
* @param scLambingRecord 产羔记录
* @return 产羔记录
*/
@Override
public List<ScLambingRecord> selectScLambingRecordList(ScLambingRecord scLambingRecord)
{
return scLambingRecordMapper.selectScLambingRecordList(scLambingRecord);
}
@Override
public ScLambingRecord selectScLambingRecordDetailById(Long id) {
return null;
}
/**
* 新增产羔记录
*
* @param scLambingRecord 产羔记录
* @return 结果
*/
@Override
public int insertScLambingRecord(ScLambingRecord scLambingRecord)
{
return scLambingRecordMapper.insertScLambingRecord(scLambingRecord);
}
/**
* 修改产羔记录
*
* @param scLambingRecord 产羔记录
* @return 结果
*/
@Override
public int updateScLambingRecord(ScLambingRecord scLambingRecord)
{
return scLambingRecordMapper.updateScLambingRecord(scLambingRecord);
}
/**
* 批量删除产羔记录
*
* @param ids 需要删除的产羔记录主键
* @return 结果
*/
@Override
public int deleteScLambingRecordByIds(Long[] ids)
{
return scLambingRecordMapper.deleteScLambingRecordByIds(ids);
}
/**
* 删除产羔记录信息
*
* @param id 产羔记录主键
* @return 结果
*/
@Override
public int deleteScLambingRecordById(Long id)
{
return scLambingRecordMapper.deleteScLambingRecordById(id);
}
@Override
public List<ScLambDetail> selectLambDetailByLambingRecordId(Long lambingRecordId) {
return Collections.emptyList();
}
@Override
public int insertLambDetailsBatch(List<ScLambDetail> lambDetails) {
return 0;
}
}

View File

@ -0,0 +1,216 @@
<?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.ScLambingRecordMapper">
<!-- 基础结果映射 -->
<resultMap type="ScLambingRecord" id="ScLambingRecordResult">
<result property="id" column="id" />
<result property="sheepId" column="sheep_id" />
<result property="parity" column="parity" />
<result property="lambsBorn" column="lambs_born" />
<result property="survival" column="survival" />
<result property="technician" column="technician" />
<result property="score" column="score" />
<result property="comment" column="comment" />
<result property="createBy" column="create_by" />
<result property="createTme" column="create_tme" />
</resultMap>
<!-- 详细结果映射(包含关联信息) -->
<resultMap type="ScLambingRecord" id="ScLambingRecordDetailResult">
<result property="id" column="id" />
<result property="sheepId" column="sheep_id" />
<result property="parity" column="parity" />
<result property="lambsBorn" column="lambs_born" />
<result property="survival" column="survival" />
<result property="technician" column="technician" />
<result property="score" column="score" />
<result property="comment" column="comment" />
<result property="createBy" column="create_by" />
<result property="createTme" column="create_tme" />
<!-- 母羊信息 -->
<result property="femaleEarNumber" column="female_ear_number" />
<result property="femaleBreed" column="female_breed" />
<result property="monthAge" column="month_age" />
<result property="currentShed" column="current_shed" />
<result property="farm" column="farm" />
<!-- 公羊信息 -->
<result property="maleEarNumber" column="male_ear_number" />
<result property="maleBreed" column="male_breed" />
<!-- 配种信息 -->
<result property="breedingDate" column="breeding_date" />
<result property="pregnancyDays" column="pregnancy_days" />
<!-- 统计信息 -->
<result property="maleCount" column="male_count" />
<result property="femaleCount" column="female_count" />
<result property="retainedMaleCount" column="retained_male_count" />
<result property="retainedFemaleCount" column="retained_female_count" />
<result property="unretainedMaleCount" column="unretained_male_count" />
<result property="unretainedFemaleCount" column="unretained_female_count" />
</resultMap>
<!-- 基础查询SQL -->
<sql id="selectScLambingRecordVo">
select id, sheep_id, parity, lambs_born, survival, technician, score, comment, create_by, create_tme from sc_lambing_record
</sql>
<!-- 详细查询SQL包含关联信息 -->
<sql id="selectScLambingRecordDetailVo">
SELECT
lr.id, lr.sheep_id, lr.parity, lr.lambs_born, lr.survival,
lr.technician, lr.score, lr.comment, lr.create_by, lr.create_tme,
-- 从bas_sheep表获取母羊信息
mother.manage_tags as female_ear_number,
mother.variety_id as female_breed,
TIMESTAMPDIFF(MONTH, mother.birthday, NOW()) as month_age,
mother.sheepfold_id as current_shed,
mother.ranch_id as farm,
-- 从sc_breed_record表获取配种信息
br.create_time as breeding_date,
DATEDIFF(lr.create_tme, br.create_time) as pregnancy_days,
-- 从bas_sheep表获取公羊信息
father.manage_tags as male_ear_number,
father.variety_id as male_breed,
-- 统计羔羊信息从bas_sheep表统计根据母羊ID
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.is_delete = 0) as male_count,
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.is_delete = 0) as female_count,
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.status_id = 1 AND lamb.is_delete = 0) as retained_male_count,
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.status_id = 1 AND lamb.is_delete = 0) as retained_female_count,
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.status_id != 1 AND lamb.is_delete = 0) as unretained_male_count,
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.status_id != 1 AND lamb.is_delete = 0) as unretained_female_count
FROM sc_lambing_record lr
LEFT JOIN bas_sheep mother ON lr.sheep_id = mother.id
LEFT JOIN sc_breed_record br ON lr.sheep_id = br.ewe_id AND lr.parity = mother.parity
LEFT JOIN bas_sheep father ON br.ram_id = father.id
</sql>
<!-- 查询产羔记录列表(包含关联信息) -->
<select id="selectScLambingRecordList" parameterType="ScLambingRecord" resultMap="ScLambingRecordDetailResult">
<include refid="selectScLambingRecordDetailVo"/>
<where>
<if test="femaleEarNumber != null and femaleEarNumber != ''"> and mother.manage_tags LIKE CONCAT('%', #{femaleEarNumber}, '%')</if>
<if test="femaleBreed != null and femaleBreed != ''"> and mother.variety_id = #{femaleBreed}</if>
<if test="farm != null and farm != ''"> and mother.ranch_id = #{farm}</if>
<if test="sheepId != null and sheepId != ''"> and lr.sheep_id = #{sheepId}</if>
<if test="parity != null"> and lr.parity = #{parity}</if>
<if test="lambsBorn != null"> and lr.lambs_born = #{lambsBorn}</if>
<if test="survival != null"> and lr.survival = #{survival}</if>
<if test="technician != null and technician != ''"> and lr.technician LIKE CONCAT('%', #{technician}, '%')</if>
<if test="score != null"> and lr.score = #{score}</if>
<if test="comment != null and comment != ''"> and lr.comment LIKE CONCAT('%', #{comment}, '%')</if>
<if test="createBy != null and createBy != ''"> and lr.create_by = #{createBy}</if>
<if test="createTme != null"> and DATE(lr.create_tme) = #{createTme}</if>
<if test="params.beginBreedingDate != null and params.beginBreedingDate != ''"><!-- 配种日期开始 -->
and DATE(br.create_time) &gt;= #{params.beginBreedingDate}
</if>
<if test="params.endBreedingDate != null and params.endBreedingDate != ''"><!-- 配种日期结束 -->
and DATE(br.create_time) &lt;= #{params.endBreedingDate}
</if>
and mother.is_delete = 0
</where>
ORDER BY lr.create_tme DESC
</select>
<!-- 查询产羔记录基础信息 -->
<select id="selectScLambingRecordById" parameterType="Long" resultMap="ScLambingRecordResult">
<include refid="selectScLambingRecordVo"/>
where id = #{id}
</select>
<!-- 查询产羔记录详细信息(包含关联信息) -->
<select id="selectScLambingRecordDetailById" parameterType="Long" resultMap="ScLambingRecordDetailResult">
<include refid="selectScLambingRecordDetailVo"/>
where lr.id = #{id} and mother.is_delete = 0
</select>
<!-- 查询羔羊详情从bas_sheep表查询 -->
<select id="selectLambDetailByLambingRecordId" parameterType="Long" resultType="map">
SELECT
sheep.manage_tags as lambEarNumber,
sheep.variety_id as lambBreed,
CASE sheep.gender
WHEN 1 THEN 'male'
WHEN 0 THEN 'female'
ELSE 'unknown'
END as gender,
sheep.birth_weight as birthWeight,
CASE sheep.status_id
WHEN 1 THEN true
ELSE false
END as isRetained,
sheep.family as lineage,
sheep.birthday
FROM bas_sheep sheep
WHERE sheep.mother_id = (SELECT sheep_id FROM sc_lambing_record WHERE id = #{lambingRecordId})
AND sheep.is_delete = 0
ORDER BY sheep.birthday ASC
</select>
<!-- 新增产羔记录 -->
<insert id="insertScLambingRecord" parameterType="ScLambingRecord" useGeneratedKeys="true" keyProperty="id">
insert into sc_lambing_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="parity != null">parity,</if>
<if test="lambsBorn != null">lambs_born,</if>
<if test="survival != null">survival,</if>
<if test="technician != null">technician,</if>
<if test="score != null">score,</if>
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTme != null">create_tme,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="parity != null">#{parity},</if>
<if test="lambsBorn != null">#{lambsBorn},</if>
<if test="survival != null">#{survival},</if>
<if test="technician != null">#{technician},</if>
<if test="score != null">#{score},</if>
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTme != null">#{createTme},</if>
</trim>
</insert>
<!-- 修改产羔记录 -->
<update id="updateScLambingRecord" parameterType="ScLambingRecord">
update sc_lambing_record
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="parity != null">parity = #{parity},</if>
<if test="lambsBorn != null">lambs_born = #{lambsBorn},</if>
<if test="survival != null">survival = #{survival},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="score != null">score = #{score},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTme != null">create_tme = #{createTme},</if>
</trim>
where id = #{id}
</update>
<!-- 删除产羔记录 -->
<delete id="deleteScLambingRecordById" parameterType="Long">
delete from sc_lambing_record where id = #{id}
</delete>
<!-- 批量删除产羔记录 -->
<delete id="deleteScLambingRecordByIds" parameterType="String">
delete from sc_lambing_record where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>