Merge remote-tracking branch 'origin/main'

This commit is contained in:
wyt 2025-07-15 17:09:41 +08:00
commit 134f3fcf40
38 changed files with 1880 additions and 278 deletions

View File

@ -0,0 +1,104 @@
package com.zhyc.module.base.variety.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.base.variety.domain.BasSheepVariety;
import com.zhyc.module.base.variety.service.IBasSheepVarietyService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 羊只品种Controller
*
* @author ruoyi
* @date 2025-07-15
*/
@RestController
@RequestMapping("/base/variety")
public class BasSheepVarietyController extends BaseController
{
@Autowired
private IBasSheepVarietyService basSheepVarietyService;
/**
* 查询羊只品种列表
*/
@PreAuthorize("@ss.hasPermi('base:variety:list')")
@GetMapping("/list")
public TableDataInfo list(BasSheepVariety basSheepVariety)
{
startPage();
List<BasSheepVariety> list = basSheepVarietyService.selectBasSheepVarietyList(basSheepVariety);
return getDataTable(list);
}
/**
* 导出羊只品种列表
*/
@PreAuthorize("@ss.hasPermi('base:variety:export')")
@Log(title = "羊只品种", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BasSheepVariety basSheepVariety)
{
List<BasSheepVariety> list = basSheepVarietyService.selectBasSheepVarietyList(basSheepVariety);
ExcelUtil<BasSheepVariety> util = new ExcelUtil<BasSheepVariety>(BasSheepVariety.class);
util.exportExcel(response, list, "羊只品种数据");
}
/**
* 获取羊只品种详细信息
*/
@PreAuthorize("@ss.hasPermi('base:variety:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(basSheepVarietyService.selectBasSheepVarietyById(id));
}
/**
* 新增羊只品种
*/
@PreAuthorize("@ss.hasPermi('base:variety:add')")
@Log(title = "羊只品种", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BasSheepVariety basSheepVariety)
{
return toAjax(basSheepVarietyService.insertBasSheepVariety(basSheepVariety));
}
/**
* 修改羊只品种
*/
@PreAuthorize("@ss.hasPermi('base:variety:edit')")
@Log(title = "羊只品种", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BasSheepVariety basSheepVariety)
{
return toAjax(basSheepVarietyService.updateBasSheepVariety(basSheepVariety));
}
/**
* 删除羊只品种
*/
@PreAuthorize("@ss.hasPermi('base:variety:remove')")
@Log(title = "羊只品种", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(basSheepVarietyService.deleteBasSheepVarietyByIds(ids));
}
}

View File

@ -0,0 +1,52 @@
package com.zhyc.module.base.variety.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 羊只品种对象 bas_sheep_variety
*
* @author ruoyi
* @date 2025-07-15
*/
public class BasSheepVariety extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 品种 */
@Excel(name = "品种")
private String variety;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setVariety(String variety)
{
this.variety = variety;
}
public String getVariety()
{
return variety;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("variety", getVariety())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.base.variety.mapper;
import java.util.List;
import com.zhyc.module.base.variety.domain.BasSheepVariety;
/**
* 羊只品种Mapper接口
*
* @author ruoyi
* @date 2025-07-15
*/
public interface BasSheepVarietyMapper
{
/**
* 查询羊只品种
*
* @param id 羊只品种主键
* @return 羊只品种
*/
public BasSheepVariety selectBasSheepVarietyById(Long id);
/**
* 查询羊只品种列表
*
* @param basSheepVariety 羊只品种
* @return 羊只品种集合
*/
public List<BasSheepVariety> selectBasSheepVarietyList(BasSheepVariety basSheepVariety);
/**
* 新增羊只品种
*
* @param basSheepVariety 羊只品种
* @return 结果
*/
public int insertBasSheepVariety(BasSheepVariety basSheepVariety);
/**
* 修改羊只品种
*
* @param basSheepVariety 羊只品种
* @return 结果
*/
public int updateBasSheepVariety(BasSheepVariety basSheepVariety);
/**
* 删除羊只品种
*
* @param id 羊只品种主键
* @return 结果
*/
public int deleteBasSheepVarietyById(Long id);
/**
* 批量删除羊只品种
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteBasSheepVarietyByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.base.variety.service;
import java.util.List;
import com.zhyc.module.base.variety.domain.BasSheepVariety;
/**
* 羊只品种Service接口
*
* @author ruoyi
* @date 2025-07-15
*/
public interface IBasSheepVarietyService
{
/**
* 查询羊只品种
*
* @param id 羊只品种主键
* @return 羊只品种
*/
public BasSheepVariety selectBasSheepVarietyById(Long id);
/**
* 查询羊只品种列表
*
* @param basSheepVariety 羊只品种
* @return 羊只品种集合
*/
public List<BasSheepVariety> selectBasSheepVarietyList(BasSheepVariety basSheepVariety);
/**
* 新增羊只品种
*
* @param basSheepVariety 羊只品种
* @return 结果
*/
public int insertBasSheepVariety(BasSheepVariety basSheepVariety);
/**
* 修改羊只品种
*
* @param basSheepVariety 羊只品种
* @return 结果
*/
public int updateBasSheepVariety(BasSheepVariety basSheepVariety);
/**
* 批量删除羊只品种
*
* @param ids 需要删除的羊只品种主键集合
* @return 结果
*/
public int deleteBasSheepVarietyByIds(Long[] ids);
/**
* 删除羊只品种信息
*
* @param id 羊只品种主键
* @return 结果
*/
public int deleteBasSheepVarietyById(Long id);
}

View File

@ -0,0 +1,93 @@
package com.zhyc.module.base.variety.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.base.variety.mapper.BasSheepVarietyMapper;
import com.zhyc.module.base.variety.domain.BasSheepVariety;
import com.zhyc.module.base.variety.service.IBasSheepVarietyService;
/**
* 羊只品种Service业务层处理
*
* @author ruoyi
* @date 2025-07-15
*/
@Service
public class BasSheepVarietyServiceImpl implements IBasSheepVarietyService
{
@Autowired
private BasSheepVarietyMapper basSheepVarietyMapper;
/**
* 查询羊只品种
*
* @param id 羊只品种主键
* @return 羊只品种
*/
@Override
public BasSheepVariety selectBasSheepVarietyById(Long id)
{
return basSheepVarietyMapper.selectBasSheepVarietyById(id);
}
/**
* 查询羊只品种列表
*
* @param basSheepVariety 羊只品种
* @return 羊只品种
*/
@Override
public List<BasSheepVariety> selectBasSheepVarietyList(BasSheepVariety basSheepVariety)
{
return basSheepVarietyMapper.selectBasSheepVarietyList(basSheepVariety);
}
/**
* 新增羊只品种
*
* @param basSheepVariety 羊只品种
* @return 结果
*/
@Override
public int insertBasSheepVariety(BasSheepVariety basSheepVariety)
{
return basSheepVarietyMapper.insertBasSheepVariety(basSheepVariety);
}
/**
* 修改羊只品种
*
* @param basSheepVariety 羊只品种
* @return 结果
*/
@Override
public int updateBasSheepVariety(BasSheepVariety basSheepVariety)
{
return basSheepVarietyMapper.updateBasSheepVariety(basSheepVariety);
}
/**
* 批量删除羊只品种
*
* @param ids 需要删除的羊只品种主键
* @return 结果
*/
@Override
public int deleteBasSheepVarietyByIds(Long[] ids)
{
return basSheepVarietyMapper.deleteBasSheepVarietyByIds(ids);
}
/**
* 删除羊只品种信息
*
* @param id 羊只品种主键
* @return 结果
*/
@Override
public int deleteBasSheepVarietyById(Long id)
{
return basSheepVarietyMapper.deleteBasSheepVarietyById(id);
}
}

View File

@ -1,4 +1,4 @@
package com.zhyc.module.dryMatterCorrection.controller;
package com.zhyc.module.dairyProducts.dryMatterCorrection.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
@ -16,8 +16,8 @@ import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.dryMatterCorrection.domain.XzDryMatterCorrection;
import com.zhyc.module.dryMatterCorrection.service.IXzDryMatterCorrectionService;
import com.zhyc.module.dairyProducts.dryMatterCorrection.domain.XzDryMatterCorrection;
import com.zhyc.module.dairyProducts.dryMatterCorrection.service.IXzDryMatterCorrectionService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.zhyc.module.dryMatterCorrection.domain;
package com.zhyc.module.dairyProducts.dryMatterCorrection.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;

View File

@ -1,7 +1,7 @@
package com.zhyc.module.dryMatterCorrection.mapper;
package com.zhyc.module.dairyProducts.dryMatterCorrection.mapper;
import java.util.List;
import com.zhyc.module.dryMatterCorrection.domain.XzDryMatterCorrection;
import com.zhyc.module.dairyProducts.dryMatterCorrection.domain.XzDryMatterCorrection;
/**
* 干物质校正Mapper接口

View File

@ -1,7 +1,7 @@
package com.zhyc.module.dryMatterCorrection.service;
package com.zhyc.module.dairyProducts.dryMatterCorrection.service;
import java.util.List;
import com.zhyc.module.dryMatterCorrection.domain.XzDryMatterCorrection;
import com.zhyc.module.dairyProducts.dryMatterCorrection.domain.XzDryMatterCorrection;
/**
* 干物质校正Service接口

View File

@ -1,11 +1,11 @@
package com.zhyc.module.dryMatterCorrection.service.impl;
package com.zhyc.module.dairyProducts.dryMatterCorrection.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.dryMatterCorrection.mapper.XzDryMatterCorrectionMapper;
import com.zhyc.module.dryMatterCorrection.domain.XzDryMatterCorrection;
import com.zhyc.module.dryMatterCorrection.service.IXzDryMatterCorrectionService;
import com.zhyc.module.dairyProducts.dryMatterCorrection.mapper.XzDryMatterCorrectionMapper;
import com.zhyc.module.dairyProducts.dryMatterCorrection.domain.XzDryMatterCorrection;
import com.zhyc.module.dairyProducts.dryMatterCorrection.service.IXzDryMatterCorrectionService;
/**
* 干物质校正Service业务层处理

View File

@ -1,4 +1,4 @@
package com.zhyc.module.parityCorrection.controller;
package com.zhyc.module.dairyProducts.parityCorrection.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
@ -16,8 +16,8 @@ import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.parityCorrection.domain.XzParityCorrection;
import com.zhyc.module.parityCorrection.service.IXzParityCorrectionService;
import com.zhyc.module.dairyProducts.parityCorrection.domain.XzParityCorrection;
import com.zhyc.module.dairyProducts.parityCorrection.service.IXzParityCorrectionService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.zhyc.module.parityCorrection.domain;
package com.zhyc.module.dairyProducts.parityCorrection.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

View File

@ -1,7 +1,7 @@
package com.zhyc.module.parityCorrection.mapper;
package com.zhyc.module.dairyProducts.parityCorrection.mapper;
import java.util.List;
import com.zhyc.module.parityCorrection.domain.XzParityCorrection;
import com.zhyc.module.dairyProducts.parityCorrection.domain.XzParityCorrection;
/**
* 胎次校正Mapper接口

View File

@ -1,7 +1,7 @@
package com.zhyc.module.parityCorrection.service;
package com.zhyc.module.dairyProducts.parityCorrection.service;
import java.util.List;
import com.zhyc.module.parityCorrection.domain.XzParityCorrection;
import com.zhyc.module.dairyProducts.parityCorrection.domain.XzParityCorrection;
/**
* 胎次校正Service接口

View File

@ -1,11 +1,11 @@
package com.zhyc.module.parityCorrection.service.impl;
package com.zhyc.module.dairyProducts.parityCorrection.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.parityCorrection.mapper.XzParityCorrectionMapper;
import com.zhyc.module.parityCorrection.domain.XzParityCorrection;
import com.zhyc.module.parityCorrection.service.IXzParityCorrectionService;
import com.zhyc.module.dairyProducts.parityCorrection.mapper.XzParityCorrectionMapper;
import com.zhyc.module.dairyProducts.parityCorrection.domain.XzParityCorrection;
import com.zhyc.module.dairyProducts.parityCorrection.service.IXzParityCorrectionService;
/**
* 胎次校正Service业务层处理

View File

@ -1,4 +1,4 @@
package com.zhyc.module.weightCorrection.controller;
package com.zhyc.module.dairyProducts.weightCorrection.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
@ -16,8 +16,8 @@ import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.weightCorrection.domain.XzWegihCorrection;
import com.zhyc.module.weightCorrection.service.IXzWegihCorrectionService;
import com.zhyc.module.dairyProducts.weightCorrection.domain.XzWegihCorrection;
import com.zhyc.module.dairyProducts.weightCorrection.service.IXzWegihCorrectionService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

View File

@ -1,4 +1,4 @@
package com.zhyc.module.weightCorrection.domain;
package com.zhyc.module.dairyProducts.weightCorrection.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;

View File

@ -1,7 +1,7 @@
package com.zhyc.module.weightCorrection.mapper;
package com.zhyc.module.dairyProducts.weightCorrection.mapper;
import java.util.List;
import com.zhyc.module.weightCorrection.domain.XzWegihCorrection;
import com.zhyc.module.dairyProducts.weightCorrection.domain.XzWegihCorrection;
/**
* 称重校正Mapper接口

View File

@ -1,7 +1,7 @@
package com.zhyc.module.weightCorrection.service;
package com.zhyc.module.dairyProducts.weightCorrection.service;
import java.util.List;
import com.zhyc.module.weightCorrection.domain.XzWegihCorrection;
import com.zhyc.module.dairyProducts.weightCorrection.domain.XzWegihCorrection;
/**
* 称重校正Service接口

View File

@ -1,11 +1,11 @@
package com.zhyc.module.weightCorrection.service.impl;
package com.zhyc.module.dairyProducts.weightCorrection.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.weightCorrection.mapper.XzWegihCorrectionMapper;
import com.zhyc.module.weightCorrection.domain.XzWegihCorrection;
import com.zhyc.module.weightCorrection.service.IXzWegihCorrectionService;
import com.zhyc.module.dairyProducts.weightCorrection.mapper.XzWegihCorrectionMapper;
import com.zhyc.module.dairyProducts.weightCorrection.domain.XzWegihCorrection;
import com.zhyc.module.dairyProducts.weightCorrection.service.IXzWegihCorrectionService;
/**
* 称重校正Service业务层处理

View File

@ -24,24 +24,20 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 产羔记录Controller
*
* @author ruoyi
* @date 2025-07-11
*/
@RestController
@RequestMapping("/breed/lambing_records")
public class ScLambingRecordController extends BaseController
{
public class ScLambingRecordController extends BaseController {
@Autowired
private IScLambingRecordService scLambingRecordService;
/**
* 查询产羔记录列表包含关联信息
* 查询产羔记录列表
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:list')")
@GetMapping("/list")
public TableDataInfo list(ScLambingRecord scLambingRecord)
{
public TableDataInfo list(ScLambingRecord scLambingRecord) {
startPage();
List<ScLambingRecord> list = scLambingRecordService.selectScLambingRecordList(scLambingRecord);
return getDataTable(list);
@ -53,8 +49,7 @@ public class ScLambingRecordController extends BaseController
@PreAuthorize("@ss.hasPermi('breed:lambing_records:export')")
@Log(title = "产羔记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScLambingRecord scLambingRecord)
{
public void export(HttpServletResponse response, ScLambingRecord scLambingRecord) {
List<ScLambingRecord> list = scLambingRecordService.selectScLambingRecordList(scLambingRecord);
ExcelUtil<ScLambingRecord> util = new ExcelUtil<ScLambingRecord>(ScLambingRecord.class);
util.exportExcel(response, list, "产羔记录数据");
@ -65,41 +60,41 @@ public class ScLambingRecordController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(scLambingRecordService.selectScLambingRecordById(id));
}
/**
* 获取产羔记录详细信息包含关联信息
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')")
@GetMapping(value = "/detail/{id}")
public AjaxResult getDetailInfo(@PathVariable("id") Long id)
{
return success(scLambingRecordService.selectScLambingRecordDetailById(id));
}
/**
* 查询产羔详情羔羊信息列表
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')")
@GetMapping("/lamb_detail/{lambingRecordId}")
public AjaxResult getLambDetail(@PathVariable("lambingRecordId") Long lambingRecordId)
{
List<ScLambDetail> list = scLambingRecordService.selectLambDetailByLambingRecordId(lambingRecordId);
return success(list);
}
/**
* 新增产羔记录包含羔羊详情
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:add')")
@Log(title = "产羔记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScLambingRecord scLambingRecord)
{
return toAjax(scLambingRecordService.insertScLambingRecord(scLambingRecord));
public AjaxResult add(@RequestBody ScLambingRecord scLambingRecord) {
try {
// 设置创建人
scLambingRecord.setCreateBy(getUsername());
// 如果没有设置创建时间使用当前时间
if (scLambingRecord.getCreateTime() == null) {
scLambingRecord.setCreateTime(new java.util.Date());
}
int result = scLambingRecordService.insertScLambingRecord(scLambingRecord);
if (result > 0) {
String message = "新增产羔记录成功";
if (scLambingRecord.getLambDetails() != null && !scLambingRecord.getLambDetails().isEmpty()) {
message += ",同时录入了 " + scLambingRecord.getLambDetails().size() + " 只羔羊详情";
}
return success(message);
} else {
return error("新增产羔记录失败");
}
} catch (Exception e) {
logger.error("新增产羔记录异常", e);
return error("新增产羔记录失败:" + e.getMessage());
}
}
/**
@ -108,9 +103,15 @@ public class ScLambingRecordController extends BaseController
@PreAuthorize("@ss.hasPermi('breed:lambing_records:edit')")
@Log(title = "产羔记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScLambingRecord scLambingRecord)
{
return toAjax(scLambingRecordService.updateScLambingRecord(scLambingRecord));
public AjaxResult edit(@RequestBody ScLambingRecord scLambingRecord) {
try {
scLambingRecord.setUpdateBy(getUsername());
scLambingRecord.setUpdateTime(new java.util.Date());
return toAjax(scLambingRecordService.updateScLambingRecord(scLambingRecord));
} catch (Exception e) {
logger.error("修改产羔记录异常", e);
return error("修改产羔记录失败:" + e.getMessage());
}
}
/**
@ -119,19 +120,27 @@ public class ScLambingRecordController extends BaseController
@PreAuthorize("@ss.hasPermi('breed:lambing_records:remove')")
@Log(title = "产羔记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(scLambingRecordService.deleteScLambingRecordByIds(ids));
public AjaxResult remove(@PathVariable Long[] ids) {
try {
return toAjax(scLambingRecordService.deleteScLambingRecordByIds(ids));
} catch (Exception e) {
logger.error("删除产羔记录异常", e);
return error("删除产羔记录失败:" + e.getMessage());
}
}
/**
* 批量新增羔羊详情
* 查询羔羊详情
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:add')")
@Log(title = "羔羊详情", businessType = BusinessType.INSERT)
@PostMapping("/lamb_details/batch")
public AjaxResult addLambDetailsBatch(@RequestBody List<ScLambDetail> lambDetails)
{
return toAjax(scLambingRecordService.insertLambDetailsBatch(lambDetails));
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')")
@GetMapping("/lamb_detail/{lambingRecordId}")
public AjaxResult getLambDetail(@PathVariable("lambingRecordId") Long lambingRecordId) {
try {
List<ScLambDetail> lambDetails = scLambingRecordService.selectLambDetailByLambingRecordId(lambingRecordId);
return success(lambDetails);
} catch (Exception e) {
logger.error("查询羔羊详情异常", e);
return error("查询羔羊详情失败:" + e.getMessage());
}
}
}

View File

@ -2,6 +2,8 @@ package com.zhyc.module.produce.breed.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -29,13 +31,13 @@ public class ScLambDetail extends BaseEntity
@Excel(name = "羔羊耳号")
private String lambEarNumber;
/** 羔羊品种 */
@Excel(name = "羔羊品种")
private String lambBreed;
/** 羔羊品种ID */
@Excel(name = "羔羊品种ID")
private Integer lambBreed; // 改为Integer类型存储品种ID
/** 性别 */
@Excel(name = "性别")
private String gender;
private Integer gender;
/** 出生重量 */
@Excel(name = "出生重量")
@ -54,6 +56,23 @@ public class ScLambDetail extends BaseEntity
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday;
private List<ScLambDetail> lambDetails;
/** 母羊ID */
private Long motherId;
/** 父羊ID */
private Long fatherId;
/** 牧场ID */
private Integer ranchId;
/** 羊舍ID */
private Integer sheepfoldId;
/** 胎次 */
private Integer parity;
// getter和setter方法
public void setId(Long id)
{
@ -85,22 +104,22 @@ public class ScLambDetail extends BaseEntity
return lambEarNumber;
}
public void setLambBreed(String lambBreed)
public void setLambBreed(Integer lambBreed) // 改为Integer类型
{
this.lambBreed = lambBreed;
}
public String getLambBreed()
public Integer getLambBreed() // 改为Integer类型
{
return lambBreed;
}
public void setGender(String gender)
public void setGender(Integer gender)
{
this.gender = gender;
}
public String getGender()
public Integer getGender()
{
return gender;
}
@ -145,6 +164,66 @@ public class ScLambDetail extends BaseEntity
return birthday;
}
public List<ScLambDetail> getLambDetails()
{
return lambDetails;
}
public void setLambDetails(List<ScLambDetail> lambDetails)
{
this.lambDetails = lambDetails;
}
public Long getMotherId()
{
return motherId;
}
public void setMotherId(Long motherId)
{
this.motherId = motherId;
}
public Long getFatherId()
{
return fatherId;
}
public void setFatherId(Long fatherId)
{
this.fatherId = fatherId;
}
public Integer getRanchId()
{
return ranchId;
}
public void setRanchId(Integer ranchId)
{
this.ranchId = ranchId;
}
public Integer getSheepfoldId()
{
return sheepfoldId;
}
public void setSheepfoldId(Integer sheepfoldId)
{
this.sheepfoldId = sheepfoldId;
}
public Integer getParity()
{
return parity;
}
public void setParity(Integer parity)
{
this.parity = parity;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -50,9 +50,9 @@ public class ScLambingRecord extends BaseEntity
private String comment;
/** 创建日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date createTme;
private Date createTime; // 改为 createTime
// ========== 关联查询字段简化版 ==========
@ -124,6 +124,8 @@ public class ScLambingRecord extends BaseEntity
/** 羔羊信息列表(从羊只信息表查询) */
private List<SheepLambInfo> lambInfoList;
private List<ScLambDetail> lambDetails;
// ========== 原有getter和setter方法 ==========
public void setId(Long id)
@ -206,14 +208,14 @@ public class ScLambingRecord extends BaseEntity
return comment;
}
public void setCreateTme(Date createTme)
public void setCreateTime(Date createTime)
{
this.createTme = createTme;
this.createTime = createTime;
}
public Date getCreateTme()
public Date getCreateTime()
{
return createTme;
return createTime;
}
// ========== 简化版关联字段的getter和setter方法 ==========
@ -282,6 +284,7 @@ public class ScLambingRecord extends BaseEntity
this.maleBreed = maleBreed;
}
public Integer getPregnancyDays() {
return pregnancyDays;
}
@ -354,6 +357,14 @@ public class ScLambingRecord extends BaseEntity
this.lambInfoList = lambInfoList;
}
public List<ScLambDetail> getLambDetails() {
return lambDetails;
}
public void setLambDetails(List<ScLambDetail> lambDetails) {
this.lambDetails = lambDetails;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -366,7 +377,7 @@ public class ScLambingRecord extends BaseEntity
.append("score", getScore())
.append("comment", getComment())
.append("createBy", getCreateBy())
.append("createTme", getCreateTme())
.append("createTime", getCreateTime()) // 改为 createTime
.append("femaleEarNumber", getFemaleEarNumber())
.append("femaleBreed", getFemaleBreed())
.append("farm", getFarm())
@ -380,7 +391,7 @@ public class ScLambingRecord extends BaseEntity
class SheepLambInfo {
private String lambEarNumber; // 羔羊耳号
private String lambBreed; // 羔羊品种
private String gender; // 性别
private Integer gender; // 性别
private Double birthWeight; // 出生重量
private Boolean isRetained; // 是否留养
private String lineage; // 家系

View File

@ -2,84 +2,62 @@ package com.zhyc.module.produce.breed.mapper;
import java.util.List;
import com.zhyc.module.produce.breed.domain.ScLambDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 羔羊详情Mapper接口
*
* @author ruoyi
* @date 2025-07-11
*/
public interface ScLambDetailMapper
{
/**
* 查询羔羊详情
*
* @param id 羔羊详情主键
* @return 羔羊详情
*/
public ScLambDetail selectScLambDetailById(Long id);
@Mapper
public interface ScLambDetailMapper {
/**
* 查询羔羊详情列表
*
* @param scLambDetail 羔羊详情
* @return 羔羊详情集合
*/
public List<ScLambDetail> selectScLambDetailList(ScLambDetail scLambDetail);
/**
* 根据产羔记录ID查询羔羊详情列表
*
* @param lambingRecordId 产羔记录ID
* @return 羔羊详情集合
*/
public List<ScLambDetail> selectScLambDetailByLambingRecordId(Long lambingRecordId);
/**
* 新增羔羊详情
*
* @param scLambDetail 羔羊详情
* @return 结果
*/
public int insertScLambDetail(ScLambDetail scLambDetail);
public int insertBasSheep(ScLambDetail scLambDetail);
/**
* 批量新增羔羊详情
*
* @param lambDetails 羔羊详情列表
* @return 结果
*/
public int insertScLambDetailBatch(List<ScLambDetail> lambDetails);
public int insertScLambDetailBatch(@Param("list") List<ScLambDetail> scLambDetailList);
public int insertBasSheepBatch(@Param("list") List<ScLambDetail> scLambDetailList);
/**
* 修改羔羊详情
*
* @param scLambDetail 羔羊详情
* @return 结果
*/
public int updateScLambDetail(ScLambDetail scLambDetail);
/**
* 删除羔羊详情
*
* @param id 羔羊详情主键
* @return 结果
*/
public int deleteScLambDetailById(Long id);
/**
* 批量删除羔羊详情
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScLambDetailByIds(Long[] ids);
/**
* 根据产羔记录ID删除羔羊详情
*
* @param lambingRecordId 产羔记录ID
* @return 结果
*/
public int deleteScLambDetailByLambingRecordId(Long lambingRecordId);
/**
* 查询羔羊详情
*/
public ScLambDetail selectScLambDetailById(Long id);
/**
* 根据产羔记录ID查询羔羊详情列表
*/
public List<ScLambDetail> selectScLambDetailByLambingRecordId(Long lambingRecordId);
/**
* 检查羔羊耳号是否已存在
*/
public int checkLambEarNumberExists(@Param("lambEarNumber") String lambEarNumber, @Param("excludeId") Long excludeId);
}

View File

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

View File

@ -1,112 +1,192 @@
package com.zhyc.module.produce.breed.service.impl;
import java.math.BigDecimal;
import java.util.List;
import com.zhyc.module.produce.breed.domain.ScLambDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zhyc.module.produce.breed.mapper.ScLambingRecordMapper;
import com.zhyc.module.produce.breed.mapper.ScLambDetailMapper;
import com.zhyc.module.produce.breed.domain.ScLambingRecord;
import com.zhyc.module.produce.breed.domain.ScLambDetail;
import com.zhyc.module.produce.breed.service.IScLambingRecordService;
import java.util.Collections;
/**
* 产羔记录Service业务层处理
*
* @author ruoyi
* @date 2025-07-11
*/
@Service
public class ScLambingRecordServiceImpl implements IScLambingRecordService
{
public class ScLambingRecordServiceImpl implements IScLambingRecordService {
@Autowired
private ScLambingRecordMapper scLambingRecordMapper;
/**
* 查询产羔记录
*
* @param id 产羔记录主键
* @return 产羔记录
*/
@Override
public ScLambingRecord selectScLambingRecordById(Long id)
{
return scLambingRecordMapper.selectScLambingRecordById(id);
}
@Autowired
private ScLambDetailMapper scLambDetailMapper;
/**
* 查询产羔记录列表
*
* @param scLambingRecord 产羔记录
* @return 产羔记录
*/
@Override
public List<ScLambingRecord> selectScLambingRecordList(ScLambingRecord scLambingRecord)
{
public List<ScLambingRecord> selectScLambingRecordList(ScLambingRecord scLambingRecord) {
return scLambingRecordMapper.selectScLambingRecordList(scLambingRecord);
}
/**
* 新增产羔记录包含羔羊详情
*/
@Override
public ScLambingRecord selectScLambingRecordDetailById(Long id) {
return null;
@Transactional
public int insertScLambingRecord(ScLambingRecord scLambingRecord) {
// 1. 插入产羔记录
int result = scLambingRecordMapper.insertScLambingRecord(scLambingRecord);
// 2. 如果有羔羊详情则批量插入羔羊详情
if (scLambingRecord.getLambDetails() != null && !scLambingRecord.getLambDetails().isEmpty()) {
insertLambDetails(scLambingRecord);
}
return result;
}
/**
* 新增产羔记录
*
* @param scLambingRecord 产羔记录
* @return 结果
* 批量插入羔羊详情
*/
@Override
public int insertScLambingRecord(ScLambingRecord scLambingRecord)
{
return scLambingRecordMapper.insertScLambingRecord(scLambingRecord);
private void insertLambDetails(ScLambingRecord scLambingRecord) {
// 遍历羔羊详情列表逐个插入
for (ScLambDetail lambDetail : scLambingRecord.getLambDetails()) {
// 设置产羔记录ID
lambDetail.setLambingRecordId(scLambingRecord.getId());
// 设置创建信息
lambDetail.setCreateBy(scLambingRecord.getCreateBy());
lambDetail.setCreateTime(scLambingRecord.getCreateTime());
// 数据验证和转换
validateAndConvertLambDetail(lambDetail);
// 插入羔羊详情
scLambDetailMapper.insertScLambDetail(lambDetail);
scLambDetailMapper.insertBasSheep(lambDetail);
}
}
/**
* 验证和转换羔羊详情
*/
/**
* 验证和转换羔羊详情
*/
private void validateAndConvertLambDetail(ScLambDetail lambDetail) {
// 验证必填字段
if (lambDetail.getLambEarNumber() == null || lambDetail.getLambEarNumber().trim().isEmpty()) {
throw new RuntimeException("羔羊耳号不能为空");
}
if (lambDetail.getGender() == null) { // 改为检查Integer类型
throw new RuntimeException("羔羊性别不能为空");
}
// 验证性别值的有效性假设0=母羊1=公羊
if (lambDetail.getGender() < 0 || lambDetail.getGender() > 1) {
throw new RuntimeException("羔羊性别值无效请使用0母羊或1公羊");
}
// 检查耳号是否已存在
int count = scLambDetailMapper.checkLambEarNumberExists(lambDetail.getLambEarNumber().trim(), null);
if (count > 0) {
throw new RuntimeException("羔羊耳号 [" + lambDetail.getLambEarNumber() + "] 已存在,请使用其他耳号");
}
// 设置默认值
if (lambDetail.getIsRetained() == null) {
lambDetail.setIsRetained(false);
}
if (lambDetail.getBirthday() == null) {
lambDetail.setBirthday(new java.util.Date());
}
// 处理体重前端可能传来的是number类型
if (lambDetail.getBirthWeight() == null) {
lambDetail.setBirthWeight(BigDecimal.ZERO);
}
// 验证品种ID
if (lambDetail.getLambBreed() == null) {
throw new RuntimeException("羔羊品种不能为空");
}
// 去除空格
lambDetail.setLambEarNumber(lambDetail.getLambEarNumber().trim());
if (lambDetail.getLineage() != null) {
lambDetail.setLineage(lambDetail.getLineage().trim());
}
}
/**
* 修改产羔记录
*
* @param scLambingRecord 产羔记录
* @return 结果
*/
@Override
public int updateScLambingRecord(ScLambingRecord scLambingRecord)
{
return scLambingRecordMapper.updateScLambingRecord(scLambingRecord);
@Transactional
public int updateScLambingRecord(ScLambingRecord scLambingRecord) {
// 更新产羔记录
int result = scLambingRecordMapper.updateScLambingRecord(scLambingRecord);
// 如果包含羔羊详情先删除原有的再插入新的
if (scLambingRecord.getLambDetails() != null) {
// 删除原有羔羊详情
scLambDetailMapper.deleteScLambDetailByLambingRecordId(scLambingRecord.getId());
// 插入新的羔羊详情
if (!scLambingRecord.getLambDetails().isEmpty()) {
insertLambDetails(scLambingRecord);
}
}
return result;
}
/**
* 批量删除产羔记录
*
* @param ids 需要删除的产羔记录主键
* @return 结果
*/
@Override
public int deleteScLambingRecordByIds(Long[] ids)
{
@Transactional
public int deleteScLambingRecordByIds(Long[] ids) {
// 先删除关联的羔羊详情
for (Long id : ids) {
scLambDetailMapper.deleteScLambDetailByLambingRecordId(id);
}
// 再删除产羔记录
return scLambingRecordMapper.deleteScLambingRecordByIds(ids);
}
/**
* 删除产羔记录信息
*
* @param id 产羔记录主键
* @return 结果
*/
@Override
public int deleteScLambingRecordById(Long id)
{
@Transactional
public int deleteScLambingRecordById(Long id) {
// 先删除关联的羔羊详情
scLambDetailMapper.deleteScLambDetailByLambingRecordId(id);
// 再删除产羔记录
return scLambingRecordMapper.deleteScLambingRecordById(id);
}
/**
* 查询产羔记录
*/
@Override
public ScLambingRecord selectScLambingRecordById(Long id) {
return scLambingRecordMapper.selectScLambingRecordById(id);
}
/**
* 查询羔羊详情
*/
@Override
public List<ScLambDetail> selectLambDetailByLambingRecordId(Long lambingRecordId) {
return Collections.emptyList();
}
@Override
public int insertLambDetailsBatch(List<ScLambDetail> lambDetails) {
return 0;
return scLambDetailMapper.selectScLambDetailByLambingRecordId(lambingRecordId);
}
}

View File

@ -0,0 +1,161 @@
package com.zhyc.module.produce.wean.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.produce.wean.domain.ScWeanRecord;
import com.zhyc.module.produce.wean.service.IScWeanRecordService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 断奶记录Controller
*
* @author zhyc
* @date 2024-01-01
*/
@RestController
@RequestMapping("/Weaning/weaning_record")
public class ScWeanRecordController extends BaseController {
@Autowired
private IScWeanRecordService scWeanRecordService;
/**
* 查询断奶记录列表
*/
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:list')")
@GetMapping("/list")
public TableDataInfo list(ScWeanRecord scWeanRecord) {
startPage();
List<ScWeanRecord> list = scWeanRecordService.selectScWeanRecordList(scWeanRecord);
return getDataTable(list);
}
/**
* 导出断奶记录列表
*/
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:export')")
@Log(title = "断奶记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScWeanRecord scWeanRecord) {
List<ScWeanRecord> list = scWeanRecordService.selectScWeanRecordList(scWeanRecord);
ExcelUtil<ScWeanRecord> util = new ExcelUtil<ScWeanRecord>(ScWeanRecord.class);
util.exportExcel(response, list, "断奶记录数据");
}
/**
* 获取断奶记录详细信息
*/
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(scWeanRecordService.selectScWeanRecordById(id));
}
/**
* 根据耳号查询羊只ID
*/
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:query')")
@GetMapping(value = "/sheepId/{earNumber}")
public AjaxResult getSheepIdByEarNumber(@PathVariable("earNumber") String earNumber) {
Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(earNumber);
if (sheepId != null) {
return success(sheepId);
} else {
return error("未找到对应的羊只信息");
}
}
/**
* 新增断奶记录
*/
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:add')")
@Log(title = "断奶记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScWeanRecord scWeanRecord) {
// 验证耳号是否存在
if (scWeanRecord.getEarNumber() != null) {
Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
if (sheepId == null) {
return error("耳号不存在,请检查后重新输入");
}
scWeanRecord.setSheepId(sheepId);
}
// 验证必要字段
if (scWeanRecord.getSheepId() == null) {
return error("羊只信息不能为空");
}
if (scWeanRecord.getDatetime() == null) {
return error("断奶日期不能为空");
}
if (scWeanRecord.getWeight() == null) {
return error("断奶重量不能为空");
}
if (scWeanRecord.getStatus() == null) {
return error("是否留养不能为空");
}
scWeanRecord.setCreateBy(getUsername());
return toAjax(scWeanRecordService.insertScWeanRecord(scWeanRecord));
}
/**
* 修改断奶记录
*/
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:edit')")
@Log(title = "断奶记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScWeanRecord scWeanRecord) {
// 验证耳号是否存在
if (scWeanRecord.getEarNumber() != null) {
Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
if (sheepId == null) {
return error("耳号不存在,请检查后重新输入");
}
scWeanRecord.setSheepId(sheepId);
}
// 验证必要字段
if (scWeanRecord.getId() == null) {
return error("记录ID不能为空");
}
if (scWeanRecord.getSheepId() == null) {
return error("羊只信息不能为空");
}
if (scWeanRecord.getDatetime() == null) {
return error("断奶日期不能为空");
}
if (scWeanRecord.getWeight() == null) {
return error("断奶重量不能为空");
}
if (scWeanRecord.getStatus() == null) {
return error("是否留养不能为空");
}
return toAjax(scWeanRecordService.updateScWeanRecord(scWeanRecord));
}
/**
* 删除断奶记录
*/
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:remove')")
@Log(title = "断奶记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(scWeanRecordService.deleteScWeanRecordByIds(ids));
}
}

View File

@ -0,0 +1,262 @@
package com.zhyc.module.produce.wean.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 断奶记录对象 sc_wean_record
*
* @author zhyc
* @date 2024-01-01
*/
public class ScWeanRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 羊只ID */
@Excel(name = "羊只ID")
private Long sheepId;
/** 断奶日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "断奶日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
/** 断奶重量 */
@Excel(name = "断奶重量")
private BigDecimal weight;
/** 是否留养 */
@Excel(name = "是否留养")
private String status;
/** 技术员 */
@Excel(name = "技术员")
private String technician;
/** 备注 */
@Excel(name = "备注")
private String comment;
/** 电子耳号 */
@Excel(name = "电子耳号")
private String electronicTags;
// 关联查询字段
/** 耳号 */
@Excel(name = "耳号")
private String earNumber;
/** 品种 */
@Excel(name = "品种")
private String breed;
/** 事件类型 */
@Excel(name = "事件类型")
private String eventType;
/** 性别 */
@Excel(name = "性别")
private String gender;
/** 父号 */
@Excel(name = "父号")
private String fatherNumber;
/** 母号 */
@Excel(name = "母号")
private String motherNumber;
/** 月龄 */
@Excel(name = "月龄")
private Integer monthAge;
/** 出生重量 */
@Excel(name = "出生重量")
private BigDecimal birthWeight;
/** 羊舍 */
@Excel(name = "羊舍")
private String sheepPen;
/** 繁育状态 */
@Excel(name = "繁育状态")
private String breedingStatus;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setSheepId(Long sheepId) {
this.sheepId = sheepId;
}
public Long getSheepId() {
return sheepId;
}
public void setDatetime(Date datetime) {
this.datetime = datetime;
}
public Date getDatetime() {
return datetime;
}
public void setWeight(BigDecimal weight) {
this.weight = weight;
}
public BigDecimal getWeight() {
return weight;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
public void setTechnician(String technician) {
this.technician = technician;
}
public String getTechnician() {
return technician;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getComment() {
return comment;
}
public void setElectronicTags(String electronicTags) {
this.electronicTags = electronicTags;
}
public String getElectronicTags() {
return electronicTags;
}
public void setEarNumber(String earNumber) {
this.earNumber = earNumber;
}
public String getEarNumber() {
return earNumber;
}
public void setBreed(String breed) {
this.breed = breed;
}
public String getBreed() {
return breed;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getEventType() {
return eventType;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getGender() {
return gender;
}
public void setFatherNumber(String fatherNumber) {
this.fatherNumber = fatherNumber;
}
public String getFatherNumber() {
return fatherNumber;
}
public void setMotherNumber(String motherNumber) {
this.motherNumber = motherNumber;
}
public String getMotherNumber() {
return motherNumber;
}
public void setMonthAge(Integer monthAge) {
this.monthAge = monthAge;
}
public Integer getMonthAge() {
return monthAge;
}
public void setBirthWeight(BigDecimal birthWeight) {
this.birthWeight = birthWeight;
}
public BigDecimal getBirthWeight() {
return birthWeight;
}
public void setSheepPen(String sheepPen) {
this.sheepPen = sheepPen;
}
public String getSheepPen() {
return sheepPen;
}
public void setBreedingStatus(String breedingStatus) {
this.breedingStatus = breedingStatus;
}
public String getBreedingStatus() {
return breedingStatus;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("sheepId", getSheepId())
.append("datetime", getDatetime())
.append("weight", getWeight())
.append("status", getStatus())
.append("technician", getTechnician())
.append("comment", getComment())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("electronicTags", getElectronicTags())
.append("earNumber", getEarNumber())
.append("breed", getBreed())
.append("eventType", getEventType())
.append("gender", getGender())
.append("fatherNumber", getFatherNumber())
.append("motherNumber", getMotherNumber())
.append("monthAge", getMonthAge())
.append("birthWeight", getBirthWeight())
.append("sheepPen", getSheepPen())
.append("breedingStatus", getBreedingStatus())
.toString();
}
}

View File

@ -0,0 +1,68 @@
package com.zhyc.module.produce.wean.mapper;
import java.util.List;
import com.zhyc.module.produce.wean.domain.ScWeanRecord;
/**
* 断奶记录Mapper接口
*
* @author zhyc
* @date 2024-01-01
*/
public interface ScWeanRecordMapper {
/**
* 查询断奶记录
*
* @param id 断奶记录主键
* @return 断奶记录
*/
public ScWeanRecord selectScWeanRecordById(Long id);
/**
* 查询断奶记录列表
*
* @param scWeanRecord 断奶记录
* @return 断奶记录集合
*/
public List<ScWeanRecord> selectScWeanRecordList(ScWeanRecord scWeanRecord);
/**
* 新增断奶记录
*
* @param scWeanRecord 断奶记录
* @return 结果
*/
public int insertScWeanRecord(ScWeanRecord scWeanRecord);
/**
* 修改断奶记录
*
* @param scWeanRecord 断奶记录
* @return 结果
*/
public int updateScWeanRecord(ScWeanRecord scWeanRecord);
/**
* 删除断奶记录
*
* @param id 断奶记录主键
* @return 结果
*/
public int deleteScWeanRecordById(Long id);
/**
* 批量删除断奶记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScWeanRecordByIds(Long[] ids);
/**
* 根据耳号查询羊只ID
*
* @param earNumber 耳号
* @return 羊只ID
*/
public Long selectSheepIdByEarNumber(String earNumber);
}

View File

@ -0,0 +1,68 @@
package com.zhyc.module.produce.wean.service;
import java.util.List;
import com.zhyc.module.produce.wean.domain.ScWeanRecord;
/**
* 断奶记录Service接口
*
* @author ruoyi
* @date 2025-07-13
*/
public interface IScWeanRecordService {
/**
* 查询断奶记录
*
* @param id 断奶记录主键
* @return 断奶记录
*/
public ScWeanRecord selectScWeanRecordById(Long id);
/**
* 查询断奶记录列表
*
* @param scWeanRecord 断奶记录
* @return 断奶记录集合
*/
public List<ScWeanRecord> selectScWeanRecordList(ScWeanRecord scWeanRecord);
/**
* 新增断奶记录
*
* @param scWeanRecord 断奶记录
* @return 结果
*/
public int insertScWeanRecord(ScWeanRecord scWeanRecord);
/**
* 修改断奶记录
*
* @param scWeanRecord 断奶记录
* @return 结果
*/
public int updateScWeanRecord(ScWeanRecord scWeanRecord);
/**
* 批量删除断奶记录
*
* @param ids 需要删除的断奶记录主键集合
* @return 结果
*/
public int deleteScWeanRecordByIds(Long[] ids);
/**
* 删除断奶记录信息
*
* @param id 断奶记录主键
* @return 结果
*/
public int deleteScWeanRecordById(Long id);
/**
* 根据耳号查询羊只ID
*
* @param earNumber 耳号
* @return 羊只ID
*/
public Long selectSheepIdByEarNumber(String earNumber);
}

View File

@ -0,0 +1,113 @@
package com.zhyc.module.produce.wean.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.wean.mapper.ScWeanRecordMapper;
import com.zhyc.module.produce.wean.domain.ScWeanRecord;
import com.zhyc.module.produce.wean.service.IScWeanRecordService;
/**
* 断奶记录Service业务层处理
*
* @author ruoyi
* @date 2025-07-13
*/
@Service
public class ScWeanRecordServiceImpl implements IScWeanRecordService {
@Autowired
private ScWeanRecordMapper scWeanRecordMapper;
/**
* 查询断奶记录
*
* @param id 断奶记录主键
* @return 断奶记录
*/
@Override
public ScWeanRecord selectScWeanRecordById(Long id) {
return scWeanRecordMapper.selectScWeanRecordById(id);
}
/**
* 查询断奶记录列表
*
* @param scWeanRecord 断奶记录
* @return 断奶记录
*/
@Override
public List<ScWeanRecord> selectScWeanRecordList(ScWeanRecord scWeanRecord) {
return scWeanRecordMapper.selectScWeanRecordList(scWeanRecord);
}
/**
* 新增断奶记录
*
* @param scWeanRecord 断奶记录
* @return 结果
*/
@Override
public int insertScWeanRecord(ScWeanRecord scWeanRecord) {
// 如果前端传递的是耳号需要先获取羊只ID
if (scWeanRecord.getEarNumber() != null && scWeanRecord.getSheepId() == null) {
Long sheepId = scWeanRecordMapper.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
if (sheepId != null) {
scWeanRecord.setSheepId(sheepId);
}
}
scWeanRecord.setCreateTime(DateUtils.getNowDate());
return scWeanRecordMapper.insertScWeanRecord(scWeanRecord);
}
/**
* 修改断奶记录
*
* @param scWeanRecord 断奶记录
* @return 结果
*/
@Override
public int updateScWeanRecord(ScWeanRecord scWeanRecord) {
// 如果前端传递的是耳号需要先获取羊只ID
if (scWeanRecord.getEarNumber() != null && scWeanRecord.getSheepId() == null) {
Long sheepId = scWeanRecordMapper.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
if (sheepId != null) {
scWeanRecord.setSheepId(sheepId);
}
}
return scWeanRecordMapper.updateScWeanRecord(scWeanRecord);
}
/**
* 批量删除断奶记录
*
* @param ids 需要删除的断奶记录主键
* @return 结果
*/
@Override
public int deleteScWeanRecordByIds(Long[] ids) {
return scWeanRecordMapper.deleteScWeanRecordByIds(ids);
}
/**
* 删除断奶记录信息
*
* @param id 断奶记录主键
* @return 结果
*/
@Override
public int deleteScWeanRecordById(Long id) {
return scWeanRecordMapper.deleteScWeanRecordById(id);
}
/**
* 根据耳号查询羊只ID
*
* @param earNumber 耳号
* @return 羊只ID
*/
@Override
public Long selectSheepIdByEarNumber(String earNumber) {
return scWeanRecordMapper.selectSheepIdByEarNumber(earNumber);
}
}

View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.wean.mapper.ScWeanRecordMapper">
<resultMap type="ScWeanRecord" id="ScWeanRecordResult">
<result property="id" column="id" />
<result property="sheepId" column="sheep_id" />
<result property="datetime" column="datetime" />
<result property="weight" column="weight" />
<result property="status" column="status" />
<result property="technician" column="technician" />
<result property="comment" column="comment" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="electronicTags" column="electronic_tags" />
<!-- 关联查询的字段 -->
<result property="earNumber" column="bs_manage_tags" />
<result property="breed" column="variety" />
<result property="eventType" column="event_type" />
<result property="gender" column="gender" />
<result property="fatherNumber" column="father_manage_tags" />
<result property="motherNumber" column="mother_manage_tags" />
<result property="monthAge" column="month_age" />
<result property="birthWeight" column="birth_weight" />
<result property="sheepPen" column="sheepfold_name" />
<result property="breedingStatus" column="breed" />
</resultMap>
<!-- 带关联查询的基础SQL -->
<sql id="selectScWeanRecordVo">
select
wr.id, wr.sheep_id, wr.datetime, wr.weight, wr.status, wr.technician,
wr.comment, wr.create_by, wr.create_time, wr.electronic_tags,
sf.bs_manage_tags, sf.variety, sf.gender, sf.father_manage_tags, sf.mother_manage_tags,
sf.birth_weight, sf.sheepfold_name, sf.breed, sf.month_age,
'断奶' as event_type
from sc_wean_record wr
left join sheep_file sf on wr.sheep_id = sf.id
</sql>
<!-- 查询断奶记录列表 -->
<select id="selectScWeanRecordList" parameterType="ScWeanRecord" resultMap="ScWeanRecordResult">
<include refid="selectScWeanRecordVo"/>
<where>
<if test="sheepId != null "> and wr.sheep_id = #{sheepId}</if>
<if test="earNumber != null and earNumber != ''"> and sf.bs_manage_tags like concat('%', #{earNumber}, '%')</if>
<if test="datetime != null "> and wr.datetime = #{datetime}</if>
<if test="weight != null "> and wr.weight = #{weight}</if>
<if test="status != null "> and wr.status = #{status}</if>
<if test="technician != null and technician != ''"> and wr.technician like concat('%', #{technician}, '%')</if>
<if test="comment != null and comment != ''"> and wr.comment like concat('%', #{comment}, '%')</if>
<if test="createBy != null and createBy != ''"> and wr.create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and wr.create_time = #{createTime}</if>
<if test="electronicTags != null and electronicTags != ''"> and wr.electronic_tags like concat('%', #{electronicTags}, '%')</if>
<if test="breed != null and breed != ''"> and sf.variety like concat('%', #{breed}, '%')</if>
<if test="gender != null and gender != ''"> and sf.gender = #{gender}</if>
<if test="fatherNumber != null and fatherNumber != ''"> and sf.father_manage_tags like concat('%', #{fatherNumber}, '%')</if>
<if test="motherNumber != null and motherNumber != ''"> and sf.mother_manage_tags like concat('%', #{motherNumber}, '%')</if>
<if test="sheepPen != null and sheepPen != ''"> and sf.sheepfold_name like concat('%', #{sheepPen}, '%')</if>
<if test="breedingStatus != null and breedingStatus != ''"> and sf.breed = #{breedingStatus}</if>
</where>
order by wr.create_time desc
</select>
<!-- 根据ID查询断奶记录 -->
<select id="selectScWeanRecordById" parameterType="Long" resultMap="ScWeanRecordResult">
<include refid="selectScWeanRecordVo"/>
where wr.id = #{id}
</select>
<!-- 根据耳号查询羊只ID -->
<select id="selectSheepIdByEarNumber" parameterType="String" resultType="Long">
select id from sheep_file where bs_manage_tags = #{earNumber}
</select>
<!-- 插入断奶记录 -->
<insert id="insertScWeanRecord" parameterType="ScWeanRecord" useGeneratedKeys="true" keyProperty="id">
insert into sc_wean_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="datetime != null">datetime,</if>
<if test="weight != null">weight,</if>
<if test="status != null">status,</if>
<if test="technician != null">technician,</if>
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="electronicTags != null">electronic_tags,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="datetime != null">#{datetime},</if>
<if test="weight != null">#{weight},</if>
<if test="status != null">#{status},</if>
<if test="technician != null">#{technician},</if>
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="electronicTags != null">#{electronicTags},</if>
</trim>
</insert>
<!-- 更新断奶记录 -->
<update id="updateScWeanRecord" parameterType="ScWeanRecord">
update sc_wean_record
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="datetime != null">datetime = #{datetime},</if>
<if test="weight != null">weight = #{weight},</if>
<if test="status != null">status = #{status},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="electronicTags != null">electronic_tags = #{electronicTags},</if>
</trim>
where id = #{id}
</update>
<!-- 删除断奶记录 -->
<delete id="deleteScWeanRecordById" parameterType="Long">
delete from sc_wean_record where id = #{id}
</delete>
<!-- 批量删除断奶记录 -->
<delete id="deleteScWeanRecordByIds" parameterType="String">
delete from sc_wean_record where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,256 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScLambDetailMapper">
<!-- 羔羊详情结果映射 -->
<resultMap type="ScLambDetail" id="ScLambDetailResult">
<result property="id" column="id" />
<result property="lambingRecordId" column="lambing_record_id" />
<result property="lambEarNumber" column="lamb_ear_number" />
<result property="lambBreed" column="lamb_breed" />
<result property="gender" column="gender" />
<result property="birthWeight" column="birth_weight" />
<result property="isRetained" column="is_retained" />
<result property="lineage" column="lineage" />
<result property="birthday" column="birthday" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<!-- 基础查询SQL -->
<sql id="selectScLambDetailVo">
select id, lambing_record_id, lamb_ear_number, lamb_breed, gender, birth_weight,
is_retained, lineage, birthday, create_by, create_time, update_by, update_time
from sc_lamb_detail
</sql>
<!-- 查询羔羊详情列表 -->
<select id="selectScLambDetailList" parameterType="ScLambDetail" resultMap="ScLambDetailResult">
<include refid="selectScLambDetailVo"/>
<where>
<if test="lambingRecordId != null"> and lambing_record_id = #{lambingRecordId}</if>
<if test="lambEarNumber != null and lambEarNumber != ''"> and lamb_ear_number like concat('%', #{lambEarNumber}, '%')</if>
<if test="lambBreed != null"> and lamb_breed = #{lambBreed}</if>
<if test="gender != null"> and gender = #{gender}</if>
<if test="isRetained != null"> and is_retained = #{isRetained}</if>
<if test="lineage != null and lineage != ''"> and lineage like concat('%', #{lineage}, '%')</if>
</where>
order by create_time desc
</select>
<!-- 查询羔羊详情 -->
<select id="selectScLambDetailById" parameterType="Long" resultMap="ScLambDetailResult">
<include refid="selectScLambDetailVo"/>
where id = #{id}
</select>
<!-- 根据产羔记录ID查询羔羊详情列表 -->
<select id="selectScLambDetailByLambingRecordId" parameterType="Long" resultMap="ScLambDetailResult">
<include refid="selectScLambDetailVo"/>
where lambing_record_id = #{lambingRecordId}
order by create_time asc
</select>
<!-- 检查羔羊耳号是否已存在 -->
<select id="checkLambEarNumberExists" resultType="int">
select count(*) from sc_lamb_detail
where lamb_ear_number = #{lambEarNumber}
<if test="excludeId != null">
and id != #{excludeId}
</if>
</select>
<!-- 新增羔羊详情同步录入到bas_sheep表 -->
<insert id="insertScLambDetail" parameterType="ScLambDetail" useGeneratedKeys="true" keyProperty="id">
<!-- 插入到sc_lamb_detail表 -->
insert into sc_lamb_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="lambingRecordId != null">lambing_record_id,</if>
<if test="lambEarNumber != null and lambEarNumber != ''">lamb_ear_number,</if>
<if test="lambBreed != null">lamb_breed,</if>
<if test="gender != null">gender,</if>
<if test="birthWeight != null">birth_weight,</if>
<if test="isRetained != null">is_retained,</if>
<if test="lineage != null">lineage,</if>
<if test="birthday != null">birthday,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="lambingRecordId != null">#{lambingRecordId},</if>
<if test="lambEarNumber != null and lambEarNumber != ''">#{lambEarNumber},</if>
<if test="lambBreed != null">#{lambBreed},</if>
<if test="gender != null ">#{gender},</if>
<if test="birthWeight != null">#{birthWeight},</if>
<if test="isRetained != null">#{isRetained},</if>
<if test="lineage != null">#{lineage},</if>
<if test="birthday != null">#{birthday},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<!-- 同步插入到bas_sheep表 -->
<insert id="insertBasSheep" parameterType="ScLambDetail">
insert into bas_sheep
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="lambEarNumber != null and lambEarNumber != ''">manage_tags,</if>
<if test="lambBreed != null">variety_id,</if>
<if test="gender != null">gender,</if>
<if test="birthday != null">birthday,</if>
<if test="birthWeight != null">birth_weight,</if>
<if test="lineage != null">family,</if>
<if test="motherId != null">mother_id,</if>
<if test="fatherId != null">father_id,</if>
<if test="ranchId != null">ranch_id,</if>
<if test="sheepfoldId != null">sheepfold_id,</if>
<if test="parity != null">parity,</if>
<if test="isRetained != null">status_id,</if>
type_id,
breed_status_id,
is_delete,
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="lambEarNumber != null and lambEarNumber != ''">#{lambEarNumber},</if>
<if test="lambBreed != null">#{lambBreed},</if>
<if test="gender != null">#{gender},</if>
<if test="birthday != null">#{birthday},</if>
<if test="birthWeight != null">#{birthWeight},</if>
<if test="lineage != null">#{lineage},</if>
<if test="motherId != null">#{motherId},</if>
<if test="fatherId != null">#{fatherId},</if>
<if test="ranchId != null">#{ranchId},</if>
<if test="sheepfoldId != null">#{sheepfoldId},</if>
<if test="parity != null">#{parity},</if>
<if test="isRetained != null">#{isRetained},</if>
3, <!-- type_id: 3表示羔羊 -->
1, <!-- breed_status_id: 1表示初始繁育状态 -->
0, <!-- is_delete: 0表示未删除 -->
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<!-- 批量新增羔羊详情同步录入到bas_sheep表 -->
<insert id="insertScLambDetailBatch" parameterType="java.util.List">
<!-- 批量插入到sc_lamb_detail表 -->
insert into sc_lamb_detail (lambing_record_id, lamb_ear_number, lamb_breed, gender, birth_weight,
is_retained, lineage, birthday, create_by, create_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.lambingRecordId}, #{item.lambEarNumber}, #{item.lambBreed}, #{item.gender},
#{item.birthWeight}, #{item.isRetained}, #{item.lineage}, #{item.birthday},
#{item.createBy}, #{item.createTime})
</foreach>
</insert>
<!-- 批量同步插入到bas_sheep表 -->
<insert id="insertBasSheepBatch" parameterType="java.util.List">
insert into bas_sheep (manage_tags, variety_id, gender, birthday, birth_weight, family,
mother_id, father_id, ranch_id, sheepfold_id, parity, status_id, type_id, breed_status_id, is_delete, create_by, create_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.lambEarNumber}, #{item.lambBreed}, #{item.gender}, #{item.birthday},
#{item.birthWeight}, #{item.lineage}, #{item.motherId}, #{item.fatherId},
#{item.ranchId}, #{item.sheepfoldId}, #{item.parity}, #{item.isRetained},
3, 1, 0, #{item.createBy}, #{item.createTime})
</foreach>
</insert>
<!-- 修改羔羊详情同步更新bas_sheep表 -->
<update id="updateScLambDetail" parameterType="ScLambDetail">
update sc_lamb_detail
<trim prefix="SET" suffixOverrides=",">
<if test="lambingRecordId != null">lambing_record_id = #{lambingRecordId},</if>
<if test="lambEarNumber != null and lambEarNumber != ''">lamb_ear_number = #{lambEarNumber},</if>
<if test="lambBreed != null">lamb_breed = #{lambBreed},</if>
<if test="gender != null">gender = #{gender},</if>
<if test="birthWeight != null">birth_weight = #{birthWeight},</if>
<if test="isRetained != null">is_retained = #{isRetained},</if>
<if test="lineage != null">lineage = #{lineage},</if>
<if test="birthday != null">birthday = #{birthday},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<!-- 同步更新bas_sheep表 -->
<update id="updateBasSheep" parameterType="ScLambDetail">
update bas_sheep
<trim prefix="SET" suffixOverrides=",">
<if test="lambEarNumber != null and lambEarNumber != ''">manage_tags = #{lambEarNumber},</if>
<if test="lambBreed != null">variety_id = #{lambBreed},</if>
<if test="gender != null ">gender = #{gender},</if>
<if test="birthday != null">birthday = #{birthday},</if>
<if test="birthWeight != null">birth_weight = #{birthWeight},</if>
<if test="lineage != null">family = #{lineage},</if>
<if test="isRetained != null">status_id = #{isRetained},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where manage_tags = #{lambEarNumber} and is_delete = 0
</update>
<!-- 删除羔羊详情同步删除bas_sheep表 -->
<delete id="deleteScLambDetailById" parameterType="Long">
delete from sc_lamb_detail where id = #{id}
</delete>
<!-- 同步删除bas_sheep表中的羔羊记录 -->
<update id="deleteBasSheepByEarNumber" parameterType="String">
update bas_sheep set is_delete = 1 where manage_tags = #{lambEarNumber}
</update>
<!-- 批量删除羔羊详情同步删除bas_sheep表 -->
<delete id="deleteScLambDetailByIds" parameterType="String">
delete from sc_lamb_detail where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 批量同步删除bas_sheep表中的羔羊记录 -->
<update id="deleteBasSheepByEarNumbers" parameterType="String">
update bas_sheep set is_delete = 1 where manage_tags in
<foreach item="earNumber" collection="array" open="(" separator="," close=")">
#{earNumber}
</foreach>
</update>
<!-- 根据产羔记录ID删除羔羊详情同步删除bas_sheep表 -->
<delete id="deleteScLambDetailByLambingRecordId" parameterType="Long">
delete from sc_lamb_detail where lambing_record_id = #{lambingRecordId}
</delete>
<!-- 同步删除bas_sheep表中对应产羔记录的羔羊 -->
<update id="deleteBasSheepByLambingRecordId" parameterType="Long">
update bas_sheep set is_delete = 1
where manage_tags in (
select lamb_ear_number from sc_lamb_detail
where lambing_record_id = #{lambingRecordId}
)
</update>
<!-- 根据产羔记录获取母羊和父羊信息 -->
<select id="getParentInfoByLambingRecordId" parameterType="Long" resultType="java.util.Map">
SELECT
lr.sheep_id as motherId,
mother.ranch_id as ranchId,
mother.sheepfold_id as sheepfoldId,
mother.parity as parity,
father.id as fatherId
FROM sc_lambing_record lr
LEFT JOIN bas_sheep mother ON lr.sheep_id = mother.id
LEFT JOIN sc_breed_record br ON lr.sheep_id = br.ewe_id AND lr.parity = mother.parity
LEFT JOIN bas_sheep father ON br.ram_id = father.id
WHERE lr.id = #{lambingRecordId}
</select>
</mapper>

View File

@ -15,7 +15,7 @@
<result property="score" column="score" />
<result property="comment" column="comment" />
<result property="createBy" column="create_by" />
<result property="createTme" column="create_tme" />
<result property="createTime" column="create_tme" />
</resultMap>
<!-- 详细结果映射(包含关联信息) -->
@ -29,7 +29,7 @@
<result property="score" column="score" />
<result property="comment" column="comment" />
<result property="createBy" column="create_by" />
<result property="createTme" column="create_tme" />
<result property="createTime" column="create_tme" />
<!-- 母羊信息 -->
<result property="femaleEarNumber" column="female_ear_number" />
@ -110,7 +110,7 @@
<if test="score != null"> and lr.score = #{score}</if>
<if test="comment != null and comment != ''"> and lr.comment LIKE CONCAT('%', #{comment}, '%')</if>
<if test="createBy != null and createBy != ''"> and lr.create_by = #{createBy}</if>
<if test="createTme != null"> and DATE(lr.create_tme) = #{createTme}</if>
<if test="createTime != null"> and DATE(lr.create_tme) = #{createTime}</if>
<if test="params.beginBreedingDate != null and params.beginBreedingDate != ''"><!-- 配种日期开始 -->
and DATE(br.create_time) &gt;= #{params.beginBreedingDate}
</if>
@ -134,27 +134,23 @@
where lr.id = #{id} and mother.is_delete = 0
</select>
<!-- 查询羔羊详情(从bas_sheep表查询) -->
<select id="selectLambDetailByLambingRecordId" parameterType="Long" resultType="map">
<!-- 查询羔羊详情(从sc_lamb_detail表查询) -->
<select id="selectLambDetailByLambingRecordId" parameterType="Long" resultType="ScLambDetail">
SELECT
sheep.manage_tags as lambEarNumber,
sheep.variety_id as lambBreed,
CASE sheep.gender
WHEN 1 THEN 'male'
WHEN 0 THEN 'female'
ELSE 'unknown'
END as gender,
sheep.birth_weight as birthWeight,
CASE sheep.status_id
WHEN 1 THEN true
ELSE false
END as isRetained,
sheep.family as lineage,
sheep.birthday
FROM bas_sheep sheep
WHERE sheep.mother_id = (SELECT sheep_id FROM sc_lambing_record WHERE id = #{lambingRecordId})
AND sheep.is_delete = 0
ORDER BY sheep.birthday ASC
id,
lambing_record_id as lambingRecordId,
lamb_ear_number as lambEarNumber,
lamb_breed as lambBreed,
gender,
birth_weight as birthWeight,
is_retained as isRetained,
lineage,
birthday,
create_by as createBy,
create_time as createTime
FROM sc_lamb_detail
WHERE lambing_record_id = #{lambingRecordId}
ORDER BY create_time ASC
</select>
<!-- 新增产羔记录 -->
@ -169,7 +165,7 @@
<if test="score != null">score,</if>
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTme != null">create_tme,</if>
<if test="createTime != null">create_tme,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@ -180,7 +176,7 @@
<if test="score != null">#{score},</if>
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTme != null">#{createTme},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
@ -196,7 +192,7 @@
<if test="score != null">score = #{score},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTme != null">create_tme = #{createTme},</if>
<if test="createTime != null">create_tme = #{createTime},</if>
</trim>
where id = #{id}
</update>

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.dryMatterCorrection.mapper.XzDryMatterCorrectionMapper">
<mapper namespace="com.zhyc.module.dairyProducts.dryMatterCorrection.mapper.XzDryMatterCorrectionMapper">
<resultMap type="XzDryMatterCorrection" id="XzDryMatterCorrectionResult">
<result property="id" column="id"/>

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.parityCorrection.mapper.XzParityCorrectionMapper">
<mapper namespace="com.zhyc.module.dairyProducts.parityCorrection.mapper.XzParityCorrectionMapper">
<resultMap type="XzParityCorrection" id="XzParityCorrectionResult">
<result property="id" column="id" />

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.weightCorrection.mapper.XzWegihCorrectionMapper">
<mapper namespace="com.zhyc.module.dairyProducts.weightCorrection.mapper.XzWegihCorrectionMapper">
<resultMap type="XzWegihCorrection" id="XzWegihCorrectionResult">
<result property="id" column="id" />

View File

@ -0,0 +1,56 @@
<?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.base.variety.mapper.BasSheepVarietyMapper">
<resultMap type="BasSheepVariety" id="BasSheepVarietyResult">
<result property="id" column="id" />
<result property="variety" column="variety" />
</resultMap>
<sql id="selectBasSheepVarietyVo">
select id, variety from bas_sheep_variety
</sql>
<select id="selectBasSheepVarietyList" parameterType="BasSheepVariety" resultMap="BasSheepVarietyResult">
<include refid="selectBasSheepVarietyVo"/>
<where>
<if test="variety != null and variety != ''"> and variety = #{variety}</if>
</where>
</select>
<select id="selectBasSheepVarietyById" parameterType="Long" resultMap="BasSheepVarietyResult">
<include refid="selectBasSheepVarietyVo"/>
where id = #{id}
</select>
<insert id="insertBasSheepVariety" parameterType="BasSheepVariety" useGeneratedKeys="true" keyProperty="id">
insert into bas_sheep_variety
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="variety != null">variety,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="variety != null">#{variety},</if>
</trim>
</insert>
<update id="updateBasSheepVariety" parameterType="BasSheepVariety">
update bas_sheep_variety
<trim prefix="SET" suffixOverrides=",">
<if test="variety != null">variety = #{variety},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBasSheepVarietyById" parameterType="Long">
delete from bas_sheep_variety where id = #{id}
</delete>
<delete id="deleteBasSheepVarietyByIds" parameterType="String">
delete from bas_sheep_variety where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>