feat(module): 饲喂管理 - 配方管理

完成饲喂管理模块中的配方管理部分
This commit is contained in:
HashMap 2025-08-12 15:55:22 +08:00
parent 3b527145d3
commit e965c9c35c
25 changed files with 2095 additions and 1 deletions

View File

@ -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<SgFeedPlan> 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<SgFeedPlan> list = sgFeedPlanService.selectSgFeedPlanList(sgFeedPlan);
ExcelUtil<SgFeedPlan> 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));
}
}

View File

@ -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<SgFormulaList> 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<SgFormulaList> list = sgFormulaListService.selectSgFormulaListList(sgFormulaList);
ExcelUtil<SgFormulaList> 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));
}
}

View File

@ -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<SgFormulaManagement> FormulaManagement = sgFormulaManagementService.selectSgFormulaManagementList(sgFormulaManagement);
for (SgFormulaManagement sgFormulaManagementItem : FormulaManagement) {
SgFormulaManagement query = new SgFormulaManagement();
query.setFormulaId(sgFormulaManagementItem.getFormulaId());
query.setQueryType("Sub");
List<SgFormulaManagement> 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<SgFormulaManagement> list = sgFormulaManagementService.selectSgFormulaManagementList(sgFormulaManagement);
ExcelUtil<SgFormulaManagement> 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> 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> 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<SgFormulaManagement> list = sgFormulaManagementService.selectSgFormulaManagementList(sgFormulaManagement);
if (list.size() > 1) {
throw new RuntimeException("WARNING 该配方正被使用,无法删除");
}
sgFormulaManagement.setBatchId(batchId);
}
// 前置检查完毕 执行删除
sgFormulaManagement.setBatchId(batchId);
return toAjax(sgFormulaManagementService.deleteSgFormulaManagement(sgFormulaManagement));
}
}

View File

@ -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<SgMaterial> 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<SgMaterial> list = sgMaterialService.selectSgMaterialList(sgMaterial);
ExcelUtil<SgMaterial> 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));
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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> sgFormulaList;
/** 子配方 */
private List<SgFormulaManagement> 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();
}
}

View File

@ -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;
}

View File

@ -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<SgFeedPlan> 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);
}

View File

@ -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<SgFormulaList> 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);
}

View File

@ -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<SgFormulaManagement> 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);
}

View File

@ -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<SgMaterial> 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);
}

View File

@ -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<SgFeedPlan> 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);
}

View File

@ -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<SgFormulaList> 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);
}

View File

@ -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<SgFormulaManagement> 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);
}

View File

@ -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<SgMaterial> 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);
}

View File

@ -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<SgFeedPlan> 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);
}
}

View File

@ -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<SgFormulaList> 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);
}
}

View File

@ -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<SgFormulaManagement> selectSgFormulaManagementList(SgFormulaManagement sgFormulaManagement) {
List<SgFormulaManagement> sgFormulaManagements =
sgFormulaManagementMapper.selectSgFormulaManagementList(sgFormulaManagement);
Iterator<SgFormulaManagement> 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<SgFormulaList> 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);
}
}

View File

@ -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<SgMaterial> 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);
}
}

View File

@ -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;
}

View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.feed.mapper.SgFeedPlanMapper">
<resultMap type="SgFeedPlan" id="SgFeedPlanResult">
<result property="createDate" column="create_date" />
<result property="formulaId" column="formula_id" />
<result property="sheepHouseId" column="sheep_house_id" />
<result property="sheepCount" column="sheep_count" />
<result property="planDailySize" column="plan_daily_size" />
<result property="planMorningSize" column="plan_morning_size" />
<result property="planMorningTotal" column="plan_morning_total" />
<result property="ratioMorning" column="ratio_morning" />
<result property="actualMorningSize" column="actual_morning_size" />
<result property="planNoonSize" column="plan_noon_size" />
<result property="planNoonTotal" column="plan_noon_total" />
<result property="actualNoonSize" column="actual_noon_size" />
<result property="ratioNoon" column="ratio_noon" />
<result property="planAfternoonSize" column="plan_afternoon_size" />
<result property="planAfternoonTotal" column="plan_afternoon_total" />
<result property="actualAfternoonSize" column="actual_afternoon_size" />
<result property="ratioAfternoon" column="ratio_afternoon" />
<result property="planFeedTotal" column="plan_feed_total" />
<result property="zookeeper" column="zookeeper" />
<result property="planDate" column="plan_date" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectSgFeedPlanVo">
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
</sql>
<select id="selectSgFeedPlanList" parameterType="SgFeedPlan" resultMap="SgFeedPlanResult">
<include refid="selectSgFeedPlanVo"/>
<where>
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
<if test="sheepHouseId != null "> and sheep_house_id = #{sheepHouseId}</if>
<if test="zookeeper != null and zookeeper != ''"> and zookeeper = #{zookeeper}</if>
<if test="planDate != null "> and plan_date = #{planDate}</if>
</where>
</select>
<select id="selectSgFeedPlanByCreateDate" parameterType="Date" resultMap="SgFeedPlanResult">
<include refid="selectSgFeedPlanVo"/>
where create_date = #{createDate}
</select>
<insert id="insertSgFeedPlan" parameterType="SgFeedPlan">
insert into sg_feed_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="createDate != null">create_date,</if>
<if test="formulaId != null and formulaId != ''">formula_id,</if>
<if test="sheepHouseId != null">sheep_house_id,</if>
<if test="sheepCount != null">sheep_count,</if>
<if test="planDailySize != null">plan_daily_size,</if>
<if test="planMorningSize != null">plan_morning_size,</if>
<if test="planMorningTotal != null">plan_morning_total,</if>
<if test="ratioMorning != null">ratio_morning,</if>
<if test="actualMorningSize != null">actual_morning_size,</if>
<if test="planNoonSize != null">plan_noon_size,</if>
<if test="planNoonTotal != null">plan_noon_total,</if>
<if test="actualNoonSize != null">actual_noon_size,</if>
<if test="ratioNoon != null">ratio_noon,</if>
<if test="planAfternoonSize != null">plan_afternoon_size,</if>
<if test="planAfternoonTotal != null">plan_afternoon_total,</if>
<if test="actualAfternoonSize != null">actual_afternoon_size,</if>
<if test="ratioAfternoon != null">ratio_afternoon,</if>
<if test="planFeedTotal != null">plan_feed_total,</if>
<if test="zookeeper != null">zookeeper,</if>
<if test="planDate != null">plan_date,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="createDate != null">#{createDate},</if>
<if test="formulaId != null and formulaId != ''">#{formulaId},</if>
<if test="sheepHouseId != null">#{sheepHouseId},</if>
<if test="sheepCount != null">#{sheepCount},</if>
<if test="planDailySize != null">#{planDailySize},</if>
<if test="planMorningSize != null">#{planMorningSize},</if>
<if test="planMorningTotal != null">#{planMorningTotal},</if>
<if test="ratioMorning != null">#{ratioMorning},</if>
<if test="actualMorningSize != null">#{actualMorningSize},</if>
<if test="planNoonSize != null">#{planNoonSize},</if>
<if test="planNoonTotal != null">#{planNoonTotal},</if>
<if test="actualNoonSize != null">#{actualNoonSize},</if>
<if test="ratioNoon != null">#{ratioNoon},</if>
<if test="planAfternoonSize != null">#{planAfternoonSize},</if>
<if test="planAfternoonTotal != null">#{planAfternoonTotal},</if>
<if test="actualAfternoonSize != null">#{actualAfternoonSize},</if>
<if test="ratioAfternoon != null">#{ratioAfternoon},</if>
<if test="planFeedTotal != null">#{planFeedTotal},</if>
<if test="zookeeper != null">#{zookeeper},</if>
<if test="planDate != null">#{planDate},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateSgFeedPlan" parameterType="SgFeedPlan">
update sg_feed_plan
<trim prefix="SET" suffixOverrides=",">
<if test="formulaId != null and formulaId != ''">formula_id = #{formulaId},</if>
<if test="sheepHouseId != null">sheep_house_id = #{sheepHouseId},</if>
<if test="sheepCount != null">sheep_count = #{sheepCount},</if>
<if test="planDailySize != null">plan_daily_size = #{planDailySize},</if>
<if test="planMorningSize != null">plan_morning_size = #{planMorningSize},</if>
<if test="planMorningTotal != null">plan_morning_total = #{planMorningTotal},</if>
<if test="ratioMorning != null">ratio_morning = #{ratioMorning},</if>
<if test="actualMorningSize != null">actual_morning_size = #{actualMorningSize},</if>
<if test="planNoonSize != null">plan_noon_size = #{planNoonSize},</if>
<if test="planNoonTotal != null">plan_noon_total = #{planNoonTotal},</if>
<if test="actualNoonSize != null">actual_noon_size = #{actualNoonSize},</if>
<if test="ratioNoon != null">ratio_noon = #{ratioNoon},</if>
<if test="planAfternoonSize != null">plan_afternoon_size = #{planAfternoonSize},</if>
<if test="planAfternoonTotal != null">plan_afternoon_total = #{planAfternoonTotal},</if>
<if test="actualAfternoonSize != null">actual_afternoon_size = #{actualAfternoonSize},</if>
<if test="ratioAfternoon != null">ratio_afternoon = #{ratioAfternoon},</if>
<if test="planFeedTotal != null">plan_feed_total = #{planFeedTotal},</if>
<if test="zookeeper != null">zookeeper = #{zookeeper},</if>
<if test="planDate != null">plan_date = #{planDate},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where create_date = #{createDate}
</update>
<delete id="deleteSgFeedPlanByCreateDate" parameterType="Date">
delete from sg_feed_plan where create_date = #{createDate}
</delete>
<delete id="deleteSgFeedPlanByCreateDates" parameterType="String">
delete from sg_feed_plan where create_date in
<foreach item="createDate" collection="array" open="(" separator="," close=")">
#{createDate}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.feed.mapper.SgFormulaListMapper">
<resultMap type="SgFormulaList" id="SgFormulaListResult">
<result property="code" column="code" />
<result property="formulaId" column="formula_id" />
<result property="batchId" column="batch_id" />
<result property="materialId" column="material_id" />
<result property="materialName" column="material_name" />
<result property="ratio" column="ratio" />
<result property="isGranular" column="is_granular" />
<result property="isSupplement" column="is_supplement" />
</resultMap>
<sql id="selectSgFormulaListVo">
select code, formula_id, material_id, material_name, ratio, is_granular, is_supplement from sg_formula_list
</sql>
<select id="selectSgFormulaListList" parameterType="SgFormulaList" resultMap="SgFormulaListResult">
<include refid="selectSgFormulaListVo"/>
<where>
<if test="materialId != null and materialId != ''">material_id = #{materialId}</if>
<if test="formulaId != null and formulaId != ''">and formula_id = #{formulaId}</if>
<if test="batchId != null and batchId != ''"> and batch_id = #{batchId}</if>
</where>
</select>
<select id="selectSgFormulaListByCode" parameterType="Long" resultMap="SgFormulaListResult">
<include refid="selectSgFormulaListVo"/>
where code = #{code}
</select>
<insert id="insertSgFormulaList" parameterType="SgFormulaList">
insert into sg_formula_list
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="code != null">code,</if>
<if test="formulaId != null">formula_id,</if>
<if test="batchId != null">batch_id,</if>
<if test="materialId != null">material_id,</if>
<if test="materialName != null">material_name,</if>
<if test="ratio != null">ratio,</if>
<if test="isGranular != null">is_granular,</if>
<if test="isSupplement != null">is_supplement,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">#{code},</if>
<if test="formulaId != null">#{formulaId},</if>
<if test="batchId != null">#{batchId},</if>
<if test="materialId != null">#{materialId},</if>
<if test="materialName != null">#{materialName},</if>
<if test="ratio != null">#{ratio},</if>
<if test="isGranular != null">#{isGranular},</if>
<if test="isSupplement != null">#{isSupplement},</if>
</trim>
</insert>
<update id="updateSgFormulaList" parameterType="SgFormulaList">
update sg_formula_list
<trim prefix="SET" suffixOverrides=",">
<if test="formulaId != null">formula_id = #{formulaId},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="materialName != null">material_name = #{materialName},</if>
<if test="ratio != null">ratio = #{ratio},</if>
<if test="isGranular != null">is_granular = #{isGranular},</if>
<if test="isSupplement != null">is_supplement = #{isSupplement},</if>
</trim>
where code = #{code}
</update>
<delete id="deleteSgFormulaListByCode" parameterType="Long">
delete from sg_formula_list where code = #{code}
</delete>
<delete id="deleteSgFormulaListByCodes" parameterType="String">
delete from sg_formula_list where code in
<foreach item="code" collection="array" open="(" separator="," close=")">
#{code}
</foreach>
</delete>
<delete id="deleteSgFormulaListByFormulaIdAndBatchId" parameterType="SgFormulaList">
DELETE FROM sg_formula_list WHERE formula_id = #{formulaId} AND batch_id = #{batchId}
</delete>
</mapper>

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.feed.mapper.SgFormulaManagementMapper">
<resultMap type="SgFormulaManagement" id="SgFormulaManagementResult">
<result property="formulaId" column="formula_id" />
<result property="feedStage" column="feed_stage" />
<result property="batchId" column="batch_id" />
<result property="useStartDate" column="use_start_date" />
<result property="useEndDate" column="use_end_date" />
<result property="useState" column="use_state" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectSgFormulaManagementVo">
select formula_id, feed_stage, batch_id, use_start_date, use_end_date, use_state, remark from sg_formula_management
</sql>
<select id="selectSgFormulaManagementList" parameterType="SgFormulaManagement" resultMap="SgFormulaManagementResult">
<include refid="selectSgFormulaManagementVo"/>
<where>
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
<if test="feedStage != null and feedStage != ''"> and feed_stage = #{feedStage}</if>
<if test="batchId != null and batchId != ''"> and batch_id = #{batchId}</if>
</where>
</select>
<select id="selectSgFormulaManagementByFormulaId" parameterType="String" resultMap="SgFormulaManagementResult">
<include refid="selectSgFormulaManagementVo"/>
where formula_id = #{formulaId}
</select>
<insert id="insertSgFormulaManagement" parameterType="SgFormulaManagement">
insert into sg_formula_management
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="formulaId != null and formulaId != ''">formula_id,</if>
<if test="feedStage != null and feedStage != ''">feed_stage,</if>
<if test="batchId != null">batch_id,</if>
<if test="useStartDate != null">use_start_date,</if>
<if test="useEndDate != null">use_end_date,</if>
<if test="useState != null">use_state,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="formulaId != null and formulaId != ''">#{formulaId},</if>
<if test="feedStage != null and feedStage != ''">#{feedStage},</if>
<if test="batchId != null">#{batchId},</if>
<if test="useStartDate != null">#{useStartDate},</if>
<if test="useEndDate != null">#{useEndDate},</if>
<if test="useState != null">#{useState},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateSgFormulaManagement" parameterType="SgFormulaManagement">
update sg_formula_management
<trim prefix="SET" suffixOverrides=",">
<if test="feedStage != null and feedStage != ''">feed_stage = #{feedStage},</if>
<if test="useStartDate != null">use_start_date = #{useStartDate},</if>
<if test="useEndDate != null">use_end_date = #{useEndDate},</if>
<if test="useState != null">use_state = #{useState},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where formula_id = #{formulaId} AND batch_id = #{batchId}
</update>
<delete id="deleteSgFormulaManagementByFormulaId" parameterType="String">
delete from sg_formula_management where formula_id = #{formulaId}
</delete>
<delete id="deleteSgFormulaManagementByFormulaIds" parameterType="String">
delete from sg_formula_management where formula_id in
<foreach item="formulaId" collection="array" open="(" separator="," close=")">
#{formulaId}
</foreach>
</delete>
<delete id="deleteSgFormulaManagement" parameterType="SgFormulaManagement">
delete from sg_formula_management where formula_id = #{formulaId} and batch_id = #{batchId}
</delete>
</mapper>

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.feed.mapper.SgMaterialMapper">
<resultMap type="SgMaterial" id="SgMaterialResult">
<result property="materialId" column="material_id" />
<result property="materialName" column="material_name" />
<result property="isGranular" column="is_granular" />
</resultMap>
<sql id="selectSgMaterialVo">
select material_id, material_name, is_granular from sg_material
</sql>
<select id="selectSgMaterialList" parameterType="SgMaterial" resultMap="SgMaterialResult">
<include refid="selectSgMaterialVo"/>
<where>
<if test="materialId != null and materialId != ''"> and material_id = #{materialId}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="isGranular != null "> and is_granular = #{isGranular}</if>
</where>
</select>
<select id="selectSgMaterialByMaterialId" parameterType="String" resultMap="SgMaterialResult">
<include refid="selectSgMaterialVo"/>
where material_id = #{materialId}
</select>
<insert id="insertSgMaterial" parameterType="SgMaterial">
insert into sg_material
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="materialId != null">material_id,</if>
<if test="materialName != null and materialName != ''">material_name,</if>
<if test="isGranular != null">is_granular,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="materialId != null">#{materialId},</if>
<if test="materialName != null and materialName != ''">#{materialName},</if>
<if test="isGranular != null">#{isGranular},</if>
</trim>
</insert>
<update id="updateSgMaterial" parameterType="SgMaterial">
update sg_material
<trim prefix="SET" suffixOverrides=",">
<if test="materialName != null and materialName != ''">material_name = #{materialName},</if>
<if test="isGranular != null">is_granular = #{isGranular},</if>
</trim>
where material_id = #{materialId}
</update>
<delete id="deleteSgMaterialByMaterialId" parameterType="String">
delete from sg_material where material_id = #{materialId}
</delete>
<delete id="deleteSgMaterialByMaterialIds" parameterType="String">
delete from sg_material where material_id in
<foreach item="materialId" collection="array" open="(" separator="," close=")">
#{materialId}
</foreach>
</delete>
</mapper>