From 3f4647e08df3ea7b7fe6dfad2e460b3cfbbf2703 Mon Sep 17 00:00:00 2001 From: zyk Date: Sat, 12 Jul 2025 00:17:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E4=BA=A7=E7=BE=94?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E9=A1=B5=E9=9D=A2=EF=BC=8C=E7=BC=BA=E4=B9=8F?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=B8=8A=E7=9A=84=E8=A1=A8=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=EF=BC=8C=E5=9B=A0=E4=B8=BA=E5=BE=88=E5=A4=9A=E8=A1=A8=E6=B2=A1?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=97=A0=E6=B3=95=E8=81=94=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScLambingRecordController.java | 137 ++++++ .../produce/breed/domain/ScLambDetail.java | 163 ++++++++ .../produce/breed/domain/ScLambingRecord.java | 390 ++++++++++++++++++ .../breed/mapper/ScLambDetailMapper.java | 85 ++++ .../breed/mapper/ScLambingRecordMapper.java | 70 ++++ .../service/IScLambingRecordService.java | 86 ++++ .../impl/ScLambingRecordServiceImpl.java | 112 +++++ .../mapper/breed/ScLambingRecordMapper.xml | 216 ++++++++++ 8 files changed, 1259 insertions(+) create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScLambingRecordController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambDetail.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambingRecord.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScLambDetailMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScLambingRecordMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScLambingRecordService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScLambingRecordServiceImpl.java create mode 100644 zhyc-module/src/main/resources/mapper/breed/ScLambingRecordMapper.xml diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScLambingRecordController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScLambingRecordController.java new file mode 100644 index 0000000..77bc4c0 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/controller/ScLambingRecordController.java @@ -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 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 list = scLambingRecordService.selectScLambingRecordList(scLambingRecord); + ExcelUtil util = new ExcelUtil(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 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 lambDetails) + { + return toAjax(scLambingRecordService.insertLambDetailsBatch(lambDetails)); + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambDetail.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambDetail.java new file mode 100644 index 0000000..27973a6 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambDetail.java @@ -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(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambingRecord.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambingRecord.java new file mode 100644 index 0000000..5aebf45 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/domain/ScLambingRecord.java @@ -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 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 getLambInfoList() { + return lambInfoList; + } + + public void setLambInfoList(List 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方法... +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScLambDetailMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScLambDetailMapper.java new file mode 100644 index 0000000..c562ae2 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScLambDetailMapper.java @@ -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 selectScLambDetailList(ScLambDetail scLambDetail); + + /** + * 根据产羔记录ID查询羔羊详情列表 + * + * @param lambingRecordId 产羔记录ID + * @return 羔羊详情集合 + */ + public List selectScLambDetailByLambingRecordId(Long lambingRecordId); + + /** + * 新增羔羊详情 + * + * @param scLambDetail 羔羊详情 + * @return 结果 + */ + public int insertScLambDetail(ScLambDetail scLambDetail); + + /** + * 批量新增羔羊详情 + * + * @param lambDetails 羔羊详情列表 + * @return 结果 + */ + public int insertScLambDetailBatch(List 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); +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScLambingRecordMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScLambingRecordMapper.java new file mode 100644 index 0000000..7719104 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScLambingRecordMapper.java @@ -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 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); +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScLambingRecordService.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScLambingRecordService.java new file mode 100644 index 0000000..16338a9 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/IScLambingRecordService.java @@ -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 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 selectLambDetailByLambingRecordId(Long lambingRecordId); + + /** + * 批量新增羔羊详情 + * + * @param lambDetails 羔羊详情列表 + * @return 结果 + */ + public int insertLambDetailsBatch(List lambDetails); +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScLambingRecordServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScLambingRecordServiceImpl.java new file mode 100644 index 0000000..2f0998a --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScLambingRecordServiceImpl.java @@ -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 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 selectLambDetailByLambingRecordId(Long lambingRecordId) { + return Collections.emptyList(); + } + + @Override + public int insertLambDetailsBatch(List lambDetails) { + return 0; + } +} diff --git a/zhyc-module/src/main/resources/mapper/breed/ScLambingRecordMapper.xml b/zhyc-module/src/main/resources/mapper/breed/ScLambingRecordMapper.xml new file mode 100644 index 0000000..ed000d9 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/breed/ScLambingRecordMapper.xml @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, sheep_id, parity, lambs_born, survival, technician, score, comment, create_by, create_tme from sc_lambing_record + + + + + 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 + + + + + + + + + + + + + + + + + insert into sc_lambing_record + + sheep_id, + parity, + lambs_born, + survival, + technician, + score, + comment, + create_by, + create_tme, + + + #{sheepId}, + #{parity}, + #{lambsBorn}, + #{survival}, + #{technician}, + #{score}, + #{comment}, + #{createBy}, + #{createTme}, + + + + + + update sc_lambing_record + + sheep_id = #{sheepId}, + parity = #{parity}, + lambs_born = #{lambsBorn}, + survival = #{survival}, + technician = #{technician}, + score = #{score}, + comment = #{comment}, + create_by = #{createBy}, + create_tme = #{createTme}, + + where id = #{id} + + + + + delete from sc_lambing_record where id = #{id} + + + + + delete from sc_lambing_record where id in + + #{id} + + + \ No newline at end of file