Compare commits

..

2 Commits

Author SHA1 Message Date
3bff858643 feat(sys | login): 多租户模式支持
+ 两个业务通过用户ID分配数据源
2026-01-28 13:07:58 +08:00
9c678c84bf refactor(Druid - DataSource): 系统表与业务表分库读写 | 支持动态数据源切换
+ 使用AbstractRoutingDataSource实现动态数据源
+ 数据库 sys 与 业务表划分为两部分独立数据库以实现多数据分区
+ 添加过滤器在请求时识别请求类型通过determineCurrentLookupKey决定最终数据源
+ ContextHolder 存储数据源标识确保全局统一
+ 修改了FeedList模块的缓存初始化时机确保在第一次请求时初始化而非构造时
2026-01-28 13:07:58 +08:00
211 changed files with 2836 additions and 6751 deletions

View File

@@ -0,0 +1,24 @@
package com.zhyc.Event;
import lombok.Data;
@Data
public class FarmLoginEvent {
private final String farmCode;
private final Long userId;
public FarmLoginEvent(String farmCode, Long userId) {
this.farmCode = farmCode;
this.userId = userId;
}
public String getFarmCode() {
return farmCode;
}
public Long getUserId() {
return userId;
}
}

View File

@@ -0,0 +1,49 @@
package com.zhyc.Routing.Filter;
import com.zhyc.framework.config.routing.DataSourceKeys;
import com.zhyc.framework.datasource.DynamicDataSourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.bytedeco.opencv.presets.opencv_core;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
@Slf4j
@Order(value = -100)
public class DataSourceRoutingFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
String uri = request.getRequestURI();
String username = request.getRemoteUser();
log.debug("username:{}",username);
try {
if (uri.startsWith("/app") || uri.startsWith("/base") || uri.startsWith("/biosafety") || uri.startsWith("/common")
|| uri.startsWith("/dairyProducts") || uri.startsWith("/enums") || uri.startsWith("/feed") || uri.startsWith("/frozen") || uri.startsWith("/produce")
|| uri.startsWith("sale") || uri.startsWith("/stock") || uri.startsWith("/work") || uri.startsWith("/sheepfold_management")) {
log.debug("业务请求 : BUSINESS : {}", uri);
if (username.equals("admin")) {
DynamicDataSourceContextHolder.setDataSourceType(DataSourceKeys.FARM_1);
}else if (username.equals("ry")) {
DynamicDataSourceContextHolder.setDataSourceType(DataSourceKeys.FARM_2);
}
} else {
log.debug("系统请求 SYSTEM : {}", uri);
DynamicDataSourceContextHolder.setDataSourceType(DataSourceKeys.SYSTEM);
}
filterChain.doFilter(request, response);
} finally {
// 业务结束后清楚数据源-防止线程复用导致错误
DynamicDataSourceContextHolder.clearDataSourceType();
}
}
}

View File

@@ -76,9 +76,6 @@ public class SysDeptController extends BaseController
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept)
{
if (!deptService.checkRanchName(dept)){
return error("新增部门'" + dept.getDeptName() + "'失败,牧场名称已存在");
}
if (!deptService.checkDeptNameUnique(dept))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");

View File

@@ -0,0 +1,17 @@
package com.zhyc.web.mvc;
import com.zhyc.Routing.Filter.DataSourceRoutingFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MvcConfig {
@Bean
public FilterRegistrationBean<DataSourceRoutingFilter> myFilter() {
FilterRegistrationBean<DataSourceRoutingFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new DataSourceRoutingFilter());
registrationBean.addUrlPatterns("/*");
return registrationBean;
}
}

View File

@@ -9,16 +9,19 @@ spring:
# url: jdbc:mysql://localhost:3306/zhyc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: 123456
url: jdbc:mysql://118.182.97.76:3306/zhyc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://118.182.97.76:3306/zhyc_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: zhyc
password: yszh123
# 从库数据源
slave:
farm01:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
url: jdbc:mysql://118.182.97.76:3306/zhyc_sheep01?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: zhyc
password: yszh123
farm02:
url: jdbc:mysql://118.182.97.76:3306/zhyc_sheep02?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: zhyc
password: yszh123
# 初始连接数
initialSize: 5
# 最小连接池数量

View File

@@ -11,7 +11,7 @@ import java.lang.annotation.Target;
*
* @author ruoyi
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DataScope

View File

@@ -31,10 +31,6 @@ public class SysDept extends BaseEntity
/** 部门名称 */
private String deptName;
/** 牧场id */
private Long ranchId;
private String ranchName;
/** 显示顺序 */
private Integer orderNum;
@@ -59,22 +55,6 @@ public class SysDept extends BaseEntity
/** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>();
public String getRanchName() {
return ranchName;
}
public void setRanchName(String ranchName) {
this.ranchName = ranchName;
}
public Long getRanchId() {
return ranchId;
}
public void setRanchId(Long ranchId) {
this.ranchId = ranchId;
}
public Long getDeptId()
{
return deptId;

View File

@@ -1,36 +0,0 @@
package com.zhyc.common.core.domain.entity;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 牧场管理对象 da_ranch
*
* @author ruoyi
* @date 2025-07-22
*/
public class SysRanch extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 牧场名称 */
private String ranch;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRanch() {
return ranch;
}
public void setRanch(String ranch) {
this.ranch = ranch;
}
}

View File

@@ -9,6 +9,8 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -19,23 +21,34 @@ import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
import com.alibaba.druid.util.Utils;
import com.zhyc.common.enums.DataSourceType;
import com.zhyc.common.utils.spring.SpringUtils;
import com.zhyc.framework.config.properties.DruidProperties;
import com.zhyc.framework.datasource.DynamicDataSource;
/**
* druid 配置多数据源
*
*
* @author ruoyi
*/
@Configuration
public class DruidConfig
{
public class DruidConfig {
@Bean
@ConfigurationProperties("spring.datasource.druid.master")
public DataSource masterDataSource(DruidProperties druidProperties)
{
public DataSource masterDataSource(DruidProperties druidProperties) {
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@Bean
@ConfigurationProperties("spring.datasource.druid.farm01")
public DataSource farm1DataSource(DruidProperties druidProperties) {
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@Bean
@ConfigurationProperties("spring.datasource.druid.farm02")
public DataSource farm2DataSource(DruidProperties druidProperties) {
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@@ -43,49 +56,49 @@ public class DruidConfig
@Bean
@ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
public DataSource slaveDataSource(DruidProperties druidProperties)
{
public DataSource slaveDataSource(DruidProperties druidProperties) {
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@Bean(name = "dynamicDataSource")
@Primary
public DynamicDataSource dataSource(DataSource masterDataSource)
{
public DataSource dynamicDataSource(
@Qualifier("masterDataSource") DataSource systemDataSource,
@Qualifier("farm1DataSource") DataSource farm1DataSource,
@Qualifier("farm2DataSource") DataSource farm2DataSource) {
// 存储数据源路由
Map<Object, Object> targetDataSources = new HashMap<>();
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
return new DynamicDataSource(masterDataSource, targetDataSources);
targetDataSources.put("system", systemDataSource);
targetDataSources.put("farm01", farm1DataSource);
targetDataSources.put("farm02", farm2DataSource);
return new DynamicDataSource(systemDataSource, targetDataSources);
}
/**
* 设置数据源
*
*
* @param targetDataSources 备选数据源集合
* @param sourceName 数据源名称
* @param beanName bean名称
* @param sourceName 数据源名称
* @param beanName bean名称
*/
public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName)
{
try
{
public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName) {
try {
DataSource dataSource = SpringUtils.getBean(beanName);
targetDataSources.put(sourceName, dataSource);
}
catch (Exception e)
{
} catch (Exception e) {
}
}
/**
* 去除监控页面底部的广告
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Bean
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties)
{
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) {
// 获取web监控页面的参数
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
// 提取common.js的配置路径
@@ -93,16 +106,14 @@ public class DruidConfig
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
final String filePath = "support/http/resources/js/common.js";
// 创建filter进行过滤
Filter filter = new Filter()
{
Filter filter = new Filter() {
@Override
public void init(javax.servlet.FilterConfig filterConfig) throws ServletException
{
public void init(javax.servlet.FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
throws IOException, ServletException {
chain.doFilter(request, response);
// 重置缓冲区,响应头不会被重置
response.resetBuffer();
@@ -113,9 +124,9 @@ public class DruidConfig
text = text.replaceAll("powered.*?shrek.wang</a>", "");
response.getWriter().write(text);
}
@Override
public void destroy()
{
public void destroy() {
}
};
FilterRegistrationBean registrationBean = new FilterRegistrationBean();

View File

@@ -0,0 +1,8 @@
package com.zhyc.framework.config.routing;
public interface DataSourceKeys {
String SYSTEM = "system";
String FARM_1 = "farm01";
String FARM_2 = "farm02";
}

View File

@@ -1,6 +1,8 @@
package com.zhyc.framework.web.service;
import javax.annotation.Resource;
import com.zhyc.framework.datasource.DynamicDataSourceContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;

View File

@@ -201,10 +201,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -1,7 +1,9 @@
package com.zhyc.module.base.controller;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.base.domain.BasSheep;
@@ -44,7 +46,6 @@ public class BasSheepController extends BaseController {
return getDataTable(list);
}
//查询耳号列表
@GetMapping("/earNumbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
try {
@@ -108,61 +109,20 @@ public class BasSheepController extends BaseController {
}
/**
* 批量查询羊只耳号状态
* 根据耳号查询
*/
@GetMapping("/byManageTags/{manageTags}")
public AjaxResult byManageTags(@PathVariable String manageTags) {
if (manageTags == null || manageTags.trim().isEmpty()) {
return error("管理耳号不能为空");
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
if (sheep == null) {
return error("未找到对应的羊只");
}
// 批量查询模式 - 使用空格或逗号分割
String[] tags = manageTags.split("[\\s,]+");
// 补品种名称
BasSheepVariety variety = basSheepVarietyService.selectBasSheepVarietyById(sheep.getVarietyId());
sheep.setVarietyName(variety == null ? "" : variety.getVariety());
try {
// 过滤掉空值并去重
List<String> validTags = Arrays.stream(tags)
.map(String::trim)
.filter(tag -> !tag.isEmpty())
.distinct()
.collect(Collectors.toList());
if (validTags.isEmpty()) {
return error("有效的耳号不能为空");
}
// 查询所有存在的羊只
List<BasSheep> existingSheep = basSheepService.selectBasSheepByManageTagsList(validTags);
Set<String> existingTagSet = existingSheep.stream()
.map(BasSheep::getManageTags)
.collect(Collectors.toSet());
// 分别统计在羊群和不在羊群的耳号
List<String> inHerd = new ArrayList<>();
List<String> notInHerd = new ArrayList<>();
for (String tag : validTags) {
if (existingTagSet.contains(tag)) {
inHerd.add(tag);
} else {
notInHerd.add(tag);
}
}
Map<String, Object> result = new HashMap<>();
result.put("inHerd", inHerd);
result.put("notInHerd", notInHerd);
result.put("total", validTags.size());
result.put("inHerdCount", inHerd.size());
result.put("notInHerdCount", notInHerd.size());
result.put("sheepDetails", existingSheep);
return success(result);
} catch (Exception e) {
logger.error("批量查询羊只状态异常", e);
return error("批量查询失败:" + e.getMessage());
}
return success(sheep);
}
/**
@@ -176,6 +136,7 @@ public class BasSheepController extends BaseController {
}
BasSheep query = new BasSheep();
query.setTypeId(typeId.longValue());
startPage();
List<BasSheep> list = basSheepService.selectBasSheepList(query);
return getDataTable(list);
}
@@ -192,6 +153,7 @@ public class BasSheepController extends BaseController {
BasSheep query = new BasSheep();
query.setSheepfoldId(sheepfoldId.longValue());
query.setTypeId(typeId.longValue());
startPage();
List<BasSheep> list = basSheepService.selectBasSheepList(query);
return getDataTable(list);
}
@@ -228,6 +190,7 @@ public class BasSheepController extends BaseController {
return success(result);
}
/**
* 判断耳号是否存在(用于新增羊只时校验)
*/

View File

@@ -77,7 +77,7 @@ public class DaRanchController extends BaseController
/**
* 获取指定牧场下的所有羊只耳号
*/
@GetMapping("/getSheepByRanchId/{ranchId}")
// @GetMapping("/getSheepByRanchId/{ranchId}")
public AjaxResult getSheepByRanchId(@PathVariable Long ranchId) {
List<BasSheep> sheepList = basSheepService.getSheepByRanchId(ranchId);
return AjaxResult.success(sheepList);

View File

@@ -8,7 +8,6 @@ import com.zhyc.common.enums.BusinessType;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.DaSheepfold;
import com.zhyc.module.base.domain.DaSheepfoldSummaryExportVO;
import com.zhyc.module.base.service.IDaSheepfoldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -45,17 +44,6 @@ public class DaSheepfoldController extends BaseController
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldList(daSheepfold);
return getDataTable(list);
}
/**
* 主表格:羊舍级别汇总列表
*/
@GetMapping("/summaryList")
public TableDataInfo summaryList(DaSheepfold daSheepfold) {
startPage();
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldSummaryList(daSheepfold);
return getDataTable(list);
}
/*
* 根据羊舍ids查询羊只id
* */
@@ -81,73 +69,6 @@ public class DaSheepfoldController extends BaseController
util.exportExcel(response, list, "羊舍管理数据");
}
/**
* 导出羊舍管理汇总列表(主表格数据)- 新增方法
*/
@PreAuthorize("@ss.hasPermi('sheepfold_management:sheepfold_management:export')")
@Log(title = "羊舍管理汇总导出", businessType = BusinessType.EXPORT)
@PostMapping("/exportSummary")
public void exportSummary(HttpServletResponse response, DaSheepfold daSheepfold) {
// 1. 查询汇总数据
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldSummaryList(daSheepfold);
// 2. 转换为导出VO
List<DaSheepfoldSummaryExportVO> exportList = convertToExportVO(list);
// 3. 使用VO类导出Excel
ExcelUtil<DaSheepfoldSummaryExportVO> util = new ExcelUtil<>(DaSheepfoldSummaryExportVO.class);
util.exportExcel(response, exportList, "羊舍管理汇总数据");
}
/**
* 将DaSheepfold列表转换为导出VO列表
*/
private List<DaSheepfoldSummaryExportVO> convertToExportVO(List<DaSheepfold> daSheepfoldList) {
List<DaSheepfoldSummaryExportVO> voList = new ArrayList<>();
for (DaSheepfold entity : daSheepfoldList) {
DaSheepfoldSummaryExportVO vo = new DaSheepfoldSummaryExportVO();
// 字典翻译牧场ID -> 牧场名称
if (entity.getRanchId() != null) {
String ranchName = DictUtils.getDictLabel("da_ranch", entity.getRanchId().toString());
vo.setRanchName(ranchName != null ? ranchName : entity.getRanchId().toString());
} else {
vo.setRanchName("");
}
// 使用汇总查询中的羊舍名称
vo.setSheepfoldName(entity.getSheepfoldName() != null ? entity.getSheepfoldName() : "");
// 字典翻译羊舍类型ID -> 羊舍类型名称
if (entity.getSheepfoldTypeId() != null) {
String typeName = DictUtils.getDictLabel("bas_sheepfold_type", entity.getSheepfoldTypeId().toString());
vo.setSheepfoldTypeName(typeName != null ? typeName : entity.getSheepfoldTypeId().toString());
} else {
vo.setSheepfoldTypeName("");
}
// 羊舍编号
vo.setSheepfoldNo(entity.getSheepfoldNo() != null ? entity.getSheepfoldNo() : "");
// 羊数(确保不为空)
vo.setTotalSheepCount(entity.getTotalSheepCount() != null ? entity.getTotalSheepCount() : 0);
// 备注
vo.setComment(entity.getComment() != null ? entity.getComment() : "");
voList.add(vo);
}
return voList;
}
/**
* 获取羊舍管理详细信息
*/
@@ -180,74 +101,16 @@ public class DaSheepfoldController extends BaseController
return toAjax(daSheepfoldService.updateDaSheepfold(daSheepfold));
}
// /**
// * 删除羊舍管理
// */
// @PreAuthorize("@ss.hasPermi('sheepfold_management:sheepfold_management:remove')")
// @Log(title = "羊舍管理", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// public AjaxResult remove(@PathVariable Long[] ids)
// {
// return toAjax(daSheepfoldService.deleteDaSheepfoldByIds(ids));
// }
/**
* 修改后:根据组合条件删除羊圈信息(单条)
* 接收ranch_id/sheepfold_no/sheepfold_type_id/sheepfold_name组合条件
* 删除羊舍管理
*/
@PreAuthorize("@ss.hasPermi('sheep:sheepfold:remove')")
@DeleteMapping("/deleteByCondition")
public AjaxResult removeByCondition(@RequestBody DaSheepfold sheepfold) {
// 1. 校验核心条件非空(避免条件缺失导致误删)
if (sheepfold.getRanchId() == null
|| sheepfold.getSheepfoldNo() == null || sheepfold.getSheepfoldNo().isEmpty()
|| sheepfold.getSheepfoldTypeId() == null) {
return AjaxResult.error("删除失败核心条件牧场ID/羊圈编号/羊圈类型ID不能为空");
}
// 2. 调用Service执行组合条件删除
boolean deleteResult = daSheepfoldService.deleteSheepfoldByCondition(sheepfold);
if (deleteResult) {
return AjaxResult.success("删除成功");
} else {
return AjaxResult.error("删除失败:未找到匹配条件的记录");
}
@PreAuthorize("@ss.hasPermi('sheepfold_management:sheepfold_management:remove')")
@Log(title = "羊舍管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(daSheepfoldService.deleteDaSheepfoldByIds(ids));
}
/**
* 【扩展】批量删除:接收多条组合条件数据,循环删除
*/
@PreAuthorize("@ss.hasPermi('sheep:sheepfold:remove')")
@DeleteMapping("/batchDeleteByCondition")
public AjaxResult batchRemoveByCondition(@RequestBody List<DaSheepfold> sheepfoldList) {
if (sheepfoldList == null || sheepfoldList.isEmpty()) {
return AjaxResult.error("删除失败:请选择要删除的羊圈数据");
}
// 统计成功删除的数量
int successCount = 0;
for (DaSheepfold sheepfold : sheepfoldList) {
// 跳过条件不全的记录
if (sheepfold.getRanchId() == null
|| sheepfold.getSheepfoldNo() == null || sheepfold.getSheepfoldNo().isEmpty()
|| sheepfold.getSheepfoldTypeId() == null) {
continue;
}
if (daSheepfoldService.deleteSheepfoldByCondition(sheepfold)) {
successCount++;
}
}
if (successCount == 0) {
return AjaxResult.error("批量删除失败:无符合条件的记录可删除");
} else {
return AjaxResult.success("批量删除成功,共删除" + successCount + "条记录");
}
}
/**
* 检查羊舍编号是否已存在
*/

View File

@@ -10,18 +10,23 @@ import com.zhyc.common.enums.BusinessType;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.module.base.domain.SheepFile;
import com.zhyc.module.base.service.ISheepFileService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
/**
* 羊只档案Controller
* * @author wyt
*
* @author wyt
* @date 2025-07-13
*/
@RestController
@@ -47,7 +52,7 @@ public class SheepFileController extends BaseController
Integer pageSize = 10;
if (queryParams != null && !queryParams.isEmpty()) {
// ------------------ 1. 处理分页参数 ------------------
// 提取分页参数
if (queryParams.containsKey("pageNum") && queryParams.get("pageNum") != null) {
try {
pageNum = Integer.parseInt(queryParams.get("pageNum").toString());
@@ -55,6 +60,7 @@ public class SheepFileController extends BaseController
// 使用默认值
}
} else if (queryParams.containsKey("page") && queryParams.get("page") != null) {
// 如果 pageNum 不存在,则尝试使用 page
try {
pageNum = Integer.parseInt(queryParams.get("page").toString());
} catch (NumberFormatException e) {
@@ -62,13 +68,15 @@ public class SheepFileController extends BaseController
}
}
if (queryParams.containsKey("pageSize") && queryParams.get("pageSize") != null) {
try {
pageSize = Integer.parseInt(queryParams.get("pageSize").toString());
} catch (NumberFormatException e) {
// 使用默认值
}
} else if (queryParams.containsKey("limit") && queryParams.get("limit") != null) {
}else if (queryParams.containsKey("limit") && queryParams.get("limit") != null) {
// 如果 pageSize 不存在,则尝试使用 limit
try {
pageSize = Integer.parseInt(queryParams.get("limit").toString());
} catch (NumberFormatException e) {
@@ -76,25 +84,7 @@ public class SheepFileController extends BaseController
}
}
// ------------------ 2. 核心修复:处理 List 多选参数 ------------------
// 使用 parseList 方法兼容处理 List、Array、逗号分隔字符串
sheepFile.setAllEarNumbers(parseList(queryParams.get("allEarNumbers")));
sheepFile.setAllEleEarNumbers(parseList(queryParams.get("allEleEarNumbers")));
sheepFile.setAllBreedingStatus(parseList(queryParams.get("allBreedingStatus")));
sheepFile.setAllSheepTypes(parseList(queryParams.get("allSheepTypes")));
// 性别处理 (需要将 String/Integer 转为 Long)
List<String> genderStrs = parseList(queryParams.get("allGenders"));
if (genderStrs != null && !genderStrs.isEmpty()) {
List<Long> genderLongs = new ArrayList<>();
for (String s : genderStrs) {
Long v = convertToLong(s);
if(v != null) genderLongs.add(v);
}
sheepFile.setAllGenders(genderLongs);
}
// ------------------ 3. 处理常规单值参数 ------------------
// 提取常规查询参数到 SheepFile 对象
if (queryParams.containsKey("bsManageTags") && queryParams.get("bsManageTags") != null) {
sheepFile.setBsManageTags(queryParams.get("bsManageTags").toString());
}
@@ -120,17 +110,23 @@ public class SheepFileController extends BaseController
sheepFile.setBreed(queryParams.get("breed").toString());
}
// ------------------ 4. 提取自定义参数 (排除已处理的键) ------------------
// 定义需要跳过的key防止重复处理
Set<String> processedKeys = new HashSet<>(Arrays.asList(
"pageNum", "pageSize", "page", "limit",
"bsManageTags", "electronicTags", "drRanch", "variety", "name", "gender", "statusId", "breed",
"allEarNumbers", "allEleEarNumbers", "allGenders", "allBreedingStatus", "allSheepTypes"
));
// 除已处理的参数,剩下的作为自定义筛选参数
for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
if (!processedKeys.contains(entry.getKey()) && entry.getValue() != null) {
customParams.put(entry.getKey(), entry.getValue());
String key = entry.getKey();
Object value = entry.getValue();
// 跳过常规参数和分页参数
if ("bsManageTags".equals(key) || "electronicTags".equals(key) ||
"drRanch".equals(key) || "variety".equals(key) ||
"name".equals(key) || "gender".equals(key) ||
"statusId".equals(key) || "breed".equals(key) ||
"pageNum".equals(key) || "pageSize".equals(key)) {
continue;
}
// 添加到自定义参数中
if (value != null) {
customParams.put(key, value);
}
}
}
@@ -143,41 +139,6 @@ public class SheepFileController extends BaseController
return getDataTable(list);
}
/**
* 辅助方法:统一解析各种格式的数组参数
* 支持List, String[] (数组), Object[] (数组), "A,B" (逗号分隔字符串)
*/
private List<String> parseList(Object obj) {
if (obj == null) return null;
List<String> result = new ArrayList<>();
if (obj instanceof List) {
// JSON 传来的通常是 List
for (Object o : (List<?>) obj) {
if (o != null) result.add(o.toString());
}
} else if (obj.getClass().isArray()) {
// 如果是数组
if (obj instanceof Object[]) {
for (Object o : (Object[]) obj) {
if (o != null) result.add(o.toString());
}
} else if (obj instanceof String[]) {
Collections.addAll(result, (String[]) obj);
}
} else if (obj instanceof String) {
// 如果是逗号分隔字符串
String s = (String) obj;
if (StringUtils.isNotBlank(s)) {
String[] split = s.split(",");
Collections.addAll(result, split);
}
}
return result.isEmpty() ? null : result;
}
/**
* 转换对象为Long类型
*/
@@ -225,7 +186,6 @@ public class SheepFileController extends BaseController
// 使用若依框架的工具方法处理参数
switch (key) {
// --- 单值参数 ---
case "bsManageTags":
sheepFile.setBsManageTags(convertToString(value));
break;
@@ -250,30 +210,6 @@ public class SheepFileController extends BaseController
case "breed":
sheepFile.setBreed(convertToString(value));
break;
// --- 新增:处理多选数组参数 ---
// request.getParameterMap 中的值本身就是 String[],可以直接使用
case "allEarNumbers":
sheepFile.setAllEarNumbers(new ArrayList<>(Arrays.asList(values)));
break;
case "allEleEarNumbers":
sheepFile.setAllEleEarNumbers(new ArrayList<>(Arrays.asList(values)));
break;
case "allBreedingStatus":
sheepFile.setAllBreedingStatus(new ArrayList<>(Arrays.asList(values)));
break;
case "allSheepTypes":
sheepFile.setAllSheepTypes(new ArrayList<>(Arrays.asList(values)));
break;
case "allGenders":
List<Long> genderList = new ArrayList<>();
for(String v : values){
Long l = Convert.toLong(v);
if(l != null) genderList.add(l);
}
sheepFile.setAllGenders(genderList);
break;
case "pageNum":
case "pageSize":
// 忽略分页参数
@@ -294,14 +230,6 @@ public class SheepFileController extends BaseController
util.exportExcel(response, list, "羊只档案数据");
}
/**
* 新增:模糊搜索耳号接口 (用于前端下拉框远程搜索)
*/
@GetMapping("/searchEarNumbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query)
{
return success(sheepFileService.searchEarNumbers(query));
}
/**
* 字符串转换工具方法
@@ -324,14 +252,15 @@ public class SheepFileController extends BaseController
}
/*
* 根据耳号查询是否存在羊舍
* */
* 根据耳号查询是否存在羊舍
* */
@GetMapping("/byNo/{manageTags}")
public AjaxResult byManageTags(@PathVariable String manageTags){
SheepFile sheep=sheepFileService.selectBasSheepByManageTags(manageTags.trim());
return success(sheep);
}
@GetMapping("/stat/sheepType")
public AjaxResult statSheepType() {
return success(sheepFileService.countBySheepType());
@@ -360,18 +289,43 @@ public class SheepFileController extends BaseController
/**
* 新增API获取字段的唯一值列表
*
* 这个API为前端自定义筛选功能提供数据支持
* 当用户选择某个字段进行筛选时,前端调用此接口获取该字段的所有可能值
*
* @param fieldName 字段名(数据库列名)
* @return AjaxResult 包含字段值列表的响应结果
*
* 接口地址GET /sheep_file/sheep_file/field/{fieldName}
*
* 使用示例:
* 前端请求GET /sheep_file/sheep_file/field/bs_manage_tags
* 后端返回:{ "code": 200, "msg": "操作成功", "data": ["AF00001", "AF00002", "AF00003"] }
*
* 安全说明:
* - 使用白名单机制防止SQL注入
* - 只有预定义的字段名可以被查询
*/
@GetMapping("/field/{fieldName}")
public AjaxResult getFieldValues(@PathVariable String fieldName) {
try {
// 调用Service层获取字段唯一值
List<String> fieldValues = sheepFileService.getFieldValues(fieldName);
// 返回成功响应,包含字段值列表
return AjaxResult.success("获取字段值成功", fieldValues);
} catch (IllegalArgumentException e) {
// 处理字段名不合法的异常
// 这种情况通常是因为前端传入了不在白名单中的字段名
return AjaxResult.error("请求的字段名不合法: " + e.getMessage());
} catch (Exception e) {
// 处理其他未知异常
// 记录日志并返回友好的错误信息
logger.error("获取字段值失败,字段名: " + fieldName, e);
return AjaxResult.error("系统错误,获取字段值失败");
}
}
}
}

View File

@@ -1,110 +0,0 @@
package com.zhyc.module.base.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.base.util.SheepPedigreeExcelUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.base.domain.SheepPedigree;
import com.zhyc.module.base.service.ISheepPedigreeService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;
/**
* VIEWController
*
* @author ruoyi
* @date 2026-02-04
*/
@RestController
@RequestMapping("/system/pedigree")
public class SheepPedigreeController extends BaseController
{
@Autowired
private ISheepPedigreeService sheepPedigreeService;
/**
* 查询VIEW列表
*/
@PreAuthorize("@ss.hasPermi('system:pedigree:list')")
@GetMapping("/list")
public TableDataInfo list(SheepPedigree sheepPedigree)
{
startPage();
List<SheepPedigree> list = sheepPedigreeService.selectSheepPedigreeList(sheepPedigree);
return getDataTable(list);
}
/**
* 导出VIEW列表
*/
// 在Controller/Service中注入工具类
@Autowired
private SheepPedigreeExcelUtils sheepPedigreeExcelUtils;
@PreAuthorize("@ss.hasPermi('system:pedigree:export')")
@Log(title = "VIEW", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SheepPedigree sheepPedigree) throws Exception {
List<SheepPedigree> dataList = sheepPedigreeService.selectSheepPedigreeList(sheepPedigree);
// 调用实例方法(而非静态方法)
sheepPedigreeExcelUtils.export(response, dataList);
}
/**
* 获取VIEW详细信息
*/
@PreAuthorize("@ss.hasPermi('system:pedigree:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(sheepPedigreeService.selectSheepPedigreeById(id));
}
/**
* 新增VIEW
*/
@PreAuthorize("@ss.hasPermi('system:pedigree:add')")
@Log(title = "VIEW", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SheepPedigree sheepPedigree)
{
return toAjax(sheepPedigreeService.insertSheepPedigree(sheepPedigree));
}
/**
* 修改VIEW
*/
@PreAuthorize("@ss.hasPermi('system:pedigree:edit')")
@Log(title = "VIEW", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SheepPedigree sheepPedigree)
{
return toAjax(sheepPedigreeService.updateSheepPedigree(sheepPedigree));
}
/**
* 删除VIEW
*/
@PreAuthorize("@ss.hasPermi('system:pedigree:remove')")
@Log(title = "VIEW", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sheepPedigreeService.deleteSheepPedigreeByIds(ids));
}
}

View File

@@ -115,10 +115,5 @@ public class DaSheepfold extends BaseEntity
@Excel(name = "备注")
private String comment;
// 非数据库字段:单栏位羊数(子表格用)
private Integer sheepCount;
// 非数据库字段:羊舍总羊数(主表格用)
private Integer totalSheepCount;
}

View File

@@ -1,55 +0,0 @@
package com.zhyc.module.base.domain;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 羊舍汇总导出VO
*/
@Data
public class DaSheepfoldSummaryExportVO {
/** 牧场名称 */
@Excel(name = "牧场")
private String ranchName;
/** 羊舍名称 */
@Excel(name = "羊舍名称")
private String sheepfoldName;
/** 羊舍类型名称 */
@Excel(name = "羊舍类型")
private String sheepfoldTypeName;
/** 羊舍编号 */
@Excel(name = "羊舍编号")
private String sheepfoldNo;
/** 羊舍总羊数 */
@Excel(name = "羊数")
private Integer totalSheepCount;
/** 备注 */
@Excel(name = "备注")
private String comment;
// 构造函数
public DaSheepfoldSummaryExportVO() {
}
public DaSheepfoldSummaryExportVO(String ranchName, String sheepfoldName,
String sheepfoldTypeName, String sheepfoldNo,
Integer totalSheepCount, String comment) {
this.ranchName = ranchName;
this.sheepfoldName = sheepfoldName;
this.sheepfoldTypeName = sheepfoldTypeName;
this.sheepfoldNo = sheepfoldNo;
this.totalSheepCount = totalSheepCount;
this.comment = comment;
}
}

View File

@@ -1,28 +0,0 @@
// 创建文件ExportConfig.java
package com.zhyc.module.base.domain;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* 导出配置类
*/
@Data
public class ExportConfig {
/**
* 要导出的列名列表(前端传递的驼峰命名)
*/
private List<String> columnNames;
/**
* 查询条件
*/
private Map<String, Object> queryParams;
/**
* 自定义筛选条件
*/
private Map<String, Object> customFilterParams;
}

View File

@@ -8,11 +8,11 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* 羊只档案对象 sheep_file
* * @author wyt
*
* @author wyt
* @date 2025-07-13
*/
@Data
@@ -29,10 +29,6 @@ public class SheepFile extends BaseEntity
@Excel(name = "管理耳号")
private String bsManageTags;
/** ================= 新增:多选查询字段 ================= */
/** 耳号集合(多选/模糊查询用) */
private List<String> allEarNumbers;
/** 牧场id */
// @Excel(name = "牧场id")
private Long ranchId;
@@ -53,10 +49,6 @@ public class SheepFile extends BaseEntity
@Excel(name = "电子耳号")
private String electronicTags;
/** ================= 新增:多选查询字段 ================= */
/** 电子耳号集合(多选查询用) */
private List<String> allEleEarNumbers;
/** 品种id */
// @Excel(name = "品种id")
private Long varietyId;
@@ -73,22 +65,14 @@ public class SheepFile extends BaseEntity
@Excel(name = "羊只类型")
private String name;
/** ================= 新增:多选查询字段 ================= */
/** 羊只类型集合(多选查询用) */
private List<String> allSheepTypes;
// /** 性别 */
//// @Excel(name = "性别")
// private Long gender;
/** 性别 - 使用字典转换 */
@Excel(name = "性别", dictType = "sheep_gender")
@Excel(name = "性别", dictType = "sheep_gender") // 添加 dictType
private Long gender;
/** ================= 新增:多选查询字段 ================= */
/** 性别集合(多选查询用) */
private List<Long> allGenders;
/** 出生日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd")
@@ -119,6 +103,7 @@ public class SheepFile extends BaseEntity
@Excel(name = "羊只状态", dictType = "sheep_status")
private Long statusId;
/** 断奶体重 */
@Excel(name = "断奶体重")
private Double weaningWeight;
@@ -144,10 +129,6 @@ public class SheepFile extends BaseEntity
@Excel(name = "繁殖状态")
private String breed;
/** ================= 新增:多选查询字段 ================= */
/** 繁殖状态集合(多选查询用) */
private List<String> allBreedingStatus;
/** 父号id */
// @Excel(name = "父号id")
private Long bsFatherId;
@@ -319,4 +300,6 @@ public class SheepFile extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date createTime;
}
}

View File

@@ -1,996 +0,0 @@
package com.zhyc.module.base.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
/**
* VIEW对象 sheep_pedigree
*
* @author ruoyi
* @date 2026-02-04
*/
public class SheepPedigree extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 管理耳号 */
@Excel(name = "管理耳号")
private String bsManageTags;
/** 牧场id */
@Excel(name = "牧场id")
private Long ranchId;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String drRanch;
/** 羊舍id */
@Excel(name = "羊舍id")
private Long sheepfoldId;
/** 羊舍名称 */
@Excel(name = "羊舍名称")
private String sheepfoldName;
/** 电子耳号 */
@Excel(name = "电子耳号")
private String electronicTags;
/** 品种id */
@Excel(name = "品种id")
private Long varietyId;
/** 品种 */
@Excel(name = "品种")
private String variety;
/** 家系 */
@Excel(name = "家系")
private String family;
/** 羊只类型 */
@Excel(name = "羊只类型")
private String name;
/** 性别 */
@Excel(name = "性别")
private Long gender;
/** 出生日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long dayAge;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long monthAge;
/** 胎次 */
@Excel(name = "胎次")
private Long parity;
/** 出生体重 */
@Excel(name = "出生体重")
private Long birthWeight;
/** 断奶日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "断奶日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date weaningDate;
/** 羊只状态 */
@Excel(name = "羊只状态")
private Long statusId;
/** 断奶体重 */
@Excel(name = "断奶体重")
private Long weaningWeight;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long weaningDayAge;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private BigDecimal weaningDailyGain;
/** 当前体重 */
@Excel(name = "当前体重")
private Long currentWeight;
/** 繁育状态id */
@Excel(name = "繁育状态id")
private Long breedStatusId;
/** 繁殖状态 */
@Excel(name = "繁殖状态")
private String breed;
/** 父号id */
@Excel(name = "父号id")
private Long bsFatherId;
/** 管理耳号 */
@Excel(name = "管理耳号")
private String fatherManageTags;
/** 母号id */
@Excel(name = "母号id")
private Long bsMotherId;
/** 管理耳号 */
@Excel(name = "管理耳号")
private String motherManageTags;
/** 受体id */
@Excel(name = "受体id")
private Long receptorId;
/** 管理耳号 */
@Excel(name = "管理耳号")
private String receptorManageTags;
/** 父号id */
@Excel(name = "父号id")
private Long fatherFatherId;
/** 管理耳号 */
@Excel(name = "祖父管理耳号")
private String grandfatherManageTags;
/** 母号id */
@Excel(name = "母号id")
private Long fatherMotherId;
/** 管理耳号 */
@Excel(name = "祖母管理耳号")
private String grandmotherManageTags;
/** 父号id */
@Excel(name = "父号id")
private Long fatherId;
/** 管理耳号 */
@Excel(name = "管理耳号")
private String maternalGrandfatherManageTags;
/** 母号id */
@Excel(name = "母号id")
private Long motherId;
/** 管理耳号 */
@Excel(name = "管理耳号")
private String maternalGrandmotherManageTags;
/** 配种日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "配种日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date matingDate;
/** 配种类型 */
@Excel(name = "配种类型")
private Long matingTypeId;
/** 孕检日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "孕检日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date pregDate;
/** 产羔日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "产羔日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date lambingDate;
/** 产羔时怀孕天数 */
@Excel(name = "产羔时怀孕天数")
private Long lambingDay;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long matingDay;
/** 怀孕天数 */
@Excel(name = "怀孕天数")
private Long gestationDay;
/** 预产日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "预产日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date expectedDate;
/** 产后天数 */
@Excel(name = "产后天数")
private Long postLambingDay;
/** 泌乳天数 */
@Excel(name = "泌乳天数")
private Long lactationDay;
/** 空怀天数 */
@Excel(name = "空怀天数")
private Long anestrousDay;
/** 配种次数 */
@Excel(name = "配种次数")
private Long matingCounts;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long matingTotal;
/** 累计流产次数 */
@Excel(name = "累计流产次数")
private Long miscarriageCounts;
/** 备注 */
@Excel(name = "备注")
private String comment;
/** 是否性控 */
@Excel(name = "是否性控")
private Long controlled;
/** 体况评分 */
@Excel(name = "体况评分")
private Long body;
/** 乳房评分 */
@Excel(name = "乳房评分")
private Long breast;
/** 入群来源 */
@Excel(name = "入群来源")
private String source;
/** 入群日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "入群日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date sourceDate;
/** 来源牧场id */
@Excel(name = "来源牧场id")
private Long sourceRanchId;
/** $column.columnComment */
@Excel(name = "来源牧场", readConverterExp = "$column.readConverterExp()")
private String sourceRanch;
/** 是否删除 */
@Excel(name = "是否删除")
private Long isDelete;
/** $column.columnComment */
@Excel(name = "毛色", readConverterExp = "$column.readConverterExp()")
private String sheepColor;
/** $column.columnComment */
@Excel(name = "等级", readConverterExp = "$column.readConverterExp()")
private String groupName;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setBsManageTags(String bsManageTags)
{
this.bsManageTags = bsManageTags;
}
public String getBsManageTags()
{
return bsManageTags;
}
public void setRanchId(Long ranchId)
{
this.ranchId = ranchId;
}
public Long getRanchId()
{
return ranchId;
}
public void setDrRanch(String drRanch)
{
this.drRanch = drRanch;
}
public String getDrRanch()
{
return drRanch;
}
public void setSheepfoldId(Long sheepfoldId)
{
this.sheepfoldId = sheepfoldId;
}
public Long getSheepfoldId()
{
return sheepfoldId;
}
public void setSheepfoldName(String sheepfoldName)
{
this.sheepfoldName = sheepfoldName;
}
public String getSheepfoldName()
{
return sheepfoldName;
}
public void setElectronicTags(String electronicTags)
{
this.electronicTags = electronicTags;
}
public String getElectronicTags()
{
return electronicTags;
}
public void setVarietyId(Long varietyId)
{
this.varietyId = varietyId;
}
public Long getVarietyId()
{
return varietyId;
}
public void setVariety(String variety)
{
this.variety = variety;
}
public String getVariety()
{
return variety;
}
public void setFamily(String family)
{
this.family = family;
}
public String getFamily()
{
return family;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setGender(Long gender)
{
this.gender = gender;
}
public Long getGender()
{
return gender;
}
public void setBirthday(Date birthday)
{
this.birthday = birthday;
}
public Date getBirthday()
{
return birthday;
}
public void setDayAge(Long dayAge)
{
this.dayAge = dayAge;
}
public Long getDayAge()
{
return dayAge;
}
public void setMonthAge(Long monthAge)
{
this.monthAge = monthAge;
}
public Long getMonthAge()
{
return monthAge;
}
public void setParity(Long parity)
{
this.parity = parity;
}
public Long getParity()
{
return parity;
}
public void setBirthWeight(Long birthWeight)
{
this.birthWeight = birthWeight;
}
public Long getBirthWeight()
{
return birthWeight;
}
public void setWeaningDate(Date weaningDate)
{
this.weaningDate = weaningDate;
}
public Date getWeaningDate()
{
return weaningDate;
}
public void setStatusId(Long statusId)
{
this.statusId = statusId;
}
public Long getStatusId()
{
return statusId;
}
public void setWeaningWeight(Long weaningWeight)
{
this.weaningWeight = weaningWeight;
}
public Long getWeaningWeight()
{
return weaningWeight;
}
public void setWeaningDayAge(Long weaningDayAge)
{
this.weaningDayAge = weaningDayAge;
}
public Long getWeaningDayAge()
{
return weaningDayAge;
}
public void setWeaningDailyGain(BigDecimal weaningDailyGain)
{
this.weaningDailyGain = weaningDailyGain;
}
public BigDecimal getWeaningDailyGain()
{
return weaningDailyGain;
}
public void setCurrentWeight(Long currentWeight)
{
this.currentWeight = currentWeight;
}
public Long getCurrentWeight()
{
return currentWeight;
}
public void setBreedStatusId(Long breedStatusId)
{
this.breedStatusId = breedStatusId;
}
public Long getBreedStatusId()
{
return breedStatusId;
}
public void setBreed(String breed)
{
this.breed = breed;
}
public String getBreed()
{
return breed;
}
public void setBsFatherId(Long bsFatherId)
{
this.bsFatherId = bsFatherId;
}
public Long getBsFatherId()
{
return bsFatherId;
}
public void setFatherManageTags(String fatherManageTags)
{
this.fatherManageTags = fatherManageTags;
}
public String getFatherManageTags()
{
return fatherManageTags;
}
public void setBsMotherId(Long bsMotherId)
{
this.bsMotherId = bsMotherId;
}
public Long getBsMotherId()
{
return bsMotherId;
}
public void setMotherManageTags(String motherManageTags)
{
this.motherManageTags = motherManageTags;
}
public String getMotherManageTags()
{
return motherManageTags;
}
public void setReceptorId(Long receptorId)
{
this.receptorId = receptorId;
}
public Long getReceptorId()
{
return receptorId;
}
public void setReceptorManageTags(String receptorManageTags)
{
this.receptorManageTags = receptorManageTags;
}
public String getReceptorManageTags()
{
return receptorManageTags;
}
public void setFatherFatherId(Long fatherFatherId)
{
this.fatherFatherId = fatherFatherId;
}
public Long getFatherFatherId()
{
return fatherFatherId;
}
public void setGrandfatherManageTags(String grandfatherManageTags)
{
this.grandfatherManageTags = grandfatherManageTags;
}
public String getGrandfatherManageTags()
{
return grandfatherManageTags;
}
public void setFatherMotherId(Long fatherMotherId)
{
this.fatherMotherId = fatherMotherId;
}
public Long getFatherMotherId()
{
return fatherMotherId;
}
public void setGrandmotherManageTags(String grandmotherManageTags)
{
this.grandmotherManageTags = grandmotherManageTags;
}
public String getGrandmotherManageTags()
{
return grandmotherManageTags;
}
public void setFatherId(Long fatherId)
{
this.fatherId = fatherId;
}
public Long getFatherId()
{
return fatherId;
}
public void setMaternalGrandfatherManageTags(String maternalGrandfatherManageTags)
{
this.maternalGrandfatherManageTags = maternalGrandfatherManageTags;
}
public String getMaternalGrandfatherManageTags()
{
return maternalGrandfatherManageTags;
}
public void setMotherId(Long motherId)
{
this.motherId = motherId;
}
public Long getMotherId()
{
return motherId;
}
public void setMaternalGrandmotherManageTags(String maternalGrandmotherManageTags)
{
this.maternalGrandmotherManageTags = maternalGrandmotherManageTags;
}
public String getMaternalGrandmotherManageTags()
{
return maternalGrandmotherManageTags;
}
public void setMatingDate(Date matingDate)
{
this.matingDate = matingDate;
}
public Date getMatingDate()
{
return matingDate;
}
public void setMatingTypeId(Long matingTypeId)
{
this.matingTypeId = matingTypeId;
}
public Long getMatingTypeId()
{
return matingTypeId;
}
public void setPregDate(Date pregDate)
{
this.pregDate = pregDate;
}
public Date getPregDate()
{
return pregDate;
}
public void setLambingDate(Date lambingDate)
{
this.lambingDate = lambingDate;
}
public Date getLambingDate()
{
return lambingDate;
}
public void setLambingDay(Long lambingDay)
{
this.lambingDay = lambingDay;
}
public Long getLambingDay()
{
return lambingDay;
}
public void setMatingDay(Long matingDay)
{
this.matingDay = matingDay;
}
public Long getMatingDay()
{
return matingDay;
}
public void setGestationDay(Long gestationDay)
{
this.gestationDay = gestationDay;
}
public Long getGestationDay()
{
return gestationDay;
}
public void setExpectedDate(Date expectedDate)
{
this.expectedDate = expectedDate;
}
public Date getExpectedDate()
{
return expectedDate;
}
public void setPostLambingDay(Long postLambingDay)
{
this.postLambingDay = postLambingDay;
}
public Long getPostLambingDay()
{
return postLambingDay;
}
public void setLactationDay(Long lactationDay)
{
this.lactationDay = lactationDay;
}
public Long getLactationDay()
{
return lactationDay;
}
public void setAnestrousDay(Long anestrousDay)
{
this.anestrousDay = anestrousDay;
}
public Long getAnestrousDay()
{
return anestrousDay;
}
public void setMatingCounts(Long matingCounts)
{
this.matingCounts = matingCounts;
}
public Long getMatingCounts()
{
return matingCounts;
}
public void setMatingTotal(Long matingTotal)
{
this.matingTotal = matingTotal;
}
public Long getMatingTotal()
{
return matingTotal;
}
public void setMiscarriageCounts(Long miscarriageCounts)
{
this.miscarriageCounts = miscarriageCounts;
}
public Long getMiscarriageCounts()
{
return miscarriageCounts;
}
public void setComment(String comment)
{
this.comment = comment;
}
public String getComment()
{
return comment;
}
public void setControlled(Long controlled)
{
this.controlled = controlled;
}
public Long getControlled()
{
return controlled;
}
public void setBody(Long body)
{
this.body = body;
}
public Long getBody()
{
return body;
}
public void setBreast(Long breast)
{
this.breast = breast;
}
public Long getBreast()
{
return breast;
}
public void setSource(String source)
{
this.source = source;
}
public String getSource()
{
return source;
}
public void setSourceDate(Date sourceDate)
{
this.sourceDate = sourceDate;
}
public Date getSourceDate()
{
return sourceDate;
}
public void setSourceRanchId(Long sourceRanchId)
{
this.sourceRanchId = sourceRanchId;
}
public Long getSourceRanchId()
{
return sourceRanchId;
}
public void setSourceRanch(String sourceRanch)
{
this.sourceRanch = sourceRanch;
}
public String getSourceRanch()
{
return sourceRanch;
}
public void setIsDelete(Long isDelete)
{
this.isDelete = isDelete;
}
public Long getIsDelete()
{
return isDelete;
}
public void setSheepColor(String sheepColor)
{
this.sheepColor = sheepColor;
}
public String getSheepColor()
{
return sheepColor;
}
public void setGroupName(String groupName)
{
this.groupName = groupName;
}
public String getGroupName()
{
return groupName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("bsManageTags", getBsManageTags())
.append("ranchId", getRanchId())
.append("drRanch", getDrRanch())
.append("sheepfoldId", getSheepfoldId())
.append("sheepfoldName", getSheepfoldName())
.append("electronicTags", getElectronicTags())
.append("varietyId", getVarietyId())
.append("variety", getVariety())
.append("family", getFamily())
.append("name", getName())
.append("gender", getGender())
.append("birthday", getBirthday())
.append("dayAge", getDayAge())
.append("monthAge", getMonthAge())
.append("parity", getParity())
.append("birthWeight", getBirthWeight())
.append("weaningDate", getWeaningDate())
.append("statusId", getStatusId())
.append("weaningWeight", getWeaningWeight())
.append("weaningDayAge", getWeaningDayAge())
.append("weaningDailyGain", getWeaningDailyGain())
.append("currentWeight", getCurrentWeight())
.append("breedStatusId", getBreedStatusId())
.append("breed", getBreed())
.append("bsFatherId", getBsFatherId())
.append("fatherManageTags", getFatherManageTags())
.append("bsMotherId", getBsMotherId())
.append("motherManageTags", getMotherManageTags())
.append("receptorId", getReceptorId())
.append("receptorManageTags", getReceptorManageTags())
.append("fatherFatherId", getFatherFatherId())
.append("grandfatherManageTags", getGrandfatherManageTags())
.append("fatherMotherId", getFatherMotherId())
.append("grandmotherManageTags", getGrandmotherManageTags())
.append("fatherId", getFatherId())
.append("maternalGrandfatherManageTags", getMaternalGrandfatherManageTags())
.append("motherId", getMotherId())
.append("maternalGrandmotherManageTags", getMaternalGrandmotherManageTags())
.append("matingDate", getMatingDate())
.append("matingTypeId", getMatingTypeId())
.append("pregDate", getPregDate())
.append("lambingDate", getLambingDate())
.append("lambingDay", getLambingDay())
.append("matingDay", getMatingDay())
.append("gestationDay", getGestationDay())
.append("expectedDate", getExpectedDate())
.append("postLambingDay", getPostLambingDay())
.append("lactationDay", getLactationDay())
.append("anestrousDay", getAnestrousDay())
.append("matingCounts", getMatingCounts())
.append("matingTotal", getMatingTotal())
.append("miscarriageCounts", getMiscarriageCounts())
.append("comment", getComment())
.append("controlled", getControlled())
.append("body", getBody())
.append("breast", getBreast())
.append("source", getSource())
.append("sourceDate", getSourceDate())
.append("sourceRanchId", getSourceRanchId())
.append("sourceRanch", getSourceRanch())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("isDelete", getIsDelete())
.append("sheepColor", getSheepColor())
.append("groupName", getGroupName())
.toString();
}
}

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.base.mapper;
import java.util.List;
import com.zhyc.common.core.domain.BaseEntity;
import com.zhyc.module.base.domain.BasSheep;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -74,10 +73,10 @@ public interface BasSheepMapper
/**
* 模糊查询母羊耳号列表
*
* @param sheep 查询关键字
* @param query 查询关键字
* @return 耳号列表
*/
List<String> searchEarNumbers(BasSheep sheep);
List<String> searchEarNumbers(@Param("query") String query);
List<BasSheep> selectBasSheepBySheepfold(String id);
@@ -92,5 +91,4 @@ public interface BasSheepMapper
int existsByElectronicTag(@Param("tag") String tag);
List<BasSheep> selectBasSheepByManageTagsList(@Param("manageTagsList") List<String> manageTagsList, @Param("sheep")BasSheep sheep);
}

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.base.mapper;
import com.zhyc.module.base.domain.DaSheepfold;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -31,12 +30,6 @@ public interface DaSheepfoldMapper
*/
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold);
/**
* 羊舍级别汇总查询(主表格)
*/
List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold);
/**
* 新增羊舍管理
*
@@ -70,13 +63,5 @@ public interface DaSheepfoldMapper
public int deleteDaSheepfoldByIds(Long[] ids);
public int selectCount(DaSheepfold daSheepfold);
// 新增:按组合条件删除的自定义方法(核心)
int deleteSheepfoldByCondition(
@Param("ranchId") Long ranchId,
@Param("sheepfoldNo") String sheepfoldNo,
@Param("sheepfoldTypeId") Long sheepfoldTypeId
);
}

View File

@@ -27,19 +27,13 @@ public interface SheepFileMapper
public SheepFile selectSheepFileById(Long id);
/**
* 查询羊只档案列表 (基础查询)
* 查询羊只档案列表
*
* @param sheepFile 羊只档案
* @return 羊只档案集合
*/
public List<SheepFile> selectSheepFileList(SheepFile sheepFile);
/**
* 新增:模糊查询耳号列表(用于下拉框远程搜索)
* @param query 搜索关键字
* @return 匹配的耳号列表
*/
List<String> searchEarNumbers(@Param("query") String query);
/**
* 根据管理耳号查询
@@ -49,9 +43,11 @@ public interface SheepFileMapper
*/
SheepFile selectSheepByManageTags(String tags);
// 在群羊只总数
Long countInGroup();
// 羊只类别分布(按 name 分组)
List<Map<String,Object>> countBySheepType();
@@ -64,34 +60,52 @@ public interface SheepFileMapper
// 泌乳羊胎次分布name = '泌乳羊' 时按 parity 分组)
List<Map<String,Object>> countParityOfLactation();
/**
* 获取指定字段的唯一值列表 (配合 XML 中的 selectFieldValues)
*/
List<String> selectFieldValues(@Param("fieldName") String fieldName);
/**
* 核心修复:根据复杂条件查询羊只档案列表
* 对应 XML 中的 <select id="selectSheepFileListByCondition">
* 必须使用 @Param 注解以便 XML 能正确识别两个参数
* 新增方法:获取指定字段的唯一值列表
*
* 这个方法用于查询数据库中某个字段的所有不重复的值
* 主要用于前端筛选条件中的下拉选项数据
*
* @param fieldName 字段名(数据库表中的列名)
* @return 该字段的所有唯一值列表,按字母顺序排序
*
* 使用场景示例:
* - 用户选择"耳号"字段时,返回所有不重复的耳号
* - 用户选择"品种"字段时,返回所有不重复的品种名称
*/
List<String> selectFieldValues(String fieldName);
/**
* 根据复杂条件查询羊只档案列表
*
* @param params 查询参数映射
* @param sheepFile 原有的查询条件(保持兼容)
* @return 羊只档案列表
*/
List<SheepFile> selectSheepFileListByCondition(
@Param("params") Map<String, Object> params,
@Param("sheepFile") SheepFile sheepFile
);
/**
* 保留原有 Provider 方法 (若项目其他地方有用到)
*/
// 修改:使用 @SelectProvider 并指定 ResultMap
@SelectProvider(type = SheepFileSqlProvider.class, method = "selectByCondition")
@ResultMap("SheepFileResult")
@ResultMap("SheepFileResult") // 重要:指定使用 XML 中定义的 ResultMap
List<SheepFile> selectByCondition(
@Param("sheepFile") SheepFile sheepFile,
@Param("conditions") Map<String, Object> conditions
);
// 修改:获取字段值的方法
@SelectProvider(type = SheepFileSqlProvider.class, method = "selectFieldValues")
List<String> selectFieldValuesByProvider(@Param("fieldName") String fieldName);
/**
* 查询所有公羊gender=2
*
* @return 公羊列表
*/
/**
* 查询所有公羊gender=2
* @return 公羊列表
@@ -104,24 +118,4 @@ public interface SheepFileMapper
* @return 羊只信息
*/
SheepFile selectSheepFileByManageTags(String manageTags);
/**
* 新增羊只档案 (对应 XML 中的 insert)
*/
public int insertSheepFile(SheepFile sheepFile);
/**
* 修改羊只档案 (对应 XML 中的 update)
*/
public int updateSheepFile(SheepFile sheepFile);
/**
* 删除羊只档案 (对应 XML 中的 delete)
*/
public int deleteSheepFileById(Long id);
/**
* 批量删除羊只档案 (对应 XML 中的 delete)
*/
public int deleteSheepFileByIds(Long[] ids);
}
}

View File

@@ -1,70 +0,0 @@
package com.zhyc.module.base.mapper;
import java.util.List;
import com.zhyc.module.base.domain.SheepPedigree;
import org.apache.ibatis.annotations.Param;
/**
* VIEWMapper接口
*
* @author ruoyi
* @date 2026-02-04
*/
public interface SheepPedigreeMapper
{
/**
* 查询VIEW
*
* @param id VIEW主键
* @return VIEW
*/
public SheepPedigree selectSheepPedigreeById(Long id);
/**
* 查询VIEW列表
*
* @param sheepPedigree VIEW
* @return VIEW集合
*/
public List<SheepPedigree> selectSheepPedigreeList(SheepPedigree sheepPedigree);
/**
* 新增VIEW
*
* @param sheepPedigree VIEW
* @return 结果
*/
public int insertSheepPedigree(SheepPedigree sheepPedigree);
/**
* 修改VIEW
*
* @param sheepPedigree VIEW
* @return 结果
*/
public int updateSheepPedigree(SheepPedigree sheepPedigree);
/**
* 删除VIEW
*
* @param id VIEW主键
* @return 结果
*/
public int deleteSheepPedigreeById(Long id);
/**
* 批量删除VIEW
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSheepPedigreeByIds(Long[] ids);
/**
* 根据int类型id查询繁育状态名称
* @param id 主键idint类型
* @return 繁育状态名称breed列的值
*/
String selectBreedNameById(@Param("id") Long id);
}

View File

@@ -71,12 +71,6 @@ public interface IBasSheepService
* 根据羊只耳号获取羊只
*/
BasSheep selectBasSheepByManageTags(String trim);
/**
* 根据管理耳号列表批量查询羊只
*/
List<BasSheep> selectBasSheepByManageTagsList(List<String> manageTagsList);
/**
* 根据牧场ID获取羊只列表

View File

@@ -29,8 +29,6 @@ public interface IDaSheepfoldService
*/
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold);
public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold);
/**
* 新增羊舍管理
*
@@ -75,8 +73,4 @@ public interface IDaSheepfoldService
// 根据羊舍id获取该羊舍的羊
List<BasSheep> sheepListById(String id);
/** 新增:根据组合条件删除羊圈记录 */
boolean deleteSheepfoldByCondition(DaSheepfold sheepfold);
}

View File

@@ -8,29 +8,28 @@ import java.util.Map;
/**
* 羊只档案Service接口
* * @author wyt
*
* @author wyt
* @date 2025-07-13
*/
public interface ISheepFileService
public interface ISheepFileService
{
/**
* 查询羊只档案
* * @param id 羊只档案主键
*
* @param id 羊只档案主键
* @return 羊只档案
*/
public SheepFile selectSheepFileById(Long id);
/**
* 查询羊只档案列表
* * @param sheepFile 羊只档案
*
* @param sheepFile 羊只档案
* @return 羊只档案集合
*/
public List<SheepFile> selectSheepFileList(SheepFile sheepFile);
/**
* 新增:搜索耳号接口
*/
List<String> searchEarNumbers(String query);
SheepFile selectBasSheepByManageTags(String trim);
@@ -42,14 +41,27 @@ public interface ISheepFileService
List<Map<String,Object>> countParityOfLactation();
/**
* 获取指定字段的唯一值列表
* 新增方法:获取指定字段的唯一值列表
*
* 这个方法为前端筛选功能提供数据支持
* 当用户选择某个字段进行筛选时,调用此方法获取该字段的所有可能值
*
* @param fieldName 字段名(需要是数据库表中的列名)
* @return 该字段的所有唯一值列表
* @throws IllegalArgumentException 当字段名不在白名单中时抛出异常
*
* 示例用法:
* List<String> earTags = getFieldValues("bs_manage_tags");
* // 返回结果可能是:["AF00001", "AF00002", "AF00003", ...]
*/
List<String> getFieldValues(String fieldName);
/**
* 根据复杂条件查询羊只档案列表
* @param params 自定义参数Map (用于动态SQL)
* @param sheepFile 包含List筛选条件的实体对象
*
* @param params 查询参数映射
* @param sheepFile 原有的查询条件
* @return 羊只档案列表
*/
List<SheepFile> selectSheepFileListByCondition(
Map<String, Object> params,
@@ -61,4 +73,4 @@ public interface ISheepFileService
@Transactional
int updateSheepFile(SheepFile sheepFile);
}
}

View File

@@ -1,63 +0,0 @@
package com.zhyc.module.base.service;
import java.util.List;
import com.zhyc.module.base.domain.SheepPedigree;
/**
* VIEWService接口
*
* @author ruoyi
* @date 2026-02-04
*/
public interface ISheepPedigreeService
{
/**
* 查询VIEW
*
* @param id VIEW主键
* @return VIEW
*/
public SheepPedigree selectSheepPedigreeById(Long id);
/**
* 查询VIEW列表
*
* @param sheepPedigree VIEW
* @return VIEW集合
*/
public List<SheepPedigree> selectSheepPedigreeList(SheepPedigree sheepPedigree);
/**
* 新增VIEW
*
* @param sheepPedigree VIEW
* @return 结果
*/
public int insertSheepPedigree(SheepPedigree sheepPedigree);
/**
* 修改VIEW
*
* @param sheepPedigree VIEW
* @return 结果
*/
public int updateSheepPedigree(SheepPedigree sheepPedigree);
/**
* 批量删除VIEW
*
* @param ids 需要删除的VIEW主键集合
* @return 结果
*/
public int deleteSheepPedigreeByIds(Long[] ids);
/**
* 删除VIEW信息
*
* @param id VIEW主键
* @return 结果
*/
public int deleteSheepPedigreeById(Long id);
public String getBreedNameById(Long id);
}

View File

@@ -1,10 +1,6 @@
package com.zhyc.module.base.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.core.domain.BaseEntity;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.mapper.BasSheepMapper;
@@ -55,22 +51,9 @@ public class BasSheepServiceImpl implements IBasSheepService
* @return
*/
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<String> searchEarNumbers(String query) {
BasSheep basSheep = new BasSheep();
basSheep.setManageTags(query);
return basSheepMapper.searchEarNumbers(basSheep);
return basSheepMapper.searchEarNumbers(query);
}
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<BasSheep> selectBasSheepByManageTagsList(List<String> manageTagsList) {
if (manageTagsList == null || manageTagsList.isEmpty()) {
return new ArrayList<>();
}
return basSheepMapper.selectBasSheepByManageTagsList(manageTagsList,new BasSheep());
}
/**
* 新增羊只基本信息
*

View File

@@ -1,40 +1,32 @@
package com.zhyc.module.base.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.DaSheepfold;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.mapper.DaSheepfoldMapper;
import com.zhyc.module.base.service.IDaSheepfoldService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* 羊舍管理Service业务层处理
*
*
* @author wyt
* @date 2025-07-11
*/
@Service
public class DaSheepfoldServiceImpl implements IDaSheepfoldService
public class DaSheepfoldServiceImpl implements IDaSheepfoldService
{
@Autowired
private DaSheepfoldMapper daSheepfoldMapper;
@Autowired
private BasSheepMapper basSheepMapper;
// 日志对象
private static final Logger log = LoggerFactory.getLogger(DaSheepfoldServiceImpl.class);
/**
* 查询羊舍管理
*
*
* @param id 羊舍管理主键
* @return 羊舍管理
*/
@@ -46,27 +38,19 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/**
* 查询羊舍管理列表
*
*
* @param daSheepfold 羊舍管理
* @return 羊舍管理
*/
@Override
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold)
{
List<DaSheepfold> sheepfoldList = daSheepfoldMapper.selectDaSheepfoldList(daSheepfold);
return sheepfoldList; // 修复原代码重复调用Mapper改为返回已查询的列表
}
/**
* 羊舍级别汇总查询(主表格)
*/
public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold) {
return daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold);
return daSheepfoldMapper.selectDaSheepfoldList(daSheepfold);
}
/**
* 新增羊舍管理
*
*
* @param daSheepfold 羊舍管理
* @return 结果
*/
@@ -78,7 +62,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/**
* 修改羊舍管理
*
*
* @param daSheepfold 羊舍管理
* @return 结果
*/
@@ -90,7 +74,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/**
* 批量删除羊舍管理
*
*
* @param ids 需要删除的羊舍管理主键
* @return 结果
*/
@@ -102,7 +86,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/**
* 删除羊舍管理信息
*
*
* @param id 羊舍管理主键
* @return 结果
*/
@@ -112,6 +96,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
return daSheepfoldMapper.deleteDaSheepfoldById(id);
}
@Override
public boolean checkSheepfoldNoExist(Long ranchId, Long sheepfoldTypeId, String sheepfoldNo) {
DaSheepfold query = new DaSheepfold();
@@ -126,40 +111,4 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
List<BasSheep> basSheep = basSheepMapper.selectBasSheepBySheepfold(id);
return basSheep;
}
/**
* 核心实现根据组合条件删除完全自定义无MP依赖
* 条件ranch_id = ? AND sheepfold_no = ? AND sheepfold_type_id = ?
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteSheepfoldByCondition(DaSheepfold sheepfold) {
// 1. 前置校验仅校验3个核心字段移除sheepfoldName的校验
if (sheepfold.getRanchId() == null
|| !StringUtils.hasText(sheepfold.getSheepfoldNo())
|| sheepfold.getSheepfoldTypeId() == null) {
log.error("删除失败核心条件不能为空牧场ID={}, 羊舍编号={}, 羊舍类型ID={}",
sheepfold.getRanchId(), sheepfold.getSheepfoldNo(), sheepfold.getSheepfoldTypeId());
throw new IllegalArgumentException("删除失败牧场ID、羊舍编号、羊舍类型ID不能为空");
}
// 2. 调用Mapper方法仅传递3个核心字段移除sheepfoldName
int deleteCount = daSheepfoldMapper.deleteSheepfoldByCondition(
sheepfold.getRanchId(),
sheepfold.getSheepfoldNo(),
sheepfold.getSheepfoldTypeId()
);
boolean isSuccess = deleteCount > 0;
// 3. 日志打印移除sheepfoldName相关内容
if (isSuccess) {
log.info("成功删除羊舍记录牧场ID={}, 羊舍编号={}, 羊舍类型ID={}",
sheepfold.getRanchId(), sheepfold.getSheepfoldNo(), sheepfold.getSheepfoldTypeId());
} else {
log.warn("未找到匹配条件的羊舍记录牧场ID={}, 羊舍编号={}, 羊舍类型ID={}",
sheepfold.getRanchId(), sheepfold.getSheepfoldNo(), sheepfold.getSheepfoldTypeId());
}
return isSuccess;
}
}
}

View File

@@ -11,12 +11,12 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.List;import java.util.Map;
/**
* 羊只档案Service业务层处理
* * @author wyt
*
* @author wyt
* @date 2025-07-13
*/
@Service
@@ -24,11 +24,11 @@ public class SheepFileServiceImpl implements ISheepFileService {
@Autowired
private SheepFileMapper sheepFileMapper;
@Autowired
private IBreedRamFileService breedRamFileService;
/**
* 查询羊只档案
*
* @param id 羊只档案主键
* @return 羊只档案
*/
@Override
public SheepFile selectSheepFileById(Long id) {
@@ -37,25 +37,21 @@ public class SheepFileServiceImpl implements ISheepFileService {
/**
* 查询羊只档案列表
*
* @param sheepFile 羊只档案
* @return 羊只档案
*/
@Override
public List<SheepFile> selectSheepFileList(SheepFile sheepFile) {
return sheepFileMapper.selectSheepFileList(sheepFile);
}
/**
* 新增:模糊搜索耳号实现
*/
@Override
public List<String> searchEarNumbers(String query) {
return sheepFileMapper.searchEarNumbers(query);
}
@Override
public SheepFile selectBasSheepByManageTags(String tags) {
return sheepFileMapper.selectSheepByManageTags(tags);
}
@Override
public List<Map<String, Object>> countBySheepType() {
return sheepFileMapper.countBySheepType();
@@ -75,7 +71,6 @@ public class SheepFileServiceImpl implements ISheepFileService {
public List<Map<String, Object>> countParityOfLactation() {
return sheepFileMapper.countParityOfLactation();
}
@Override
public Long countInGroup() { return sheepFileMapper.countInGroup(); }
@@ -89,42 +84,31 @@ public class SheepFileServiceImpl implements ISheepFileService {
throw new IllegalArgumentException("非法的字段名: " + fieldName + ",请检查字段名是否正确");
}
// 调用Mapper
// 注意:这里假设 Mapper 中有 selectFieldValues 方法
// 如果你的 Mapper XML 中 id 是 selectFieldValues请确保 Mapper 接口一致
return sheepFileMapper.selectFieldValues(fieldName);
// 第二步:调用新的 Provider 方法
// 注意:这里调用的是 selectFieldValuesByProvider不是 selectFieldValues
return sheepFileMapper.selectFieldValuesByProvider(fieldName);
}
/**
* 核心修复:复杂条件查询
* 必须调用 Mapper 中对应的 XML 方法 (selectSheepFileListByCondition)
* 并且传递 sheepFile 对象以启用 <foreach> 列表查询
*/
@Override
public List<SheepFile> selectSheepFileListByCondition(Map<String, Object> params, SheepFile sheepFile) {
// 1. 验证并处理自定义参数 (驼峰转下划线、安全检查)
// 验证并处理参数
Map<String, Object> safeConditions = processConditions(params);
// 2. 调用 Mapper
// 这里必须使用与 XML 中 <select id="selectSheepFileListByCondition"> 对应的方法
return sheepFileMapper.selectSheepFileListByCondition(safeConditions, sheepFile);
// 调用新的 Provider 方法
List<SheepFile> result = sheepFileMapper.selectByCondition(sheepFile, safeConditions);
return result;
}
@Override
@Transactional
public int insertSheepFile(SheepFile sheepFile) {
// int rows = sheepFileMapper.insertSheepFile(sheepFile);
// if (rows > 0) { syncToBreedRamFile(sheepFile); }
// return rows;
return 0;
}
@Override
@Transactional
public int updateSheepFile(SheepFile sheepFile) {
// int rows = sheepFileMapper.updateSheepFile(sheepFile);
// if (rows > 0) { syncToBreedRamFile(sheepFile); }
// return rows;
return 0;
}
@@ -142,13 +126,12 @@ public class SheepFileServiceImpl implements ISheepFileService {
String fieldName = entry.getKey();
Object value = entry.getValue();
// 将前端字段名转换为数据库字段名 (例如: fatherManageTags -> father_manage_tags)
// 这对于 XML 中的 ${key} = #{value} 至关重要
// 将前端字段名转换为数据库字段名
String dbFieldName = convertToDbFieldName(fieldName);
// 验证字段名是否安全
if (isValidFieldName(dbFieldName)) {
// 处理值
// 处理值,确保不是 Character 类型
Object safeValue = value;
if (value != null) {
String strValue = value.toString();
@@ -157,17 +140,23 @@ public class SheepFileServiceImpl implements ISheepFileService {
if (strValue.startsWith("GT:") || strValue.startsWith("LT:") ||
strValue.startsWith("GE:") || strValue.startsWith("LE:")) {
String numPart = strValue.substring(3);
// 验证数字部分是否安全
// 验证数字部分是否安全(防止 SQL 注入)
if (isNumeric(numPart)) {
safeValue = strValue;
} else {
// 如果不是数字,忽略这个条件
System.out.println("警告:范围条件的值不是数字: " + fieldName + " = " + strValue);
continue;
}
} else {
// 其他值直接使用字符串
safeValue = strValue;
}
}
safeParams.put(dbFieldName, safeValue);
} else {
// 记录日志
System.out.println("警告:忽略非法字段名: " + fieldName + " -> " + dbFieldName);
}
}
@@ -202,17 +191,61 @@ public class SheepFileServiceImpl implements ISheepFileService {
* 扩展字段名白名单验证
*/
private boolean isValidFieldName(String fieldName) {
// 字段白名单
// 扩展允许查询的字段白名单
String[] allowedFields = {
"id", "bs_manage_tags", "electronic_tags", "dr_ranch", "sheepfold_name", "variety", "family",
"name", "gender", "birthday", "day_age", "month_age", "parity", "birth_weight", "weaning_date",
"status_id", "weaning_weight", "current_weight", "weaning_day_age", "weaning_daily_gain", "breed",
"father_manage_tags", "mother_manage_tags", "receptor_manage_tags", "grandfather_manage_tags",
"grandmother_manage_tags", "maternal_grandfather_manage_tags", "maternal_grandmother_manage_tags",
"mating_date", "mating_type_id", "preg_date", "lambing_date", "lambing_day", "mating_day",
"gestation_day", "expected_date", "post_lambing_day", "lactation_day", "anestrous_day",
"mating_counts", "mating_total", "miscarriage_counts", "comment", "controlled", "body", "breast",
"source", "source_date", "source_ranch", "update_by", "update_time", "create_by", "create_time"
"id",
"bs_manage_tags", // 管理耳号
"electronic_tags", // 电子耳号
"dr_ranch", // 牧场名称
"sheepfold_name", // 羊舍名称
"variety", // 品种
"family", // 家系
"name", // 羊只类型
"gender", // 性别
"birthday", // 出生日期
"day_age", // 日龄
"month_age", // 月龄
"parity", // 胎次
"birth_weight", // 出生体重
"weaning_date", // 断奶日期
"status_id", // 羊只状态
"weaning_weight", // 断奶体重
"current_weight", // 当前体重
"weaning_day_age", // 断奶日龄
"weaning_daily_gain", // 断奶日增重
"breed", // 繁殖状态
"father_manage_tags", // 父亲耳号
"mother_manage_tags", // 母亲耳号
"receptor_manage_tags", // 受体耳号
"grandfather_manage_tags", // 祖父耳号
"grandmother_manage_tags", // 祖母耳号
"maternal_grandfather_manage_tags", // 外祖父耳号
"maternal_grandmother_manage_tags", // 外祖母耳号
"mating_date", // 配种日期
"mating_type_id", // 配种类型
"preg_date", // 孕检日期
"lambing_date", // 产羔日期
"lambing_day", // 产羔时怀孕天数
"mating_day", // 配后天数
"gestation_day", // 怀孕天数
"expected_date", // 预产日期
"post_lambing_day", // 产后天数
"lactation_day", // 泌乳天数
"anestrous_day", // 空怀天数
"mating_counts", // 配种次数
"mating_total", // 累计配种次数
"miscarriage_counts", // 累计流产次数
"comment", // 备注
"controlled", // 是否性控
"body", // 体况评分
"breast", // 乳房评分
"source", // 入群来源
"source_date", // 入群日期
"source_ranch", // 来源牧场
"update_by", // 修改人
"update_time", // 修改日期
"create_by", // 创建人
"create_time" // 创建日期
};
for (String allowedField : allowedFields) {
@@ -224,32 +257,45 @@ public class SheepFileServiceImpl implements ISheepFileService {
return false;
}
@Autowired
private IBreedRamFileService breedRamFileService; // 注入种公羊服务
/**
* 新增羊只档案
*/
/**
* 同步公羊数据到种公羊档案表
*/
private void syncToBreedRamFile(SheepFile sheepFile) {
try {
// 检查是否已存在
BreedRamFile existingRam = breedRamFileService.selectBreedRamFileByOrdinaryEarNumber(
sheepFile.getBsManageTags()
);
if (existingRam != null) {
// 已存在,更新
BreedRamFile updateRam = convertToBreedRamFile(sheepFile);
updateRam.setId(existingRam.getId());
breedRamFileService.updateBreedRamFile(updateRam);
} else {
// 不存在,新增
BreedRamFile newRam = convertToBreedRamFile(sheepFile);
breedRamFileService.insertBreedRamFile(newRam);
}
} catch (Exception e) {
e.printStackTrace();
// 记录日志,但不影响主流
}
}
/**
* 将SheepFile转换为BreedRamFile
*/
private BreedRamFile convertToBreedRamFile(SheepFile sheepFile) {
BreedRamFile breedRamFile = new BreedRamFile();
// 基本信息
breedRamFile.setOrdinaryEarNumber(sheepFile.getBsManageTags());
breedRamFile.setRanchId(sheepFile.getRanchId());
breedRamFile.setRanchName(sheepFile.getDrRanch());
@@ -261,13 +307,15 @@ public class SheepFileServiceImpl implements ISheepFileService {
breedRamFile.setSheepCategory(sheepFile.getName());
breedRamFile.setBirthday(sheepFile.getBirthday());
if (sheepFile.getBirthWeight() != null) breedRamFile.setBirthWeight(BigDecimal.valueOf(sheepFile.getBirthWeight()));
// 体重相关
breedRamFile.setBirthWeight(BigDecimal.valueOf(sheepFile.getBirthWeight()));
breedRamFile.setWeaningDate(sheepFile.getWeaningDate());
breedRamFile.setWeaningDayAge(sheepFile.getWeaningDayAge());
if (sheepFile.getWeaningWeight() != null) breedRamFile.setWeaningWeight(BigDecimal.valueOf(sheepFile.getWeaningWeight()));
if (sheepFile.getWeaningDailyGain() != null) breedRamFile.setWeaningDailyGain(BigDecimal.valueOf(sheepFile.getWeaningDailyGain()));
if (sheepFile.getCurrentWeight() != null) breedRamFile.setCurrentWeight(BigDecimal.valueOf(sheepFile.getCurrentWeight()));
breedRamFile.setWeaningWeight(BigDecimal.valueOf(sheepFile.getWeaningWeight()));
breedRamFile.setWeaningDailyGain(BigDecimal.valueOf(sheepFile.getWeaningDailyGain()));
breedRamFile.setCurrentWeight(BigDecimal.valueOf(sheepFile.getCurrentWeight()));
// 家系信息
breedRamFile.setFatherNumber(sheepFile.getFatherManageTags());
breedRamFile.setMotherNumber(sheepFile.getMotherManageTags());
breedRamFile.setGrandfatherNumber(sheepFile.getGrandfatherManageTags());
@@ -275,6 +323,7 @@ public class SheepFileServiceImpl implements ISheepFileService {
breedRamFile.setMaternalGrandfatherNumber(sheepFile.getMaternalGrandfatherManageTags());
breedRamFile.setMaternalGrandmotherNumber(sheepFile.getMaternalGrandmotherManageTags());
// 审计信息
breedRamFile.setCreateBy(sheepFile.getCreateBy());
breedRamFile.setCreateTime(sheepFile.getCreateTime());
breedRamFile.setUpdateBy(sheepFile.getUpdateBy());
@@ -283,4 +332,5 @@ public class SheepFileServiceImpl implements ISheepFileService {
return breedRamFile;
}
}
}

View File

@@ -1,104 +0,0 @@
package com.zhyc.module.base.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.base.mapper.SheepPedigreeMapper;
import com.zhyc.module.base.domain.SheepPedigree;
import com.zhyc.module.base.service.ISheepPedigreeService;
/**
* VIEWService业务层处理
*
* @author ruoyi
* @date 2026-02-04
*/
@Service
public class SheepPedigreeServiceImpl implements ISheepPedigreeService
{
@Autowired
private SheepPedigreeMapper sheepPedigreeMapper;
/**
* 查询VIEW
*
* @param id VIEW主键
* @return VIEW
*/
@Override
public SheepPedigree selectSheepPedigreeById(Long id)
{
return sheepPedigreeMapper.selectSheepPedigreeById(id);
}
/**
* 查询VIEW列表
*
* @param sheepPedigree VIEW
* @return VIEW
*/
@Override
public List<SheepPedigree> selectSheepPedigreeList(SheepPedigree sheepPedigree)
{
return sheepPedigreeMapper.selectSheepPedigreeList(sheepPedigree);
}
/**
* 新增VIEW
*
* @param sheepPedigree VIEW
* @return 结果
*/
@Override
public int insertSheepPedigree(SheepPedigree sheepPedigree)
{
sheepPedigree.setCreateTime(DateUtils.getNowDate());
return sheepPedigreeMapper.insertSheepPedigree(sheepPedigree);
}
/**
* 修改VIEW
*
* @param sheepPedigree VIEW
* @return 结果
*/
@Override
public int updateSheepPedigree(SheepPedigree sheepPedigree)
{
sheepPedigree.setUpdateTime(DateUtils.getNowDate());
return sheepPedigreeMapper.updateSheepPedigree(sheepPedigree);
}
/**
* 批量删除VIEW
*
* @param ids 需要删除的VIEW主键
* @return 结果
*/
@Override
public int deleteSheepPedigreeByIds(Long[] ids)
{
return sheepPedigreeMapper.deleteSheepPedigreeByIds(ids);
}
/**
* 删除VIEW信息
*
* @param id VIEW主键
* @return 结果
*/
@Override
public int deleteSheepPedigreeById(Long id)
{
return sheepPedigreeMapper.deleteSheepPedigreeById(id);
}
@Override
public String getBreedNameById(Long id) {
if (id == null) { // int类型id为空直接返回空
return "";
}
return sheepPedigreeMapper.selectBreedNameById(id);
}
}

View File

@@ -1,511 +0,0 @@
package com.zhyc.module.base.util;
import com.zhyc.module.base.domain.SheepPedigree;
import com.zhyc.module.base.service.ISheepPedigreeService;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.zhyc.common.utils.DictUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 羊只系谱自定义Excel导出工具适配羊只系谱表2样式
*/
@Component
public class SheepPedigreeExcelUtils {
// 日期格式化
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
// 注入Service接口
@Autowired
private ISheepPedigreeService sheepPedigreeService;
/**
* 导出指定bsManageTags的羊只系谱符合羊只系谱表2样式
*/
public void export(HttpServletResponse response, List<SheepPedigree> dataList) throws Exception {
// 1. 创建Excel工作簿和工作表
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("羊只系谱");
// 设置列宽6列索引0-5
sheet.setColumnWidth(0, 15 * 256); // 第1列
sheet.setColumnWidth(1, 15 * 256); // 第2列
sheet.setColumnWidth(2, 15 * 256); // 第3列
sheet.setColumnWidth(3, 15 * 256); // 第4列
sheet.setColumnWidth(4, 15 * 256); // 第5列
sheet.setColumnWidth(5, 15 * 256); // 第6列
// 2. 定义样式(新增:通用边框样式,所有单元格都应用)
CellStyle titleStyle = createTitleStyle(workbook);
CellStyle blockTitleStyle = createBlockTitleStyle(workbook);
CellStyle contentStyle = createContentStyle(workbook);
CellStyle borderStyle = createBorderStyle(workbook); // 纯边框样式,用于空单元格
int rowNum = 0;
// 遍历数据
for (SheepPedigree pedigree : dataList) {
// ========== 1. 大标题:羊只系谱 ==========
Row titleRow = sheet.createRow(rowNum++);
titleRow.setHeightInPoints(25);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue("羊只系谱");
titleCell.setCellStyle(titleStyle);
// 给标题行所有列应用边框
fillRowWithBorder(titleRow, 0, 5, borderStyle);
sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 0, 5));
// ========== 2. 基础信息区块 ==========
// 普通耳号
Row earTagRow = sheet.createRow(rowNum++);
earTagRow.setHeightInPoints(20);
Cell earTagLabelCell = earTagRow.createCell(0);
earTagLabelCell.setCellValue("普通耳号");
earTagLabelCell.setCellStyle(contentStyle);
String earTagContent = pedigree.getBsManageTags() != null ? pedigree.getBsManageTags() : "";
Cell earTagValueCell = earTagRow.createCell(1);
earTagValueCell.setCellValue(earTagContent);
earTagValueCell.setCellStyle(contentStyle);
// 给当前行所有列填充边框
fillRowWithBorder(earTagRow, 0, 5, borderStyle);
CellRangeAddress earTagMerge = new CellRangeAddress(
rowNum - 1,
rowNum - 1,
1,
5
);
sheet.addMergedRegion(earTagMerge);
// 品种 + 类别
Row varietyRow = sheet.createRow(rowNum++);
varietyRow.setHeightInPoints(20);
Cell varietyLabelCell = varietyRow.createCell(0);
varietyLabelCell.setCellValue("品种");
varietyLabelCell.setCellStyle(contentStyle);
String varietyContent = pedigree.getVariety() != null ? pedigree.getVariety() : "";
Cell varietyValueCell = varietyRow.createCell(1);
varietyValueCell.setCellValue(varietyContent);
varietyValueCell.setCellStyle(contentStyle);
Cell categoryLabelCell = varietyRow.createCell(2);
categoryLabelCell.setCellValue("类别");
categoryLabelCell.setCellStyle(contentStyle);
String categoryContent = pedigree.getName() != null ? pedigree.getName() : "";
Cell categoryValueCell = varietyRow.createCell(3);
categoryValueCell.setCellValue(categoryContent);
categoryValueCell.setCellStyle(contentStyle);
// 填充边框
fillRowWithBorder(varietyRow, 0, 5, borderStyle);
CellRangeAddress categoryMerge = new CellRangeAddress(
rowNum - 1,
rowNum - 1,
3,
5
);
sheet.addMergedRegion(categoryMerge);
// 性别 + 出生重量 + 出生日期
Row genderRow = sheet.createRow(rowNum++);
genderRow.setHeightInPoints(20);
Cell genderLabelCell = genderRow.createCell(0);
genderLabelCell.setCellValue("性别");
genderLabelCell.setCellStyle(contentStyle);
Cell genderValueCell = genderRow.createCell(1);
genderValueCell.setCellValue(getGenderText(pedigree.getGender()));
genderValueCell.setCellStyle(contentStyle);
Cell birthWeightLabelCell = genderRow.createCell(2);
birthWeightLabelCell.setCellValue("出生重量");
birthWeightLabelCell.setCellStyle(contentStyle);
Cell birthWeightValueCell = genderRow.createCell(3);
String birthWeightContent = pedigree.getBirthWeight() != null ? pedigree.getBirthWeight() + "kg" : "";
birthWeightValueCell.setCellValue(birthWeightContent);
birthWeightValueCell.setCellStyle(contentStyle);
Cell birthDateLabelCell = genderRow.createCell(4);
birthDateLabelCell.setCellValue("出生日期");
birthDateLabelCell.setCellStyle(contentStyle);
Cell birthDateValueCell = genderRow.createCell(5);
String birthDate = pedigree.getBirthday() != null ? DATE_FORMAT.format(pedigree.getBirthday()) : "";
birthDateValueCell.setCellValue(birthDate);
birthDateValueCell.setCellStyle(contentStyle);
// 填充边框
fillRowWithBorder(genderRow, 0, 5, borderStyle);
// 毛色 + 月龄 + 状态
Row furColorRow = sheet.createRow(rowNum++);
furColorRow.setHeightInPoints(20);
Cell furColorLabelCell = furColorRow.createCell(0);
furColorLabelCell.setCellValue("毛色");
furColorLabelCell.setCellStyle(contentStyle);
Cell furColorValueCell = furColorRow.createCell(1);
String furColorContent = pedigree.getSheepColor() != null ? pedigree.getSheepColor() : "";
furColorValueCell.setCellValue(furColorContent);
furColorValueCell.setCellStyle(contentStyle);
Cell monthAgeLabelCell = furColorRow.createCell(2);
monthAgeLabelCell.setCellValue("月龄");
monthAgeLabelCell.setCellStyle(contentStyle);
Cell monthAgeValueCell = furColorRow.createCell(3);
String monthAgeContent = pedigree.getMonthAge() != null ? pedigree.getMonthAge() + "" : "";
monthAgeValueCell.setCellValue(monthAgeContent);
monthAgeValueCell.setCellStyle(contentStyle);
Cell statusLabelCell = furColorRow.createCell(4);
statusLabelCell.setCellValue("状态");
statusLabelCell.setCellStyle(contentStyle);
Map<Object, String> statusDict = new HashMap<>();
statusDict.put(1L, "在群");
statusDict.put(2L, "不在群");
statusDict.put(null, "");
Object statusId = pedigree.getStatusId();
String statusContent = statusDict.getOrDefault(statusId, "未知状态");
Cell statusValueCell = furColorRow.createCell(5);
statusValueCell.setCellValue(statusContent);
statusValueCell.setCellStyle(contentStyle);
// 填充边框
fillRowWithBorder(furColorRow, 0, 5, borderStyle);
// 繁育状态 + 来源
Row breedStatusRow = sheet.createRow(rowNum++);
breedStatusRow.setHeightInPoints(20);
int currentRow = rowNum - 1;
Cell breedStatusLabelCell = breedStatusRow.createCell(0);
breedStatusLabelCell.setCellValue("繁育状态");
breedStatusLabelCell.setCellStyle(contentStyle);
Cell breedStatusValueCell = breedStatusRow.createCell(1);
String breedStatusContent = "";
try {
Object breedObj = pedigree.getBreed();
if (breedObj != null) {
breedStatusContent = breedObj.toString().trim();
}
if (breedStatusContent == null || breedStatusContent.isEmpty()) {
breedStatusContent = "";
}
} catch (Exception e) {
breedStatusContent = "";
}
breedStatusValueCell.setCellValue(breedStatusContent);
breedStatusValueCell.setCellStyle(contentStyle);
Cell sourceLabelCell = breedStatusRow.createCell(2);
sourceLabelCell.setCellValue("来源");
sourceLabelCell.setCellStyle(contentStyle);
Cell sourceValueCell = breedStatusRow.createCell(3);
String sourceCode = pedigree.getSource() != null ? pedigree.getSource().toString() : "";
String sourceContent = "";
try {
sourceContent = DictUtils.getDictLabel("source", sourceCode, "");
} catch (Exception e) {
sourceContent = "";
System.err.println("来源字典映射失败:" + e.getMessage());
}
sourceValueCell.setCellValue(sourceContent);
sourceValueCell.setCellStyle(contentStyle);
// 填充边框
fillRowWithBorder(breedStatusRow, 0, 5, borderStyle);
CellRangeAddress sourceMerge = new CellRangeAddress(
currentRow,
currentRow,
3,
5
);
sheet.addMergedRegion(sourceMerge);
// 等级 + 家系
Row levelRow = sheet.createRow(rowNum++);
levelRow.setHeightInPoints(20);
int currentLevelRow = rowNum - 1;
Cell levelLabelCell = levelRow.createCell(0);
levelLabelCell.setCellValue("等级");
levelLabelCell.setCellStyle(contentStyle);
Cell levelValueCell = levelRow.createCell(1);
String levelContent = pedigree.getGroupName() != null ? pedigree.getGroupName() : "";
levelValueCell.setCellValue(levelContent);
levelValueCell.setCellStyle(contentStyle);
Cell familyLabelCell = levelRow.createCell(2);
familyLabelCell.setCellValue("家系");
familyLabelCell.setCellStyle(contentStyle);
Cell familyValueCell = levelRow.createCell(3);
String familyContent = pedigree.getFamily() != null ? pedigree.getFamily() : "";
familyValueCell.setCellValue(familyContent);
familyValueCell.setCellStyle(contentStyle);
// 填充边框
fillRowWithBorder(levelRow, 0, 5, borderStyle);
CellRangeAddress familyMerge = new CellRangeAddress(
currentLevelRow,
currentLevelRow,
3,
5
);
sheet.addMergedRegion(familyMerge);
// ========== 3. 系谱信息区块(最终修复版) ==========
Row pedigreeTitleRow = sheet.createRow(rowNum++);
pedigreeTitleRow.setHeightInPoints(25); // 区块标题行高
Cell pedigreeTitleCell = pedigreeTitleRow.createCell(0);
pedigreeTitleCell.setCellValue("系谱信息");
pedigreeTitleCell.setCellStyle(blockTitleStyle);
// 填充标题行边框
fillRowWithBorder(pedigreeTitleRow, 0, 5, borderStyle);
sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 0, 5));
// 系谱区块起始行此时rowNum是系谱内容第1行
int pedigreeStartRow = rowNum;
int pedigreeTotalRows = 12;
// 统一设置系谱12行的行高+填充边框
for (int i = 0; i < pedigreeTotalRows; i++) {
Row tempRow = sheet.createRow(pedigreeStartRow + i);
tempRow.setHeightInPoints(20);
// 给每行的0-5列都填充边框样式
fillRowWithBorder(tempRow, 0, 5, borderStyle);
}
// ========== 1. 羊只列第1列合并12行 ==========
Row sheepRow = sheet.getRow(pedigreeStartRow);
Cell sheepCell = sheepRow.createCell(0);
String sheepValue = pedigree.getBsManageTags() != null && !pedigree.getBsManageTags().isEmpty()
? "羊只:" + pedigree.getBsManageTags()
: "羊只:无";
sheepCell.setCellValue(sheepValue);
sheepCell.setCellStyle(contentStyle); // 覆盖为内容样式(带边框+字体)
sheet.addMergedRegion(new CellRangeAddress(
pedigreeStartRow,
pedigreeStartRow + 11,
0,
0
));
// ========== 2. 父耳号第2-3列合并前6行 ==========
Row fatherRow = sheet.getRow(pedigreeStartRow);
Cell fatherCell = fatherRow.createCell(1);
String fatherValue = pedigree.getFatherManageTags() != null && !pedigree.getFatherManageTags().isEmpty()
? "父耳号:" + pedigree.getFatherManageTags()
: "父耳号:无";
fatherCell.setCellValue(fatherValue);
fatherCell.setCellStyle(contentStyle);
sheet.addMergedRegion(new CellRangeAddress(
pedigreeStartRow,
pedigreeStartRow + 5,
1,
2
));
// ========== 3. 母耳号第2-3列合并后6行 ==========
Row motherRow = sheet.getRow(pedigreeStartRow + 6);
Cell motherCell = motherRow.createCell(1);
String motherValue = pedigree.getMotherManageTags() != null && !pedigree.getMotherManageTags().isEmpty()
? "母耳号:" + pedigree.getMotherManageTags()
: "母耳号:无";
motherCell.setCellValue(motherValue);
motherCell.setCellStyle(contentStyle);
sheet.addMergedRegion(new CellRangeAddress(
pedigreeStartRow + 6,
pedigreeStartRow + 11,
1,
2
));
// ========== 4. 祖父耳号第4-6列合并1-3行 ==========
Row grandFatherRow = sheet.getRow(pedigreeStartRow);
Cell grandFatherCell = grandFatherRow.createCell(3);
String grandFatherValue = pedigree.getGrandfatherManageTags() != null && !pedigree.getGrandfatherManageTags().isEmpty()
? "祖父耳号:" + pedigree.getGrandfatherManageTags()
: "祖父耳号:无";
grandFatherCell.setCellValue(grandFatherValue);
grandFatherCell.setCellStyle(contentStyle);
sheet.addMergedRegion(new CellRangeAddress(
pedigreeStartRow,
pedigreeStartRow + 2,
3,
5
));
// ========== 5. 祖母耳号第4-6列合并4-6行 ==========
Row grandMotherRow = sheet.getRow(pedigreeStartRow + 3);
Cell grandMotherCell = grandMotherRow.createCell(3);
String grandMotherValue = pedigree.getGrandmotherManageTags() != null && !pedigree.getGrandmotherManageTags().isEmpty()
? "祖母耳号:" + pedigree.getGrandmotherManageTags()
: "祖母耳号:无";
grandMotherCell.setCellValue(grandMotherValue);
grandMotherCell.setCellStyle(contentStyle);
sheet.addMergedRegion(new CellRangeAddress(
pedigreeStartRow + 3,
pedigreeStartRow + 5,
3,
5
));
// ========== 6. 外祖父耳号第4-6列合并7-9行 ==========
Row maternalGrandFatherRow = sheet.getRow(pedigreeStartRow + 6);
Cell maternalGrandFatherCell = maternalGrandFatherRow.createCell(3);
String maternalGrandFatherValue = pedigree.getMaternalGrandfatherManageTags() != null && !pedigree.getMaternalGrandfatherManageTags().isEmpty()
? "外祖父耳号:" + pedigree.getMaternalGrandfatherManageTags()
: "外祖父耳号:无";
maternalGrandFatherCell.setCellValue(maternalGrandFatherValue);
maternalGrandFatherCell.setCellStyle(contentStyle);
sheet.addMergedRegion(new CellRangeAddress(
pedigreeStartRow + 6,
pedigreeStartRow + 8,
3,
5
));
// ========== 7. 外祖母耳号第4-6列合并10-12行 ==========
Row maternalGrandMotherRow = sheet.getRow(pedigreeStartRow + 9);
Cell maternalGrandMotherCell = maternalGrandMotherRow.createCell(3);
String maternalGrandMotherValue = pedigree.getMaternalGrandmotherManageTags() != null && !pedigree.getMaternalGrandmotherManageTags().isEmpty()
? "外祖母耳号:" + pedigree.getMaternalGrandmotherManageTags()
: "外祖母耳号:无";
maternalGrandMotherCell.setCellValue(maternalGrandMotherValue);
maternalGrandMotherCell.setCellStyle(contentStyle);
sheet.addMergedRegion(new CellRangeAddress(
pedigreeStartRow + 9,
pedigreeStartRow + 11,
3,
5
));
// 更新rowNum到系谱区块结束行+1
rowNum = pedigreeStartRow + pedigreeTotalRows;
}
// ========== 4. 输出Excel ==========
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("羊只系谱_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
OutputStream os = response.getOutputStream();
workbook.write(os);
os.flush();
os.close();
workbook.close();
}
// ========== 新增:填充整行边框的工具方法 ==========
private void fillRowWithBorder(Row row, int startCol, int endCol, CellStyle borderStyle) {
for (int col = startCol; col <= endCol; col++) {
Cell cell = row.getCell(col);
if (cell == null) {
cell = row.createCell(col);
}
// 仅当单元格无样式时设置边框样式(避免覆盖已有内容样式)
if (cell.getCellStyle() == null || cell.getCellStyle().getBorderTop() == BorderStyle.NONE) {
cell.setCellStyle(borderStyle);
}
}
}
// ========== 样式定义 ==========
private static CellStyle createTitleStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
Font font = workbook.createFont();
font.setFontName("微软雅黑");
font.setFontHeightInPoints((short) 16);
font.setBold(true);
style.setFont(font);
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 标题样式带完整边框
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
return style;
}
private static CellStyle createBlockTitleStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
Font font = workbook.createFont();
font.setFontName("微软雅黑");
font.setFontHeightInPoints((short) 14);
font.setBold(true);
style.setFont(font);
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
// 区块标题带完整边框
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
return style;
}
private static CellStyle createContentStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
Font font = workbook.createFont();
font.setFontName("微软雅黑");
font.setFontHeightInPoints((short) 12);
style.setFont(font);
style.setAlignment(HorizontalAlignment.LEFT);
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 内容样式带完整边框
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
return style;
}
// 新增:纯边框样式(用于空单元格)
private static CellStyle createBorderStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
// 仅设置边框,无字体/背景色(避免覆盖内容样式)
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setAlignment(HorizontalAlignment.LEFT);
style.setVerticalAlignment(VerticalAlignment.CENTER);
return style;
}
// 性别数字转文字
private static String getGenderText(Long gender) {
if (gender == null) return "";
switch (gender.intValue()) {
case 1: return "";
case 2: return "";
case 3: return "阉羊";
case 4: return "兼性";
default: return "";
}
}
}

View File

@@ -78,8 +78,7 @@ public class DewormController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody Deworm deworm)
{
deworm.setDeptId(getDeptId());
deworm.setUserId(getUserId());
System.out.println(deworm);
return toAjax(dewormService.insertDeworm(deworm));
}

View File

@@ -77,8 +77,6 @@ public class DiagnosisController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody Diagnosis diagnosis)
{
diagnosis.setDeptId(getDeptId());
diagnosis.setUserId(getUserId());
return toAjax(diagnosisService.insertDiagnosis(diagnosis));
}

View File

@@ -78,8 +78,6 @@ public class DisinfectController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody Disinfect disinfect)
{
disinfect.setDeptId(getDeptId());
disinfect.setUserId(getUserId());
return toAjax(disinfectService.insertDisinfect(disinfect));
}

View File

@@ -79,8 +79,6 @@ public class HealthController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody Health health)
{
health.setDeptId(getDeptId());
health.setUserId(getUserId());
return toAjax(healthService.insertHealth(health));
}

View File

@@ -78,8 +78,6 @@ public class ImmunityController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody Immunity immunity)
{
immunity.setDeptId(getDeptId());
immunity.setUserId(getUserId());
return toAjax(immunityService.insertImmunity(immunity));
}

View File

@@ -78,8 +78,6 @@ public class QuarantineReportController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody QuarantineReport quarantineReport)
{
quarantineReport.setDeptId(getDeptId());
quarantineReport.setUserId(getUserId());
return toAjax(quarantineReportService.insertQuarantineReport(quarantineReport));
}

View File

@@ -84,8 +84,6 @@ public class SwMedicineUsageController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SwMedicineUsage swMedicineUsage)
{
swMedicineUsage.setDeptId(getDeptId());
swMedicineUsage.setUserId(getUserId());
return toAjax(swMedicineUsageService.insertSwMedicineUsage(swMedicineUsage));
}

View File

@@ -78,8 +78,6 @@ public class TreatmentController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody Treatment treatment)
{
treatment.setDeptId(getDeptId());
treatment.setUserId(getUserId());
return toAjax(treatmentService.insertTreatment(treatment));
}

View File

@@ -54,8 +54,7 @@ public class Deworm extends BaseEntity
@Excel(name = "胎次")
private Long parity;
private Long userId;
private Long deptId;
/** 药品使用记录 */
@Excel(name = "药品使用记录")
@@ -82,5 +81,4 @@ public class Deworm extends BaseEntity
// 排序查询
private String orderByColumn;
private String isAsc;
}

View File

@@ -106,9 +106,6 @@ public class Diagnosis extends BaseEntity
private String orderByColumn;
private String isAsc;
private Long userId;
private Long deptId;
public void setGender(String gender) {
this.gender = gender;
if (gender != null && !gender.trim().isEmpty()) {

View File

@@ -61,9 +61,6 @@ public class Disinfect extends BaseEntity
/** 药品名称用于查询*/
private String mediName;
private Long userId;
private Long deptId;
// 药品使用
private List<SwMedicineUsageDetails> usageDetails;

View File

@@ -69,9 +69,6 @@ public class Health extends BaseEntity
@Excel(name = "备注")
private String comment;
private Long userId;
private Long deptId;
// 药品使用
private List<SwMedicineUsageDetails> usageDetails;

View File

@@ -78,9 +78,6 @@ public class Immunity extends BaseEntity
@Excel(name = "备注")
private String comment;
private Long userId;
private Long deptId;
// 药品使用
private List<SwMedicineUsageDetails> usageDetails;

View File

@@ -42,12 +42,6 @@ public class QuarantineReport extends BaseEntity
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
@Excel(name = "品种")
private String variety;
/** 检疫日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "检疫日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
@Excel(name = "羊只类别")
private String sheepType;
@@ -62,7 +56,10 @@ public class QuarantineReport extends BaseEntity
private String breed;
/** 检疫日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "检疫日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
/** 检疫项目 */
@@ -101,22 +98,9 @@ public class QuarantineReport extends BaseEntity
@Excel(name = "备注")
private String comment;
private Long userId;
private Long deptId;
public void setGender(String gender) {
this.gender = gender;
if (gender != null && !gender.trim().isEmpty()) {
try {
Integer genderCode = Integer.valueOf(gender.trim());
this.genderName = Gender.getDescByCode(genderCode);
} catch (NumberFormatException e) {
// 如果转换失败,设置为空或默认值
this.genderName = null;
}
} else {
this.genderName = null;
}
this.genderName = Gender.getDescByCode(Integer.valueOf(gender));
}
// 排序查询

View File

@@ -53,9 +53,6 @@ public class SwMedicineUsage extends BaseEntity
@Excel(name = "使用类型",width = 20, needMerge = true)
private String useType;
private Long userId;
private Long deptId;
/** 药品使用记录详情信息 */
@Excel
private List<SwMedicineUsageDetails> swMedicineUsageDetailsList;

View File

@@ -104,9 +104,6 @@ public class Treatment extends BaseEntity
@Excel(name = "药品使用记录id")
private Integer usageId;
private Long userId;
private Long deptId;
// 药品使用
private List<SwMedicineUsageDetails> usageDetails;

View File

@@ -3,8 +3,6 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
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.bean.BeanUtils;
@@ -60,7 +58,6 @@ public class DewormServiceImpl implements IDewormService
* @return 驱虫
*/
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Deworm> selectDewormList(Deworm deworm)
{
String[] sheepNos = null;

View File

@@ -4,7 +4,6 @@ import java.util.Date;
import java.util.List;
import java.util.Objects;
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;
@@ -61,7 +60,6 @@ public class DiagnosisServiceImpl implements IDiagnosisService
* @return 诊疗结果
*/
@Override
@DataScope(deptAlias = "sd", userAlias = "sd")
public List<Diagnosis> selectDiagnosisList(Diagnosis diagnosis)
{
String[] sheepNos = null;

View File

@@ -2,8 +2,6 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList;
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.bean.BeanUtils;
@@ -61,7 +59,6 @@ public class DisinfectServiceImpl implements IDisinfectService
* @return 消毒记录
*/
@Override
@DataScope(deptAlias = "sd", userAlias = "sd")
public List<Disinfect> selectDisinfectList(Disinfect disinfect)
{
return disinfectMapper.selectDisinfectList(disinfect);

View File

@@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils;
@@ -63,7 +62,6 @@ public class HealthServiceImpl implements IHealthService
* @return 保健
*/
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Health> selectHealthList(Health health)
{
String[] sheepNos = null;

View File

@@ -2,8 +2,6 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList;
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.bean.BeanUtils;
@@ -63,7 +61,6 @@ public class ImmunityServiceImpl implements IImmunityService
* @return 免疫
*/
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Immunity> selectImmunityList(Immunity immunity)
{
String[] sheepNos = null;

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.biosafety.domain.QuarantineItems;
import com.zhyc.module.biosafety.mapper.QuarantineItemsMapper;
import com.zhyc.module.biosafety.service.IQuarantineItemsService;

View File

@@ -2,8 +2,6 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList;
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.bean.BeanUtils;
@@ -48,7 +46,6 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
* @return 检疫记录
*/
@Override
@DataScope(deptAlias = "sqr", userAlias = "sqr")
public List<QuarantineReport> selectQuarantineReportList(QuarantineReport quarantineReport)
{
String[] sheepNos = null;
@@ -85,7 +82,6 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
BeanUtils.copyProperties(quarantineReport, quarantine);
quarantine.setSheepId(sheepFile.getId());
quarantine.setSheepNo(sheepFile.getElectronicTags());
quarantine.setVariety(sheepFile.getVariety() != null ? sheepFile.getVariety() : "");
quarantine.setSheepType(sheepFile.getName());
// 性别前端处理

View File

@@ -1,8 +1,6 @@
package com.zhyc.module.biosafety.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.biosafety.service.ISwMedicineUsageService;
@@ -46,7 +44,6 @@ public class SwMedicineUsageServiceImpl implements ISwMedicineUsageService
* @return 药品使用记录
*/
@Override
@DataScope(deptAlias = "smu", userAlias = "smu")
public List<SwMedicineUsage> selectSwMedicineUsageList(SwMedicineUsage swMedicineUsage)
{
String[] sheepNos = null;

View File

@@ -2,8 +2,6 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList;
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.bean.BeanUtils;
@@ -67,7 +65,6 @@ public class TreatmentServiceImpl implements ITreatmentService
* @return 治疗记录
*/
@Override
@DataScope(deptAlias = "t", userAlias = "t")
public List<Treatment> selectTreatmentList(Treatment treatment)
{
String[] sheepNos = null;

View File

@@ -26,9 +26,7 @@ public class UserPostController {
// 根据岗位编码获取用户
@GetMapping("/getUser")
public AjaxResult getUserPost(String postCode){
User user = new User();
user.setPostCode(postCode);
List<User> list = userService.getUserListByCode(user);
List<User> list = userService.getUserListByCode(postCode);
return AjaxResult.success(list);
}

View File

@@ -1,22 +0,0 @@
package com.zhyc.module.common.domain;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Dept extends BaseEntity {
private Long deptId;
private Long parentId;
private String ancestors;
private String deptName;
private String orderNum;
private String leader;
private String phone;
private String email;
private String status;
private String delFlag;
}

View File

@@ -1,7 +1,6 @@
package com.zhyc.module.common.domain;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -9,7 +8,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Post extends BaseEntity {
public class Post {
/** 岗位序号 */
@Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC)

View File

@@ -1,6 +1,5 @@
package com.zhyc.module.common.domain;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -8,10 +7,9 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User extends BaseEntity {
public class User {
// 用户id
private Long userId;
private Long deptId;
private String userId;
// 用户名
private String nickName;
// 岗位名称
@@ -19,5 +17,4 @@ public class User extends BaseEntity {
// 岗位编码
private String postCode;
}

View File

@@ -1,15 +0,0 @@
package com.zhyc.module.common.mapper;
import com.zhyc.module.common.domain.Dept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface DeptMapper {
/**
* 根据部门ID查询其所属二级部门排除根部门
*/
Dept selectTopSecondLevelDept(Long deptId);
}

View File

@@ -8,5 +8,5 @@ import java.util.List;
@Mapper
public interface UserMapper {
List<User> getUserListByCode(User user);
List<User> getUserListByCode(String postCode);
}

View File

@@ -5,5 +5,5 @@ import com.zhyc.module.common.domain.User;
import java.util.List;
public interface UserService {
List<User> getUserListByCode(User postCode);
List<User> getUserListByCode(String postCode);
}

View File

@@ -1,10 +1,6 @@
package com.zhyc.module.common.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.common.domain.Dept;
import com.zhyc.module.common.domain.User;
import com.zhyc.module.common.mapper.DeptMapper;
import com.zhyc.module.common.mapper.UserMapper;
import com.zhyc.module.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -16,16 +12,9 @@ import java.util.List;
public class UserPostServiceImpl implements UserService {
@Autowired
UserMapper userMapper;
@Autowired
DeptMapper deptMapper;
@Override
public List<User> getUserListByCode(User user) {
Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
Dept secondLevel = deptMapper.selectTopSecondLevelDept(deptId);
user.setDeptId(secondLevel.getDeptId());
System.out.println(secondLevel);
return userMapper.getUserListByCode(user);
public List<User> getUserListByCode(String postCode) {
return userMapper.getUserListByCode(postCode);
}
}

View File

@@ -23,7 +23,8 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 鲜奶生产成品检验记录Controller
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-18
*/
@RestController
@@ -76,11 +77,6 @@ public class NpFreshMilkInspController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody NpFreshMilkInsp npFreshMilkInsp)
{
// === 修改开始注入当前用户和部门ID ===
npFreshMilkInsp.setUserId(getUserId());
npFreshMilkInsp.setDeptId(getDeptId());
// === 修改结束 ===
return toAjax(npFreshMilkInspService.insertNpFreshMilkInsp(npFreshMilkInsp));
}
@@ -100,9 +96,9 @@ public class NpFreshMilkInspController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('freshMilkTest:freshMilkTest:remove')")
@Log(title = "鲜奶生产,成品检验记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(npFreshMilkInspService.deleteNpFreshMilkInspByIds(ids));
}
}
}

View File

@@ -28,10 +28,11 @@ public class NpMilkProdClassesController extends BaseController {
public TableDataInfo list(
@RequestParam(required = false) Date datetimeStart,
@RequestParam(required = false) Date datetimeEnd,
@RequestParam(required = false) List<String> allEarNumbers,
@RequestParam(required = false) List<String> allEarNumbers, // 修改处:接收多耳号数组
@RequestParam(required = false) String factory,
@RequestParam(required = false) Integer classes) {
startPage();
// 修改处:将参数封装进实体,以便 Service 和 Mapper 统一处理
NpMilkProdClasses params = new NpMilkProdClasses();
params.setAllEarNumbers(allEarNumbers);
params.setFactory(factory);
@@ -42,6 +43,9 @@ public class NpMilkProdClassesController extends BaseController {
return getDataTable(list);
}
/**
* 修改处:新增耳号模糊查询接口
*/
@PreAuthorize("@ss.hasPermi('milkProdclasses:milkProdclasses:list')")
@GetMapping("/search_ear_numbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
@@ -60,16 +64,6 @@ public class NpMilkProdClassesController extends BaseController {
try {
ExcelUtil<NpMilkProdClasses> util = new ExcelUtil<>(NpMilkProdClasses.class);
List<NpMilkProdClasses> list = util.importExcel(file.getInputStream());
// === 修改开始循环注入当前用户和部门ID ===
Long userId = getUserId();
Long deptId = getDeptId();
for (NpMilkProdClasses item : list) {
item.setUserId(userId);
item.setDeptId(deptId);
}
// === 修改结束 ===
int rows = npMilkProdClassesService.importMilkProdClasses(list);
return success("成功导入 " + rows + " 行数据");
} catch (Exception e) {
@@ -83,7 +77,7 @@ public class NpMilkProdClassesController extends BaseController {
public void export(HttpServletResponse response,
@RequestParam(required = false) Date datetimeStart,
@RequestParam(required = false) Date datetimeEnd,
@RequestParam(required = false) List<String> allEarNumbers,
@RequestParam(required = false) List<String> allEarNumbers, // 修改处:接收多耳号
@RequestParam(required = false) String factory,
@RequestParam(required = false) Integer classes) {

View File

@@ -24,7 +24,8 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 生乳检验记录Controller
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-15
*/
@RestController
@@ -77,11 +78,6 @@ public class NpRawMilkInspeController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody NpRawMilkInspe npRawMilkInspe)
{
// === 修改开始注入当前用户和部门ID ===
npRawMilkInspe.setUserId(getUserId());
npRawMilkInspe.setDeptId(getDeptId());
// === 修改结束 ===
return toAjax(npRawMilkInspeService.insertNpRawMilkInspe(npRawMilkInspe));
}
@@ -101,9 +97,9 @@ public class NpRawMilkInspeController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('rawMilkTest:rawMilkTest:remove')")
@Log(title = "生乳检验记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(npRawMilkInspeService.deleteNpRawMilkInspeByIds(ids));
}
}
}

View File

@@ -24,7 +24,8 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 酸奶生产成品检疫记录Controller
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-17
*/
@RestController
@@ -77,11 +78,6 @@ public class NpYogurtInspController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody NpYogurtInsp npYogurtInsp)
{
// === 修改开始注入当前用户和部门ID ===
npYogurtInsp.setUserId(getUserId());
npYogurtInsp.setDeptId(getDeptId());
// === 修改结束 ===
return toAjax(npYogurtInspService.insertNpYogurtInsp(npYogurtInsp));
}
@@ -101,9 +97,9 @@ public class NpYogurtInspController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('yogurtTest:yogurtTest:remove')")
@Log(title = "酸奶生产,成品检疫记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(npYogurtInspService.deleteNpYogurtInspByIds(ids));
}
}
}

View File

@@ -23,7 +23,8 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 干物质校正Controller
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-12
*/
@RestController
@@ -76,9 +77,6 @@ public class XzDryMatterCorrectionController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody XzDryMatterCorrection xzDryMatterCorrection)
{
// 自动填充用户ID和部门ID
xzDryMatterCorrection.setUserId(getUserId());
xzDryMatterCorrection.setDeptId(getDeptId());
return toAjax(xzDryMatterCorrectionService.insertXzDryMatterCorrection(xzDryMatterCorrection));
}
@@ -98,9 +96,9 @@ public class XzDryMatterCorrectionController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('dryMatterCorrection:dryMatterCorrection:remove')")
@Log(title = "干物质校正", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(xzDryMatterCorrectionService.deleteXzDryMatterCorrectionByIds(ids));
}
}
}

View File

@@ -24,7 +24,8 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 称重校正Controller
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-12
*/
@RestController
@@ -77,9 +78,6 @@ public class XzWegihCorrectionController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody XzWegihCorrection xzWegihCorrection)
{
// 自动填充用户ID和部门ID
xzWegihCorrection.setUserId(getUserId());
xzWegihCorrection.setDeptId(getDeptId());
return toAjax(xzWegihCorrectionService.insertXzWegihCorrection(xzWegihCorrection));
}
@@ -99,9 +97,9 @@ public class XzWegihCorrectionController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('weightCorrection:weightCorrection:remove')")
@Log(title = "称重校正", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(xzWegihCorrectionService.deleteXzWegihCorrectionByIds(ids));
}
}
}

View File

@@ -10,7 +10,8 @@ import com.zhyc.common.core.domain.BaseEntity;
/**
* 鲜奶生产,成品检验记录对象 np_fresh_milk_insp
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-18
*/
@Data
@@ -84,12 +85,4 @@ public class NpFreshMilkInsp extends BaseEntity
@Excel(name = "备注")
private String commnet;
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
}

View File

@@ -65,14 +65,6 @@ public class NpMilkInOutStore extends BaseEntity {
@Excel(name = "爱特退回酸奶")
private BigDecimal returnYogurt;
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
// --- getters and setters ---
public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; }
@@ -133,10 +125,4 @@ public class NpMilkInOutStore extends BaseEntity {
public BigDecimal getReturnYogurt() { return returnYogurt; }
public void setReturnYogurt(BigDecimal returnYogurt) { this.returnYogurt = returnYogurt; }
public Long getUserId() { return userId; }
public void setUserId(Long userId) { this.userId = userId; }
public Long getDeptId() { return deptId; }
public void setDeptId(Long deptId) { this.deptId = deptId; }
}

View File

@@ -2,7 +2,7 @@ package com.zhyc.module.dairyProducts.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.List; // 引入 List
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.common.annotation.Excel;
@@ -40,19 +40,11 @@ public class NpMilkProdClasses implements Serializable {
private String sheepId;
// 修改处:新增字段用于多耳号查询
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
// --- Getters and Setters ---
// Getters and Setters
public List<String> getAllEarNumbers() {
return allEarNumbers;
}
@@ -96,10 +88,4 @@ public class NpMilkProdClasses implements Serializable {
public String getSheepId() { return sheepId; }
public void setSheepId(String sheepId) { this.sheepId = sheepId; }
public Long getUserId() { return userId; }
public void setUserId(Long userId) { this.userId = userId; }
public Long getDeptId() { return deptId; }
public void setDeptId(Long deptId) { this.deptId = deptId; }
}

View File

@@ -451,12 +451,4 @@ public class NpRawMilkInspe extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
}

View File

@@ -10,7 +10,8 @@ import com.zhyc.common.core.domain.BaseEntity;
/**
* 酸奶生产,成品检疫记录对象 np_yogurt_insp
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-17
*/
@Data
@@ -41,7 +42,7 @@ public class NpYogurtInsp extends BaseEntity
private Double protein;
/** 非脂g/100g
*/
*/
@Excel(name = "非脂g/100g")
private Double nonFat;
@@ -85,12 +86,4 @@ public class NpYogurtInsp extends BaseEntity
@Excel(name = "备注")
private String comment;
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
}
}

View File

@@ -32,9 +32,4 @@ public class XzDryMatterCorrection extends BaseEntity {
@Excel(name = "干物质系数")
private Double coefficient;
/** 用户ID */
private Long userId;
/** 部门ID */
private Long deptId;
}

View File

@@ -45,9 +45,5 @@ public class XzWegihCorrection extends BaseEntity
@Excel(name = "称重系数")
private Double coefficient;
/** 用户ID */
private Long userId;
/** 部门ID */
private Long deptId;
}

View File

@@ -8,49 +8,16 @@ import java.util.List;
import java.util.Map;
public interface NpMilkInOutStoreMapper {
/**
* 动态列查询
*/
List<Map<String,Object>> selectWithColumns(
@Param("start") Date start, @Param("end") Date end,
@Param("feedSources") List<String> feedSources,
@Param("saleDestinations") List<String> saleDestinations
);
/**
* 插入主表
*/
int insertStore(NpMilkInOutStore store);
void insertFeedRecord(@Param("storeId") Integer storeId, @Param("source") String source, @Param("amount") java.math.BigDecimal amount);
void insertSaleRecord(@Param("storeId") Integer storeId, @Param("destination") String dest, @Param("amount") java.math.BigDecimal amount);
/**
* 插入饲喂子表(已修正:增加 userId 和 deptId 参数)
*/
void insertFeedRecord(
@Param("storeId") Integer storeId,
@Param("source") String source,
@Param("amount") java.math.BigDecimal amount,
@Param("userId") Long userId,
@Param("deptId") Long deptId
);
/**
* 插入销售子表(已修正:增加 userId 和 deptId 参数)
*/
void insertSaleRecord(
@Param("storeId") Integer storeId,
@Param("destination") String dest,
@Param("amount") java.math.BigDecimal amount,
@Param("userId") Long userId,
@Param("deptId") Long deptId
);
/**
* 获取饲喂来源列表(用于动态列头)
*/
List<String> selectFeedSources();
/**
* 获取销售去向列表(用于动态列头)
*/
List<String> selectSaleDestinations();
}
}

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.dairyProducts.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.dairyProducts.mapper.NpFreshMilkInspMapper;
@@ -11,18 +10,20 @@ import com.zhyc.module.dairyProducts.service.INpFreshMilkInspService;
/**
* 鲜奶生产成品检验记录Service业务层处理
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-18
*/
@Service
public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
{
@Autowired
private NpFreshMilkInspMapper npFreshMilkInspMapper;
/**
* 查询鲜奶生产,成品检验记录
* * @param id 鲜奶生产,成品检验记录主键
*
* @param id 鲜奶生产,成品检验记录主键
* @return 鲜奶生产,成品检验记录
*/
@Override
@@ -33,11 +34,11 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 查询鲜奶生产,成品检验记录列表
* * @param npFreshMilkInsp 鲜奶生产,成品检验记录
*
* @param npFreshMilkInsp 鲜奶生产,成品检验记录
* @return 鲜奶生产,成品检验记录
*/
@Override
@DataScope(deptAlias = "a", userAlias = "a")
public List<NpFreshMilkInsp> selectNpFreshMilkInspList(NpFreshMilkInsp npFreshMilkInsp)
{
return npFreshMilkInspMapper.selectNpFreshMilkInspList(npFreshMilkInsp);
@@ -45,7 +46,8 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 新增鲜奶生产,成品检验记录
* * @param npFreshMilkInsp 鲜奶生产,成品检验记录
*
* @param npFreshMilkInsp 鲜奶生产,成品检验记录
* @return 结果
*/
@Override
@@ -57,7 +59,8 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 修改鲜奶生产,成品检验记录
* * @param npFreshMilkInsp 鲜奶生产,成品检验记录
*
* @param npFreshMilkInsp 鲜奶生产,成品检验记录
* @return 结果
*/
@Override
@@ -68,7 +71,8 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 批量删除鲜奶生产,成品检验记录
* * @param ids 需要删除的鲜奶生产,成品检验记录主键
*
* @param ids 需要删除的鲜奶生产,成品检验记录主键
* @return 结果
*/
@Override
@@ -79,7 +83,8 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 删除鲜奶生产,成品检验记录信息
* * @param id 鲜奶生产,成品检验记录主键
*
* @param id 鲜奶生产,成品检验记录主键
* @return 结果
*/
@Override
@@ -87,4 +92,4 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
{
return npFreshMilkInspMapper.deleteNpFreshMilkInspById(id);
}
}
}

View File

@@ -1,7 +1,5 @@
package com.zhyc.module.dairyProducts.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.dairyProducts.domain.NpMilkInOutStore;
import com.zhyc.module.dairyProducts.mapper.NpMilkInOutStoreMapper;
import com.zhyc.module.dairyProducts.service.INpMilkInOutStoreService;
@@ -21,7 +19,6 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
private NpMilkInOutStoreMapper mapper;
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Map<String, Object>> selectWithDynamicColumns(Date start, Date end) {
List<String> feed = mapper.selectFeedSources();
List<String> sale = mapper.selectSaleDestinations();
@@ -61,46 +58,25 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
@Override
public void batchInsertFromRows(List<Map<String, Object>> rows) throws Exception {
// === 修改开始获取当前用户和部门ID ===
Long userId = SecurityUtils.getUserId();
Long deptId = SecurityUtils.getDeptId();
// === 修改结束 ===
for (Map<String,Object> row : rows) {
// 提取主表字段
NpMilkInOutStore store = new NpMilkInOutStore();
// 这里假设 Excel 中的"日期"格式是标准的 yyyy-MM-dd如果格式不对可能会报错建议加 try-catch 或格式化处理
store.setDatetime(java.sql.Date.valueOf(row.get("日期").toString()));
store.setNum(Integer.valueOf(row.get("羊数").toString()));
// 手动填充其它主表字段,这里省略了具体的 get 调用,请根据您的 Excel 列名自行补充
// store.setColostSheep(...);
// === 修改开始给主表实体注入用户和部门ID ===
store.setUserId(userId);
store.setDeptId(deptId);
// === 修改结束 ===
// ... 设置其它固定字段 ...
mapper.insertStore(store);
Integer sid = store.getId();
// 其余列为动态饲喂或销售,根据字典决定分类:
for (Map.Entry<String,Object> ent: row.entrySet()) {
String col = ent.getKey();
// 跳过固定列
if (col.equals("日期") || col.equals("羊数") || col.equals("id")) continue;
if (ent.getValue() == null || "".equals(ent.getValue().toString())) continue;
BigDecimal amt = new BigDecimal(ent.getValue().toString());
if (mapper.selectFeedSources().contains(col)) {
// === 修改开始:插入饲喂子表时传入 userId 和 deptId ===
mapper.insertFeedRecord(sid, col, amt, userId, deptId);
mapper.insertFeedRecord(sid, col, amt);
} else if (mapper.selectSaleDestinations().contains(col)) {
// === 修改开始:插入销售子表时传入 userId 和 deptId ===
mapper.insertSaleRecord(sid, col, amt, userId, deptId);
mapper.insertSaleRecord(sid, col, amt);
}
}
}
}
}
}

View File

@@ -1,6 +1,5 @@
package com.zhyc.module.dairyProducts.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.dairyProducts.domain.NpMilkProdClasses;
import com.zhyc.module.dairyProducts.mapper.NpMilkProdClassesMapper;
import com.zhyc.module.dairyProducts.service.INpMilkProdClassesService;
@@ -17,7 +16,6 @@ public class NpMilkProdClassesServiceImpl implements INpMilkProdClassesService {
private NpMilkProdClassesMapper mapper;
@Override
@DataScope(deptAlias = "mpc", userAlias = "mpc")
public List<NpMilkProdClasses> selectNpMilkProdClassesList(NpMilkProdClasses npMilkProdClasses, Date datetimeStart, Date datetimeEnd) {
// 修改处:传递实体对象
return mapper.selectNpMilkProdClassesList(npMilkProdClasses, datetimeStart, datetimeEnd);

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.dairyProducts.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.dairyProducts.mapper.NpRawMilkInspeMapper;
@@ -11,18 +10,20 @@ import com.zhyc.module.dairyProducts.service.INpRawMilkInspeService;
/**
* 生乳检验记录Service业务层处理
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-15
*/
@Service
public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
{
@Autowired
private NpRawMilkInspeMapper npRawMilkInspeMapper;
/**
* 查询生乳检验记录
* * @param id 生乳检验记录主键
*
* @param id 生乳检验记录主键
* @return 生乳检验记录
*/
@Override
@@ -33,11 +34,11 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 查询生乳检验记录列表
* * @param npRawMilkInspe 生乳检验记录
*
* @param npRawMilkInspe 生乳检验记录
* @return 生乳检验记录
*/
@Override
@DataScope(deptAlias = "a", userAlias = "a")
public List<NpRawMilkInspe> selectNpRawMilkInspeList(NpRawMilkInspe npRawMilkInspe)
{
return npRawMilkInspeMapper.selectNpRawMilkInspeList(npRawMilkInspe);
@@ -45,7 +46,8 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 新增生乳检验记录
* * @param npRawMilkInspe 生乳检验记录
*
* @param npRawMilkInspe 生乳检验记录
* @return 结果
*/
@Override
@@ -57,7 +59,8 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 修改生乳检验记录
* * @param npRawMilkInspe 生乳检验记录
*
* @param npRawMilkInspe 生乳检验记录
* @return 结果
*/
@Override
@@ -68,7 +71,8 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 批量删除生乳检验记录
* * @param ids 需要删除的生乳检验记录主键
*
* @param ids 需要删除的生乳检验记录主键
* @return 结果
*/
@Override
@@ -79,7 +83,8 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 删除生乳检验记录信息
* * @param id 生乳检验记录主键
*
* @param id 生乳检验记录主键
* @return 结果
*/
@Override
@@ -87,4 +92,4 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
{
return npRawMilkInspeMapper.deleteNpRawMilkInspeById(id);
}
}
}

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.dairyProducts.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.dairyProducts.domain.NpYogurtInsp;
import com.zhyc.module.dairyProducts.mapper.NpYogurtInspMapper;
import com.zhyc.module.dairyProducts.service.INpYogurtInspService;
@@ -11,7 +10,8 @@ import org.springframework.stereotype.Service;
/**
* 酸奶生产成品检疫记录Service业务层处理
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-17
*/
@Service
@@ -22,7 +22,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 查询酸奶生产,成品检疫记录
* * @param id 酸奶生产,成品检疫记录主键
*
* @param id 酸奶生产,成品检疫记录主键
* @return 酸奶生产,成品检疫记录
*/
@Override
@@ -33,11 +34,11 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 查询酸奶生产,成品检疫记录列表
* * @param npYogurtInsp 酸奶生产,成品检疫记录
*
* @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 酸奶生产,成品检疫记录
*/
@Override
@DataScope(deptAlias = "a", userAlias = "a")
public List<NpYogurtInsp> selectNpYogurtInspList(NpYogurtInsp npYogurtInsp)
{
return npYogurtInspMapper.selectNpYogurtInspList(npYogurtInsp);
@@ -45,7 +46,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 新增酸奶生产,成品检疫记录
* * @param npYogurtInsp 酸奶生产,成品检疫记录
*
* @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 结果
*/
@Override
@@ -57,7 +59,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 修改酸奶生产,成品检疫记录
* * @param npYogurtInsp 酸奶生产,成品检疫记录
*
* @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 结果
*/
@Override
@@ -68,7 +71,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 批量删除酸奶生产,成品检疫记录
* * @param ids 需要删除的酸奶生产,成品检疫记录主键
*
* @param ids 需要删除的酸奶生产,成品检疫记录主键
* @return 结果
*/
@Override
@@ -79,7 +83,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 删除酸奶生产,成品检疫记录信息
* * @param id 酸奶生产,成品检疫记录主键
*
* @param id 酸奶生产,成品检疫记录主键
* @return 结果
*/
@Override
@@ -87,4 +92,4 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
{
return npYogurtInspMapper.deleteNpYogurtInspById(id);
}
}
}

View File

@@ -6,22 +6,23 @@ import org.springframework.stereotype.Service;
import com.zhyc.module.dairyProducts.mapper.XzDryMatterCorrectionMapper;
import com.zhyc.module.dairyProducts.domain.XzDryMatterCorrection;
import com.zhyc.module.dairyProducts.service.IXzDryMatterCorrectionService;
import com.zhyc.common.annotation.DataScope; // 引入数据权限注解
/**
* 干物质校正Service业务层处理
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-12
*/
@Service
public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionService
public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionService
{
@Autowired
private XzDryMatterCorrectionMapper xzDryMatterCorrectionMapper;
/**
* 查询干物质校正
* * @param id 干物质校正主键
*
* @param id 干物质校正主键
* @return 干物质校正
*/
@Override
@@ -32,11 +33,11 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/**
* 查询干物质校正列表
* * @param xzDryMatterCorrection 干物质校正
*
* @param xzDryMatterCorrection 干物质校正
* @return 干物质校正
*/
@Override
@DataScope(deptAlias = "d", userAlias = "d") // 添加数据权限注解
public List<XzDryMatterCorrection> selectXzDryMatterCorrectionList(XzDryMatterCorrection xzDryMatterCorrection)
{
return xzDryMatterCorrectionMapper.selectXzDryMatterCorrectionList(xzDryMatterCorrection);
@@ -101,7 +102,8 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/**
* 批量删除干物质校正
* * @param ids 需要删除的干物质校正主键
*
* @param ids 需要删除的干物质校正主键
* @return 结果
*/
@Override
@@ -112,7 +114,8 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/**
* 删除干物质校正信息
* * @param id 干物质校正主键
*
* @param id 干物质校正主键
* @return 结果
*/
@Override
@@ -120,4 +123,4 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
{
return xzDryMatterCorrectionMapper.deleteXzDryMatterCorrectionById(id);
}
}
}

View File

@@ -8,13 +8,13 @@ import com.zhyc.common.exception.ServiceException;
import com.zhyc.module.dairyProducts.domain.XzWegihCorrection;
import com.zhyc.module.dairyProducts.mapper.XzWegihCorrectionMapper;
import com.zhyc.module.dairyProducts.service.IXzWegihCorrectionService;
import com.zhyc.common.annotation.DataScope; // 引入数据权限注解
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 称重校正Service业务层处理
* * @author ruoyi
*
* @author ruoyi
* @date 2025-07-12
*/
@Service
@@ -25,7 +25,8 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/**
* 查询称重校正
* * @param id 称重校正主键
*
* @param id 称重校正主键
* @return 称重校正
*/
@Override
@@ -36,11 +37,11 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/**
* 查询称重校正列表
* * @param xzWegihCorrection 称重校正
*
* @param xzWegihCorrection 称重校正
* @return 称重校正
*/
@Override
@DataScope(deptAlias = "w", userAlias = "w") // 添加数据权限注解
public List<XzWegihCorrection> selectXzWegihCorrectionList(XzWegihCorrection xzWegihCorrection)
{
return xzWegihCorrectionMapper.selectXzWegihCorrectionList(xzWegihCorrection);
@@ -105,7 +106,8 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/**
* 批量删除称重校正
* * @param ids 需要删除的称重校正主键
*
* @param ids 需要删除的称重校正主键
* @return 结果
*/
@Override
@@ -116,7 +118,8 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/**
* 删除称重校正信息
* * @param id 称重校正主键
*
* @param id 称重校正主键
* @return 结果
*/
@Override
@@ -124,4 +127,4 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
{
return xzWegihCorrectionMapper.deleteXzWegihCorrectionById(id);
}
}
}

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.feed.service.impl.SgFeedListServiceImpl;
@@ -39,7 +40,7 @@ public class SgFeedListController extends BaseController {
private final ISgFeedListService sgFeedListService;
public static boolean refresh = true;
public static final AtomicBoolean refresh = new AtomicBoolean(true);
@Autowired
public SgFeedListController(ISgFeedListService sgFeedListService) {
@@ -57,9 +58,8 @@ public class SgFeedListController extends BaseController {
刷新缓存
当配方管理表出现更新 或 饲喂计划表出现增删改时会将refresh置为true 通知此处进行刷新
*/
if (refresh) {
sgFeedListService.SyncFeedList();
refresh = false;
if (refresh.compareAndSet(true, false)) {
sgFeedListService.syncFeedListSafely();
}
startPage();
List<SgFeedList> list = sgFeedListService.selectSgFeedListList(sgFeedList);
@@ -109,8 +109,6 @@ public class SgFeedListController extends BaseController {
@Log(title = "配料清单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SgFeedList sgFeedList) {
sgFeedList.setDeptId(getDeptId());
sgFeedList.setUserId(getUserId());
return toAjax(sgFeedListService.insertSgFeedList(sgFeedList));
}

View File

@@ -79,13 +79,11 @@ public class SgFeedPlanController extends BaseController {
if (null == sgFeedPlan) {
throw new RuntimeException("数据为空");
}
sgFeedPlan.setDeptId(getDeptId());
sgFeedPlan.setUserId(getUserId());
sgFeedPlan.setCreateDate(new Date());
// 计算其他字段值
setPlan(sgFeedPlan);
// 通知配料清单刷新数据
SgFeedListController.refresh = true;
SgFeedListController.refresh.set(true);
return toAjax(sgFeedPlanService.insertSgFeedPlan(sgFeedPlan));
}
@@ -99,7 +97,7 @@ public class SgFeedPlanController extends BaseController {
// 根据修改后的值重新计算
setPlan(sgFeedPlan);
// 通知配料清单刷新数据
SgFeedListController.refresh = true;
SgFeedListController.refresh.set(true);
return toAjax(sgFeedPlanService.updateSgFeedPlan(sgFeedPlan));
}
@@ -111,7 +109,7 @@ public class SgFeedPlanController extends BaseController {
@DeleteMapping("/{createDates}")
public AjaxResult remove(@PathVariable Date[] createDates) {
// 通知配料清单刷新数据
SgFeedListController.refresh = true;
SgFeedListController.refresh.set(true);
return toAjax(sgFeedPlanService.deleteSgFeedPlanByCreateDates(createDates));
}

View File

@@ -84,8 +84,6 @@ public class SgFeedStatisticController extends BaseController {
if (null == sgFeedStatistic.getFormulaId() && null == sgFeedStatistic.getFormulaBatchId()) {
throw new RuntimeException("ERROR: 数据为空");
}
sgFeedStatistic.setUserId(getUserId());
sgFeedStatistic.setDeptId(getDeptId());
List<SgFeedStatistic> isExist = sgFeedStatisticService.selectSgFeedStatisticList(sgFeedStatistic);
if (null != isExist && !isExist.isEmpty()) {
throw new RuntimeException("WARNING: 数据重复");

View File

@@ -79,8 +79,6 @@ public class SgFormulaListController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SgFormulaList sgFormulaList)
{
sgFormulaList.setUserId(getUserId());
sgFormulaList.setDeptId(getDeptId());
return toAjax(sgFormulaListService.insertSgFormulaList(sgFormulaList));
}

View File

@@ -93,10 +93,7 @@ public class SgFormulaManagementController extends BaseController {
@PostMapping
@Transactional(rollbackFor = Exception.class)
public AjaxResult add(@RequestBody SgFormulaManagement sgFormulaManagement) {
if (null == sgFormulaManagement)
throw new RuntimeException("ERROR: 数据为空");
sgFormulaManagement.setUserId(getUserId());
sgFormulaManagement.setDeptId(getDeptId());
if (null == sgFormulaManagement) throw new RuntimeException("ERROR: 数据为空");
if (Objects.equals(sgFormulaManagement.getBatchId(), "0")) {
SgFormulaManagement exist = sgFormulaManagementService.selectSgFormulaManagementByFormulaId(sgFormulaManagement.getFormulaId());
if (exist != null) {
@@ -147,7 +144,7 @@ public class SgFormulaManagementController extends BaseController {
}
// 通知配料清单刷新数据
SgFeedListController.refresh = true;
SgFeedListController.refresh.set(true);
return toAjax(sgFormulaManagementService.updateSgFormulaManagement(sgFormulaManagement));
}
@@ -174,7 +171,7 @@ public class SgFormulaManagementController extends BaseController {
sgFormulaManagement.setBatchId(batchId);
// 通知配料清单刷新数据
SgFeedListController.refresh = true;
SgFeedListController.refresh.set(true);
return toAjax(sgFormulaManagementService.deleteSgFormulaManagement(sgFormulaManagement));
}
}

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.feed.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -24,13 +23,14 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 原料Controller
*
*
* @author HashMap
* @date 2026-01-16
*/
@RestController
@RequestMapping("/feed/material")
public class SgMaterialController extends BaseController {
public class SgMaterialController extends BaseController
{
@Autowired
private ISgMaterialService sgMaterialService;
@@ -39,7 +39,8 @@ public class SgMaterialController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('feed:material:list')")
@GetMapping("/list")
public TableDataInfo list(SgMaterial sgMaterial) {
public TableDataInfo list(SgMaterial sgMaterial)
{
startPage();
List<SgMaterial> list = sgMaterialService.selectSgMaterialList(sgMaterial);
return getDataTable(list);
@@ -51,7 +52,8 @@ public class SgMaterialController extends BaseController {
@PreAuthorize("@ss.hasPermi('feed:material:export')")
@Log(title = "原料", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SgMaterial sgMaterial) {
public void export(HttpServletResponse response, SgMaterial sgMaterial)
{
List<SgMaterial> list = sgMaterialService.selectSgMaterialList(sgMaterial);
ExcelUtil<SgMaterial> util = new ExcelUtil<SgMaterial>(SgMaterial.class);
util.exportExcel(response, list, "原料数据");
@@ -62,7 +64,8 @@ public class SgMaterialController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('feed:material:query')")
@GetMapping(value = "/{materialId}")
public AjaxResult getInfo(@PathVariable("materialId") String materialId) {
public AjaxResult getInfo(@PathVariable("materialId") String materialId)
{
return success(sgMaterialService.selectSgMaterialByMaterialId(materialId));
}
@@ -72,9 +75,8 @@ public class SgMaterialController extends BaseController {
@PreAuthorize("@ss.hasPermi('feed:material:add')")
@Log(title = "原料", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SgMaterial sgMaterial) {
sgMaterial.setUserId(getUserId());
sgMaterial.setDeptId(getDeptId());
public AjaxResult add(@RequestBody SgMaterial sgMaterial)
{
return toAjax(sgMaterialService.insertSgMaterial(sgMaterial));
}
@@ -84,7 +86,8 @@ public class SgMaterialController extends BaseController {
@PreAuthorize("@ss.hasPermi('feed:material:edit')")
@Log(title = "原料", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SgMaterial sgMaterial) {
public AjaxResult edit(@RequestBody SgMaterial sgMaterial)
{
return toAjax(sgMaterialService.updateSgMaterial(sgMaterial));
}
@@ -93,8 +96,9 @@ public class SgMaterialController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('feed:material:remove')")
@Log(title = "原料", businessType = BusinessType.DELETE)
@DeleteMapping("/{materialIds}")
public AjaxResult remove(@PathVariable String[] materialIds) {
@DeleteMapping("/{materialIds}")
public AjaxResult remove(@PathVariable String[] materialIds)
{
return toAjax(sgMaterialService.deleteSgMaterialByMaterialIds(materialIds));
}
}

View File

@@ -19,36 +19,26 @@ import com.zhyc.common.core.domain.BaseEntity;
*/
@Setter
@Getter
public class SgFeedList extends BaseEntity {
public class SgFeedList extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long userId;
private Long deptId;
/**
* 序号
*/
/** 序号 */
private Long id;
/**
* 配方编号
*/
/** 配方编号 */
@Excel(name = "配方编号")
private String formulaId;
/**
* 配方批号
*/
/** 配方批号 */
@Excel(name = "配方批号")
private String formulaBatchId;
/**
* 饲草班人员
*/
/** 饲草班人员 */
@Excel(name = "饲草班人员")
private String zookeeper;
/**
* 配料日期
*/
/** 配料日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "配料日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date deployDate;
@@ -61,14 +51,14 @@ public class SgFeedList extends BaseEntity {
private Double noonTotal;
private Double afternoonTotal;
private List<SgFormulaList> formulaList;
private List<SgFormulaList> formulaList;
private List<SgFeedPlan> planList;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("formulaId", getFormulaId())
.append("formulaBatchId", getFormulaBatchId())

View File

@@ -1,7 +1,6 @@
package com.zhyc.module.feed.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
@@ -12,144 +11,125 @@ import com.zhyc.common.core.domain.BaseEntity;
/**
* 饲喂计划对象 sg_feed_plan
*
*
* @author HashMap
* @date 2025-08-14
*/
@Getter
@Setter
public class SgFeedPlan extends BaseEntity {
public class SgFeedPlan extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long userId;
private Long deptId;
/**
* 创建日期
*/
/** 创建日期 */
private Date createDate;
/**
* 配方编码
*/
/** 配方编码 */
@Excel(name = "配方编码")
private String formulaId;
/**
* 批号
*/
/** 批号 */
@Excel(name = "批号")
private String batchId;
/**
* 羊舍
*/
/** 羊舍 */
@Excel(name = "羊舍")
private Integer sheepHouseId;
/**
* 羊只数量
*/
/** 羊只数量 */
@Excel(name = "羊只数量")
private Integer sheepCount;
/**
* 日均计划量
*/
/** 日均计划量 */
@Excel(name = "日均计划量")
private Double planDailySize;
/**
* 饲喂比例(早)
*/
/** 饲喂比例(早) */
@Excel(name = "饲喂比例(早)")
private Double ratioMorning;
/**
* 饲喂比例(中)
*/
/** 饲喂比例(中) */
@Excel(name = "饲喂比例(中)")
private Double ratioNoon;
/**
* 饲喂比例(下)
*/
/** 饲喂比例(下) */
@Excel(name = "饲喂比例(下)")
private Double ratioAfternoon;
/**
* 计划量(早)
*/
/** 计划量(早) */
@Excel(name = "计划量(早)")
private Double planMorningSize;
/**
* 计划总量(早)
*/
/** 计划总量(早) */
@Excel(name = "计划总量(早)")
private Double planMorningTotal;
/**
* 实际量(早)
*/
/** 实际量(早) */
@Excel(name = "实际量(早)")
private Double actualMorningSize;
/**
* 计划量(中)
*/
/** 计划量(中) */
@Excel(name = "计划量(中)")
private Double planNoonSize;
/**
* 计划总量(中)
*/
/** 计划总量(中) */
@Excel(name = "计划总量(中)")
private Double planNoonTotal;
/**
* 实际量(中)
*/
/** 实际量(中) */
@Excel(name = "实际量(中)")
private Double actualNoonSize;
/**
* 计划量(下)
*/
/** 计划量(下) */
@Excel(name = "计划量(下)")
private Double planAfternoonSize;
/**
* 计划总量(下)
*/
/** 计划总量(下) */
@Excel(name = "计划总量(下)")
private Double planAfternoonTotal;
/**
* 实际量(下)
*/
/** 实际量(下) */
@Excel(name = "实际量(下)")
private Double actualAfternoonSize;
/**
* 计划饲喂总量
*/
/** 计划饲喂总量 */
@Excel(name = "计划饲喂总量")
private Double planFeedTotal;
/**
* 饲草班人员
*/
/** 饲草班人员 */
@Excel(name = "饲草班人员")
private String zookeeper;
/**
* 饲喂计划日期
*/
/** 饲喂计划日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "饲喂计划日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date planDate;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("createDate", getCreateDate()).append("formulaId", getFormulaId()).append("batchId", getBatchId()).append("sheepHouseId", getSheepHouseId()).append("sheepCount", getSheepCount()).append("planDailySize", getPlanDailySize()).append("ratioMorning", getRatioMorning()).append("ratioNoon", getRatioNoon()).append("ratioAfternoon", getRatioAfternoon()).append("planMorningSize", getPlanMorningSize()).append("planMorningTotal", getPlanMorningTotal()).append("actualMorningSize", getActualMorningSize()).append("planNoonSize", getPlanNoonSize()).append("planNoonTotal", getPlanNoonTotal()).append("actualNoonSize", getActualNoonSize()).append("planAfternoonSize", getPlanAfternoonSize()).append("planAfternoonTotal", getPlanAfternoonTotal()).append("actualAfternoonSize", getActualAfternoonSize()).append("planFeedTotal", getPlanFeedTotal()).append("zookeeper", getZookeeper()).append("planDate", getPlanDate()).append("remark", getRemark()).toString();
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("createDate", getCreateDate())
.append("formulaId", getFormulaId())
.append("batchId", getBatchId())
.append("sheepHouseId", getSheepHouseId())
.append("sheepCount", getSheepCount())
.append("planDailySize", getPlanDailySize())
.append("ratioMorning", getRatioMorning())
.append("ratioNoon", getRatioNoon())
.append("ratioAfternoon", getRatioAfternoon())
.append("planMorningSize", getPlanMorningSize())
.append("planMorningTotal", getPlanMorningTotal())
.append("actualMorningSize", getActualMorningSize())
.append("planNoonSize", getPlanNoonSize())
.append("planNoonTotal", getPlanNoonTotal())
.append("actualNoonSize", getActualNoonSize())
.append("planAfternoonSize", getPlanAfternoonSize())
.append("planAfternoonTotal", getPlanAfternoonTotal())
.append("actualAfternoonSize", getActualAfternoonSize())
.append("planFeedTotal", getPlanFeedTotal())
.append("zookeeper", getZookeeper())
.append("planDate", getPlanDate())
.append("remark", getRemark())
.toString();
}
}

View File

@@ -23,8 +23,7 @@ import java.util.List;
@Getter
public class SgFeedStatistic extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long userId;
private Long deptId;
/**
* UUID
*/

View File

@@ -9,45 +9,33 @@ import com.zhyc.common.core.domain.BaseEntity;
/**
* 配方列表对象 sg_formula_list
*
*
* @author HashMap
* @date 2025-08-09
*/
@Setter
@Getter
public class SgFormulaList extends BaseEntity {
public class SgFormulaList extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long userId;
private Long deptId;
/**
* 序号
*/
/** 序号 */
private Long code;
/**
* 配方编号
*/
/** 配方编号 */
private String formulaId;
/**
* 配方编号
*/
/** 配方编号 */
private String batchId;
/**
* 原料编号
*/
/** 原料编号 */
@Excel(name = "原料编号")
private String materialId;
/**
* 原料名称
*/
/** 原料名称 */
@Excel(name = "原料名称")
private String materialName;
/**
* 比例
*/
/** 比例 */
@Excel(name = "比例")
private Long ratio;
@@ -72,14 +60,14 @@ public class SgFormulaList extends BaseEntity {
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("code", getCode())
.append("formulaId", getFormulaId())
.append("materialId", getMaterialId())
.append("materialName", getMaterialName())
.append("ratio", getRatio())
.append("isGranular", getIsGranular())
.append("isSupplement", getIsSupplement())
.toString();
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("code", getCode())
.append("formulaId", getFormulaId())
.append("materialId", getMaterialId())
.append("materialName", getMaterialName())
.append("ratio", getRatio())
.append("isGranular", getIsGranular())
.append("isSupplement", getIsSupplement())
.toString();
}
}

View File

@@ -13,87 +13,67 @@ import com.zhyc.common.core.domain.BaseEntity;
/**
* 配方管理对象 sg_formula_management
*
*
* @author HashMap
* @date 2025-08-09
*/
@Setter
@Getter
public class SgFormulaManagement extends BaseEntity {
public class SgFormulaManagement extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long userId;
private Long deptId;
/**
* 配方编号
*/
/** 配方编号 */
private String formulaId;
/**
* 饲养阶段
*/
/** 饲养阶段 */
@Excel(name = "饲养阶段")
private String feedStage;
/**
* 批号
*/
/** 批号 */
@Excel(name = "批号")
private String batchId;
/**
* 开始使用时间
*/
/** 开始使用时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "开始使用时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date useStartDate;
/**
* 结束使用时间
*/
/** 结束使用时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "结束使用时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date useEndDate;
/**
* 使用状态
*/
/** 使用状态 */
@Excel(name = "使用状态")
private String useState;
/**
* 备注
*/
/** 备注 */
@Excel(name = "备注")
private String remark;
/**
* 配方列表
*/
private List<SgFormulaList> sgFormulaList;
/** 配方列表 */
private List<SgFormulaList> sgFormulaList;
/**
* 子配方
*/
/** 子配方 */
private List<SgFormulaManagement> subFormulaList;
/**
* 查询类型 *
/** 查询类型 *
* Sub : 子配方查询
* query : 类型查询
*
*/
* */
private String queryType;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("formulaId", getFormulaId())
.append("feedStage", getFeedStage())
.append("batchId", getBatchId())
.append("useStartDate", getUseStartDate())
.append("useEndDate", getUseEndDate())
.append("useState", getUseState())
.append("remark", getRemark())
.toString();
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("formulaId", getFormulaId())
.append("feedStage", getFeedStage())
.append("batchId", getBatchId())
.append("useStartDate", getUseStartDate())
.append("useEndDate", getUseEndDate())
.append("useState", getUseState())
.append("remark", getRemark())
.toString();
}
}

Some files were not shown because too many files have changed in this diff Show More