diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/variety/controller/BasSheepVarietyController.java b/zhyc-module/src/main/java/com/zhyc/module/base/variety/controller/BasSheepVarietyController.java new file mode 100644 index 0000000..1c24dfa --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/base/variety/controller/BasSheepVarietyController.java @@ -0,0 +1,104 @@ +package com.zhyc.module.base.variety.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.base.variety.domain.BasSheepVariety; +import com.zhyc.module.base.variety.service.IBasSheepVarietyService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 羊只品种Controller + * + * @author ruoyi + * @date 2025-07-15 + */ +@RestController +@RequestMapping("/base/variety") +public class BasSheepVarietyController extends BaseController +{ + @Autowired + private IBasSheepVarietyService basSheepVarietyService; + + /** + * 查询羊只品种列表 + */ + @PreAuthorize("@ss.hasPermi('base:variety:list')") + @GetMapping("/list") + public TableDataInfo list(BasSheepVariety basSheepVariety) + { + startPage(); + List list = basSheepVarietyService.selectBasSheepVarietyList(basSheepVariety); + return getDataTable(list); + } + + /** + * 导出羊只品种列表 + */ + @PreAuthorize("@ss.hasPermi('base:variety:export')") + @Log(title = "羊只品种", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, BasSheepVariety basSheepVariety) + { + List list = basSheepVarietyService.selectBasSheepVarietyList(basSheepVariety); + ExcelUtil util = new ExcelUtil(BasSheepVariety.class); + util.exportExcel(response, list, "羊只品种数据"); + } + + /** + * 获取羊只品种详细信息 + */ + @PreAuthorize("@ss.hasPermi('base:variety:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(basSheepVarietyService.selectBasSheepVarietyById(id)); + } + + /** + * 新增羊只品种 + */ + @PreAuthorize("@ss.hasPermi('base:variety:add')") + @Log(title = "羊只品种", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BasSheepVariety basSheepVariety) + { + return toAjax(basSheepVarietyService.insertBasSheepVariety(basSheepVariety)); + } + + /** + * 修改羊只品种 + */ + @PreAuthorize("@ss.hasPermi('base:variety:edit')") + @Log(title = "羊只品种", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BasSheepVariety basSheepVariety) + { + return toAjax(basSheepVarietyService.updateBasSheepVariety(basSheepVariety)); + } + + /** + * 删除羊只品种 + */ + @PreAuthorize("@ss.hasPermi('base:variety:remove')") + @Log(title = "羊只品种", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(basSheepVarietyService.deleteBasSheepVarietyByIds(ids)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/variety/domain/BasSheepVariety.java b/zhyc-module/src/main/java/com/zhyc/module/base/variety/domain/BasSheepVariety.java new file mode 100644 index 0000000..35a541a --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/base/variety/domain/BasSheepVariety.java @@ -0,0 +1,52 @@ +package com.zhyc.module.base.variety.domain; + +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; + +/** + * 羊只品种对象 bas_sheep_variety + * + * @author ruoyi + * @date 2025-07-15 + */ +public class BasSheepVariety extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 品种 */ + @Excel(name = "品种") + private String variety; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setVariety(String variety) + { + this.variety = variety; + } + + public String getVariety() + { + return variety; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("variety", getVariety()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/variety/mapper/BasSheepVarietyMapper.java b/zhyc-module/src/main/java/com/zhyc/module/base/variety/mapper/BasSheepVarietyMapper.java new file mode 100644 index 0000000..02927cb --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/base/variety/mapper/BasSheepVarietyMapper.java @@ -0,0 +1,61 @@ +package com.zhyc.module.base.variety.mapper; + +import java.util.List; +import com.zhyc.module.base.variety.domain.BasSheepVariety; + +/** + * 羊只品种Mapper接口 + * + * @author ruoyi + * @date 2025-07-15 + */ +public interface BasSheepVarietyMapper +{ + /** + * 查询羊只品种 + * + * @param id 羊只品种主键 + * @return 羊只品种 + */ + public BasSheepVariety selectBasSheepVarietyById(Long id); + + /** + * 查询羊只品种列表 + * + * @param basSheepVariety 羊只品种 + * @return 羊只品种集合 + */ + public List selectBasSheepVarietyList(BasSheepVariety basSheepVariety); + + /** + * 新增羊只品种 + * + * @param basSheepVariety 羊只品种 + * @return 结果 + */ + public int insertBasSheepVariety(BasSheepVariety basSheepVariety); + + /** + * 修改羊只品种 + * + * @param basSheepVariety 羊只品种 + * @return 结果 + */ + public int updateBasSheepVariety(BasSheepVariety basSheepVariety); + + /** + * 删除羊只品种 + * + * @param id 羊只品种主键 + * @return 结果 + */ + public int deleteBasSheepVarietyById(Long id); + + /** + * 批量删除羊只品种 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteBasSheepVarietyByIds(Long[] ids); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/variety/service/IBasSheepVarietyService.java b/zhyc-module/src/main/java/com/zhyc/module/base/variety/service/IBasSheepVarietyService.java new file mode 100644 index 0000000..f2fc713 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/base/variety/service/IBasSheepVarietyService.java @@ -0,0 +1,61 @@ +package com.zhyc.module.base.variety.service; + +import java.util.List; +import com.zhyc.module.base.variety.domain.BasSheepVariety; + +/** + * 羊只品种Service接口 + * + * @author ruoyi + * @date 2025-07-15 + */ +public interface IBasSheepVarietyService +{ + /** + * 查询羊只品种 + * + * @param id 羊只品种主键 + * @return 羊只品种 + */ + public BasSheepVariety selectBasSheepVarietyById(Long id); + + /** + * 查询羊只品种列表 + * + * @param basSheepVariety 羊只品种 + * @return 羊只品种集合 + */ + public List selectBasSheepVarietyList(BasSheepVariety basSheepVariety); + + /** + * 新增羊只品种 + * + * @param basSheepVariety 羊只品种 + * @return 结果 + */ + public int insertBasSheepVariety(BasSheepVariety basSheepVariety); + + /** + * 修改羊只品种 + * + * @param basSheepVariety 羊只品种 + * @return 结果 + */ + public int updateBasSheepVariety(BasSheepVariety basSheepVariety); + + /** + * 批量删除羊只品种 + * + * @param ids 需要删除的羊只品种主键集合 + * @return 结果 + */ + public int deleteBasSheepVarietyByIds(Long[] ids); + + /** + * 删除羊只品种信息 + * + * @param id 羊只品种主键 + * @return 结果 + */ + public int deleteBasSheepVarietyById(Long id); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/variety/service/impl/BasSheepVarietyServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/base/variety/service/impl/BasSheepVarietyServiceImpl.java new file mode 100644 index 0000000..beacc22 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/base/variety/service/impl/BasSheepVarietyServiceImpl.java @@ -0,0 +1,93 @@ +package com.zhyc.module.base.variety.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhyc.module.base.variety.mapper.BasSheepVarietyMapper; +import com.zhyc.module.base.variety.domain.BasSheepVariety; +import com.zhyc.module.base.variety.service.IBasSheepVarietyService; + +/** + * 羊只品种Service业务层处理 + * + * @author ruoyi + * @date 2025-07-15 + */ +@Service +public class BasSheepVarietyServiceImpl implements IBasSheepVarietyService +{ + @Autowired + private BasSheepVarietyMapper basSheepVarietyMapper; + + /** + * 查询羊只品种 + * + * @param id 羊只品种主键 + * @return 羊只品种 + */ + @Override + public BasSheepVariety selectBasSheepVarietyById(Long id) + { + return basSheepVarietyMapper.selectBasSheepVarietyById(id); + } + + /** + * 查询羊只品种列表 + * + * @param basSheepVariety 羊只品种 + * @return 羊只品种 + */ + @Override + public List selectBasSheepVarietyList(BasSheepVariety basSheepVariety) + { + return basSheepVarietyMapper.selectBasSheepVarietyList(basSheepVariety); + } + + /** + * 新增羊只品种 + * + * @param basSheepVariety 羊只品种 + * @return 结果 + */ + @Override + public int insertBasSheepVariety(BasSheepVariety basSheepVariety) + { + return basSheepVarietyMapper.insertBasSheepVariety(basSheepVariety); + } + + /** + * 修改羊只品种 + * + * @param basSheepVariety 羊只品种 + * @return 结果 + */ + @Override + public int updateBasSheepVariety(BasSheepVariety basSheepVariety) + { + return basSheepVarietyMapper.updateBasSheepVariety(basSheepVariety); + } + + /** + * 批量删除羊只品种 + * + * @param ids 需要删除的羊只品种主键 + * @return 结果 + */ + @Override + public int deleteBasSheepVarietyByIds(Long[] ids) + { + return basSheepVarietyMapper.deleteBasSheepVarietyByIds(ids); + } + + /** + * 删除羊只品种信息 + * + * @param id 羊只品种主键 + * @return 结果 + */ + @Override + public int deleteBasSheepVarietyById(Long id) + { + return basSheepVarietyMapper.deleteBasSheepVarietyById(id); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/controller/XzDryMatterCorrectionController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/controller/XzDryMatterCorrectionController.java similarity index 93% rename from zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/controller/XzDryMatterCorrectionController.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/controller/XzDryMatterCorrectionController.java index 8efc78e..d250d5c 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/controller/XzDryMatterCorrectionController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/controller/XzDryMatterCorrectionController.java @@ -1,4 +1,4 @@ -package com.zhyc.module.dryMatterCorrection.controller; +package com.zhyc.module.dairyProducts.dryMatterCorrection.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -16,8 +16,8 @@ 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.dryMatterCorrection.domain.XzDryMatterCorrection; -import com.zhyc.module.dryMatterCorrection.service.IXzDryMatterCorrectionService; +import com.zhyc.module.dairyProducts.dryMatterCorrection.domain.XzDryMatterCorrection; +import com.zhyc.module.dairyProducts.dryMatterCorrection.service.IXzDryMatterCorrectionService; import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.common.core.page.TableDataInfo; diff --git a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/domain/XzDryMatterCorrection.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/domain/XzDryMatterCorrection.java similarity index 96% rename from zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/domain/XzDryMatterCorrection.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/domain/XzDryMatterCorrection.java index 2bbb0d2..5ea4e82 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/domain/XzDryMatterCorrection.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/domain/XzDryMatterCorrection.java @@ -1,4 +1,4 @@ -package com.zhyc.module.dryMatterCorrection.domain; +package com.zhyc.module.dairyProducts.dryMatterCorrection.domain; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/mapper/XzDryMatterCorrectionMapper.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/mapper/XzDryMatterCorrectionMapper.java similarity index 90% rename from zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/mapper/XzDryMatterCorrectionMapper.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/mapper/XzDryMatterCorrectionMapper.java index 123db3c..8566be9 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/mapper/XzDryMatterCorrectionMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/mapper/XzDryMatterCorrectionMapper.java @@ -1,7 +1,7 @@ -package com.zhyc.module.dryMatterCorrection.mapper; +package com.zhyc.module.dairyProducts.dryMatterCorrection.mapper; import java.util.List; -import com.zhyc.module.dryMatterCorrection.domain.XzDryMatterCorrection; +import com.zhyc.module.dairyProducts.dryMatterCorrection.domain.XzDryMatterCorrection; /** * 干物质校正Mapper接口 diff --git a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/service/IXzDryMatterCorrectionService.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/service/IXzDryMatterCorrectionService.java similarity index 90% rename from zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/service/IXzDryMatterCorrectionService.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/service/IXzDryMatterCorrectionService.java index 06359a9..ce3a891 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/service/IXzDryMatterCorrectionService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/service/IXzDryMatterCorrectionService.java @@ -1,7 +1,7 @@ -package com.zhyc.module.dryMatterCorrection.service; +package com.zhyc.module.dairyProducts.dryMatterCorrection.service; import java.util.List; -import com.zhyc.module.dryMatterCorrection.domain.XzDryMatterCorrection; +import com.zhyc.module.dairyProducts.dryMatterCorrection.domain.XzDryMatterCorrection; /** * 干物质校正Service接口 diff --git a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/service/impl/XzDryMatterCorrectionServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/service/impl/XzDryMatterCorrectionServiceImpl.java similarity index 87% rename from zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/service/impl/XzDryMatterCorrectionServiceImpl.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/service/impl/XzDryMatterCorrectionServiceImpl.java index 948a2b6..dcf666f 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dryMatterCorrection/service/impl/XzDryMatterCorrectionServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/dryMatterCorrection/service/impl/XzDryMatterCorrectionServiceImpl.java @@ -1,11 +1,11 @@ -package com.zhyc.module.dryMatterCorrection.service.impl; +package com.zhyc.module.dairyProducts.dryMatterCorrection.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.zhyc.module.dryMatterCorrection.mapper.XzDryMatterCorrectionMapper; -import com.zhyc.module.dryMatterCorrection.domain.XzDryMatterCorrection; -import com.zhyc.module.dryMatterCorrection.service.IXzDryMatterCorrectionService; +import com.zhyc.module.dairyProducts.dryMatterCorrection.mapper.XzDryMatterCorrectionMapper; +import com.zhyc.module.dairyProducts.dryMatterCorrection.domain.XzDryMatterCorrection; +import com.zhyc.module.dairyProducts.dryMatterCorrection.service.IXzDryMatterCorrectionService; /** * 干物质校正Service业务层处理 diff --git a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/controller/XzParityCorrectionController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/controller/XzParityCorrectionController.java similarity index 94% rename from zhyc-module/src/main/java/com/zhyc/module/parityCorrection/controller/XzParityCorrectionController.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/controller/XzParityCorrectionController.java index fbecfc9..edc1fba 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/controller/XzParityCorrectionController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/controller/XzParityCorrectionController.java @@ -1,4 +1,4 @@ -package com.zhyc.module.parityCorrection.controller; +package com.zhyc.module.dairyProducts.parityCorrection.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -16,8 +16,8 @@ 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.parityCorrection.domain.XzParityCorrection; -import com.zhyc.module.parityCorrection.service.IXzParityCorrectionService; +import com.zhyc.module.dairyProducts.parityCorrection.domain.XzParityCorrection; +import com.zhyc.module.dairyProducts.parityCorrection.service.IXzParityCorrectionService; import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.common.core.page.TableDataInfo; diff --git a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/domain/XzParityCorrection.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/domain/XzParityCorrection.java similarity index 95% rename from zhyc-module/src/main/java/com/zhyc/module/parityCorrection/domain/XzParityCorrection.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/domain/XzParityCorrection.java index 107b070..3c9e098 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/domain/XzParityCorrection.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/domain/XzParityCorrection.java @@ -1,4 +1,4 @@ -package com.zhyc.module.parityCorrection.domain; +package com.zhyc.module.dairyProducts.parityCorrection.domain; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; diff --git a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/mapper/XzParityCorrectionMapper.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/mapper/XzParityCorrectionMapper.java similarity index 90% rename from zhyc-module/src/main/java/com/zhyc/module/parityCorrection/mapper/XzParityCorrectionMapper.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/mapper/XzParityCorrectionMapper.java index ff6a1b4..392ff04 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/mapper/XzParityCorrectionMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/mapper/XzParityCorrectionMapper.java @@ -1,7 +1,7 @@ -package com.zhyc.module.parityCorrection.mapper; +package com.zhyc.module.dairyProducts.parityCorrection.mapper; import java.util.List; -import com.zhyc.module.parityCorrection.domain.XzParityCorrection; +import com.zhyc.module.dairyProducts.parityCorrection.domain.XzParityCorrection; /** * 胎次校正Mapper接口 diff --git a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/service/IXzParityCorrectionService.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/service/IXzParityCorrectionService.java similarity index 90% rename from zhyc-module/src/main/java/com/zhyc/module/parityCorrection/service/IXzParityCorrectionService.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/service/IXzParityCorrectionService.java index 7845899..099dfa2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/service/IXzParityCorrectionService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/service/IXzParityCorrectionService.java @@ -1,7 +1,7 @@ -package com.zhyc.module.parityCorrection.service; +package com.zhyc.module.dairyProducts.parityCorrection.service; import java.util.List; -import com.zhyc.module.parityCorrection.domain.XzParityCorrection; +import com.zhyc.module.dairyProducts.parityCorrection.domain.XzParityCorrection; /** * 胎次校正Service接口 diff --git a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/service/impl/XzParityCorrectionServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/service/impl/XzParityCorrectionServiceImpl.java similarity index 87% rename from zhyc-module/src/main/java/com/zhyc/module/parityCorrection/service/impl/XzParityCorrectionServiceImpl.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/service/impl/XzParityCorrectionServiceImpl.java index 7f97f3f..ef55515 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/parityCorrection/service/impl/XzParityCorrectionServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/parityCorrection/service/impl/XzParityCorrectionServiceImpl.java @@ -1,11 +1,11 @@ -package com.zhyc.module.parityCorrection.service.impl; +package com.zhyc.module.dairyProducts.parityCorrection.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.zhyc.module.parityCorrection.mapper.XzParityCorrectionMapper; -import com.zhyc.module.parityCorrection.domain.XzParityCorrection; -import com.zhyc.module.parityCorrection.service.IXzParityCorrectionService; +import com.zhyc.module.dairyProducts.parityCorrection.mapper.XzParityCorrectionMapper; +import com.zhyc.module.dairyProducts.parityCorrection.domain.XzParityCorrection; +import com.zhyc.module.dairyProducts.parityCorrection.service.IXzParityCorrectionService; /** * 胎次校正Service业务层处理 diff --git a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/controller/XzWegihCorrectionController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/controller/XzWegihCorrectionController.java similarity index 94% rename from zhyc-module/src/main/java/com/zhyc/module/weightCorrection/controller/XzWegihCorrectionController.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/controller/XzWegihCorrectionController.java index ea692ab..36baa44 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/controller/XzWegihCorrectionController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/controller/XzWegihCorrectionController.java @@ -1,4 +1,4 @@ -package com.zhyc.module.weightCorrection.controller; +package com.zhyc.module.dairyProducts.weightCorrection.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -16,8 +16,8 @@ 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.weightCorrection.domain.XzWegihCorrection; -import com.zhyc.module.weightCorrection.service.IXzWegihCorrectionService; +import com.zhyc.module.dairyProducts.weightCorrection.domain.XzWegihCorrection; +import com.zhyc.module.dairyProducts.weightCorrection.service.IXzWegihCorrectionService; import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.common.core.page.TableDataInfo; diff --git a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/domain/XzWegihCorrection.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/domain/XzWegihCorrection.java similarity index 97% rename from zhyc-module/src/main/java/com/zhyc/module/weightCorrection/domain/XzWegihCorrection.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/domain/XzWegihCorrection.java index f3c3d6b..5a53ac8 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/domain/XzWegihCorrection.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/domain/XzWegihCorrection.java @@ -1,4 +1,4 @@ -package com.zhyc.module.weightCorrection.domain; +package com.zhyc.module.dairyProducts.weightCorrection.domain; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/mapper/XzWegihCorrectionMapper.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/mapper/XzWegihCorrectionMapper.java similarity index 90% rename from zhyc-module/src/main/java/com/zhyc/module/weightCorrection/mapper/XzWegihCorrectionMapper.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/mapper/XzWegihCorrectionMapper.java index 1b92971..2d1a65b 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/mapper/XzWegihCorrectionMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/mapper/XzWegihCorrectionMapper.java @@ -1,7 +1,7 @@ -package com.zhyc.module.weightCorrection.mapper; +package com.zhyc.module.dairyProducts.weightCorrection.mapper; import java.util.List; -import com.zhyc.module.weightCorrection.domain.XzWegihCorrection; +import com.zhyc.module.dairyProducts.weightCorrection.domain.XzWegihCorrection; /** * 称重校正Mapper接口 diff --git a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/service/IXzWegihCorrectionService.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/service/IXzWegihCorrectionService.java similarity index 90% rename from zhyc-module/src/main/java/com/zhyc/module/weightCorrection/service/IXzWegihCorrectionService.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/service/IXzWegihCorrectionService.java index 57c2144..04f070a 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/service/IXzWegihCorrectionService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/service/IXzWegihCorrectionService.java @@ -1,7 +1,7 @@ -package com.zhyc.module.weightCorrection.service; +package com.zhyc.module.dairyProducts.weightCorrection.service; import java.util.List; -import com.zhyc.module.weightCorrection.domain.XzWegihCorrection; +import com.zhyc.module.dairyProducts.weightCorrection.domain.XzWegihCorrection; /** * 称重校正Service接口 diff --git a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/service/impl/XzWegihCorrectionServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/service/impl/XzWegihCorrectionServiceImpl.java similarity index 87% rename from zhyc-module/src/main/java/com/zhyc/module/weightCorrection/service/impl/XzWegihCorrectionServiceImpl.java rename to zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/service/impl/XzWegihCorrectionServiceImpl.java index b69187a..a8c59fb 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/weightCorrection/service/impl/XzWegihCorrectionServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/weightCorrection/service/impl/XzWegihCorrectionServiceImpl.java @@ -1,11 +1,11 @@ -package com.zhyc.module.weightCorrection.service.impl; +package com.zhyc.module.dairyProducts.weightCorrection.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.zhyc.module.weightCorrection.mapper.XzWegihCorrectionMapper; -import com.zhyc.module.weightCorrection.domain.XzWegihCorrection; -import com.zhyc.module.weightCorrection.service.IXzWegihCorrectionService; +import com.zhyc.module.dairyProducts.weightCorrection.mapper.XzWegihCorrectionMapper; +import com.zhyc.module.dairyProducts.weightCorrection.domain.XzWegihCorrection; +import com.zhyc.module.dairyProducts.weightCorrection.service.IXzWegihCorrectionService; /** * 称重校正Service业务层处理 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 index 77bc4c0..04bce38 100644 --- 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 @@ -24,24 +24,20 @@ import com.zhyc.common.core.page.TableDataInfo; /** * 产羔记录Controller - * - * @author ruoyi - * @date 2025-07-11 */ @RestController @RequestMapping("/breed/lambing_records") -public class ScLambingRecordController extends BaseController -{ +public class ScLambingRecordController extends BaseController { + @Autowired private IScLambingRecordService scLambingRecordService; /** - * 查询产羔记录列表(包含关联信息) + * 查询产羔记录列表 */ @PreAuthorize("@ss.hasPermi('breed:lambing_records:list')") @GetMapping("/list") - public TableDataInfo list(ScLambingRecord scLambingRecord) - { + public TableDataInfo list(ScLambingRecord scLambingRecord) { startPage(); List list = scLambingRecordService.selectScLambingRecordList(scLambingRecord); return getDataTable(list); @@ -53,8 +49,7 @@ public class ScLambingRecordController extends BaseController @PreAuthorize("@ss.hasPermi('breed:lambing_records:export')") @Log(title = "产羔记录", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, ScLambingRecord scLambingRecord) - { + public void export(HttpServletResponse response, ScLambingRecord scLambingRecord) { List list = scLambingRecordService.selectScLambingRecordList(scLambingRecord); ExcelUtil util = new ExcelUtil(ScLambingRecord.class); util.exportExcel(response, list, "产羔记录数据"); @@ -65,41 +60,41 @@ public class ScLambingRecordController extends BaseController */ @PreAuthorize("@ss.hasPermi('breed:lambing_records:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long 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)); + public AjaxResult add(@RequestBody ScLambingRecord scLambingRecord) { + try { + // 设置创建人 + scLambingRecord.setCreateBy(getUsername()); + + // 如果没有设置创建时间,使用当前时间 + if (scLambingRecord.getCreateTime() == null) { + scLambingRecord.setCreateTime(new java.util.Date()); + } + + int result = scLambingRecordService.insertScLambingRecord(scLambingRecord); + + if (result > 0) { + String message = "新增产羔记录成功"; + if (scLambingRecord.getLambDetails() != null && !scLambingRecord.getLambDetails().isEmpty()) { + message += ",同时录入了 " + scLambingRecord.getLambDetails().size() + " 只羔羊详情"; + } + return success(message); + } else { + return error("新增产羔记录失败"); + } + } catch (Exception e) { + logger.error("新增产羔记录异常", e); + return error("新增产羔记录失败:" + e.getMessage()); + } } /** @@ -108,9 +103,15 @@ public class ScLambingRecordController extends BaseController @PreAuthorize("@ss.hasPermi('breed:lambing_records:edit')") @Log(title = "产羔记录", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody ScLambingRecord scLambingRecord) - { - return toAjax(scLambingRecordService.updateScLambingRecord(scLambingRecord)); + public AjaxResult edit(@RequestBody ScLambingRecord scLambingRecord) { + try { + scLambingRecord.setUpdateBy(getUsername()); + scLambingRecord.setUpdateTime(new java.util.Date()); + return toAjax(scLambingRecordService.updateScLambingRecord(scLambingRecord)); + } catch (Exception e) { + logger.error("修改产羔记录异常", e); + return error("修改产羔记录失败:" + e.getMessage()); + } } /** @@ -119,19 +120,27 @@ public class ScLambingRecordController extends BaseController @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)); + public AjaxResult remove(@PathVariable Long[] ids) { + try { + return toAjax(scLambingRecordService.deleteScLambingRecordByIds(ids)); + } catch (Exception e) { + logger.error("删除产羔记录异常", e); + return error("删除产羔记录失败:" + e.getMessage()); + } } /** - * 批量新增羔羊详情 + * 查询羔羊详情 */ - @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)); + @PreAuthorize("@ss.hasPermi('breed:lambing_records:query')") + @GetMapping("/lamb_detail/{lambingRecordId}") + public AjaxResult getLambDetail(@PathVariable("lambingRecordId") Long lambingRecordId) { + try { + List lambDetails = scLambingRecordService.selectLambDetailByLambingRecordId(lambingRecordId); + return success(lambDetails); + } catch (Exception e) { + logger.error("查询羔羊详情异常", e); + return error("查询羔羊详情失败:" + e.getMessage()); + } } } \ 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 index 27973a6..f2bcb3a 100644 --- 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 @@ -2,6 +2,8 @@ package com.zhyc.module.produce.breed.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; @@ -29,13 +31,13 @@ public class ScLambDetail extends BaseEntity @Excel(name = "羔羊耳号") private String lambEarNumber; - /** 羔羊品种 */ - @Excel(name = "羔羊品种") - private String lambBreed; + /** 羔羊品种ID */ + @Excel(name = "羔羊品种ID") + private Integer lambBreed; // 改为Integer类型,存储品种ID /** 性别 */ @Excel(name = "性别") - private String gender; + private Integer gender; /** 出生重量 */ @Excel(name = "出生重量") @@ -54,6 +56,23 @@ public class ScLambDetail extends BaseEntity @Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd") private Date birthday; + private List lambDetails; + + /** 母羊ID */ + private Long motherId; + + /** 父羊ID */ + private Long fatherId; + + /** 牧场ID */ + private Integer ranchId; + + /** 羊舍ID */ + private Integer sheepfoldId; + + /** 胎次 */ + private Integer parity; + // getter和setter方法 public void setId(Long id) { @@ -85,22 +104,22 @@ public class ScLambDetail extends BaseEntity return lambEarNumber; } - public void setLambBreed(String lambBreed) + public void setLambBreed(Integer lambBreed) // 改为Integer类型 { this.lambBreed = lambBreed; } - public String getLambBreed() + public Integer getLambBreed() // 改为Integer类型 { return lambBreed; } - public void setGender(String gender) + public void setGender(Integer gender) { this.gender = gender; } - public String getGender() + public Integer getGender() { return gender; } @@ -145,6 +164,66 @@ public class ScLambDetail extends BaseEntity return birthday; } + public List getLambDetails() + { + return lambDetails; + } + + public void setLambDetails(List lambDetails) + { + this.lambDetails = lambDetails; + } + + public Long getMotherId() + { + return motherId; + } + + public void setMotherId(Long motherId) + { + this.motherId = motherId; + } + + public Long getFatherId() + { + return fatherId; + } + + public void setFatherId(Long fatherId) + { + this.fatherId = fatherId; + } + + public Integer getRanchId() + { + return ranchId; + } + + public void setRanchId(Integer ranchId) + { + this.ranchId = ranchId; + } + + public Integer getSheepfoldId() + { + return sheepfoldId; + } + + public void setSheepfoldId(Integer sheepfoldId) + { + this.sheepfoldId = sheepfoldId; + } + + public Integer getParity() + { + return parity; + } + + public void setParity(Integer parity) + { + this.parity = parity; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -160,4 +239,4 @@ public class ScLambDetail extends BaseEntity .append("createTime", getCreateTime()) .toString(); } -} +} \ No newline at end of file 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 index 5aebf45..895ad55 100644 --- 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 @@ -50,9 +50,9 @@ public class ScLambingRecord extends BaseEntity private String comment; /** 创建日期 */ - @JsonFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd") - private Date createTme; + private Date createTime; // 改为 createTime // ========== 关联查询字段(简化版) ========== @@ -124,6 +124,8 @@ public class ScLambingRecord extends BaseEntity /** 羔羊信息列表(从羊只信息表查询) */ private List lambInfoList; + private List lambDetails; + // ========== 原有getter和setter方法 ========== public void setId(Long id) @@ -206,14 +208,14 @@ public class ScLambingRecord extends BaseEntity return comment; } - public void setCreateTme(Date createTme) + public void setCreateTime(Date createTime) { - this.createTme = createTme; + this.createTime = createTime; } - public Date getCreateTme() + public Date getCreateTime() { - return createTme; + return createTime; } // ========== 简化版关联字段的getter和setter方法 ========== @@ -282,6 +284,7 @@ public class ScLambingRecord extends BaseEntity this.maleBreed = maleBreed; } + public Integer getPregnancyDays() { return pregnancyDays; } @@ -354,6 +357,14 @@ public class ScLambingRecord extends BaseEntity this.lambInfoList = lambInfoList; } + public List getLambDetails() { + return lambDetails; + } + + public void setLambDetails(List lambDetails) { + this.lambDetails = lambDetails; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -366,7 +377,7 @@ public class ScLambingRecord extends BaseEntity .append("score", getScore()) .append("comment", getComment()) .append("createBy", getCreateBy()) - .append("createTme", getCreateTme()) + .append("createTime", getCreateTime()) // 改为 createTime .append("femaleEarNumber", getFemaleEarNumber()) .append("femaleBreed", getFemaleBreed()) .append("farm", getFarm()) @@ -380,7 +391,7 @@ public class ScLambingRecord extends BaseEntity class SheepLambInfo { private String lambEarNumber; // 羔羊耳号 private String lambBreed; // 羔羊品种 - private String gender; // 性别 + private Integer gender; // 性别 private Double birthWeight; // 出生重量 private Boolean isRetained; // 是否留养 private String lineage; // 家系 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 index c562ae2..2ba02de 100644 --- 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 @@ -2,84 +2,62 @@ package com.zhyc.module.produce.breed.mapper; import java.util.List; import com.zhyc.module.produce.breed.domain.ScLambDetail; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 羔羊详情Mapper接口 - * - * @author ruoyi - * @date 2025-07-11 */ -public interface ScLambDetailMapper -{ - /** - * 查询羔羊详情 - * - * @param id 羔羊详情主键 - * @return 羔羊详情 - */ - public ScLambDetail selectScLambDetailById(Long id); +@Mapper +public interface ScLambDetailMapper { /** * 查询羔羊详情列表 - * - * @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); - + public int insertBasSheep(ScLambDetail scLambDetail); /** * 批量新增羔羊详情 - * - * @param lambDetails 羔羊详情列表 - * @return 结果 */ - public int insertScLambDetailBatch(List lambDetails); - + public int insertScLambDetailBatch(@Param("list") List scLambDetailList); + public int insertBasSheepBatch(@Param("list") List scLambDetailList); /** * 修改羔羊详情 - * - * @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); + + /** + * 查询羔羊详情 + */ + public ScLambDetail selectScLambDetailById(Long id); + + /** + * 根据产羔记录ID查询羔羊详情列表 + */ + public List selectScLambDetailByLambingRecordId(Long lambingRecordId); + + /** + * 检查羔羊耳号是否已存在 + */ + public int checkLambEarNumberExists(@Param("lambEarNumber") String lambEarNumber, @Param("excludeId") Long excludeId); } \ 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 index 16338a9..83a6497 100644 --- 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 @@ -6,81 +6,41 @@ 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); +public interface IScLambingRecordService { /** - * 查询产羔记录列表(包含关联信息) - * - * @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); + public ScLambingRecord selectScLambingRecordById(Long id); /** - * 批量新增羔羊详情 - * - * @param lambDetails 羔羊详情列表 - * @return 结果 + * 查询羔羊详情 */ - public int insertLambDetailsBatch(List lambDetails); + public List selectLambDetailByLambingRecordId(Long lambingRecordId); } \ 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 index 2f0998a..74b6715 100644 --- 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 @@ -1,112 +1,192 @@ package com.zhyc.module.produce.breed.service.impl; +import java.math.BigDecimal; 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 org.springframework.transaction.annotation.Transactional; import com.zhyc.module.produce.breed.mapper.ScLambingRecordMapper; +import com.zhyc.module.produce.breed.mapper.ScLambDetailMapper; 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 java.util.Collections; /** * 产羔记录Service业务层处理 - * - * @author ruoyi - * @date 2025-07-11 */ @Service -public class ScLambingRecordServiceImpl implements IScLambingRecordService -{ +public class ScLambingRecordServiceImpl implements IScLambingRecordService { + @Autowired private ScLambingRecordMapper scLambingRecordMapper; - /** - * 查询产羔记录 - * - * @param id 产羔记录主键 - * @return 产羔记录 - */ - @Override - public ScLambingRecord selectScLambingRecordById(Long id) - { - return scLambingRecordMapper.selectScLambingRecordById(id); - } + @Autowired + private ScLambDetailMapper scLambDetailMapper; /** * 查询产羔记录列表 - * - * @param scLambingRecord 产羔记录 - * @return 产羔记录 */ @Override - public List selectScLambingRecordList(ScLambingRecord scLambingRecord) - { + public List selectScLambingRecordList(ScLambingRecord scLambingRecord) { return scLambingRecordMapper.selectScLambingRecordList(scLambingRecord); } + /** + * 新增产羔记录(包含羔羊详情) + */ @Override - public ScLambingRecord selectScLambingRecordDetailById(Long id) { - return null; + @Transactional + public int insertScLambingRecord(ScLambingRecord scLambingRecord) { + // 1. 插入产羔记录 + int result = scLambingRecordMapper.insertScLambingRecord(scLambingRecord); + + // 2. 如果有羔羊详情,则批量插入羔羊详情 + if (scLambingRecord.getLambDetails() != null && !scLambingRecord.getLambDetails().isEmpty()) { + insertLambDetails(scLambingRecord); + } + + return result; } /** - * 新增产羔记录 - * - * @param scLambingRecord 产羔记录 - * @return 结果 + * 批量插入羔羊详情 */ - @Override - public int insertScLambingRecord(ScLambingRecord scLambingRecord) - { - return scLambingRecordMapper.insertScLambingRecord(scLambingRecord); + private void insertLambDetails(ScLambingRecord scLambingRecord) { + // 遍历羔羊详情列表,逐个插入 + for (ScLambDetail lambDetail : scLambingRecord.getLambDetails()) { + // 设置产羔记录ID + lambDetail.setLambingRecordId(scLambingRecord.getId()); + + // 设置创建信息 + lambDetail.setCreateBy(scLambingRecord.getCreateBy()); + lambDetail.setCreateTime(scLambingRecord.getCreateTime()); + + // 数据验证和转换 + validateAndConvertLambDetail(lambDetail); + + // 插入羔羊详情 + scLambDetailMapper.insertScLambDetail(lambDetail); + scLambDetailMapper.insertBasSheep(lambDetail); + } + } + + + + /** + * 验证和转换羔羊详情 + */ + /** + * 验证和转换羔羊详情 + */ + private void validateAndConvertLambDetail(ScLambDetail lambDetail) { + // 验证必填字段 + if (lambDetail.getLambEarNumber() == null || lambDetail.getLambEarNumber().trim().isEmpty()) { + throw new RuntimeException("羔羊耳号不能为空"); + } + + if (lambDetail.getGender() == null) { // 改为检查Integer类型 + throw new RuntimeException("羔羊性别不能为空"); + } + + // 验证性别值的有效性(假设0=母羊,1=公羊) + if (lambDetail.getGender() < 0 || lambDetail.getGender() > 1) { + throw new RuntimeException("羔羊性别值无效,请使用0(母羊)或1(公羊)"); + } + + // 检查耳号是否已存在 + int count = scLambDetailMapper.checkLambEarNumberExists(lambDetail.getLambEarNumber().trim(), null); + if (count > 0) { + throw new RuntimeException("羔羊耳号 [" + lambDetail.getLambEarNumber() + "] 已存在,请使用其他耳号"); + } + + // 设置默认值 + if (lambDetail.getIsRetained() == null) { + lambDetail.setIsRetained(false); + } + + if (lambDetail.getBirthday() == null) { + lambDetail.setBirthday(new java.util.Date()); + } + + // 处理体重(前端可能传来的是number类型) + if (lambDetail.getBirthWeight() == null) { + lambDetail.setBirthWeight(BigDecimal.ZERO); + } + + // 验证品种ID + if (lambDetail.getLambBreed() == null) { + throw new RuntimeException("羔羊品种不能为空"); + } + + // 去除空格 + lambDetail.setLambEarNumber(lambDetail.getLambEarNumber().trim()); + if (lambDetail.getLineage() != null) { + lambDetail.setLineage(lambDetail.getLineage().trim()); + } } /** * 修改产羔记录 - * - * @param scLambingRecord 产羔记录 - * @return 结果 */ @Override - public int updateScLambingRecord(ScLambingRecord scLambingRecord) - { - return scLambingRecordMapper.updateScLambingRecord(scLambingRecord); + @Transactional + public int updateScLambingRecord(ScLambingRecord scLambingRecord) { + // 更新产羔记录 + int result = scLambingRecordMapper.updateScLambingRecord(scLambingRecord); + + // 如果包含羔羊详情,先删除原有的,再插入新的 + if (scLambingRecord.getLambDetails() != null) { + // 删除原有羔羊详情 + scLambDetailMapper.deleteScLambDetailByLambingRecordId(scLambingRecord.getId()); + + // 插入新的羔羊详情 + if (!scLambingRecord.getLambDetails().isEmpty()) { + insertLambDetails(scLambingRecord); + } + } + + return result; } /** * 批量删除产羔记录 - * - * @param ids 需要删除的产羔记录主键 - * @return 结果 */ @Override - public int deleteScLambingRecordByIds(Long[] ids) - { + @Transactional + public int deleteScLambingRecordByIds(Long[] ids) { + // 先删除关联的羔羊详情 + for (Long id : ids) { + scLambDetailMapper.deleteScLambDetailByLambingRecordId(id); + } + // 再删除产羔记录 return scLambingRecordMapper.deleteScLambingRecordByIds(ids); } /** * 删除产羔记录信息 - * - * @param id 产羔记录主键 - * @return 结果 */ @Override - public int deleteScLambingRecordById(Long id) - { + @Transactional + public int deleteScLambingRecordById(Long id) { + // 先删除关联的羔羊详情 + scLambDetailMapper.deleteScLambDetailByLambingRecordId(id); + // 再删除产羔记录 return scLambingRecordMapper.deleteScLambingRecordById(id); } + /** + * 查询产羔记录 + */ + @Override + public ScLambingRecord selectScLambingRecordById(Long id) { + return scLambingRecordMapper.selectScLambingRecordById(id); + } + /** + * 查询羔羊详情 + */ @Override public List selectLambDetailByLambingRecordId(Long lambingRecordId) { - return Collections.emptyList(); + return scLambDetailMapper.selectScLambDetailByLambingRecordId(lambingRecordId); } - - @Override - public int insertLambDetailsBatch(List lambDetails) { - return 0; - } -} +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/wean/controller/ScWeanRecordController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/controller/ScWeanRecordController.java new file mode 100644 index 0000000..79c05c5 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/controller/ScWeanRecordController.java @@ -0,0 +1,161 @@ +package com.zhyc.module.produce.wean.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.wean.domain.ScWeanRecord; +import com.zhyc.module.produce.wean.service.IScWeanRecordService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 断奶记录Controller + * + * @author zhyc + * @date 2024-01-01 + */ +@RestController +@RequestMapping("/Weaning/weaning_record") +public class ScWeanRecordController extends BaseController { + @Autowired + private IScWeanRecordService scWeanRecordService; + + /** + * 查询断奶记录列表 + */ + @PreAuthorize("@ss.hasPermi('Weaning:weaning_record:list')") + @GetMapping("/list") + public TableDataInfo list(ScWeanRecord scWeanRecord) { + startPage(); + List list = scWeanRecordService.selectScWeanRecordList(scWeanRecord); + return getDataTable(list); + } + + /** + * 导出断奶记录列表 + */ + @PreAuthorize("@ss.hasPermi('Weaning:weaning_record:export')") + @Log(title = "断奶记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ScWeanRecord scWeanRecord) { + List list = scWeanRecordService.selectScWeanRecordList(scWeanRecord); + ExcelUtil util = new ExcelUtil(ScWeanRecord.class); + util.exportExcel(response, list, "断奶记录数据"); + } + + /** + * 获取断奶记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('Weaning:weaning_record:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return success(scWeanRecordService.selectScWeanRecordById(id)); + } + + /** + * 根据耳号查询羊只ID + */ + @PreAuthorize("@ss.hasPermi('Weaning:weaning_record:query')") + @GetMapping(value = "/sheepId/{earNumber}") + public AjaxResult getSheepIdByEarNumber(@PathVariable("earNumber") String earNumber) { + Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(earNumber); + if (sheepId != null) { + return success(sheepId); + } else { + return error("未找到对应的羊只信息"); + } + } + + /** + * 新增断奶记录 + */ + @PreAuthorize("@ss.hasPermi('Weaning:weaning_record:add')") + @Log(title = "断奶记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ScWeanRecord scWeanRecord) { + // 验证耳号是否存在 + if (scWeanRecord.getEarNumber() != null) { + Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(scWeanRecord.getEarNumber()); + if (sheepId == null) { + return error("耳号不存在,请检查后重新输入"); + } + scWeanRecord.setSheepId(sheepId); + } + + // 验证必要字段 + if (scWeanRecord.getSheepId() == null) { + return error("羊只信息不能为空"); + } + if (scWeanRecord.getDatetime() == null) { + return error("断奶日期不能为空"); + } + if (scWeanRecord.getWeight() == null) { + return error("断奶重量不能为空"); + } + if (scWeanRecord.getStatus() == null) { + return error("是否留养不能为空"); + } + + scWeanRecord.setCreateBy(getUsername()); + return toAjax(scWeanRecordService.insertScWeanRecord(scWeanRecord)); + } + + /** + * 修改断奶记录 + */ + @PreAuthorize("@ss.hasPermi('Weaning:weaning_record:edit')") + @Log(title = "断奶记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ScWeanRecord scWeanRecord) { + // 验证耳号是否存在 + if (scWeanRecord.getEarNumber() != null) { + Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(scWeanRecord.getEarNumber()); + if (sheepId == null) { + return error("耳号不存在,请检查后重新输入"); + } + scWeanRecord.setSheepId(sheepId); + } + + // 验证必要字段 + if (scWeanRecord.getId() == null) { + return error("记录ID不能为空"); + } + if (scWeanRecord.getSheepId() == null) { + return error("羊只信息不能为空"); + } + if (scWeanRecord.getDatetime() == null) { + return error("断奶日期不能为空"); + } + if (scWeanRecord.getWeight() == null) { + return error("断奶重量不能为空"); + } + if (scWeanRecord.getStatus() == null) { + return error("是否留养不能为空"); + } + + return toAjax(scWeanRecordService.updateScWeanRecord(scWeanRecord)); + } + + /** + * 删除断奶记录 + */ + @PreAuthorize("@ss.hasPermi('Weaning:weaning_record:remove')") + @Log(title = "断奶记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(scWeanRecordService.deleteScWeanRecordByIds(ids)); + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/wean/domain/ScWeanRecord.java b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/domain/ScWeanRecord.java new file mode 100644 index 0000000..1d11f7d --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/domain/ScWeanRecord.java @@ -0,0 +1,262 @@ +package com.zhyc.module.produce.wean.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 断奶记录对象 sc_wean_record + * + * @author zhyc + * @date 2024-01-01 + */ +public class ScWeanRecord extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private Long id; + + /** 羊只ID */ + @Excel(name = "羊只ID") + private Long sheepId; + + /** 断奶日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "断奶日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date datetime; + + /** 断奶重量 */ + @Excel(name = "断奶重量") + private BigDecimal weight; + + /** 是否留养 */ + @Excel(name = "是否留养") + private String status; + + /** 技术员 */ + @Excel(name = "技术员") + private String technician; + + /** 备注 */ + @Excel(name = "备注") + private String comment; + + /** 电子耳号 */ + @Excel(name = "电子耳号") + private String electronicTags; + + // 关联查询字段 + /** 耳号 */ + @Excel(name = "耳号") + private String earNumber; + + /** 品种 */ + @Excel(name = "品种") + private String breed; + + /** 事件类型 */ + @Excel(name = "事件类型") + private String eventType; + + /** 性别 */ + @Excel(name = "性别") + private String gender; + + /** 父号 */ + @Excel(name = "父号") + private String fatherNumber; + + /** 母号 */ + @Excel(name = "母号") + private String motherNumber; + + /** 月龄 */ + @Excel(name = "月龄") + private Integer monthAge; + + /** 出生重量 */ + @Excel(name = "出生重量") + private BigDecimal birthWeight; + + /** 羊舍 */ + @Excel(name = "羊舍") + private String sheepPen; + + /** 繁育状态 */ + @Excel(name = "繁育状态") + private String breedingStatus; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setSheepId(Long sheepId) { + this.sheepId = sheepId; + } + + public Long getSheepId() { + return sheepId; + } + + public void setDatetime(Date datetime) { + this.datetime = datetime; + } + + public Date getDatetime() { + return datetime; + } + + public void setWeight(BigDecimal weight) { + this.weight = weight; + } + + public BigDecimal getWeight() { + return weight; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return status; + } + + public void setTechnician(String technician) { + this.technician = technician; + } + + public String getTechnician() { + return technician; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getComment() { + return comment; + } + + public void setElectronicTags(String electronicTags) { + this.electronicTags = electronicTags; + } + + public String getElectronicTags() { + return electronicTags; + } + + public void setEarNumber(String earNumber) { + this.earNumber = earNumber; + } + + public String getEarNumber() { + return earNumber; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + public String getBreed() { + return breed; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getEventType() { + return eventType; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public String getGender() { + return gender; + } + + public void setFatherNumber(String fatherNumber) { + this.fatherNumber = fatherNumber; + } + + public String getFatherNumber() { + return fatherNumber; + } + + public void setMotherNumber(String motherNumber) { + this.motherNumber = motherNumber; + } + + public String getMotherNumber() { + return motherNumber; + } + + public void setMonthAge(Integer monthAge) { + this.monthAge = monthAge; + } + + public Integer getMonthAge() { + return monthAge; + } + + public void setBirthWeight(BigDecimal birthWeight) { + this.birthWeight = birthWeight; + } + + public BigDecimal getBirthWeight() { + return birthWeight; + } + + public void setSheepPen(String sheepPen) { + this.sheepPen = sheepPen; + } + + public String getSheepPen() { + return sheepPen; + } + + public void setBreedingStatus(String breedingStatus) { + this.breedingStatus = breedingStatus; + } + + public String getBreedingStatus() { + return breedingStatus; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("sheepId", getSheepId()) + .append("datetime", getDatetime()) + .append("weight", getWeight()) + .append("status", getStatus()) + .append("technician", getTechnician()) + .append("comment", getComment()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("electronicTags", getElectronicTags()) + .append("earNumber", getEarNumber()) + .append("breed", getBreed()) + .append("eventType", getEventType()) + .append("gender", getGender()) + .append("fatherNumber", getFatherNumber()) + .append("motherNumber", getMotherNumber()) + .append("monthAge", getMonthAge()) + .append("birthWeight", getBirthWeight()) + .append("sheepPen", getSheepPen()) + .append("breedingStatus", getBreedingStatus()) + .toString(); + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/wean/mapper/ScWeanRecordMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/mapper/ScWeanRecordMapper.java new file mode 100644 index 0000000..b8b5d5e --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/mapper/ScWeanRecordMapper.java @@ -0,0 +1,68 @@ +package com.zhyc.module.produce.wean.mapper; + +import java.util.List; +import com.zhyc.module.produce.wean.domain.ScWeanRecord; + +/** + * 断奶记录Mapper接口 + * + * @author zhyc + * @date 2024-01-01 + */ +public interface ScWeanRecordMapper { + /** + * 查询断奶记录 + * + * @param id 断奶记录主键 + * @return 断奶记录 + */ + public ScWeanRecord selectScWeanRecordById(Long id); + + /** + * 查询断奶记录列表 + * + * @param scWeanRecord 断奶记录 + * @return 断奶记录集合 + */ + public List selectScWeanRecordList(ScWeanRecord scWeanRecord); + + /** + * 新增断奶记录 + * + * @param scWeanRecord 断奶记录 + * @return 结果 + */ + public int insertScWeanRecord(ScWeanRecord scWeanRecord); + + /** + * 修改断奶记录 + * + * @param scWeanRecord 断奶记录 + * @return 结果 + */ + public int updateScWeanRecord(ScWeanRecord scWeanRecord); + + /** + * 删除断奶记录 + * + * @param id 断奶记录主键 + * @return 结果 + */ + public int deleteScWeanRecordById(Long id); + + /** + * 批量删除断奶记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteScWeanRecordByIds(Long[] ids); + + /** + * 根据耳号查询羊只ID + * + * @param earNumber 耳号 + * @return 羊只ID + */ + public Long selectSheepIdByEarNumber(String earNumber); +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/wean/service/IScWeanRecordService.java b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/service/IScWeanRecordService.java new file mode 100644 index 0000000..9926de0 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/service/IScWeanRecordService.java @@ -0,0 +1,68 @@ +package com.zhyc.module.produce.wean.service; + +import java.util.List; +import com.zhyc.module.produce.wean.domain.ScWeanRecord; + +/** + * 断奶记录Service接口 + * + * @author ruoyi + * @date 2025-07-13 + */ +public interface IScWeanRecordService { + /** + * 查询断奶记录 + * + * @param id 断奶记录主键 + * @return 断奶记录 + */ + public ScWeanRecord selectScWeanRecordById(Long id); + + /** + * 查询断奶记录列表 + * + * @param scWeanRecord 断奶记录 + * @return 断奶记录集合 + */ + public List selectScWeanRecordList(ScWeanRecord scWeanRecord); + + /** + * 新增断奶记录 + * + * @param scWeanRecord 断奶记录 + * @return 结果 + */ + public int insertScWeanRecord(ScWeanRecord scWeanRecord); + + /** + * 修改断奶记录 + * + * @param scWeanRecord 断奶记录 + * @return 结果 + */ + public int updateScWeanRecord(ScWeanRecord scWeanRecord); + + /** + * 批量删除断奶记录 + * + * @param ids 需要删除的断奶记录主键集合 + * @return 结果 + */ + public int deleteScWeanRecordByIds(Long[] ids); + + /** + * 删除断奶记录信息 + * + * @param id 断奶记录主键 + * @return 结果 + */ + public int deleteScWeanRecordById(Long id); + + /** + * 根据耳号查询羊只ID + * + * @param earNumber 耳号 + * @return 羊只ID + */ + public Long selectSheepIdByEarNumber(String earNumber); +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/wean/service/impl/ScWeanRecordServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/service/impl/ScWeanRecordServiceImpl.java new file mode 100644 index 0000000..2bc63c2 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/wean/service/impl/ScWeanRecordServiceImpl.java @@ -0,0 +1,113 @@ +package com.zhyc.module.produce.wean.service.impl; + +import java.util.List; +import com.zhyc.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhyc.module.produce.wean.mapper.ScWeanRecordMapper; +import com.zhyc.module.produce.wean.domain.ScWeanRecord; +import com.zhyc.module.produce.wean.service.IScWeanRecordService; + +/** + * 断奶记录Service业务层处理 + * + * @author ruoyi + * @date 2025-07-13 + */ +@Service +public class ScWeanRecordServiceImpl implements IScWeanRecordService { + @Autowired + private ScWeanRecordMapper scWeanRecordMapper; + + /** + * 查询断奶记录 + * + * @param id 断奶记录主键 + * @return 断奶记录 + */ + @Override + public ScWeanRecord selectScWeanRecordById(Long id) { + return scWeanRecordMapper.selectScWeanRecordById(id); + } + + /** + * 查询断奶记录列表 + * + * @param scWeanRecord 断奶记录 + * @return 断奶记录 + */ + @Override + public List selectScWeanRecordList(ScWeanRecord scWeanRecord) { + return scWeanRecordMapper.selectScWeanRecordList(scWeanRecord); + } + + /** + * 新增断奶记录 + * + * @param scWeanRecord 断奶记录 + * @return 结果 + */ + @Override + public int insertScWeanRecord(ScWeanRecord scWeanRecord) { + // 如果前端传递的是耳号,需要先获取羊只ID + if (scWeanRecord.getEarNumber() != null && scWeanRecord.getSheepId() == null) { + Long sheepId = scWeanRecordMapper.selectSheepIdByEarNumber(scWeanRecord.getEarNumber()); + if (sheepId != null) { + scWeanRecord.setSheepId(sheepId); + } + } + scWeanRecord.setCreateTime(DateUtils.getNowDate()); + return scWeanRecordMapper.insertScWeanRecord(scWeanRecord); + } + + /** + * 修改断奶记录 + * + * @param scWeanRecord 断奶记录 + * @return 结果 + */ + @Override + public int updateScWeanRecord(ScWeanRecord scWeanRecord) { + // 如果前端传递的是耳号,需要先获取羊只ID + if (scWeanRecord.getEarNumber() != null && scWeanRecord.getSheepId() == null) { + Long sheepId = scWeanRecordMapper.selectSheepIdByEarNumber(scWeanRecord.getEarNumber()); + if (sheepId != null) { + scWeanRecord.setSheepId(sheepId); + } + } + return scWeanRecordMapper.updateScWeanRecord(scWeanRecord); + } + + /** + * 批量删除断奶记录 + * + * @param ids 需要删除的断奶记录主键 + * @return 结果 + */ + @Override + public int deleteScWeanRecordByIds(Long[] ids) { + return scWeanRecordMapper.deleteScWeanRecordByIds(ids); + } + + /** + * 删除断奶记录信息 + * + * @param id 断奶记录主键 + * @return 结果 + */ + @Override + public int deleteScWeanRecordById(Long id) { + return scWeanRecordMapper.deleteScWeanRecordById(id); + } + + /** + * 根据耳号查询羊只ID + * + * @param earNumber 耳号 + * @return 羊只ID + */ + @Override + public Long selectSheepIdByEarNumber(String earNumber) { + return scWeanRecordMapper.selectSheepIdByEarNumber(earNumber); + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/Weaning/ScWeanRecordMapper.xml b/zhyc-module/src/main/resources/mapper/Weaning/ScWeanRecordMapper.xml new file mode 100644 index 0000000..a5cdc3b --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/Weaning/ScWeanRecordMapper.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + wr.id, wr.sheep_id, wr.datetime, wr.weight, wr.status, wr.technician, + wr.comment, wr.create_by, wr.create_time, wr.electronic_tags, + sf.bs_manage_tags, sf.variety, sf.gender, sf.father_manage_tags, sf.mother_manage_tags, + sf.birth_weight, sf.sheepfold_name, sf.breed, sf.month_age, + '断奶' as event_type + from sc_wean_record wr + left join sheep_file sf on wr.sheep_id = sf.id + + + + + + + + + + + + + + insert into sc_wean_record + + sheep_id, + datetime, + weight, + status, + technician, + comment, + create_by, + create_time, + electronic_tags, + + + #{sheepId}, + #{datetime}, + #{weight}, + #{status}, + #{technician}, + #{comment}, + #{createBy}, + #{createTime}, + #{electronicTags}, + + + + + + update sc_wean_record + + sheep_id = #{sheepId}, + datetime = #{datetime}, + weight = #{weight}, + status = #{status}, + technician = #{technician}, + comment = #{comment}, + create_by = #{createBy}, + create_time = #{createTime}, + electronic_tags = #{electronicTags}, + + where id = #{id} + + + + + delete from sc_wean_record where id = #{id} + + + + + delete from sc_wean_record where id in + + #{id} + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/breed/ScLambDetailMapper.xml b/zhyc-module/src/main/resources/mapper/breed/ScLambDetailMapper.xml new file mode 100644 index 0000000..c94b857 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/breed/ScLambDetailMapper.xml @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + select id, lambing_record_id, lamb_ear_number, lamb_breed, gender, birth_weight, + is_retained, lineage, birthday, create_by, create_time, update_by, update_time + from sc_lamb_detail + + + + + + + + + + + + + + + + + + insert into sc_lamb_detail + + lambing_record_id, + lamb_ear_number, + lamb_breed, + gender, + birth_weight, + is_retained, + lineage, + birthday, + create_by, + create_time, + + + #{lambingRecordId}, + #{lambEarNumber}, + #{lambBreed}, + #{gender}, + #{birthWeight}, + #{isRetained}, + #{lineage}, + #{birthday}, + #{createBy}, + #{createTime}, + + + + + + insert into bas_sheep + + manage_tags, + variety_id, + gender, + birthday, + birth_weight, + family, + mother_id, + father_id, + ranch_id, + sheepfold_id, + parity, + status_id, + type_id, + breed_status_id, + is_delete, + create_by, + create_time, + + + #{lambEarNumber}, + #{lambBreed}, + #{gender}, + #{birthday}, + #{birthWeight}, + #{lineage}, + #{motherId}, + #{fatherId}, + #{ranchId}, + #{sheepfoldId}, + #{parity}, + #{isRetained}, + 3, + 1, + 0, + #{createBy}, + #{createTime}, + + + + + + + insert into sc_lamb_detail (lambing_record_id, lamb_ear_number, lamb_breed, gender, birth_weight, + is_retained, lineage, birthday, create_by, create_time) + values + + (#{item.lambingRecordId}, #{item.lambEarNumber}, #{item.lambBreed}, #{item.gender}, + #{item.birthWeight}, #{item.isRetained}, #{item.lineage}, #{item.birthday}, + #{item.createBy}, #{item.createTime}) + + + + + + insert into bas_sheep (manage_tags, variety_id, gender, birthday, birth_weight, family, + mother_id, father_id, ranch_id, sheepfold_id, parity, status_id, type_id, breed_status_id, is_delete, create_by, create_time) + values + + (#{item.lambEarNumber}, #{item.lambBreed}, #{item.gender}, #{item.birthday}, + #{item.birthWeight}, #{item.lineage}, #{item.motherId}, #{item.fatherId}, + #{item.ranchId}, #{item.sheepfoldId}, #{item.parity}, #{item.isRetained}, + 3, 1, 0, #{item.createBy}, #{item.createTime}) + + + + + + update sc_lamb_detail + + lambing_record_id = #{lambingRecordId}, + lamb_ear_number = #{lambEarNumber}, + lamb_breed = #{lambBreed}, + gender = #{gender}, + birth_weight = #{birthWeight}, + is_retained = #{isRetained}, + lineage = #{lineage}, + birthday = #{birthday}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + + update bas_sheep + + manage_tags = #{lambEarNumber}, + variety_id = #{lambBreed}, + gender = #{gender}, + birthday = #{birthday}, + birth_weight = #{birthWeight}, + family = #{lineage}, + status_id = #{isRetained}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where manage_tags = #{lambEarNumber} and is_delete = 0 + + + + + delete from sc_lamb_detail where id = #{id} + + + + + update bas_sheep set is_delete = 1 where manage_tags = #{lambEarNumber} + + + + + delete from sc_lamb_detail where id in + + #{id} + + + + + + update bas_sheep set is_delete = 1 where manage_tags in + + #{earNumber} + + + + + + delete from sc_lamb_detail where lambing_record_id = #{lambingRecordId} + + + + + update bas_sheep set is_delete = 1 + where manage_tags in ( + select lamb_ear_number from sc_lamb_detail + where lambing_record_id = #{lambingRecordId} + ) + + + + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/breed/ScLambingRecordMapper.xml b/zhyc-module/src/main/resources/mapper/breed/ScLambingRecordMapper.xml index ed000d9..937834b 100644 --- a/zhyc-module/src/main/resources/mapper/breed/ScLambingRecordMapper.xml +++ b/zhyc-module/src/main/resources/mapper/breed/ScLambingRecordMapper.xml @@ -15,7 +15,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -110,7 +110,7 @@ and lr.score = #{score} and lr.comment LIKE CONCAT('%', #{comment}, '%') and lr.create_by = #{createBy} - and DATE(lr.create_tme) = #{createTme} + and DATE(lr.create_tme) = #{createTime} and DATE(br.create_time) >= #{params.beginBreedingDate} @@ -134,27 +134,23 @@ where lr.id = #{id} and mother.is_delete = 0 - - 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 + id, + lambing_record_id as lambingRecordId, + lamb_ear_number as lambEarNumber, + lamb_breed as lambBreed, + gender, + birth_weight as birthWeight, + is_retained as isRetained, + lineage, + birthday, + create_by as createBy, + create_time as createTime + FROM sc_lamb_detail + WHERE lambing_record_id = #{lambingRecordId} + ORDER BY create_time ASC @@ -169,7 +165,7 @@ score, comment, create_by, - create_tme, + create_tme, #{sheepId}, @@ -180,7 +176,7 @@ #{score}, #{comment}, #{createBy}, - #{createTme}, + #{createTime}, @@ -196,7 +192,7 @@ score = #{score}, comment = #{comment}, create_by = #{createBy}, - create_tme = #{createTme}, + create_tme = #{createTime}, where id = #{id} diff --git a/zhyc-module/src/main/resources/mapper/dryMatterCorrection/XzDryMatterCorrectionMapper.xml b/zhyc-module/src/main/resources/mapper/dairyProducts/dryMatterCorrection/XzDryMatterCorrectionMapper.xml similarity index 96% rename from zhyc-module/src/main/resources/mapper/dryMatterCorrection/XzDryMatterCorrectionMapper.xml rename to zhyc-module/src/main/resources/mapper/dairyProducts/dryMatterCorrection/XzDryMatterCorrectionMapper.xml index 0e4e33c..4099d6e 100644 --- a/zhyc-module/src/main/resources/mapper/dryMatterCorrection/XzDryMatterCorrectionMapper.xml +++ b/zhyc-module/src/main/resources/mapper/dairyProducts/dryMatterCorrection/XzDryMatterCorrectionMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/zhyc-module/src/main/resources/mapper/parityCorrection/XzParityCorrectionMapper.xml b/zhyc-module/src/main/resources/mapper/dairyProducts/parityCorrection/XzParityCorrectionMapper.xml similarity index 95% rename from zhyc-module/src/main/resources/mapper/parityCorrection/XzParityCorrectionMapper.xml rename to zhyc-module/src/main/resources/mapper/dairyProducts/parityCorrection/XzParityCorrectionMapper.xml index 217cd7d..3e76551 100644 --- a/zhyc-module/src/main/resources/mapper/parityCorrection/XzParityCorrectionMapper.xml +++ b/zhyc-module/src/main/resources/mapper/dairyProducts/parityCorrection/XzParityCorrectionMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/zhyc-module/src/main/resources/mapper/weightCorrection/XzWegihCorrectionMapper.xml b/zhyc-module/src/main/resources/mapper/dairyProducts/weightCorrection/XzWegihCorrectionMapper.xml similarity index 97% rename from zhyc-module/src/main/resources/mapper/weightCorrection/XzWegihCorrectionMapper.xml rename to zhyc-module/src/main/resources/mapper/dairyProducts/weightCorrection/XzWegihCorrectionMapper.xml index 6c19408..38696ad 100644 --- a/zhyc-module/src/main/resources/mapper/weightCorrection/XzWegihCorrectionMapper.xml +++ b/zhyc-module/src/main/resources/mapper/dairyProducts/weightCorrection/XzWegihCorrectionMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/zhyc-module/src/main/resources/mapper/variety/BasSheepVarietyMapper.xml b/zhyc-module/src/main/resources/mapper/variety/BasSheepVarietyMapper.xml new file mode 100644 index 0000000..dcc97fc --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/variety/BasSheepVarietyMapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + select id, variety from bas_sheep_variety + + + + + + + + insert into bas_sheep_variety + + variety, + + + #{variety}, + + + + + update bas_sheep_variety + + variety = #{variety}, + + where id = #{id} + + + + delete from bas_sheep_variety where id = #{id} + + + + delete from bas_sheep_variety where id in + + #{id} + + + \ No newline at end of file