diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java b/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java index edbabb6..f2722a1 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java @@ -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) { diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyMeasureController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyMeasureController.java index f1bbb81..7970480 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyMeasureController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyMeasureController.java @@ -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++; diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyScoreController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyScoreController.java index 2ee2ca7..7d78fcf 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyScoreController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyScoreController.java @@ -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)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBreastRatingController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBreastRatingController.java index 670b566..3633f62 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBreastRatingController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBreastRatingController.java @@ -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)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java index 2b1bf5b..4a1ae39 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java @@ -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; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java index c37ee77..9035967 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java @@ -87,4 +87,14 @@ public class ScBodyScore extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java index fc0859e..e366749 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java @@ -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; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBodyMeasureMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBodyMeasureMapper.java index 7859be9..5d0b7eb 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBodyMeasureMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBodyMeasureMapper.java @@ -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> selectBreedStatusList(); + + } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBreastRatingMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBreastRatingMapper.java index dedcb4b..b5caa35 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBreastRatingMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBreastRatingMapper.java @@ -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 selectScBreastRatingList( @Param("sc") ScBreastRating sc, @Param("manageTagsList") List manageTagsList); + + /** + * 查询指定日期前该羊只最新的乳房评分记录 + */ + ScBreastRating selectLatestBySheepIdBeforeDate( + @Param("sheepId") Long sheepId, + @Param("measureDate") Date measureDate + ); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyMeasureServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyMeasureServiceImpl.java index 77a334b..075ccd9 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyMeasureServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyMeasureServiceImpl.java @@ -1,35 +1,46 @@ 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; /** * 体尺测量Service业务层处理 - * + * * @author ruoyi * @date 2025-07-27 */ @Service -public class ScBodyMeasureServiceImpl implements IScBodyMeasureService +public class ScBodyMeasureServiceImpl implements IScBodyMeasureService { @Autowired private ScBodyMeasureMapper scBodyMeasureMapper; + @Autowired private IBasSheepService basSheepService; + + @Autowired + private ScBreastRatingMapper scBreastRatingMapper; + /** * 查询体尺测量 - * + * * @param id 体尺测量主键 * @return 体尺测量 */ @@ -41,11 +52,12 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService /** * 查询体尺测量列表 - * + * * @param scBodyMeasure 体尺测量 * @return 体尺测量 */ @Override + @DataScope(deptAlias = "sm", userAlias = "sm") public List selectScBodyMeasureList(ScBodyMeasure scBodyMeasure) { return scBodyMeasureMapper.selectScBodyMeasureList(scBodyMeasure, scBodyMeasure.getManageTagsList()); @@ -58,57 +70,164 @@ 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); } /** * 批量删除体尺测量 - * + * * @param ids 需要删除的体尺测量主键 * @return 结果 */ @@ -120,7 +239,7 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService /** * 删除体尺测量信息 - * + * * @param id 体尺测量主键 * @return 结果 */ @@ -134,4 +253,4 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService public List> selectBreedStatusList() { return scBodyMeasureMapper.selectBreedStatusList(); } -} +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyScoreServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyScoreServiceImpl.java index e25bce9..f720f08 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyScoreServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyScoreServiceImpl.java @@ -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 selectScBodyScoreList(ScBodyScore scBodyScore) { return scBodyScoreMapper.selectScBodyScoreList(scBodyScore, scBodyScore.getManageTagsList()); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBreastRatingServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBreastRatingServiceImpl.java index 4fd01cd..70c35c0 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBreastRatingServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBreastRatingServiceImpl.java @@ -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 selectScBreastRatingList(ScBreastRating scBreastRating) { return scBreastRatingMapper.selectScBreastRatingList(scBreastRating, scBreastRating.getManageTagsList()); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScAddSheepController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScAddSheepController.java index 51bc1c9..0f7a70e 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScAddSheepController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScAddSheepController.java @@ -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 util = new ExcelUtil<>(ScAddSheep.class); List 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); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeCommentController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeCommentController.java index f6f5d88..f5d25b4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeCommentController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeCommentController.java @@ -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)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeEarController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeEarController.java index a1cb289..3ed4ea9 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeEarController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeEarController.java @@ -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)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeVarietyController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeVarietyController.java index 5bd289e..696ef2a 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeVarietyController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeVarietyController.java @@ -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)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransGroupController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransGroupController.java index 192ed1f..0c55b4f 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransGroupController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransGroupController.java @@ -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)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransitionInfoController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransitionInfoController.java index 5863be8..fe5e615 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransitionInfoController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransitionInfoController.java @@ -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 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); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java index 4bb4444..6d99be7 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java @@ -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; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java index 3260a90..66c7247 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java @@ -82,4 +82,14 @@ public class ScChangeComment extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java index 911a156..9db0c0d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java @@ -101,4 +101,14 @@ public class ScChangeEar extends BaseEntity { * 在群状态 0-全部 1-在群 2-不在群(列表查询用) */ private Integer inGroup; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java index d984268..92cdd55 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java @@ -88,4 +88,14 @@ public class ScChangeVariety extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java index 40b7d0b..c106749 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java @@ -112,4 +112,14 @@ public class ScTransGroup extends BaseEntity { * 是否在群查询条件(0-在群,1-离群) */ private Integer isDelete; + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java index e47bf49..d1d3a4e 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java @@ -120,4 +120,14 @@ public class ScTransitionInfo extends BaseEntity { * 当前场区名称(展示用),非数据库字段 */ private String currentRanchName; + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java index 51c85f5..7f04ca2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java @@ -26,7 +26,7 @@ public interface ScChangeCommentMapper * @param scChangeComment 改备注 * @return 改备注集合 */ - public List selectScChangeCommentList(ScChangeComment scChangeComment); +// public List selectScChangeCommentList(ScChangeComment scChangeComment); /** * 新增改备注 diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScAddSheepService.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScAddSheepService.java index e39b7c9..95201a1 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScAddSheepService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScAddSheepService.java @@ -20,7 +20,7 @@ public interface IScAddSheepService { boolean deleteScAddSheepByIds(Integer[] ids); //导入 - String importSheep(List list, boolean updateSupport, String operName); + String importSheep(List list, boolean updateSupport, String operName, Long userId, Long deptId); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java index 073a562..23cc7ba 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java @@ -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 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 list, boolean updateSupport, String operName) { + public String importSheep(List 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 + " 条"; } - - } \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeCommentServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeCommentServiceImpl.java index 9d582d4..67f9ee2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeCommentServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeCommentServiceImpl.java @@ -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 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); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeEarServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeEarServiceImpl.java index fd968ff..b025041 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeEarServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeEarServiceImpl.java @@ -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 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; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java index be56bde..e8fac47 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java @@ -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 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) { diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransGroupServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransGroupServiceImpl.java index f78e247..7910cb4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransGroupServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransGroupServiceImpl.java @@ -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 selectScTransGroupList(ScTransGroup scTransGroup) { List 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 { diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java index ceafa11..73067fe 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java @@ -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 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 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); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScCastrateController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScCastrateController.java index 57a0411..d4ae1b8 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScCastrateController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScCastrateController.java @@ -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)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScFixHoofController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScFixHoofController.java index fb20b18..208ade3 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScFixHoofController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScFixHoofController.java @@ -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); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java index f2bfc4d..f97a8a2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java @@ -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; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java index 70867f0..0329a66 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java @@ -89,4 +89,14 @@ public class ScFixHoof extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScCastrateServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScCastrateServiceImpl.java index f000dd3..226de72 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScCastrateServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScCastrateServiceImpl.java @@ -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 selectScCastrateList(ScCastrate scCastrate) { return scCastrateMapper.selectScCastrateList(scCastrate, scCastrate.getManageTagsList()); @@ -55,22 +58,33 @@ 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())); - sheep.setGender(3L); - basSheepService.updateBasSheep(sheep); - } catch (Exception e) { - throw new RuntimeException("去势成功,但更新羊只性别失败,请重试"); - } + // ✅ 第3步:再执行 insert(此时所有字段都有值了) + int result = scCastrateMapper.insertScCastrate(scCastrate); + if (result <= 0) { + return result; } + // 第4步:更新羊只性别为去势(3) + sheep.setGender(3L); + basSheepService.updateBasSheep(sheep); + return result; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScFixHoofServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScFixHoofServiceImpl.java index ed77ff9..fba20cf 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScFixHoofServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScFixHoofServiceImpl.java @@ -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 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); } diff --git a/zhyc-module/src/main/resources/mapper/base/BasSheepMapper.xml b/zhyc-module/src/main/resources/mapper/base/BasSheepMapper.xml index 93abbc6..a2660f4 100644 --- a/zhyc-module/src/main/resources/mapper/base/BasSheepMapper.xml +++ b/zhyc-module/src/main/resources/mapper/base/BasSheepMapper.xml @@ -167,7 +167,6 @@ LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id s.manage_tags = #{manageTags} AND s.is_delete = 0 - ${params.dataScope} diff --git a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml index 7f0c262..c6c2fc0 100644 --- a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml @@ -30,10 +30,18 @@ - + + + + + + + + + @@ -42,47 +50,54 @@ select sm.id, - sm.sheep_id, - bs.manage_tags, - ds.id as sheepfold_id, - ds.sheepfold_name, - bsv.id as variety_id, - bsv.variety as variety_name, - '体尺测量' as event_type, - bst.name as sheep_type_name, - sm.measure_date, - bs.gender, - bs.parity, - bs.birth_weight as birth_weight, - bs.weaning_weight as weaning_weight, - sm.current_weight as current_weight, - 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, - 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, - sm.create_time + sm.sheep_id, + sm.user_id, + sm.dept_id, + bs.manage_tags, + ds.id as sheepfold_id, + ds.sheepfold_name, + bsv.id as variety_id, + bsv.variety as variety_name, + '体尺测量' as event_type, + bst.name as sheep_type_name, + sm.measure_date, + bs.gender, + bs.parity, + bs.birth_weight as birth_weight, + bs.weaning_weight as weaning_weight, + sm.current_weight as current_weight, + 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.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, + 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 - LEFT JOIN bas_breed_status bbs ON bs.breed_status_id = bbs.id - LEFT JOIN da_sheepfold ds ON bs.sheepfold_id = ds.id - LEFT JOIN bas_sheep_type bst ON bs.type_id = bst.id - LEFT JOIN bas_sheep_variety bsv ON bs.variety_id = bsv.id + LEFT JOIN bas_sheep bs ON sm.sheep_id = bs.id + LEFT JOIN bas_breed_status bbs ON bs.breed_status_id = bbs.id + LEFT JOIN da_sheepfold ds ON bs.sheepfold_id = ds.id + LEFT JOIN bas_sheep_type bst ON bs.type_id = bst.id + LEFT JOIN bas_sheep_variety bsv ON bs.variety_id = bsv.id @@ -146,10 +168,23 @@ current_weight, hip_width, hip_cross_height, + month_age, + breast_depth, + breast_position, + breast_length, + breast_adbere, + breast_spacing, + breast_score, + body_score, + lactation_day, + gestation_day, + post_mating_day, comment, technician, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -165,10 +200,23 @@ #{currentWeight}, #{hipWidth}, #{hipCrossHeight}, + #{monthAge}, + #{breastDepth}, + #{breastPosition}, + #{breastLength}, + #{breastAdbere}, + #{breastSpacing}, + #{breastScore}, + #{bodyScore}, + #{lactationDay}, + #{gestationDay}, + #{postMatingDay}, #{comment}, #{technician}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, @@ -188,6 +236,17 @@ current_weight = #{currentWeight}, hip_width = #{hipWidth}, hip_cross_height = #{hipCrossHeight}, + month_age = #{monthAge}, + breast_depth = #{breastDepth}, + breast_position = #{breastPosition}, + breast_length = #{breastLength}, + breast_adbere = #{breastAdbere}, + breast_spacing = #{breastSpacing}, + breast_score = #{breastScore}, + body_score = #{bodyScore}, + lactation_day = #{lactationDay}, + gestation_day = #{gestationDay}, + post_mating_day = #{postMatingDay}, comment = #{comment}, technician = #{technician}, create_by = #{createBy}, @@ -208,11 +267,12 @@ #{id} + diff --git a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml index 6dc816f..6500661 100644 --- a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml @@ -24,10 +24,12 @@ select sbs.id, sbs.sheep_id, + sbs.user_id, + sbs.dept_id, bs.manage_tags, - bsv.id as varietyId, - bsv.variety as varietyName, - '体况评分' as event_type, + bsv.id as varietyId, + bsv.variety as varietyName, + '体况评分' as event_type, sbs.datetime, sbs.score, ds.sheepfold_name as sheepfoldName, @@ -62,6 +64,10 @@ and bs.is_delete = #{sc.isDelete} + + and sbs.technician like concat('%', #{sc.technician}, '%') + + ${sc.params.dataScope} ORDER BY sbs.create_time DESC @@ -82,6 +88,8 @@ technician, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -92,6 +100,8 @@ #{technician}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, @@ -129,6 +139,5 @@ WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 ORDER BY bs.manage_tags - LIMIT 50 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml index b674066..44b9222 100644 --- a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml @@ -24,11 +24,15 @@ + + 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 @@ and bs.is_delete = #{sc.isDelete} + + and sbr.technician = #{sc.technician} + + + and sbr.score = #{sc.score} + + ${sc.params.dataScope} ORDER BY sbr.create_time DESC @@ -84,6 +95,8 @@ technician, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -98,6 +111,8 @@ #{technician}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, @@ -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 + + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml index 6c0b7b9..514e9a4 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml @@ -25,18 +25,40 @@ + + - - + AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%') @@ -50,6 +72,7 @@ AND sas.type_id = #{typeId} + ${params.dataScope} @@ -61,12 +84,46 @@ 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}) + + ear_number, + sheepfold, + ranch_id, + father, + mother, + born_weight, + birthday, + gender, + parity, + variety_id, + type_id, + join_date, + comment, + technician, + create_by, + create_time, + user_id, + dept_id, + + + #{earNumber}, + #{sheepfold}, + #{ranchId}, + #{father}, + #{mother}, + #{bornWeight}, + #{birthday}, + #{gender}, + #{parity}, + #{varietyId}, + #{typeId}, + #{joinDate}, + #{comment}, + #{technician}, + #{createBy}, + #{createTime}, + #{userId}, + #{deptId}, + diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml index e2695b3..a574a3e 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml @@ -21,6 +21,8 @@ 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}, '%') - - - + + + and scc.technician like concat('%', #{sc.technician}, '%') @@ -66,6 +68,7 @@ and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY scc.create_time DESC @@ -85,6 +88,8 @@ create_time, event_date, technician, + user_id, + dept_id, #{sheepId}, @@ -94,6 +99,8 @@ #{createTime}, #{eventDate}, #{technician}, + #{userId}, + #{deptId}, @@ -128,6 +135,5 @@ WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 ORDER BY bs.manage_tags - LIMIT 50 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml index 39b26ef..f33c1f7 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml @@ -73,6 +73,7 @@ and bs.is_delete = 1 + ${sc.params.dataScope} ORDER BY sce.create_time DESC @@ -94,6 +95,8 @@ create_time, event_date, technician, + user_id, + dept_id, #{sheepId}, @@ -105,6 +108,8 @@ #{createTime}, #{eventDate}, #{technician}, + #{userId}, + #{deptId}, @@ -141,6 +146,5 @@ WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 ORDER BY bs.manage_tags - LIMIT 50 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml index 9119ca8..c3b9bf4 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml @@ -65,6 +65,7 @@ and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY scv.create_time DESC @@ -83,8 +84,10 @@ comment, create_by, create_time, - technician, - event_date, + technician, + event_date, + user_id, + dept_id, #{sheepId}, @@ -93,8 +96,10 @@ #{comment}, #{createBy}, #{createTime}, - #{technician}, - #{eventDate}, + #{technician}, + #{eventDate}, + #{userId}, + #{deptId}, @@ -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 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml index b74eb91..03cbb40 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml @@ -18,11 +18,15 @@ + + 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 @@ and s.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY tg.create_time DESC @@ -99,6 +102,8 @@ comment, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -112,6 +117,8 @@ #{comment}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml index 79073ae..4b5fcfa 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml @@ -19,12 +19,16 @@ + + 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 @@ and bs.ranch_id = #{sc.currentRanchId} + ${sc.params.dataScope} ORDER BY t.create_time DESC @@ -101,6 +106,8 @@ comment, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -115,6 +122,8 @@ #{comment}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, @@ -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 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml b/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml index 92dfb96..66d31e2 100644 --- a/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml @@ -50,7 +50,9 @@ and bs.sheepfold_id = #{sc.sheepfold} and bs.variety_id = #{sc.varietyId} - and sc.technician like concat('%', #{sc.technician}, '%') + + and sc.technician like concat('%', #{sc.technician}, '%') + and sc.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} @@ -60,6 +62,7 @@ and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY sc.create_time DESC @@ -80,6 +83,8 @@ create_by, create_time, event_date, + user_id, + dept_id, #{sheepId}, @@ -90,6 +95,8 @@ #{createBy}, #{createTime}, #{eventDate}, + #{userId}, + #{deptId}, @@ -126,6 +133,5 @@ WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 ORDER BY bs.manage_tags - LIMIT 50 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/other/ScFixHoofMapper.xml b/zhyc-module/src/main/resources/mapper/produce/other/ScFixHoofMapper.xml index cb31739..6622a68 100644 --- a/zhyc-module/src/main/resources/mapper/produce/other/ScFixHoofMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/other/ScFixHoofMapper.xml @@ -59,6 +59,7 @@ and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY fh.create_time DESC @@ -68,26 +69,32 @@ where fh.id = #{id} - - INSERT INTO sc_fix_hoof - (sheep_id, - sheepfold, - variety_id, - comment, - technician, - event_date, - create_by, - create_time) - VALUES - (#{sheepId}, - #{sheepfold}, - #{varietyId}, - #{comment}, - #{technician}, - #{eventDate}, - #{createBy}, - #{createTime}) + + insert into sc_fix_hoof + + sheep_id, + sheepfold, + variety_id, + comment, + technician, + event_date, + create_by, + create_time, + user_id, + dept_id, + + + #{sheepId}, + #{sheepfold}, + #{varietyId}, + #{comment}, + #{technician}, + #{eventDate}, + #{createBy}, + #{createTime}, + #{userId}, + #{deptId}, +