Compare commits

...

2 Commits

Author SHA1 Message Date
zyh
2f5bf785a7 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	zhyc-module/src/main/java/com/zhyc/module/base/mapper/BasSheepMapper.java
#	zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScTransitionInfoMapper.java
2025-07-29 21:59:44 +08:00
zyh
9b0fd3799e 新增羊只,转场,转群,改耳号,改品种,改备注,体尺测量,体况评分,乳况评分,修蹄,去势初版 2025-07-29 21:58:46 +08:00
79 changed files with 4399 additions and 310 deletions

View File

@ -1,12 +1,16 @@
package com.zhyc.module.base.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.BasSheepVariety;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.service.IBasSheepService;
import com.zhyc.module.base.service.IBasSheepVarietyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -29,6 +33,9 @@ public class BasSheepController extends BaseController {
@Autowired
private IBasSheepService basSheepService;
@Autowired
private IBasSheepVarietyService basSheepVarietyService;
/**
* 查询羊只基本信息列表
*/
@ -97,6 +104,14 @@ public class BasSheepController extends BaseController {
@GetMapping("/byManageTags/{manageTags}")
public AjaxResult byManageTags(@PathVariable String manageTags) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
if (sheep == null) {
return error("未找到对应的羊只");
}
// 补品种名称
BasSheepVariety variety = basSheepVarietyService.selectBasSheepVarietyById(sheep.getVarietyId());
sheep.setVarietyName(variety == null ? "" : variety.getVariety());
return success(sheep);
}
@ -107,7 +122,6 @@ public class BasSheepController extends BaseController {
@GetMapping("/listByTypeId")
public TableDataInfo listByTypeId(Integer typeId) {
if (typeId == null) {
// Java 8 中返回空列表的方式替代 List.of()
return getDataTable(new ArrayList<>());
}
BasSheep query = new BasSheep();
@ -124,7 +138,6 @@ public class BasSheepController extends BaseController {
@GetMapping("/listBySheepfoldAndType")
public TableDataInfo listBySheepfoldAndType(Integer sheepfoldId, Integer typeId) {
if (sheepfoldId == null || typeId == null) {
// Java 8 中返回空列表的方式替代 List.of()
return getDataTable(new ArrayList<>());
}
BasSheep query = new BasSheep();
@ -134,4 +147,58 @@ public class BasSheepController extends BaseController {
List<BasSheep> list = basSheepService.selectBasSheepList(query);
return getDataTable(list);
}
/**
* 根据耳号管理耳号或电子耳号+ 耳号类型 查询羊只信息
* earType0-电子耳号1-管理耳号
*/
@GetMapping("/byEarNumber")
public AjaxResult byEarNumber(@RequestParam String earNumber, @RequestParam Integer earType) {
BasSheep query = new BasSheep();
query.setManageTags(earNumber);
List<BasSheep> list = basSheepService.selectBasSheepList(query);
if (list.isEmpty()) {
query.setManageTags(null);
query.setElectronicTags(earNumber);
list = basSheepService.selectBasSheepList(query);
}
if (list.isEmpty()) {
return error("未找到对应的羊只");
}
BasSheep sheep = list.get(0);
String oldTag = earType == 0 ? sheep.getElectronicTags() : sheep.getManageTags();
Map<String, Object> result = new HashMap<>();
result.put("sheep", sheep);
result.put("oldTag", oldTag);
return success(result);
}
/**
* 判断耳号是否存在用于新增羊只时校验
*/
@GetMapping("/existsByManageTags/{manageTags}")
public AjaxResult existsByManageTags(@PathVariable String manageTags) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
if (sheep != null) {
return success(true);
}
return success(false);
}
@GetMapping("/existsByTag")
public AjaxResult existsByTag(@RequestParam String tag, @RequestParam Integer earType) {
boolean exists = basSheepService.existsByTag(tag, earType);
Map<String, Object> result = new HashMap<>();
result.put("exists", exists);
return success(result);
}
}

View File

@ -0,0 +1,119 @@
package com.zhyc.module.base.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.service.IBasSheepService;
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.domain.DaRanch;
import com.zhyc.module.base.service.IDaRanchService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 牧场管理Controller
*
* @author ruoyi
* @date 2025-07-22
*/
@RestController
@RequestMapping("/ranch/ranch")
public class DaRanchController extends BaseController
{
@Autowired
private IDaRanchService daRanchService;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询牧场管理列表
*/
@PreAuthorize("@ss.hasPermi('ranch:ranch:list')")
@GetMapping("/list")
public TableDataInfo list(DaRanch daRanch)
{
startPage();
List<DaRanch> list = daRanchService.selectDaRanchList(daRanch);
return getDataTable(list);
}
/**
* 导出牧场管理列表
*/
@PreAuthorize("@ss.hasPermi('ranch:ranch:export')")
@Log(title = "牧场管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DaRanch daRanch)
{
List<DaRanch> list = daRanchService.selectDaRanchList(daRanch);
ExcelUtil<DaRanch> util = new ExcelUtil<DaRanch>(DaRanch.class);
util.exportExcel(response, list, "牧场管理数据");
}
/**
* 获取牧场管理详细信息
*/
@PreAuthorize("@ss.hasPermi('ranch:ranch:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(daRanchService.selectDaRanchById(id));
}
/**
* 获取指定牧场下的所有羊只耳号
*/
@GetMapping("/getSheepByRanchId/{ranchId}")
public AjaxResult getSheepByRanchId(@PathVariable Long ranchId) {
List<BasSheep> sheepList = basSheepService.getSheepByRanchId(ranchId);
return AjaxResult.success(sheepList);
}
/**
* 新增牧场管理
*/
@PreAuthorize("@ss.hasPermi('ranch:ranch:add')")
@Log(title = "牧场管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DaRanch daRanch)
{
return toAjax(daRanchService.insertDaRanch(daRanch));
}
/**
* 修改牧场管理
*/
@PreAuthorize("@ss.hasPermi('ranch:ranch:edit')")
@Log(title = "牧场管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DaRanch daRanch)
{
return toAjax(daRanchService.updateDaRanch(daRanch));
}
/**
* 删除牧场管理
*/
@PreAuthorize("@ss.hasPermi('ranch:ranch:remove')")
@Log(title = "牧场管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(daRanchService.deleteDaRanchByIds(ids));
}
}

View File

@ -48,6 +48,9 @@ public class BasSheep extends BaseEntity
@Excel(name = "品种id")
private Long varietyId;
//仅用于改品种页面的回显
private String varietyName;
/** 家系 */
@Excel(name = "家系")
private String family;

View File

@ -0,0 +1,31 @@
package com.zhyc.module.base.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
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;
/**
* 牧场管理对象 da_ranch
*
* @author ruoyi
* @date 2025-07-22
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DaRanch extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 牧场名称 */
private String ranch;
}

View File

@ -3,7 +3,7 @@ package com.zhyc.module.base.mapper;
import java.util.List;
import com.zhyc.module.base.domain.BasSheep;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 羊只基本信息Mapper接口
@ -11,7 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
* @author ruoyi
* @date 2025-07-15
*/
@Mapper
public interface BasSheepMapper
{
/**
@ -71,5 +70,12 @@ public interface BasSheepMapper
List<BasSheep> selectBasSheepBySheepfold(String id);
// 根据牧场ID获取羊只列表
List<BasSheep> getSheepByRanchId(Long ranchId);
List<BasSheep> selectBasSheepListByIds(List<Long> ids);
//用于校验改耳号部分新管理/电子耳号
int existsByManageTag(@Param("tag") String tag);
int existsByElectronicTag(@Param("tag") String tag);
}

View File

@ -70,4 +70,6 @@ public interface BasSheepVarietyMapper
* @return 品种 ID
*/
Long selectIdByName(String varietyName);
BasSheepVariety selectByVarietyName(String varietyName);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.base.mapper;
import java.util.List;
import com.zhyc.module.base.domain.DaRanch;
/**
* 牧场管理Mapper接口
*
* @author ruoyi
* @date 2025-07-22
*/
public interface DaRanchMapper
{
/**
* 查询牧场管理
*
* @param id 牧场管理主键
* @return 牧场管理
*/
public DaRanch selectDaRanchById(Long id);
/**
* 查询牧场管理列表
*
* @param daRanch 牧场管理
* @return 牧场管理集合
*/
public List<DaRanch> selectDaRanchList(DaRanch daRanch);
/**
* 新增牧场管理
*
* @param daRanch 牧场管理
* @return 结果
*/
public int insertDaRanch(DaRanch daRanch);
/**
* 修改牧场管理
*
* @param daRanch 牧场管理
* @return 结果
*/
public int updateDaRanch(DaRanch daRanch);
/**
* 删除牧场管理
*
* @param id 牧场管理主键
* @return 结果
*/
public int deleteDaRanchById(Long id);
/**
* 批量删除牧场管理
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDaRanchByIds(Long[] ids);
}

View File

@ -60,7 +60,18 @@ public interface IBasSheepService
*/
public int deleteBasSheepById(Long id);
/**
* 根据羊只耳号获取羊只
*/
BasSheep selectBasSheepByManageTags(String trim);
/**
* 根据牧场ID获取羊只列表
*/
List<BasSheep> getSheepByRanchId(Long ranchId);
List<BasSheep> selectBasSheepListByIds(List<Long> ids);
//校验新管理/电子耳号
boolean existsByTag(String tag, Integer earType);
}

View File

@ -59,4 +59,9 @@ public interface IBasSheepVarietyService
* @return 结果
*/
public int deleteBasSheepVarietyById(Long id);
// 根据品种名称查询品种
public BasSheepVariety selectByVarietyName(String varietyName);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.base.service;
import java.util.List;
import com.zhyc.module.base.domain.DaRanch;
/**
* 牧场管理Service接口
*
* @author ruoyi
* @date 2025-07-22
*/
public interface IDaRanchService
{
/**
* 查询牧场管理
*
* @param id 牧场管理主键
* @return 牧场管理
*/
public DaRanch selectDaRanchById(Long id);
/**
* 查询牧场管理列表
*
* @param daRanch 牧场管理
* @return 牧场管理集合
*/
public List<DaRanch> selectDaRanchList(DaRanch daRanch);
/**
* 新增牧场管理
*
* @param daRanch 牧场管理
* @return 结果
*/
public int insertDaRanch(DaRanch daRanch);
/**
* 修改牧场管理
*
* @param daRanch 牧场管理
* @return 结果
*/
public int updateDaRanch(DaRanch daRanch);
/**
* 批量删除牧场管理
*
* @param ids 需要删除的牧场管理主键集合
* @return 结果
*/
public int deleteDaRanchByIds(Long[] ids);
/**
* 删除牧场管理信息
*
* @param id 牧场管理主键
* @return 结果
*/
public int deleteDaRanchById(Long id);
}

View File

@ -100,6 +100,26 @@ public class BasSheepServiceImpl implements IBasSheepService
return basSheepMapper.selectBasSheepByManageTags(manageTags);
}
@Override
public List<BasSheep> getSheepByRanchId(Long ranchId) {
return basSheepMapper.getSheepByRanchId(ranchId);
}
@Override
public List<BasSheep> selectBasSheepListByIds(List<Long> ids) {
return basSheepMapper.selectBasSheepListByIds(ids);
}
//校验新管理/电子耳号
@Override
public boolean existsByTag(String tag, Integer earType) {
if (earType == 0) {
return basSheepMapper.existsByElectronicTag(tag) > 0;
} else if (earType == 1) {
return basSheepMapper.existsByManageTag(tag) > 0;
}
return false;
}
}

View File

@ -91,4 +91,9 @@ public class BasSheepVarietyServiceImpl implements IBasSheepVarietyService
{
return basSheepVarietyMapper.deleteBasSheepVarietyById(id);
}
@Override
public BasSheepVariety selectByVarietyName(String varietyName) {
return basSheepVarietyMapper.selectByVarietyName(varietyName);
}
}

View File

@ -0,0 +1,93 @@
package com.zhyc.module.base.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.base.mapper.DaRanchMapper;
import com.zhyc.module.base.domain.DaRanch;
import com.zhyc.module.base.service.IDaRanchService;
/**
* 牧场管理Service业务层处理
*
* @author ruoyi
* @date 2025-07-22
*/
@Service
public class DaRanchServiceImpl implements IDaRanchService
{
@Autowired
private DaRanchMapper daRanchMapper;
/**
* 查询牧场管理
*
* @param id 牧场管理主键
* @return 牧场管理
*/
@Override
public DaRanch selectDaRanchById(Long id)
{
return daRanchMapper.selectDaRanchById(id);
}
/**
* 查询牧场管理列表
*
* @param daRanch 牧场管理
* @return 牧场管理
*/
@Override
public List<DaRanch> selectDaRanchList(DaRanch daRanch)
{
return daRanchMapper.selectDaRanchList(daRanch);
}
/**
* 新增牧场管理
*
* @param daRanch 牧场管理
* @return 结果
*/
@Override
public int insertDaRanch(DaRanch daRanch)
{
return daRanchMapper.insertDaRanch(daRanch);
}
/**
* 修改牧场管理
*
* @param daRanch 牧场管理
* @return 结果
*/
@Override
public int updateDaRanch(DaRanch daRanch)
{
return daRanchMapper.updateDaRanch(daRanch);
}
/**
* 批量删除牧场管理
*
* @param ids 需要删除的牧场管理主键
* @return 结果
*/
@Override
public int deleteDaRanchByIds(Long[] ids)
{
return daRanchMapper.deleteDaRanchByIds(ids);
}
/**
* 删除牧场管理信息
*
* @param id 牧场管理主键
* @return 结果
*/
@Override
public int deleteDaRanchById(Long id)
{
return daRanchMapper.deleteDaRanchById(id);
}
}

View File

@ -0,0 +1,107 @@
package com.zhyc.module.produce.bodyManage.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.common.utils.SecurityUtils;
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.bodyManage.domain.ScBodyMeasure;
import com.zhyc.module.produce.bodyManage.service.IScBodyMeasureService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 体尺测量Controller
*
* @author ruoyi
* @date 2025-07-27
*/
@RestController
@RequestMapping("/body_measure/body_measure")
public class ScBodyMeasureController extends BaseController
{
@Autowired
private IScBodyMeasureService scBodyMeasureService;
/**
* 查询体尺测量列表
*/
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:list')")
@GetMapping("/list")
public TableDataInfo list(ScBodyMeasure scBodyMeasure)
{
startPage();
List<ScBodyMeasure> list = scBodyMeasureService.selectScBodyMeasureList(scBodyMeasure);
return getDataTable(list);
}
/**
* 导出体尺测量列表
*/
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:export')")
@Log(title = "体尺测量", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScBodyMeasure scBodyMeasure)
{
List<ScBodyMeasure> list = scBodyMeasureService.selectScBodyMeasureList(scBodyMeasure);
ExcelUtil<ScBodyMeasure> util = new ExcelUtil<ScBodyMeasure>(ScBodyMeasure.class);
util.exportExcel(response, list, "体尺测量数据");
}
/**
* 获取体尺测量详细信息
*/
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(scBodyMeasureService.selectScBodyMeasureById(id));
}
/**
* 新增体尺测量
*/
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:add')")
@Log(title = "体尺测量", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScBodyMeasure scBodyMeasure)
{
return toAjax(scBodyMeasureService.insertScBodyMeasure(scBodyMeasure));
}
/**
* 修改体尺测量
*/
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:edit')")
@Log(title = "体尺测量", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScBodyMeasure scBodyMeasure)
{
return toAjax(scBodyMeasureService.updateScBodyMeasure(scBodyMeasure));
}
/**
* 删除体尺测量
*/
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:remove')")
@Log(title = "体尺测量", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(scBodyMeasureService.deleteScBodyMeasureByIds(ids));
}
}

View File

@ -0,0 +1,104 @@
package com.zhyc.module.produce.bodyManage.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.bodyManage.domain.ScBodyScore;
import com.zhyc.module.produce.bodyManage.service.IScBodyScoreService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 体况评分Controller
*
* @author ruoyi
* @date 2025-07-27
*/
@RestController
@RequestMapping("/body_score/body_score")
public class ScBodyScoreController extends BaseController
{
@Autowired
private IScBodyScoreService scBodyScoreService;
/**
* 查询体况评分列表
*/
@PreAuthorize("@ss.hasPermi('body_score:body_score:list')")
@GetMapping("/list")
public TableDataInfo list(ScBodyScore scBodyScore)
{
startPage();
List<ScBodyScore> list = scBodyScoreService.selectScBodyScoreList(scBodyScore);
return getDataTable(list);
}
/**
* 导出体况评分列表
*/
@PreAuthorize("@ss.hasPermi('body_score:body_score:export')")
@Log(title = "体况评分", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScBodyScore scBodyScore)
{
List<ScBodyScore> list = scBodyScoreService.selectScBodyScoreList(scBodyScore);
ExcelUtil<ScBodyScore> util = new ExcelUtil<ScBodyScore>(ScBodyScore.class);
util.exportExcel(response, list, "体况评分数据");
}
/**
* 获取体况评分详细信息
*/
@PreAuthorize("@ss.hasPermi('body_score:body_score:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(scBodyScoreService.selectScBodyScoreById(id));
}
/**
* 新增体况评分
*/
@PreAuthorize("@ss.hasPermi('body_score:body_score:add')")
@Log(title = "体况评分", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScBodyScore scBodyScore)
{
return toAjax(scBodyScoreService.insertScBodyScore(scBodyScore));
}
/**
* 修改体况评分
*/
@PreAuthorize("@ss.hasPermi('body_score:body_score:edit')")
@Log(title = "体况评分", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScBodyScore scBodyScore)
{
return toAjax(scBodyScoreService.updateScBodyScore(scBodyScore));
}
/**
* 删除体况评分
*/
@PreAuthorize("@ss.hasPermi('body_score:body_score:remove')")
@Log(title = "体况评分", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(scBodyScoreService.deleteScBodyScoreByIds(ids));
}
}

View File

@ -0,0 +1,104 @@
package com.zhyc.module.produce.bodyManage.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.bodyManage.domain.ScBreastRating;
import com.zhyc.module.produce.bodyManage.service.IScBreastRatingService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 乳房评分Controller
*
* @author ruoyi
* @date 2025-07-27
*/
@RestController
@RequestMapping("/breast_rating/breast_rating")
public class ScBreastRatingController extends BaseController
{
@Autowired
private IScBreastRatingService scBreastRatingService;
/**
* 查询乳房评分列表
*/
@PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:list')")
@GetMapping("/list")
public TableDataInfo list(ScBreastRating scBreastRating)
{
startPage();
List<ScBreastRating> list = scBreastRatingService.selectScBreastRatingList(scBreastRating);
return getDataTable(list);
}
/**
* 导出乳房评分列表
*/
@PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:export')")
@Log(title = "乳房评分", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScBreastRating scBreastRating)
{
List<ScBreastRating> list = scBreastRatingService.selectScBreastRatingList(scBreastRating);
ExcelUtil<ScBreastRating> util = new ExcelUtil<ScBreastRating>(ScBreastRating.class);
util.exportExcel(response, list, "乳房评分数据");
}
/**
* 获取乳房评分详细信息
*/
@PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(scBreastRatingService.selectScBreastRatingById(id));
}
/**
* 新增乳房评分
*/
@PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:add')")
@Log(title = "乳房评分", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScBreastRating scBreastRating)
{
return toAjax(scBreastRatingService.insertScBreastRating(scBreastRating));
}
/**
* 修改乳房评分
*/
@PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:edit')")
@Log(title = "乳房评分", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScBreastRating scBreastRating)
{
return toAjax(scBreastRatingService.updateScBreastRating(scBreastRating));
}
/**
* 删除乳房评分
*/
@PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:remove')")
@Log(title = "乳房评分", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(scBreastRatingService.deleteScBreastRatingByIds(ids));
}
}

View File

@ -0,0 +1,81 @@
package com.zhyc.module.produce.bodyManage.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
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;
import org.springframework.data.annotation.AccessType;
/**
* 体尺测量对象 sc_body_measure
*
* @author ruoyi
* @date 2025-07-27
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScBodyMeasure extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 耳号 */
private Long sheepId;
@Excel(name = "耳号")
private String manageTags;
/** 体高 */
@Excel(name = "体高")
private Long height;
/** 胸围 */
@Excel(name = "胸围")
private Long bust;
/** 体斜长 */
@Excel(name = "体斜长")
private Long bodyLength;
/** 管围 */
@Excel(name = "管围")
private Long pipeLength;
/** 胸深 */
@Excel(name = "胸深")
private Long chestDepth;
/** 臀高 */
@Excel(name = "臀高")
private Long hipHeight;
/** 尻宽 */
@Excel(name = "尻宽")
private Long rumpWidth;
/** 尻高 */
@Excel(name = "尻高")
private Long rumpHeignt;
/** 腰角宽 */
@Excel(name = "腰角宽")
private Long hipWidth;
/** 十字部高 */
@Excel(name = "十字部高")
private Long hipCrossHeight;
/** 备注 */
@Excel(name = "备注")
private String comment;
/** 技术员 */
@Excel(name = "技术员")
private String technician;
}

View File

@ -0,0 +1,68 @@
package com.zhyc.module.produce.bodyManage.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 体况评分对象 sc_body_score
*
* @author ruoyi
* @date 2025-07-27
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScBodyScore extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* 羊只id
*/
private String sheepId;
@Excel(name = "管理耳号")
private String manageTags;
/**
* 事件日期
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "事件日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
/**
* 体况评分
*/
@Excel(name = "体况评分")
private Long score;
/**
* 羊舍id
*/
private Long sheepfold;
@Excel(name = "羊舍名称")
private String sheepfoldName;
/**
* 备注
*/
@Excel(name = "备注")
private String comment;
/**
* 技术员
*/
@Excel(name = "技术员")
private String technician;
}

View File

@ -0,0 +1,84 @@
package com.zhyc.module.produce.bodyManage.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 乳房评分对象 sc_breast_rating
*
* @author ruoyi
* @date 2025-07-27
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScBreastRating extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* 羊只id
*/
private String sheepId;
@Excel(name = "羊只id")
private String manageTags;
/**
* 乳房深度
*/
@Excel(name = "乳房深度")
private Long depth;
/**
* 乳房长度
*/
@Excel(name = "乳房长度")
private Long length;
/**
* 乳房位置
*/
@Excel(name = "乳房位置")
private String position;
/**
* 乳房附着
*/
@Excel(name = "乳房附着")
private String adbere;
/**
* 乳房间隔度
*/
@Excel(name = "乳房间隔度")
private String spacing;
/**
* 乳房评分
*/
@Excel(name = "乳房评分")
private Long score;
/**
* 备注
*/
@Excel(name = "备注")
private String comment;
/**
* 技术员
*/
@Excel(name = "技术员")
private String technician;
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.bodyManage.mapper;
import java.util.List;
import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure;
/**
* 体尺测量Mapper接口
*
* @author ruoyi
* @date 2025-07-27
*/
public interface ScBodyMeasureMapper
{
/**
* 查询体尺测量
*
* @param id 体尺测量主键
* @return 体尺测量
*/
public ScBodyMeasure selectScBodyMeasureById(Long id);
/**
* 查询体尺测量列表
*
* @param scBodyMeasure 体尺测量
* @return 体尺测量集合
*/
public List<ScBodyMeasure> selectScBodyMeasureList(ScBodyMeasure scBodyMeasure);
/**
* 新增体尺测量
*
* @param scBodyMeasure 体尺测量
* @return 结果
*/
public int insertScBodyMeasure(ScBodyMeasure scBodyMeasure);
/**
* 修改体尺测量
*
* @param scBodyMeasure 体尺测量
* @return 结果
*/
public int updateScBodyMeasure(ScBodyMeasure scBodyMeasure);
/**
* 删除体尺测量
*
* @param id 体尺测量主键
* @return 结果
*/
public int deleteScBodyMeasureById(Long id);
/**
* 批量删除体尺测量
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScBodyMeasureByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.bodyManage.mapper;
import java.util.List;
import com.zhyc.module.produce.bodyManage.domain.ScBodyScore;
/**
* 体况评分Mapper接口
*
* @author ruoyi
* @date 2025-07-27
*/
public interface ScBodyScoreMapper
{
/**
* 查询体况评分
*
* @param id 体况评分主键
* @return 体况评分
*/
public ScBodyScore selectScBodyScoreById(Long id);
/**
* 查询体况评分列表
*
* @param scBodyScore 体况评分
* @return 体况评分集合
*/
public List<ScBodyScore> selectScBodyScoreList(ScBodyScore scBodyScore);
/**
* 新增体况评分
*
* @param scBodyScore 体况评分
* @return 结果
*/
public int insertScBodyScore(ScBodyScore scBodyScore);
/**
* 修改体况评分
*
* @param scBodyScore 体况评分
* @return 结果
*/
public int updateScBodyScore(ScBodyScore scBodyScore);
/**
* 删除体况评分
*
* @param id 体况评分主键
* @return 结果
*/
public int deleteScBodyScoreById(Long id);
/**
* 批量删除体况评分
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScBodyScoreByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.bodyManage.mapper;
import java.util.List;
import com.zhyc.module.produce.bodyManage.domain.ScBreastRating;
/**
* 乳房评分Mapper接口
*
* @author ruoyi
* @date 2025-07-27
*/
public interface ScBreastRatingMapper
{
/**
* 查询乳房评分
*
* @param id 乳房评分主键
* @return 乳房评分
*/
public ScBreastRating selectScBreastRatingById(Long id);
/**
* 查询乳房评分列表
*
* @param scBreastRating 乳房评分
* @return 乳房评分集合
*/
public List<ScBreastRating> selectScBreastRatingList(ScBreastRating scBreastRating);
/**
* 新增乳房评分
*
* @param scBreastRating 乳房评分
* @return 结果
*/
public int insertScBreastRating(ScBreastRating scBreastRating);
/**
* 修改乳房评分
*
* @param scBreastRating 乳房评分
* @return 结果
*/
public int updateScBreastRating(ScBreastRating scBreastRating);
/**
* 删除乳房评分
*
* @param id 乳房评分主键
* @return 结果
*/
public int deleteScBreastRatingById(Long id);
/**
* 批量删除乳房评分
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScBreastRatingByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.bodyManage.service;
import java.util.List;
import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure;
/**
* 体尺测量Service接口
*
* @author ruoyi
* @date 2025-07-27
*/
public interface IScBodyMeasureService
{
/**
* 查询体尺测量
*
* @param id 体尺测量主键
* @return 体尺测量
*/
public ScBodyMeasure selectScBodyMeasureById(Long id);
/**
* 查询体尺测量列表
*
* @param scBodyMeasure 体尺测量
* @return 体尺测量集合
*/
public List<ScBodyMeasure> selectScBodyMeasureList(ScBodyMeasure scBodyMeasure);
/**
* 新增体尺测量
*
* @param scBodyMeasure 体尺测量
* @return 结果
*/
public int insertScBodyMeasure(ScBodyMeasure scBodyMeasure);
/**
* 修改体尺测量
*
* @param scBodyMeasure 体尺测量
* @return 结果
*/
public int updateScBodyMeasure(ScBodyMeasure scBodyMeasure);
/**
* 批量删除体尺测量
*
* @param ids 需要删除的体尺测量主键集合
* @return 结果
*/
public int deleteScBodyMeasureByIds(Long[] ids);
/**
* 删除体尺测量信息
*
* @param id 体尺测量主键
* @return 结果
*/
public int deleteScBodyMeasureById(Long id);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.bodyManage.service;
import java.util.List;
import com.zhyc.module.produce.bodyManage.domain.ScBodyScore;
/**
* 体况评分Service接口
*
* @author ruoyi
* @date 2025-07-27
*/
public interface IScBodyScoreService
{
/**
* 查询体况评分
*
* @param id 体况评分主键
* @return 体况评分
*/
public ScBodyScore selectScBodyScoreById(Long id);
/**
* 查询体况评分列表
*
* @param scBodyScore 体况评分
* @return 体况评分集合
*/
public List<ScBodyScore> selectScBodyScoreList(ScBodyScore scBodyScore);
/**
* 新增体况评分
*
* @param scBodyScore 体况评分
* @return 结果
*/
public int insertScBodyScore(ScBodyScore scBodyScore);
/**
* 修改体况评分
*
* @param scBodyScore 体况评分
* @return 结果
*/
public int updateScBodyScore(ScBodyScore scBodyScore);
/**
* 批量删除体况评分
*
* @param ids 需要删除的体况评分主键集合
* @return 结果
*/
public int deleteScBodyScoreByIds(Long[] ids);
/**
* 删除体况评分信息
*
* @param id 体况评分主键
* @return 结果
*/
public int deleteScBodyScoreById(Long id);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.bodyManage.service;
import java.util.List;
import com.zhyc.module.produce.bodyManage.domain.ScBreastRating;
/**
* 乳房评分Service接口
*
* @author ruoyi
* @date 2025-07-27
*/
public interface IScBreastRatingService
{
/**
* 查询乳房评分
*
* @param id 乳房评分主键
* @return 乳房评分
*/
public ScBreastRating selectScBreastRatingById(Long id);
/**
* 查询乳房评分列表
*
* @param scBreastRating 乳房评分
* @return 乳房评分集合
*/
public List<ScBreastRating> selectScBreastRatingList(ScBreastRating scBreastRating);
/**
* 新增乳房评分
*
* @param scBreastRating 乳房评分
* @return 结果
*/
public int insertScBreastRating(ScBreastRating scBreastRating);
/**
* 修改乳房评分
*
* @param scBreastRating 乳房评分
* @return 结果
*/
public int updateScBreastRating(ScBreastRating scBreastRating);
/**
* 批量删除乳房评分
*
* @param ids 需要删除的乳房评分主键集合
* @return 结果
*/
public int deleteScBreastRatingByIds(Long[] ids);
/**
* 删除乳房评分信息
*
* @param id 乳房评分主键
* @return 结果
*/
public int deleteScBreastRatingById(Long id);
}

View File

@ -0,0 +1,117 @@
package com.zhyc.module.produce.bodyManage.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.service.IBasSheepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.bodyManage.mapper.ScBodyMeasureMapper;
import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure;
import com.zhyc.module.produce.bodyManage.service.IScBodyMeasureService;
/**
* 体尺测量Service业务层处理
*
* @author ruoyi
* @date 2025-07-27
*/
@Service
public class ScBodyMeasureServiceImpl implements IScBodyMeasureService
{
@Autowired
private ScBodyMeasureMapper scBodyMeasureMapper;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询体尺测量
*
* @param id 体尺测量主键
* @return 体尺测量
*/
@Override
public ScBodyMeasure selectScBodyMeasureById(Long id)
{
return scBodyMeasureMapper.selectScBodyMeasureById(id);
}
/**
* 查询体尺测量列表
*
* @param scBodyMeasure 体尺测量
* @return 体尺测量
*/
@Override
public List<ScBodyMeasure> selectScBodyMeasureList(ScBodyMeasure scBodyMeasure)
{
return scBodyMeasureMapper.selectScBodyMeasureList(scBodyMeasure);
}
/**
* 新增体尺测量
*
* @param scBodyMeasure 体尺测量
* @return 结果
*/
@Override
public int insertScBodyMeasure(ScBodyMeasure scBodyMeasure)
{
String manageTags = scBodyMeasure.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scBodyMeasure.setSheepId(sheep.getId());
}
scBodyMeasure.setCreateTime(DateUtils.getNowDate());
scBodyMeasure.setCreateBy(SecurityUtils.getUsername());
return scBodyMeasureMapper.insertScBodyMeasure(scBodyMeasure);
}
/**
* 修改体尺测量
*
* @param scBodyMeasure 体尺测量
* @return 结果
*/
@Override
public int updateScBodyMeasure(ScBodyMeasure scBodyMeasure)
{
String manageTags = scBodyMeasure.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scBodyMeasure.setSheepId(sheep.getId());
}
return scBodyMeasureMapper.updateScBodyMeasure(scBodyMeasure);
}
/**
* 批量删除体尺测量
*
* @param ids 需要删除的体尺测量主键
* @return 结果
*/
@Override
public int deleteScBodyMeasureByIds(Long[] ids)
{
return scBodyMeasureMapper.deleteScBodyMeasureByIds(ids);
}
/**
* 删除体尺测量信息
*
* @param id 体尺测量主键
* @return 结果
*/
@Override
public int deleteScBodyMeasureById(Long id)
{
return scBodyMeasureMapper.deleteScBodyMeasureById(id);
}
}

View File

@ -0,0 +1,127 @@
package com.zhyc.module.produce.bodyManage.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.service.IBasSheepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.bodyManage.mapper.ScBodyScoreMapper;
import com.zhyc.module.produce.bodyManage.domain.ScBodyScore;
import com.zhyc.module.produce.bodyManage.service.IScBodyScoreService;
import org.springframework.transaction.annotation.Transactional;
/**
* 体况评分Service业务层处理
*
* @author ruoyi
* @date 2025-07-27
*/
@Service
public class ScBodyScoreServiceImpl implements IScBodyScoreService {
@Autowired
private ScBodyScoreMapper scBodyScoreMapper;
@Autowired
private IBasSheepService basSheepService;
@Autowired
private BasSheepMapper basSheepMapper;
/**
* 查询体况评分
*
* @param id 体况评分主键
* @return 体况评分
*/
@Override
public ScBodyScore selectScBodyScoreById(Long id) {
return scBodyScoreMapper.selectScBodyScoreById(id);
}
/**
* 查询体况评分列表
*
* @param scBodyScore 体况评分
* @return 体况评分
*/
@Override
public List<ScBodyScore> selectScBodyScoreList(ScBodyScore scBodyScore) {
return scBodyScoreMapper.selectScBodyScoreList(scBodyScore);
}
/**
* 新增体况评分
*
* @param scBodyScore 体况评分
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScBodyScore(ScBodyScore scBodyScore) {
String manageTags = scBodyScore.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scBodyScore.setSheepId(sheep.getId().toString());
}
scBodyScore.setCreateTime(DateUtils.getNowDate());
scBodyScore.setCreateBy(SecurityUtils.getUsername());
int insertResult = scBodyScoreMapper.insertScBodyScore(scBodyScore);
if (insertResult > 0 && scBodyScore.getSheepId() != null) {
BasSheep updateSheep = new BasSheep();
updateSheep.setId(Long.parseLong(scBodyScore.getSheepId()));
updateSheep.setBody(scBodyScore.getScore());
basSheepMapper.updateBasSheep(updateSheep);
}
return insertResult;
}
/**
* 修改体况评分
*
* @param scBodyScore 体况评分
* @return 结果
*/
@Override
public int updateScBodyScore(ScBodyScore scBodyScore) {
String manageTags = scBodyScore.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scBodyScore.setSheepId(sheep.getId().toString());
}
return scBodyScoreMapper.updateScBodyScore(scBodyScore);
}
/**
* 批量删除体况评分
*
* @param ids 需要删除的体况评分主键
* @return 结果
*/
@Override
public int deleteScBodyScoreByIds(Long[] ids) {
return scBodyScoreMapper.deleteScBodyScoreByIds(ids);
}
/**
* 删除体况评分信息
*
* @param id 体况评分主键
* @return 结果
*/
@Override
public int deleteScBodyScoreById(Long id) {
return scBodyScoreMapper.deleteScBodyScoreById(id);
}
}

View File

@ -0,0 +1,131 @@
package com.zhyc.module.produce.bodyManage.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.service.IBasSheepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.bodyManage.mapper.ScBreastRatingMapper;
import com.zhyc.module.produce.bodyManage.domain.ScBreastRating;
import com.zhyc.module.produce.bodyManage.service.IScBreastRatingService;
import org.springframework.transaction.annotation.Transactional;
/**
* 乳房评分Service业务层处理
*
* @author ruoyi
* @date 2025-07-27
*/
@Service
public class ScBreastRatingServiceImpl implements IScBreastRatingService {
@Autowired
private ScBreastRatingMapper scBreastRatingMapper;
@Autowired
private IBasSheepService basSheepService;
@Autowired
private BasSheepMapper basSheepMapper;
/**
* 查询乳房评分
*
* @param id 乳房评分主键
* @return 乳房评分
*/
@Override
public ScBreastRating selectScBreastRatingById(Long id) {
return scBreastRatingMapper.selectScBreastRatingById(id);
}
/**
* 查询乳房评分列表
*
* @param scBreastRating 乳房评分
* @return 乳房评分
*/
@Override
public List<ScBreastRating> selectScBreastRatingList(ScBreastRating scBreastRating) {
return scBreastRatingMapper.selectScBreastRatingList(scBreastRating);
}
/**
* 新增乳房评分
*
* @param scBreastRating 乳房评分
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScBreastRating(ScBreastRating scBreastRating) {
String manageTags = scBreastRating.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scBreastRating.setSheepId(sheep.getId().toString());
}
scBreastRating.setCreateTime(DateUtils.getNowDate());
scBreastRating.setCreateBy(SecurityUtils.getUsername());
int rows = scBreastRatingMapper.insertScBreastRating(scBreastRating);
if (rows > 0 && scBreastRating.getSheepId() != null) {
Long sheepId = Long.parseLong(scBreastRating.getSheepId());
Long score = scBreastRating.getScore().longValue();
BasSheep updateSheep = new BasSheep();
updateSheep.setId(sheepId);
updateSheep.setBreast(score);
basSheepMapper.updateBasSheep(updateSheep);
}
return rows;
}
/**
* 修改乳房评分
*
* @param scBreastRating 乳房评分
* @return 结果
*/
@Override
public int updateScBreastRating(ScBreastRating scBreastRating) {
String manageTags = scBreastRating.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scBreastRating.setSheepId(sheep.getId().toString());
}
return scBreastRatingMapper.updateScBreastRating(scBreastRating);
}
/**
* 批量删除乳房评分
*
* @param ids 需要删除的乳房评分主键
* @return 结果
*/
@Override
public int deleteScBreastRatingByIds(Long[] ids) {
return scBreastRatingMapper.deleteScBreastRatingByIds(ids);
}
/**
* 删除乳房评分信息
*
* @param id 乳房评分主键
* @return 结果
*/
@Override
public int deleteScBreastRatingById(Long id) {
return scBreastRatingMapper.deleteScBreastRatingById(id);
}
}

View File

@ -5,6 +5,8 @@ import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.module.base.domain.BasSheepVariety;
import com.zhyc.module.base.service.IBasSheepVarietyService;
import com.zhyc.module.produce.manage_sheep.domain.ScAddSheep;
import com.zhyc.module.produce.manage_sheep.service.IScAddSheepService;
import com.zhyc.module.base.domain.DaSheepfold;
@ -32,7 +34,8 @@ public class ScAddSheepController {
private IScAddSheepService scAddSheepService;
@Autowired
private IDaSheepfoldService daSheepfoldMapper;
@Autowired
private IBasSheepVarietyService basSheepVarietyMapper;
//新增羊只验证
@PreAuthorize("@ss.hasPermi('produce:add_sheep:add')")
@Log(title = "新增", businessType = BusinessType.INSERT)
@ -70,13 +73,14 @@ public class ScAddSheepController {
}
@PostMapping("/exportForm")
//导出
@Log(title = "羊只信息", businessType = BusinessType.EXPORT)
@PostMapping("/exportForm")
public void exportForm(HttpServletResponse response, @RequestBody ScAddSheep scAddSheep) throws IOException {
ExcelUtil<ScAddSheep> util = new ExcelUtil<>(ScAddSheep.class);
List<ScAddSheep> list = new ArrayList<>();
// 设置羊舍名称从数据库查
// 处理羊舍名称原有逻辑
if (scAddSheep.getSheepfold() != null) {
DaSheepfold fold = daSheepfoldMapper.selectDaSheepfoldById(scAddSheep.getSheepfold().longValue());
if (fold != null) {
@ -84,10 +88,16 @@ public class ScAddSheepController {
}
}
if (scAddSheep.getVarietyId() != null) {
BasSheepVariety variety = basSheepVarietyMapper.selectBasSheepVarietyById(scAddSheep.getVarietyId().longValue());
if (variety != null) {
scAddSheep.setVarietyName(variety.getVariety());
}
}
list.add(scAddSheep);
util.exportExcel(response, list, "羊只信息");
}
//导入
@PostMapping("/importData")
@PreAuthorize("@ss.hasPermi('produce:add_sheep:import')")

View File

@ -0,0 +1,104 @@
package com.zhyc.module.produce.manage_sheep.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.manage_sheep.domain.ScChangeComment;
import com.zhyc.module.produce.manage_sheep.service.IScChangeCommentService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 改备注Controller
*
* @author ruoyi
* @date 2025-07-24
*/
@RestController
@RequestMapping("/changeComment/changeComment")
public class ScChangeCommentController extends BaseController
{
@Autowired
private IScChangeCommentService scChangeCommentService;
/**
* 查询改备注列表
*/
@PreAuthorize("@ss.hasPermi('changeComment:changeComment:list')")
@GetMapping("/list")
public TableDataInfo list(ScChangeComment scChangeComment)
{
startPage();
List<ScChangeComment> list = scChangeCommentService.selectScChangeCommentList(scChangeComment);
return getDataTable(list);
}
/**
* 导出改备注列表
*/
@PreAuthorize("@ss.hasPermi('changeComment:changeComment:export')")
@Log(title = "改备注", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScChangeComment scChangeComment)
{
List<ScChangeComment> list = scChangeCommentService.selectScChangeCommentList(scChangeComment);
ExcelUtil<ScChangeComment> util = new ExcelUtil<ScChangeComment>(ScChangeComment.class);
util.exportExcel(response, list, "改备注数据");
}
/**
* 获取改备注详细信息
*/
@PreAuthorize("@ss.hasPermi('changeComment:changeComment:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(scChangeCommentService.selectScChangeCommentById(id));
}
/**
* 新增改备注
*/
@PreAuthorize("@ss.hasPermi('changeComment:changeComment:add')")
@Log(title = "改备注", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScChangeComment scChangeComment)
{
return toAjax(scChangeCommentService.insertScChangeComment(scChangeComment));
}
/**
* 修改改备注
*/
@PreAuthorize("@ss.hasPermi('changeComment:changeComment:edit')")
@Log(title = "改备注", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScChangeComment scChangeComment)
{
return toAjax(scChangeCommentService.updateScChangeComment(scChangeComment));
}
/**
* 删除改备注
*/
@PreAuthorize("@ss.hasPermi('changeComment:changeComment:remove')")
@Log(title = "改备注", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(scChangeCommentService.deleteScChangeCommentByIds(ids));
}
}

View File

@ -0,0 +1,119 @@
package com.zhyc.module.produce.manage_sheep.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.service.IBasSheepService;
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.manage_sheep.domain.ScChangeEar;
import com.zhyc.module.produce.manage_sheep.service.IScChangeEarService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 修改电子耳号记录Controller
*
* @author ruoyi
* @date 2025-07-24
*/
@RestController
@RequestMapping("/changeEar/changeEar")
public class ScChangeEarController extends BaseController
{
@Autowired
private IScChangeEarService scChangeEarService;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询修改电子耳号记录列表
*/
@PreAuthorize("@ss.hasPermi('changeEar:changeEar:list')")
@GetMapping("/list")
public TableDataInfo list(ScChangeEar scChangeEar)
{
startPage();
List<ScChangeEar> list = scChangeEarService.selectScChangeEarList(scChangeEar);
return getDataTable(list);
}
/**
* 导出修改电子耳号记录列表
*/
@PreAuthorize("@ss.hasPermi('changeEar:changeEar:export')")
@Log(title = "修改电子耳号记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScChangeEar scChangeEar)
{
List<ScChangeEar> list = scChangeEarService.selectScChangeEarList(scChangeEar);
ExcelUtil<ScChangeEar> util = new ExcelUtil<ScChangeEar>(ScChangeEar.class);
util.exportExcel(response, list, "修改电子耳号记录数据");
}
/**
* 获取修改电子耳号记录详细信息
*/
@PreAuthorize("@ss.hasPermi('changeEar:changeEar:query')")
@GetMapping("/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id) {
ScChangeEar changeEar = scChangeEarService.selectScChangeEarById(id);
// 关联查询羊只表获取旧耳号
BasSheep sheep = basSheepService.selectBasSheepById(changeEar.getSheepId());
if (sheep != null) {
// 根据耳号类型设置旧耳号
if (changeEar.getEarType() == 0) {
changeEar.setOldTag(sheep.getElectronicTags());
} else {
changeEar.setOldTag(sheep.getManageTags());
}
}
return success(changeEar);
}
/**
* 新增修改电子耳号记录
*/
@PreAuthorize("@ss.hasPermi('changeEar:changeEar:add')")
@Log(title = "修改电子耳号记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScChangeEar scChangeEar)
{
return toAjax(scChangeEarService.insertScChangeEar(scChangeEar));
}
/**
* 修改修改电子耳号记录
*/
@PreAuthorize("@ss.hasPermi('changeEar:changeEar:edit')")
@Log(title = "修改电子耳号记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScChangeEar scChangeEar)
{
return toAjax(scChangeEarService.updateScChangeEar(scChangeEar));
}
/**
* 删除修改电子耳号记录
*/
@PreAuthorize("@ss.hasPermi('changeEar:changeEar:remove')")
@Log(title = "修改电子耳号记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(scChangeEarService.deleteScChangeEarByIds(ids));
}
}

View File

@ -0,0 +1,104 @@
package com.zhyc.module.produce.manage_sheep.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.manage_sheep.domain.ScChangeVariety;
import com.zhyc.module.produce.manage_sheep.service.IScChangeVarietyService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* 改品种记录Controller
*
* @author ruoyi
* @date 2025-07-24
*/
@RestController
@RequestMapping("/changeVariety/changeVariety")
public class ScChangeVarietyController extends BaseController
{
@Autowired
private IScChangeVarietyService scChangeVarietyService;
/**
* 查询改品种记录列表
*/
@PreAuthorize("@ss.hasPermi('changeVariety:changeVariety:list')")
@GetMapping("/list")
public TableDataInfo list(ScChangeVariety scChangeVariety)
{
startPage();
List<ScChangeVariety> list = scChangeVarietyService.selectScChangeVarietyList(scChangeVariety);
return getDataTable(list);
}
/**
* 导出改品种记录列表
*/
@PreAuthorize("@ss.hasPermi('changeVariety:changeVariety:export')")
@Log(title = "改品种记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScChangeVariety scChangeVariety)
{
List<ScChangeVariety> list = scChangeVarietyService.selectScChangeVarietyList(scChangeVariety);
ExcelUtil<ScChangeVariety> util = new ExcelUtil<ScChangeVariety>(ScChangeVariety.class);
util.exportExcel(response, list, "改品种记录数据");
}
/**
* 获取改品种记录详细信息
*/
@PreAuthorize("@ss.hasPermi('changeVariety:changeVariety:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(scChangeVarietyService.selectScChangeVarietyById(id));
}
/**
* 新增改品种记录
*/
@PreAuthorize("@ss.hasPermi('changeVariety:changeVariety:add')")
@Log(title = "改品种记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScChangeVariety scChangeVariety)
{
return toAjax(scChangeVarietyService.insertScChangeVariety(scChangeVariety));
}
/**
* 修改改品种记录
*/
@PreAuthorize("@ss.hasPermi('changeVariety:changeVariety:edit')")
@Log(title = "改品种记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScChangeVariety scChangeVariety)
{
return toAjax(scChangeVarietyService.updateScChangeVariety(scChangeVariety));
}
/**
* 删除改品种记录
*/
@PreAuthorize("@ss.hasPermi('changeVariety:changeVariety:remove')")
@Log(title = "改品种记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(scChangeVarietyService.deleteScChangeVarietyByIds(ids));
}
}

View File

@ -96,4 +96,13 @@ public class ScTransGroupController extends BaseController {
public AjaxResult remove(@PathVariable Integer[] ids) {
return toAjax(scTransGroupService.deleteScTransGroupByIds(ids));
}
/**
* 审批转群记录
*/
@PutMapping("/approve")
public AjaxResult approve(@RequestBody ScTransGroup scTransGroup) {
return toAjax(scTransGroupService.approveScTransGroup(scTransGroup));
}
}

View File

@ -2,6 +2,7 @@ package com.zhyc.module.produce.manage_sheep.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;
@ -23,14 +24,13 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 转场Controller
*
*
* @author ruoyi
* @date 2025-07-10
*/
@RestController
@RequestMapping("produce/manage_sheep/transition_info")
public class ScTransitionInfoController extends BaseController
{
public class ScTransitionInfoController extends BaseController {
@Autowired
private IScTransitionInfoService scTransitionInfoService;
@ -39,8 +39,7 @@ public class ScTransitionInfoController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('produce:transition_info:list')")
@GetMapping("/list")
public TableDataInfo list(ScTransitionInfo scTransitionInfo)
{
public TableDataInfo list(ScTransitionInfo scTransitionInfo) {
startPage();
List<ScTransitionInfo> list = scTransitionInfoService.selectScTransitionInfoList(scTransitionInfo);
return getDataTable(list);
@ -52,10 +51,13 @@ public class ScTransitionInfoController extends BaseController
@PreAuthorize("@ss.hasPermi('produce:transition_info:export')")
@Log(title = "转场", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScTransitionInfo scTransitionInfo)
{
public void export(HttpServletResponse response, ScTransitionInfo scTransitionInfo) {
List<ScTransitionInfo> list = scTransitionInfoService.selectScTransitionInfoList(scTransitionInfo);
ExcelUtil<ScTransitionInfo> util = new ExcelUtil<ScTransitionInfo>(ScTransitionInfo.class);
for (ScTransitionInfo item : list) {
item.setStatusText(scTransitionInfoService.convertStatus(item.getStatus()));
item.setTransTypeText(scTransitionInfoService.convertTransType(item.getTransType()));
}
ExcelUtil<ScTransitionInfo> util = new ExcelUtil<>(ScTransitionInfo.class);
util.exportExcel(response, list, "转场数据");
}
@ -64,9 +66,10 @@ public class ScTransitionInfoController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('produce:transition_info:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(scTransitionInfoService.selectScTransitionInfoById(id));
public AjaxResult getInfo(@PathVariable("id") Integer id) {
ScTransitionInfo transitionInfo = scTransitionInfoService.selectScTransitionInfoById(id);
transitionInfo.setTransTypeText(scTransitionInfoService.convertTransType(transitionInfo.getTransType()));
return success(transitionInfo);
}
/**
@ -75,19 +78,23 @@ public class ScTransitionInfoController extends BaseController
@PreAuthorize("@ss.hasPermi('produce:transition_info:add')")
@Log(title = "转场", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScTransitionInfo scTransitionInfo)
{
public AjaxResult add(@RequestBody ScTransitionInfo scTransitionInfo) {
return toAjax(scTransitionInfoService.insertScTransitionInfo(scTransitionInfo));
}
//批量添加
@PostMapping("/batch")
public AjaxResult addBatch(@RequestBody List<ScTransitionInfo> transitionInfoList) {
return toAjax(scTransitionInfoService.insertScTransitionInfoBatch(transitionInfoList));
}
/**
* 修改转场
*/
@PreAuthorize("@ss.hasPermi('produce:transition_info:edit')")
@Log(title = "转场", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScTransitionInfo scTransitionInfo)
{
public AjaxResult edit(@RequestBody ScTransitionInfo scTransitionInfo) {
return toAjax(scTransitionInfoService.updateScTransitionInfo(scTransitionInfo));
}
@ -96,9 +103,14 @@ public class ScTransitionInfoController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('produce:transition_info:remove')")
@Log(title = "转场", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids) {
return toAjax(scTransitionInfoService.deleteScTransitionInfoByIds(ids));
}
@PutMapping("/approve")
public AjaxResult approveScTransitionInfo(@RequestBody ScTransitionInfo scTransitionInfo) {
int rows = scTransitionInfoService.approveScTransitionInfo(scTransitionInfo);
return toAjax(rows);
}
}

View File

@ -1,5 +1,6 @@
package com.zhyc.module.produce.manage_sheep.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
@ -21,7 +22,7 @@ public class ScAddSheep extends BaseEntity {
*/
private static final long serialVersionUID = 1L;
@Excel(name = "主键")
private Integer id; // 如果数据库主键叫 id就加这一行
private Integer id;
/** 羊只耳号 */
@Excel(name = "耳号")
private String earNumber;
@ -29,7 +30,6 @@ public class ScAddSheep extends BaseEntity {
/** 羊舍编号 */
private Integer sheepfold;
// @Excel(name = "羊舍名称")
private String sheepfoldName;
// 导出时生成羊舍名称 Excel 不映射到数据库
@ -49,11 +49,12 @@ public class ScAddSheep extends BaseEntity {
private BigDecimal bornWeight;
/** 出生日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "出生日期", dateFormat = "yyyy-MM-dd")
private Date birthday;
/** 性别 1公 0母 2阉羊 3兼性 */
@Excel(name = "性别", readConverterExp = "1=公,0=母,2=阉羊,3=兼性")
/** 性别 1母 2公 3阉羊 */
@Excel(name = "性别", readConverterExp = "1=母,2=公,3=阉羊")
private Integer gender;
/** 胎次 */
@ -68,6 +69,7 @@ public class ScAddSheep extends BaseEntity {
private String varietyName;
/** 入群日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "入群日期", dateFormat = "yyyy-MM-dd")
private Date joinDate;
@ -79,7 +81,7 @@ public class ScAddSheep extends BaseEntity {
@Excel(name = "技术员")
private String technician;
/* 以下字段不导出 */
private String createBy;
private Date createTime;

View File

@ -0,0 +1,47 @@
package com.zhyc.module.produce.manage_sheep.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 改备注对象 sc_change_comment
*
* @author ruoyi
* @date 2025-07-24
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScChangeComment extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* 羊只id
*/
private String sheepId;
@Excel(name = "管理耳号")
private String manageTags;
/**
* 新备注
*/
@Excel(name = "新备注")
private String newComment;
/**
* 原备注
*/
@Excel(name = "原备注")
private String oldComment;
}

View File

@ -0,0 +1,50 @@
package com.zhyc.module.produce.manage_sheep.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 修改电子耳号记录对象 sc_change_ear
*
* @author ruoyi
* @date 2025-07-24
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScChangeEar extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Integer id;
/** 羊只id */
private Long sheepId;
@Excel(name = "管理耳号")
private String manageTags;
/** 选择更改耳号类型0电子耳号1管理耳号 */
@Excel(name = "耳号类型", readConverterExp = "0=电子耳号,1=管理耳号")
private Integer earType;
/** 新耳号/电子耳号 */
@Excel(name = "新耳号/电子耳号")
private String newTag;
/** 旧耳号/电子耳号 */
@Excel(name = "旧耳号/电子耳号")
private String oldTag;
/** 备注 */
@Excel(name = "备注")
private String comment;
}

View File

@ -0,0 +1,52 @@
package com.zhyc.module.produce.manage_sheep.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 改品种记录对象 sc_change_variety
*
* @author ruoyi
* @date 2025-07-24
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScChangeVariety extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Integer id;
/** 羊只id */
private Integer sheepId;
@Excel(name = "耳号")
private String manageTags;
/** 原品种 */
@Excel(name = "原品种")
private String varietyOld;
/** 新品种 */
@Excel(name = "新品种")
private String varietyNew;
/** 备注 */
@Excel(name = "备注")
private String comment;
/** 创建日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date createTime;
}

View File

@ -29,7 +29,6 @@ public class ScTransGroup extends BaseEntity {
/**
* 羊只id
*/
// @Excel(name = "羊只id")
private Integer sheepId;
@Excel(name = "耳号")
@ -50,12 +49,17 @@ public class ScTransGroup extends BaseEntity {
@Excel(name = "转出羊舍")
private String foldFromName;
/**
* 羊只类型ID
*/
private Integer sheepTypeId;
// 羊只类型名称
private String sheepTypeName;
/**
* 转入羊舍名称
*/
@Excel(name = "转入羊舍")
private String foldToName;
/** 转群原因 */
/**
* 品种id

View File

@ -21,16 +21,17 @@ public class ScTransitionInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*主键
*/
private Integer id;
/**
* 羊只id
*/
@Excel(name = "羊只id")
private Integer sheepId;
@Excel(name = "耳号")
private String manageTags;
/**
* 品种id
*/
@ -74,9 +75,9 @@ public class ScTransitionInfo extends BaseEntity {
/**
* 状态
*/
@Excel(name = "状态")
private Integer status;
@Excel(name = "状态")
private String statusText;
/**
* 备注
*/

View File

@ -7,11 +7,19 @@ import java.util.List;
@Mapper
public interface ScAddSheepMapper {
//新增羊只
int insert(ScAddSheep scAddSheep);
//查询新增羊只列表
List<ScAddSheep> selectScAddSheepList(ScAddSheep scAddSheep);
//修改羊只
int updateScAddSheep(ScAddSheep scAddSheep);
//删除羊只(支持批量)
int deleteScAddSheepByIds(Integer[] ids);
//根据耳号查询羊只
ScAddSheep selectByEarNumber(String earNumber);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.manage_sheep.mapper;
import java.util.List;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeComment;
/**
* 改备注Mapper接口
*
* @author ruoyi
* @date 2025-07-24
*/
public interface ScChangeCommentMapper
{
/**
* 查询改备注
*
* @param id 改备注主键
* @return 改备注
*/
public ScChangeComment selectScChangeCommentById(Long id);
/**
* 查询改备注列表
*
* @param scChangeComment 改备注
* @return 改备注集合
*/
public List<ScChangeComment> selectScChangeCommentList(ScChangeComment scChangeComment);
/**
* 新增改备注
*
* @param scChangeComment 改备注
* @return 结果
*/
public int insertScChangeComment(ScChangeComment scChangeComment);
/**
* 修改改备注
*
* @param scChangeComment 改备注
* @return 结果
*/
public int updateScChangeComment(ScChangeComment scChangeComment);
/**
* 删除改备注
*
* @param id 改备注主键
* @return 结果
*/
public int deleteScChangeCommentById(Long id);
/**
* 批量删除改备注
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScChangeCommentByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.manage_sheep.mapper;
import java.util.List;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeEar;
/**
* 修改电子耳号记录Mapper接口
*
* @author ruoyi
* @date 2025-07-24
*/
public interface ScChangeEarMapper
{
/**
* 查询修改电子耳号记录
*
* @param id 修改电子耳号记录主键
* @return 修改电子耳号记录
*/
public ScChangeEar selectScChangeEarById(Integer id);
/**
* 查询修改电子耳号记录列表
*
* @param scChangeEar 修改电子耳号记录
* @return 修改电子耳号记录集合
*/
public List<ScChangeEar> selectScChangeEarList(ScChangeEar scChangeEar);
/**
* 新增修改电子耳号记录
*
* @param scChangeEar 修改电子耳号记录
* @return 结果
*/
public int insertScChangeEar(ScChangeEar scChangeEar);
/**
* 修改修改电子耳号记录
*
* @param scChangeEar 修改电子耳号记录
* @return 结果
*/
public int updateScChangeEar(ScChangeEar scChangeEar);
/**
* 删除修改电子耳号记录
*
* @param id 修改电子耳号记录主键
* @return 结果
*/
public int deleteScChangeEarById(Integer id);
/**
* 批量删除修改电子耳号记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScChangeEarByIds(Integer[] ids);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.manage_sheep.mapper;
import java.util.List;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeVariety;
/**
* 改品种记录Mapper接口
*
* @author ruoyi
* @date 2025-07-24
*/
public interface ScChangeVarietyMapper
{
/**
* 查询改品种记录
*
* @param id 改品种记录主键
* @return 改品种记录
*/
public ScChangeVariety selectScChangeVarietyById(Integer id);
/**
* 查询改品种记录列表
*
* @param scChangeVariety 改品种记录
* @return 改品种记录集合
*/
public List<ScChangeVariety> selectScChangeVarietyList(ScChangeVariety scChangeVariety);
/**
* 新增改品种记录
*
* @param scChangeVariety 改品种记录
* @return 结果
*/
public int insertScChangeVariety(ScChangeVariety scChangeVariety);
/**
* 修改改品种记录
*
* @param scChangeVariety 改品种记录
* @return 结果
*/
public int updateScChangeVariety(ScChangeVariety scChangeVariety);
/**
* 删除改品种记录
*
* @param id 改品种记录主键
* @return 结果
*/
public int deleteScChangeVarietyById(Integer id);
/**
* 批量删除改品种记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScChangeVarietyByIds(Integer[] ids);
}

View File

@ -3,7 +3,7 @@ package com.zhyc.module.produce.manage_sheep.mapper;
import java.util.List;
import com.zhyc.module.produce.manage_sheep.domain.ScTransitionInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 转场Mapper接口
@ -11,7 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
* @author ruoyi
* @date 2025-07-10
*/
@Mapper
public interface ScTransitionInfoMapper
{
/**
@ -61,4 +60,7 @@ public interface ScTransitionInfoMapper
* @return 结果
*/
public int deleteScTransitionInfoByIds(Integer[] ids);
//批量转场
int insertScTransitionInfoBatch(@Param("list") List<ScTransitionInfo> transitionInfoList);
}

View File

@ -7,11 +7,19 @@ import java.util.List;
public interface IScAddSheepService {
//新增
boolean insertScAddSheep(ScAddSheep scAddSheep);
//查询
List<ScAddSheep> selectScAddSheepList(ScAddSheep scAddSheep);
//修改
boolean updateScAddSheep(ScAddSheep scAddSheep);
//删除
boolean deleteScAddSheepByIds(Integer[] ids);
//导入
String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName);

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.manage_sheep.service;
import java.util.List;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeComment;
/**
* 改备注Service接口
*
* @author ruoyi
* @date 2025-07-24
*/
public interface IScChangeCommentService
{
/**
* 查询改备注
*
* @param id 改备注主键
* @return 改备注
*/
public ScChangeComment selectScChangeCommentById(Long id);
/**
* 查询改备注列表
*
* @param scChangeComment 改备注
* @return 改备注集合
*/
public List<ScChangeComment> selectScChangeCommentList(ScChangeComment scChangeComment);
/**
* 新增改备注
*
* @param scChangeComment 改备注
* @return 结果
*/
public int insertScChangeComment(ScChangeComment scChangeComment);
/**
* 修改改备注
*
* @param scChangeComment 改备注
* @return 结果
*/
public int updateScChangeComment(ScChangeComment scChangeComment);
/**
* 批量删除改备注
*
* @param ids 需要删除的改备注主键集合
* @return 结果
*/
public int deleteScChangeCommentByIds(Long[] ids);
/**
* 删除改备注信息
*
* @param id 改备注主键
* @return 结果
*/
public int deleteScChangeCommentById(Long id);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.manage_sheep.service;
import java.util.List;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeEar;
/**
* 修改电子耳号记录Service接口
*
* @author ruoyi
* @date 2025-07-24
*/
public interface IScChangeEarService
{
/**
* 查询修改电子耳号记录
*
* @param id 修改电子耳号记录主键
* @return 修改电子耳号记录
*/
public ScChangeEar selectScChangeEarById(Integer id);
/**
* 查询修改电子耳号记录列表
*
* @param scChangeEar 修改电子耳号记录
* @return 修改电子耳号记录集合
*/
public List<ScChangeEar> selectScChangeEarList(ScChangeEar scChangeEar);
/**
* 新增修改电子耳号记录
*
* @param scChangeEar 修改电子耳号记录
* @return 结果
*/
public int insertScChangeEar(ScChangeEar scChangeEar);
/**
* 修改修改电子耳号记录
*
* @param scChangeEar 修改电子耳号记录
* @return 结果
*/
public int updateScChangeEar(ScChangeEar scChangeEar);
/**
* 批量删除修改电子耳号记录
*
* @param ids 需要删除的修改电子耳号记录主键集合
* @return 结果
*/
public int deleteScChangeEarByIds(Integer[] ids);
/**
* 删除修改电子耳号记录信息
*
* @param id 修改电子耳号记录主键
* @return 结果
*/
public int deleteScChangeEarById(Integer id);
}

View File

@ -0,0 +1,61 @@
package com.zhyc.module.produce.manage_sheep.service;
import java.util.List;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeVariety;
/**
* 改品种记录Service接口
*
* @author ruoyi
* @date 2025-07-24
*/
public interface IScChangeVarietyService
{
/**
* 查询改品种记录
*
* @param id 改品种记录主键
* @return 改品种记录
*/
public ScChangeVariety selectScChangeVarietyById(Integer id);
/**
* 查询改品种记录列表
*
* @param scChangeVariety 改品种记录
* @return 改品种记录集合
*/
public List<ScChangeVariety> selectScChangeVarietyList(ScChangeVariety scChangeVariety);
/**
* 新增改品种记录
*
* @param scChangeVariety 改品种记录
* @return 结果
*/
public int insertScChangeVariety(ScChangeVariety scChangeVariety);
/**
* 修改改品种记录
*
* @param scChangeVariety 改品种记录
* @return 结果
*/
public int updateScChangeVariety(ScChangeVariety scChangeVariety);
/**
* 批量删除改品种记录
*
* @param ids 需要删除的改品种记录主键集合
* @return 结果
*/
public int deleteScChangeVarietyByIds(Integer[] ids);
/**
* 删除改品种记录信息
*
* @param id 改品种记录主键
* @return 结果
*/
public int deleteScChangeVarietyById(Integer id);
}

View File

@ -58,4 +58,10 @@ public interface IScTransGroupService {
* @return 结果
*/
public int deleteScTransGroupById(Integer id);
/**
* 审批转群记录
*/
int approveScTransGroup(ScTransGroup scTransGroup);
}

View File

@ -6,15 +6,14 @@ import com.zhyc.module.produce.manage_sheep.domain.ScTransitionInfo;
/**
* 转场Service接口
*
*
* @author ruoyi
* @date 2025-07-10
*/
public interface IScTransitionInfoService
{
public interface IScTransitionInfoService {
/**
* 查询转场
*
*
* @param id 转场主键
* @return 转场
*/
@ -22,7 +21,7 @@ public interface IScTransitionInfoService
/**
* 查询转场列表
*
*
* @param scTransitionInfo 转场
* @return 转场集合
*/
@ -30,7 +29,7 @@ public interface IScTransitionInfoService
/**
* 新增转场
*
*
* @param scTransitionInfo 转场
* @return 结果
*/
@ -38,7 +37,7 @@ public interface IScTransitionInfoService
/**
* 修改转场
*
*
* @param scTransitionInfo 转场
* @return 结果
*/
@ -46,7 +45,7 @@ public interface IScTransitionInfoService
/**
* 批量删除转场
*
*
* @param ids 需要删除的转场主键集合
* @return 结果
*/
@ -54,9 +53,21 @@ public interface IScTransitionInfoService
/**
* 删除转场信息
*
*
* @param id 转场主键
* @return 结果
*/
public int deleteScTransitionInfoById(Integer id);
//批量转场
public int insertScTransitionInfoBatch(List<ScTransitionInfo> transitionInfoList);
//状态
public String convertStatus(Integer status);
//转场类型
public String convertTransType(Integer transType);
//审批转场
public int approveScTransitionInfo(ScTransitionInfo scTransitionInfo);
}

View File

@ -12,6 +12,7 @@ import com.zhyc.module.base.domain.DaSheepfold;
import com.zhyc.module.base.mapper.DaSheepfoldMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@ -29,57 +30,66 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
private IBasSheepService basSheepService;
@Autowired
private BasSheepVarietyMapper basSheepVarietyMapper; // 假设你有这个 mapper
private BasSheepVarietyMapper basSheepVarietyMapper;
//新增
@Override
@Transactional(rollbackFor = Exception.class)
public boolean insertScAddSheep(ScAddSheep scAddSheep) {
// 1. 重复校验
ScAddSheep exist = scAddSheepMapper.selectByEarNumber(scAddSheep.getEarNumber());
if (exist != null) {
throw new ServiceException("添加失败,耳号重复");
}
// 2. 写入 sc_add_sheep
boolean ok = scAddSheepMapper.insert(scAddSheep) > 0;
if (!ok) return false;
// 3. 字段映射 BasSheep
BasSheep bs = new BasSheep();
bs.setManageTags(scAddSheep.getEarNumber()); // 管理耳号
bs.setElectronicTags(scAddSheep.getEarNumber()); // 电子耳号
bs.setSheepfoldId(scAddSheep.getSheepfold().longValue()); // 羊舍
bs.setFatherId(null); // 父号/母号可后续补全
bs.setManageTags(scAddSheep.getEarNumber());
// bs.setElectronicTags(scAddSheep.getEarNumber());
bs.setSheepfoldId(scAddSheep.getSheepfold().longValue());
bs.setFatherId(null);
bs.setMotherId(null);
bs.setBirthWeight(scAddSheep.getBornWeight().longValue());
bs.setSource(String.valueOf(2));
bs.setBirthday(scAddSheep.getBirthday());
bs.setGender(scAddSheep.getGender().longValue());
bs.setParity(scAddSheep.getParity().longValue());
if (scAddSheep.getParity() != null) {
bs.setParity(scAddSheep.getParity().longValue());
} else {
bs.setParity(null);
}
bs.setVarietyId(scAddSheep.getVarietyId().longValue());
bs.setSourceDate(scAddSheep.getJoinDate());
bs.setComment(scAddSheep.getComment());
bs.setCreateBy(scAddSheep.getCreateBy());
bs.setCreateTime(new Date());
// 4. 写入 bas_sheep
basSheepService.insertBasSheep(bs);
return true;
}
//查询
@Override
public List<ScAddSheep> selectScAddSheepList(ScAddSheep scAddSheep) {
return scAddSheepMapper.selectScAddSheepList(scAddSheep);
}
//修改
@Override
public boolean updateScAddSheep(ScAddSheep scAddSheep) {
return scAddSheepMapper.updateScAddSheep(scAddSheep) > 0;
}
//删除
@Override
public boolean deleteScAddSheepByIds(Integer[] ids) {
return scAddSheepMapper.deleteScAddSheepByIds(ids) > 0;
}
/* ------------------ 导入 ------------------ */
//导入羊只
@Override
@Transactional(rollbackFor = Exception.class)
public String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName) {
if (list == null || list.isEmpty()) {
throw new ServiceException("导入数据不能为空!");
@ -91,7 +101,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
for (int i = 0; i < list.size(); i++) {
ScAddSheep sheep = list.get(i);
try {
/* 0. 品种名称 → 品种 ID必须最先处理 */
if (StringUtils.isNotBlank(sheep.getVarietyName())) {
Long varietyId = basSheepVarietyMapper.selectIdByName(sheep.getVarietyName());
if (varietyId == null) {
@ -112,7 +121,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue;
}
/* 1. 羊舍名称 → ID */
if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) {
DaSheepfold param = new DaSheepfold();
param.setSheepfoldName(sheep.getSheepfoldNameExcel());
@ -129,7 +137,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
sheep.setSheepfold(foldList.get(0).getId().intValue());
}
/* 2. 耳号非空校验 */
if (StringUtils.isBlank(sheep.getEarNumber())) {
failure++;
failureMsg.append("<br/>第")
@ -138,7 +145,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue;
}
/* 3. 耳号重复校验 */
ScAddSheep exist = scAddSheepMapper.selectByEarNumber(sheep.getEarNumber());
if (exist != null) {
failure++;
@ -150,7 +156,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue;
}
/* 4. 插入或更新 */
if (updateSupport && sheep.getId() != null) {
sheep.setUpdateBy(operName);
updateScAddSheep(sheep);

View File

@ -0,0 +1,120 @@
package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.Date;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.service.IBasSheepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.manage_sheep.mapper.ScChangeCommentMapper;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeComment;
import com.zhyc.module.produce.manage_sheep.service.IScChangeCommentService;
import org.springframework.transaction.annotation.Transactional;
/**
* 改备注Service业务层处理
*
* @author ruoyi
* @date 2025-07-24
*/
@Service
public class ScChangeCommentServiceImpl implements IScChangeCommentService
{
@Autowired
private ScChangeCommentMapper scChangeCommentMapper;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询改备注
*
* @param id 改备注主键
* @return 改备注
*/
@Override
public ScChangeComment selectScChangeCommentById(Long id)
{
return scChangeCommentMapper.selectScChangeCommentById(id);
}
/**
* 查询改备注列表
*
* @param scChangeComment 改备注
* @return 改备注
*/
@Override
public List<ScChangeComment> selectScChangeCommentList(ScChangeComment scChangeComment)
{
return scChangeCommentMapper.selectScChangeCommentList(scChangeComment);
}
/**
* 新增改备注
*
* @param scChangeComment 改备注
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScChangeComment(ScChangeComment scChangeComment)
{
scChangeComment.setCreateTime(new Date());
scChangeComment.setCreateBy(SecurityUtils.getUsername());
int rows = scChangeCommentMapper.insertScChangeComment(scChangeComment);
if (rows <= 0) {
return rows;
}
String manageTags = scChangeComment.getManageTags();
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只,无法更新备注");
}
sheep.setComment(scChangeComment.getNewComment());
basSheepService.updateBasSheep(sheep);
return rows;
}
/**
* 修改改备注
*
* @param scChangeComment 改备注
* @return 结果
*/
@Override
public int updateScChangeComment(ScChangeComment scChangeComment)
{
return scChangeCommentMapper.updateScChangeComment(scChangeComment);
}
/**
* 批量删除改备注
*
* @param ids 需要删除的改备注主键
* @return 结果
*/
@Override
public int deleteScChangeCommentByIds(Long[] ids)
{
return scChangeCommentMapper.deleteScChangeCommentByIds(ids);
}
/**
* 删除改备注信息
*
* @param id 改备注主键
* @return 结果
*/
@Override
public int deleteScChangeCommentById(Long id)
{
return scChangeCommentMapper.deleteScChangeCommentById(id);
}
}

View File

@ -0,0 +1,156 @@
package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.service.IBasSheepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.manage_sheep.mapper.ScChangeEarMapper;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeEar;
import com.zhyc.module.produce.manage_sheep.service.IScChangeEarService;
import org.springframework.transaction.annotation.Transactional;
/**
* 修改电子耳号记录Service业务层处理
*
* @author ruoyi
* @date 2025-07-24
*/
@Service
public class ScChangeEarServiceImpl implements IScChangeEarService
{
@Autowired
private ScChangeEarMapper scChangeEarMapper;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询修改电子耳号记录
*
* @param id 修改电子耳号记录主键
* @return 修改电子耳号记录
*/
@Override
public ScChangeEar selectScChangeEarById(Integer id) {
ScChangeEar changeEar = scChangeEarMapper.selectScChangeEarById(id);
if (changeEar != null && changeEar.getSheepId() != null) {
System.out.println("当前要查询羊只信息的sheepId: " + changeEar.getSheepId());
BasSheep sheep = basSheepService.selectBasSheepById(changeEar.getSheepId());
System.out.println("查询到的羊只信息: " + sheep);
if (sheep != null) {
if (changeEar.getEarType() != null) {
if (changeEar.getEarType() == 0) {
changeEar.setOldTag(sheep.getElectronicTags());
} else {
changeEar.setOldTag(sheep.getManageTags());
}
}
changeEar.setManageTags(sheep.getManageTags());
} else {
System.out.println("根据sheepId: " + changeEar.getSheepId() + " 未查询到对应的羊只信息");
}
} else {
System.out.println("changeEar为null或者sheepId为null");
}
System.out.println("设置旧耳号: " + changeEar.getOldTag());
return changeEar;
}
/**
* 查询修改电子耳号记录列表
*
* @param scChangeEar 修改电子耳号记录
* @return 修改电子耳号记录
*/
@Override
public List<ScChangeEar> selectScChangeEarList(ScChangeEar scChangeEar) {
List<ScChangeEar> list = scChangeEarMapper.selectScChangeEarList(scChangeEar);
return list;
}
/**
* 新增修改电子耳号记录
*
* @param scChangeEar 修改电子耳号记录
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScChangeEar(ScChangeEar scChangeEar) {
scChangeEar.setCreateTime(DateUtils.getNowDate());
scChangeEar.setCreateBy(SecurityUtils.getUsername());
// 在新增时确保旧耳号被正确设置为原始耳号的值
if (scChangeEar.getSheepId() == null) {
throw new RuntimeException("未找到对应的羊只ID");
}
BasSheep sheep = basSheepService.selectBasSheepById(scChangeEar.getSheepId());
if (sheep == null) {
throw new RuntimeException("未找到ID为【" + scChangeEar.getSheepId() + "】的羊只");
}
// 设置旧耳号为原始耳号的值
if (scChangeEar.getEarType() == 0) {
scChangeEar.setOldTag(sheep.getElectronicTags());
} else if (scChangeEar.getEarType() == 1) {
scChangeEar.setOldTag(sheep.getManageTags());
} else {
throw new RuntimeException("无效的耳号类型:" + scChangeEar.getEarType());
}
int rows = scChangeEarMapper.insertScChangeEar(scChangeEar);
System.out.println(scChangeEar);
if (rows <= 0) {
return rows;
}
// 更新羊只基本信息表中的管理耳号或电子耳号
if (scChangeEar.getEarType() == 0) {
sheep.setElectronicTags(scChangeEar.getNewTag());
} else if (scChangeEar.getEarType() == 1) {
sheep.setManageTags(scChangeEar.getNewTag());
}
basSheepService.updateBasSheep(sheep);
return rows;
}
/**
* 修改修改电子耳号记录
*
* @param scChangeEar 修改电子耳号记录
* @return 结果
*/
@Override
public int updateScChangeEar(ScChangeEar scChangeEar)
{
return scChangeEarMapper.updateScChangeEar(scChangeEar);
}
/**
* 批量删除修改电子耳号记录
*
* @param ids 需要删除的修改电子耳号记录主键
* @return 结果
*/
@Override
public int deleteScChangeEarByIds(Integer[] ids)
{
return scChangeEarMapper.deleteScChangeEarByIds(ids);
}
/**
* 删除修改电子耳号记录信息
*
* @param id 修改电子耳号记录主键
* @return 结果
*/
@Override
public int deleteScChangeEarById(Integer id)
{
return scChangeEarMapper.deleteScChangeEarById(id);
}
}

View File

@ -0,0 +1,127 @@
package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.Date;
import java.util.List;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.BasSheepVariety;
import com.zhyc.module.base.service.IBasSheepService;
import com.zhyc.module.base.service.IBasSheepVarietyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.manage_sheep.mapper.ScChangeVarietyMapper;
import com.zhyc.module.produce.manage_sheep.domain.ScChangeVariety;
import com.zhyc.module.produce.manage_sheep.service.IScChangeVarietyService;
import org.springframework.transaction.annotation.Transactional;
/**
* 改品种记录Service业务层处理
*
* @author ruoyi
* @date 2025-07-24
*/
@Service
public class ScChangeVarietyServiceImpl implements IScChangeVarietyService
{
@Autowired
private ScChangeVarietyMapper scChangeVarietyMapper;
@Autowired
private IBasSheepService basSheepService;
@Autowired
private IBasSheepVarietyService varietyService;
/**
* 查询改品种记录
*
* @param id 改品种记录主键
* @return 改品种记录
*/
@Override
public ScChangeVariety selectScChangeVarietyById(Integer id)
{
return scChangeVarietyMapper.selectScChangeVarietyById(id);
}
/**
* 查询改品种记录列表
*
* @param scChangeVariety 改品种记录
* @return 改品种记录
*/
@Override
public List<ScChangeVariety> selectScChangeVarietyList(ScChangeVariety scChangeVariety)
{
return scChangeVarietyMapper.selectScChangeVarietyList(scChangeVariety);
}
/**
* 新增改品种记录
*
* @param scChangeVariety 改品种记录
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScChangeVariety(ScChangeVariety scChangeVariety)
{
scChangeVariety.setCreateTime(new Date());
scChangeVariety.setCreateBy(SecurityUtils.getUsername());
int rows = scChangeVarietyMapper.insertScChangeVariety(scChangeVariety);
if (rows <= 0) {
return rows;
}
String manageTags = scChangeVariety.getManageTags();
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只,无法更新品种");
}
String newVarietyName = scChangeVariety.getVarietyNew();
BasSheepVariety newVariety = varietyService.selectByVarietyName(newVarietyName);
if (newVariety == null) {
throw new RuntimeException("未找到品种【" + newVarietyName + "】的信息,请检查品种名称");
}
sheep.setVarietyId(newVariety.getId());
basSheepService.updateBasSheep(sheep);
return rows;
}
/**
* 修改改品种记录
*
* @param scChangeVariety 改品种记录
* @return 结果
*/
@Override
public int updateScChangeVariety(ScChangeVariety scChangeVariety)
{
return scChangeVarietyMapper.updateScChangeVariety(scChangeVariety);
}
/**
* 批量删除改品种记录
*
* @param ids 需要删除的改品种记录主键
* @return 结果
*/
@Override
public int deleteScChangeVarietyByIds(Integer[] ids)
{
return scChangeVarietyMapper.deleteScChangeVarietyByIds(ids);
}
/**
* 删除改品种记录信息
*
* @param id 改品种记录主键
* @return 结果
*/
@Override
public int deleteScChangeVarietyById(Integer id)
{
return scChangeVarietyMapper.deleteScChangeVarietyById(id);
}
}

View File

@ -1,15 +1,21 @@
package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.service.IBasSheepService;
import com.zhyc.module.produce.manage_sheep.mapper.ScTransGroupMapper;
import com.zhyc.module.produce.manage_sheep.service.IScTransGroupService;
import com.zhyc.module.produce.manage_sheep.domain.ScTransGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 转群记录Service业务层处理
@ -21,7 +27,10 @@ import org.springframework.stereotype.Service;
public class ScTransGroupServiceImpl implements IScTransGroupService {
@Autowired
private ScTransGroupMapper scTransGroupMapper;
@Autowired
private BasSheepMapper basSheepMapper;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询转群记录
*
@ -64,6 +73,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
public int insertScTransGroup(ScTransGroup scTransGroup) {
scTransGroup.setStatus(0);
scTransGroup.setCreateTime(DateUtils.getNowDate());
scTransGroup.setCreateBy(SecurityUtils.getUsername());
return scTransGroupMapper.insertScTransGroup(scTransGroup);
}
@ -100,6 +110,51 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
return scTransGroupMapper.deleteScTransGroupById(id);
}
/**
* 审批转群记录
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int approveScTransGroup(ScTransGroup scTransGroup) {
int rows = scTransGroupMapper.updateScTransGroup(scTransGroup);
if (rows > 0 && scTransGroup.getStatus() == 1) {
updateSheepFold(scTransGroup);
}
return rows;
}
/**
* 更新羊只所在羊舍
*/
private void updateSheepFold(ScTransGroup transGroup) {
Long foldTo = Long.valueOf(transGroup.getFoldTo());
if (foldTo == null) {
throw new RuntimeException("转入羊舍不能为空");
}
String manageTags = transGroup.getManageTags();
if (manageTags == null || manageTags.isEmpty()) {
throw new RuntimeException("耳号不能为空");
}
List<String> tagList = Arrays.asList(manageTags.split(","));
for (String tag : tagList) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(tag.trim());
if (sheep != null) {
BasSheep updateSheep = new BasSheep();
updateSheep.setId(sheep.getId());
updateSheep.setSheepfoldId(foldTo);
basSheepMapper.updateBasSheep(updateSheep);
} else {
throw new RuntimeException("耳号 [" + tag + "] 不存在");
}
}
}
/**
* 转换转群原因
*/

View File

@ -1,12 +1,22 @@
package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.List;
import java.util.*;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.DaRanch;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.mapper.DaRanchMapper;
import com.zhyc.module.base.service.IBasSheepService;
import com.zhyc.module.base.service.IDaRanchService;
import com.zhyc.module.produce.manage_sheep.mapper.ScTransitionInfoMapper;
import com.zhyc.module.produce.manage_sheep.domain.ScTransitionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.manage_sheep.service.IScTransitionInfoService;
import org.springframework.transaction.annotation.Transactional;
/**
* 转场Service业务层处理
@ -19,7 +29,12 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
{
@Autowired
private ScTransitionInfoMapper scTransitionInfoMapper;
@Autowired
private BasSheepMapper basSheepMapper;
@Autowired
private IDaRanchService daRanchService;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询转场
*
@ -93,4 +108,94 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
{
return scTransitionInfoMapper.deleteScTransitionInfoById(id);
}
@Override
public int insertScTransitionInfoBatch(List<ScTransitionInfo> transitionInfoList) {
String username = SecurityUtils.getUsername();
Date now = DateUtils.getNowDate();
for (ScTransitionInfo info : transitionInfoList) {
info.setCreateBy(username); // 设置创建人
info.setCreateTime(now); // 设置创建时间
info.setStatus(0); // 设置默认状态
}
return scTransitionInfoMapper.insertScTransitionInfoBatch(transitionInfoList);
}
/**
* 审批转场记录通过时更新羊只所在牧场
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int approveScTransitionInfo(ScTransitionInfo scTransitionInfo) {
int rows = scTransitionInfoMapper.updateScTransitionInfo(scTransitionInfo);
if (rows > 0 && scTransitionInfo.getStatus() == 1) {
updateSheepRanch(scTransitionInfo);
}
return rows;
}
/**
* 更新羊只的所在牧场基于现有牧场列表接口
*/
private void updateSheepRanch(ScTransitionInfo transitionInfo) {
String transTo = transitionInfo.getTransTo();
if (StringUtils.isBlank(transTo)) {
throw new RuntimeException("转入牧场不能为空");
}
DaRanch query = new DaRanch();
query.setRanch(transTo);
List<DaRanch> ranchList = daRanchService.selectDaRanchList(query);
Optional<DaRanch> matchedRanch = ranchList.stream()
.filter(ranch -> transTo.equals(ranch.getRanch()))
.findFirst();
if (!matchedRanch.isPresent()) {
throw new RuntimeException("转入牧场 [" + transTo + "] 不存在");
}
Long targetRanchId = matchedRanch.get().getId();
String manageTags = transitionInfo.getManageTags();
if (StringUtils.isBlank(manageTags)) {
throw new RuntimeException("耳号不能为空");
}
List<String> tagList = Arrays.asList(manageTags.split(","));
for (String tag : tagList) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(tag.trim());
if (sheep == null) {
throw new RuntimeException("耳号 [" + tag + "] 不存在");
}
BasSheep updateSheep = new BasSheep();
updateSheep.setId(sheep.getId());
updateSheep.setRanchId(targetRanchId);
basSheepMapper.updateBasSheep(updateSheep);
}
}
/**
* 状态
*/
public String convertStatus(Integer statusCode) {
Map<Integer, String> statusMap = new HashMap<>();
statusMap.put(0, "待批准");
statusMap.put(1, "通过");
statusMap.put(2, "驳回");
return statusMap.getOrDefault(statusCode, "未知状态");
}
/**
* 转场类型
*/
public String convertTransType(Integer transTypeCode) {
Map<Integer, String> transTypeMap = new HashMap<>();
transTypeMap.put(0, "内部调拨");
transTypeMap.put(1, "内部销售");
transTypeMap.put(2, "育肥调拨");
return transTypeMap.getOrDefault(transTypeCode, "未知类型");
}
}

View File

@ -73,11 +73,8 @@ public class ScFixHoofController extends BaseController
@Log(title = "修蹄", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody List<ScFixHoof> dtos) {
// 处理多条修蹄记录
for (ScFixHoof dto : dtos) {
// 验证羊只ID
if (dto.getSheepId() == null && StringUtils.isNotBlank(dto.getManageTags())) {
// 通过管理耳号查找羊只ID
Long sheepId = scFixHoofService.findIdByManageTags(dto.getManageTags());
dto.setSheepId(sheepId.intValue());
}

View File

@ -28,20 +28,16 @@ public class ScCastrate extends BaseEntity {
/**
* 羊只id
*/
// @Excel(name = "羊只id")
private String sheepId;
/** 耳号(非数据库字段,用于前端) */
@Excel(name = "耳号")
private String manageTags; // 新增
private String manageTags;
/**
* 羊舍id
*/
private Long sheepfold;
/**
* 用于通过羊舍id获取羊舍名称
*/
@Excel(name = "羊舍名称")
private String sheepfoldName;

View File

@ -26,7 +26,7 @@ public class ScFixHoof extends BaseEntity
/** 羊只id */
private Integer sheepId;
/** 管理耳号(仅用于接收参数/返回视图,不存库 */
/** 管理耳号(仅用于接收参数/返回视图 */
@Excel(name = "管理耳号")
private String manageTags;

View File

@ -6,15 +6,14 @@ import com.zhyc.module.produce.other.domain.ScCastrate;
/**
* 去势Service接口
*
*
* @author ruoyi
* @date 2025-07-09
*/
public interface IScCastrateService
{
public interface IScCastrateService {
/**
* 查询去势
*
*
* @param id 去势主键
* @return 去势
*/
@ -22,7 +21,7 @@ public interface IScCastrateService
/**
* 查询去势列表
*
*
* @param scCastrate 去势
* @return 去势集合
*/
@ -30,7 +29,7 @@ public interface IScCastrateService
/**
* 新增去势
*
*
* @param scCastrate 去势
* @return 结果
*/
@ -38,7 +37,7 @@ public interface IScCastrateService
/**
* 修改去势
*
*
* @param scCastrate 去势
* @return 结果
*/
@ -46,7 +45,7 @@ public interface IScCastrateService
/**
* 批量删除去势
*
*
* @param ids 需要删除的去势主键集合
* @return 结果
*/
@ -54,9 +53,11 @@ public interface IScCastrateService
/**
* 删除去势信息
*
*
* @param id 去势主键
* @return 结果
*/
public int deleteScCastrateById(Long id);
}

View File

@ -1,6 +1,7 @@
package com.zhyc.module.produce.other.service;
import java.util.List;
import com.zhyc.module.produce.other.domain.ScFixHoof;
/**
@ -9,8 +10,7 @@ import com.zhyc.module.produce.other.domain.ScFixHoof;
* @author ruoyi
* @date 2025-07-10
*/
public interface IScFixHoofService
{
public interface IScFixHoofService {
/**
* 查询修蹄
*
@ -61,6 +61,7 @@ public interface IScFixHoofService
/**
* 根据管理耳号查询
*
* @param manageTags
* @return
*/

View File

@ -1,7 +1,11 @@
package com.zhyc.module.produce.other.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.service.IBasSheepService;
import com.zhyc.module.produce.other.domain.ScCastrate;
import com.zhyc.module.produce.other.mapper.ScCastrateMapper;
import com.zhyc.module.produce.other.service.IScCastrateService;
@ -10,86 +14,95 @@ import org.springframework.stereotype.Service;
/**
* 去势Service业务层处理
*
*
* @author ruoyi
* @date 2025-07-09
*/
@Service
public class ScCastrateServiceImpl implements IScCastrateService
{
public class ScCastrateServiceImpl implements IScCastrateService {
@Autowired
private ScCastrateMapper scCastrateMapper;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询去势
*
*
* @param id 去势主键
* @return 去势
*/
@Override
public ScCastrate selectScCastrateById(Long id)
{
public ScCastrate selectScCastrateById(Long id) {
return scCastrateMapper.selectScCastrateById(id);
}
/**
* 查询去势列表
*
*
* @param scCastrate 去势
* @return 去势
*/
@Override
public List<ScCastrate> selectScCastrateList(ScCastrate scCastrate)
{
public List<ScCastrate> selectScCastrateList(ScCastrate scCastrate) {
return scCastrateMapper.selectScCastrateList(scCastrate);
}
/**
* 新增去势
*
*
* @param scCastrate 去势
* @return 结果
*/
@Override
public int insertScCastrate(ScCastrate scCastrate)
{
public int insertScCastrate(ScCastrate scCastrate) {
scCastrate.setCreateTime(DateUtils.getNowDate());
return scCastrateMapper.insertScCastrate(scCastrate);
scCastrate.setCreateBy(SecurityUtils.getUsername());
int result = scCastrateMapper.insertScCastrate(scCastrate);
if (result > 0 && scCastrate.getSheepId() != null) {
try {
BasSheep sheep = new BasSheep();
sheep.setId(Long.parseLong(scCastrate.getSheepId()));
sheep.setGender(3L);
basSheepService.updateBasSheep(sheep);
} catch (Exception e) {
throw new RuntimeException("去势成功,但更新羊只性别失败,请重试");
}
}
return result;
}
/**
* 修改去势
*
*
* @param scCastrate 去势
* @return 结果
*/
@Override
public int updateScCastrate(ScCastrate scCastrate)
{
public int updateScCastrate(ScCastrate scCastrate) {
return scCastrateMapper.updateScCastrate(scCastrate);
}
/**
* 批量删除去势
*
*
* @param ids 需要删除的去势主键
* @return 结果
*/
@Override
public int deleteScCastrateByIds(Long[] ids)
{
public int deleteScCastrateByIds(Long[] ids) {
return scCastrateMapper.deleteScCastrateByIds(ids);
}
/**
* 删除去势信息
*
*
* @param id 去势主键
* @return 结果
*/
@Override
public int deleteScCastrateById(Long id)
{
public int deleteScCastrateById(Long id) {
return scCastrateMapper.deleteScCastrateById(id);
}
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.mapper.BasSheepMapper;
@ -31,6 +32,7 @@ public class ScFixHoofServiceImpl implements IScFixHoofService {
@Autowired
private IDaSheepfoldService daSheepfoldService;
/**
* 查询修蹄
*
@ -61,12 +63,12 @@ public class ScFixHoofServiceImpl implements IScFixHoofService {
*/
@Override
public int insertScFixHoof(ScFixHoof scFixHoof) {
// 校验羊只是否存在
BasSheep sheep = basSheepMapper.selectBasSheepById(scFixHoof.getSheepId().longValue());
if (sheep == null) {
throw new ServiceException("该羊只ID不存在请检查后再添加");
}
scFixHoof.setCreateTime(DateUtils.getNowDate());
scFixHoof.setCreateBy(SecurityUtils.getUsername());
return scFixHoofMapper.insertScFixHoof(scFixHoof);
}
@ -108,15 +110,14 @@ public class ScFixHoofServiceImpl implements IScFixHoofService {
* 根据管理耳号查询
*/
@Override
public Long findIdByManageTags(String manageTags){
if(StringUtils.isBlank(manageTags))
public Long findIdByManageTags(String manageTags) {
if (StringUtils.isBlank(manageTags))
throw new ServiceException("管理耳号不能为空");
BasSheep sheep = basSheepMapper.selectBasSheepByManageTags(manageTags.trim());
if(sheep == null)
if (sheep == null)
throw new ServiceException("管理耳号不存在:" + manageTags);
return sheep.getId();
}
}

View File

@ -1,124 +1,178 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.base.mapper.BasSheepMapper">
<resultMap type="BasSheep" id="BasSheepResult">
<result property="id" column="id" />
<result property="manageTags" column="manage_tags" />
<result property="ranchId" column="ranch_id" />
<result property="sheepfoldId" column="sheepfold_id" />
<result property="electronicTags" column="electronic_tags" />
<result property="varietyId" column="variety_id" />
<result property="family" column="family" />
<result property="typeId" column="type_id" />
<result property="gender" column="gender" />
<result property="birthday" column="birthday" />
<result property="birthWeight" column="birth_weight" />
<result property="parity" column="parity" />
<result property="statusId" column="status_id" />
<result property="weaningDate" column="weaning_date" />
<result property="weaningWeight" column="weaning_weight" />
<result property="breedStatusId" column="breed_status_id" />
<result property="fatherId" column="father_id" />
<result property="motherId" column="mother_id" />
<result property="receptorId" column="receptor_id" />
<result property="matingDate" column="mating_date" />
<result property="matingTypeId" column="mating_type_id" />
<result property="pregDate" column="preg_date" />
<result property="lambingDate" column="lambing_date" />
<result property="lambingDay" column="lambing_day" />
<result property="expectedDate" column="expected_date" />
<result property="controlled" column="controlled" />
<result property="matingCounts" column="mating_counts" />
<result property="matingTotal" column="mating_total" />
<result property="miscarriageCounts" column="miscarriage_counts" />
<result property="body" column="body" />
<result property="breast" column="breast" />
<result property="source" column="source" />
<result property="sourceDate" column="source_date" />
<result property="sourceRanchId" column="source_ranch_id" />
<result property="comment" column="comment" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="isDelete" column="is_delete" />
<resultMap type="com.zhyc.module.base.domain.BasSheep" id="BasSheepResult">
<result property="id" column="id"/>
<result property="manageTags" column="manage_tags"/>
<result property="ranchId" column="ranch_id"/>
<result property="sheepfoldId" column="sheepfold_id"/>
<result property="electronicTags" column="electronic_tags"/>
<result property="varietyId" column="variety_id"/>
<result property="family" column="family"/>
<result property="typeId" column="type_id"/>
<result property="gender" column="gender"/>
<result property="birthday" column="birthday"/>
<result property="birthWeight" column="birth_weight"/>
<result property="parity" column="parity"/>
<result property="statusId" column="status_id"/>
<result property="weaningDate" column="weaning_date"/>
<result property="weaningWeight" column="weaning_weight"/>
<result property="breedStatusId" column="breed_status_id"/>
<result property="fatherId" column="father_id"/>
<result property="motherId" column="mother_id"/>
<result property="receptorId" column="receptor_id"/>
<result property="matingDate" column="mating_date"/>
<result property="matingTypeId" column="mating_type_id"/>
<result property="pregDate" column="preg_date"/>
<result property="lambingDate" column="lambing_date"/>
<result property="lambingDay" column="lambing_day"/>
<result property="expectedDate" column="expected_date"/>
<result property="controlled" column="controlled"/>
<result property="matingCounts" column="mating_counts"/>
<result property="matingTotal" column="mating_total"/>
<result property="miscarriageCounts" column="miscarriage_counts"/>
<result property="body" column="body"/>
<result property="breast" column="breast"/>
<result property="source" column="source"/>
<result property="sourceDate" column="source_date"/>
<result property="sourceRanchId" column="source_ranch_id"/>
<result property="comment" column="comment"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="isDelete" column="is_delete"/>
</resultMap>
<sql id="selectBasSheepVo">
select id, manage_tags, ranch_id, sheepfold_id, electronic_tags, variety_id, family, type_id, gender, birthday, birth_weight, parity, status_id, weaning_date, weaning_weight, breed_status_id, father_id, mother_id, receptor_id, mating_date, mating_type_id, preg_date, lambing_date, lambing_day, expected_date, controlled, mating_counts, mating_total, miscarriage_counts, body, breast, source, source_date, source_ranch_id, comment, update_by, update_time, create_by, create_time, is_delete from bas_sheep
select id,
manage_tags,
ranch_id,
sheepfold_id,
electronic_tags,
variety_id,
family,
type_id,
gender,
birthday,
birth_weight,
parity,
status_id,
weaning_date,
weaning_weight,
breed_status_id,
father_id,
mother_id,
receptor_id,
mating_date,
mating_type_id,
preg_date,
lambing_date,
lambing_day,
expected_date,
controlled,
mating_counts,
mating_total,
miscarriage_counts,
body,
breast,
source,
source_date,
source_ranch_id,
comment,
update_by,
update_time,
create_by,
create_time,
is_delete
from bas_sheep
</sql>
<select id="selectBasSheepList" parameterType="BasSheep" resultMap="BasSheepResult">
<include refid="selectBasSheepVo"/>
<where>
<if test="manageTags != null and manageTags != ''"> and manage_tags = #{manageTags}</if>
<if test="ranchId != null "> and ranch_id = #{ranchId}</if>
<if test="sheepfoldId != null "> and sheepfold_id = #{sheepfoldId}</if>
<if test="electronicTags != null and electronicTags != ''"> and electronic_tags = #{electronicTags}</if>
<if test="varietyId != null "> and variety_id = #{varietyId}</if>
<if test="family != null and family != ''"> and family = #{family}</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
<if test="gender != null "> and gender = #{gender}</if>
<if test="birthday != null "> and birthday = #{birthday}</if>
<if test="birthWeight != null "> and birth_weight = #{birthWeight}</if>
<if test="parity != null "> and parity = #{parity}</if>
<if test="statusId != null "> and status_id = #{statusId}</if>
<if test="weaningDate != null "> and weaning_date = #{weaningDate}</if>
<if test="weaningWeight != null "> and weaning_weight = #{weaningWeight}</if>
<if test="breedStatusId != null "> and breed_status_id = #{breedStatusId}</if>
<if test="fatherId != null "> and father_id = #{fatherId}</if>
<if test="motherId != null "> and mother_id = #{motherId}</if>
<if test="receptorId != null "> and receptor_id = #{receptorId}</if>
<if test="matingDate != null "> and mating_date = #{matingDate}</if>
<if test="matingTypeId != null "> and mating_type_id = #{matingTypeId}</if>
<if test="pregDate != null "> and preg_date = #{pregDate}</if>
<if test="lambingDate != null "> and lambing_date = #{lambingDate}</if>
<if test="lambingDay != null "> and lambing_day = #{lambingDay}</if>
<if test="expectedDate != null "> and expected_date = #{expectedDate}</if>
<if test="controlled != null "> and controlled = #{controlled}</if>
<if test="matingCounts != null "> and mating_counts = #{matingCounts}</if>
<if test="matingTotal != null "> and mating_total = #{matingTotal}</if>
<if test="miscarriageCounts != null "> and miscarriage_counts = #{miscarriageCounts}</if>
<if test="body != null "> and body = #{body}</if>
<if test="breast != null "> and breast = #{breast}</if>
<if test="source != null and source != ''"> and source = #{source}</if>
<if test="sourceDate != null "> and source_date = #{sourceDate}</if>
<if test="sourceRanchId != null "> and source_ranch_id = #{sourceRanchId}</if>
<if test="comment != null and comment != ''"> and comment = #{comment}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
<if test="manageTags != null and manageTags != ''">and manage_tags = #{manageTags}</if>
<if test="ranchId != null ">and ranch_id = #{ranchId}</if>
<if test="sheepfoldId != null ">and sheepfold_id = #{sheepfoldId}</if>
<if test="electronicTags != null and electronicTags != ''">and electronic_tags = #{electronicTags}</if>
<if test="varietyId != null ">and variety_id = #{varietyId}</if>
<if test="family != null and family != ''">and family = #{family}</if>
<if test="typeId != null ">and type_id = #{typeId}</if>
<if test="gender != null ">and gender = #{gender}</if>
<if test="birthday != null ">and birthday = #{birthday}</if>
<if test="birthWeight != null ">and birth_weight = #{birthWeight}</if>
<if test="parity != null ">and parity = #{parity}</if>
<if test="statusId != null ">and status_id = #{statusId}</if>
<if test="weaningDate != null ">and weaning_date = #{weaningDate}</if>
<if test="weaningWeight != null ">and weaning_weight = #{weaningWeight}</if>
<if test="breedStatusId != null ">and breed_status_id = #{breedStatusId}</if>
<if test="fatherId != null ">and father_id = #{fatherId}</if>
<if test="motherId != null ">and mother_id = #{motherId}</if>
<if test="receptorId != null ">and receptor_id = #{receptorId}</if>
<if test="matingDate != null ">and mating_date = #{matingDate}</if>
<if test="matingTypeId != null ">and mating_type_id = #{matingTypeId}</if>
<if test="pregDate != null ">and preg_date = #{pregDate}</if>
<if test="lambingDate != null ">and lambing_date = #{lambingDate}</if>
<if test="lambingDay != null ">and lambing_day = #{lambingDay}</if>
<if test="expectedDate != null ">and expected_date = #{expectedDate}</if>
<if test="controlled != null ">and controlled = #{controlled}</if>
<if test="matingCounts != null ">and mating_counts = #{matingCounts}</if>
<if test="matingTotal != null ">and mating_total = #{matingTotal}</if>
<if test="miscarriageCounts != null ">and miscarriage_counts = #{miscarriageCounts}</if>
<if test="body != null ">and body = #{body}</if>
<if test="breast != null ">and breast = #{breast}</if>
<if test="source != null and source != ''">and source = #{source}</if>
<if test="sourceDate != null ">and source_date = #{sourceDate}</if>
<if test="sourceRanchId != null ">and source_ranch_id = #{sourceRanchId}</if>
<if test="comment != null and comment != ''">and comment = #{comment}</if>
<if test="isDelete != null ">and is_delete = #{isDelete}</if>
</where>
</select>
<select id="selectBasSheepById" parameterType="java.lang.Long" resultType="com.zhyc.module.base.domain.BasSheep">
SELECT s.id,
s.sheepfold_id AS sheepfoldId,
sf.sheepfold_name AS sheepfoldName,
s.variety_id AS varietyId,
bv.variety AS varietyName
s.manage_tags AS manageTags,
s.electronic_tags AS electronicTags,
s.sheepfold_id AS sheepfoldId,
sf.sheepfold_name AS sheepfoldName,
s.variety_id AS varietyId,
bv.variety AS varietyName
FROM bas_sheep s
LEFT JOIN da_sheepfold sf ON s.sheepfold_id = sf.id
LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id
WHERE s.id = #{id}
</select>
<select id="selectBasSheepByManageTags" parameterType="BasSheep" resultMap="BasSheepResult">
<include refid="selectBasSheepVo"/>
<where>
manage_tags = #{manageTags}
</where>
<select id="selectBasSheepByManageTags" parameterType="String" resultMap="BasSheepResult">
SELECT s.*,
bv.variety AS varietyName
FROM bas_sheep s
LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id
WHERE s.manage_tags = #{manageTags} LIMIT 1
</select>
<select id="selectBasSheepBySheepfold" parameterType="BasSheep" resultMap="BasSheepResult">
<include refid="selectBasSheepVo"/>
<where>
sheepfold_id = #{id}
</where>
<where>
sheepfold_id = #{id}
</where>
</select>
<select id="getSheepByRanchId" resultMap="BasSheepResult">
SELECT *
FROM bas_sheep
WHERE ranch_id = #{ranchId}
</select>
<select id="selectBasSheepListByIds" parameterType="list" resultMap="BasSheepResult">
SELECT * FROM bas_sheep WHERE id IN
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertBasSheep" parameterType="BasSheep" useGeneratedKeys="true" keyProperty="id">
insert into bas_sheep
@ -162,7 +216,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="isDelete != null">is_delete,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="manageTags != null">#{manageTags},</if>
<if test="ranchId != null">#{ranchId},</if>
@ -203,7 +257,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="isDelete != null">#{isDelete},</if>
</trim>
</trim>
</insert>
<update id="updateBasSheep" parameterType="BasSheep">
@ -253,7 +307,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteBasSheepById" parameterType="Long">
delete from bas_sheep where id = #{id}
delete
from bas_sheep
where id = #{id}
</delete>
<delete id="deleteBasSheepByIds" parameterType="String">
@ -263,5 +319,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="existsByManageTag" resultType="int">
SELECT COUNT(*) FROM bas_sheep WHERE manage_tags = #{tag} AND is_delete = 0
</select>
<select id="existsByElectronicTag" resultType="int">
SELECT COUNT(*) FROM bas_sheep WHERE electronic_tags = #{tag} AND is_delete = 0
</select>
</mapper>

View File

@ -1,25 +1,26 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.base.mapper.BasSheepVarietyMapper">
<resultMap type="BasSheepVariety" id="BasSheepVarietyResult">
<result property="id" column="id" />
<result property="variety" column="variety" />
<result property="id" column="id"/>
<result property="variety" column="variety"/>
</resultMap>
<sql id="selectBasSheepVarietyVo">
select id, variety from bas_sheep_variety
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>
<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}
@ -29,10 +30,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into bas_sheep_variety
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="variety != null">variety,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="variety != null">#{variety},</if>
</trim>
</trim>
</insert>
<update id="updateBasSheepVariety" parameterType="BasSheepVariety">
@ -44,11 +45,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteBasSheepVarietyById" parameterType="Long">
delete from bas_sheep_variety where id = #{id}
delete
from bas_sheep_variety
where id = #{id}
</delete>
<delete id="deleteBasSheepVarietyByIds" parameterType="String">
delete from bas_sheep_variety where id in
delete from bas_sheep_variety where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
@ -57,7 +60,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectIdByName" parameterType="string" resultType="java.lang.Long">
SELECT id
FROM bas_sheep_variety
WHERE variety = #{varietyName}
LIMIT 1
WHERE variety = #{varietyName} LIMIT 1
</select>
<select id="selectByVarietyName" parameterType="String" resultMap="BasSheepVarietyResult">
SELECT id, variety
FROM bas_sheep_variety
WHERE variety = #{varietyName} LIMIT 1
</select>
</mapper>

View File

@ -0,0 +1,59 @@
<?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.mapper.DaRanchMapper">
<resultMap type="DaRanch" id="DaRanchResult">
<result property="id" column="id"/>
<result property="ranch" column="ranch"/>
</resultMap>
<sql id="selectDaRanchVo">
select id, ranch
from da_ranch
</sql>
<select id="selectDaRanchList" parameterType="DaRanch" resultMap="DaRanchResult">
<include refid="selectDaRanchVo"/>
<where>
<if test="ranch != null and ranch != ''">and ranch = #{ranch}</if>
</where>
</select>
<select id="selectDaRanchById" parameterType="Long" resultMap="DaRanchResult">
<include refid="selectDaRanchVo"/>
where id = #{id}
</select>
<insert id="insertDaRanch" parameterType="DaRanch" useGeneratedKeys="true" keyProperty="id">
insert into da_ranch
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ranch != null">ranch,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ranch != null">#{ranch},</if>
</trim>
</insert>
<update id="updateDaRanch" parameterType="DaRanch">
update da_ranch
<trim prefix="SET" suffixOverrides=",">
<if test="ranch != null">ranch = #{ranch},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDaRanchById" parameterType="Long">
delete
from da_ranch
where id = #{id}
</delete>
<delete id="deleteDaRanchByIds" parameterType="String">
delete from da_ranch where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -1,32 +1,40 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.base.mapper.DaSheepfoldMapper">
<resultMap type="DaSheepfold" id="DaSheepfoldResult">
<result property="id" column="id" />
<result property="ranchId" column="ranch_id" />
<result property="sheepfoldName" column="sheepfold_name" />
<result property="sheepfoldTypeId" column="sheepfold_type_id" />
<result property="sheepfoldNo" column="sheepfold_no" />
<result property="rowNo" column="row_no" />
<result property="columns" column="columns" />
<result property="comment" column="comment" />
<resultMap type="com.zhyc.module.base.domain.DaSheepfold" id="DaSheepfoldResult">
<result property="id" column="id"/>
<result property="ranchId" column="ranch_id"/>
<result property="sheepfoldName" column="sheepfold_name"/>
<result property="sheepfoldTypeId" column="sheepfold_type_id"/>
<result property="sheepfoldNo" column="sheepfold_no"/>
<result property="rowNo" column="row_no"/>
<result property="columns" column="columns"/>
<result property="comment" column="comment"/>
</resultMap>
<sql id="selectDaSheepfoldVo">
select id, ranch_id, sheepfold_name, sheepfold_type_id, sheepfold_no, row_no, columns, comment from da_sheepfold
select id,
ranch_id,
sheepfold_name,
sheepfold_type_id,
sheepfold_no,
row_no,
columns,
comment
from da_sheepfold
</sql>
<select id="selectDaSheepfoldList" parameterType="DaSheepfold" resultMap="DaSheepfoldResult">
<include refid="selectDaSheepfoldVo"/>
<where>
<if test="ranchId != null "> and ranch_id = #{ranchId}</if>
<if test="sheepfoldTypeId != null "> and sheepfold_type_id = #{sheepfoldTypeId}</if>
<where>
<if test="ranchId != null ">and ranch_id = #{ranchId}</if>
<if test="sheepfoldTypeId != null ">and sheepfold_type_id = #{sheepfoldTypeId}</if>
</where>
</select>
<select id="selectDaSheepfoldById" parameterType="Long" resultMap="DaSheepfoldResult">
<include refid="selectDaSheepfoldVo"/>
where id = #{id}
@ -42,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="rowNo != null">row_no,</if>
<if test="columns != null">columns,</if>
<if test="comment != null">comment,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ranchId != null">#{ranchId},</if>
<if test="sheepfoldName != null">#{sheepfoldName},</if>
@ -51,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="rowNo != null">#{rowNo},</if>
<if test="columns != null">#{columns},</if>
<if test="comment != null">#{comment},</if>
</trim>
</trim>
</insert>
<update id="updateDaSheepfold" parameterType="DaSheepfold">
@ -69,11 +77,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteDaSheepfoldById" parameterType="Long">
delete from da_sheepfold where id = #{id}
delete
from da_sheepfold
where id = #{id}
</delete>
<delete id="deleteDaSheepfoldByIds" parameterType="String">
delete from da_sheepfold where id in
delete from da_sheepfold where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -0,0 +1,139 @@
<?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.bodyManage.mapper.ScBodyMeasureMapper">
<resultMap type="com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure" id="ScBodyMeasureResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manage_tags"/>
<result property="height" column="height"/>
<result property="bust" column="bust"/>
<result property="bodyLength" column="body_length"/>
<result property="pipeLength" column="pipe_length"/>
<result property="chestDepth" column="chest_depth"/>
<result property="hipHeight" column="hip_height"/>
<result property="rumpWidth" column="rump_width"/>
<result property="rumpHeignt" column="rump_heignt"/>
<result property="hipWidth" column="hip_width"/>
<result property="hipCrossHeight" column="hip_cross_height"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectScBodyMeasureVo">
select sm.id,
sm.sheep_id,
bs.manage_tags,
sm.height,
sm.bust,
sm.body_length,
sm.pipe_length,
sm.chest_depth,
sm.hip_height,
sm.rump_width,
sm.rump_heignt,
sm.hip_width,
sm.hip_cross_height,
sm.comment,
sm.technician,
sm.create_by,
sm.create_time
from sc_body_measure sm
left join bas_sheep bs on sm.sheep_id = bs.id
</sql>
<select id="selectScBodyMeasureList" parameterType="ScBodyMeasure" resultMap="ScBodyMeasureResult">
<include refid="selectScBodyMeasureVo"/>
<where>
<if test="sheepId != null ">and sm.sheep_id = #{sheepId}</if>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="params.beginCreateTime != null and params.endCreateTime != null">
and sm.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
</select>
<select id="selectScBodyMeasureById" parameterType="Long" resultMap="ScBodyMeasureResult">
<include refid="selectScBodyMeasureVo"/>
where sm.id = #{id}
</select>
<insert id="insertScBodyMeasure" parameterType="ScBodyMeasure" useGeneratedKeys="true" keyProperty="id">
insert into sc_body_measure
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="height != null">height,</if>
<if test="bust != null">bust,</if>
<if test="bodyLength != null">body_length,</if>
<if test="pipeLength != null">pipe_length,</if>
<if test="chestDepth != null">chest_depth,</if>
<if test="hipHeight != null">hip_height,</if>
<if test="rumpWidth != null">rump_width,</if>
<if test="rumpHeignt != null">rump_heignt,</if>
<if test="hipWidth != null">hip_width,</if>
<if test="hipCrossHeight != null">hip_cross_height,</if>
<if test="comment != null">comment,</if>
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="height != null">#{height},</if>
<if test="bust != null">#{bust},</if>
<if test="bodyLength != null">#{bodyLength},</if>
<if test="pipeLength != null">#{pipeLength},</if>
<if test="chestDepth != null">#{chestDepth},</if>
<if test="hipHeight != null">#{hipHeight},</if>
<if test="rumpWidth != null">#{rumpWidth},</if>
<if test="rumpHeignt != null">#{rumpHeignt},</if>
<if test="hipWidth != null">#{hipWidth},</if>
<if test="hipCrossHeight != null">#{hipCrossHeight},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateScBodyMeasure" parameterType="ScBodyMeasure">
update sc_body_measure
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="height != null">height = #{height},</if>
<if test="bust != null">bust = #{bust},</if>
<if test="bodyLength != null">body_length = #{bodyLength},</if>
<if test="pipeLength != null">pipe_length = #{pipeLength},</if>
<if test="chestDepth != null">chest_depth = #{chestDepth},</if>
<if test="hipHeight != null">hip_height = #{hipHeight},</if>
<if test="rumpWidth != null">rump_width = #{rumpWidth},</if>
<if test="rumpHeignt != null">rump_heignt = #{rumpHeignt},</if>
<if test="hipWidth != null">hip_width = #{hipWidth},</if>
<if test="hipCrossHeight != null">hip_cross_height = #{hipCrossHeight},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScBodyMeasureById" parameterType="Long">
delete
from sc_body_measure
where id = #{id}
</delete>
<delete id="deleteScBodyMeasureByIds" parameterType="String">
delete from sc_body_measure where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,111 @@
<?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.bodyManage.mapper.ScBodyScoreMapper">
<resultMap type="com.zhyc.module.produce.bodyManage.domain.ScBodyScore" id="ScBodyScoreResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manage_tags"/>
<result property="datetime" column="datetime"/>
<result property="score" column="score"/>
<result property="sheepfold" column="sheepfold"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectScBodyScoreVo">
select sbs.id,
sbs.sheep_id,
bs.manage_tags,
sbs.datetime,
sbs.score,
sbs.sheepfold,
ds.sheepfold_name as sheepfoldName,
sbs.comment,
sbs.technician,
sbs.create_by,
sbs.create_time
from sc_body_score sbs
left join bas_sheep bs on sbs.sheep_id = bs.id
left join da_sheepfold ds on sbs.sheepfold = ds.id
</sql>
<select id="selectScBodyScoreList" parameterType="ScBodyScore" resultMap="ScBodyScoreResult">
<include refid="selectScBodyScoreVo"/>
<where>
<if test="sheepId != null and sheepId != ''">and sbs.sheep_id = #{sheepId}</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''">
and sbs.datetime between #{params.beginDatetime} and #{params.endDatetime}
</if>
<if test="score != null ">and score = #{score}</if>
<if test="sheepfold != null ">and sheepfold = #{sheepfold}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and sbs.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
</where>
</select>
<select id="selectScBodyScoreById" parameterType="Long" resultMap="ScBodyScoreResult">
<include refid="selectScBodyScoreVo"/>
where sbs.id = #{id}
</select>
<insert id="insertScBodyScore" parameterType="ScBodyScore" useGeneratedKeys="true" keyProperty="id">
insert into sc_body_score
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="datetime != null">datetime,</if>
<if test="score != null">score,</if>
<if test="sheepfold != null">sheepfold,</if>
<if test="comment != null">comment,</if>
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="datetime != null">#{datetime},</if>
<if test="score != null">#{score},</if>
<if test="sheepfold != null">#{sheepfold},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateScBodyScore" parameterType="ScBodyScore">
update sc_body_score
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="datetime != null">datetime = #{datetime},</if>
<if test="score != null">score = #{score},</if>
<if test="sheepfold != null">sheepfold = #{sheepfold},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScBodyScoreById" parameterType="Long">
delete
from sc_body_score
where id = #{id}
</delete>
<delete id="deleteScBodyScoreByIds" parameterType="String">
delete from sc_body_score where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,107 @@
<?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.bodyManage.mapper.ScBreastRatingMapper">
<resultMap type="com.zhyc.module.produce.bodyManage.domain.ScBreastRating" id="ScBreastRatingResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manageTags"/>
<result property="depth" column="depth"/>
<result property="length" column="length"/>
<result property="position" column="position"/>
<result property="adbere" column="adbere"/>
<result property="spacing" column="spacing"/>
<result property="score" column="score"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectScBreastRatingVo">
select sbr.*,
bs.manage_tags as manageTags
from sc_breast_rating sbr
left join bas_sheep bs on sbr.sheep_id = bs.id
</sql>
<select id="selectScBreastRatingList" parameterType="ScBreastRating" resultMap="ScBreastRatingResult">
<include refid="selectScBreastRatingVo"/>
<where>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="params.beginCreateTime != null and params.endCreateTime != null">
and sbr.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
</select>
<select id="selectScBreastRatingById" parameterType="Long" resultMap="ScBreastRatingResult">
<include refid="selectScBreastRatingVo"/>
where sbr.id = #{id}
</select>
<insert id="insertScBreastRating" parameterType="ScBreastRating" useGeneratedKeys="true" keyProperty="id">
insert into sc_breast_rating
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="depth != null">depth,</if>
<if test="length != null">length,</if>
<if test="position != null">position,</if>
<if test="adbere != null">adbere,</if>
<if test="spacing != null">spacing,</if>
<if test="score != null">score,</if>
<if test="comment != null">comment,</if>
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="depth != null">#{depth},</if>
<if test="length != null">#{length},</if>
<if test="position != null">#{position},</if>
<if test="adbere != null">#{adbere},</if>
<if test="spacing != null">#{spacing},</if>
<if test="score != null">#{score},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateScBreastRating" parameterType="ScBreastRating">
update sc_breast_rating
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="depth != null">depth = #{depth},</if>
<if test="length != null">length = #{length},</if>
<if test="position != null">position = #{position},</if>
<if test="adbere != null">adbere = #{adbere},</if>
<if test="spacing != null">spacing = #{spacing},</if>
<if test="score != null">score = #{score},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScBreastRatingById" parameterType="Long">
delete
from sc_breast_rating
where id = #{id}
</delete>
<delete id="deleteScBreastRatingByIds" parameterType="String">
delete from sc_breast_rating where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -5,36 +5,34 @@
<mapper namespace="com.zhyc.module.produce.manage_sheep.mapper.ScAddSheepMapper">
<!-- 1. 结果映射:包含羊舍名称、品种名称 -->
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScAddSheep" id="ScAddSheepResult">
<result property="id" column="id"/>
<result property="earNumber" column="ear_number"/>
<result property="sheepfold" column="sheepfold"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="father" column="father"/>
<result property="mother" column="mother"/>
<result property="bornWeight" column="born_weight"/>
<result property="birthday" column="birthday"/>
<result property="gender" column="gender"/>
<result property="parity" column="parity"/>
<result property="varietyId" column="variety_id"/>
<result property="varietyName" column="varietyName"/>
<result property="joinDate" column="join_date"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="id" column="id"/>
<result property="earNumber" column="ear_number"/>
<result property="sheepfold" column="sheepfold"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="father" column="father"/>
<result property="mother" column="mother"/>
<result property="bornWeight" column="born_weight"/>
<result property="birthday" column="birthday"/>
<result property="gender" column="gender"/>
<result property="parity" column="parity"/>
<result property="varietyId" column="variety_id"/>
<result property="varietyName" column="varietyName"/>
<result property="joinDate" column="join_date"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<!-- 2. 查询列表:支持按品种筛选 -->
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
SELECT
sas.*,
sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName
bv.variety AS varietyName
FROM sc_add_sheep sas
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
<where>
<if test="earNumber != null and earNumber != ''">
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
@ -48,46 +46,43 @@
</where>
</select>
<!-- 3. 根据耳号精确查询 -->
<select id="selectByEarNumber" parameterType="string" resultMap="ScAddSheepResult">
SELECT * FROM sc_add_sheep WHERE ear_number = #{earNumber}
SELECT *
FROM sc_add_sheep
WHERE ear_number = #{earNumber}
</select>
<!-- 4. 插入 -->
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_add_sheep
(ear_number, sheepfold, father, mother, born_weight, birthday,
gender, parity, variety_id, join_date, comment, technician,
create_by, create_time)
VALUES
(#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight},
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{joinDate},
#{comment}, #{technician}, #{createBy}, #{createTime})
VALUES (#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight},
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{joinDate},
#{comment}, #{technician}, #{createBy}, #{createTime})
</insert>
<!-- 5. 更新 -->
<update id="updateScAddSheep" parameterType="ScAddSheep">
UPDATE sc_add_sheep
<set>
ear_number = #{earNumber},
sheepfold = #{sheepfold},
father = #{father},
mother = #{mother},
born_weight = #{bornWeight},
birthday = #{birthday},
gender = #{gender},
parity = #{parity},
variety_id = #{varietyId},
join_date = #{joinDate},
comment = #{comment},
technician = #{technician},
update_by = #{updateBy},
update_time = NOW()
ear_number = #{earNumber},
sheepfold = #{sheepfold},
father = #{father},
mother = #{mother},
born_weight = #{bornWeight},
birthday = #{birthday},
gender = #{gender},
parity = #{parity},
variety_id = #{varietyId},
join_date = #{joinDate},
comment = #{comment},
technician = #{technician},
update_by = #{updateBy},
update_time = NOW()
</set>
WHERE id = #{id}
</update>
<!-- 6. 批量删除 -->
<delete id="deleteScAddSheepByIds">
DELETE FROM sc_add_sheep WHERE id IN
<foreach collection="array" item="id" open="(" separator="," close=")">

View File

@ -0,0 +1,95 @@
<?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.manage_sheep.mapper.ScChangeCommentMapper">
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScChangeComment" id="ScChangeCommentResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manage_tags"/>
<result property="newComment" column="new_comment"/>
<result property="oldComment" column="old_comment"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectScChangeCommentVo">
select scc.id,
scc.sheep_id,
bs.manage_tags as manage_tags,
scc.new_comment,
scc.old_comment,
scc.create_by,
scc.create_time
from sc_change_comment scc
left join bas_sheep bs on scc.sheep_id = bs.id
</sql>
<select id="selectScChangeCommentList" parameterType="ScChangeComment" resultMap="ScChangeCommentResult">
<include refid="selectScChangeCommentVo"/>
<where>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="newComment != null and newComment != ''">
and scc.new_comment like concat('%', #{newComment}, '%')
</if>
<if test="oldComment != null and oldComment != ''">
and scc.old_comment like concat('%', #{oldComment}, '%')
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''
and params.endCreateTime != null and params.endCreateTime != ''">
and scc.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
</select>
<select id="selectScChangeCommentById" parameterType="Long" resultMap="ScChangeCommentResult">
<include refid="selectScChangeCommentVo"/>
where scc.id = #{id}
</select>
<insert id="insertScChangeComment" parameterType="ScChangeComment" useGeneratedKeys="true" keyProperty="id">
insert into sc_change_comment
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null and sheepId != ''">sheep_id,</if>
<if test="newComment != null and newComment != ''">new_comment,</if>
<if test="oldComment != null and oldComment != ''">old_comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null and sheepId != ''">#{sheepId},</if>
<if test="newComment != null and newComment != ''">#{newComment},</if>
<if test="oldComment != null and oldComment != ''">#{oldComment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateScChangeComment" parameterType="ScChangeComment">
update sc_change_comment
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null and sheepId != ''">sheep_id = #{sheepId},</if>
<if test="newComment != null and newComment != ''">new_comment = #{newComment},</if>
<if test="oldComment != null and oldComment != ''">old_comment = #{oldComment},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScChangeCommentById" parameterType="Long">
delete
from sc_change_comment
where id = #{id}
</delete>
<delete id="deleteScChangeCommentByIds" parameterType="String">
delete from sc_change_comment where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,106 @@
<?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.manage_sheep.mapper.ScChangeEarMapper">
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScChangeEar" id="ScChangeEarResult">
<result property="id" column="sce_id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manage_tags"/>
<result property="earType" column="ear_type"/>
<result property="newTag" column="newTag"/>
<result property="oldTag" column="oldTag"/>
<result property="comment" column="comment"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectScChangeEarVo">
select sce.id as sce_id,
sce.sheep_id,
bs.manage_tags as manage_tags,
sce.ear_type,
sce.newTag,
sce.oldTag as oldTag,
sce.comment,
sce.create_by,
sce.create_time
from sc_change_ear sce
LEFT JOIN bas_sheep bs ON sce.sheep_id = bs.id
</sql>
<select id="selectScChangeEarList" parameterType="ScChangeEar" resultMap="ScChangeEarResult">
<include refid="selectScChangeEarVo"/>
<where>
<if test="sheepId != null">and sce.sheep_id = #{sheepId}</if>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags LIKE CONCAT('%', #{manageTags}, '%')
</if>
<if test="earType != null ">and sce.ear_type = #{earType}</if>
<if test="newTag != null and newTag != ''">
and sce.newTag LIKE CONCAT('%', #{newTag}, '%')
</if>
<if test="oldTag != null and oldTag != ''">
and sce.oldTag LIKE CONCAT('%', #{oldTag}, '%')
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and sce.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
</select>
<select id="selectScChangeEarById" parameterType="Integer" resultMap="ScChangeEarResult">
<include refid="selectScChangeEarVo"/>
where sce.id = #{id}
</select>
<insert id="insertScChangeEar" parameterType="ScChangeEar" useGeneratedKeys="true" keyProperty="id">
insert into sc_change_ear
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="earType != null">ear_type,</if>
<if test="newTag != null and newTag != ''">newTag,</if>
<if test="oldTag != null and oldTag != ''">oldTag,</if>
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="earType != null">#{earType},</if>
<if test="newTag != null and newTag != ''">#{newTag},</if>
<if test="oldTag != null and oldTag != ''">#{oldTag},</if>
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateScChangeEar" parameterType="ScChangeEar">
update sc_change_ear
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="earType != null">ear_type = #{earType},</if>
<if test="newTag != null and newTag != ''">newTag = #{newTag},</if>
<if test="oldTag != null and oldTag != ''">oldTag = #{oldTag},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScChangeEarById" parameterType="Integer">
delete
from sc_change_ear
where id = #{id}
</delete>
<delete id="deleteScChangeEarByIds" parameterType="String">
delete from sc_change_ear where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,101 @@
<?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.manage_sheep.mapper.ScChangeVarietyMapper">
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScChangeVariety" id="ScChangeVarietyResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manage_tags"/>
<result property="varietyOld" column="variety_old"/>
<result property="varietyNew" column="variety_new"/>
<result property="comment" column="comment"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectScChangeVarietyVo">
select scv.id,
scv.sheep_id,
bs.manage_tags as manage_tags,
scv.variety_old,
scv.variety_new,
scv.comment,
scv.create_by,
scv.create_time
from sc_change_variety scv
left join bas_sheep bs on scv.sheep_id = bs.id
</sql>
<select id="selectScChangeVarietyList" parameterType="ScChangeVariety" resultMap="ScChangeVarietyResult">
<include refid="selectScChangeVarietyVo"/>
<where>
<if test="sheepId != null">and scv.sheep_id = #{sheepId}</if>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="varietyOld != null and varietyOld != ''">
and scv.variety_old like concat('%', #{varietyOld}, '%')
</if>
<if test="varietyNew != null and varietyNew != ''">
and scv.variety_new like concat('%', #{varietyNew}, '%')
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''
and params.endCreateTime != null and params.endCreateTime != ''">
and scv.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
</select>
<select id="selectScChangeVarietyById" parameterType="Integer" resultMap="ScChangeVarietyResult">
<include refid="selectScChangeVarietyVo"/>
where scv.id = #{id}
</select>
<insert id="insertScChangeVariety" parameterType="ScChangeVariety" useGeneratedKeys="true" keyProperty="id">
insert into sc_change_variety
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="varietyOld != null and varietyOld != ''">variety_old,</if>
<if test="varietyNew != null and varietyNew != ''">variety_new,</if>
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="varietyOld != null and varietyOld != ''">#{varietyOld},</if>
<if test="varietyNew != null and varietyNew != ''">#{varietyNew},</if>
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateScChangeVariety" parameterType="ScChangeVariety">
update sc_change_variety
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="varietyOld != null and varietyOld != ''">variety_old = #{varietyOld},</if>
<if test="varietyNew != null and varietyNew != ''">variety_new = #{varietyNew},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScChangeVarietyById" parameterType="Integer">
delete
from sc_change_variety
where id = #{id}
</delete>
<delete id="deleteScChangeVarietyByIds" parameterType="String">
delete from sc_change_variety where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -4,10 +4,11 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.manage_sheep.mapper.ScTransGroupMapper">
<resultMap type="ScTransGroup" id="ScTransGroupResult">
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScTransGroup" id="ScTransGroupResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manageTags"/>
<result property="sheepTypeId" column="type_id"/>
<result property="foldTo" column="fold_to"/>
<result property="foldFrom" column="fold_from"/>
<result property="reason" column="reason"/>
@ -23,7 +24,7 @@
<sql id="selectScTransGroupVo">
SELECT tg.id,
tg.sheep_id,
s.manage_tags AS manageTags,
s.manage_tags AS manageTags,
tg.fold_to,
tg.fold_from,
tg.reason,
@ -35,9 +36,12 @@
tg.create_by,
tg.create_time,
sf_from.sheepfold_name AS foldFromName,
sf_to.sheepfold_name AS foldToName
sf_to.sheepfold_name AS foldToName,
st.id AS sheepTypeId,
st.name AS sheepTypeName
FROM sc_trans_group tg
LEFT JOIN bas_sheep s ON tg.sheep_id = s.id
LEFT JOIN bas_sheep_type st ON s.type_id = st.id
LEFT JOIN da_sheepfold sf_from ON tg.fold_from = sf_from.id
LEFT JOIN da_sheepfold sf_to ON tg.fold_to = sf_to.id
LEFT JOIN bas_sheep_variety bv ON tg.variety_id = bv.id
@ -55,7 +59,7 @@
<if test="status != null">and status = #{status}</if>
<if test="varietyId != null">and tg.variety_id = #{varietyId}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
and tg.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
</select>

View File

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.manage_sheep.mapper.ScTransitionInfoMapper">
<resultMap type="ScTransitionInfo" id="ScTransitionInfoResult">
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScTransitionInfo" id="ScTransitionInfoResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="varietyId" column="variety_id"/>
@ -11,7 +11,7 @@
<result property="transTo" column="trans_to"/>
<result property="transFrom" column="trans_from"/>
<result property="transType" column="trans_type"/>
<result property="transTypeText" column="trans_type_text"/>
<result property="transTypeText" column="transTypeText"/>
<result property="technician" column="technician"/>
<result property="status" column="status"/>
<result property="comment" column="comment"/>
@ -20,27 +20,39 @@
</resultMap>
<sql id="selectScTransitionInfoVo">
SELECT t.*, bv.variety AS varietyName,
SELECT t.*,
bv.variety AS varietyName,
bs.manage_tags AS manageTags,
CASE t.trans_type
WHEN 0 THEN '内部转场'
WHEN 1 THEN '跨场转场'
WHEN 2 THEN '销售转场'
WHEN 0 THEN '内部调拨'
WHEN 1 THEN '内部销售'
WHEN 2 THEN '育肥调拨'
ELSE '未知'
END AS trans_type_text
END AS transTypeText,
CASE t.status
WHEN 0 THEN '待审批'
WHEN 1 THEN '已通过'
WHEN 2 THEN '已驳回'
ELSE '未知状态'
END AS statusText
FROM sc_transition_info t
LEFT JOIN bas_sheep_variety bv ON t.variety_id = bv.id
LEFT JOIN bas_sheep bs ON t.sheep_id = bs.id
</sql>
<select id="selectScTransitionInfoList" parameterType="ScTransitionInfo" resultMap="ScTransitionInfoResult">
<include refid="selectScTransitionInfoVo"/>
<where>
<if test="sheepId != null ">and sheep_id = #{sheepId}</if>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags LIKE CONCAT('%', #{manageTags}, '%')
</if>
<if test="varietyId != null">and t.variety_id = #{varietyId}</if>
<if test="transTo != null and transTo != ''">and trans_to = #{transTo}</if>
<if test="transFrom != null and transFrom != ''">and trans_from = #{transFrom}</if>
<if test="status != null ">and status = #{status}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
and t.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
</select>
@ -78,6 +90,21 @@
</trim>
</insert>
<insert id="insertScTransitionInfoBatch">
INSERT INTO sc_transition_info (
sheep_id, variety_id, trans_to, trans_from,
trans_type, technician, status, comment,
create_by, create_time
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.sheepId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom},
#{item.transType}, #{item.technician}, #{item.status}, #{item.comment},
#{item.createBy}, now()
)
</foreach>
</insert>
<update id="updateScTransitionInfo" parameterType="ScTransitionInfo">
update sc_transition_info
<trim prefix="SET" suffixOverrides=",">

View File

@ -7,7 +7,7 @@
<resultMap type="ScCastrate" id="ScCastrateResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manageTags"/> <!-- 新增耳号映射 -->
<result property="manageTags" column="manageTags"/>
<result property="sheepfold" column="sheepfold"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="varietyId" column="variety_id"/>
@ -21,17 +21,17 @@
<sql id="selectScCastrateVo">
select sc.id,
sc.sheep_id,
bs.manage_tags as manageTags, -- 关联羊只表的耳号
bs.manage_tags as manageTags,
sc.sheepfold,
sf.sheepfold_name as sheepfoldName,
sc.variety_id,
bv.variety as varietyName,
bv.variety as varietyName,
sc.comment,
sc.technician,
sc.create_by,
sc.create_time
from sc_castrate sc
left join bas_sheep bs on sc.sheep_id = bs.id -- 关联羊只表获取耳号
left join bas_sheep bs on sc.sheep_id = bs.id
left join da_sheepfold sf on sc.sheepfold = sf.id
left join bas_sheep_variety bv on sc.variety_id = bv.id
</sql>
@ -39,13 +39,13 @@
<select id="selectScCastrateList" parameterType="ScCastrate" resultMap="ScCastrateResult">
<include refid="selectScCastrateVo"/>
<where>
<!-- 替换原sheepId条件为耳号条件 -->
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="sheepfold != null ">and sc.sheepfold = #{sheepfold}</if>
<if test="varietyId != null">and sc.variety_id = #{varietyId}</if>
<if test="technician != null and technician != ''">and sc.technician like concat('%', #{technician}, '%')</if>
<if test="technician != null and technician != ''">and sc.technician like concat('%', #{technician}, '%')
</if>
<if test="params.beginCreateTime != null and params.endCreateTime != null">
and sc.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>

View File

@ -42,7 +42,7 @@
and fh.variety_id = #{varietyId}
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
and fh.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')