测试数据

This commit is contained in:
lhx
2025-11-19 18:32:56 +08:00
parent 940bef8c06
commit 02e13aa755
15 changed files with 510 additions and 93 deletions

View File

@@ -0,0 +1,27 @@
package com.dc.dc_project.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CorsConfig {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**") // 允许所有路径
.allowedOrigins("http://localhost:8080", // 你的前端开发服务器地址
"http://localhost:3000",
"http://localhost:8000",
"https://www.yourfrontend.com" ) // 允许的来源(可修改为前端地址)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 允许的请求方法
.allowedHeaders("*") // 允许所有请求头
.allowCredentials(false); // 允许携带 Cookie
}
};
}
}

View File

@@ -1,27 +1,27 @@
package com.dc.dc_project.config;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class SaTokenConfigure implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SaInterceptor(h -> {
SaManager.getLog().debug("----- 请求path={} 提交token={}", SaHolder.getRequest().getRequestPath(), StpUtil.getTokenValue());
SaRouter.match("/project/**").check(StpUtil::checkLogin);
})).addPathPatterns("/**");
}
}
//package com.dc.dc_project.config;
//
//import cn.dev33.satoken.SaManager;
//import cn.dev33.satoken.context.SaHolder;
//import cn.dev33.satoken.interceptor.SaInterceptor;
//import cn.dev33.satoken.router.SaRouter;
//import cn.dev33.satoken.stp.StpUtil;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//
//@Configuration
//@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
//public class SaTokenConfigure implements WebMvcConfigurer {
//
// @Override
// public void addInterceptors(InterceptorRegistry registry) {
// registry.addInterceptor(new SaInterceptor(h -> {
//
// SaManager.getLog().debug("----- 请求path={} 提交token={}", SaHolder.getRequest().getRequestPath(), StpUtil.getTokenValue());
// SaRouter.match("/project/**").check(StpUtil::checkLogin);
// })).addPathPatterns("/**");
// }
//
//}

View File

@@ -1,46 +1,46 @@
package com.dc.dc_project.config;
import cn.dev33.satoken.stp.StpInterface;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dc.dc_project.model.pojo.Role;
import com.dc.dc_project.model.pojo.UserRole;
import com.dc.dc_project.service.RoleService;
import com.dc.dc_project.service.UserRoleService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 权限加载接口实现类
*/
@Component
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class StpInterfaceImpl implements StpInterface {
@Autowired
private UserRoleService userRoleService;
@Autowired
private RoleService roleService;
/**
* 返回一个账号所拥有的权限码集合
*/
@Override
public List<String> getPermissionList(Object loginId, String loginType) {
LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, Long.valueOf(loginId.toString()));
List<Long> roleIds = userRoleService.list(lambdaQueryWrapper).stream().map(UserRole::getRoleId).toList();
return roleService.list(new LambdaQueryWrapper<Role>().in(Role::getId, roleIds)).stream().map(Role::getCode).toList();
}
/**
* 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
*/
@Override
public List<String> getRoleList(Object loginId, String loginType) {
LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, Long.valueOf(loginId.toString()));
List<Long> roleIds = userRoleService.list(lambdaQueryWrapper).stream().map(UserRole::getRoleId).toList();
return roleService.list(new LambdaQueryWrapper<Role>().in(Role::getId, roleIds)).stream().map(Role::getCode).toList();
}
}
//package com.dc.dc_project.config;
//
//import cn.dev33.satoken.stp.StpInterface;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.dc.dc_project.model.pojo.Role;
//import com.dc.dc_project.model.pojo.UserRole;
//import com.dc.dc_project.service.RoleService;
//import com.dc.dc_project.service.UserRoleService;
//import lombok.RequiredArgsConstructor;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import java.util.List;
//
///**
// * 权限加载接口实现类
// */
//@Component
//@RequiredArgsConstructor(onConstructor_ = {@Autowired})
//public class StpInterfaceImpl implements StpInterface {
//
// @Autowired
// private UserRoleService userRoleService;
//
// @Autowired
// private RoleService roleService;
// /**
// * 返回一个账号所拥有的权限码集合
// */
// @Override
// public List<String> getPermissionList(Object loginId, String loginType) {
// LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, Long.valueOf(loginId.toString()));
// List<Long> roleIds = userRoleService.list(lambdaQueryWrapper).stream().map(UserRole::getRoleId).toList();
// return roleService.list(new LambdaQueryWrapper<Role>().in(Role::getId, roleIds)).stream().map(Role::getCode).toList();
// }
//
// /**
// * 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
// */
// @Override
// public List<String> getRoleList(Object loginId, String loginType) {
// LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, Long.valueOf(loginId.toString()));
// List<Long> roleIds = userRoleService.list(lambdaQueryWrapper).stream().map(UserRole::getRoleId).toList();
// return roleService.list(new LambdaQueryWrapper<Role>().in(Role::getId, roleIds)).stream().map(Role::getCode).toList();
// }
//
//}

View File

@@ -0,0 +1,28 @@
package com.dc.dc_project.controller;
import cn.dev33.satoken.stp.StpUtil;
import com.dc.dc_project.common.ResponseResult;
import com.dc.dc_project.model.dto.RoleDto;
import com.dc.dc_project.model.pojo.RecordResult;
import com.dc.dc_project.service.RoleService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/role")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class RoleController {
private final RoleService roleService;
@PostMapping("/list")
public ResponseResult list(@RequestBody RoleDto roleDto) {
Long userId = StpUtil.getLoginIdAsLong();
return roleService.getList(roleDto, userId);
}
}

View File

@@ -1,9 +1,11 @@
package com.dc.dc_project.controller;
import cn.dev33.satoken.stp.StpUtil;
import com.dc.dc_project.common.ResponseResult;
import com.dc.dc_project.model.dto.user.UpdateUserPasswordDto;
import com.dc.dc_project.model.dto.user.UserInfoUpdateDto;
import com.dc.dc_project.model.dto.user.UserReqDto;
import com.dc.dc_project.model.pojo.RecordResult;
import com.dc.dc_project.model.pojo.User;
import com.dc.dc_project.service.UserService;
@@ -21,6 +23,12 @@ public class UserController {
private final UserService userService;
@PostMapping("/list")
public ResponseResult UserList(@RequestBody UserReqDto userReqDto) {
Long userId = StpUtil.getLoginIdAsLong();
return userService.UserList(userReqDto, userId);
}
@PostMapping("/getUserInfo")
ResponseResult getUserInfo() {
return userService.getUserInfo();

View File

@@ -0,0 +1,18 @@
package com.dc.dc_project.model.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class RoleDto extends BasePage<RoleDto>{
private String name;
private String code;
private Long level;
private Long status;
}

View File

@@ -0,0 +1,27 @@
package com.dc.dc_project.model.dto.user;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserReqDto extends Page<UserReqDto> {
private String name;
private String phone;
private String email;
private String status;
private Long orgId;
}

View File

@@ -1,5 +1,6 @@
package com.dc.dc_project.model.vo.bigScreen;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -22,6 +23,11 @@ public class RecordStatisticsVo {
private String engineeringName;
private String engineeringId;
/**
* 检测项目名称
*/
private String projectName;
/**
* 委托总数量
*/
@@ -42,5 +48,15 @@ public class RecordStatisticsVo {
*/
private Double unqualifiedRate;
private Page<RecordStatisticsVo> page;
public RecordStatisticsVo(String engineeringName, String engineeringId, String projectName, Long entrustCount, Long reportCount, Long unqualifiedCount) {
this.engineeringName = engineeringName;
this.engineeringId = engineeringId;
this.projectName = projectName;
this.entrustCount = entrustCount;
this.reportCount = reportCount;
this.unqualifiedCount = unqualifiedCount;
}
}

View File

@@ -1,5 +1,8 @@
package com.dc.dc_project.service;
import com.dc.dc_project.common.ResponseResult;
import com.dc.dc_project.model.dto.RoleDto;
import com.dc.dc_project.model.pojo.RecordResult;
import com.dc.dc_project.model.pojo.Role;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -10,4 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface RoleService extends IService<Role> {
ResponseResult getList(RoleDto roleDto, Long userId);
}

View File

@@ -2,6 +2,7 @@ package com.dc.dc_project.service;
import com.dc.dc_project.common.ResponseResult;
import com.dc.dc_project.model.dto.user.LoginDto;
import com.dc.dc_project.model.dto.user.UserReqDto;
import com.dc.dc_project.model.pojo.RecordResult;
import com.dc.dc_project.model.pojo.User;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -28,4 +29,12 @@ public interface UserService extends IService<User> {
* @return
*/
ResponseResult getUserInfo();
/**
* 用户列表
* @param userReqDto
* @param userId
* @return
*/
ResponseResult UserList(UserReqDto userReqDto, Long userId);
}

View File

@@ -12,9 +12,11 @@ import com.dc.dc_project.model.dto.bigScreen.SystemWarningDto;
import com.dc.dc_project.model.vo.BasePageVo;
import com.dc.dc_project.model.vo.bigScreen.*;
import com.dc.dc_project.service.*;
import com.dc.dc_project.temp.data;
import com.dc.dc_project.utils.DateUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.tags.EditorAwareTag;
import java.time.LocalDateTime;
import java.time.YearMonth;
@@ -41,14 +43,20 @@ public class BigScreenServiceImpl implements BigScreenService {
//试验室
bigScreenStatistics.setLaboratoryCount(laboratoryService.count());
//设备
bigScreenStatistics.setDeviceCount(equipmentService.count());
//bigScreenStatistics.setDeviceCount(equipmentService.count());
bigScreenStatistics.setDeviceCount(2313L);
//人员
bigScreenStatistics.setPersonCount(personnelService.count());
//bigScreenStatistics.setPersonCount(personnelService.count());
bigScreenStatistics.setPersonCount(433L);
//工程数
bigScreenStatistics.setProjectCount(standardService.count());
bigScreenStatistics.setProjectBuildingCount(standardService.count());
bigScreenStatistics.setProjectCompletedCount(standardService.count());
bigScreenStatistics.setEntrustCount(recordEntrustService.count());
//bigScreenStatistics.setProjectCount(standardService.count());
//bigScreenStatistics.setProjectBuildingCount(standardService.count());
//bigScreenStatistics.setProjectCompletedCount(standardService.count());
//bigScreenStatistics.setEntrustCount(recordEntrustService.count());
bigScreenStatistics.setProjectCount(291L);
bigScreenStatistics.setProjectBuildingCount(190L);
bigScreenStatistics.setProjectCompletedCount(101L);
bigScreenStatistics.setEntrustCount(5466L);
return ResponseResult.success(bigScreenStatistics);
}
@@ -57,6 +65,15 @@ public class BigScreenServiceImpl implements BigScreenService {
// 获取本年时间
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
RecordEntrustStatisticsVo root = new RecordEntrustStatisticsVo(DateUtils.getCurrentYear());
Long ii = 5466L;
Long jj = 4936L;
root.setEntrustCount(ii);
root.setReportCount(jj);
// 将总数随机分成12份用于每月数据
long[] entrustCounts = distributeRandomly(ii, 12);
long[] reportCounts = distributeRandomly(jj, 12);
for (int i = 1; i < 13; i++) {
int year = LocalDateTime.now().getYear();
// 本年开始时间1月1日 00:00:00
@@ -74,6 +91,11 @@ public class BigScreenServiceImpl implements BigScreenService {
recordEntrustStatistics.setReportCount(
recordReportService.getCountByTime(startTimeStr, endTimeStr)
);
// 使用分配好的假数据确保entrustCount比reportCount大
recordEntrustStatistics.setEntrustCount(entrustCounts[i-1]);
recordEntrustStatistics.setReportCount(reportCounts[i-1]);
root.getRecordEntrustStatisticsVos().add(recordEntrustStatistics);
}
return ResponseResult.success(root);
@@ -92,20 +114,34 @@ public class BigScreenServiceImpl implements BigScreenService {
String endTimeStr = endTime.format(dtf);
Page<RecordStatisticsVo> page = new Page<>(
recordBigScreenDto.getCurrent(), recordBigScreenDto.getSize());
RecordStatisticsVo root = new RecordStatisticsVo();
root.setYear(recordBigScreenDto.getYear());
Long ii = 5466L;
Long jj = 4936L;
Long kk = 132L;
root.setEntrustCount(ii);
root.setReportCount(jj);
root.setUnqualifiedCount(kk);
root.setUnqualifiedRate(kk * 1.0 / jj);
if (recordBigScreenDto.getTypeMode() == 1) {
// 工程
page = recordEntrustMapper.getCountByTimeGroupE(startTimeStr, endTimeStr, page);
//工程
//page = recordEntrustMapper.getCountByTimeGroupE(startTimeStr, endTimeStr, page);
page = data.getRecordStatisticsVo();
for (RecordStatisticsVo recordStatisticsVo : page.getRecords()) {
recordStatisticsVo.setYear(recordBigScreenDto.getYear());
recordStatisticsVo.setUnqualifiedRate(recordStatisticsVo.getUnqualifiedCount() * 1.0 / recordStatisticsVo.getReportCount());
}
} else if (recordBigScreenDto.getTypeMode() == 2) {
// 按项目
for (RecordStatisticsVo recordStatisticsVo : page.getRecords()) {
recordStatisticsVo.setYear(recordBigScreenDto.getYear());
recordStatisticsVo.setUnqualifiedRate(recordStatisticsVo.getUnqualifiedCount() * 1.0 / recordStatisticsVo.getReportCount());
}
} else {
return ResponseResult.error("参数错误");
}
return ResponseResult.success(page);
root.setPage(page);
return ResponseResult.success(root);
}
@Override
@@ -117,16 +153,28 @@ public class BigScreenServiceImpl implements BigScreenService {
// 数量统计
IPage<SystemWarningItemVo> page = new Page<>(systemWarningDto.getCurrent(), systemWarningDto.getSize());
Page<SystemWarningItemVo> checkOverdue = equipmentMapper.getCheckOverdueCount(nowStr, page);
Page<SystemWarningItemVo> checkExpiring = equipmentMapper.getCheckExpiringCount(nowStr, page);
Page<SystemWarningItemVo> checkNotCheckedCount = recordSampleMapper.getCheckNotCheckedCount(nowStr, page);
Page<SystemWarningItemVo> checkNotChecked = recordSampleMapper.getCheckNotChecked(nowStr, page);
//Page<SystemWarningItemVo> checkOverdue = equipmentMapper.getCheckOverdueCount(nowStr, page);
//Page<SystemWarningItemVo> checkExpiring = equipmentMapper.getCheckExpiringCount(nowStr, page);
//Page<SystemWarningItemVo> checkNotCheckedCount = recordSampleMapper.getCheckNotCheckedCount(nowStr, page);
//Page<SystemWarningItemVo> checkNotChecked = recordSampleMapper.getCheckNotChecked(nowStr, page);
Page<SystemWarningItemVo> checkOverdue = data.getCheckOverdueCount();
Page<SystemWarningItemVo> checkExpiring = data.getCheckExpiringCount();
Page<SystemWarningItemVo> checkNotCheckedCount = data.getCheckNotCheckedCount();
Page<SystemWarningItemVo> checkNotChecked = data.getCheckNotChecked();
//SystemWarningVo systemWarningVo = new SystemWarningVo(
// checkOverdue.getTotal(),
// checkExpiring.getTotal(),
// checkNotCheckedCount.getTotal(),
// checkNotChecked.getTotal(),
// checkOverdue
//);
SystemWarningVo systemWarningVo = new SystemWarningVo(
checkOverdue.getTotal(),
checkExpiring.getTotal(),
checkNotCheckedCount.getTotal(),
checkNotChecked.getTotal(),
10L,
12L,
23L,
14L,
checkOverdue
);
if (systemWarningDto.getTypeMode() == 2) {
@@ -139,5 +187,39 @@ public class BigScreenServiceImpl implements BigScreenService {
return ResponseResult.success(systemWarningVo);
}
/**
* 将总数随机分成指定份数
* @param total 总数
* @param parts 份数
* @return 每份的数量数组
*/
private long[] distributeRandomly(Long total, int parts) {
long[] result = new long[parts];
long remaining = total;
// 为前parts-1个月生成随机数
for (int i = 0; i < parts - 1; i++) {
// 每个月最多分配剩余数量的平均值的2倍但至少分配1
long max = Math.max(1, (remaining * 2) / (parts - i));
long value = Math.max(1, (long) (Math.random() * max));
// 确保不会超过剩余数量
value = Math.min(value, remaining - (parts - i - 1));
result[i] = value;
remaining -= value;
}
// 最后一个月分配剩余的所有数量
result[parts - 1] = remaining;
// 打乱数组顺序使数据更自然
for (int i = 0; i < parts; i++) {
int j = (int) (Math.random() * parts);
long temp = result[i];
result[i] = result[j];
result[j] = temp;
}
return result;
}
}

View File

@@ -1,6 +1,11 @@
package com.dc.dc_project.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dc.dc_project.common.ResponseResult;
import com.dc.dc_project.model.dto.RoleDto;
import com.dc.dc_project.model.pojo.RecordResult;
import com.dc.dc_project.model.pojo.Role;
import com.dc.dc_project.service.RoleService;
import com.dc.dc_project.mapper.RoleMapper;
@@ -17,6 +22,17 @@ import lombok.extern.slf4j.Slf4j;
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role>
implements RoleService{
@Override
public ResponseResult getList(RoleDto roleDto, Long userId) {
LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper
.like(roleDto.getName() != null, Role::getName, roleDto.getName())
.like(roleDto.getCode() != null,Role::getCode, roleDto.getCode())
.eq(roleDto.getLevel() != null,Role::getLevel, roleDto.getLevel())
.eq(roleDto.getStatus() != null,Role::getStatus, roleDto.getStatus());
Page<Role> page = new Page<>(roleDto.getCurrent(), roleDto.getSize());
return ResponseResult.success(this.page(page, queryWrapper));
}
}

View File

@@ -7,6 +7,7 @@ import com.dc.dc_project.common.ResponseResult;
import com.dc.dc_project.common.ResultCode;
import com.dc.dc_project.mapper.*;
import com.dc.dc_project.model.dto.user.LoginDto;
import com.dc.dc_project.model.dto.user.UserReqDto;
import com.dc.dc_project.model.pojo.*;
import com.dc.dc_project.model.vo.PersonnelVo;
import com.dc.dc_project.model.vo.PositionVo;
@@ -90,6 +91,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
}
@Override
public ResponseResult UserList(UserReqDto userReqDto, Long userId) {
return null;
}
}

View File

@@ -0,0 +1,175 @@
package com.dc.dc_project.temp;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dc.dc_project.model.vo.bigScreen.RecordStatisticsVo;
import com.dc.dc_project.model.vo.bigScreen.SystemWarningItemVo;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
@Configuration
public class data {
// 超期未检设备 (已过期的设备)
public static Page<SystemWarningItemVo> getCheckOverdueCount() {
Page<SystemWarningItemVo> page = new Page<>(1, 10);
List<SystemWarningItemVo> records = Arrays.asList(
new SystemWarningItemVo(1L, "万能材料试验机", "2025-10-25", 25L),
new SystemWarningItemVo(2L, "水泥胶砂搅拌机", "2025-11-05", 14L),
new SystemWarningItemVo(3L, "沥青针入度仪", "2025-11-10", 9L),
new SystemWarningItemVo(4L, "混凝土含气量测定仪", "2025-11-15", 4L),
new SystemWarningItemVo(5L, "钢筋标距仪", "2025-11-17", 2L),
new SystemWarningItemVo(6L, "电动击实仪", "2025-11-18", 1L),
new SystemWarningItemVo(7L, "路面平整度检测仪", "2025-11-18", 1L),
new SystemWarningItemVo(8L, "摆式摩擦系数测定仪", "2025-11-17", 2L),
new SystemWarningItemVo(9L, "砂当量仪", "2025-11-16", 3L),
new SystemWarningItemVo(10L, "马歇尔稳定度仪", "2025-11-12", 7L)
);
page.setRecords(records);
return page;
}
// 临期未检校设备 (即将到期的设备)
public static Page<SystemWarningItemVo> getCheckExpiringCount() {
Page<SystemWarningItemVo> page = new Page<>(1, 12);
List<SystemWarningItemVo> records = Arrays.asList(
new SystemWarningItemVo(1L, "混凝土坍落度筒", "2025-11-20", 1L),
new SystemWarningItemVo(2L, "集料压碎值试验仪", "2025-11-21", 2L),
new SystemWarningItemVo(3L, "水泥净浆搅拌机", "2025-11-22", 3L),
new SystemWarningItemVo(4L, "沥青延度仪", "2025-11-23", 4L),
new SystemWarningItemVo(5L, "水泥安定性试验仪", "2025-11-24", 5L),
new SystemWarningItemVo(6L, "细集料棱角性测定仪", "2025-11-25", 6L),
new SystemWarningItemVo(7L, "粗集料磨光值测定仪", "2025-11-26", 7L),
new SystemWarningItemVo(8L, "土工布透水性测试仪", "2025-11-27", 8L),
new SystemWarningItemVo(9L, "路面构造深度测试仪", "2025-11-28", 9L),
new SystemWarningItemVo(10L, "水泥胶砂流动度测定仪", "2025-11-29", 10L),
new SystemWarningItemVo(11L, "沥青混合料车辙试验机", "2025-11-30", 11L),
new SystemWarningItemVo(12L, "路基弯沉检测仪", "2025-12-01", 12L)
);
page.setRecords(records);
return page;
}
// 超期未检测样品 (已过期的样品)
public static Page<SystemWarningItemVo> getCheckNotCheckedCount() {
Page<SystemWarningItemVo> page = new Page<>(1, 23);
List<SystemWarningItemVo> records = Arrays.asList(
new SystemWarningItemVo(1L, "沥青混合料试件", "2025-11-01", 18L),
new SystemWarningItemVo(2L, "水泥混凝土试块", "2025-11-03", 16L),
new SystemWarningItemVo(3L, "钢筋焊接接头", "2025-11-05", 14L),
new SystemWarningItemVo(4L, "路基填土压实度", "2025-11-07", 12L),
new SystemWarningItemVo(5L, "桥梁支座试件", "2025-11-08", 11L),
new SystemWarningItemVo(6L, "隧道喷射混凝土", "2025-11-09", 10L),
new SystemWarningItemVo(7L, "级配碎石样品", "2025-11-10", 9L),
new SystemWarningItemVo(8L, "水泥稳定碎石", "2025-11-11", 8L),
new SystemWarningItemVo(9L, "粉煤灰样品", "2025-11-12", 7L),
new SystemWarningItemVo(10L, "矿粉活性指数", "2025-11-13", 6L),
new SystemWarningItemVo(11L, "外加剂样品", "2025-11-14", 5L),
new SystemWarningItemVo(12L, "防水卷材样品", "2025-11-15", 4L),
new SystemWarningItemVo(13L, "桥梁预应力锚具", "2025-11-15", 4L),
new SystemWarningItemVo(14L, "波纹管环刚度", "2025-11-16", 3L),
new SystemWarningItemVo(15L, "伸缩缝橡胶条", "2025-11-16", 3L),
new SystemWarningItemVo(16L, "声测管密闭性", "2025-11-17", 2L),
new SystemWarningItemVo(17L, "钢绞线力学性能", "2025-11-17", 2L),
new SystemWarningItemVo(18L, "桥梁支座滑板", "2025-11-18", 1L),
new SystemWarningItemVo(19L, "隧道防水板", "2025-11-18", 1L),
new SystemWarningItemVo(20L, "排水盲管", "2025-11-18", 1L),
new SystemWarningItemVo(21L, "护栏立柱", "2025-11-18", 1L),
new SystemWarningItemVo(22L, "标志牌反光膜", "2025-11-18", 1L),
new SystemWarningItemVo(23L, "标线涂料", "2025-11-18", 1L)
);
page.setRecords(records);
return page;
}
// 临期将检样品 (即将检测的样品)
public static Page<SystemWarningItemVo> getCheckNotChecked() {
Page<SystemWarningItemVo> page = new Page<>(1, 14);
List<SystemWarningItemVo> records = Arrays.asList(
new SystemWarningItemVo(1L, "沥青路面芯样", "2025-11-20", 1L),
new SystemWarningItemVo(2L, "水泥剂量", "2025-11-21", 2L),
new SystemWarningItemVo(3L, "石灰有效钙镁含量", "2025-11-22", 3L),
new SystemWarningItemVo(4L, "基层混合料强度", "2025-11-23", 4L),
new SystemWarningItemVo(5L, "路基弯沉值", "2025-11-24", 5L),
new SystemWarningItemVo(6L, "桥梁静载试验", "2025-11-25", 6L),
new SystemWarningItemVo(7L, "隧道地质雷达", "2025-11-26", 7L),
new SystemWarningItemVo(8L, "边坡稳定性监测", "2025-11-27", 8L),
new SystemWarningItemVo(9L, "桥梁动载试验", "2025-11-28", 9L),
new SystemWarningItemVo(10L, "路面抗滑性能", "2025-11-29", 10L),
new SystemWarningItemVo(11L, "排水系统流量", "2025-11-30", 11L),
new SystemWarningItemVo(12L, "交通安全设施", "2025-12-01", 12L),
new SystemWarningItemVo(13L, "机电系统联调", "2025-12-02", 13L),
new SystemWarningItemVo(14L, "绿化成活率", "2025-12-03", 14L)
);
page.setRecords(records);
return page;
}
private static final List<String> PROJECT_NAMES = Arrays.asList(
"京沪高速公路扩建工程", "G4京港澳高速路面大修工程", "某市轨道交通一号线项目", "S32省道桥梁检测项目",
"城市地下综合管廊施工", "跨海大桥结构健康监测工程", "某县乡村道改造工程", "山区隧道照明与通风升级",
"高速公路服务区改扩建", "港口集装箱码头建设工程",
"南水北调中线应急供水", "三峡工程泄洪闸检修", "黄河下游河道整治项目", "长江干堤防洪能力提升",
"小浪底水利枢纽调度中心", "某中型水库除险加固工程", "城市内涝防治排水系统", "农田水利高效节水灌溉",
"海河水系综合治理工程", "珠江三角洲水资源配置项目", "葛洲坝C2标段工程", "引江补汉工程"
);
private static final List<String> TEST_ITEMS = Arrays.asList(
"混凝土抗压强度", "钢筋力学性能", "沥青混合料马歇尔试验", "砂石集料筛分", "水泥安定性检测",
"土样颗粒分析", "地基承载力检测", "桩基完整性检测", "路面平整度检测", "水质常规分析",
"岩石力学试验", "结构物外观检查", "沉降观测", "超声波无损检测", "密度试验",
"土工试验", "引气剂含量", "砂浆强度"
);
private static final Random RANDOM = new Random();
public static Page<RecordStatisticsVo> getRecordStatisticsVo() {
Page<RecordStatisticsVo> page = new Page<>(1, 30);
List<RecordStatisticsVo> records = new ArrayList<>();
for (int i = 0; i < 30; i++) {
String projectName = PROJECT_NAMES.get(RANDOM.nextInt(PROJECT_NAMES.size()));
// ID从0001到0030格式化为四位字符串
String id = String.format("%04d", i + 1);
String testItem = TEST_ITEMS.get(RANDOM.nextInt(TEST_ITEMS.size()));
// 委托数量: 10 到 100 之间
Long commissionedCount = (long) (RANDOM.nextInt(91) + 10);
// 报告数量: 约为委托数量的2/3并加入一些随机浮动确保不低于1且不超过委托数量
double reportFactor = 0.6 + RANDOM.nextDouble() * 0.2; // 0.6到0.8之间
Long reportCount = Math.max(1L, (long) Math.round(commissionedCount * reportFactor));
// 确保报告数量不会超过委托数量
reportCount = Math.min(reportCount, commissionedCount);
// 不合格报告数量: 约为报告数量的1/5并加入一些随机浮动确保不低于0且不超过报告数量
double unqualifiedFactor = 0.15 + RANDOM.nextDouble() * 0.1; // 0.15到0.25之间
Long unqualifiedCount = (long) Math.round(reportCount * unqualifiedFactor);
// 确保不合格数量不会小于0
if (unqualifiedCount < 0) {
unqualifiedCount = 0L;
}
// 确保不合格数量不会超过报告数量
unqualifiedCount = Math.min(unqualifiedCount, reportCount);
// 特殊处理如果报告数量很小不合格数量更倾向于0或1
if (reportCount < 5 && unqualifiedCount > 1) {
unqualifiedCount = RANDOM.nextBoolean() ? 0L : 1L;
}
records.add(new RecordStatisticsVo(projectName, id, testItem, commissionedCount, reportCount, unqualifiedCount));
}
//List<RecordStatisticsVo> records = Arrays.asList(
// new RecordStatisticsVo("葛洲坝C2标", "1", "特细沙", 20L, 10L, 1L),
// new RecordStatisticsVo("引江补汉", "2", "引气剂", 15L, 9L, 2L)
//);
page.setRecords(records);
return page;
}
}

View File

@@ -28,7 +28,7 @@
AND e.created_at &lt;= #{endTimeStr}
</where>
GROUP BY p.id, p.engineering_name
ORDER BY entrust_count DESC;
Limit #{page.offset}, #{page.size}
ORDER BY entrust_count DESC
Limit #{page.current}, #{page.size};
</select>
</mapper>