bug修复以及数据分离操作

This commit is contained in:
zyh
2026-02-09 20:22:51 +08:00
parent 7dbe337a93
commit fb80399602
50 changed files with 876 additions and 253 deletions

View File

@@ -168,7 +168,7 @@ public class BasSheepController extends BaseController {
/**
* 根据羊只类型ID查询羊只列表
*/
@PreAuthorize("@ss.hasPermi('sheep:sheep:query')")
// @PreAuthorize("@ss.hasPermi('sheep:sheep:queryByType')")
@GetMapping("/listByTypeId")
public TableDataInfo listByTypeId(Integer typeId) {
if (typeId == null) {

View File

@@ -74,6 +74,8 @@ public class ScBodyMeasureController extends BaseController {
@Log(title = "体尺测量", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScBodyMeasure scBodyMeasure) {
scBodyMeasure.setUserId(getUserId());
scBodyMeasure.setDeptId(getDeptId());
return toAjax(scBodyMeasureService.insertScBodyMeasure(scBodyMeasure));
}
@@ -140,6 +142,9 @@ public class ScBodyMeasureController extends BaseController {
measure.setCreateTime(DateUtils.getNowDate());
measure.setCreateBy(SecurityUtils.getUsername());
// 数据分离:自动填充当前用户和部门
measure.setUserId(getUserId());
measure.setDeptId(getDeptId());
scBodyMeasureService.insertScBodyMeasure(measure);
successCount++;

View File

@@ -70,6 +70,8 @@ public class ScBodyScoreController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody ScBodyScore scBodyScore)
{
scBodyScore.setUserId(getUserId());
scBodyScore.setDeptId(getDeptId());
return toAjax(scBodyScoreService.insertScBodyScore(scBodyScore));
}

View File

@@ -70,6 +70,8 @@ public class ScBreastRatingController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody ScBreastRating scBreastRating)
{
scBreastRating.setUserId(getUserId());
scBreastRating.setDeptId(getDeptId());
return toAjax(scBreastRatingService.insertScBreastRating(scBreastRating));
}

View File

@@ -212,4 +212,38 @@ public class ScBodyMeasure extends BaseEntity {
* 月龄查询条件(结束),非数据库字段
*/
private Integer monthAgeEnd;
@Excel(name = "月龄")
private Integer monthAge; // 测量时月龄
@Excel(name = "乳房深度")
private Long breastDepth; // 测量时乳房深度
@Excel(name = "乳头位置")
private String breastPosition; // 测量时乳头位置
@Excel(name = "乳头长度")
private Long breastLength; // 测量时乳头长度
@Excel(name = "乳房附着")
private String breastAdbere; // 测量时乳房附着
@Excel(name = "乳房间隔度")
private String breastSpacing; // 测量时乳房间隔度
@Excel(name = "乳房评分")
private Long breastScore; // 测量时乳房评分(快照)
@Excel(name = "体况评分")
private Long bodyScore; // 测量时体况评分(快照)
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -87,4 +87,14 @@ public class ScBodyScore extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -54,33 +54,24 @@ public class ScBreastRating extends BaseEntity {
@Excel(name = "事件日期")
private LocalDate eventDate;
/**
* 羊舍ID
*/
private Long sheepfoldId;
@Excel(name = "羊舍")
/** 羊舍名称(用于展示) */
private String sheepfoldName;
/**
* 乳房深度
*/
@Excel(name = "乳房深度")
private Long depth;
/**
* 乳房长度
*/
@Excel(name = "乳房长度")
private Long length;
/**
* 乳房位置
*/
@Excel(name = "乳房位置")
private String position;
/**
* 乳房长度
*/
@Excel(name = "乳房长度")
private Long length;
/**
* 乳房附着
*/
@@ -100,10 +91,12 @@ public class ScBreastRating extends BaseEntity {
private Long score;
/**
* 备注
* 羊舍ID
*/
@Excel(name = "备注")
private String comment;
private Long sheepfoldId;
@Excel(name = "羊舍")
/** 羊舍名称(用于展示) */
private String sheepfoldName;
/**
* 技术员
@@ -111,6 +104,12 @@ public class ScBreastRating extends BaseEntity {
@Excel(name = "技术员")
private String technician;
/**
* 备注
*/
@Excel(name = "备注")
private String comment;
/**
* 前端多耳号查询条件,非表字段
*/
@@ -120,4 +119,14 @@ public class ScBreastRating extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -1,9 +1,11 @@
package com.zhyc.module.produce.bodyManage.mapper;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure;
import com.zhyc.module.produce.bodyManage.domain.ScBreastRating;
import org.apache.ibatis.annotations.Param;
/**
@@ -76,4 +78,6 @@ public interface ScBodyMeasureMapper
* 查询繁殖状态列表
*/
List<Map<String, Object>> selectBreedStatusList();
}

View File

@@ -1,5 +1,6 @@
package com.zhyc.module.produce.bodyManage.mapper;
import java.util.Date;
import java.util.List;
import com.zhyc.module.produce.bodyManage.domain.ScBreastRating;
import org.apache.ibatis.annotations.Param;
@@ -69,4 +70,12 @@ public interface ScBreastRatingMapper
List<ScBreastRating> selectScBreastRatingList(
@Param("sc") ScBreastRating sc,
@Param("manageTagsList") List<String> manageTagsList);
/**
* 查询指定日期前该羊只最新的乳房评分记录
*/
ScBreastRating selectLatestBySheepIdBeforeDate(
@Param("sheepId") Long sheepId,
@Param("measureDate") Date measureDate
);
}

View File

@@ -1,15 +1,21 @@
package com.zhyc.module.produce.bodyManage.service.impl;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.zhyc.common.annotation.DataScope;
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 com.zhyc.module.produce.bodyManage.domain.ScBreastRating;
import com.zhyc.module.produce.bodyManage.mapper.ScBreastRatingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zhyc.module.produce.bodyManage.mapper.ScBodyMeasureMapper;
import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure;
import com.zhyc.module.produce.bodyManage.service.IScBodyMeasureService;
@@ -25,8 +31,13 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService
{
@Autowired
private ScBodyMeasureMapper scBodyMeasureMapper;
@Autowired
private IBasSheepService basSheepService;
@Autowired
private ScBreastRatingMapper scBreastRatingMapper;
/**
* 查询体尺测量
*
@@ -46,6 +57,7 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService
* @return 体尺测量
*/
@Override
@DataScope(deptAlias = "sm", userAlias = "sm")
public List<ScBodyMeasure> selectScBodyMeasureList(ScBodyMeasure scBodyMeasure) {
return scBodyMeasureMapper.selectScBodyMeasureList(scBodyMeasure,
scBodyMeasure.getManageTagsList());
@@ -58,50 +70,157 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService
/**
* 新增体尺测量
* 追根溯源原则:记录测量时刻的所有数据快照,后续羊只信息变化不影响历史记录
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScBodyMeasure(ScBodyMeasure scBodyMeasure) {
// 1. 耳号验证并获取羊只信息
String manageTags = scBodyMeasure.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scBodyMeasure.setSheepId(sheep.getId());
// 2. 固化测量时刻的基础信息(追根溯源)
fillMeasureTimeSnapshot(scBodyMeasure, sheep);
}
if (scBodyMeasure.getCurrentWeight() != null) {
// 3. 设置创建信息
scBodyMeasure.setCreateTime(DateUtils.getNowDate());
scBodyMeasure.setCreateBy(SecurityUtils.getUsername());
// 4. 保存体尺测量记录
int rows = scBodyMeasureMapper.insertScBodyMeasure(scBodyMeasure);
// 5. 同步更新羊只当前体重(实时状态,可以更新)
if (rows > 0 && scBodyMeasure.getCurrentWeight() != null) {
BasSheep updateSheep = new BasSheep();
updateSheep.setId(scBodyMeasure.getSheepId());
updateSheep.setCurrentWeight(scBodyMeasure.getCurrentWeight());
basSheepService.updateBasSheep(updateSheep);
}
scBodyMeasure.setCreateTime(DateUtils.getNowDate());
scBodyMeasure.setCreateBy(SecurityUtils.getUsername());
return scBodyMeasureMapper.insertScBodyMeasure(scBodyMeasure);
return rows;
}
/**
* 填充测量时刻的数据快照(追根溯源)
* 所有字段基于测量日期计算,固化存储,不受后续数据变化影响
*/
private void fillMeasureTimeSnapshot(ScBodyMeasure measure, BasSheep sheep) {
Date measureDate = measure.getMeasureDate();
if (measureDate == null) {
measureDate = new Date(); // 如果未指定,默认当前日期
measure.setMeasureDate(measureDate);
}
// ========== 1. 月龄(测量日期 - 出生日期)==========
if (sheep.getBirthday() != null) {
int monthAge = calculateMonthAge(sheep.getBirthday(), measureDate);
measure.setMonthAge(monthAge);
}
// ========== 2. 体况评分 & 乳房评分(羊只档案当前值)==========
measure.setBodyScore(sheep.getBody()); // 测量时的体况评分
measure.setBreastScore(sheep.getBreast()); // 测量时的乳房评分
// ========== 3. 时间相关天数(基于测量日期计算,非当前日期)==========
// 配后天数 = 测量日期 - 配种日期
if (sheep.getMatingDate() != null) {
int postMatingDay = calculateDaysDiff(sheep.getMatingDate(), measureDate);
measure.setPostMatingDay(postMatingDay);
}
// 怀孕天数 = 测量日期 - 配种日期(如果已配种)
if (sheep.getMatingDate() != null) {
int gestationDay = calculateDaysDiff(sheep.getMatingDate(), measureDate);
measure.setGestationDay(gestationDay);
}
// 泌乳天数 = 测量日期 - 产羔日期(如果已产羔)
if (sheep.getLambingDate() != null) {
int lactationDay = calculateDaysDiff(sheep.getLambingDate(), measureDate);
measure.setLactationDay(lactationDay);
}
// ========== 4. 乳房详细指标(取测量日期前最新的乳房评分记录)==========
fillBreastRatingSnapshot(measure);
}
/**
* 填充乳房评分快照(测量时刻的最新记录)
*/
private void fillBreastRatingSnapshot(ScBodyMeasure measure) {
if (measure.getSheepId() == null || measure.getMeasureDate() == null) {
return;
}
// 查询该羊只在测量日期前最新的乳房评分记录
ScBreastRating latestRating = scBreastRatingMapper
.selectLatestBySheepIdBeforeDate(measure.getSheepId(), measure.getMeasureDate());
if (latestRating != null) {
measure.setBreastDepth(latestRating.getDepth()); // 乳房深度
measure.setBreastPosition(latestRating.getPosition()); // 乳头位置
measure.setBreastLength(latestRating.getLength()); // 乳头长度
measure.setBreastAdbere(latestRating.getAdbere()); // 乳房附着
measure.setBreastSpacing(latestRating.getSpacing()); // 乳房间隔度
// 注意breastScore 取羊只档案的当前值不取历史评分记录的score
}
}
/**
* 计算月龄(精确到月)
*/
private int calculateMonthAge(Date birthday, Date measureDate) {
Calendar birthCal = Calendar.getInstance();
birthCal.setTime(birthday);
Calendar measureCal = Calendar.getInstance();
measureCal.setTime(measureDate);
int yearDiff = measureCal.get(Calendar.YEAR) - birthCal.get(Calendar.YEAR);
int monthDiff = measureCal.get(Calendar.MONTH) - birthCal.get(Calendar.MONTH);
int monthAge = yearDiff * 12 + monthDiff;
// 如果测量日期的"日"小于出生日期的"日"则不满整月减1
if (measureCal.get(Calendar.DAY_OF_MONTH) < birthCal.get(Calendar.DAY_OF_MONTH)) {
monthAge--;
}
return Math.max(0, monthAge); // 确保不为负数
}
/**
* 计算两个日期相差天数
*/
private int calculateDaysDiff(Date startDate, Date endDate) {
long diffMillis = endDate.getTime() - startDate.getTime();
return (int) (diffMillis / (1000 * 60 * 60 * 24));
}
/**
* 修改体尺测量
* 注意:修改时不改变已固化的快照数据(月龄、评分等),只修改体尺测量值本身
*/
@Override
public int updateScBodyMeasure(ScBodyMeasure scBodyMeasure) {
String manageTags = scBodyMeasure.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scBodyMeasure.setSheepId(sheep.getId());
}
if (scBodyMeasure.getCurrentWeight() != null) {
BasSheep updateSheep = new BasSheep();
updateSheep.setId(scBodyMeasure.getSheepId());
updateSheep.setCurrentWeight(scBodyMeasure.getCurrentWeight());
basSheepService.updateBasSheep(updateSheep);
}
// 修改时不同步更新体重,避免历史记录被污染
// 如需修改体重,应通过专门的功能或重新新增记录
return scBodyMeasureMapper.updateScBodyMeasure(scBodyMeasure);
}

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.produce.bodyManage.service.impl;
import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
@@ -48,6 +49,7 @@ public class ScBodyScoreServiceImpl implements IScBodyScoreService {
* @return 体况评分
*/
@Override
@DataScope(deptAlias = "sbs", userAlias = "sbs")
public List<ScBodyScore> selectScBodyScoreList(ScBodyScore scBodyScore) {
return scBodyScoreMapper.selectScBodyScoreList(scBodyScore,
scBodyScore.getManageTagsList());

View File

@@ -3,6 +3,7 @@ package com.zhyc.module.produce.bodyManage.service.impl;
import java.util.List;
import java.util.Map;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
@@ -51,6 +52,7 @@ public class ScBreastRatingServiceImpl implements IScBreastRatingService {
* @return 乳房评分
*/
@Override
@DataScope(deptAlias = "sbr", userAlias = "sbr")
public List<ScBreastRating> selectScBreastRatingList(ScBreastRating scBreastRating) {
return scBreastRatingMapper.selectScBreastRatingList(scBreastRating,
scBreastRating.getManageTagsList());

View File

@@ -1,6 +1,7 @@
package com.zhyc.module.produce.manage_sheep.controller;
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.common.exception.ServiceException;
@@ -33,7 +34,7 @@ import static com.zhyc.common.utils.SecurityUtils.getUsername;
@RestController
@RequestMapping("produce/manage_sheep/add_sheep")
public class ScAddSheepController {
public class ScAddSheepController extends BaseController {
@Autowired
private IScAddSheepService scAddSheepService;
@Autowired
@@ -73,6 +74,8 @@ public class ScAddSheepController {
}
try {
scAddSheep.setUserId(getUserId());
scAddSheep.setDeptId(getDeptId());
boolean success = scAddSheepService.insertScAddSheep(scAddSheep);
if (success) {
return success("新增成功");
@@ -134,7 +137,9 @@ public class ScAddSheepController {
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<ScAddSheep> util = new ExcelUtil<>(ScAddSheep.class);
List<ScAddSheep> list = util.importExcel(file.getInputStream());
String message = scAddSheepService.importSheep(list, updateSupport, getUsername());
Long userId = getUserId();
Long deptId = getDeptId();
String message = scAddSheepService.importSheep(list, updateSupport, getUsername(), userId, deptId);
return success(message);
}

View File

@@ -70,6 +70,8 @@ public class ScChangeCommentController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody ScChangeComment scChangeComment)
{
scChangeComment.setUserId(getUserId());
scChangeComment.setDeptId(getDeptId());
return toAjax(scChangeCommentService.insertScChangeComment(scChangeComment));
}

View File

@@ -86,6 +86,8 @@ public class ScChangeEarController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody ScChangeEar scChangeEar)
{
scChangeEar.setUserId(getUserId());
scChangeEar.setDeptId(getDeptId());
return toAjax(scChangeEarService.insertScChangeEar(scChangeEar));
}

View File

@@ -70,6 +70,8 @@ public class ScChangeVarietyController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody ScChangeVariety scChangeVariety)
{
scChangeVariety.setUserId(getUserId());
scChangeVariety.setDeptId(getDeptId());
return toAjax(scChangeVarietyService.insertScChangeVariety(scChangeVariety));
}

View File

@@ -67,6 +67,8 @@ public class ScTransGroupController extends BaseController {
@Log(title = "转群记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScTransGroup scTransGroup) {
scTransGroup.setUserId(getUserId());
scTransGroup.setDeptId(getDeptId());
return toAjax(scTransGroupService.insertScTransGroup(scTransGroup));
}

View File

@@ -72,12 +72,16 @@ public class ScTransitionInfoController extends BaseController {
@Log(title = "转场", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScTransitionInfo scTransitionInfo) {
scTransitionInfo.setUserId(getUserId());
scTransitionInfo.setDeptId(getDeptId());
return toAjax(scTransitionInfoService.insertScTransitionInfo(scTransitionInfo));
}
//批量添加
@PostMapping("/batch")
public AjaxResult addBatch(@RequestBody List<ScTransitionInfo> transitionInfoList) {
Long userId = getUserId();
Long deptId = getDeptId();
return toAjax(scTransitionInfoService.insertScTransitionInfoBatch(transitionInfoList));
}
@@ -101,6 +105,7 @@ public class ScTransitionInfoController extends BaseController {
return toAjax(scTransitionInfoService.deleteScTransitionInfoByIds(ids));
}
@PreAuthorize("@ss.hasPermi('produce:transition_info:approve')")
@PutMapping("/approve")
public AjaxResult approveScTransitionInfo(@RequestBody ScTransitionInfo scTransitionInfo) {
int rows = scTransitionInfoService.approveScTransitionInfo(scTransitionInfo);

View File

@@ -21,18 +21,23 @@ public class ScAddSheep extends BaseEntity {
* @date 2025-07-10
*/
private static final long serialVersionUID = 1L;
@Excel(name = "主键")
private Integer id;
/** 羊只耳号 */
/**
* 羊只耳号
*/
@Excel(name = "耳号")
private String earNumber;
/** 牧场 */
/**
* 牧场
*/
private Integer ranchId;
@Excel(name = "牧场名称")
private String ranchName;
/** 羊舍编号 */
/**
* 羊舍编号
*/
private Integer sheepfold;
private String sheepfoldName;
@@ -40,62 +45,95 @@ public class ScAddSheep extends BaseEntity {
@Excel(name = "羊舍名称")
private String sheepfoldNameExcel;
/** 父号 */
/**
* 父号
*/
@Excel(name = "父号")
private String father;
/** 母号 */
/**
* 母号
*/
@Excel(name = "母号")
private String mother;
/** 出生体重 */
@Excel(name = "出生体重")
private BigDecimal bornWeight;
/** 出生日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "出生日期", dateFormat = "yyyy-MM-dd")
private Date birthday;
/** 性别 1母 2公 3阉羊 */
@Excel(name = "性别", readConverterExp = "1=母,2=公,3=阉羊")
private Integer gender;
/** 胎次 */
@Excel(name = "胎次")
private Integer parity;
/** 品种id */
private Integer varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
/** 羊只类别 */
private Long typeId;
@Excel(name = "羊只类型")
private String typeName;
/** 入群日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "入群日期", dateFormat = "yyyy-MM-dd")
private Date joinDate;
/** 备注 */
@Excel(name = "备注")
private String comment;
/** 技术员 */
@Excel(name = "技术员")
private String technician;
/** 断奶体重(仅接收,不入库) */
/**
* 断奶体重(仅接收,不入库)
*/
@Excel(name = "断奶体重")
private BigDecimal weaningWeight;
private String createBy;
private Date createTime;
/**
* 出生体重
*/
@Excel(name = "出生体重")
private BigDecimal bornWeight;
/**
* 出生日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "出生日期", dateFormat = "yyyy-MM-dd")
private Date birthday;
/**
* 性别 1母 2公 3阉羊
*/
@Excel(name = "性别", readConverterExp = "1=母,2=公,3=阉羊")
private Integer gender;
/**
* 胎次
*/
@Excel(name = "胎次")
private Integer parity;
/**
* 品种id
*/
private Integer varietyId;
/**
* 品种名称(联表查询返回,非数据库字段)
*/
@Excel(name = "品种")
private String varietyName;
/**
* 羊只类别
*/
private Long typeId;
@Excel(name = "羊只类型")
private String typeName;
/**
* 入群日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "入群日期", dateFormat = "yyyy-MM-dd")
private Date joinDate;
/**
* 备注
*/
@Excel(name = "备注")
private String comment;
/**
* 技术员
*/
@Excel(name = "技术员")
private String technician;
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -82,4 +82,14 @@ public class ScChangeComment extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -101,4 +101,14 @@ public class ScChangeEar extends BaseEntity {
* 在群状态 0-全部 1-在群 2-不在群(列表查询用)
*/
private Integer inGroup;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -88,4 +88,14 @@ public class ScChangeVariety extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -112,4 +112,14 @@ public class ScTransGroup extends BaseEntity {
* 是否在群查询条件0-在群1-离群)
*/
private Integer isDelete;
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -120,4 +120,14 @@ public class ScTransitionInfo extends BaseEntity {
* 当前场区名称(展示用),非数据库字段
*/
private String currentRanchName;
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -26,7 +26,7 @@ public interface ScChangeCommentMapper
* @param scChangeComment 改备注
* @return 改备注集合
*/
public List<ScChangeComment> selectScChangeCommentList(ScChangeComment scChangeComment);
// public List<ScChangeComment> selectScChangeCommentList(ScChangeComment scChangeComment);
/**
* 新增改备注

View File

@@ -20,7 +20,7 @@ public interface IScAddSheepService {
boolean deleteScAddSheepByIds(Integer[] ids);
//导入
String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName);
String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName, Long userId, Long deptId);
}

View File

@@ -1,5 +1,6 @@
package com.zhyc.module.produce.manage_sheep.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheepType;
@@ -41,21 +42,22 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
@Autowired
private IDaRanchService daRanchService;
//新增
@Override
@Transactional(rollbackFor = Exception.class)
public boolean insertScAddSheep(ScAddSheep scAddSheep) {
BasSheep existSheep =basSheepService.selectBasSheepByManageTags(scAddSheep.getEarNumber().trim());
BasSheep existSheep = basSheepService.selectBasSheepByManageTags(scAddSheep.getEarNumber().trim());
if (existSheep != null) {
throw new ServiceException("添加失败,耳号已存在");
}
// userId 和 deptId 已在 Controller 中设置,直接插入
boolean ok = scAddSheepMapper.insert(scAddSheep) > 0;
if (!ok) return false;
BasSheep bs = new BasSheep();
bs.setManageTags(scAddSheep.getEarNumber());
// bs.setElectronicTags(scAddSheep.getEarNumber());
bs.setRanchId(scAddSheep.getRanchId().longValue());
bs.setSheepfoldId(scAddSheep.getSheepfold().longValue());
bs.setFatherId(null);
@@ -86,6 +88,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
//查询
@Override
@DataScope(deptAlias = "sas", userAlias = "sas") // sas 是 sc_add_sheep 的别名
public List<ScAddSheep> selectScAddSheepList(ScAddSheep scAddSheep) {
return scAddSheepMapper.selectScAddSheepList(scAddSheep);
}
@@ -105,7 +108,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
//导入羊只
@Override
@Transactional(rollbackFor = Exception.class)
public String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName) {
public String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName, Long userId, Long deptId) {
if (list == null || list.isEmpty()) {
throw new ServiceException("导入数据不能为空!");
}
@@ -206,6 +209,10 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue;
}
// 数据分离:设置用户和部门
sheep.setUserId(userId);
sheep.setDeptId(deptId);
if (updateSupport && sheep.getId() != null) {
sheep.setUpdateBy(operName);
updateScAddSheep(sheep);
@@ -229,6 +236,4 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
}
return "导入成功!共 " + success + "";
}
}

View File

@@ -3,6 +3,7 @@ package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.Date;
import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheep;
@@ -47,10 +48,12 @@ public class ScChangeCommentServiceImpl implements IScChangeCommentService
* @return 改备注
*/
@Override
@DataScope(deptAlias = "scc", userAlias = "scc")
public List<ScChangeComment> selectScChangeCommentList(ScChangeComment scChangeComment)
{
// 把实体和独立参数一起传过去
return scChangeCommentMapper.selectScChangeCommentList(scChangeComment,
return scChangeCommentMapper.selectScChangeCommentList(
scChangeComment,
scChangeComment.getManageTagsList());
}
@Override
@@ -73,12 +76,6 @@ public class ScChangeCommentServiceImpl implements IScChangeCommentService
if (scChangeComment.getEventDate() == null) {
throw new RuntimeException("事件日期不能为空");
}
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);
@@ -86,6 +83,16 @@ public class ScChangeCommentServiceImpl implements IScChangeCommentService
throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只,无法更新备注");
}
scChangeComment.setSheepId(String.valueOf(sheep.getId()));
scChangeComment.setOldComment(sheep.getComment());
scChangeComment.setCreateTime(new Date());
scChangeComment.setCreateBy(SecurityUtils.getUsername());
int rows = scChangeCommentMapper.insertScChangeComment(scChangeComment);
if (rows <= 0) {
return rows;
}
sheep.setComment(scChangeComment.getNewComment());
basSheepService.updateBasSheep(sheep);

View File

@@ -1,6 +1,8 @@
package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
@@ -66,6 +68,7 @@ public class ScChangeEarServiceImpl implements IScChangeEarService
* @return 修改电子耳号记录
*/
@Override
@DataScope(deptAlias = "sce", userAlias = "sce")
public List<ScChangeEar> selectScChangeEarList(ScChangeEar scChangeEar) {
return scChangeEarMapper.selectScChangeEarList(scChangeEar,
scChangeEar.getManageTagsList());
@@ -91,9 +94,6 @@ public class ScChangeEarServiceImpl implements IScChangeEarService
if (scChangeEar.getSheepId() == null) {
throw new RuntimeException("未找到对应的羊只ID");
}
if (StringUtils.isBlank(scChangeEar.getComment())) {
throw new RuntimeException("备注不能为空");
}
BasSheep sheep = basSheepService.selectBasSheepById(scChangeEar.getSheepId());
if (sheep == null) {
@@ -122,11 +122,6 @@ public class ScChangeEarServiceImpl implements IScChangeEarService
sheep.setManageTags(scChangeEar.getNewTag());
}
// 同步更新羊只主表备注
if (StringUtils.isNotBlank(scChangeEar.getComment())) {
sheep.setComment(scChangeEar.getComment());
}
basSheepService.updateBasSheep(sheep);
return rows;
}

View File

@@ -3,6 +3,7 @@ package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.Date;
import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheep;
@@ -50,6 +51,7 @@ public class ScChangeVarietyServiceImpl implements IScChangeVarietyService
* @return 改品种记录
*/
@Override
@DataScope(deptAlias = "scv", userAlias = "scv")
public List<ScChangeVariety> selectScChangeVarietyList(ScChangeVariety scChangeVariety)
{
return scChangeVarietyMapper.selectScChangeVarietyList(scChangeVariety,
@@ -66,9 +68,29 @@ public class ScChangeVarietyServiceImpl implements IScChangeVarietyService
@Transactional(rollbackFor = Exception.class)
public int insertScChangeVariety(ScChangeVariety scChangeVariety)
{
// ✅ 第1步先查羊只移到 insert 之前!)
String manageTags = scChangeVariety.getManageTags();
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只,无法更新品种");
}
// ✅ 第2步设置所有字段关键
scChangeVariety.setSheepId(sheep.getId().intValue()); // 设置羊只ID
// 查询当前品种作为旧品种(如果前端没传)
if (StringUtils.isBlank(scChangeVariety.getVarietyOld())) {
// ✅ 修正:使用正确的方法名 selectBasSheepVarietyById
BasSheepVariety oldVariety = varietyService.selectBasSheepVarietyById(sheep.getVarietyId());
if (oldVariety != null) {
scChangeVariety.setVarietyOld(oldVariety.getVariety());
}
}
scChangeVariety.setCreateTime(new Date());
scChangeVariety.setCreateBy(SecurityUtils.getUsername());
// 校验
if (StringUtils.isBlank(scChangeVariety.getTechnician())) {
throw new RuntimeException("技术员不能为空");
}
@@ -76,17 +98,13 @@ public class ScChangeVarietyServiceImpl implements IScChangeVarietyService
throw new RuntimeException("事件日期不能为空");
}
// ✅ 第3步再执行 insert此时所有字段都有值了
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 + "】的羊只,无法更新品种");
}
// 第4步更新羊只品种保持你的原逻辑
String newVarietyName = scChangeVariety.getVarietyNew();
BasSheepVariety newVariety = varietyService.selectByVarietyName(newVarietyName);
if (newVariety == null) {

View File

@@ -5,8 +5,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.zhyc.common.annotation.DataScope;
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;
@@ -54,6 +56,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
* @return 转群记录
*/
@Override
@DataScope(deptAlias = "tg", userAlias = "tg")
public List<ScTransGroup> selectScTransGroupList(ScTransGroup scTransGroup) {
List<ScTransGroup> list = scTransGroupMapper.selectScTransGroupList(scTransGroup,
scTransGroup.getManageTagsList());
@@ -74,8 +77,28 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScTransGroup(ScTransGroup scTransGroup) {
// 1. 根据耳号查询羊只信息,填充 sheepId、varietyId 等字段
String manageTags = scTransGroup.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scTransGroup.setSheepId(sheep.getId().intValue());
scTransGroup.setVarietyId(sheep.getVarietyId());
// 转出羊舍取羊只当前所在羊舍
scTransGroup.setFoldFrom(String.valueOf(sheep.getSheepfoldId()));
} else {
throw new RuntimeException("耳号不能为空");
}
// 2. 设置创建信息
scTransGroup.setCreateTime(DateUtils.getNowDate());
scTransGroup.setCreateBy(SecurityUtils.getUsername());
// 3. 数据分离字段已在 Controller 设置,这里不需要再设置
// 4. 插入数据库
int rows = scTransGroupMapper.insertScTransGroup(scTransGroup);
if (rows > 0) {
try {

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.produce.manage_sheep.service.impl;
import java.util.*;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
@@ -53,6 +54,7 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
* @return 转场
*/
@Override
@DataScope(deptAlias = "t", userAlias = "t")
public List<ScTransitionInfo> selectScTransitionInfoList(ScTransitionInfo scTransitionInfo)
{
return scTransitionInfoMapper.selectScTransitionInfoList(scTransitionInfo,
@@ -66,13 +68,27 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
* @return 结果
*/
@Override
public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo)
{
@Transactional(rollbackFor = Exception.class)
public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo) {
// 根据耳号查询羊只信息
String manageTags = scTransitionInfo.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
if (sheep == null) {
throw new RuntimeException("耳号不存在,请检查输入");
}
scTransitionInfo.setSheepId(sheep.getId().intValue());
scTransitionInfo.setVarietyId(sheep.getVarietyId());
} else {
throw new RuntimeException("耳号不能为空");
}
scTransitionInfo.setStatus(0);
scTransitionInfo.setCreateTime(DateUtils.getNowDate());
return scTransitionInfoMapper.insertScTransitionInfo(scTransitionInfo);
}
/**
* 修改转场
*
@@ -110,11 +126,25 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
}
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScTransitionInfoBatch(List<ScTransitionInfo> transitionInfoList) {
String username = SecurityUtils.getUsername();
Date now = DateUtils.getNowDate();
for (ScTransitionInfo info : transitionInfoList) {
// 每条记录根据耳号查询羊只信息
String manageTags = info.getManageTags();
if (StringUtils.isNotBlank(manageTags)) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
if (sheep == null) {
throw new RuntimeException("耳号 " + manageTags + " 不存在,请检查输入");
}
info.setSheepId(sheep.getId().intValue());
info.setVarietyId(sheep.getVarietyId());
} else {
throw new RuntimeException("耳号不能为空");
}
info.setCreateBy(username);
info.setCreateTime(now);
info.setStatus(0);

View File

@@ -71,6 +71,8 @@ public class ScCastrateController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody ScCastrate scCastrate)
{
scCastrate.setUserId(getUserId());
scCastrate.setDeptId(getDeptId());
return toAjax(scCastrateService.insertScCastrate(scCastrate));
}

View File

@@ -78,7 +78,8 @@ public class ScFixHoofController extends BaseController
Long sheepId = scFixHoofService.findIdByManageTags(dto.getManageTags());
dto.setSheepId(sheepId.intValue());
}
dto.setUserId(getUserId());
dto.setDeptId(getDeptId());
// 保存修蹄记录
scFixHoofService.insertScFixHoof(dto);
}

View File

@@ -34,20 +34,6 @@ public class ScCastrate extends BaseEntity {
@Excel(name = "耳号")
private String manageTags;
/**
* 事件类型
*/
@Excel(name = "事件类型")
private String eventType;
/**
* 羊舍id
*/
private Long sheepfold;
@Excel(name = "羊舍名称")
private String sheepfoldName;
/**
* 品种id
*/
@@ -60,10 +46,25 @@ public class ScCastrate extends BaseEntity {
private String varietyName;
/**
* 备注
* 事件类型
*/
@Excel(name = "备注")
private String comment;
@Excel(name = "事件类型")
private String eventType;
/**
* 去势日期
*/
@Excel(name = "去势日期", width = 15, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private String eventDate;
/**
* 羊舍id
*/
private Long sheepfold;
@Excel(name = "羊舍名称")
private String sheepfoldName;
/**
* 技术员
@@ -72,11 +73,10 @@ public class ScCastrate extends BaseEntity {
private String technician;
/**
* 事件日期
* 备注
*/
@Excel(name = "事件日期", width = 15, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private String eventDate;
@Excel(name = "备注")
private String comment;
/**
* 前端多耳号查询条件,非表字段
@@ -87,4 +87,14 @@ public class ScCastrate extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -89,4 +89,14 @@ public class ScFixHoof extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.produce.other.service.impl;
import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.base.domain.BasSheep;
@@ -11,6 +12,7 @@ import com.zhyc.module.produce.other.mapper.ScCastrateMapper;
import com.zhyc.module.produce.other.service.IScCastrateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 去势Service业务层处理
@@ -43,6 +45,7 @@ public class ScCastrateServiceImpl implements IScCastrateService {
* @return 去势
*/
@Override
@DataScope(deptAlias = "sc", userAlias = "sc")
public List<ScCastrate> selectScCastrateList(ScCastrate scCastrate) {
return scCastrateMapper.selectScCastrateList(scCastrate,
scCastrate.getManageTagsList());
@@ -55,21 +58,32 @@ public class ScCastrateServiceImpl implements IScCastrateService {
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertScCastrate(ScCastrate scCastrate) {
// ✅ 第1步先根据耳号查羊只确保存在且获取完整信息
String manageTags = scCastrate.getManageTags();
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags);
if (sheep == null) {
throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只");
}
// ✅ 第2步设置 sheepId 和其他字段(关键!)
scCastrate.setSheepId(String.valueOf(sheep.getId()));
scCastrate.setVarietyId(sheep.getVarietyId()); // 品种ID也设置
scCastrate.setSheepfold(sheep.getSheepfoldId()); // 羊舍ID也设置
scCastrate.setCreateTime(DateUtils.getNowDate());
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()));
// ✅ 第3步再执行 insert此时所有字段都有值了
int result = scCastrateMapper.insertScCastrate(scCastrate);
if (result <= 0) {
return result;
}
// 第4步更新羊只性别为去势3
sheep.setGender(3L);
basSheepService.updateBasSheep(sheep);
} catch (Exception e) {
throw new RuntimeException("去势成功,但更新羊只性别失败,请重试");
}
}
return result;
}

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.produce.other.service.impl;
import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
@@ -14,6 +15,7 @@ import com.zhyc.module.produce.other.mapper.ScFixHoofMapper;
import com.zhyc.module.produce.other.service.IScFixHoofService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 修蹄Service业务层处理
@@ -50,6 +52,7 @@ public class ScFixHoofServiceImpl implements IScFixHoofService {
* @return 修蹄
*/
@Override
@DataScope(deptAlias = "fh", userAlias = "fh")
public List<ScFixHoof> selectScFixHoofList(ScFixHoof scFixHoof) {
return scFixHoofMapper.selectScFixHoofList(scFixHoof,
scFixHoof.getManageTagsList());
@@ -63,13 +66,21 @@ public class ScFixHoofServiceImpl implements IScFixHoofService {
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class) // ✅ 添加事务
public int insertScFixHoof(ScFixHoof scFixHoof) {
// ✅ 查羊只(已有)
BasSheep sheep = basSheepMapper.selectBasSheepById(scFixHoof.getSheepId().longValue());
if (sheep == null) {
throw new ServiceException("该羊只ID不存在请检查后再添加");
}
// ✅ 关键:设置 sheepfold 和 varietyId你漏了
scFixHoof.setSheepfold(sheep.getSheepfoldId().intValue());
scFixHoof.setVarietyId(sheep.getVarietyId());
scFixHoof.setCreateTime(DateUtils.getNowDate());
scFixHoof.setCreateBy(SecurityUtils.getUsername());
return scFixHoofMapper.insertScFixHoof(scFixHoof);
}

View File

@@ -167,7 +167,6 @@
LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id
<where>s.manage_tags = #{manageTags}
AND s.is_delete = 0
${params.dataScope}
</where>
</select>

View File

@@ -30,10 +30,18 @@
<result property="rumpHeignt" column="rump_heignt"/>
<result property="hipWidth" column="hip_width"/>
<result property="hipCrossHeight" column="hip_cross_height"/>
<result property="breedStatusName" column="breed_status_name"/>
<result property="monthAge" column="month_age"/>
<result property="breastDepth" column="breast_depth"/>
<result property="breastPosition" column="breast_position"/>
<result property="breastLength" column="breast_length"/>
<result property="breastAdbere" column="breast_adbere"/>
<result property="breastSpacing" column="breast_spacing"/>
<result property="breastScore" column="breast_score"/>
<result property="bodyScore" column="body_score"/>
<result property="lactationDay" column="lactation_day"/>
<result property="gestationDay" column="gestation_day"/>
<result property="postMatingDay" column="post_mating_day"/>
<result property="breedStatusName" column="breed_status_name"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
@@ -43,6 +51,8 @@
<sql id="selectScBodyMeasureVo">
select sm.id,
sm.sheep_id,
sm.user_id,
sm.dept_id,
bs.manage_tags,
ds.id as sheepfold_id,
ds.sheepfold_name,
@@ -66,13 +76,18 @@
sm.rump_heignt,
sm.hip_width,
sm.hip_cross_height,
sm.month_age,
sm.breast_depth,
sm.breast_position,
sm.breast_length,
sm.breast_adbere,
sm.breast_spacing,
sm.breast_score,
sm.body_score,
sm.lactation_day,
sm.gestation_day,
sm.post_mating_day,
bbs.breed as breed_status_name,
bs.lactation_day as lactation_day,
bs.gestation_day as gestation_day,
case when bs.mating_date is not null
then DATEDIFF(NOW(), bs.mating_date)
else null
end as post_mating_day,
sm.comment,
sm.technician,
sm.create_by,
@@ -113,14 +128,21 @@
and bs.is_delete = #{sc.isDelete}
</if>
<if test="sc.monthAgeStart != null">
and <![CDATA[ TIMESTAMPDIFF(MONTH, bs.birthday, CURDATE()) >= #{sc.monthAgeStart} ]]>
and <![CDATA[ sm.month_age >= #{sc.monthAgeStart} ]]>
</if>
<if test="sc.monthAgeEnd != null">
and <![CDATA[ TIMESTAMPDIFF(MONTH, bs.birthday, CURDATE()) <= #{sc.monthAgeEnd} ]]>
and <![CDATA[ sm.month_age <= #{sc.monthAgeEnd} ]]>
</if>
<if test="sc.breedStatusName != null and sc.breedStatusName != ''">
and bbs.breed = #{sc.breedStatusName}
</if>
<if test="sc.deptId != null">
and sm.dept_id = #{sc.deptId}
</if>
<if test="sc.userId != null">
and sm.user_id = #{sc.userId}
</if>
${sc.params.dataScope}
</where>
ORDER BY sm.create_time DESC
</select>
@@ -146,10 +168,23 @@
<if test="currentWeight != null">current_weight,</if>
<if test="hipWidth != null">hip_width,</if>
<if test="hipCrossHeight != null">hip_cross_height,</if>
<if test="monthAge != null">month_age,</if>
<if test="breastDepth != null">breast_depth,</if>
<if test="breastPosition != null">breast_position,</if>
<if test="breastLength != null">breast_length,</if>
<if test="breastAdbere != null">breast_adbere,</if>
<if test="breastSpacing != null">breast_spacing,</if>
<if test="breastScore != null">breast_score,</if>
<if test="bodyScore != null">body_score,</if>
<if test="lactationDay != null">lactation_day,</if>
<if test="gestationDay != null">gestation_day,</if>
<if test="postMatingDay != null">post_mating_day,</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>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -165,10 +200,23 @@
<if test="currentWeight != null">#{currentWeight},</if>
<if test="hipWidth != null">#{hipWidth},</if>
<if test="hipCrossHeight != null">#{hipCrossHeight},</if>
<if test="monthAge != null">#{monthAge},</if>
<if test="breastDepth != null">#{breastDepth},</if>
<if test="breastPosition != null">#{breastPosition},</if>
<if test="breastLength != null">#{breastLength},</if>
<if test="breastAdbere != null">#{breastAdbere},</if>
<if test="breastSpacing != null">#{breastSpacing},</if>
<if test="breastScore != null">#{breastScore},</if>
<if test="bodyScore != null">#{bodyScore},</if>
<if test="lactationDay != null">#{lactationDay},</if>
<if test="gestationDay != null">#{gestationDay},</if>
<if test="postMatingDay != null">#{postMatingDay},</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>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -188,6 +236,17 @@
<if test="currentWeight != null">current_weight = #{currentWeight},</if>
<if test="hipWidth != null">hip_width = #{hipWidth},</if>
<if test="hipCrossHeight != null">hip_cross_height = #{hipCrossHeight},</if>
<if test="monthAge != null">month_age = #{monthAge},</if>
<if test="breastDepth != null">breast_depth = #{breastDepth},</if>
<if test="breastPosition != null">breast_position = #{breastPosition},</if>
<if test="breastLength != null">breast_length = #{breastLength},</if>
<if test="breastAdbere != null">breast_adbere = #{breastAdbere},</if>
<if test="breastSpacing != null">breast_spacing = #{breastSpacing},</if>
<if test="breastScore != null">breast_score = #{breastScore},</if>
<if test="bodyScore != null">body_score = #{bodyScore},</if>
<if test="lactationDay != null">lactation_day = #{lactationDay},</if>
<if test="gestationDay != null">gestation_day = #{gestationDay},</if>
<if test="postMatingDay != null">post_mating_day = #{postMatingDay},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if>
@@ -208,6 +267,7 @@
#{id}
</foreach>
</delete>
<select id="searchEarNumbers" resultType="java.lang.String">
SELECT DISTINCT bs.manage_tags
FROM bas_sheep bs

View File

@@ -24,6 +24,8 @@
<sql id="selectScBodyScoreVo">
select sbs.id,
sbs.sheep_id,
sbs.user_id,
sbs.dept_id,
bs.manage_tags,
bsv.id as varietyId,
bsv.variety as varietyName,
@@ -62,6 +64,10 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
<if test="sc.technician != null and sc.technician != ''">
and sbs.technician like concat('%', #{sc.technician}, '%')
</if>
${sc.params.dataScope}
</where>
ORDER BY sbs.create_time DESC
</select>
@@ -82,6 +88,8 @@
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -92,6 +100,8 @@
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -129,6 +139,5 @@
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
LIMIT 50
</select>
</mapper>

View File

@@ -24,11 +24,15 @@
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectScBreastRatingVo">
select sbr.*,
bs.manage_tags as manageTags,
sbr.user_id,
sbr.dept_id,
bsv.id as varietyId,
bsv.variety as varietyName,
'乳房评分' as event_type,
@@ -60,6 +64,13 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
<if test="sc.technician != null and sc.technician != ''">
and sbr.technician = #{sc.technician}
</if>
<if test="sc.score != null">
and sbr.score = #{sc.score}
</if>
${sc.params.dataScope}
</where>
ORDER BY sbr.create_time DESC
</select>
@@ -84,6 +95,8 @@
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -98,6 +111,8 @@
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -137,6 +152,15 @@
FROM bas_sheep bs
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags LIMIT 50
ORDER BY bs.manage_tags
</select>
<select id="selectLatestBySheepIdBeforeDate" resultMap="ScBreastRatingResult">
SELECT *
FROM sc_breast_rating
WHERE sheep_id = #{sheepId}
AND event_date &lt;= #{measureDate}
ORDER BY event_date DESC, create_time DESC LIMIT 1
</select>
</mapper>

View File

@@ -25,11 +25,30 @@
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
<sql id="selectScAddSheepVo">
SELECT
sas.*,
sas.id,
sas.ear_number,
sas.sheepfold,
sas.ranch_id,
sas.father,
sas.mother,
sas.born_weight,
sas.birthday,
sas.gender,
sas.parity,
sas.variety_id,
sas.type_id,
sas.join_date,
sas.comment,
sas.technician,
sas.create_by,
sas.create_time,
sas.user_id,
sas.dept_id,
sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName,
st.type_name AS typeName
@@ -37,6 +56,9 @@
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
LEFT JOIN bas_sheep_type st ON sas.type_id = st.id
</sql>
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
<include refid="selectScAddSheepVo"/>
<where>
<if test="earNumber != null and earNumber != ''">
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
@@ -50,6 +72,7 @@
<if test="typeId != null">
AND sas.type_id = #{typeId}
</if>
${params.dataScope}
</where>
</select>
@@ -61,12 +84,46 @@
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_add_sheep
(ear_number, sheepfold, ranch_id, father, mother, born_weight, birthday,
gender, parity, variety_id, type_id, join_date, comment, technician,
create_by, create_time)
VALUES (#{earNumber}, #{sheepfold}, #{ranchId}, #{father}, #{mother}, #{bornWeight},
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{typeId}, #{joinDate},
#{comment}, #{technician}, #{createBy}, #{createTime})
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="earNumber != null">ear_number,</if>
<if test="sheepfold != null">sheepfold,</if>
<if test="ranchId != null">ranch_id,</if>
<if test="father != null">father,</if>
<if test="mother != null">mother,</if>
<if test="bornWeight != null">born_weight,</if>
<if test="birthday != null">birthday,</if>
<if test="gender != null">gender,</if>
<if test="parity != null">parity,</if>
<if test="varietyId != null">variety_id,</if>
<if test="typeId != null">type_id,</if>
<if test="joinDate != null">join_date,</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>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="earNumber != null">#{earNumber},</if>
<if test="sheepfold != null">#{sheepfold},</if>
<if test="ranchId != null">#{ranchId},</if>
<if test="father != null">#{father},</if>
<if test="mother != null">#{mother},</if>
<if test="bornWeight != null">#{bornWeight},</if>
<if test="birthday != null">#{birthday},</if>
<if test="gender != null">#{gender},</if>
<if test="parity != null">#{parity},</if>
<if test="varietyId != null">#{varietyId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="joinDate != null">#{joinDate},</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>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
<update id="updateScAddSheep" parameterType="ScAddSheep">

View File

@@ -21,6 +21,8 @@
<sql id="selectScChangeCommentVo">
select scc.id,
scc.sheep_id,
scc.user_id,
scc.dept_id,
bs.manage_tags as manage_tags,
sf.sheepfold_name as sheepfold_name,
'改备注' as event_type,
@@ -43,9 +45,9 @@
bs.manage_tags like concat('%', #{tag}, '%')
</foreach>
</if>
<!-- <if test="sc.sheepfoldId != null">-->
<!-- and bs.sheepfold_id = #{sc.sheepfoldId}-->
<!-- </if>-->
<!-- <if test="sc.sheepfoldId != null">-->
<!-- and bs.sheepfold_id = #{sc.sheepfoldId}-->
<!-- </if>-->
<if test="sc.technician != null and sc.technician != ''">
and scc.technician like concat('%', #{sc.technician}, '%')
</if>
@@ -66,6 +68,7 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY scc.create_time DESC
</select>
@@ -85,6 +88,8 @@
<if test="createTime != null">create_time,</if>
<if test="eventDate != null">event_date,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null and sheepId != ''">#{sheepId},</if>
@@ -94,6 +99,8 @@
<if test="createTime != null">#{createTime},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -128,6 +135,5 @@
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
LIMIT 50
</select>
</mapper>

View File

@@ -73,6 +73,7 @@
<when test="sc.inGroup == 2">and bs.is_delete = 1</when>
</choose>
</if>
${sc.params.dataScope}
</where>
ORDER BY sce.create_time DESC
</select>
@@ -94,6 +95,8 @@
<if test="createTime != null">create_time,</if>
<if test="eventDate != null">event_date,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -105,6 +108,8 @@
<if test="createTime != null">#{createTime},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -141,6 +146,5 @@
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
LIMIT 50
</select>
</mapper>

View File

@@ -65,6 +65,7 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY scv.create_time DESC
</select>
@@ -83,8 +84,10 @@
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="technician != null and technician != ''">technician,</if> <!-- 新增 -->
<if test="eventDate != null">event_date,</if> <!-- 新增 -->
<if test="technician != null and technician != ''">technician,</if>
<if test="eventDate != null">event_date,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -93,8 +96,10 @@
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="technician != null and technician != ''">#{technician},</if> <!-- 新增 -->
<if test="eventDate != null">#{eventDate},</if> <!-- 新增 -->
<if test="technician != null and technician != ''">#{technician},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -129,6 +134,6 @@
FROM bas_sheep bs
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags LIMIT 50
ORDER BY bs.manage_tags
</select>
</mapper>

View File

@@ -18,11 +18,15 @@
<result property="comment" column="comment"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectScTransGroupVo">
SELECT tg.id,
tg.sheep_id,
tg.user_id,
tg.dept_id,
s.manage_tags AS manageTags,
tg.event_type AS eventType,
tg.trans_date AS transDate,
@@ -38,9 +42,7 @@
tg.create_time,
sf_from.sheepfold_name AS foldFromName,
sf_to.sheepfold_name AS foldToName,
tg.technician,
st.id AS sheepTypeId,
st.name AS sheepTypeName
tg.technician
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
@@ -74,6 +76,7 @@
<if test="sc.isDelete != null">
and s.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY tg.create_time DESC
</select>
@@ -99,6 +102,8 @@
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -112,6 +117,8 @@
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>

View File

@@ -19,12 +19,16 @@
<result property="comment" column="comment"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectScTransitionInfoVo">
SELECT t.*,
bv.variety AS varietyName,
bs.manage_tags AS manageTags,
t.user_id,
t.dept_id,
sf.sheepfold_name AS sheepfoldName,
t.event_type AS eventType,
t.transition_date AS transitionDate,
@@ -77,6 +81,7 @@
<if test="sc.currentRanchId != null">
and bs.ranch_id = #{sc.currentRanchId}
</if>
${sc.params.dataScope}
</where>
ORDER BY t.create_time DESC
</select>
@@ -101,6 +106,8 @@
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -115,6 +122,8 @@
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -171,6 +180,6 @@
FROM bas_sheep bs
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags LIMIT 50
ORDER BY bs.manage_tags
</select>
</mapper>

View File

@@ -50,7 +50,9 @@
</if>
<if test="sc.sheepfold != null">and bs.sheepfold_id = #{sc.sheepfold}</if>
<if test="sc.varietyId != null">and bs.variety_id = #{sc.varietyId}</if>
<if test="sc.technician != null and sc.technician != ''">and sc.technician like concat('%', #{sc.technician}, '%')</if>
<if test="sc.technician != null and sc.technician != ''">
and sc.technician like concat('%', #{sc.technician}, '%')
</if>
<if test="sc.params != null and sc.params.beginCreateTime != null and sc.params.beginCreateTime != '' and sc.params.endCreateTime != null and sc.params.endCreateTime != ''">
and sc.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime}
</if>
@@ -60,6 +62,7 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY sc.create_time DESC
</select>
@@ -80,6 +83,8 @@
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="eventDate != null">event_date,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -90,6 +95,8 @@
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -126,6 +133,5 @@
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
LIMIT 50
</select>
</mapper>

View File

@@ -59,6 +59,7 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY fh.create_time DESC
</select>
@@ -68,26 +69,32 @@
where fh.id = #{id}
</select>
<insert id="insertScFixHoof" parameterType="ScFixHoof"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_fix_hoof
(sheep_id,
sheepfold,
variety_id,
<insert id="insertScFixHoof" parameterType="ScFixHoof" useGeneratedKeys="true" keyProperty="id">
insert into sc_fix_hoof
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="sheepfold != null">sheepfold,</if>
<if test="varietyId != null">variety_id,</if>
<if test="comment != null">comment,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="eventDate != null and eventDate != ''">event_date,</if>
create_by,
create_time)
VALUES
(#{sheepId},
#{sheepfold},
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="sheepfold != null">#{sheepfold},</if>
<if test="varietyId != null">#{varietyId},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="eventDate != null and eventDate != ''">#{eventDate},</if>
#{createBy},
#{createTime})
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
<update id="updateScFixHoof" parameterType="ScFixHoof">