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
189 changed files with 2420 additions and 3671 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 @PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept) public AjaxResult add(@Validated @RequestBody SysDept dept)
{ {
if (!deptService.checkRanchName(dept)){
return error("新增部门'" + dept.getDeptName() + "'失败,牧场名称已存在");
}
if (!deptService.checkDeptNameUnique(dept)) if (!deptService.checkDeptNameUnique(dept))
{ {
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); 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 # url: jdbc:mysql://localhost:3306/zhyc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root # username: root
# password: 123456 # 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 username: zhyc
password: yszh123 password: yszh123
# 从库数据源 # 从库数据源
slave: farm01:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
enabled: false url: jdbc:mysql://118.182.97.76:3306/zhyc_sheep01?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: username: zhyc
username: password: yszh123
password: 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 initialSize: 5
# 最小连接池数量 # 最小连接池数量

View File

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

View File

@@ -31,10 +31,6 @@ public class SysDept extends BaseEntity
/** 部门名称 */ /** 部门名称 */
private String deptName; private String deptName;
/** 牧场id */
private Long ranchId;
private String ranchName;
/** 显示顺序 */ /** 显示顺序 */
private Integer orderNum; private Integer orderNum;
@@ -59,22 +55,6 @@ public class SysDept extends BaseEntity
/** 子部门 */ /** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>(); 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() public Long getDeptId()
{ {
return deptId; 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.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean; 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.DruidDataSourceBuilder;
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties; import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
import com.alibaba.druid.util.Utils; import com.alibaba.druid.util.Utils;
import com.zhyc.common.enums.DataSourceType;
import com.zhyc.common.utils.spring.SpringUtils; import com.zhyc.common.utils.spring.SpringUtils;
import com.zhyc.framework.config.properties.DruidProperties; import com.zhyc.framework.config.properties.DruidProperties;
import com.zhyc.framework.datasource.DynamicDataSource; import com.zhyc.framework.datasource.DynamicDataSource;
/** /**
* druid 配置多数据源 * druid 配置多数据源
* *
* @author ruoyi * @author ruoyi
*/ */
@Configuration @Configuration
public class DruidConfig public class DruidConfig {
{
@Bean @Bean
@ConfigurationProperties("spring.datasource.druid.master") @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(); DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource); return druidProperties.dataSource(dataSource);
} }
@@ -43,49 +56,49 @@ public class DruidConfig
@Bean @Bean
@ConfigurationProperties("spring.datasource.druid.slave") @ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true") @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(); DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource); return druidProperties.dataSource(dataSource);
} }
@Bean(name = "dynamicDataSource") @Bean(name = "dynamicDataSource")
@Primary @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<>(); Map<Object, Object> targetDataSources = new HashMap<>();
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); targetDataSources.put("system", systemDataSource);
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource"); targetDataSources.put("farm01", farm1DataSource);
return new DynamicDataSource(masterDataSource, targetDataSources); targetDataSources.put("farm02", farm2DataSource);
return new DynamicDataSource(systemDataSource, targetDataSources);
} }
/** /**
* 设置数据源 * 设置数据源
* *
* @param targetDataSources 备选数据源集合 * @param targetDataSources 备选数据源集合
* @param sourceName 数据源名称 * @param sourceName 数据源名称
* @param beanName bean名称 * @param beanName bean名称
*/ */
public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName) public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName) {
{ try {
try
{
DataSource dataSource = SpringUtils.getBean(beanName); DataSource dataSource = SpringUtils.getBean(beanName);
targetDataSources.put(sourceName, dataSource); targetDataSources.put(sourceName, dataSource);
} } catch (Exception e) {
catch (Exception e)
{
} }
} }
/** /**
* 去除监控页面底部的广告 * 去除监控页面底部的广告
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
@Bean @Bean
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) {
{
// 获取web监控页面的参数 // 获取web监控页面的参数
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
// 提取common.js的配置路径 // 提取common.js的配置路径
@@ -93,16 +106,14 @@ public class DruidConfig
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
final String filePath = "support/http/resources/js/common.js"; final String filePath = "support/http/resources/js/common.js";
// 创建filter进行过滤 // 创建filter进行过滤
Filter filter = new Filter() Filter filter = new Filter() {
{
@Override @Override
public void init(javax.servlet.FilterConfig filterConfig) throws ServletException public void init(javax.servlet.FilterConfig filterConfig) throws ServletException {
{
} }
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException throws IOException, ServletException {
{
chain.doFilter(request, response); chain.doFilter(request, response);
// 重置缓冲区,响应头不会被重置 // 重置缓冲区,响应头不会被重置
response.resetBuffer(); response.resetBuffer();
@@ -113,9 +124,9 @@ public class DruidConfig
text = text.replaceAll("powered.*?shrek.wang</a>", ""); text = text.replaceAll("powered.*?shrek.wang</a>", "");
response.getWriter().write(text); response.getWriter().write(text);
} }
@Override @Override
public void destroy() public void destroy() {
{
} }
}; };
FilterRegistrationBean registrationBean = new FilterRegistrationBean(); 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; package com.zhyc.framework.web.service;
import javax.annotation.Resource; import javax.annotation.Resource;
import com.zhyc.framework.datasource.DynamicDataSourceContextHolder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;

View File

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

View File

@@ -46,7 +46,6 @@ public class BasSheepController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
//查询耳号列表
@GetMapping("/earNumbers") @GetMapping("/earNumbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) { public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
try { try {
@@ -137,6 +136,7 @@ public class BasSheepController extends BaseController {
} }
BasSheep query = new BasSheep(); BasSheep query = new BasSheep();
query.setTypeId(typeId.longValue()); query.setTypeId(typeId.longValue());
startPage();
List<BasSheep> list = basSheepService.selectBasSheepList(query); List<BasSheep> list = basSheepService.selectBasSheepList(query);
return getDataTable(list); return getDataTable(list);
} }
@@ -153,6 +153,7 @@ public class BasSheepController extends BaseController {
BasSheep query = new BasSheep(); BasSheep query = new BasSheep();
query.setSheepfoldId(sheepfoldId.longValue()); query.setSheepfoldId(sheepfoldId.longValue());
query.setTypeId(typeId.longValue()); query.setTypeId(typeId.longValue());
startPage();
List<BasSheep> list = basSheepService.selectBasSheepList(query); List<BasSheep> list = basSheepService.selectBasSheepList(query);
return getDataTable(list); return getDataTable(list);
} }
@@ -189,6 +190,7 @@ public class BasSheepController extends BaseController {
return success(result); 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) { public AjaxResult getSheepByRanchId(@PathVariable Long ranchId) {
List<BasSheep> sheepList = basSheepService.getSheepByRanchId(ranchId); List<BasSheep> sheepList = basSheepService.getSheepByRanchId(ranchId);
return AjaxResult.success(sheepList); 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.common.utils.poi.ExcelUtil;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.DaSheepfold; import com.zhyc.module.base.domain.DaSheepfold;
import com.zhyc.module.base.domain.DaSheepfoldSummaryExportVO;
import com.zhyc.module.base.service.IDaSheepfoldService; import com.zhyc.module.base.service.IDaSheepfoldService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -45,17 +44,6 @@ public class DaSheepfoldController extends BaseController
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldList(daSheepfold); List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldList(daSheepfold);
return getDataTable(list); return getDataTable(list);
} }
/**
* 主表格:羊舍级别汇总列表
*/
@GetMapping("/summaryList")
public TableDataInfo summaryList(DaSheepfold daSheepfold) {
startPage();
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldSummaryList(daSheepfold);
return getDataTable(list);
}
/* /*
* 根据羊舍ids查询羊只id * 根据羊舍ids查询羊只id
* */ * */
@@ -81,73 +69,6 @@ public class DaSheepfoldController extends BaseController
util.exportExcel(response, list, "羊舍管理数据"); 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)); 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')") @PreAuthorize("@ss.hasPermi('sheepfold_management:sheepfold_management:remove')")
@DeleteMapping("/deleteByCondition") @Log(title = "羊舍管理", businessType = BusinessType.DELETE)
public AjaxResult removeByCondition(@RequestBody DaSheepfold sheepfold) { @DeleteMapping("/{ids}")
// 1. 校验核心条件非空(避免条件缺失导致误删) public AjaxResult remove(@PathVariable Long[] ids)
if (sheepfold.getRanchId() == null {
|| sheepfold.getSheepfoldNo() == null || sheepfold.getSheepfoldNo().isEmpty() return toAjax(daSheepfoldService.deleteDaSheepfoldByIds(ids));
|| 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('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

@@ -115,10 +115,5 @@ public class DaSheepfold extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String comment; 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

@@ -2,7 +2,6 @@ package com.zhyc.module.base.mapper;
import com.zhyc.module.base.domain.DaSheepfold; import com.zhyc.module.base.domain.DaSheepfold;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@@ -31,12 +30,6 @@ public interface DaSheepfoldMapper
*/ */
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold); 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 deleteDaSheepfoldByIds(Long[] ids);
public int selectCount(DaSheepfold daSheepfold); public int selectCount(DaSheepfold daSheepfold);
// 新增:按组合条件删除的自定义方法(核心)
int deleteSheepfoldByCondition(
@Param("ranchId") Long ranchId,
@Param("sheepfoldNo") String sheepfoldNo,
@Param("sheepfoldTypeId") Long sheepfoldTypeId
);
} }

View File

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

View File

@@ -1,8 +1,6 @@
package com.zhyc.module.base.service.impl; package com.zhyc.module.base.service.impl;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.mapper.BasSheepMapper; import com.zhyc.module.base.mapper.BasSheepMapper;
@@ -53,7 +51,6 @@ public class BasSheepServiceImpl implements IBasSheepService
* @return * @return
*/ */
@Override @Override
@DataScope(deptAlias = "b", userAlias = "b")
public List<String> searchEarNumbers(String query) { public List<String> searchEarNumbers(String query) {
return basSheepMapper.searchEarNumbers(query); return basSheepMapper.searchEarNumbers(query);
} }

View File

@@ -1,40 +1,32 @@
package com.zhyc.module.base.service.impl; 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.BasSheep;
import com.zhyc.module.base.domain.DaSheepfold; import com.zhyc.module.base.domain.DaSheepfold;
import com.zhyc.module.base.mapper.BasSheepMapper; import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.mapper.DaSheepfoldMapper; import com.zhyc.module.base.mapper.DaSheepfoldMapper;
import com.zhyc.module.base.service.IDaSheepfoldService; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
/** /**
* 羊舍管理Service业务层处理 * 羊舍管理Service业务层处理
* *
* @author wyt * @author wyt
* @date 2025-07-11 * @date 2025-07-11
*/ */
@Service @Service
public class DaSheepfoldServiceImpl implements IDaSheepfoldService public class DaSheepfoldServiceImpl implements IDaSheepfoldService
{ {
@Autowired @Autowired
private DaSheepfoldMapper daSheepfoldMapper; private DaSheepfoldMapper daSheepfoldMapper;
@Autowired @Autowired
private BasSheepMapper basSheepMapper; private BasSheepMapper basSheepMapper;
// 日志对象
private static final Logger log = LoggerFactory.getLogger(DaSheepfoldServiceImpl.class);
/** /**
* 查询羊舍管理 * 查询羊舍管理
* *
* @param id 羊舍管理主键 * @param id 羊舍管理主键
* @return 羊舍管理 * @return 羊舍管理
*/ */
@@ -46,27 +38,19 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/** /**
* 查询羊舍管理列表 * 查询羊舍管理列表
* *
* @param daSheepfold 羊舍管理 * @param daSheepfold 羊舍管理
* @return 羊舍管理 * @return 羊舍管理
*/ */
@Override @Override
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold) public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold)
{ {
List<DaSheepfold> sheepfoldList = daSheepfoldMapper.selectDaSheepfoldList(daSheepfold); return daSheepfoldMapper.selectDaSheepfoldList(daSheepfold);
return sheepfoldList; // 修复原代码重复调用Mapper改为返回已查询的列表
}
/**
* 羊舍级别汇总查询(主表格)
*/
public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold) {
return daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold);
} }
/** /**
* 新增羊舍管理 * 新增羊舍管理
* *
* @param daSheepfold 羊舍管理 * @param daSheepfold 羊舍管理
* @return 结果 * @return 结果
*/ */
@@ -78,7 +62,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/** /**
* 修改羊舍管理 * 修改羊舍管理
* *
* @param daSheepfold 羊舍管理 * @param daSheepfold 羊舍管理
* @return 结果 * @return 结果
*/ */
@@ -90,7 +74,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/** /**
* 批量删除羊舍管理 * 批量删除羊舍管理
* *
* @param ids 需要删除的羊舍管理主键 * @param ids 需要删除的羊舍管理主键
* @return 结果 * @return 结果
*/ */
@@ -102,7 +86,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/** /**
* 删除羊舍管理信息 * 删除羊舍管理信息
* *
* @param id 羊舍管理主键 * @param id 羊舍管理主键
* @return 结果 * @return 结果
*/ */
@@ -112,6 +96,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
return daSheepfoldMapper.deleteDaSheepfoldById(id); return daSheepfoldMapper.deleteDaSheepfoldById(id);
} }
@Override @Override
public boolean checkSheepfoldNoExist(Long ranchId, Long sheepfoldTypeId, String sheepfoldNo) { public boolean checkSheepfoldNoExist(Long ranchId, Long sheepfoldTypeId, String sheepfoldNo) {
DaSheepfold query = new DaSheepfold(); DaSheepfold query = new DaSheepfold();
@@ -126,40 +111,4 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
List<BasSheep> basSheep = basSheepMapper.selectBasSheepBySheepfold(id); List<BasSheep> basSheep = basSheepMapper.selectBasSheepBySheepfold(id);
return basSheep; 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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -98,9 +98,6 @@ public class QuarantineReport extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String comment; private String comment;
private Long userId;
private Long deptId;
public void setGender(String gender) { public void setGender(String gender) {
this.gender = gender; this.gender = gender;
this.genderName = Gender.getDescByCode(Integer.valueOf(gender)); this.genderName = Gender.getDescByCode(Integer.valueOf(gender));

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
@@ -61,7 +60,6 @@ public class DiagnosisServiceImpl implements IDiagnosisService
* @return 诊疗结果 * @return 诊疗结果
*/ */
@Override @Override
@DataScope(deptAlias = "sd", userAlias = "sd")
public List<Diagnosis> selectDiagnosisList(Diagnosis diagnosis) public List<Diagnosis> selectDiagnosisList(Diagnosis diagnosis)
{ {
String[] sheepNos = null; String[] sheepNos = null;

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.biosafety.domain.QuarantineItems; import com.zhyc.module.biosafety.domain.QuarantineItems;
import com.zhyc.module.biosafety.mapper.QuarantineItemsMapper; import com.zhyc.module.biosafety.mapper.QuarantineItemsMapper;
import com.zhyc.module.biosafety.service.IQuarantineItemsService; 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.ArrayList;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils; import com.zhyc.common.utils.bean.BeanUtils;
@@ -48,7 +46,6 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
* @return 检疫记录 * @return 检疫记录
*/ */
@Override @Override
@DataScope(deptAlias = "sqr", userAlias = "sqr")
public List<QuarantineReport> selectQuarantineReportList(QuarantineReport quarantineReport) public List<QuarantineReport> selectQuarantineReportList(QuarantineReport quarantineReport)
{ {
String[] sheepNos = null; String[] sheepNos = null;

View File

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

View File

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

View File

@@ -26,9 +26,7 @@ public class UserPostController {
// 根据岗位编码获取用户 // 根据岗位编码获取用户
@GetMapping("/getUser") @GetMapping("/getUser")
public AjaxResult getUserPost(String postCode){ public AjaxResult getUserPost(String postCode){
User user = new User(); List<User> list = userService.getUserListByCode(postCode);
user.setPostCode(postCode);
List<User> list = userService.getUserListByCode(user);
return AjaxResult.success(list); 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; package com.zhyc.module.common.domain;
import com.zhyc.common.annotation.Excel; import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -9,7 +8,7 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class Post extends BaseEntity { public class Post {
/** 岗位序号 */ /** 岗位序号 */
@Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC)

View File

@@ -1,6 +1,5 @@
package com.zhyc.module.common.domain; package com.zhyc.module.common.domain;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -8,10 +7,9 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class User extends BaseEntity { public class User {
// 用户id // 用户id
private Long userId; private String userId;
private Long deptId;
// 用户名 // 用户名
private String nickName; private String nickName;
// 岗位名称 // 岗位名称
@@ -19,5 +17,4 @@ public class User extends BaseEntity {
// 岗位编码 // 岗位编码
private String postCode; 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 @Mapper
public interface UserMapper { 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; import java.util.List;
public interface UserService { 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; 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.domain.User;
import com.zhyc.module.common.mapper.DeptMapper;
import com.zhyc.module.common.mapper.UserMapper; import com.zhyc.module.common.mapper.UserMapper;
import com.zhyc.module.common.service.UserService; import com.zhyc.module.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -16,16 +12,9 @@ import java.util.List;
public class UserPostServiceImpl implements UserService { public class UserPostServiceImpl implements UserService {
@Autowired @Autowired
UserMapper userMapper; UserMapper userMapper;
@Autowired
DeptMapper deptMapper;
@Override @Override
public List<User> getUserListByCode(User user) { public List<User> getUserListByCode(String postCode) {
Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId(); return userMapper.getUserListByCode(postCode);
Dept secondLevel = deptMapper.selectTopSecondLevelDept(deptId);
user.setDeptId(secondLevel.getDeptId());
System.out.println(secondLevel);
return userMapper.getUserListByCode(user);
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -10,7 +10,8 @@ import com.zhyc.common.core.domain.BaseEntity;
/** /**
* 鲜奶生产,成品检验记录对象 np_fresh_milk_insp * 鲜奶生产,成品检验记录对象 np_fresh_milk_insp
* * @author ruoyi *
* @author ruoyi
* @date 2025-07-18 * @date 2025-07-18
*/ */
@Data @Data
@@ -84,12 +85,4 @@ public class NpFreshMilkInsp extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String commnet; 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 = "爱特退回酸奶") @Excel(name = "爱特退回酸奶")
private BigDecimal returnYogurt; 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 --- // --- getters and setters ---
public Integer getId() { return id; } public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; } public void setId(Integer id) { this.id = id; }
@@ -133,10 +125,4 @@ public class NpMilkInOutStore extends BaseEntity {
public BigDecimal getReturnYogurt() { return returnYogurt; } public BigDecimal getReturnYogurt() { return returnYogurt; }
public void setReturnYogurt(BigDecimal returnYogurt) { this.returnYogurt = 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.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List; // 引入 List
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.common.annotation.Excel; import com.zhyc.common.annotation.Excel;
@@ -40,19 +40,11 @@ public class NpMilkProdClasses implements Serializable {
private String sheepId; private String sheepId;
// 修改处:新增字段用于多耳号查询
/** 全部羊耳号列表(用于多耳号查询) */ /** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers; private List<String> allEarNumbers;
/** 用户ID */ // Getters and Setters
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
// --- Getters and Setters ---
public List<String> getAllEarNumbers() { public List<String> getAllEarNumbers() {
return allEarNumbers; return allEarNumbers;
} }
@@ -96,10 +88,4 @@ public class NpMilkProdClasses implements Serializable {
public String getSheepId() { return sheepId; } public String getSheepId() { return sheepId; }
public void setSheepId(String sheepId) { this.sheepId = 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") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime; 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 * 酸奶生产,成品检疫记录对象 np_yogurt_insp
* * @author ruoyi *
* @author ruoyi
* @date 2025-07-17 * @date 2025-07-17
*/ */
@Data @Data
@@ -41,7 +42,7 @@ public class NpYogurtInsp extends BaseEntity
private Double protein; private Double protein;
/** 非脂g/100g /** 非脂g/100g
*/ */
@Excel(name = "非脂g/100g") @Excel(name = "非脂g/100g")
private Double nonFat; private Double nonFat;
@@ -85,12 +86,4 @@ public class NpYogurtInsp extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String comment; 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 = "干物质系数") @Excel(name = "干物质系数")
private Double coefficient; private Double coefficient;
/** 用户ID */
private Long userId;
/** 部门ID */
private Long deptId;
} }

View File

@@ -45,9 +45,5 @@ public class XzWegihCorrection extends BaseEntity
@Excel(name = "称重系数") @Excel(name = "称重系数")
private Double coefficient; 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; import java.util.Map;
public interface NpMilkInOutStoreMapper { public interface NpMilkInOutStoreMapper {
/**
* 动态列查询
*/
List<Map<String,Object>> selectWithColumns( List<Map<String,Object>> selectWithColumns(
@Param("start") Date start, @Param("end") Date end, @Param("start") Date start, @Param("end") Date end,
@Param("feedSources") List<String> feedSources, @Param("feedSources") List<String> feedSources,
@Param("saleDestinations") List<String> saleDestinations @Param("saleDestinations") List<String> saleDestinations
); );
/**
* 插入主表
*/
int insertStore(NpMilkInOutStore store); 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> selectFeedSources();
/**
* 获取销售去向列表(用于动态列头)
*/
List<String> selectSaleDestinations(); List<String> selectSaleDestinations();
} }

View File

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

View File

@@ -1,7 +1,5 @@
package com.zhyc.module.dairyProducts.service.impl; 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.domain.NpMilkInOutStore;
import com.zhyc.module.dairyProducts.mapper.NpMilkInOutStoreMapper; import com.zhyc.module.dairyProducts.mapper.NpMilkInOutStoreMapper;
import com.zhyc.module.dairyProducts.service.INpMilkInOutStoreService; import com.zhyc.module.dairyProducts.service.INpMilkInOutStoreService;
@@ -21,7 +19,6 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
private NpMilkInOutStoreMapper mapper; private NpMilkInOutStoreMapper mapper;
@Override @Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Map<String, Object>> selectWithDynamicColumns(Date start, Date end) { public List<Map<String, Object>> selectWithDynamicColumns(Date start, Date end) {
List<String> feed = mapper.selectFeedSources(); List<String> feed = mapper.selectFeedSources();
List<String> sale = mapper.selectSaleDestinations(); List<String> sale = mapper.selectSaleDestinations();
@@ -61,46 +58,25 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
@Override @Override
public void batchInsertFromRows(List<Map<String, Object>> rows) throws Exception { 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) { for (Map<String,Object> row : rows) {
// 提取主表字段 // 提取主表字段
NpMilkInOutStore store = new NpMilkInOutStore(); NpMilkInOutStore store = new NpMilkInOutStore();
// 这里假设 Excel 中的"日期"格式是标准的 yyyy-MM-dd如果格式不对可能会报错建议加 try-catch 或格式化处理
store.setDatetime(java.sql.Date.valueOf(row.get("日期").toString())); store.setDatetime(java.sql.Date.valueOf(row.get("日期").toString()));
store.setNum(Integer.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); mapper.insertStore(store);
Integer sid = store.getId(); Integer sid = store.getId();
// 其余列为动态饲喂或销售,根据字典决定分类: // 其余列为动态饲喂或销售,根据字典决定分类:
for (Map.Entry<String,Object> ent: row.entrySet()) { for (Map.Entry<String,Object> ent: row.entrySet()) {
String col = ent.getKey(); 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()); BigDecimal amt = new BigDecimal(ent.getValue().toString());
if (mapper.selectFeedSources().contains(col)) { if (mapper.selectFeedSources().contains(col)) {
// === 修改开始:插入饲喂子表时传入 userId 和 deptId === mapper.insertFeedRecord(sid, col, amt);
mapper.insertFeedRecord(sid, col, amt, userId, deptId);
} else if (mapper.selectSaleDestinations().contains(col)) { } else if (mapper.selectSaleDestinations().contains(col)) {
// === 修改开始:插入销售子表时传入 userId 和 deptId === mapper.insertSaleRecord(sid, col, amt);
mapper.insertSaleRecord(sid, col, amt, userId, deptId);
} }
} }
} }
} }
} }

View File

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

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.dairyProducts.service.impl;
import java.util.List; import java.util.List;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.dairyProducts.domain.NpYogurtInsp; import com.zhyc.module.dairyProducts.domain.NpYogurtInsp;
import com.zhyc.module.dairyProducts.mapper.NpYogurtInspMapper; import com.zhyc.module.dairyProducts.mapper.NpYogurtInspMapper;
import com.zhyc.module.dairyProducts.service.INpYogurtInspService; import com.zhyc.module.dairyProducts.service.INpYogurtInspService;
@@ -11,7 +10,8 @@ import org.springframework.stereotype.Service;
/** /**
* 酸奶生产成品检疫记录Service业务层处理 * 酸奶生产成品检疫记录Service业务层处理
* * @author ruoyi *
* @author ruoyi
* @date 2025-07-17 * @date 2025-07-17
*/ */
@Service @Service
@@ -22,7 +22,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/** /**
* 查询酸奶生产,成品检疫记录 * 查询酸奶生产,成品检疫记录
* * @param id 酸奶生产,成品检疫记录主键 *
* @param id 酸奶生产,成品检疫记录主键
* @return 酸奶生产,成品检疫记录 * @return 酸奶生产,成品检疫记录
*/ */
@Override @Override
@@ -33,11 +34,11 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/** /**
* 查询酸奶生产,成品检疫记录列表 * 查询酸奶生产,成品检疫记录列表
* * @param npYogurtInsp 酸奶生产,成品检疫记录 *
* @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 酸奶生产,成品检疫记录 * @return 酸奶生产,成品检疫记录
*/ */
@Override @Override
@DataScope(deptAlias = "a", userAlias = "a")
public List<NpYogurtInsp> selectNpYogurtInspList(NpYogurtInsp npYogurtInsp) public List<NpYogurtInsp> selectNpYogurtInspList(NpYogurtInsp npYogurtInsp)
{ {
return npYogurtInspMapper.selectNpYogurtInspList(npYogurtInsp); return npYogurtInspMapper.selectNpYogurtInspList(npYogurtInsp);
@@ -45,7 +46,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/** /**
* 新增酸奶生产,成品检疫记录 * 新增酸奶生产,成品检疫记录
* * @param npYogurtInsp 酸奶生产,成品检疫记录 *
* @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -57,7 +59,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/** /**
* 修改酸奶生产,成品检疫记录 * 修改酸奶生产,成品检疫记录
* * @param npYogurtInsp 酸奶生产,成品检疫记录 *
* @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -68,7 +71,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/** /**
* 批量删除酸奶生产,成品检疫记录 * 批量删除酸奶生产,成品检疫记录
* * @param ids 需要删除的酸奶生产,成品检疫记录主键 *
* @param ids 需要删除的酸奶生产,成品检疫记录主键
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -79,7 +83,8 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/** /**
* 删除酸奶生产,成品检疫记录信息 * 删除酸奶生产,成品检疫记录信息
* * @param id 酸奶生产,成品检疫记录主键 *
* @param id 酸奶生产,成品检疫记录主键
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -87,4 +92,4 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
{ {
return npYogurtInspMapper.deleteNpYogurtInspById(id); 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.mapper.XzDryMatterCorrectionMapper;
import com.zhyc.module.dairyProducts.domain.XzDryMatterCorrection; import com.zhyc.module.dairyProducts.domain.XzDryMatterCorrection;
import com.zhyc.module.dairyProducts.service.IXzDryMatterCorrectionService; import com.zhyc.module.dairyProducts.service.IXzDryMatterCorrectionService;
import com.zhyc.common.annotation.DataScope; // 引入数据权限注解
/** /**
* 干物质校正Service业务层处理 * 干物质校正Service业务层处理
* * @author ruoyi *
* @author ruoyi
* @date 2025-07-12 * @date 2025-07-12
*/ */
@Service @Service
public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionService public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionService
{ {
@Autowired @Autowired
private XzDryMatterCorrectionMapper xzDryMatterCorrectionMapper; private XzDryMatterCorrectionMapper xzDryMatterCorrectionMapper;
/** /**
* 查询干物质校正 * 查询干物质校正
* * @param id 干物质校正主键 *
* @param id 干物质校正主键
* @return 干物质校正 * @return 干物质校正
*/ */
@Override @Override
@@ -32,11 +33,11 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/** /**
* 查询干物质校正列表 * 查询干物质校正列表
* * @param xzDryMatterCorrection 干物质校正 *
* @param xzDryMatterCorrection 干物质校正
* @return 干物质校正 * @return 干物质校正
*/ */
@Override @Override
@DataScope(deptAlias = "d", userAlias = "d") // 添加数据权限注解
public List<XzDryMatterCorrection> selectXzDryMatterCorrectionList(XzDryMatterCorrection xzDryMatterCorrection) public List<XzDryMatterCorrection> selectXzDryMatterCorrectionList(XzDryMatterCorrection xzDryMatterCorrection)
{ {
return xzDryMatterCorrectionMapper.selectXzDryMatterCorrectionList(xzDryMatterCorrection); return xzDryMatterCorrectionMapper.selectXzDryMatterCorrectionList(xzDryMatterCorrection);
@@ -101,7 +102,8 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/** /**
* 批量删除干物质校正 * 批量删除干物质校正
* * @param ids 需要删除的干物质校正主键 *
* @param ids 需要删除的干物质校正主键
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -112,7 +114,8 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/** /**
* 删除干物质校正信息 * 删除干物质校正信息
* * @param id 干物质校正主键 *
* @param id 干物质校正主键
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -120,4 +123,4 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
{ {
return xzDryMatterCorrectionMapper.deleteXzDryMatterCorrectionById(id); 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.domain.XzWegihCorrection;
import com.zhyc.module.dairyProducts.mapper.XzWegihCorrectionMapper; import com.zhyc.module.dairyProducts.mapper.XzWegihCorrectionMapper;
import com.zhyc.module.dairyProducts.service.IXzWegihCorrectionService; import com.zhyc.module.dairyProducts.service.IXzWegihCorrectionService;
import com.zhyc.common.annotation.DataScope; // 引入数据权限注解
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* 称重校正Service业务层处理 * 称重校正Service业务层处理
* * @author ruoyi *
* @author ruoyi
* @date 2025-07-12 * @date 2025-07-12
*/ */
@Service @Service
@@ -25,7 +25,8 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/** /**
* 查询称重校正 * 查询称重校正
* * @param id 称重校正主键 *
* @param id 称重校正主键
* @return 称重校正 * @return 称重校正
*/ */
@Override @Override
@@ -36,11 +37,11 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/** /**
* 查询称重校正列表 * 查询称重校正列表
* * @param xzWegihCorrection 称重校正 *
* @param xzWegihCorrection 称重校正
* @return 称重校正 * @return 称重校正
*/ */
@Override @Override
@DataScope(deptAlias = "w", userAlias = "w") // 添加数据权限注解
public List<XzWegihCorrection> selectXzWegihCorrectionList(XzWegihCorrection xzWegihCorrection) public List<XzWegihCorrection> selectXzWegihCorrectionList(XzWegihCorrection xzWegihCorrection)
{ {
return xzWegihCorrectionMapper.selectXzWegihCorrectionList(xzWegihCorrection); return xzWegihCorrectionMapper.selectXzWegihCorrectionList(xzWegihCorrection);
@@ -105,7 +106,8 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/** /**
* 批量删除称重校正 * 批量删除称重校正
* * @param ids 需要删除的称重校正主键 *
* @param ids 需要删除的称重校正主键
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -116,7 +118,8 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/** /**
* 删除称重校正信息 * 删除称重校正信息
* * @param id 称重校正主键 *
* @param id 称重校正主键
* @return 结果 * @return 结果
*/ */
@Override @Override
@@ -124,4 +127,4 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
{ {
return xzWegihCorrectionMapper.deleteXzWegihCorrectionById(id); return xzWegihCorrectionMapper.deleteXzWegihCorrectionById(id);
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,6 @@
package com.zhyc.module.feed.domain; package com.zhyc.module.feed.domain;
import java.util.Date; import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -12,144 +11,125 @@ import com.zhyc.common.core.domain.BaseEntity;
/** /**
* 饲喂计划对象 sg_feed_plan * 饲喂计划对象 sg_feed_plan
* *
* @author HashMap * @author HashMap
* @date 2025-08-14 * @date 2025-08-14
*/ */
@Getter @Getter
@Setter @Setter
public class SgFeedPlan extends BaseEntity { public class SgFeedPlan extends BaseEntity
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long userId;
private Long deptId; /** 创建日期 */
/**
* 创建日期
*/
private Date createDate; private Date createDate;
/** /** 配方编码 */
* 配方编码
*/
@Excel(name = "配方编码") @Excel(name = "配方编码")
private String formulaId; private String formulaId;
/** /** 批号 */
* 批号
*/
@Excel(name = "批号") @Excel(name = "批号")
private String batchId; private String batchId;
/** /** 羊舍 */
* 羊舍
*/
@Excel(name = "羊舍") @Excel(name = "羊舍")
private Integer sheepHouseId; private Integer sheepHouseId;
/** /** 羊只数量 */
* 羊只数量
*/
@Excel(name = "羊只数量") @Excel(name = "羊只数量")
private Integer sheepCount; private Integer sheepCount;
/** /** 日均计划量 */
* 日均计划量
*/
@Excel(name = "日均计划量") @Excel(name = "日均计划量")
private Double planDailySize; private Double planDailySize;
/** /** 饲喂比例(早) */
* 饲喂比例(早)
*/
@Excel(name = "饲喂比例(早)") @Excel(name = "饲喂比例(早)")
private Double ratioMorning; private Double ratioMorning;
/** /** 饲喂比例(中) */
* 饲喂比例(中)
*/
@Excel(name = "饲喂比例(中)") @Excel(name = "饲喂比例(中)")
private Double ratioNoon; private Double ratioNoon;
/** /** 饲喂比例(下) */
* 饲喂比例(下)
*/
@Excel(name = "饲喂比例(下)") @Excel(name = "饲喂比例(下)")
private Double ratioAfternoon; private Double ratioAfternoon;
/** /** 计划量(早) */
* 计划量(早)
*/
@Excel(name = "计划量(早)") @Excel(name = "计划量(早)")
private Double planMorningSize; private Double planMorningSize;
/** /** 计划总量(早) */
* 计划总量(早)
*/
@Excel(name = "计划总量(早)") @Excel(name = "计划总量(早)")
private Double planMorningTotal; private Double planMorningTotal;
/** /** 实际量(早) */
* 实际量(早)
*/
@Excel(name = "实际量(早)") @Excel(name = "实际量(早)")
private Double actualMorningSize; private Double actualMorningSize;
/** /** 计划量(中) */
* 计划量(中)
*/
@Excel(name = "计划量(中)") @Excel(name = "计划量(中)")
private Double planNoonSize; private Double planNoonSize;
/** /** 计划总量(中) */
* 计划总量(中)
*/
@Excel(name = "计划总量(中)") @Excel(name = "计划总量(中)")
private Double planNoonTotal; private Double planNoonTotal;
/** /** 实际量(中) */
* 实际量(中)
*/
@Excel(name = "实际量(中)") @Excel(name = "实际量(中)")
private Double actualNoonSize; private Double actualNoonSize;
/** /** 计划量(下) */
* 计划量(下)
*/
@Excel(name = "计划量(下)") @Excel(name = "计划量(下)")
private Double planAfternoonSize; private Double planAfternoonSize;
/** /** 计划总量(下) */
* 计划总量(下)
*/
@Excel(name = "计划总量(下)") @Excel(name = "计划总量(下)")
private Double planAfternoonTotal; private Double planAfternoonTotal;
/** /** 实际量(下) */
* 实际量(下)
*/
@Excel(name = "实际量(下)") @Excel(name = "实际量(下)")
private Double actualAfternoonSize; private Double actualAfternoonSize;
/** /** 计划饲喂总量 */
* 计划饲喂总量
*/
@Excel(name = "计划饲喂总量") @Excel(name = "计划饲喂总量")
private Double planFeedTotal; private Double planFeedTotal;
/** /** 饲草班人员 */
* 饲草班人员
*/
@Excel(name = "饲草班人员") @Excel(name = "饲草班人员")
private String zookeeper; private String zookeeper;
/** /** 饲喂计划日期 */
* 饲喂计划日期
*/
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "饲喂计划日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "饲喂计划日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date planDate; private Date planDate;
@Override @Override
public String toString() { 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 @Getter
public class SgFeedStatistic extends BaseEntity { public class SgFeedStatistic extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long userId;
private Long deptId;
/** /**
* UUID * UUID
*/ */

View File

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

View File

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

View File

@@ -1,6 +1,5 @@
package com.zhyc.module.feed.domain; package com.zhyc.module.feed.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel; import com.zhyc.common.annotation.Excel;
@@ -8,59 +7,62 @@ import com.zhyc.common.core.domain.BaseEntity;
/** /**
* 原料对象 sg_material * 原料对象 sg_material
* *
* @author HashMap * @author HashMap
* @date 2026-01-16 * @date 2026-01-16
*/ */
@Data public class SgMaterial extends BaseEntity
public class SgMaterial extends BaseEntity { {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long userId;
private Long deptId; /** 原料编码 */
/**
* 原料编码
*/
@Excel(name = "原料编码") @Excel(name = "原料编码")
private String materialId; private String materialId;
/** /** 原料名称 */
* 原料名称
*/
@Excel(name = "原料名称") @Excel(name = "原料名称")
private String materialName; private String materialName;
/** /** 颗粒料 */
* 颗粒料
*/
@Excel(name = "颗粒料") @Excel(name = "颗粒料")
private Integer isGranular; private Integer isGranular;
public void setMaterialId(String materialId) { public void setMaterialId(String materialId)
{
this.materialId = materialId; this.materialId = materialId;
} }
public String getMaterialId() { public String getMaterialId()
{
return materialId; return materialId;
} }
public void setMaterialName(String materialName) { public void setMaterialName(String materialName)
{
this.materialName = materialName; this.materialName = materialName;
} }
public String getMaterialName() { public String getMaterialName()
{
return materialName; return materialName;
} }
public void setIsGranular(Integer isGranular) { public void setIsGranular(Integer isGranular)
{
this.isGranular = isGranular; this.isGranular = isGranular;
} }
public Integer getIsGranular() { public Integer getIsGranular()
{
return isGranular; return isGranular;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("materialId", getMaterialId()).append("materialName", getMaterialName()).append("isGranular", getIsGranular()).toString(); return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("materialId", getMaterialId())
.append("materialName", getMaterialName())
.append("isGranular", getIsGranular())
.toString();
} }
} }

View File

@@ -59,5 +59,7 @@ public interface ISgFeedListService {
*/ */
int deleteSgFeedListById(Long id); int deleteSgFeedListById(Long id);
void syncFeedListSafely();
void SyncFeedList(); void SyncFeedList();
} }

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.feed.service.impl;
import java.util.*; import java.util.*;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.feed.domain.SgFeedPlan; import com.zhyc.module.feed.domain.SgFeedPlan;
import com.zhyc.module.feed.domain.SgFormulaManagement; import com.zhyc.module.feed.domain.SgFormulaManagement;
import com.zhyc.module.feed.service.ISgFeedPlanService; import com.zhyc.module.feed.service.ISgFeedPlanService;
@@ -12,6 +11,10 @@ import org.springframework.stereotype.Service;
import com.zhyc.module.feed.mapper.SgFeedListMapper; import com.zhyc.module.feed.mapper.SgFeedListMapper;
import com.zhyc.module.feed.domain.SgFeedList; import com.zhyc.module.feed.domain.SgFeedList;
import com.zhyc.module.feed.service.ISgFeedListService; import com.zhyc.module.feed.service.ISgFeedListService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import static com.zhyc.module.feed.controller.SgFeedListController.refresh;
/** /**
* 配料清单Service业务层处理 * 配料清单Service业务层处理
@@ -31,7 +34,15 @@ public class SgFeedListServiceImpl implements ISgFeedListService {
this.sgFeedListMapper = sgFeedListMapper; this.sgFeedListMapper = sgFeedListMapper;
this.sgFormulaManagementService = sgFormulaManagementService; this.sgFormulaManagementService = sgFormulaManagementService;
this.sgFeedPlanService = sgFeedPlanService; this.sgFeedPlanService = sgFeedPlanService;
// 构造时将数据库初始数据写入缓存 // 第一次请求时更新缓存
refresh.set(true);
}
/**
* 在数据源已切换后调用
*/
public synchronized void initCacheIfNecessary() {
// 初次访问时将数据库初始数据写入缓存
List<SgFeedList> feedListsFromDataBase = this.selectSgFeedListList(new SgFeedList()); List<SgFeedList> feedListsFromDataBase = this.selectSgFeedListList(new SgFeedList());
for (SgFeedList sgFeedListItem : feedListsFromDataBase) { for (SgFeedList sgFeedListItem : feedListsFromDataBase) {
String key = sgFeedListItem.getFormulaId() + "_" + sgFeedListItem.getFormulaBatchId() + "_" + sgFeedListItem.getDeployDate(); String key = sgFeedListItem.getFormulaId() + "_" + sgFeedListItem.getFormulaBatchId() + "_" + sgFeedListItem.getDeployDate();
@@ -57,7 +68,6 @@ public class SgFeedListServiceImpl implements ISgFeedListService {
* @return 配料清单 * @return 配料清单
*/ */
@Override @Override
@DataScope(deptAlias = "sg_feed_list_alias", userAlias = "sg_feed_list_alias")
public List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList) { public List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList) {
return sgFeedListMapper.selectSgFeedListList(sgFeedList); return sgFeedListMapper.selectSgFeedListList(sgFeedList);
} }
@@ -159,6 +169,16 @@ public class SgFeedListServiceImpl implements ISgFeedListService {
} }
} }
public void syncFeedListSafely() {
try {
SyncFeedList();
} catch (Exception e) {
refresh.set(true); // 初始化失败,下次还能重试
throw e;
}
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void SyncFeedList() { public void SyncFeedList() {
HashMap<String, SgFeedList> cacheTemp = new HashMap<>(sgFeedListMap); HashMap<String, SgFeedList> cacheTemp = new HashMap<>(sgFeedListMap);
// 清空旧缓存 // 清空旧缓存

View File

@@ -3,7 +3,6 @@ package com.zhyc.module.feed.service.impl;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zhyc.module.feed.mapper.SgFeedPlanMapper; import com.zhyc.module.feed.mapper.SgFeedPlanMapper;
import com.zhyc.module.feed.domain.SgFeedPlan; import com.zhyc.module.feed.domain.SgFeedPlan;
@@ -12,13 +11,14 @@ import org.springframework.transaction.annotation.Transactional;
/** /**
* 饲喂计划Service业务层处理 * 饲喂计划Service业务层处理
* *
* @author HashMap * @author HashMap
* @date 2025-08-14 * @date 2025-08-14
*/ */
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor=Exception.class)
public class SgFeedPlanServiceImpl implements ISgFeedPlanService { public class SgFeedPlanServiceImpl implements ISgFeedPlanService
{
private final SgFeedPlanMapper sgFeedPlanMapper; private final SgFeedPlanMapper sgFeedPlanMapper;
public SgFeedPlanServiceImpl(SgFeedPlanMapper sgFeedPlanMapper) { public SgFeedPlanServiceImpl(SgFeedPlanMapper sgFeedPlanMapper) {
@@ -27,68 +27,73 @@ public class SgFeedPlanServiceImpl implements ISgFeedPlanService {
/** /**
* 查询饲喂计划 * 查询饲喂计划
* *
* @param createDate 饲喂计划主键 * @param createDate 饲喂计划主键
* @return 饲喂计划 * @return 饲喂计划
*/ */
@Override @Override
public SgFeedPlan selectSgFeedPlanByCreateDate(Date createDate) { public SgFeedPlan selectSgFeedPlanByCreateDate(Date createDate)
{
return sgFeedPlanMapper.selectSgFeedPlanByCreateDate(createDate); return sgFeedPlanMapper.selectSgFeedPlanByCreateDate(createDate);
} }
/** /**
* 查询饲喂计划列表 * 查询饲喂计划列表
* *
* @param sgFeedPlan 饲喂计划 * @param sgFeedPlan 饲喂计划
* @return 饲喂计划 * @return 饲喂计划
*/ */
@Override @Override
@DataScope(deptAlias = "sg_feed_plan_alias", userAlias = "sg_feed_plan_alias") public List<SgFeedPlan> selectSgFeedPlanList(SgFeedPlan sgFeedPlan)
public List<SgFeedPlan> selectSgFeedPlanList(SgFeedPlan sgFeedPlan) { {
return sgFeedPlanMapper.selectSgFeedPlanList(sgFeedPlan); return sgFeedPlanMapper.selectSgFeedPlanList(sgFeedPlan);
} }
/** /**
* 新增饲喂计划 * 新增饲喂计划
* *
* @param sgFeedPlan 饲喂计划 * @param sgFeedPlan 饲喂计划
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertSgFeedPlan(SgFeedPlan sgFeedPlan) { public int insertSgFeedPlan(SgFeedPlan sgFeedPlan)
{
return sgFeedPlanMapper.insertSgFeedPlan(sgFeedPlan); return sgFeedPlanMapper.insertSgFeedPlan(sgFeedPlan);
} }
/** /**
* 修改饲喂计划 * 修改饲喂计划
* *
* @param sgFeedPlan 饲喂计划 * @param sgFeedPlan 饲喂计划
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateSgFeedPlan(SgFeedPlan sgFeedPlan) { public int updateSgFeedPlan(SgFeedPlan sgFeedPlan)
{
return sgFeedPlanMapper.updateSgFeedPlan(sgFeedPlan); return sgFeedPlanMapper.updateSgFeedPlan(sgFeedPlan);
} }
/** /**
* 批量删除饲喂计划 * 批量删除饲喂计划
* *
* @param createDates 需要删除的饲喂计划主键 * @param createDates 需要删除的饲喂计划主键
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteSgFeedPlanByCreateDates(Date[] createDates) { public int deleteSgFeedPlanByCreateDates(Date[] createDates)
{
return sgFeedPlanMapper.deleteSgFeedPlanByCreateDates(createDates); return sgFeedPlanMapper.deleteSgFeedPlanByCreateDates(createDates);
} }
/** /**
* 删除饲喂计划信息 * 删除饲喂计划信息
* *
* @param createDate 饲喂计划主键 * @param createDate 饲喂计划主键
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteSgFeedPlanByCreateDate(Date createDate) { public int deleteSgFeedPlanByCreateDate(Date createDate)
{
return sgFeedPlanMapper.deleteSgFeedPlanByCreateDate(createDate); return sgFeedPlanMapper.deleteSgFeedPlanByCreateDate(createDate);
} }

View File

@@ -3,7 +3,6 @@ package com.zhyc.module.feed.service.impl;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.base.domain.DaSheepfold; import com.zhyc.module.base.domain.DaSheepfold;
import com.zhyc.module.feed.domain.SgFeedList; import com.zhyc.module.feed.domain.SgFeedList;
import com.zhyc.module.feed.domain.SgFeedPlan; import com.zhyc.module.feed.domain.SgFeedPlan;
@@ -52,7 +51,6 @@ public class SgFeedStatisticServiceImpl implements ISgFeedStatisticService {
* @return 饲喂量统计 * @return 饲喂量统计
*/ */
@Override @Override
@DataScope(deptAlias = "sg_feed_statistic_alias", userAlias = "sg_feed_statistic_alias")
public List<SgFeedStatistic> selectSgFeedStatisticList(SgFeedStatistic sgFeedStatistic) { public List<SgFeedStatistic> selectSgFeedStatisticList(SgFeedStatistic sgFeedStatistic) {
return sgFeedStatisticMapper.selectSgFeedStatisticList(sgFeedStatistic); return sgFeedStatisticMapper.selectSgFeedStatisticList(sgFeedStatistic);
} }

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.feed.service.impl;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zhyc.module.feed.mapper.SgFormulaListMapper; import com.zhyc.module.feed.mapper.SgFormulaListMapper;
import com.zhyc.module.feed.domain.SgFormulaList; import com.zhyc.module.feed.domain.SgFormulaList;
@@ -42,7 +41,6 @@ public class SgFormulaListServiceImpl implements ISgFormulaListService {
* @return 配方列表 * @return 配方列表
*/ */
@Override @Override
@DataScope(deptAlias = "sg_formula_list_alias", userAlias = "sg_formula_list_alias")
public List<SgFormulaList> selectSgFormulaListList(SgFormulaList sgFormulaList) { public List<SgFormulaList> selectSgFormulaListList(SgFormulaList sgFormulaList) {
return sgFormulaListMapper.selectSgFormulaListList(sgFormulaList); return sgFormulaListMapper.selectSgFormulaListList(sgFormulaList);
} }

View File

@@ -4,7 +4,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.feed.domain.SgFormulaList; import com.zhyc.module.feed.domain.SgFormulaList;
import com.zhyc.module.feed.mapper.SgFormulaListMapper; import com.zhyc.module.feed.mapper.SgFormulaListMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -47,7 +46,6 @@ public class SgFormulaManagementServiceImpl implements ISgFormulaManagementServi
* @return 配方管理 * @return 配方管理
*/ */
@Override @Override
@DataScope(deptAlias = "sg_formula_management_alias", userAlias = "sg_formula_management_alias")
public List<SgFormulaManagement> selectSgFormulaManagementList(SgFormulaManagement sgFormulaManagement) { public List<SgFormulaManagement> selectSgFormulaManagementList(SgFormulaManagement sgFormulaManagement) {
List<SgFormulaManagement> sgFormulaManagements = List<SgFormulaManagement> sgFormulaManagements =
sgFormulaManagementMapper.selectSgFormulaManagementList(sgFormulaManagement); sgFormulaManagementMapper.selectSgFormulaManagementList(sgFormulaManagement);

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.feed.service.impl;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zhyc.module.feed.mapper.SgMaterialMapper; import com.zhyc.module.feed.mapper.SgMaterialMapper;
@@ -38,7 +37,6 @@ public class SgMaterialServiceImpl implements ISgMaterialService {
* @return 原料 * @return 原料
*/ */
@Override @Override
@DataScope(deptAlias = "sg_material_alias", userAlias = "sg_material_alias")
public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial) { public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial) {
return sgMaterialMapper.selectSgMaterialList(sgMaterial); return sgMaterialMapper.selectSgMaterialList(sgMaterial);
} }

View File

@@ -3,11 +3,6 @@ package com.zhyc.module.produce.bodyManage.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.service.IBasSheepService;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -19,28 +14,28 @@ import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure;
import com.zhyc.module.produce.bodyManage.service.IScBodyMeasureService; import com.zhyc.module.produce.bodyManage.service.IScBodyMeasureService;
import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo; import com.zhyc.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 体尺测量Controller * 体尺测量Controller
* *
* @author ruoyi * @author ruoyi
* @date 2025-07-27 * @date 2025-07-27
*/ */
@RestController @RestController
@RequestMapping("/body_measure/body_measure") @RequestMapping("/body_measure/body_measure")
public class ScBodyMeasureController extends BaseController { public class ScBodyMeasureController extends BaseController
{
@Autowired @Autowired
private IScBodyMeasureService scBodyMeasureService; private IScBodyMeasureService scBodyMeasureService;
@Autowired
private IBasSheepService basSheepService;
/** /**
* 查询体尺测量列表 * 查询体尺测量列表
*/ */
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:list')") @PreAuthorize("@ss.hasPermi('body_measure:body_measure:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(ScBodyMeasure scBodyMeasure) { public TableDataInfo list(ScBodyMeasure scBodyMeasure)
{
startPage(); startPage();
List<ScBodyMeasure> list = scBodyMeasureService.selectScBodyMeasureList(scBodyMeasure); List<ScBodyMeasure> list = scBodyMeasureService.selectScBodyMeasureList(scBodyMeasure);
return getDataTable(list); return getDataTable(list);
@@ -52,7 +47,8 @@ public class ScBodyMeasureController extends BaseController {
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:export')") @PreAuthorize("@ss.hasPermi('body_measure:body_measure:export')")
@Log(title = "体尺测量", businessType = BusinessType.EXPORT) @Log(title = "体尺测量", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, ScBodyMeasure scBodyMeasure) { public void export(HttpServletResponse response, ScBodyMeasure scBodyMeasure)
{
List<ScBodyMeasure> list = scBodyMeasureService.selectScBodyMeasureList(scBodyMeasure); List<ScBodyMeasure> list = scBodyMeasureService.selectScBodyMeasureList(scBodyMeasure);
ExcelUtil<ScBodyMeasure> util = new ExcelUtil<ScBodyMeasure>(ScBodyMeasure.class); ExcelUtil<ScBodyMeasure> util = new ExcelUtil<ScBodyMeasure>(ScBodyMeasure.class);
util.exportExcel(response, list, "体尺测量数据"); util.exportExcel(response, list, "体尺测量数据");
@@ -63,7 +59,8 @@ public class ScBodyMeasureController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:query')") @PreAuthorize("@ss.hasPermi('body_measure:body_measure:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) { public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(scBodyMeasureService.selectScBodyMeasureById(id)); return success(scBodyMeasureService.selectScBodyMeasureById(id));
} }
@@ -73,7 +70,8 @@ public class ScBodyMeasureController extends BaseController {
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:add')") @PreAuthorize("@ss.hasPermi('body_measure:body_measure:add')")
@Log(title = "体尺测量", businessType = BusinessType.INSERT) @Log(title = "体尺测量", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody ScBodyMeasure scBodyMeasure) { public AjaxResult add(@RequestBody ScBodyMeasure scBodyMeasure)
{
return toAjax(scBodyMeasureService.insertScBodyMeasure(scBodyMeasure)); return toAjax(scBodyMeasureService.insertScBodyMeasure(scBodyMeasure));
} }
@@ -83,7 +81,8 @@ public class ScBodyMeasureController extends BaseController {
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:edit')") @PreAuthorize("@ss.hasPermi('body_measure:body_measure:edit')")
@Log(title = "体尺测量", businessType = BusinessType.UPDATE) @Log(title = "体尺测量", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody ScBodyMeasure scBodyMeasure) { public AjaxResult edit(@RequestBody ScBodyMeasure scBodyMeasure)
{
return toAjax(scBodyMeasureService.updateScBodyMeasure(scBodyMeasure)); return toAjax(scBodyMeasureService.updateScBodyMeasure(scBodyMeasure));
} }
@@ -92,82 +91,14 @@ public class ScBodyMeasureController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:remove')") @PreAuthorize("@ss.hasPermi('body_measure:body_measure:remove')")
@Log(title = "体尺测量", businessType = BusinessType.DELETE) @Log(title = "体尺测量", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(scBodyMeasureService.deleteScBodyMeasureByIds(ids)); return toAjax(scBodyMeasureService.deleteScBodyMeasureByIds(ids));
} }
@GetMapping("/search_ear_numbers") @GetMapping("/search_ear_numbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) { public AjaxResult searchEarNumbers(@RequestParam("query") String query){
return success(scBodyMeasureService.searchEarNumbers(query.trim())); return success(scBodyMeasureService.searchEarNumbers(query.trim()));
} }
/**
* 导入体尺测量数据
*/
@PreAuthorize("@ss.hasPermi('body_measure:body_measure:import')")
@Log(title = "体尺测量", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importData(@RequestParam("file") MultipartFile file) throws Exception {
ExcelUtil<ScBodyMeasure> util = new ExcelUtil<>(ScBodyMeasure.class);
List<ScBodyMeasure> list = util.importExcel(file.getInputStream());
// 数据校验和处理
StringBuilder errorMsg = new StringBuilder();
int successCount = 0;
int failCount = 0;
for (int i = 0; i < list.size(); i++) {
ScBodyMeasure measure = list.get(i);
try {
// 根据耳号查询羊只ID
if (StringUtils.isNotBlank(measure.getManageTags())) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(measure.getManageTags().trim());
if (sheep == null) {
failCount++;
errorMsg.append("").append(i + 2).append("行:耳号【")
.append(measure.getManageTags()).append("】不存在;");
continue;
}
measure.setSheepId(sheep.getId());
} else {
failCount++;
errorMsg.append("").append(i + 2).append("行:耳号不能为空;");
continue;
}
// 设置默认值
measure.setCreateTime(DateUtils.getNowDate());
measure.setCreateBy(SecurityUtils.getUsername());
scBodyMeasureService.insertScBodyMeasure(measure);
successCount++;
// 更新羊只当前体重
if (measure.getCurrentWeight() != null) {
BasSheep updateSheep = new BasSheep();
updateSheep.setId(measure.getSheepId());
updateSheep.setCurrentWeight(measure.getCurrentWeight());
basSheepService.updateBasSheep(updateSheep);
}
} catch (Exception e) {
failCount++;
errorMsg.append("").append(i + 2).append("行:").append(e.getMessage()).append("");
}
}
String msg = String.format("导入完成:成功%d条失败%d条", successCount, failCount);
if (failCount > 0) {
msg += ";失败原因:" + errorMsg.toString();
}
return success(msg);
}
/**
* 获取繁殖状态列表(用于下拉选择)
*/
@GetMapping("/breedStatus")
public AjaxResult listBreedStatus() {
return success(scBodyMeasureService.selectBreedStatusList());
}
} }

View File

@@ -1,16 +1,13 @@
package com.zhyc.module.produce.bodyManage.domain; package com.zhyc.module.produce.bodyManage.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import com.zhyc.common.annotation.Excel; import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity; import com.zhyc.common.core.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@@ -65,10 +62,8 @@ public class ScBodyMeasure extends BaseEntity {
/** /**
* 测量日期 * 测量日期
*/ */
@Excel(name = "测量日期", dateFormat = "yyyy-MM-dd") @Excel(name = "测量日期")
@JsonFormat(pattern = "yyyy-MM-dd") private LocalDate measureDate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date measureDate;
/** /**
* 羊只类别 * 羊只类别
*/ */
@@ -87,12 +82,10 @@ public class ScBodyMeasure extends BaseEntity {
/** /**
* 出生体重 * 出生体重
*/ */
@Excel(name = "出生体重")
private BigDecimal birthWeight; private BigDecimal birthWeight;
/** /**
* 断奶体重 * 断奶体重
*/ */
@Excel(name = "断奶体重")
private BigDecimal weaningWeight; private BigDecimal weaningWeight;
/** /**
* 当前体重 * 当前体重
@@ -180,13 +173,6 @@ public class ScBodyMeasure extends BaseEntity {
*/ */
@Excel(name = "配后天数") @Excel(name = "配后天数")
private Integer postMatingDay; private Integer postMatingDay;
/**
* 技术员
*/
@Excel(name = "技术员")
private String technician;
/** /**
* 备注 * 备注
*/ */
@@ -194,22 +180,12 @@ public class ScBodyMeasure extends BaseEntity {
private String comment; private String comment;
/** /**
* 前端多耳号查询条件,非表字段 * 技术员
*/ */
@Excel(name = "技术员")
private String technician;
/** 前端多耳号查询条件,非表字段 */
private List<String> manageTagsList; private List<String> manageTagsList;
/**
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 月龄查询条件(开始),非数据库字段
*/
private Integer monthAgeStart;
/**
* 月龄查询条件(结束),非数据库字段
*/
private Integer monthAgeEnd;
} }

View File

@@ -78,13 +78,6 @@ public class ScBodyScore extends BaseEntity {
@Excel(name = "技术员") @Excel(name = "技术员")
private String technician; private String technician;
/** /** 前端多耳号查询条件,非表字段 */
* 前端多耳号查询条件,非表字段
*/
private List<String> manageTagsList; private List<String> manageTagsList;
/**
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
} }

View File

@@ -111,13 +111,7 @@ public class ScBreastRating extends BaseEntity {
@Excel(name = "技术员") @Excel(name = "技术员")
private String technician; private String technician;
/**
* 前端多耳号查询条件,非表字段
*/
private List<String> manageTagsList;
/** /** 前端多耳号查询条件,非表字段 */
* 是否在群查询条件0-在群1-离群),非数据库字段 private List<String> manageTagsList;
*/
private Integer isDelete;
} }

View File

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

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