From 1898417264982e1d09a7837254101199d09869ef Mon Sep 17 00:00:00 2001 From: HashMap Date: Sat, 2 Aug 2025 00:14:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(module=20mapper):=20=E6=B3=A8=E5=86=8C?= =?UTF-8?q?"=E9=A5=B2=E5=96=82=E7=AE=A1=E7=90=86"=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 注册饲喂管理组件源码及其Mapper --- .../controller/SgFeedDetailsController.java | 104 ++++++++ .../feed/controller/SgFeedInfoController.java | 104 ++++++++ .../controller/SgFeedRatioController.java | 104 ++++++++ .../feed/controller/SgFodderController.java | 104 ++++++++ .../module/feed/domain/SgFeedDetails.java | 82 ++++++ .../zhyc/module/feed/domain/SgFeedInfo.java | 252 ++++++++++++++++++ .../zhyc/module/feed/domain/SgFeedRatio.java | 82 ++++++ .../com/zhyc/module/feed/domain/SgFodder.java | 67 +++++ .../feed/mapper/SgFeedDetailsMapper.java | 61 +++++ .../module/feed/mapper/SgFeedInfoMapper.java | 61 +++++ .../module/feed/mapper/SgFeedRatioMapper.java | 61 +++++ .../module/feed/mapper/SgFodderMapper.java | 61 +++++ .../feed/service/ISgFeedDetailsService.java | 61 +++++ .../feed/service/ISgFeedInfoService.java | 61 +++++ .../feed/service/ISgFeedRatioService.java | 61 +++++ .../module/feed/service/ISgFodderService.java | 61 +++++ .../impl/SgFeedDetailsServiceImpl.java | 93 +++++++ .../service/impl/SgFeedInfoServiceImpl.java | 95 +++++++ .../service/impl/SgFeedRatioServiceImpl.java | 93 +++++++ .../service/impl/SgFodderServiceImpl.java | 93 +++++++ .../mapper/feed/SgFeedDetailsMapper.xml | 66 +++++ .../mapper/feed/SgFeedInfoMapper.xml | 129 +++++++++ .../mapper/feed/SgFeedRatioMapper.xml | 66 +++++ .../resources/mapper/feed/SgFodderMapper.xml | 61 +++++ 24 files changed, 2083 insertions(+) create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedDetailsController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedInfoController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedRatioController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFodderController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedDetails.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedInfo.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedRatio.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFodder.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedDetailsMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedInfoMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedRatioMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFodderMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedDetailsService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedInfoService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedRatioService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFodderService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedDetailsServiceImpl.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedInfoServiceImpl.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedRatioServiceImpl.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFodderServiceImpl.java create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgFeedDetailsMapper.xml create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgFeedInfoMapper.xml create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgFeedRatioMapper.xml create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgFodderMapper.xml diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedDetailsController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedDetailsController.java new file mode 100644 index 0000000..9ef4f87 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedDetailsController.java @@ -0,0 +1,104 @@ +package com.zhyc.module.feed.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.feed.domain.SgFeedDetails; +import com.zhyc.module.feed.service.ISgFeedDetailsService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 饲喂记录详情Controller + * + * @author ruoyi + * @date 2025-08-01 + */ +@RestController +@RequestMapping("/feed/details") +public class SgFeedDetailsController extends BaseController +{ + @Autowired + private ISgFeedDetailsService sgFeedDetailsService; + + /** + * 查询饲喂记录详情列表 + */ + @PreAuthorize("@ss.hasPermi('feed:details:list')") + @GetMapping("/list") + public TableDataInfo list(SgFeedDetails sgFeedDetails) + { + startPage(); + List list = sgFeedDetailsService.selectSgFeedDetailsList(sgFeedDetails); + return getDataTable(list); + } + + /** + * 导出饲喂记录详情列表 + */ + @PreAuthorize("@ss.hasPermi('feed:details:export')") + @Log(title = "饲喂记录详情", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SgFeedDetails sgFeedDetails) + { + List list = sgFeedDetailsService.selectSgFeedDetailsList(sgFeedDetails); + ExcelUtil util = new ExcelUtil(SgFeedDetails.class); + util.exportExcel(response, list, "饲喂记录详情数据"); + } + + /** + * 获取饲喂记录详情详细信息 + */ + @PreAuthorize("@ss.hasPermi('feed:details:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(sgFeedDetailsService.selectSgFeedDetailsById(id)); + } + + /** + * 新增饲喂记录详情 + */ + @PreAuthorize("@ss.hasPermi('feed:details:add')") + @Log(title = "饲喂记录详情", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SgFeedDetails sgFeedDetails) + { + return toAjax(sgFeedDetailsService.insertSgFeedDetails(sgFeedDetails)); + } + + /** + * 修改饲喂记录详情 + */ + @PreAuthorize("@ss.hasPermi('feed:details:edit')") + @Log(title = "饲喂记录详情", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SgFeedDetails sgFeedDetails) + { + return toAjax(sgFeedDetailsService.updateSgFeedDetails(sgFeedDetails)); + } + + /** + * 删除饲喂记录详情 + */ + @PreAuthorize("@ss.hasPermi('feed:details:remove')") + @Log(title = "饲喂记录详情", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sgFeedDetailsService.deleteSgFeedDetailsByIds(ids)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedInfoController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedInfoController.java new file mode 100644 index 0000000..8673f0c --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedInfoController.java @@ -0,0 +1,104 @@ +package com.zhyc.module.feed.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.feed.domain.SgFeedInfo; +import com.zhyc.module.feed.service.ISgFeedInfoService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 饲喂记录Controller + * + * @author ruoyi + * @date 2025-08-01 + */ +@RestController +@RequestMapping("/feed/info") +public class SgFeedInfoController extends BaseController +{ + @Autowired + private ISgFeedInfoService sgFeedInfoService; + + /** + * 查询饲喂记录列表 + */ + @PreAuthorize("@ss.hasPermi('feed:info:list')") + @GetMapping("/list") + public TableDataInfo list(SgFeedInfo sgFeedInfo) + { + startPage(); + List list = sgFeedInfoService.selectSgFeedInfoList(sgFeedInfo); + return getDataTable(list); + } + + /** + * 导出饲喂记录列表 + */ + @PreAuthorize("@ss.hasPermi('feed:info:export')") + @Log(title = "饲喂记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SgFeedInfo sgFeedInfo) + { + List list = sgFeedInfoService.selectSgFeedInfoList(sgFeedInfo); + ExcelUtil util = new ExcelUtil(SgFeedInfo.class); + util.exportExcel(response, list, "饲喂记录数据"); + } + + /** + * 获取饲喂记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('feed:info:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(sgFeedInfoService.selectSgFeedInfoById(id)); + } + + /** + * 新增饲喂记录 + */ + @PreAuthorize("@ss.hasPermi('feed:info:add')") + @Log(title = "饲喂记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SgFeedInfo sgFeedInfo) + { + return toAjax(sgFeedInfoService.insertSgFeedInfo(sgFeedInfo)); + } + + /** + * 修改饲喂记录 + */ + @PreAuthorize("@ss.hasPermi('feed:info:edit')") + @Log(title = "饲喂记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SgFeedInfo sgFeedInfo) + { + return toAjax(sgFeedInfoService.updateSgFeedInfo(sgFeedInfo)); + } + + /** + * 删除饲喂记录 + */ + @PreAuthorize("@ss.hasPermi('feed:info:remove')") + @Log(title = "饲喂记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sgFeedInfoService.deleteSgFeedInfoByIds(ids)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedRatioController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedRatioController.java new file mode 100644 index 0000000..81ddd36 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedRatioController.java @@ -0,0 +1,104 @@ +package com.zhyc.module.feed.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.feed.domain.SgFeedRatio; +import com.zhyc.module.feed.service.ISgFeedRatioService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 饲喂比例Controller + * + * @author ruoyi + * @date 2025-08-01 + */ +@RestController +@RequestMapping("/feed/ratio") +public class SgFeedRatioController extends BaseController +{ + @Autowired + private ISgFeedRatioService sgFeedRatioService; + + /** + * 查询饲喂比例列表 + */ + @PreAuthorize("@ss.hasPermi('feed:ratio:list')") + @GetMapping("/list") + public TableDataInfo list(SgFeedRatio sgFeedRatio) + { + startPage(); + List list = sgFeedRatioService.selectSgFeedRatioList(sgFeedRatio); + return getDataTable(list); + } + + /** + * 导出饲喂比例列表 + */ + @PreAuthorize("@ss.hasPermi('feed:ratio:export')") + @Log(title = "饲喂比例", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SgFeedRatio sgFeedRatio) + { + List list = sgFeedRatioService.selectSgFeedRatioList(sgFeedRatio); + ExcelUtil util = new ExcelUtil(SgFeedRatio.class); + util.exportExcel(response, list, "饲喂比例数据"); + } + + /** + * 获取饲喂比例详细信息 + */ + @PreAuthorize("@ss.hasPermi('feed:ratio:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(sgFeedRatioService.selectSgFeedRatioById(id)); + } + + /** + * 新增饲喂比例 + */ + @PreAuthorize("@ss.hasPermi('feed:ratio:add')") + @Log(title = "饲喂比例", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SgFeedRatio sgFeedRatio) + { + return toAjax(sgFeedRatioService.insertSgFeedRatio(sgFeedRatio)); + } + + /** + * 修改饲喂比例 + */ + @PreAuthorize("@ss.hasPermi('feed:ratio:edit')") + @Log(title = "饲喂比例", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SgFeedRatio sgFeedRatio) + { + return toAjax(sgFeedRatioService.updateSgFeedRatio(sgFeedRatio)); + } + + /** + * 删除饲喂比例 + */ + @PreAuthorize("@ss.hasPermi('feed:ratio:remove')") + @Log(title = "饲喂比例", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sgFeedRatioService.deleteSgFeedRatioByIds(ids)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFodderController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFodderController.java new file mode 100644 index 0000000..94b2161 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFodderController.java @@ -0,0 +1,104 @@ +package com.zhyc.module.feed.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.feed.domain.SgFodder; +import com.zhyc.module.feed.service.ISgFodderService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 原料Controller + * + * @author ruoyi + * @date 2025-08-01 + */ +@RestController +@RequestMapping("/feed/fodder") +public class SgFodderController extends BaseController +{ + @Autowired + private ISgFodderService sgFodderService; + + /** + * 查询原料列表 + */ + @PreAuthorize("@ss.hasPermi('feed:fodder:list')") + @GetMapping("/list") + public TableDataInfo list(SgFodder sgFodder) + { + startPage(); + List list = sgFodderService.selectSgFodderList(sgFodder); + return getDataTable(list); + } + + /** + * 导出原料列表 + */ + @PreAuthorize("@ss.hasPermi('feed:fodder:export')") + @Log(title = "原料", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SgFodder sgFodder) + { + List list = sgFodderService.selectSgFodderList(sgFodder); + ExcelUtil util = new ExcelUtil(SgFodder.class); + util.exportExcel(response, list, "原料数据"); + } + + /** + * 获取原料详细信息 + */ + @PreAuthorize("@ss.hasPermi('feed:fodder:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(sgFodderService.selectSgFodderById(id)); + } + + /** + * 新增原料 + */ + @PreAuthorize("@ss.hasPermi('feed:fodder:add')") + @Log(title = "原料", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SgFodder sgFodder) + { + return toAjax(sgFodderService.insertSgFodder(sgFodder)); + } + + /** + * 修改原料 + */ + @PreAuthorize("@ss.hasPermi('feed:fodder:edit')") + @Log(title = "原料", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SgFodder sgFodder) + { + return toAjax(sgFodderService.updateSgFodder(sgFodder)); + } + + /** + * 删除原料 + */ + @PreAuthorize("@ss.hasPermi('feed:fodder:remove')") + @Log(title = "原料", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sgFodderService.deleteSgFodderByIds(ids)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedDetails.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedDetails.java new file mode 100644 index 0000000..a1404e2 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedDetails.java @@ -0,0 +1,82 @@ +package com.zhyc.module.feed.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; + +/** + * 饲喂记录详情对象 sg_feed_details + * + * @author ruoyi + * @date 2025-08-01 + */ +public class SgFeedDetails extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 原料id */ + @Excel(name = "原料id") + private String fodder; + + /** 数量 */ + @Excel(name = "数量") + private Long number; + + /** 单位 */ + @Excel(name = "单位") + private String nuit; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setFodder(String fodder) + { + this.fodder = fodder; + } + + public String getFodder() + { + return fodder; + } + + public void setNumber(Long number) + { + this.number = number; + } + + public Long getNumber() + { + return number; + } + + public void setNuit(String nuit) + { + this.nuit = nuit; + } + + public String getNuit() + { + return nuit; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("fodder", getFodder()) + .append("number", getNumber()) + .append("nuit", getNuit()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedInfo.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedInfo.java new file mode 100644 index 0000000..37ed315 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedInfo.java @@ -0,0 +1,252 @@ +package com.zhyc.module.feed.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +/** + * 饲喂记录对象 sg_feed_info + * + * @author ruoyi + * @date 2025-08-01 + */ +public class SgFeedInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 配方编码 */ + @Excel(name = "配方编码") + private Long formulaId; + + /** 羊舍 */ + @Excel(name = "羊舍") + private String sheepfoldId; + + /** 日均计划量 */ + @Excel(name = "日均计划量") + private Long average; + + /** 早上计划量(通过饲喂比例算出来) */ + @Excel(name = "早上计划量(通过饲喂比例算出来)") + private Long planMonring; + + /** 实际添加(早) */ + @Excel(name = "实际添加", readConverterExp = "早=") + private Long actualMonring; + + /** 中午计划量 */ + @Excel(name = "中午计划量") + private Long planNoon; + + /** 实际添加(中) */ + @Excel(name = "实际添加", readConverterExp = "中=") + private Long actualNoon; + + /** 下午计划量 */ + @Excel(name = "下午计划量") + private Long planEvenig; + + /** 实际添加(下) */ + @Excel(name = "实际添加", readConverterExp = "下=") + private Long actualEvening; + + /** 颗粒原料 */ + @Excel(name = "颗粒原料") + private Long particle; + + /** 其他原料 */ + @Excel(name = "其他原料") + private Long other; + + /** 补饲饲料 */ + @Excel(name = "补饲饲料") + private Long replenish; + + /** 饲喂日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "饲喂日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date planDate; + + /** 备注 */ + @Excel(name = "备注") + private String comment; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setFormulaId(Long formulaId) + { + this.formulaId = formulaId; + } + + public Long getFormulaId() + { + return formulaId; + } + + public void setSheepfoldId(String sheepfoldId) + { + this.sheepfoldId = sheepfoldId; + } + + public String getSheepfoldId() + { + return sheepfoldId; + } + + public void setAverage(Long average) + { + this.average = average; + } + + public Long getAverage() + { + return average; + } + + public void setPlanMonring(Long planMonring) + { + this.planMonring = planMonring; + } + + public Long getPlanMonring() + { + return planMonring; + } + + public void setActualMonring(Long actualMonring) + { + this.actualMonring = actualMonring; + } + + public Long getActualMonring() + { + return actualMonring; + } + + public void setPlanNoon(Long planNoon) + { + this.planNoon = planNoon; + } + + public Long getPlanNoon() + { + return planNoon; + } + + public void setActualNoon(Long actualNoon) + { + this.actualNoon = actualNoon; + } + + public Long getActualNoon() + { + return actualNoon; + } + + public void setPlanEvenig(Long planEvenig) + { + this.planEvenig = planEvenig; + } + + public Long getPlanEvenig() + { + return planEvenig; + } + + public void setActualEvening(Long actualEvening) + { + this.actualEvening = actualEvening; + } + + public Long getActualEvening() + { + return actualEvening; + } + + public void setParticle(Long particle) + { + this.particle = particle; + } + + public Long getParticle() + { + return particle; + } + + public void setOther(Long other) + { + this.other = other; + } + + public Long getOther() + { + return other; + } + + public void setReplenish(Long replenish) + { + this.replenish = replenish; + } + + public Long getReplenish() + { + return replenish; + } + + public void setPlanDate(Date planDate) + { + this.planDate = planDate; + } + + public Date getPlanDate() + { + return planDate; + } + + public void setComment(String comment) + { + this.comment = comment; + } + + public String getComment() + { + return comment; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("formulaId", getFormulaId()) + .append("sheepfoldId", getSheepfoldId()) + .append("average", getAverage()) + .append("planMonring", getPlanMonring()) + .append("actualMonring", getActualMonring()) + .append("planNoon", getPlanNoon()) + .append("actualNoon", getActualNoon()) + .append("planEvenig", getPlanEvenig()) + .append("actualEvening", getActualEvening()) + .append("particle", getParticle()) + .append("other", getOther()) + .append("replenish", getReplenish()) + .append("planDate", getPlanDate()) + .append("comment", getComment()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedRatio.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedRatio.java new file mode 100644 index 0000000..5e3834e --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedRatio.java @@ -0,0 +1,82 @@ +package com.zhyc.module.feed.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; + +/** + * 饲喂比例对象 sg_feed_ratio + * + * @author ruoyi + * @date 2025-08-01 + */ +public class SgFeedRatio extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 早晨计划比列 */ + @Excel(name = "早晨计划比列") + private String morning; + + /** 中午计划比例 */ + @Excel(name = "中午计划比例") + private String noon; + + /** 下午计划比例 */ + @Excel(name = "下午计划比例") + private String evening; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setMorning(String morning) + { + this.morning = morning; + } + + public String getMorning() + { + return morning; + } + + public void setNoon(String noon) + { + this.noon = noon; + } + + public String getNoon() + { + return noon; + } + + public void setEvening(String evening) + { + this.evening = evening; + } + + public String getEvening() + { + return evening; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("morning", getMorning()) + .append("noon", getNoon()) + .append("evening", getEvening()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFodder.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFodder.java new file mode 100644 index 0000000..3b00b2d --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFodder.java @@ -0,0 +1,67 @@ +package com.zhyc.module.feed.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; + +/** + * 原料对象 sg_fodder + * + * @author ruoyi + * @date 2025-08-01 + */ +public class SgFodder extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 名称 */ + @Excel(name = "名称") + private String name; + + /** 0补饲饲料1配方原料2颗粒原料 */ + @Excel(name = "0补饲饲料1配方原料2颗粒原料") + private Long fodderType; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public void setFodderType(Long fodderType) + { + this.fodderType = fodderType; + } + + public Long getFodderType() + { + return fodderType; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("fodderType", getFodderType()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedDetailsMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedDetailsMapper.java new file mode 100644 index 0000000..2817118 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedDetailsMapper.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.mapper; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFeedDetails; + +/** + * 饲喂记录详情Mapper接口 + * + * @author ruoyi + * @date 2025-08-01 + */ +public interface SgFeedDetailsMapper +{ + /** + * 查询饲喂记录详情 + * + * @param id 饲喂记录详情主键 + * @return 饲喂记录详情 + */ + public SgFeedDetails selectSgFeedDetailsById(Long id); + + /** + * 查询饲喂记录详情列表 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 饲喂记录详情集合 + */ + public List selectSgFeedDetailsList(SgFeedDetails sgFeedDetails); + + /** + * 新增饲喂记录详情 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 结果 + */ + public int insertSgFeedDetails(SgFeedDetails sgFeedDetails); + + /** + * 修改饲喂记录详情 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 结果 + */ + public int updateSgFeedDetails(SgFeedDetails sgFeedDetails); + + /** + * 删除饲喂记录详情 + * + * @param id 饲喂记录详情主键 + * @return 结果 + */ + public int deleteSgFeedDetailsById(Long id); + + /** + * 批量删除饲喂记录详情 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSgFeedDetailsByIds(Long[] ids); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedInfoMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedInfoMapper.java new file mode 100644 index 0000000..11ea688 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedInfoMapper.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.mapper; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFeedInfo; + +/** + * 饲喂记录Mapper接口 + * + * @author ruoyi + * @date 2025-08-01 + */ +public interface SgFeedInfoMapper +{ + /** + * 查询饲喂记录 + * + * @param id 饲喂记录主键 + * @return 饲喂记录 + */ + public SgFeedInfo selectSgFeedInfoById(Long id); + + /** + * 查询饲喂记录列表 + * + * @param sgFeedInfo 饲喂记录 + * @return 饲喂记录集合 + */ + public List selectSgFeedInfoList(SgFeedInfo sgFeedInfo); + + /** + * 新增饲喂记录 + * + * @param sgFeedInfo 饲喂记录 + * @return 结果 + */ + public int insertSgFeedInfo(SgFeedInfo sgFeedInfo); + + /** + * 修改饲喂记录 + * + * @param sgFeedInfo 饲喂记录 + * @return 结果 + */ + public int updateSgFeedInfo(SgFeedInfo sgFeedInfo); + + /** + * 删除饲喂记录 + * + * @param id 饲喂记录主键 + * @return 结果 + */ + public int deleteSgFeedInfoById(Long id); + + /** + * 批量删除饲喂记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSgFeedInfoByIds(Long[] ids); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedRatioMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedRatioMapper.java new file mode 100644 index 0000000..5dbd1ce --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedRatioMapper.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.mapper; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFeedRatio; + +/** + * 饲喂比例Mapper接口 + * + * @author ruoyi + * @date 2025-08-01 + */ +public interface SgFeedRatioMapper +{ + /** + * 查询饲喂比例 + * + * @param id 饲喂比例主键 + * @return 饲喂比例 + */ + public SgFeedRatio selectSgFeedRatioById(Long id); + + /** + * 查询饲喂比例列表 + * + * @param sgFeedRatio 饲喂比例 + * @return 饲喂比例集合 + */ + public List selectSgFeedRatioList(SgFeedRatio sgFeedRatio); + + /** + * 新增饲喂比例 + * + * @param sgFeedRatio 饲喂比例 + * @return 结果 + */ + public int insertSgFeedRatio(SgFeedRatio sgFeedRatio); + + /** + * 修改饲喂比例 + * + * @param sgFeedRatio 饲喂比例 + * @return 结果 + */ + public int updateSgFeedRatio(SgFeedRatio sgFeedRatio); + + /** + * 删除饲喂比例 + * + * @param id 饲喂比例主键 + * @return 结果 + */ + public int deleteSgFeedRatioById(Long id); + + /** + * 批量删除饲喂比例 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSgFeedRatioByIds(Long[] ids); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFodderMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFodderMapper.java new file mode 100644 index 0000000..c916e24 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFodderMapper.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.mapper; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFodder; + +/** + * 原料Mapper接口 + * + * @author ruoyi + * @date 2025-08-01 + */ +public interface SgFodderMapper +{ + /** + * 查询原料 + * + * @param id 原料主键 + * @return 原料 + */ + public SgFodder selectSgFodderById(Long id); + + /** + * 查询原料列表 + * + * @param sgFodder 原料 + * @return 原料集合 + */ + public List selectSgFodderList(SgFodder sgFodder); + + /** + * 新增原料 + * + * @param sgFodder 原料 + * @return 结果 + */ + public int insertSgFodder(SgFodder sgFodder); + + /** + * 修改原料 + * + * @param sgFodder 原料 + * @return 结果 + */ + public int updateSgFodder(SgFodder sgFodder); + + /** + * 删除原料 + * + * @param id 原料主键 + * @return 结果 + */ + public int deleteSgFodderById(Long id); + + /** + * 批量删除原料 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSgFodderByIds(Long[] ids); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedDetailsService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedDetailsService.java new file mode 100644 index 0000000..ac695f8 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedDetailsService.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.service; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFeedDetails; + +/** + * 饲喂记录详情Service接口 + * + * @author ruoyi + * @date 2025-08-01 + */ +public interface ISgFeedDetailsService +{ + /** + * 查询饲喂记录详情 + * + * @param id 饲喂记录详情主键 + * @return 饲喂记录详情 + */ + public SgFeedDetails selectSgFeedDetailsById(Long id); + + /** + * 查询饲喂记录详情列表 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 饲喂记录详情集合 + */ + public List selectSgFeedDetailsList(SgFeedDetails sgFeedDetails); + + /** + * 新增饲喂记录详情 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 结果 + */ + public int insertSgFeedDetails(SgFeedDetails sgFeedDetails); + + /** + * 修改饲喂记录详情 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 结果 + */ + public int updateSgFeedDetails(SgFeedDetails sgFeedDetails); + + /** + * 批量删除饲喂记录详情 + * + * @param ids 需要删除的饲喂记录详情主键集合 + * @return 结果 + */ + public int deleteSgFeedDetailsByIds(Long[] ids); + + /** + * 删除饲喂记录详情信息 + * + * @param id 饲喂记录详情主键 + * @return 结果 + */ + public int deleteSgFeedDetailsById(Long id); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedInfoService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedInfoService.java new file mode 100644 index 0000000..8d412b8 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedInfoService.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.service; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFeedInfo; + +/** + * 饲喂记录Service接口 + * + * @author ruoyi + * @date 2025-08-01 + */ +public interface ISgFeedInfoService +{ + /** + * 查询饲喂记录 + * + * @param id 饲喂记录主键 + * @return 饲喂记录 + */ + public SgFeedInfo selectSgFeedInfoById(Long id); + + /** + * 查询饲喂记录列表 + * + * @param sgFeedInfo 饲喂记录 + * @return 饲喂记录集合 + */ + public List selectSgFeedInfoList(SgFeedInfo sgFeedInfo); + + /** + * 新增饲喂记录 + * + * @param sgFeedInfo 饲喂记录 + * @return 结果 + */ + public int insertSgFeedInfo(SgFeedInfo sgFeedInfo); + + /** + * 修改饲喂记录 + * + * @param sgFeedInfo 饲喂记录 + * @return 结果 + */ + public int updateSgFeedInfo(SgFeedInfo sgFeedInfo); + + /** + * 批量删除饲喂记录 + * + * @param ids 需要删除的饲喂记录主键集合 + * @return 结果 + */ + public int deleteSgFeedInfoByIds(Long[] ids); + + /** + * 删除饲喂记录信息 + * + * @param id 饲喂记录主键 + * @return 结果 + */ + public int deleteSgFeedInfoById(Long id); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedRatioService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedRatioService.java new file mode 100644 index 0000000..804130f --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedRatioService.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.service; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFeedRatio; + +/** + * 饲喂比例Service接口 + * + * @author ruoyi + * @date 2025-08-01 + */ +public interface ISgFeedRatioService +{ + /** + * 查询饲喂比例 + * + * @param id 饲喂比例主键 + * @return 饲喂比例 + */ + public SgFeedRatio selectSgFeedRatioById(Long id); + + /** + * 查询饲喂比例列表 + * + * @param sgFeedRatio 饲喂比例 + * @return 饲喂比例集合 + */ + public List selectSgFeedRatioList(SgFeedRatio sgFeedRatio); + + /** + * 新增饲喂比例 + * + * @param sgFeedRatio 饲喂比例 + * @return 结果 + */ + public int insertSgFeedRatio(SgFeedRatio sgFeedRatio); + + /** + * 修改饲喂比例 + * + * @param sgFeedRatio 饲喂比例 + * @return 结果 + */ + public int updateSgFeedRatio(SgFeedRatio sgFeedRatio); + + /** + * 批量删除饲喂比例 + * + * @param ids 需要删除的饲喂比例主键集合 + * @return 结果 + */ + public int deleteSgFeedRatioByIds(Long[] ids); + + /** + * 删除饲喂比例信息 + * + * @param id 饲喂比例主键 + * @return 结果 + */ + public int deleteSgFeedRatioById(Long id); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFodderService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFodderService.java new file mode 100644 index 0000000..3ddac8f --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFodderService.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.service; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFodder; + +/** + * 原料Service接口 + * + * @author ruoyi + * @date 2025-08-01 + */ +public interface ISgFodderService +{ + /** + * 查询原料 + * + * @param id 原料主键 + * @return 原料 + */ + public SgFodder selectSgFodderById(Long id); + + /** + * 查询原料列表 + * + * @param sgFodder 原料 + * @return 原料集合 + */ + public List selectSgFodderList(SgFodder sgFodder); + + /** + * 新增原料 + * + * @param sgFodder 原料 + * @return 结果 + */ + public int insertSgFodder(SgFodder sgFodder); + + /** + * 修改原料 + * + * @param sgFodder 原料 + * @return 结果 + */ + public int updateSgFodder(SgFodder sgFodder); + + /** + * 批量删除原料 + * + * @param ids 需要删除的原料主键集合 + * @return 结果 + */ + public int deleteSgFodderByIds(Long[] ids); + + /** + * 删除原料信息 + * + * @param id 原料主键 + * @return 结果 + */ + public int deleteSgFodderById(Long id); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedDetailsServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedDetailsServiceImpl.java new file mode 100644 index 0000000..2f58d33 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedDetailsServiceImpl.java @@ -0,0 +1,93 @@ +package com.zhyc.module.feed.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhyc.module.feed.mapper.SgFeedDetailsMapper; +import com.zhyc.module.feed.domain.SgFeedDetails; +import com.zhyc.module.feed.service.ISgFeedDetailsService; + +/** + * 饲喂记录详情Service业务层处理 + * + * @author ruoyi + * @date 2025-08-01 + */ +@Service +public class SgFeedDetailsServiceImpl implements ISgFeedDetailsService +{ + @Autowired + private SgFeedDetailsMapper sgFeedDetailsMapper; + + /** + * 查询饲喂记录详情 + * + * @param id 饲喂记录详情主键 + * @return 饲喂记录详情 + */ + @Override + public SgFeedDetails selectSgFeedDetailsById(Long id) + { + return sgFeedDetailsMapper.selectSgFeedDetailsById(id); + } + + /** + * 查询饲喂记录详情列表 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 饲喂记录详情 + */ + @Override + public List selectSgFeedDetailsList(SgFeedDetails sgFeedDetails) + { + return sgFeedDetailsMapper.selectSgFeedDetailsList(sgFeedDetails); + } + + /** + * 新增饲喂记录详情 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 结果 + */ + @Override + public int insertSgFeedDetails(SgFeedDetails sgFeedDetails) + { + return sgFeedDetailsMapper.insertSgFeedDetails(sgFeedDetails); + } + + /** + * 修改饲喂记录详情 + * + * @param sgFeedDetails 饲喂记录详情 + * @return 结果 + */ + @Override + public int updateSgFeedDetails(SgFeedDetails sgFeedDetails) + { + return sgFeedDetailsMapper.updateSgFeedDetails(sgFeedDetails); + } + + /** + * 批量删除饲喂记录详情 + * + * @param ids 需要删除的饲喂记录详情主键 + * @return 结果 + */ + @Override + public int deleteSgFeedDetailsByIds(Long[] ids) + { + return sgFeedDetailsMapper.deleteSgFeedDetailsByIds(ids); + } + + /** + * 删除饲喂记录详情信息 + * + * @param id 饲喂记录详情主键 + * @return 结果 + */ + @Override + public int deleteSgFeedDetailsById(Long id) + { + return sgFeedDetailsMapper.deleteSgFeedDetailsById(id); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedInfoServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedInfoServiceImpl.java new file mode 100644 index 0000000..ea2f711 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedInfoServiceImpl.java @@ -0,0 +1,95 @@ +package com.zhyc.module.feed.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.feed.mapper.SgFeedInfoMapper; +import com.zhyc.module.feed.domain.SgFeedInfo; +import com.zhyc.module.feed.service.ISgFeedInfoService; + +/** + * 饲喂记录Service业务层处理 + * + * @author ruoyi + * @date 2025-08-01 + */ +@Service +public class SgFeedInfoServiceImpl implements ISgFeedInfoService +{ + @Autowired + private SgFeedInfoMapper sgFeedInfoMapper; + + /** + * 查询饲喂记录 + * + * @param id 饲喂记录主键 + * @return 饲喂记录 + */ + @Override + public SgFeedInfo selectSgFeedInfoById(Long id) + { + return sgFeedInfoMapper.selectSgFeedInfoById(id); + } + + /** + * 查询饲喂记录列表 + * + * @param sgFeedInfo 饲喂记录 + * @return 饲喂记录 + */ + @Override + public List selectSgFeedInfoList(SgFeedInfo sgFeedInfo) + { + return sgFeedInfoMapper.selectSgFeedInfoList(sgFeedInfo); + } + + /** + * 新增饲喂记录 + * + * @param sgFeedInfo 饲喂记录 + * @return 结果 + */ + @Override + public int insertSgFeedInfo(SgFeedInfo sgFeedInfo) + { + sgFeedInfo.setCreateTime(DateUtils.getNowDate()); + return sgFeedInfoMapper.insertSgFeedInfo(sgFeedInfo); + } + + /** + * 修改饲喂记录 + * + * @param sgFeedInfo 饲喂记录 + * @return 结果 + */ + @Override + public int updateSgFeedInfo(SgFeedInfo sgFeedInfo) + { + return sgFeedInfoMapper.updateSgFeedInfo(sgFeedInfo); + } + + /** + * 批量删除饲喂记录 + * + * @param ids 需要删除的饲喂记录主键 + * @return 结果 + */ + @Override + public int deleteSgFeedInfoByIds(Long[] ids) + { + return sgFeedInfoMapper.deleteSgFeedInfoByIds(ids); + } + + /** + * 删除饲喂记录信息 + * + * @param id 饲喂记录主键 + * @return 结果 + */ + @Override + public int deleteSgFeedInfoById(Long id) + { + return sgFeedInfoMapper.deleteSgFeedInfoById(id); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedRatioServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedRatioServiceImpl.java new file mode 100644 index 0000000..ee15ab0 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedRatioServiceImpl.java @@ -0,0 +1,93 @@ +package com.zhyc.module.feed.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhyc.module.feed.mapper.SgFeedRatioMapper; +import com.zhyc.module.feed.domain.SgFeedRatio; +import com.zhyc.module.feed.service.ISgFeedRatioService; + +/** + * 饲喂比例Service业务层处理 + * + * @author ruoyi + * @date 2025-08-01 + */ +@Service +public class SgFeedRatioServiceImpl implements ISgFeedRatioService +{ + @Autowired + private SgFeedRatioMapper sgFeedRatioMapper; + + /** + * 查询饲喂比例 + * + * @param id 饲喂比例主键 + * @return 饲喂比例 + */ + @Override + public SgFeedRatio selectSgFeedRatioById(Long id) + { + return sgFeedRatioMapper.selectSgFeedRatioById(id); + } + + /** + * 查询饲喂比例列表 + * + * @param sgFeedRatio 饲喂比例 + * @return 饲喂比例 + */ + @Override + public List selectSgFeedRatioList(SgFeedRatio sgFeedRatio) + { + return sgFeedRatioMapper.selectSgFeedRatioList(sgFeedRatio); + } + + /** + * 新增饲喂比例 + * + * @param sgFeedRatio 饲喂比例 + * @return 结果 + */ + @Override + public int insertSgFeedRatio(SgFeedRatio sgFeedRatio) + { + return sgFeedRatioMapper.insertSgFeedRatio(sgFeedRatio); + } + + /** + * 修改饲喂比例 + * + * @param sgFeedRatio 饲喂比例 + * @return 结果 + */ + @Override + public int updateSgFeedRatio(SgFeedRatio sgFeedRatio) + { + return sgFeedRatioMapper.updateSgFeedRatio(sgFeedRatio); + } + + /** + * 批量删除饲喂比例 + * + * @param ids 需要删除的饲喂比例主键 + * @return 结果 + */ + @Override + public int deleteSgFeedRatioByIds(Long[] ids) + { + return sgFeedRatioMapper.deleteSgFeedRatioByIds(ids); + } + + /** + * 删除饲喂比例信息 + * + * @param id 饲喂比例主键 + * @return 结果 + */ + @Override + public int deleteSgFeedRatioById(Long id) + { + return sgFeedRatioMapper.deleteSgFeedRatioById(id); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFodderServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFodderServiceImpl.java new file mode 100644 index 0000000..523fc3d --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFodderServiceImpl.java @@ -0,0 +1,93 @@ +package com.zhyc.module.feed.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhyc.module.feed.mapper.SgFodderMapper; +import com.zhyc.module.feed.domain.SgFodder; +import com.zhyc.module.feed.service.ISgFodderService; + +/** + * 原料Service业务层处理 + * + * @author ruoyi + * @date 2025-08-01 + */ +@Service +public class SgFodderServiceImpl implements ISgFodderService +{ + @Autowired + private SgFodderMapper sgFodderMapper; + + /** + * 查询原料 + * + * @param id 原料主键 + * @return 原料 + */ + @Override + public SgFodder selectSgFodderById(Long id) + { + return sgFodderMapper.selectSgFodderById(id); + } + + /** + * 查询原料列表 + * + * @param sgFodder 原料 + * @return 原料 + */ + @Override + public List selectSgFodderList(SgFodder sgFodder) + { + return sgFodderMapper.selectSgFodderList(sgFodder); + } + + /** + * 新增原料 + * + * @param sgFodder 原料 + * @return 结果 + */ + @Override + public int insertSgFodder(SgFodder sgFodder) + { + return sgFodderMapper.insertSgFodder(sgFodder); + } + + /** + * 修改原料 + * + * @param sgFodder 原料 + * @return 结果 + */ + @Override + public int updateSgFodder(SgFodder sgFodder) + { + return sgFodderMapper.updateSgFodder(sgFodder); + } + + /** + * 批量删除原料 + * + * @param ids 需要删除的原料主键 + * @return 结果 + */ + @Override + public int deleteSgFodderByIds(Long[] ids) + { + return sgFodderMapper.deleteSgFodderByIds(ids); + } + + /** + * 删除原料信息 + * + * @param id 原料主键 + * @return 结果 + */ + @Override + public int deleteSgFodderById(Long id) + { + return sgFodderMapper.deleteSgFodderById(id); + } +} diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFeedDetailsMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFeedDetailsMapper.xml new file mode 100644 index 0000000..0966729 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/feed/SgFeedDetailsMapper.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + select id, fodder, number, nuit from sg_feed_details + + + + + + + + insert into sg_feed_details + + fodder, + number, + nuit, + + + #{fodder}, + #{number}, + #{nuit}, + + + + + update sg_feed_details + + fodder = #{fodder}, + number = #{number}, + nuit = #{nuit}, + + where id = #{id} + + + + delete from sg_feed_details where id = #{id} + + + + delete from sg_feed_details where id in + + #{id} + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFeedInfoMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFeedInfoMapper.xml new file mode 100644 index 0000000..536e136 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/feed/SgFeedInfoMapper.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, formula_id, sheepfold_id, average, plan_monring, actual_monring, plan_noon, actual_noon, plan_evenig, actual_evening, particle, other, replenish, plan_date, comment, create_by, create_time from sg_feed_info + + + + + + + + insert into sg_feed_info + + formula_id, + sheepfold_id, + average, + plan_monring, + actual_monring, + plan_noon, + actual_noon, + plan_evenig, + actual_evening, + particle, + other, + replenish, + plan_date, + comment, + create_by, + create_time, + + + #{formulaId}, + #{sheepfoldId}, + #{average}, + #{planMonring}, + #{actualMonring}, + #{planNoon}, + #{actualNoon}, + #{planEvenig}, + #{actualEvening}, + #{particle}, + #{other}, + #{replenish}, + #{planDate}, + #{comment}, + #{createBy}, + #{createTime}, + + + + + update sg_feed_info + + formula_id = #{formulaId}, + sheepfold_id = #{sheepfoldId}, + average = #{average}, + plan_monring = #{planMonring}, + actual_monring = #{actualMonring}, + plan_noon = #{planNoon}, + actual_noon = #{actualNoon}, + plan_evenig = #{planEvenig}, + actual_evening = #{actualEvening}, + particle = #{particle}, + other = #{other}, + replenish = #{replenish}, + plan_date = #{planDate}, + comment = #{comment}, + create_by = #{createBy}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from sg_feed_info where id = #{id} + + + + delete from sg_feed_info where id in + + #{id} + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFeedRatioMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFeedRatioMapper.xml new file mode 100644 index 0000000..2ebb1fd --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/feed/SgFeedRatioMapper.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + select id, morning, noon, evening from sg_feed_ratio + + + + + + + + insert into sg_feed_ratio + + morning, + noon, + evening, + + + #{morning}, + #{noon}, + #{evening}, + + + + + update sg_feed_ratio + + morning = #{morning}, + noon = #{noon}, + evening = #{evening}, + + where id = #{id} + + + + delete from sg_feed_ratio where id = #{id} + + + + delete from sg_feed_ratio where id in + + #{id} + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFodderMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFodderMapper.xml new file mode 100644 index 0000000..8f4638b --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/feed/SgFodderMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + select id, name, fodder_type from sg_fodder + + + + + + + + insert into sg_fodder + + name, + fodder_type, + + + #{name}, + #{fodderType}, + + + + + update sg_fodder + + name = #{name}, + fodder_type = #{fodderType}, + + where id = #{id} + + + + delete from sg_fodder where id = #{id} + + + + delete from sg_fodder where id in + + #{id} + + + \ No newline at end of file From e965c9c35cdc43e7f7cd0776d870645adfd7d1c8 Mon Sep 17 00:00:00 2001 From: HashMap Date: Tue, 12 Aug 2025 15:55:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(module):=20=E9=A5=B2=E5=96=82=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20-=20=E9=85=8D=E6=96=B9=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 完成饲喂管理模块中的配方管理部分 --- .../feed/controller/SgFeedPlanController.java | 107 +++++++++++ .../controller/SgFormulaListController.java | 106 +++++++++++ .../SgFormulaManagementController.java | 172 ++++++++++++++++++ .../feed/controller/SgMaterialController.java | 107 +++++++++++ .../zhyc/module/feed/domain/SgFeedPlan.java | 132 ++++++++++++++ .../module/feed/domain/SgFormulaList.java | 62 +++++++ .../feed/domain/SgFormulaManagement.java | 79 ++++++++ .../zhyc/module/feed/domain/SgMaterial.java | 15 ++ .../module/feed/mapper/SgFeedPlanMapper.java | 64 +++++++ .../feed/mapper/SgFormulaListMapper.java | 71 ++++++++ .../mapper/SgFormulaManagementMapper.java | 65 +++++++ .../module/feed/mapper/SgMaterialMapper.java | 63 +++++++ .../feed/service/ISgFeedPlanService.java | 62 +++++++ .../feed/service/ISgFormulaListService.java | 63 +++++++ .../service/ISgFormulaManagementService.java | 66 +++++++ .../feed/service/ISgMaterialService.java | 61 +++++++ .../service/impl/SgFeedPlanServiceImpl.java | 99 ++++++++++ .../impl/SgFormulaListServiceImpl.java | 97 ++++++++++ .../impl/SgFormulaManagementServiceImpl.java | 135 ++++++++++++++ .../service/impl/SgMaterialServiceImpl.java | 96 ++++++++++ .../service/impl/WzStockInServiceImpl.java | 4 +- .../mapper/feed/SgFeedPlanMapper.xml | 137 ++++++++++++++ .../mapper/feed/SgFormulaListMapper.xml | 87 +++++++++ .../mapper/feed/SgFormulaManagementMapper.xml | 82 +++++++++ .../mapper/feed/SgMaterialMapper.xml | 64 +++++++ 25 files changed, 2095 insertions(+), 1 deletion(-) create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedPlanController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFormulaListController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFormulaManagementController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgMaterialController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedPlan.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaList.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaManagement.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgMaterial.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedPlanMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFormulaListMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFormulaManagementMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgMaterialMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedPlanService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFormulaListService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFormulaManagementService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgMaterialService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedPlanServiceImpl.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFormulaListServiceImpl.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFormulaManagementServiceImpl.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgMaterialServiceImpl.java create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgFeedPlanMapper.xml create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgFormulaListMapper.xml create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgFormulaManagementMapper.xml create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgMaterialMapper.xml diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedPlanController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedPlanController.java new file mode 100644 index 0000000..ad2a6a2 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedPlanController.java @@ -0,0 +1,107 @@ +package com.zhyc.module.feed.controller; + +import java.util.Date; +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.zhyc.common.annotation.Log; +import com.zhyc.common.core.controller.BaseController; +import com.zhyc.common.core.domain.AjaxResult; +import com.zhyc.common.enums.BusinessType; +import com.zhyc.module.feed.domain.SgFeedPlan; +import com.zhyc.module.feed.service.ISgFeedPlanService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 饲喂计划Controller + * + * @author HashMap + * @date 2025-08-08 + */ +@RestController +@RequestMapping("/feed/FeedPlan") +public class SgFeedPlanController extends BaseController +{ + private final ISgFeedPlanService sgFeedPlanService; + + public SgFeedPlanController(ISgFeedPlanService sgFeedPlanService) { + this.sgFeedPlanService = sgFeedPlanService; + } + + /** + * 查询饲喂计划列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FeedPlan:list')") + @GetMapping("/list") + public TableDataInfo list(SgFeedPlan sgFeedPlan) + { + startPage(); + List list = sgFeedPlanService.selectSgFeedPlanList(sgFeedPlan); + return getDataTable(list); + } + + /** + * 导出饲喂计划列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FeedPlan:export')") + @Log(title = "饲喂计划", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SgFeedPlan sgFeedPlan) + { + List list = sgFeedPlanService.selectSgFeedPlanList(sgFeedPlan); + ExcelUtil util = new ExcelUtil<>(SgFeedPlan.class); + util.exportExcel(response, list, "饲喂计划数据"); + } + + /** + * 获取饲喂计划详细信息 + */ + @PreAuthorize("@ss.hasPermi('feed:FeedPlan:query')") + @GetMapping(value = "/{createDate}") + public AjaxResult getInfo(@PathVariable("createDate") Date createDate) + { + return success(sgFeedPlanService.selectSgFeedPlanByCreateDate(createDate)); + } + + /** + * 新增饲喂计划 + */ + @PreAuthorize("@ss.hasPermi('feed:FeedPlan:add')") + @Log(title = "饲喂计划", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SgFeedPlan sgFeedPlan) + { + return toAjax(sgFeedPlanService.insertSgFeedPlan(sgFeedPlan)); + } + + /** + * 修改饲喂计划 + */ + @PreAuthorize("@ss.hasPermi('feed:FeedPlan:edit')") + @Log(title = "饲喂计划", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SgFeedPlan sgFeedPlan) + { + return toAjax(sgFeedPlanService.updateSgFeedPlan(sgFeedPlan)); + } + + /** + * 删除饲喂计划 + */ + @PreAuthorize("@ss.hasPermi('feed:FeedPlan:remove')") + @Log(title = "饲喂计划", businessType = BusinessType.DELETE) + @DeleteMapping("/{createDates}") + public AjaxResult remove(@PathVariable Date[] createDates) + { + return toAjax(sgFeedPlanService.deleteSgFeedPlanByCreateDates(createDates)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFormulaListController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFormulaListController.java new file mode 100644 index 0000000..fb6a83b --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFormulaListController.java @@ -0,0 +1,106 @@ +package com.zhyc.module.feed.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.zhyc.common.annotation.Log; +import com.zhyc.common.core.controller.BaseController; +import com.zhyc.common.core.domain.AjaxResult; +import com.zhyc.common.enums.BusinessType; +import com.zhyc.module.feed.domain.SgFormulaList; +import com.zhyc.module.feed.service.ISgFormulaListService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 配方列表Controller + * + * @author HashMap + * @date 2025-08-09 + */ +@RestController +@RequestMapping("/feed/FormulaList") +public class SgFormulaListController extends BaseController +{ + private final ISgFormulaListService sgFormulaListService; + + public SgFormulaListController(ISgFormulaListService sgFormulaListService) { + this.sgFormulaListService = sgFormulaListService; + } + + /** + * 查询配方列表列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaList:list')") + @GetMapping("/list") + public TableDataInfo list(SgFormulaList sgFormulaList) + { + startPage(); + List list = sgFormulaListService.selectSgFormulaListList(sgFormulaList); + return getDataTable(list); + } + + /** + * 导出配方列表列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaList:export')") + @Log(title = "配方列表", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SgFormulaList sgFormulaList) + { + List list = sgFormulaListService.selectSgFormulaListList(sgFormulaList); + ExcelUtil util = new ExcelUtil<>(SgFormulaList.class); + util.exportExcel(response, list, "配方列表数据"); + } + + /** + * 获取配方列表详细信息 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaList:query')") + @GetMapping(value = "/{code}") + public AjaxResult getInfo(@PathVariable("code") Long code) + { + return success(sgFormulaListService.selectSgFormulaListByCode(code)); + } + + /** + * 新增配方列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaList:add')") + @Log(title = "配方列表", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SgFormulaList sgFormulaList) + { + return toAjax(sgFormulaListService.insertSgFormulaList(sgFormulaList)); + } + + /** + * 修改配方列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaList:edit')") + @Log(title = "配方列表", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SgFormulaList sgFormulaList) + { + return toAjax(sgFormulaListService.updateSgFormulaList(sgFormulaList)); + } + + /** + * 删除配方列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaList:remove')") + @Log(title = "配方列表", businessType = BusinessType.DELETE) + @DeleteMapping("/{codes}") + public AjaxResult remove(@PathVariable Long[] codes) + { + return toAjax(sgFormulaListService.deleteSgFormulaListByCodes(codes)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFormulaManagementController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFormulaManagementController.java new file mode 100644 index 0000000..3f33ae2 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFormulaManagementController.java @@ -0,0 +1,172 @@ +package com.zhyc.module.feed.controller; + +import java.util.List; +import java.util.Objects; +import javax.servlet.http.HttpServletResponse; + +import com.zhyc.module.feed.domain.SgFormulaList; +import com.zhyc.module.feed.service.ISgFormulaListService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.zhyc.common.annotation.Log; +import com.zhyc.common.core.controller.BaseController; +import com.zhyc.common.core.domain.AjaxResult; +import com.zhyc.common.enums.BusinessType; +import com.zhyc.module.feed.domain.SgFormulaManagement; +import com.zhyc.module.feed.service.ISgFormulaManagementService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 配方管理Controller + * + * @author HashMap + * @date 2025-08-09 + */ +@RestController +@RequestMapping("/feed/FormulaManagement") +public class SgFormulaManagementController extends BaseController { + private final ISgFormulaManagementService sgFormulaManagementService; + private final ISgFormulaListService sgFormulaListService; + + public SgFormulaManagementController(ISgFormulaManagementService sgFormulaManagementService, ISgFormulaListService sgFormulaListService) { + this.sgFormulaManagementService = sgFormulaManagementService; + this.sgFormulaListService = sgFormulaListService; + } + + /** + * 查询配方管理列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaManagement:list')") + @GetMapping("/list") + public TableDataInfo list(SgFormulaManagement sgFormulaManagement) { + startPage(); + // 非查询详情时设定BatchId为0查询配方模板 + if (null != sgFormulaManagement && !Objects.equals(sgFormulaManagement.getQueryType(), "query")) { + sgFormulaManagement.setBatchId("0"); + } + List FormulaManagement = sgFormulaManagementService.selectSgFormulaManagementList(sgFormulaManagement); + for (SgFormulaManagement sgFormulaManagementItem : FormulaManagement) { + SgFormulaManagement query = new SgFormulaManagement(); + query.setFormulaId(sgFormulaManagementItem.getFormulaId()); + query.setQueryType("Sub"); + List subFormula = sgFormulaManagementService.selectSgFormulaManagementList(query); + sgFormulaManagementItem.setSubFormulaList(subFormula); + } + return getDataTable(FormulaManagement); + } + + /** + * 导出配方管理列表 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaManagement:export')") + @Log(title = "配方管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SgFormulaManagement sgFormulaManagement) { + List list = sgFormulaManagementService.selectSgFormulaManagementList(sgFormulaManagement); + ExcelUtil util = new ExcelUtil<>(SgFormulaManagement.class); + util.exportExcel(response, list, "配方管理数据"); + } + + /** + * 获取配方管理详细信息 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaManagement:query')") + @GetMapping(value = "/{formulaId}") + public AjaxResult getInfo(@PathVariable("formulaId") String formulaId) { + return success(sgFormulaManagementService.selectSgFormulaManagementByFormulaId(formulaId)); + } + + /** + * 新增配方管理 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaManagement:add')") + @Log(title = "配方管理", businessType = BusinessType.INSERT) + @PostMapping + @Transactional(rollbackFor = Exception.class) + public AjaxResult add(@RequestBody SgFormulaManagement sgFormulaManagement) { + if (null == sgFormulaManagement) + throw new RuntimeException("ERROR: 数据为空"); + if (Objects.equals(sgFormulaManagement.getBatchId(), "0")) { + SgFormulaManagement exist = sgFormulaManagementService.selectSgFormulaManagementByFormulaId(sgFormulaManagement.getFormulaId()); + if (exist != null) { + throw new RuntimeException("WARNING: 配方编码重复,录入失败"); + } + } else { + SgFormulaManagement exist = new SgFormulaManagement(); + exist.setFormulaId(sgFormulaManagement.getFormulaId()); + exist.setBatchId(sgFormulaManagement.getBatchId()); + if (!sgFormulaManagementService.selectSgFormulaManagementList(exist).isEmpty()) { + throw new RuntimeException("WARNING: 批号重复,录入失败"); + } + } + List sgFormulaList = sgFormulaManagement.getSgFormulaList(); + for (SgFormulaList sgFormulaListItem : sgFormulaList) { + // 前端引用模板数据时会引用主键Code,在插入前置为空 + sgFormulaListItem.setCode(null); + sgFormulaListItem.setFormulaId(sgFormulaManagement.getFormulaId()); + sgFormulaListItem.setBatchId(sgFormulaManagement.getBatchId()); + sgFormulaListService.insertSgFormulaList(sgFormulaListItem); + } + return toAjax(sgFormulaManagementService.insertSgFormulaManagement(sgFormulaManagement)); + } + + /** + * 修改配方管理 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaManagement:edit')") + @Log(title = "配方管理", businessType = BusinessType.UPDATE) + @PutMapping + @Transactional(rollbackFor = Exception.class) + public AjaxResult edit(@RequestBody SgFormulaManagement sgFormulaManagement) { + List sgFormulaList = sgFormulaManagement.getSgFormulaList(); + if (null != sgFormulaManagement.getFormulaId() && null != sgFormulaManagement.getBatchId()) { + SgFormulaList delete = new SgFormulaList(); + delete.setFormulaId(sgFormulaManagement.getFormulaId()); + delete.setBatchId(sgFormulaManagement.getBatchId()); + sgFormulaListService.deleteSgFormulaListByFormulaIdAndBatchId(delete); + } else { + throw new RuntimeException("FormulaID & BatchID不能为空"); + } + + // 配方表同步更新 + for (SgFormulaList sgFormulaListItem : sgFormulaList) { + sgFormulaListItem.setBatchId(sgFormulaManagement.getBatchId()); + sgFormulaListItem.setFormulaId(sgFormulaManagement.getFormulaId()); + sgFormulaListService.insertSgFormulaList(sgFormulaListItem); + } + return toAjax(sgFormulaManagementService.updateSgFormulaManagement(sgFormulaManagement)); + } + + /** + * 删除配方管理 + */ + @PreAuthorize("@ss.hasPermi('feed:FormulaManagement:remove')") + @Log(title = "配方管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{formulaId}/{batchId}") + @Transactional(rollbackFor = Exception.class) + public AjaxResult remove(@PathVariable String formulaId, @PathVariable String batchId) { + SgFormulaManagement sgFormulaManagement = new SgFormulaManagement(); + sgFormulaManagement.setFormulaId(formulaId); + sgFormulaManagement.setBatchId(batchId); + if (sgFormulaManagement.getBatchId().equals("0")) { + sgFormulaManagement.setBatchId(null); + List list = sgFormulaManagementService.selectSgFormulaManagementList(sgFormulaManagement); + if (list.size() > 1) { + throw new RuntimeException("WARNING 该配方正被使用,无法删除"); + } + sgFormulaManagement.setBatchId(batchId); + } + // 前置检查完毕 执行删除 + sgFormulaManagement.setBatchId(batchId); + return toAjax(sgFormulaManagementService.deleteSgFormulaManagement(sgFormulaManagement)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgMaterialController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgMaterialController.java new file mode 100644 index 0000000..8f4c789 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgMaterialController.java @@ -0,0 +1,107 @@ +package com.zhyc.module.feed.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.feed.domain.SgMaterial; +import com.zhyc.module.feed.service.ISgMaterialService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 原料Controller + * + * @author HashMap + * @date 2025-08-11 + */ +@RestController +@RequestMapping("/feed/material") +public class SgMaterialController extends BaseController +{ + private final ISgMaterialService sgMaterialService; + + public SgMaterialController(ISgMaterialService sgMaterialService) { + this.sgMaterialService = sgMaterialService; + } + + /** + * 查询原料列表 + */ + @PreAuthorize("@ss.hasPermi('feed:material:list')") + @GetMapping("/list") + public TableDataInfo list(SgMaterial sgMaterial) + { + startPage(); + List list = sgMaterialService.selectSgMaterialList(sgMaterial); + return getDataTable(list); + } + + /** + * 导出原料列表 + */ + @PreAuthorize("@ss.hasPermi('feed:material:export')") + @Log(title = "原料", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SgMaterial sgMaterial) + { + List list = sgMaterialService.selectSgMaterialList(sgMaterial); + ExcelUtil util = new ExcelUtil<>(SgMaterial.class); + util.exportExcel(response, list, "原料数据"); + } + + /** + * 获取原料详细信息 + */ + @PreAuthorize("@ss.hasPermi('feed:material:query')") + @GetMapping(value = "/{materialId}") + public AjaxResult getInfo(@PathVariable("materialId") String materialId) + { + return success(sgMaterialService.selectSgMaterialByMaterialId(materialId)); + } + + /** + * 新增原料 + */ + @PreAuthorize("@ss.hasPermi('feed:material:add')") + @Log(title = "原料", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SgMaterial sgMaterial) + { + return toAjax(sgMaterialService.insertSgMaterial(sgMaterial)); + } + + /** + * 修改原料 + */ + @PreAuthorize("@ss.hasPermi('feed:material:edit')") + @Log(title = "原料", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SgMaterial sgMaterial) + { + return toAjax(sgMaterialService.updateSgMaterial(sgMaterial)); + } + + /** + * 删除原料 + */ + @PreAuthorize("@ss.hasPermi('feed:material:remove')") + @Log(title = "原料", businessType = BusinessType.DELETE) + @DeleteMapping("/{materialIds}") + public AjaxResult remove(@PathVariable String[] materialIds) + { + return toAjax(sgMaterialService.deleteSgMaterialByMaterialIds(materialIds)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedPlan.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedPlan.java new file mode 100644 index 0000000..596eac2 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedPlan.java @@ -0,0 +1,132 @@ +package com.zhyc.module.feed.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +/** + * 饲喂计划对象 sg_feed_plan + * + * @author HashMap + * @date 2025-08-08 + */ +@Setter +@Getter +public class SgFeedPlan extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 创建日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date createDate; + + /** 配方编码 */ + @Excel(name = "配方编码") + private String formulaId; + + /** 羊舍 */ + @Excel(name = "羊舍") + private Long sheepHouseId; + + /** 羊只数量 */ + @Excel(name = "羊只数量") + private Long sheepCount; + + /** 日均计划量 */ + @Excel(name = "日均计划量") + private Long planDailySize; + + /** 计划量(早) */ + @Excel(name = "计划量(早)") + private Long planMorningSize; + + /** 计划总量(早) */ + @Excel(name = "计划总量(早)") + private Long planMorningTotal; + + /** 饲喂比例(早) */ + @Excel(name = "饲喂比例(早)") + private Long ratioMorning; + + /** 实际量(早) */ + @Excel(name = "实际量(早)") + private Long actualMorningSize; + + /** 计划量(中) */ + @Excel(name = "计划量(中)") + private Long planNoonSize; + + /** 计划总量(中) */ + @Excel(name = "计划总量(中)") + private Long planNoonTotal; + + /** 实际量(中) */ + @Excel(name = "实际量(中)") + private Long actualNoonSize; + + /** 饲喂比例(中) */ + @Excel(name = "饲喂比例(中)") + private Long ratioNoon; + + /** 计划量(下) */ + @Excel(name = "计划量(下)") + private Long planAfternoonSize; + + /** 计划总量(下) */ + @Excel(name = "计划总量(下)") + private Long planAfternoonTotal; + + /** 实际量(下) */ + @Excel(name = "实际量(下)") + private Long actualAfternoonSize; + + /** 饲喂比例(下) */ + @Excel(name = "饲喂比例(下)") + private Long ratioAfternoon; + + /** 计划饲喂总量 */ + @Excel(name = "计划饲喂总量") + private Long planFeedTotal; + + /** 饲草班人员 */ + @Excel(name = "饲草班人员") + private String zookeeper; + + /** 饲喂计划日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "饲喂计划日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date planDate; + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("createDate", getCreateDate()) + .append("formulaId", getFormulaId()) + .append("sheepHouseId", getSheepHouseId()) + .append("sheepCount", getSheepCount()) + .append("planDailySize", getPlanDailySize()) + .append("planMorningSize", getPlanMorningSize()) + .append("planMorningTotal", getPlanMorningTotal()) + .append("ratioMorning", getRatioMorning()) + .append("actualMorningSize", getActualMorningSize()) + .append("planNoonSize", getPlanNoonSize()) + .append("planNoonTotal", getPlanNoonTotal()) + .append("actualNoonSize", getActualNoonSize()) + .append("ratioNoon", getRatioNoon()) + .append("planAfternoonSize", getPlanAfternoonSize()) + .append("planAfternoonTotal", getPlanAfternoonTotal()) + .append("actualAfternoonSize", getActualAfternoonSize()) + .append("ratioAfternoon", getRatioAfternoon()) + .append("planFeedTotal", getPlanFeedTotal()) + .append("zookeeper", getZookeeper()) + .append("planDate", getPlanDate()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaList.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaList.java new file mode 100644 index 0000000..03ab542 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaList.java @@ -0,0 +1,62 @@ +package com.zhyc.module.feed.domain; + +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +/** + * 配方列表对象 sg_formula_list + * + * @author HashMap + * @date 2025-08-09 + */ +@Setter +@Getter +public class SgFormulaList extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 序号 */ + private Long code; + + /** 配方编号 */ + private String formulaId; + + /** 配方编号 */ + private String batchId; + /** 原料编号 */ + @Excel(name = "原料编号") + private String materialId; + + /** 原料名称 */ + @Excel(name = "原料名称") + private String materialName; + + /** 比例 */ + @Excel(name = "比例") + private Long ratio; + + /** 颗粒原料 */ + @Excel(name = "颗粒原料") + private String isGranular; + + /** 补饲 */ + @Excel(name = "补饲") + private String isSupplement; + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("code", getCode()) + .append("formulaId", getFormulaId()) + .append("materialId", getMaterialId()) + .append("materialName", getMaterialName()) + .append("ratio", getRatio()) + .append("isGranular", getIsGranular()) + .append("isSupplement", getIsSupplement()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaManagement.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaManagement.java new file mode 100644 index 0000000..3fa8563 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaManagement.java @@ -0,0 +1,79 @@ +package com.zhyc.module.feed.domain; + +import java.util.Date; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +/** + * 配方管理对象 sg_formula_management + * + * @author HashMap + * @date 2025-08-09 + */ +@Setter +@Getter +public class SgFormulaManagement extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 配方编号 */ + private String formulaId; + + /** 饲养阶段 */ + @Excel(name = "饲养阶段") + private String feedStage; + + /** 批号 */ + @Excel(name = "批号") + private String batchId; + + /** 开始使用时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始使用时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date useStartDate; + + /** 结束使用时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束使用时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date useEndDate; + + /** 使用状态 */ + @Excel(name = "使用状态") + private String useState; + + /** 备注 */ + @Excel(name = "备注") + private String remark; + + /** 配方列表 */ + private List sgFormulaList; + + /** 子配方 */ + private List subFormulaList; + + /** 查询类型 * + * Sub : 子配方查询 + * query : 类型查询 + * */ + private String queryType; + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("formulaId", getFormulaId()) + .append("feedStage", getFeedStage()) + .append("batchId", getBatchId()) + .append("useStartDate", getUseStartDate()) + .append("useEndDate", getUseEndDate()) + .append("useState", getUseState()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgMaterial.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgMaterial.java new file mode 100644 index 0000000..a9634be --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgMaterial.java @@ -0,0 +1,15 @@ +package com.zhyc.module.feed.domain; + +import com.zhyc.common.core.domain.BaseEntity; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class SgMaterial extends BaseEntity { + private static final long serialVersionUID = 1L; + + private String materialId; + private String materialName; + private String isGranular; +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedPlanMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedPlanMapper.java new file mode 100644 index 0000000..7ea4493 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedPlanMapper.java @@ -0,0 +1,64 @@ +package com.zhyc.module.feed.mapper; + +import java.util.Date; +import java.util.List; +import com.zhyc.module.feed.domain.SgFeedPlan; +import org.apache.ibatis.annotations.Mapper; + +/** + * 饲喂计划Mapper接口 + * + * @author HashMap + * @date 2025-08-08 + */ +@Mapper +public interface SgFeedPlanMapper +{ + /** + * 查询饲喂计划 + * + * @param createDate 饲喂计划主键 + * @return 饲喂计划 + */ + SgFeedPlan selectSgFeedPlanByCreateDate(Date createDate); + + /** + * 查询饲喂计划列表 + * + * @param sgFeedPlan 饲喂计划 + * @return 饲喂计划集合 + */ + List selectSgFeedPlanList(SgFeedPlan sgFeedPlan); + + /** + * 新增饲喂计划 + * + * @param sgFeedPlan 饲喂计划 + * @return 结果 + */ + int insertSgFeedPlan(SgFeedPlan sgFeedPlan); + + /** + * 修改饲喂计划 + * + * @param sgFeedPlan 饲喂计划 + * @return 结果 + */ + int updateSgFeedPlan(SgFeedPlan sgFeedPlan); + + /** + * 删除饲喂计划 + * + * @param createDate 饲喂计划主键 + * @return 结果 + */ + int deleteSgFeedPlanByCreateDate(Date createDate); + + /** + * 批量删除饲喂计划 + * + * @param createDates 需要删除的数据主键集合 + * @return 结果 + */ + int deleteSgFeedPlanByCreateDates(Date[] createDates); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFormulaListMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFormulaListMapper.java new file mode 100644 index 0000000..4d13b9e --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFormulaListMapper.java @@ -0,0 +1,71 @@ +package com.zhyc.module.feed.mapper; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFormulaList; +import org.apache.ibatis.annotations.Mapper; + +/** + * 配方列表Mapper接口 + * + * @author HashMap + * @date 2025-08-09 + */ +@Mapper +public interface SgFormulaListMapper +{ + /** + * 查询配方列表 + * + * @param code 配方列表主键 + * @return 配方列表 + */ + SgFormulaList selectSgFormulaListByCode(Long code); + + /** + * 查询配方列表列表 + * + * @param sgFormulaList 配方列表 + * @return 配方列表集合 + */ + List selectSgFormulaListList(SgFormulaList sgFormulaList); + + /** + * 新增配方列表 + * + * @param sgFormulaList 配方列表 + * @return 结果 + */ + int insertSgFormulaList(SgFormulaList sgFormulaList); + + /** + * 修改配方列表 + * + * @param sgFormulaList 配方列表 + * @return 结果 + */ + int updateSgFormulaList(SgFormulaList sgFormulaList); + + /** + * 删除配方列表 + * + * @param code 配方列表主键 + * @return 结果 + */ + int deleteSgFormulaListByCode(Long code); + + /** + * 批量删除配方列表 + * + * @param codes 需要删除的数据主键集合 + * @return 结果 + */ + int deleteSgFormulaListByCodes(Long[] codes); + + /** + * 批量删除配方列表 + * + * @param sgFormulaList 参数实体 + * @return 结果 + */ + int deleteSgFormulaListByFormulaIdAndBatchId(SgFormulaList sgFormulaList); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFormulaManagementMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFormulaManagementMapper.java new file mode 100644 index 0000000..ff782e9 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFormulaManagementMapper.java @@ -0,0 +1,65 @@ +package com.zhyc.module.feed.mapper; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFormulaManagement; +import org.apache.ibatis.annotations.Mapper; + +/** + * 配方管理Mapper接口 + * + * @author HashMap + * @date 2025-08-09 + */ +@Mapper +public interface SgFormulaManagementMapper +{ + /** + * 查询配方管理 + * + * @param formulaId 配方管理主键 + * @return 配方管理 + */ + SgFormulaManagement selectSgFormulaManagementByFormulaId(String formulaId); + + /** + * 查询配方管理列表 + * + * @param sgFormulaManagement 配方管理 + * @return 配方管理集合 + */ + List selectSgFormulaManagementList(SgFormulaManagement sgFormulaManagement); + + /** + * 新增配方管理 + * + * @param sgFormulaManagement 配方管理 + * @return 结果 + */ + int insertSgFormulaManagement(SgFormulaManagement sgFormulaManagement); + + /** + * 修改配方管理 + * + * @param sgFormulaManagement 配方管理 + * @return 结果 + */ + int updateSgFormulaManagement(SgFormulaManagement sgFormulaManagement); + + /** + * 删除配方管理 + * + * @param formulaId 配方管理主键 + * @return 结果 + */ + int deleteSgFormulaManagementByFormulaId(String formulaId); + + /** + * 批量删除配方管理 + * + * @param formulaIds 需要删除的数据主键集合 + * @return 结果 + */ + int deleteSgFormulaManagementByFormulaIds(String[] formulaIds); + + int deleteSgFormulaManagement(SgFormulaManagement sgFormulaManagement); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgMaterialMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgMaterialMapper.java new file mode 100644 index 0000000..a7a3d70 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgMaterialMapper.java @@ -0,0 +1,63 @@ +package com.zhyc.module.feed.mapper; + +import java.util.List; +import com.zhyc.module.feed.domain.SgMaterial; +import org.apache.ibatis.annotations.Mapper; + +/** + * 原料Mapper接口 + * + * @author HashMap + * @date 2025-08-11 + */ +@Mapper +public interface SgMaterialMapper +{ + /** + * 查询原料 + * + * @param materialId 原料主键 + * @return 原料 + */ + public SgMaterial selectSgMaterialByMaterialId(String materialId); + + /** + * 查询原料列表 + * + * @param sgMaterial 原料 + * @return 原料集合 + */ + public List selectSgMaterialList(SgMaterial sgMaterial); + + /** + * 新增原料 + * + * @param sgMaterial 原料 + * @return 结果 + */ + public int insertSgMaterial(SgMaterial sgMaterial); + + /** + * 修改原料 + * + * @param sgMaterial 原料 + * @return 结果 + */ + public int updateSgMaterial(SgMaterial sgMaterial); + + /** + * 删除原料 + * + * @param materialId 原料主键 + * @return 结果 + */ + public int deleteSgMaterialByMaterialId(String materialId); + + /** + * 批量删除原料 + * + * @param materialIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSgMaterialByMaterialIds(String[] materialIds); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedPlanService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedPlanService.java new file mode 100644 index 0000000..3b172e0 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedPlanService.java @@ -0,0 +1,62 @@ +package com.zhyc.module.feed.service; + +import java.util.Date; +import java.util.List; +import com.zhyc.module.feed.domain.SgFeedPlan; + +/** + * 饲喂计划Service接口 + * + * @author HashMap + * @date 2025-08-08 + */ +public interface ISgFeedPlanService +{ + /** + * 查询饲喂计划 + * + * @param createDate 饲喂计划主键 + * @return 饲喂计划 + */ + SgFeedPlan selectSgFeedPlanByCreateDate(Date createDate); + + /** + * 查询饲喂计划列表 + * + * @param sgFeedPlan 饲喂计划 + * @return 饲喂计划集合 + */ + List selectSgFeedPlanList(SgFeedPlan sgFeedPlan); + + /** + * 新增饲喂计划 + * + * @param sgFeedPlan 饲喂计划 + * @return 结果 + */ + int insertSgFeedPlan(SgFeedPlan sgFeedPlan); + + /** + * 修改饲喂计划 + * + * @param sgFeedPlan 饲喂计划 + * @return 结果 + */ + int updateSgFeedPlan(SgFeedPlan sgFeedPlan); + + /** + * 批量删除饲喂计划 + * + * @param createDates 需要删除的饲喂计划主键集合 + * @return 结果 + */ + int deleteSgFeedPlanByCreateDates(Date[] createDates); + + /** + * 删除饲喂计划信息 + * + * @param createDate 饲喂计划主键 + * @return 结果 + */ + int deleteSgFeedPlanByCreateDate(Date createDate); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFormulaListService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFormulaListService.java new file mode 100644 index 0000000..288308d --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFormulaListService.java @@ -0,0 +1,63 @@ +package com.zhyc.module.feed.service; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFormulaList; + +/** + * 配方列表Service接口 + * + * @author HashMap + * @date 2025-08-09 + */ +public interface ISgFormulaListService +{ + /** + * 查询配方列表 + * + * @param code 配方列表主键 + * @return 配方列表 + */ + SgFormulaList selectSgFormulaListByCode(Long code); + + /** + * 查询配方列表列表 + * + * @param sgFormulaList 配方列表 + * @return 配方列表集合 + */ + List selectSgFormulaListList(SgFormulaList sgFormulaList); + + /** + * 新增配方列表 + * + * @param sgFormulaList 配方列表 + * @return 结果 + */ + int insertSgFormulaList(SgFormulaList sgFormulaList); + + /** + * 修改配方列表 + * + * @param sgFormulaList 配方列表 + * @return 结果 + */ + int updateSgFormulaList(SgFormulaList sgFormulaList); + + /** + * 批量删除配方列表 + * + * @param codes 需要删除的配方列表主键集合 + * @return 结果 + */ + int deleteSgFormulaListByCodes(Long[] codes); + + /** + * 删除配方列表信息 + * + * @param code 配方列表主键 + * @return 结果 + */ + int deleteSgFormulaListByCode(Long code); + + int deleteSgFormulaListByFormulaIdAndBatchId(SgFormulaList sgFormulaList); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFormulaManagementService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFormulaManagementService.java new file mode 100644 index 0000000..55d0156 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFormulaManagementService.java @@ -0,0 +1,66 @@ +package com.zhyc.module.feed.service; + +import java.util.List; +import com.zhyc.module.feed.domain.SgFormulaManagement; + +/** + * 配方管理Service接口 + * + * @author HashMap + * @date 2025-08-09 + */ +public interface ISgFormulaManagementService +{ + /** + * 查询配方管理 + * + * @param formulaId 配方管理主键 + * @return 配方管理 + */ + SgFormulaManagement selectSgFormulaManagementByFormulaId(String formulaId); + + /** + * 查询配方管理列表 + * + * @param sgFormulaManagement 配方管理 + * @return 配方管理集合 + */ + List selectSgFormulaManagementList(SgFormulaManagement sgFormulaManagement); + + /** + * 新增配方管理 + * + * @param sgFormulaManagement 配方管理 + * @return 结果 + */ + int insertSgFormulaManagement(SgFormulaManagement sgFormulaManagement); + + /** + * 修改配方管理 + * + * @param sgFormulaManagement 配方管理 + * @return 结果 + */ + int updateSgFormulaManagement(SgFormulaManagement sgFormulaManagement); + + /** + * 批量删除配方管理 + * + * @param formulaIds 需要删除的配方管理主键集合 + * @return 结果 + */ + int deleteSgFormulaManagementByFormulaIds(String[] formulaIds); + + /** + * 删除配方管理信息 + * + * @param formulaId 配方管理主键 + * @return 结果 + */ + int deleteSgFormulaManagementByFormulaId(String formulaId); + + /*** + * 删除配方管理信息 + */ + int deleteSgFormulaManagement(SgFormulaManagement sgFormulaManagement); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgMaterialService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgMaterialService.java new file mode 100644 index 0000000..ba1e6ac --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgMaterialService.java @@ -0,0 +1,61 @@ +package com.zhyc.module.feed.service; + +import java.util.List; +import com.zhyc.module.feed.domain.SgMaterial; + +/** + * 原料Service接口 + * + * @author HashMap + * @date 2025-08-11 + */ +public interface ISgMaterialService +{ + /** + * 查询原料 + * + * @param materialId 原料主键 + * @return 原料 + */ + SgMaterial selectSgMaterialByMaterialId(String materialId); + + /** + * 查询原料列表 + * + * @param sgMaterial 原料 + * @return 原料集合 + */ + List selectSgMaterialList(SgMaterial sgMaterial); + + /** + * 新增原料 + * + * @param sgMaterial 原料 + * @return 结果 + */ + int insertSgMaterial(SgMaterial sgMaterial); + + /** + * 修改原料 + * + * @param sgMaterial 原料 + * @return 结果 + */ + int updateSgMaterial(SgMaterial sgMaterial); + + /** + * 批量删除原料 + * + * @param materialIds 需要删除的原料主键集合 + * @return 结果 + */ + int deleteSgMaterialByMaterialIds(String[] materialIds); + + /** + * 删除原料信息 + * + * @param materialId 原料主键 + * @return 结果 + */ + int deleteSgMaterialByMaterialId(String materialId); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedPlanServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedPlanServiceImpl.java new file mode 100644 index 0000000..937cd32 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedPlanServiceImpl.java @@ -0,0 +1,99 @@ +package com.zhyc.module.feed.service.impl; + +import java.util.Date; +import java.util.List; + +import org.springframework.stereotype.Service; +import com.zhyc.module.feed.mapper.SgFeedPlanMapper; +import com.zhyc.module.feed.domain.SgFeedPlan; +import com.zhyc.module.feed.service.ISgFeedPlanService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 饲喂计划Service业务层处理 + * + * @author HashMap + * @date 2025-08-08 + */ +@Service +@Transactional(rollbackFor=Exception.class) +public class SgFeedPlanServiceImpl implements ISgFeedPlanService +{ + private final SgFeedPlanMapper sgFeedPlanMapper; + + public SgFeedPlanServiceImpl(SgFeedPlanMapper sgFeedPlanMapper) { + this.sgFeedPlanMapper = sgFeedPlanMapper; + } + + /** + * 查询饲喂计划 + * + * @param createDate 饲喂计划主键 + * @return 饲喂计划 + */ + @Override + public SgFeedPlan selectSgFeedPlanByCreateDate(Date createDate) + { + return sgFeedPlanMapper.selectSgFeedPlanByCreateDate(createDate); + } + + /** + * 查询饲喂计划列表 + * + * @param sgFeedPlan 饲喂计划 + * @return 饲喂计划 + */ + @Override + public List selectSgFeedPlanList(SgFeedPlan sgFeedPlan) + { + return sgFeedPlanMapper.selectSgFeedPlanList(sgFeedPlan); + } + + /** + * 新增饲喂计划 + * + * @param sgFeedPlan 饲喂计划 + * @return 结果 + */ + @Override + public int insertSgFeedPlan(SgFeedPlan sgFeedPlan) + { + return sgFeedPlanMapper.insertSgFeedPlan(sgFeedPlan); + } + + /** + * 修改饲喂计划 + * + * @param sgFeedPlan 饲喂计划 + * @return 结果 + */ + @Override + public int updateSgFeedPlan(SgFeedPlan sgFeedPlan) + { + return sgFeedPlanMapper.updateSgFeedPlan(sgFeedPlan); + } + + /** + * 批量删除饲喂计划 + * + * @param createDates 需要删除的饲喂计划主键 + * @return 结果 + */ + @Override + public int deleteSgFeedPlanByCreateDates(Date[] createDates) + { + return sgFeedPlanMapper.deleteSgFeedPlanByCreateDates(createDates); + } + + /** + * 删除饲喂计划信息 + * + * @param createDate 饲喂计划主键 + * @return 结果 + */ + @Override + public int deleteSgFeedPlanByCreateDate(Date createDate) + { + return sgFeedPlanMapper.deleteSgFeedPlanByCreateDate(createDate); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFormulaListServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFormulaListServiceImpl.java new file mode 100644 index 0000000..f26eb3a --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFormulaListServiceImpl.java @@ -0,0 +1,97 @@ +package com.zhyc.module.feed.service.impl; + +import java.util.List; +import java.util.Objects; + +import org.springframework.stereotype.Service; +import com.zhyc.module.feed.mapper.SgFormulaListMapper; +import com.zhyc.module.feed.domain.SgFormulaList; +import com.zhyc.module.feed.service.ISgFormulaListService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 配方列表Service业务层处理 + * + * @author HashMap + * @date 2025-08-09 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class SgFormulaListServiceImpl implements ISgFormulaListService { + private final SgFormulaListMapper sgFormulaListMapper; + + public SgFormulaListServiceImpl(SgFormulaListMapper sgFormulaListMapper) { + this.sgFormulaListMapper = sgFormulaListMapper; + } + + /** + * 查询配方列表 + * + * @param code 配方列表主键 + * @return 配方列表 + */ + @Override + public SgFormulaList selectSgFormulaListByCode(Long code) { + return sgFormulaListMapper.selectSgFormulaListByCode(code); + } + + /** + * 查询配方列表列表 + * + * @param sgFormulaList 配方列表 + * @return 配方列表 + */ + @Override + public List selectSgFormulaListList(SgFormulaList sgFormulaList) { + return sgFormulaListMapper.selectSgFormulaListList(sgFormulaList); + } + + /** + * 新增配方列表 + * + * @param sgFormulaList 配方列表 + * @return 结果 + */ + @Override + public int insertSgFormulaList(SgFormulaList sgFormulaList) { + return sgFormulaListMapper.insertSgFormulaList(sgFormulaList); + } + + /** + * 修改配方列表 + * + * @param sgFormulaList 配方列表 + * @return 结果 + */ + @Override + public int updateSgFormulaList(SgFormulaList sgFormulaList) { + return sgFormulaListMapper.updateSgFormulaList(sgFormulaList); + } + + /** + * 批量删除配方列表 + * + * @param codes 需要删除的配方列表主键 + * @return 结果 + */ + @Override + public int deleteSgFormulaListByCodes(Long[] codes) { + return sgFormulaListMapper.deleteSgFormulaListByCodes(codes); + } + + /** + * 删除配方列表信息 + * + * @param code 配方列表主键 + * @return 结果 + */ + @Override + public int deleteSgFormulaListByCode(Long code) { + return sgFormulaListMapper.deleteSgFormulaListByCode(code); + } + + @Override + public int deleteSgFormulaListByFormulaIdAndBatchId(SgFormulaList sgFormulaList) { + return sgFormulaListMapper.deleteSgFormulaListByFormulaIdAndBatchId(sgFormulaList); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFormulaManagementServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFormulaManagementServiceImpl.java new file mode 100644 index 0000000..b07028f --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFormulaManagementServiceImpl.java @@ -0,0 +1,135 @@ +package com.zhyc.module.feed.service.impl; + +import java.util.Iterator; +import java.util.List; +import java.util.Objects; + +import com.zhyc.module.feed.domain.SgFormulaList; +import com.zhyc.module.feed.mapper.SgFormulaListMapper; +import org.springframework.stereotype.Service; +import com.zhyc.module.feed.mapper.SgFormulaManagementMapper; +import com.zhyc.module.feed.domain.SgFormulaManagement; +import com.zhyc.module.feed.service.ISgFormulaManagementService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 配方管理Service业务层处理 + * + * @author HashMap + * @date 2025-08-09 + */ +@Service +public class SgFormulaManagementServiceImpl implements ISgFormulaManagementService { + private final SgFormulaManagementMapper sgFormulaManagementMapper; + private final SgFormulaListMapper sgFormulaListMapper; + + public SgFormulaManagementServiceImpl(SgFormulaManagementMapper sgFormulaManagementMapper, SgFormulaListMapper sgFormulaListMapper) { + this.sgFormulaManagementMapper = sgFormulaManagementMapper; + this.sgFormulaListMapper = sgFormulaListMapper; + } + + /** + * 查询配方管理 + * + * @param formulaId 配方管理主键 + * @return 配方管理 + */ + @Override + public SgFormulaManagement selectSgFormulaManagementByFormulaId(String formulaId) { + return sgFormulaManagementMapper.selectSgFormulaManagementByFormulaId(formulaId); + } + + /** + * 查询配方管理列表 + * + * @param sgFormulaManagement 配方管理 + * @return 配方管理 + */ + @Override + public List selectSgFormulaManagementList(SgFormulaManagement sgFormulaManagement) { + List sgFormulaManagements = + sgFormulaManagementMapper.selectSgFormulaManagementList(sgFormulaManagement); + + Iterator iterator = sgFormulaManagements.iterator(); + while (iterator.hasNext()) { + SgFormulaManagement formulaManagement = iterator.next(); + // 子查询中去除重复的父项 + if (formulaManagement != null + && sgFormulaManagement.getQueryType() != null + && sgFormulaManagement.getQueryType().equals("Sub") + && Objects.equals(formulaManagement.getBatchId(), "0")) { + iterator.remove(); // 安全删除 + continue; // 删除后跳过本次循环 + } + // 绑定配方列表 + if (formulaManagement != null + && formulaManagement.getFormulaId() != null + && formulaManagement.getBatchId() != null) { + SgFormulaList sgFormulaList = new SgFormulaList(); + sgFormulaList.setFormulaId(formulaManagement.getFormulaId()); + sgFormulaList.setBatchId(formulaManagement.getBatchId()); + List formulaLists = + sgFormulaListMapper.selectSgFormulaListList(sgFormulaList); + formulaManagement.setSgFormulaList(formulaLists); + } + } + + return sgFormulaManagements; + } + + + /** + * 新增配方管理 + * + * @param sgFormulaManagement 配方管理 + * @return 结果 + */ + @Override + public int insertSgFormulaManagement(SgFormulaManagement sgFormulaManagement) { + return sgFormulaManagementMapper.insertSgFormulaManagement(sgFormulaManagement); + } + + /** + * 修改配方管理 + * + * @param sgFormulaManagement 配方管理 + * @return 结果 + */ + @Override + public int updateSgFormulaManagement(SgFormulaManagement sgFormulaManagement) { + return sgFormulaManagementMapper.updateSgFormulaManagement(sgFormulaManagement); + } + + /** + * 批量删除配方管理 + * + * @param formulaIds 需要删除的配方管理主键 + * @return 结果 + */ + @Override + public int deleteSgFormulaManagementByFormulaIds(String[] formulaIds) { + return sgFormulaManagementMapper.deleteSgFormulaManagementByFormulaIds(formulaIds); + } + + /** + * 删除配方管理信息 + * + * @param formulaId 配方管理主键 + * @return 结果 + */ + @Override + public int deleteSgFormulaManagementByFormulaId(String formulaId) { + return sgFormulaManagementMapper.deleteSgFormulaManagementByFormulaId(formulaId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteSgFormulaManagement(SgFormulaManagement sgFormulaManagement) { + // 删除关联配方表 + SgFormulaList sgFormulaList = new SgFormulaList(); + sgFormulaList.setFormulaId(sgFormulaManagement.getFormulaId()); + sgFormulaList.setBatchId(sgFormulaManagement.getBatchId()); + sgFormulaListMapper.deleteSgFormulaListByFormulaIdAndBatchId(sgFormulaList); + return sgFormulaManagementMapper.deleteSgFormulaManagement(sgFormulaManagement); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgMaterialServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgMaterialServiceImpl.java new file mode 100644 index 0000000..b858ae3 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgMaterialServiceImpl.java @@ -0,0 +1,96 @@ +package com.zhyc.module.feed.service.impl; + +import java.util.List; + +import org.springframework.stereotype.Service; +import com.zhyc.module.feed.mapper.SgMaterialMapper; +import com.zhyc.module.feed.domain.SgMaterial; +import com.zhyc.module.feed.service.ISgMaterialService; + +/** + * 原料Service业务层处理 + * + * @author HashMap + * @date 2025-08-11 + */ +@Service +public class SgMaterialServiceImpl implements ISgMaterialService +{ + private final SgMaterialMapper sgMaterialMapper; + + public SgMaterialServiceImpl(SgMaterialMapper sgMaterialMapper) { + this.sgMaterialMapper = sgMaterialMapper; + } + + /** + * 查询原料 + * + * @param materialId 原料主键 + * @return 原料 + */ + @Override + public SgMaterial selectSgMaterialByMaterialId(String materialId) + { + return sgMaterialMapper.selectSgMaterialByMaterialId(materialId); + } + + /** + * 查询原料列表 + * + * @param sgMaterial 原料 + * @return 原料 + */ + @Override + public List selectSgMaterialList(SgMaterial sgMaterial) + { + return sgMaterialMapper.selectSgMaterialList(sgMaterial); + } + + /** + * 新增原料 + * + * @param sgMaterial 原料 + * @return 结果 + */ + @Override + public int insertSgMaterial(SgMaterial sgMaterial) + { + return sgMaterialMapper.insertSgMaterial(sgMaterial); + } + + /** + * 修改原料 + * + * @param sgMaterial 原料 + * @return 结果 + */ + @Override + public int updateSgMaterial(SgMaterial sgMaterial) + { + return sgMaterialMapper.updateSgMaterial(sgMaterial); + } + + /** + * 批量删除原料 + * + * @param materialIds 需要删除的原料主键 + * @return 结果 + */ + @Override + public int deleteSgMaterialByMaterialIds(String[] materialIds) + { + return sgMaterialMapper.deleteSgMaterialByMaterialIds(materialIds); + } + + /** + * 删除原料信息 + * + * @param materialId 原料主键 + * @return 结果 + */ + @Override + public int deleteSgMaterialByMaterialId(String materialId) + { + return sgMaterialMapper.deleteSgMaterialByMaterialId(materialId); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/stock/service/impl/WzStockInServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/stock/service/impl/WzStockInServiceImpl.java index 7632654..7af887f 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/stock/service/impl/WzStockInServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/stock/service/impl/WzStockInServiceImpl.java @@ -107,13 +107,15 @@ public class WzStockInServiceImpl implements IWzStockInService { int successNum = 0; int failureNum = 0; int sameNum = 0; + boolean emptyTable = true; StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); try { WzStockIn earliestStockIn = wzStockInMapper.getEarliestStockIn(); + if (null != earliestStockIn) emptyTable = false; System.out.println(earliestStockIn); for (WzStockIn wzStockIn : StockInList) { - if (earliestStockIn.getDocDate().getTime() >= wzStockIn.getDocDate().getTime()) { + if (!emptyTable && earliestStockIn.getDocDate().getTime() >= wzStockIn.getDocDate().getTime()) { sameNum++; continue; } diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFeedPlanMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFeedPlanMapper.xml new file mode 100644 index 0000000..fe2b6e3 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/feed/SgFeedPlanMapper.xml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select create_date, formula_id, sheep_house_id, sheep_count, plan_daily_size, plan_morning_size, plan_morning_total, ratio_morning, actual_morning_size, plan_noon_size, plan_noon_total, actual_noon_size, ratio_noon, plan_afternoon_size, plan_afternoon_total, actual_afternoon_size, ratio_afternoon, plan_feed_total, zookeeper, plan_date, remark from sg_feed_plan + + + + + + + + insert into sg_feed_plan + + create_date, + formula_id, + sheep_house_id, + sheep_count, + plan_daily_size, + plan_morning_size, + plan_morning_total, + ratio_morning, + actual_morning_size, + plan_noon_size, + plan_noon_total, + actual_noon_size, + ratio_noon, + plan_afternoon_size, + plan_afternoon_total, + actual_afternoon_size, + ratio_afternoon, + plan_feed_total, + zookeeper, + plan_date, + remark, + + + #{createDate}, + #{formulaId}, + #{sheepHouseId}, + #{sheepCount}, + #{planDailySize}, + #{planMorningSize}, + #{planMorningTotal}, + #{ratioMorning}, + #{actualMorningSize}, + #{planNoonSize}, + #{planNoonTotal}, + #{actualNoonSize}, + #{ratioNoon}, + #{planAfternoonSize}, + #{planAfternoonTotal}, + #{actualAfternoonSize}, + #{ratioAfternoon}, + #{planFeedTotal}, + #{zookeeper}, + #{planDate}, + #{remark}, + + + + + update sg_feed_plan + + formula_id = #{formulaId}, + sheep_house_id = #{sheepHouseId}, + sheep_count = #{sheepCount}, + plan_daily_size = #{planDailySize}, + plan_morning_size = #{planMorningSize}, + plan_morning_total = #{planMorningTotal}, + ratio_morning = #{ratioMorning}, + actual_morning_size = #{actualMorningSize}, + plan_noon_size = #{planNoonSize}, + plan_noon_total = #{planNoonTotal}, + actual_noon_size = #{actualNoonSize}, + ratio_noon = #{ratioNoon}, + plan_afternoon_size = #{planAfternoonSize}, + plan_afternoon_total = #{planAfternoonTotal}, + actual_afternoon_size = #{actualAfternoonSize}, + ratio_afternoon = #{ratioAfternoon}, + plan_feed_total = #{planFeedTotal}, + zookeeper = #{zookeeper}, + plan_date = #{planDate}, + remark = #{remark}, + + where create_date = #{createDate} + + + + delete from sg_feed_plan where create_date = #{createDate} + + + + delete from sg_feed_plan where create_date in + + #{createDate} + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFormulaListMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFormulaListMapper.xml new file mode 100644 index 0000000..f422ccb --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/feed/SgFormulaListMapper.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + select code, formula_id, material_id, material_name, ratio, is_granular, is_supplement from sg_formula_list + + + + + + + + insert into sg_formula_list + + code, + formula_id, + batch_id, + material_id, + material_name, + ratio, + is_granular, + is_supplement, + + + #{code}, + #{formulaId}, + #{batchId}, + #{materialId}, + #{materialName}, + #{ratio}, + #{isGranular}, + #{isSupplement}, + + + + + update sg_formula_list + + formula_id = #{formulaId}, + material_id = #{materialId}, + material_name = #{materialName}, + ratio = #{ratio}, + is_granular = #{isGranular}, + is_supplement = #{isSupplement}, + + where code = #{code} + + + + delete from sg_formula_list where code = #{code} + + + + delete from sg_formula_list where code in + + #{code} + + + + + DELETE FROM sg_formula_list WHERE formula_id = #{formulaId} AND batch_id = #{batchId} + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFormulaManagementMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFormulaManagementMapper.xml new file mode 100644 index 0000000..17602f1 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/feed/SgFormulaManagementMapper.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + select formula_id, feed_stage, batch_id, use_start_date, use_end_date, use_state, remark from sg_formula_management + + + + + + + + insert into sg_formula_management + + formula_id, + feed_stage, + batch_id, + use_start_date, + use_end_date, + use_state, + remark, + + + #{formulaId}, + #{feedStage}, + #{batchId}, + #{useStartDate}, + #{useEndDate}, + #{useState}, + #{remark}, + + + + + update sg_formula_management + + feed_stage = #{feedStage}, + use_start_date = #{useStartDate}, + use_end_date = #{useEndDate}, + use_state = #{useState}, + remark = #{remark}, + + where formula_id = #{formulaId} AND batch_id = #{batchId} + + + + delete from sg_formula_management where formula_id = #{formulaId} + + + + delete from sg_formula_management where formula_id in + + #{formulaId} + + + + delete from sg_formula_management where formula_id = #{formulaId} and batch_id = #{batchId} + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/feed/SgMaterialMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgMaterialMapper.xml new file mode 100644 index 0000000..f4960c9 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/feed/SgMaterialMapper.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + select material_id, material_name, is_granular from sg_material + + + + + + + + insert into sg_material + + material_id, + material_name, + is_granular, + + + #{materialId}, + #{materialName}, + #{isGranular}, + + + + + update sg_material + + material_name = #{materialName}, + is_granular = #{isGranular}, + + where material_id = #{materialId} + + + + delete from sg_material where material_id = #{materialId} + + + + delete from sg_material where material_id in + + #{materialId} + + + \ No newline at end of file From c9f05d722f649726e5661e90e129757f55eb4c68 Mon Sep 17 00:00:00 2001 From: ll <1079863556@qq.com> Date: Wed, 13 Aug 2025 18:55:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A5=B6=E4=BA=A7=E9=87=8F=E5=88=86?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NpSheepMilkAnalysisController.java | 51 +--- .../domain/NpSheepMilkAnalysis.java | 42 ++- .../mapper/NpSheepMilkAnalysisMapper.java | 29 +- .../service/INpSheepMilkAnalysisService.java | 10 +- .../impl/NpSheepMilkAnalysisServiceImpl.java | 277 ++++++++++++++++-- .../NpSheepMilkAnalysisMapper.xml | 180 +++--------- 6 files changed, 380 insertions(+), 209 deletions(-) diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpSheepMilkAnalysisController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpSheepMilkAnalysisController.java index 0c2955d..3e4f07a 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpSheepMilkAnalysisController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpSheepMilkAnalysisController.java @@ -8,12 +8,14 @@ import com.zhyc.common.enums.BusinessType; import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis; import com.zhyc.module.dairyProducts.service.INpSheepMilkAnalysisService; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; +/** + * 只保留:分页列表(只读) + 单条查询 + 导出 + */ @RestController @RequestMapping("/dairyProducts/sheepMilkAnalysis") public class NpSheepMilkAnalysisController extends BaseController { @@ -22,58 +24,33 @@ public class NpSheepMilkAnalysisController extends BaseController { private INpSheepMilkAnalysisService npSheepMilkAnalysisService; /** - * 查询奶产量分析列表 + * 查询奶产量分析列表(只读,分页) + * 支持参数 manageEarTag(耳号模糊) 和 screenDays(筛选天数) */ @GetMapping("/list") public TableDataInfo list(NpSheepMilkAnalysis analysis) { - startPage(); + startPage(); // 使用 PageHelper 分页(注意 service 中第一个 DB 调用是 distinct sheep id) List list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis); return getDataTable(list); } /** - * 获取单个分析记录详细信息 + * 获取单个分析记录详细信息(按 sheepId) */ - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) { - return AjaxResult.success(npSheepMilkAnalysisService.selectNpSheepMilkAnalysisById(id)); - } - /** - * 新增奶产量分析记录 - */ - @Log(title = "奶产量分析", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody NpSheepMilkAnalysis analysis) { - return toAjax(npSheepMilkAnalysisService.insertNpSheepMilkAnalysis(analysis)); + @GetMapping(value = "/{sheepId}") + public AjaxResult getInfo(@PathVariable("sheepId") String sheepId) { + return AjaxResult.success(npSheepMilkAnalysisService.selectNpSheepMilkAnalysisBySheepId(sheepId)); } /** - * 修改奶产量分析记录 + * 导出奶产量分析记录(Excel) + * 支持 manageEarTag 与 screenDays 两个查询条件 */ - @Log(title = "奶产量分析", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody NpSheepMilkAnalysis analysis) { - return toAjax(npSheepMilkAnalysisService.updateNpSheepMilkAnalysis(analysis)); - } - - /** - * 删除奶产量分析记录 - */ - @Log(title = "奶产量分析", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) { - return toAjax(npSheepMilkAnalysisService.deleteNpSheepMilkAnalysisByIds(ids)); - } - - /** - * 导出奶产量分析记录 - */ - @Log(title = "奶产量分析", businessType = BusinessType.EXPORT) + @Log(title = "奶产量分析 导出", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(NpSheepMilkAnalysis analysis) { List list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis); ExcelUtil util = new ExcelUtil<>(NpSheepMilkAnalysis.class); - return util.exportExcel(list, "奶产量分析数据"); + return util.exportExcel(list, "羊奶产量分析数据"); } } - diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpSheepMilkAnalysis.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpSheepMilkAnalysis.java index 05972f6..0573a0d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpSheepMilkAnalysis.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpSheepMilkAnalysis.java @@ -1,34 +1,64 @@ package com.zhyc.module.dairyProducts.domain; import java.util.Date; + public class NpSheepMilkAnalysis { + // 唯一键(可用于前端 row-key) private String sheepId; + + // 耳号(从 sheep_file.bs_manage_tags) private String manageEarTag; + private String variety; + + // 最高校正胎次的挤奶开始时间 & 干奶时间 private Date milkingStartTime; private Date dryEndTime; + + // 挤奶天数(该胎次) private Integer milkingDays; + + // 前端传入的筛选天数(screenDays) + private Integer screenDays; + + // 分析天数(若你有不同命名,可忽略) private Integer analysisDays; + + // 校正后最大胎次(即校正奶量之和最大的胎次) private Integer maxParity; + + // 最高校正胎次区间内的系统奶量与校正奶量(按筛选窗口) private Double sumSystemMilk; private Double sumCorrectedMilk; + + // 校正日平均奶量(按 min(挤奶天数, 筛选天数)) private Double avgCorrectedDaily; + + // 各胎次总奶量(校正) private Double sumParity1Milk; private Double sumParity2Milk; private Double sumParity3Milk; private Double sumParity4Milk; + + // 各胎次日平均(按规则) private Double avgParity1Daily; private Double avgParity2Daily; private Double avgParity3Daily; private Double avgParity4Daily; + + // 泌乳天数(sheep_file.lactation_day) private Integer lactationDays; + + // 过去 7 / 14 / 30 日平均(系统奶量) private Double avgLast7Milk; - private Double avgLast7Corrected; + private Double avgLast7Corrected; // = avgLast7Milk * weightCoefficient (默认 1.0) private Double avgLast14Milk; private Double avgLast30Milk; + + // 羊只基础信息(来自 sheep_file) private String sheepCategory; private Date birthday; - private Integer parity; + private Integer parity; // 当前胎次 private Integer monthAge; private Double currentWeight; private String breedStatus; @@ -36,12 +66,16 @@ public class NpSheepMilkAnalysis { private String motherManageTags; private String ranchName; private String family; + + // 母亲相关字段(由已计算的母亲分析结果中取值) private Integer motherMilkingDays; private Double motherSumCorrected; private Integer motherMaxParity; private Double motherAvgCorrectedDaily; + private Date lastUpdate; + // getters and setters public String getSheepId() { return sheepId; } public void setSheepId(String sheepId) { this.sheepId = sheepId; } @@ -60,6 +94,9 @@ public class NpSheepMilkAnalysis { public Integer getMilkingDays() { return milkingDays; } public void setMilkingDays(Integer milkingDays) { this.milkingDays = milkingDays; } + public Integer getScreenDays() { return screenDays; } + public void setScreenDays(Integer screenDays) { this.screenDays = screenDays; } + public Integer getAnalysisDays() { return analysisDays; } public void setAnalysisDays(Integer analysisDays) { this.analysisDays = analysisDays; } @@ -159,4 +196,3 @@ public class NpSheepMilkAnalysis { public Date getLastUpdate() { return lastUpdate; } public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; } } - diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpSheepMilkAnalysisMapper.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpSheepMilkAnalysisMapper.java index f330707..002e009 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpSheepMilkAnalysisMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpSheepMilkAnalysisMapper.java @@ -1,19 +1,36 @@ package com.zhyc.module.dairyProducts.mapper; import com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis; +import org.apache.ibatis.annotations.Param; + import java.util.List; +import java.util.Map; public interface NpSheepMilkAnalysisMapper { - NpSheepMilkAnalysis selectNpSheepMilkAnalysisById(Long id); + /** + * 按筛选天数 screenDays 统计并返回所有羊只的奶产量分析 + */ + List selectAnalysisForExport(@Param("screenDays") Integer screenDays); - List selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis); + /** + * 根据羊只ID查询羊只奶产量分析信息,返回Map结构 + */ + Map selectNpSheepMilkAnalysisBySheepId(@Param("sheepId") String sheepId); - int insertNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis); + /** + * 根据管理耳标筛选,返回distinct的sheepId列表 + */ + List selectDistinctSheepIds(@Param("manageEarTag") String manageEarTag); - int updateNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis); + /** + * 根据羊只ID查询羊只档案信息,返回Map结构 + */ + Map selectSheepFileBySheepId(@Param("sheepId") String sheepId); - int deleteNpSheepMilkAnalysisById(Long id); + /** + * 根据羊只ID查询挤奶班次数据,返回List + */ + List> selectMilkRecordsBySheepId(@Param("sheepId") String sheepId); - int deleteNpSheepMilkAnalysisByIds(Long[] ids); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/INpSheepMilkAnalysisService.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/INpSheepMilkAnalysisService.java index 7750a5f..8760789 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/INpSheepMilkAnalysisService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/INpSheepMilkAnalysisService.java @@ -5,16 +5,8 @@ import java.util.List; public interface INpSheepMilkAnalysisService { - NpSheepMilkAnalysis selectNpSheepMilkAnalysisById(Long id); + NpSheepMilkAnalysis selectNpSheepMilkAnalysisBySheepId(String sheepId); List selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis); - int insertNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis); - - int updateNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis); - - int deleteNpSheepMilkAnalysisById(Long id); - - int deleteNpSheepMilkAnalysisByIds(Long[] ids); } - diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/NpSheepMilkAnalysisServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/NpSheepMilkAnalysisServiceImpl.java index c2476ee..161a381 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/NpSheepMilkAnalysisServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/NpSheepMilkAnalysisServiceImpl.java @@ -1,12 +1,17 @@ package com.zhyc.module.dairyProducts.service.impl; -import java.util.List; - -import com.zhyc.module.dairyProducts.mapper.NpSheepMilkAnalysisMapper; import com.zhyc.module.dairyProducts.domain.NpSheepMilkAnalysis; +import com.zhyc.module.dairyProducts.mapper.NpSheepMilkAnalysisMapper; import com.zhyc.module.dairyProducts.service.INpSheepMilkAnalysisService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; @Service public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisService { @@ -14,34 +19,268 @@ public class NpSheepMilkAnalysisServiceImpl implements INpSheepMilkAnalysisServi @Autowired private NpSheepMilkAnalysisMapper npSheepMilkAnalysisMapper; + // 将 Rec 定义为静态内部类 + private static class Rec { + LocalDate date; + double systemMilk; + double correctedMilk; + int parity; + } + + // 将 ParityStat 定义为静态内部类 + private static class ParityStat { + int parity; + double sumCorrected; + double sumSystem; + LocalDate first; + LocalDate last; + long days; + } + @Override - public NpSheepMilkAnalysis selectNpSheepMilkAnalysisById(Long id) { - return npSheepMilkAnalysisMapper.selectNpSheepMilkAnalysisById(id); + public NpSheepMilkAnalysis selectNpSheepMilkAnalysisBySheepId(String sheepId) { + Map map = npSheepMilkAnalysisMapper.selectNpSheepMilkAnalysisBySheepId(sheepId); + if (map == null) return null; + NpSheepMilkAnalysis ana = new NpSheepMilkAnalysis(); + ana.setSheepId(sheepId); + ana.setManageEarTag((String) map.get("manageEarTag")); + return ana; } @Override public List selectNpSheepMilkAnalysisList(NpSheepMilkAnalysis analysis) { - return npSheepMilkAnalysisMapper.selectNpSheepMilkAnalysisList(analysis); + int screenDays = (analysis != null && analysis.getScreenDays() != null) ? analysis.getScreenDays() : 100; + String manageEarTagFilter = (analysis != null) ? analysis.getManageEarTag() : null; + + List sheepIds = npSheepMilkAnalysisMapper.selectDistinctSheepIds(manageEarTagFilter); + if (CollectionUtils.isEmpty(sheepIds)) return Collections.emptyList(); + + List resultList = new ArrayList<>(); + Map mapByManageTag = new HashMap<>(); + + for (String sheepId : sheepIds) { + Map sf = npSheepMilkAnalysisMapper.selectSheepFileBySheepId(sheepId); + List> records = npSheepMilkAnalysisMapper.selectMilkRecordsBySheepId(sheepId); + + if (records == null || records.isEmpty()) { + NpSheepMilkAnalysis emptyAna = new NpSheepMilkAnalysis(); + emptyAna.setSheepId(sheepId); + if (sf != null) { + emptyAna.setManageEarTag((String) sf.get("manageEarTag")); + emptyAna.setVariety((String) sf.get("variety")); + emptyAna.setLactationDays(toInteger(sf.get("lactationDay"))); + emptyAna.setSheepCategory((String) sf.get("sheepType")); + emptyAna.setBirthday(convertToDate(sf.get("birthday"))); + emptyAna.setParity(toInteger(sf.get("currentParity"))); + emptyAna.setMonthAge(toInteger(sf.get("monthAge"))); + emptyAna.setCurrentWeight(toDouble(sf.get("currentWeight"))); + emptyAna.setBreedStatus((String) sf.get("breedStatus")); + emptyAna.setFatherManageTags((String) sf.get("fatherManageTags")); + emptyAna.setMotherManageTags((String) sf.get("motherManageTags")); + emptyAna.setRanchName((String) sf.get("ranchName")); + emptyAna.setFamily((String) sf.get("family")); + } + resultList.add(emptyAna); + mapByManageTag.put(emptyAna.getManageEarTag(), emptyAna); + continue; + } + + // 使用静态内部类 Rec + List recs = new ArrayList<>(); + for (Map r : records) { + Rec rr = new Rec(); + rr.date = toLocalDate(r.get("classDate")); + rr.systemMilk = toDouble(r.get("systemMilk")); + rr.correctedMilk = toDouble(r.get("correctedMilk")); + rr.parity = (r.get("parity") == null) ? 0 : Integer.parseInt(String.valueOf(r.get("parity"))); + recs.add(rr); + } + + Map> byParity = recs.stream().collect(Collectors.groupingBy(r -> r.parity)); + + // 使用静态内部类 ParityStat + List parityStats = new ArrayList<>(); + for (Map.Entry> e : byParity.entrySet()) { + List list = e.getValue(); + double sumCorr = list.stream().mapToDouble(x -> x.correctedMilk).sum(); + double sumSys = list.stream().mapToDouble(x -> x.systemMilk).sum(); + LocalDate first = list.stream().map(x -> x.date).min(LocalDate::compareTo).get(); + LocalDate last = list.stream().map(x -> x.date).max(LocalDate::compareTo).get(); + long days = ChronoUnit.DAYS.between(first, last) + 1; + ParityStat ps = new ParityStat(); + ps.parity = e.getKey(); + ps.sumCorrected = sumCorr; + ps.sumSystem = sumSys; + ps.first = first; + ps.last = last; + ps.days = Math.max(days, 1); + parityStats.add(ps); + } + + parityStats.sort(Comparator.comparingDouble((ParityStat p) -> p.sumCorrected).reversed() + .thenComparingInt(p -> p.parity)); + ParityStat maxParityStat = parityStats.get(0); + + LocalDate windowStart = maxParityStat.first; + LocalDate windowEndByDays = windowStart.plusDays(screenDays - 1); + LocalDate actualWindowEnd = (maxParityStat.last.isBefore(windowEndByDays)) ? maxParityStat.last : windowEndByDays; + + double sumSystemWindow = recs.stream() + .filter(r -> r.parity == maxParityStat.parity && !r.date.isBefore(windowStart) && !r.date.isAfter(actualWindowEnd)) + .mapToDouble(r -> r.systemMilk).sum(); + + double sumCorrectedWindow = recs.stream() + .filter(r -> r.parity == maxParityStat.parity && !r.date.isBefore(windowStart) && !r.date.isAfter(actualWindowEnd)) + .mapToDouble(r -> r.correctedMilk).sum(); + + long milkingDays = maxParityStat.days; + long denominator = Math.min(milkingDays, screenDays); + double avgCorrectedDaily = (denominator > 0) ? (sumCorrectedWindow / (double) denominator) : 0.0; + + double sumParity1 = parityStats.stream().filter(p -> p.parity == 1).mapToDouble(p -> p.sumCorrected).sum(); + double sumParity2 = parityStats.stream().filter(p -> p.parity == 2).mapToDouble(p -> p.sumCorrected).sum(); + double sumParity3 = parityStats.stream().filter(p -> p.parity == 3).mapToDouble(p -> p.sumCorrected).sum(); + double sumParity4 = parityStats.stream().filter(p -> p.parity == 4).mapToDouble(p -> p.sumCorrected).sum(); + + // 你之前的 computeParityAvg 方法里没实现,保留调用0 + double avgP1 = computeParityAvg(parityStats, 1, screenDays); + double avgP2 = computeParityAvg(parityStats, 2, screenDays); + double avgP3 = computeParityAvg(parityStats, 3, screenDays); + double avgP4 = computeParityAvg(parityStats, 4, screenDays); + + LocalDate lastDate = recs.stream().map(r -> r.date).max(LocalDate::compareTo).get(); + double avgLast7 = computeLastNDaysAvg(recs, lastDate, 7); + double avgLast14 = computeLastNDaysAvg(recs, lastDate, 14); + double avgLast30 = computeLastNDaysAvg(recs, lastDate, 30); + + double weightCoefficient = 1.0; + if (sf != null && sf.get("weighCoefficient") != null) { + weightCoefficient = toDouble(sf.get("weighCoefficient")); + } + double avgLast7Corrected = avgLast7 * weightCoefficient; + + NpSheepMilkAnalysis ana = new NpSheepMilkAnalysis(); + ana.setSheepId(sheepId); + ana.setManageEarTag(sf == null ? null : (String) sf.get("manageEarTag")); + ana.setVariety(sf == null ? null : (String) sf.get("variety")); + ana.setMilkingStartTime(toDate(windowStart)); + ana.setDryEndTime(toDate(maxParityStat.last)); + ana.setMilkingDays((int) milkingDays); + ana.setScreenDays(screenDays); + ana.setMaxParity(maxParityStat.parity); + ana.setSumSystemMilk(sumSystemWindow); + ana.setSumCorrectedMilk(sumCorrectedWindow); + ana.setAvgCorrectedDaily(avgCorrectedDaily); + ana.setSumParity1Milk(sumParity1); + ana.setSumParity2Milk(sumParity2); + ana.setSumParity3Milk(sumParity3); + ana.setSumParity4Milk(sumParity4); + ana.setAvgParity1Daily(avgP1); + ana.setAvgParity2Daily(avgP2); + ana.setAvgParity3Daily(avgP3); + ana.setAvgParity4Daily(avgP4); + ana.setLactationDays(toInteger(sf == null ? null : sf.get("lactationDay"))); + ana.setAvgLast7Milk(avgLast7); + ana.setAvgLast7Corrected(avgLast7Corrected); + ana.setAvgLast14Milk(avgLast14); + ana.setAvgLast30Milk(avgLast30); + + if (sf != null) { + ana.setSheepCategory((String) sf.get("sheepType")); + ana.setBirthday(convertToDate(sf.get("birthday"))); + ana.setParity(toInteger(sf.get("currentParity"))); + ana.setMonthAge(toInteger(sf.get("monthAge"))); + ana.setCurrentWeight(toDouble(sf.get("currentWeight"))); + ana.setBreedStatus((String) sf.get("breedStatus")); + ana.setFatherManageTags((String) sf.get("fatherManageTags")); + ana.setMotherManageTags((String) sf.get("motherManageTags")); + ana.setRanchName((String) sf.get("ranchName")); + ana.setFamily((String) sf.get("family")); + } + + ana.setLastUpdate(toDate(lastDate)); + + resultList.add(ana); + mapByManageTag.put(ana.getManageEarTag(), ana); + } + + // 填充母亲相关字段 + for (NpSheepMilkAnalysis a : resultList) { + String motherTag = a.getMotherManageTags(); + if (motherTag != null && mapByManageTag.containsKey(motherTag)) { + NpSheepMilkAnalysis mom = mapByManageTag.get(motherTag); + a.setMotherMilkingDays(mom.getMilkingDays()); + a.setMotherSumCorrected(mom.getSumCorrectedMilk()); + a.setMotherMaxParity(mom.getMaxParity()); + a.setMotherAvgCorrectedDaily(mom.getAvgCorrectedDaily()); + } + } + + return resultList; } - @Override - public int insertNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis) { - return npSheepMilkAnalysisMapper.insertNpSheepMilkAnalysis(analysis); + private static Date convertToDate(Object obj) { + if (obj == null) return null; + if (obj instanceof Date) { + return (Date) obj; + } + if (obj instanceof java.sql.Date) { + return new Date(((java.sql.Date) obj).getTime()); + } + return null; } - @Override - public int updateNpSheepMilkAnalysis(NpSheepMilkAnalysis analysis) { - return npSheepMilkAnalysisMapper.updateNpSheepMilkAnalysis(analysis); + private static LocalDate toLocalDate(Object obj) { + if (obj == null) return null; + if (obj instanceof java.sql.Date) { + return ((java.sql.Date) obj).toLocalDate(); + } + if (obj instanceof Date) { + return ((Date) obj).toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + } + return null; } - @Override - public int deleteNpSheepMilkAnalysisById(Long id) { - return npSheepMilkAnalysisMapper.deleteNpSheepMilkAnalysisById(id); + private static Date toDate(LocalDate ld) { + if (ld == null) return null; + return Date.from(ld.atStartOfDay(ZoneId.systemDefault()).toInstant()); } - @Override - public int deleteNpSheepMilkAnalysisByIds(Long[] ids) { - return npSheepMilkAnalysisMapper.deleteNpSheepMilkAnalysisByIds(ids); + private static Integer toInteger(Object obj) { + if (obj == null) return null; + if (obj instanceof Number) return ((Number) obj).intValue(); + try { + return Integer.parseInt(obj.toString()); + } catch (Exception e) { + return null; + } + } + + private static Double toDouble(Object obj) { + if (obj == null) return 0.0; + if (obj instanceof Number) return ((Number) obj).doubleValue(); + try { + return Double.parseDouble(obj.toString()); + } catch (Exception e) { + return 0.0; + } + } + + private double computeParityAvg(List stats, int parity, int screenDays) { + // 这里你之前实现是直接返回0,可按需完善 + return 0.0; + } + + private double computeLastNDaysAvg(List recs, LocalDate lastDate, int days) { + LocalDate startDate = lastDate.minusDays(days - 1); + double sum = 0; + int count = 0; + for (Rec r : recs) { + if (r.date != null && !r.date.isBefore(startDate) && !r.date.isAfter(lastDate)) { + sum += r.correctedMilk; + count++; + } + } + return (count > 0) ? (sum / count) : 0.0; } } - diff --git a/zhyc-module/src/main/resources/mapper/dairyProducts/NpSheepMilkAnalysisMapper.xml b/zhyc-module/src/main/resources/mapper/dairyProducts/NpSheepMilkAnalysisMapper.xml index 34e4ba2..8069e16 100644 --- a/zhyc-module/src/main/resources/mapper/dairyProducts/NpSheepMilkAnalysisMapper.xml +++ b/zhyc-module/src/main/resources/mapper/dairyProducts/NpSheepMilkAnalysisMapper.xml @@ -2,151 +2,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id, manage_ear_tag, variety, milking_date, dry_date, milking_days, - screen_days, max_parity, total_milk, total_corrected_milk, - avg_daily_corrected_milk, parity1_total_milk, parity2_total_milk, - parity3_total_milk, parity4_total_milk, parity1_avg_milk, - parity2_avg_milk, parity3_avg_milk, parity4_avg_milk, - lactation_days, last_7_avg_milk, last_7_corrected_milk, - last_14_avg_milk, last_30_avg_milk, sheep_type, birthday, - current_parity, month_age, current_weight, breed_status, - father_tag, mother_tag, ranch, family, mother_milking_days, - mother_total_corrected_milk, mother_max_parity, - mother_avg_corrected - - - - - + SELECT DISTINCT a.sheep_id + FROM np_milk_prod_classes a + LEFT JOIN sheep_file sf ON a.sheep_id = sf.id - AND manage_ear_tag LIKE CONCAT('%', #{manageEarTag}, '%') + AND sf.bs_manage_tags LIKE CONCAT('%', #{manageEarTag}, '%') - - ORDER BY milking_date DESC + ORDER BY a.sheep_id - - INSERT INTO np_sheep_milk_analysis ( - - ) VALUES ( - #{id}, #{manageEarTag}, #{variety}, #{milkingDate}, #{dryDate}, - #{milkingDays}, #{screenDays}, #{maxParity}, #{totalMilk}, - #{totalCorrectedMilk}, #{avgDailyCorrectedMilk}, #{parity1TotalMilk}, - #{parity2TotalMilk}, #{parity3TotalMilk}, #{parity4TotalMilk}, - #{parity1AvgMilk}, #{parity2AvgMilk}, #{parity3AvgMilk}, - #{parity4AvgMilk}, #{lactationDays}, #{last7AvgMilk}, - #{last7CorrectedMilk}, #{last14AvgMilk}, #{last30AvgMilk}, - #{sheepType}, #{birthday}, #{currentParity}, #{monthAge}, - #{currentWeight}, #{breedStatus}, #{fatherTag}, #{motherTag}, - #{ranch}, #{family}, #{motherMilkingDays}, - #{motherTotalCorrectedMilk}, #{motherMaxParity}, - #{motherAvgCorrected} - ) - + + + - - UPDATE np_sheep_milk_analysis - SET manage_ear_tag = #{manageEarTag}, - variety = #{variety}, - milking_date = #{milkingDate}, - dry_date = #{dryDate}, - milking_days = #{milkingDays}, - screen_days = #{screenDays}, - max_parity = #{maxParity}, - total_milk = #{totalMilk}, - total_corrected_milk = #{totalCorrectedMilk}, - avg_daily_corrected_milk = #{avgDailyCorrectedMilk}, - parity1_total_milk = #{parity1TotalMilk}, - parity2_total_milk = #{parity2TotalMilk}, - parity3_total_milk = #{parity3TotalMilk}, - parity4_total_milk = #{parity4TotalMilk}, - parity1_avg_milk = #{parity1AvgMilk}, - parity2_avg_milk = #{parity2AvgMilk}, - parity3_avg_milk = #{parity3AvgMilk}, - parity4_avg_milk = #{parity4AvgMilk}, - lactation_days = #{lactationDays}, - last_7_avg_milk = #{last7AvgMilk}, - last_7_corrected_milk = #{last7CorrectedMilk}, - last_14_avg_milk = #{last14AvgMilk}, - last_30_avg_milk = #{last30AvgMilk}, - sheep_type = #{sheepType}, - birthday = #{birthday}, - current_parity = #{currentParity}, - month_age = #{monthAge}, - current_weight = #{currentWeight}, - breed_status = #{breedStatus}, - father_tag = #{fatherTag}, - mother_tag = #{motherTag}, - ranch = #{ranch}, - family = #{family}, - mother_milking_days = #{motherMilkingDays}, - mother_total_corrected_milk = #{motherTotalCorrectedMilk}, - mother_max_parity = #{motherMaxParity}, - mother_avg_corrected = #{motherAvgCorrected} - WHERE id = #{id} - - - DELETE FROM np_sheep_milk_analysis WHERE id = #{id} - + + + - - DELETE FROM np_sheep_milk_analysis WHERE id IN - - #{id} - - + +