Compare commits

..

45 Commits

Author SHA1 Message Date
zt
a8cb16ab3f 通知 2025-09-10 20:21:01 +08:00
2c45762c66 09-10-netty优化 2025-09-10 19:41:11 +08:00
056b28af31 我的任务优化、工程量清单优化、gps消息websocket连接、物资管理:物资验收入库添加附件 2025-09-10 19:38:10 +08:00
lcj
7dd6d97a3e 进度管理app 2025-09-10 19:18:30 +08:00
zt
697beb67c4 通知 2025-09-10 17:34:49 +08:00
lcj
4d627af3a1 进度管理app、注解翻译项目名称 2025-09-10 16:43:49 +08:00
ab332c462f 09-10-netty设置系统消息type为2 2025-09-10 16:11:30 +08:00
0f3d1e38be 09-10-netty优化 2025-09-10 16:00:43 +08:00
lcj
4392a287cc 修改bug 2025-09-10 10:03:53 +08:00
lcj
f38538be33 修改进度管理 2025-09-10 00:15:55 +08:00
lcj
ede1e501b4 企业级大屏 2025-09-09 23:42:24 +08:00
4a2b62cf92 我的任务bug修改 2025-09-09 21:52:49 +08:00
zt
325f392e8f 大屏,消息 2025-09-09 20:39:00 +08:00
lcj
5b991396c2 企业级大屏 2025-09-09 19:49:14 +08:00
c75563b46a 09-09-修改 2025-09-09 18:53:28 +08:00
724ebf8dbd 09-09-netty完善修改 2025-09-09 18:47:48 +08:00
a52b9078a0 gps定位接口 2025-09-09 17:47:49 +08:00
9d682a3290 09-09-netty发送系统消息 2025-09-09 17:08:39 +08:00
lcj
abad289c2b 进度管理,企业级大屏,修改bug 2025-09-09 15:42:00 +08:00
820188863e 修改一览表单价精度 2025-09-09 15:24:17 +08:00
113b5debc9 供应商bug修改 2025-09-09 10:40:17 +08:00
6b4cd4ae0d Merge remote-tracking branch 'origin/dev' into dev 2025-09-09 09:12:54 +08:00
261dd0b643 09-09-netty消息搭建 2025-09-09 09:12:19 +08:00
zt
71f3810e51 Merge remote-tracking branch 'origin/dev' into dev 2025-09-08 20:03:11 +08:00
zt
fa835684d4 消息 2025-09-08 20:02:51 +08:00
e19ef3003a bug修改 2025-09-08 20:00:29 +08:00
zt
8a18223d06 二维码 2025-09-08 16:38:01 +08:00
c90828f98e 09-08-土地流转新增type区分完成和未完成 2025-09-08 16:02:26 +08:00
2ecb0063bf 限价、投标、招采、物资一览bug修改 2025-09-08 15:33:03 +08:00
zt
998547e63f bug 2025-09-08 11:47:14 +08:00
zt
78829ef5e7 bug 2025-09-08 11:42:36 +08:00
zt
da0dd8f78f bug 2025-09-06 19:20:40 +08:00
lcj
96d0406931 物资、里程碑进度execl导出 2025-09-06 19:07:10 +08:00
d7616960c6 gpsbug修改 2025-09-06 18:48:39 +08:00
66e8495859 bug修改 2025-09-06 18:35:51 +08:00
95c2858a64 bug修改 2025-09-06 18:33:06 +08:00
5cbb0c630b bug修改 2025-09-06 18:24:27 +08:00
lcj
e0cc521291 进度、物资管理模块 2025-09-06 15:30:57 +08:00
ff9f49b1d9 09-06-修复bug,完善功能 2025-09-06 15:16:41 +08:00
zt
b738bb821d app 2025-09-06 13:06:33 +08:00
2cea57646d 设计管理设计出图导入导出 2025-09-06 12:52:12 +08:00
lcj
ab5cd491d6 修改ai工单 2025-09-04 22:25:10 +08:00
lcj
3f3e20a64b 项目大屏进度数据统计,修改ai工单逻辑 2025-09-04 21:30:18 +08:00
zt
f5d9cb7fc1 Merge remote-tracking branch 'origin/dev' into dev 2025-09-04 21:27:26 +08:00
zt
5b05d2eb40 版本号 2025-09-04 21:27:11 +08:00
265 changed files with 8830 additions and 919 deletions

View File

@ -307,7 +307,6 @@
<artifactId>snail-job-client-job-core</artifactId>
<version>${snailjob.version}</version>
</dependency>
<!-- 加密包引入 -->
<dependency>
<groupId>org.bouncycastle</groupId>

View File

@ -6,6 +6,7 @@ import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -41,16 +42,20 @@ import org.dromara.web.domain.vo.TenantListVo;
import org.dromara.web.service.IAuthStrategy;
import org.dromara.web.service.SysLoginService;
import org.dromara.web.service.SysRegisterService;
import org.dromara.websocket.domain.ChatGroup;
import org.dromara.websocket.service.Impl.ChatGroupServiceImpl;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* 认证
@ -72,6 +77,7 @@ public class AuthController {
private final ISysSocialService socialUserService;
private final ISysClientService clientService;
private final ScheduledExecutorService scheduledExecutorService;
private final ChatGroupServiceImpl chatGroupService;
/**
@ -103,10 +109,7 @@ public class AuthController {
// Long userId = LoginHelper.getUserId();
// scheduledExecutorService.schedule(() -> {
// SseMessageDto dto = new SseMessageDto();
// dto.setMessage("欢迎登录新能源项目管理系统");
// dto.setUserIds(List.of(userId));
// SseMessageUtils.publishMessage(dto);
// chatGroupService.createSystem(userId,client.getClientKey());
// }, 5, TimeUnit.SECONDS);
return R.ok(loginVo);
}
@ -193,6 +196,12 @@ public class AuthController {
return R.ok();
}
@PostMapping("/app/register")
public R<Void> appRegister(@Validated @RequestBody RegisterBody user) {
registerService.appRegister(user);
return R.ok();
}
/**
* 登录页面租户下拉框
*

View File

@ -55,7 +55,8 @@ public class UserActionListener implements SaTokenListener {
String username = (String) loginModel.getExtra(LoginHelper.USER_NAME_KEY);
String tenantId = (String) loginModel.getExtra(LoginHelper.TENANT_KEY);
dto.setUserName(username);
dto.setClientKey((String) loginModel.getExtra(LoginHelper.CLIENT_KEY));
String clientId = (String) loginModel.getExtra(LoginHelper.CLIENT_KEY);
dto.setClientKey(clientId);
dto.setDeviceType(loginModel.getDevice());
dto.setDeptName((String) loginModel.getExtra(LoginHelper.DEPT_NAME_KEY));
TenantHelper.dynamic(tenantId, () -> {
@ -75,7 +76,7 @@ public class UserActionListener implements SaTokenListener {
SpringUtils.context().publishEvent(logininforEvent);
// 更新登录信息
loginService.recordLoginInfo((Long) loginModel.getExtra(LoginHelper.USER_KEY), ip);
log.info("user doLogin, userId:{}, token:{}", loginId, tokenValue);
log.info("user doLogin, userId:{}, token:{}, clientid{}", loginId, tokenValue, clientId);
}
/**

View File

@ -77,6 +77,46 @@ public class SysRegisterService {
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
}
/**
* 注册
*/
public void appRegister(RegisterBody registerBody) {
String tenantId = registerBody.getTenantId();
String username = registerBody.getPhonenumber();
String password = registerBody.getPassword();
// 校验用户类型是否存在
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
// 校验密码是否符合要求
String pattern = "^(?!.*\\s)(?!^[a-zA-Z]+$)(?!^[0-9]+$)(?!^[^a-zA-Z0-9]+$)(?!^[a-zA-Z0-9]+$).{8,18}$";
boolean isValid = password.matches(pattern);
if (!isValid) {
throw new UserException("注册失败密码需满足818位包含大小写字母、数字、特殊字符中的至少三种组合");
}
// 验证码开关
SysUserBo sysUser = new SysUserBo();
sysUser.setUserName(username);
sysUser.setNickName(username);
sysUser.setPhonenumber(username);
sysUser.setPassword(BCrypt.hashpw(password));
sysUser.setUserType(userType);
sysUser.setEmail(registerBody.getEmail());
boolean exist = TenantHelper.dynamic(tenantId, () -> {
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getPhonenumber, sysUser.getPhonenumber()));
});
if (exist) {
throw new UserException("user.register.save.error", username);
}
boolean regFlag = userService.registerUser(sysUser, tenantId);
if (!regFlag) {
throw new UserException("user.register.error");
}
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
}
/**
* 校验验证码
*

View File

@ -13,7 +13,7 @@ spring.boot.admin.client:
--- # snail-job 配置
snail-job:
enabled: false
enabled: true
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
group: "ruoyi_group"
# SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config` 表

View File

@ -1,5 +1,6 @@
package org.dromara.test;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -7,6 +8,7 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.contractor.service.ISubUserSalaryDetailService;
import org.dromara.design.service.IDesTechnicalStandardService;
import org.dromara.facility.domain.FacMatrix;
import org.dromara.facility.service.IFacMatrixService;
@ -20,6 +22,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
@ -57,6 +60,9 @@ public class DemoTest {
@Resource
private ISubConstructionUserService constructionUserService;
@Resource
private ISubUserSalaryDetailService userSalaryDetailService;
@Test
void test() {
Boolean result = photovoltaicPanelPartsService
@ -120,4 +126,18 @@ public class DemoTest {
constructionUserService.update(constructionUserLuw);
}
@Test
void testSalary() {
List<SubConstructionUser> list = constructionUserService.lambdaQuery()
.eq(SubConstructionUser::getProjectId, 1897160897167638529L)
.list();
if (CollUtil.isNotEmpty(list)) {
for (SubConstructionUser user : list) {
for (int i = 1; i < 7; i++) {
userSalaryDetailService.insertByAttendance(user.getSysUserId(), LocalDate.now().minusDays(i));
}
}
}
}
}

View File

@ -80,4 +80,9 @@ public interface CacheNames {
*/
String ONLINE_TOKEN = "online_tokens";
/**
* 项目名称
*/
String PROJECT_NAME = "project_name#30d";
}

View File

@ -30,4 +30,12 @@ public class RegisterBody extends LoginBody {
private String userType;
private Long projectId;
private String email;
private String phonenumber;
private Long deptId;
}

View File

@ -0,0 +1,17 @@
package org.dromara.common.core.service;
/**
* @author lilemy
* @date 2025-09-10 16:15
*/
public interface ProjectService {
/**
* 通过项目ID查询项目名称
*
* @param projectId 项目ID
* @return 项目名称
*/
String selectProjectNameById(Long projectId);
}

View File

@ -32,4 +32,9 @@ public interface TransConstant {
*/
String OSS_ID_TO_URL = "oss_id_to_url";
/**
* 项目id转名称
*/
String PROJECT_ID_TO_NAME = "project_id_to_name";
}

View File

@ -0,0 +1,35 @@
package org.dromara.common.translation.core.impl;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.dromara.common.core.service.ProjectService;
import org.dromara.common.translation.annotation.TranslationType;
import org.dromara.common.translation.constant.TransConstant;
import org.dromara.common.translation.core.TranslationInterface;
/**
* @author lilemy
* @date 2025-09-10 16:13
*/
@AllArgsConstructor
@TranslationType(type = TransConstant.PROJECT_ID_TO_NAME)
public class ProjectNameTranslationImpl implements TranslationInterface<String> {
@Resource
private ProjectService projectService;
/**
* 翻译
*
* @param key 需要被翻译的键(不为空)
* @param other 其他参数
* @return 返回键对应的值
*/
@Override
public String translation(Object key, String other) {
if (key instanceof Long id) {
return projectService.selectProjectNameById(id);
}
return null;
}
}

View File

@ -4,3 +4,4 @@ org.dromara.common.translation.core.impl.DictTypeTranslationImpl
org.dromara.common.translation.core.impl.OssUrlTranslationImpl
org.dromara.common.translation.core.impl.UserNameTranslationImpl
org.dromara.common.translation.core.impl.NicknameTranslationImpl
org.dromara.common.translation.core.impl.ProjectNameTranslationImpl

View File

@ -12,6 +12,8 @@ public interface WebSocketConstants {
*/
String LOGIN_USER_KEY = "loginUser";
String PROJECT_ID = "projectId";
/**
* 订阅的频道
*/

View File

@ -13,6 +13,7 @@ import java.io.IOException;
import java.util.List;
import static org.dromara.common.websocket.constant.WebSocketConstants.LOGIN_USER_KEY;
import static org.dromara.common.websocket.constant.WebSocketConstants.PROJECT_ID;
/**
* WebSocketHandler 实现类
@ -27,14 +28,17 @@ public class PlusWebSocketHandler extends AbstractWebSocketHandler {
*/
@Override
public void afterConnectionEstablished(WebSocketSession session) throws IOException {
LoginUser loginUser = (LoginUser) session.getAttributes().get(LOGIN_USER_KEY);
if (ObjectUtil.isNull(loginUser)) {
// LoginUser loginUser = (LoginUser) session.getAttributes().get(LOGIN_USER_KEY);
Long loginUser = (Long) session.getAttributes().get(PROJECT_ID);
// if (ObjectUtil.isNull(loginUser) ) {
if (loginUser == null ) {
session.close(CloseStatus.BAD_DATA);
log.info("[connect] invalid token received. sessionId: {}", session.getId());
return;
}
WebSocketSessionHolder.addSession(loginUser.getUserId(), session);
log.info("[connect] sessionId: {},userId:{},userType:{}", session.getId(), loginUser.getUserId(), loginUser.getUserType());
WebSocketSessionHolder.addSession(loginUser, session);
// WebSocketSessionHolder.addSession(loginUser.getUserId(), session);
// log.info("[connect] sessionId: {},userId:{},userType:{}", session.getId(), loginUser.getUserId(), loginUser.getUserType());
}
/**
@ -47,11 +51,13 @@ public class PlusWebSocketHandler extends AbstractWebSocketHandler {
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
// 从WebSocket会话中获取登录用户信息
LoginUser loginUser = (LoginUser) session.getAttributes().get(LOGIN_USER_KEY);
// LoginUser loginUser = (LoginUser) session.getAttributes().get(LOGIN_USER_KEY);
Long loginUser = (Long) session.getAttributes().get(PROJECT_ID);
// 创建WebSocket消息DTO对象
WebSocketMessageDto webSocketMessageDto = new WebSocketMessageDto();
webSocketMessageDto.setSessionKeys(List.of(loginUser.getUserId()));
// webSocketMessageDto.setSessionKeys(List.of(loginUser.getUserId()));
webSocketMessageDto.setSessionKeys(List.of(loginUser));
webSocketMessageDto.setMessage(message.getPayload());
WebSocketUtils.publishMessage(webSocketMessageDto);
}
@ -100,13 +106,16 @@ public class PlusWebSocketHandler extends AbstractWebSocketHandler {
*/
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
LoginUser loginUser = (LoginUser) session.getAttributes().get(LOGIN_USER_KEY);
if (ObjectUtil.isNull(loginUser)) {
// LoginUser loginUser = (LoginUser) session.getAttributes().get(LOGIN_USER_KEY);
Long loginUser = (Long) session.getAttributes().get(PROJECT_ID);
// if (ObjectUtil.isNull(loginUser)) {
if (loginUser != null ) {
log.info("[disconnect] invalid token received. sessionId: {}", session.getId());
return;
}
WebSocketSessionHolder.removeSession(loginUser.getUserId());
log.info("[disconnect] sessionId: {},userId:{},userType:{}", session.getId(), loginUser.getUserId(), loginUser.getUserType());
// WebSocketSessionHolder.removeSession(loginUser.getUserId());
WebSocketSessionHolder.removeSession(loginUser);
// log.info("[disconnect] sessionId: {},userId:{},userType:{}", session.getId(), loginUser.getUserId(), loginUser.getUserType());
}
/**

View File

@ -15,6 +15,7 @@ import org.springframework.web.socket.server.HandshakeInterceptor;
import java.util.Map;
import static org.dromara.common.websocket.constant.WebSocketConstants.LOGIN_USER_KEY;
import static org.dromara.common.websocket.constant.WebSocketConstants.PROJECT_ID;
/**
* WebSocket握手请求的拦截器
@ -44,6 +45,8 @@ public class PlusWebSocketInterceptor implements HandshakeInterceptor {
String headerCid = ServletUtils.getRequest().getHeader(LoginHelper.CLIENT_KEY);
String paramCid = ServletUtils.getParameter(LoginHelper.CLIENT_KEY);
String clientId = StpUtil.getExtra(LoginHelper.CLIENT_KEY).toString();
String projectIdStr = ServletUtils.getRequest().getParameter("projectId");
Long projectId = Long.parseLong(projectIdStr);
if (!StringUtils.equalsAny(clientId, headerCid, paramCid)) {
// token 无效
throw NotLoginException.newInstance(StpUtil.getLoginType(),
@ -52,6 +55,7 @@ public class PlusWebSocketInterceptor implements HandshakeInterceptor {
}
attributes.put(LOGIN_USER_KEY, loginUser);
attributes.put(PROJECT_ID,projectId);
return true;
} catch (NotLoginException e) {
log.error("WebSocket 认证失败'{}',无法访问系统资源", e.getMessage());

View File

@ -252,6 +252,11 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -107,8 +107,8 @@ public class BusBiddingLimitListController extends BaseController {
@Log(title = "成本-投标", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/importExcelFile")
public R<Void> importExcelFile(Long projectId, @RequestParam("file") MultipartFile file) {
return toAjax(busBiddingLimitListService.importExcelFile(projectId, file));
public R<Void> importExcelFile(BusBiddingLimitListBo bo, @RequestParam("file") MultipartFile file) {
return toAjax(busBiddingLimitListService.importExcelFile(bo, file));
}
/**

View File

@ -42,6 +42,14 @@ public class BusBiddingLimitVersions extends BaseEntity {
*/
private String versions;
/**
* 版本号名称
*/
private String versionsName;
/**
* excel文件
*/

View File

@ -44,6 +44,14 @@ public class BusBiddingLimitVersionsBo extends BaseEntity {
@NotBlank(message = "版本号不能为空", groups = { AddGroup.class, EditGroup.class })
private String versions;
/**
* 版本号名称
*/
private String versionsName;
/**
* excel文件
*/

View File

@ -1,5 +1,6 @@
package org.dromara.bidding.domain.vo;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import org.dromara.bidding.domain.BusBiddingLimitList;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
@ -77,6 +78,7 @@ public class BusBiddingLimitListVo implements Serializable {
* 名称
*/
@ExcelProperty(value = "名称")
@ColumnWidth(50)
private String name;
/**

View File

@ -52,6 +52,14 @@ public class BusBiddingLimitVersionsVo implements Serializable {
@ExcelProperty(value = "版本号")
private String versions;
/**
* 版本号名称
*/
private String versionsName;
/**
* excel文件
*/

View File

@ -79,7 +79,7 @@ public interface IBusBiddingLimitListService extends IService<BusBiddingLimitLis
*/
List<BusBiddingLimitListVo> getTree(BusBiddingLimitListBo bo);
Boolean importExcelFile(Long projectId, MultipartFile file);
Boolean importExcelFile(BusBiddingLimitListBo projectId, MultipartFile file);
List<BusBiddingLimitVersionsVo> obtainAllVersionNumbers(BiddingAllVersionNumbersReq bo);

View File

@ -71,4 +71,6 @@ public interface IBusBiddingLimitVersionsService extends IService<BusBiddingLimi
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
BusBiddingLimitVersions queryByProjectId( String versions, Long projectId);
BusBiddingLimitVersions getByProjectIdVersions(Long projectId, String versions);
}

View File

@ -25,8 +25,6 @@ import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.utils.excel.ExcelDynamicReader;
import org.dromara.tender.domain.BusBillofquantitiesLimitList;
import org.dromara.tender.domain.bo.BusBillofquantitiesLimitListBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -191,7 +189,7 @@ public class BusBiddingLimitListServiceImpl extends ServiceImpl<BusBiddingLimitL
listVoList.stream().filter(vo -> vo.getUnitPrice() != null && vo.getUnitPrice().compareTo(BigDecimal.ZERO) != 0)
.filter(vo -> vo.getQuantity() != null && vo.getQuantity().compareTo(BigDecimal.ZERO) != 0)
.forEach(item -> {
item.setPrice(item.getUnitPrice().multiply(item.getQuantity()).setScale(2, RoundingMode.HALF_UP));
item.setPrice(item.getUnitPrice().multiply(item.getQuantity()).setScale(4, RoundingMode.HALF_UP));
});
//构建父子映射
@ -232,14 +230,22 @@ public class BusBiddingLimitListServiceImpl extends ServiceImpl<BusBiddingLimitL
BigDecimal totalPrice = node.getChildren().stream()
.map(BusBiddingLimitListVo::getPrice)
.reduce(BigDecimal.ZERO, BigDecimal::add)
.setScale(2, RoundingMode.HALF_UP);
.setScale(4, RoundingMode.HALF_UP);
node.setPrice(totalPrice);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean importExcelFile(Long projectId, MultipartFile file) {
public Boolean importExcelFile(BusBiddingLimitListBo bo, MultipartFile file) {
BusBiddingLimitVersions biddingLimitVersions = busBiddingLimitVersionsService.getByProjectIdVersions(bo.getProjectId(),bo.getVersions());
if (biddingLimitVersions == null) {
throw new ServiceException("版本号不存在!!!");
}
if (BusinessStatusEnum.FINISH.getStatus().equals(biddingLimitVersions.getStatus())) {
throw new ServiceException("数据已审核完成,不允许修改!!!");
}
// 跳过1行表头读取0到6列共7列映射到ExcelData实体类
List<BusBiddingLimitListBo> dataList = null;
@ -271,7 +277,6 @@ public class BusBiddingLimitListServiceImpl extends ServiceImpl<BusBiddingLimitL
busBillofquantities.add(limitList);
});
log.info(busBillofquantities.toString());
return this.updateBatchById(busBillofquantities);
}

View File

@ -145,6 +145,13 @@ public class BusBiddingLimitVersionsServiceImpl extends ServiceImpl<BusBiddingLi
.eq(BusBiddingLimitVersions::getVersions, versions));
}
@Override
public BusBiddingLimitVersions getByProjectIdVersions(Long projectId, String versions) {
return baseMapper.selectOne(new LambdaQueryWrapper<BusBiddingLimitVersions>()
.eq(BusBiddingLimitVersions::getProjectId, projectId)
.eq(BusBiddingLimitVersions::getVersions, versions));
}
/**
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)

View File

@ -0,0 +1,220 @@
package org.dromara.bigscreen.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.dromara.bigscreen.domain.dto.WeatherQueryReq;
import org.dromara.bigscreen.domain.vo.*;
import org.dromara.bigscreen.service.EnterpriseBigScreenService;
import org.dromara.common.core.domain.R;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import org.dromara.project.domain.BusAttendance;
import org.dromara.project.domain.BusProject;
import org.dromara.project.domain.BusUserProjectRelevancy;
import org.dromara.project.service.IBusAttendanceService;
import org.dromara.project.service.IBusProjectService;
import org.dromara.project.service.IBusUserProjectRelevancyService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
/**
* 企业级大屏
*
* @author lilemy
* @date 2025-09-09 14:55
*/
@Validated
@RestController
@RequestMapping("/enterprise/big/screen")
public class EnterpriseBigScreenController {
@Resource
private EnterpriseBigScreenService enterpriseBigScreenService;
@Resource
private IBusUserProjectRelevancyService userProjectRelevancyService;
@Resource
private IBusAttendanceService attendanceService;
@Resource
private IBusProjectService projectService;
/**
* 获取关键指标
*/
@SaCheckPermission("enterprise:bigScreen:keyIndex")
@GetMapping("/keyIndex")
public R<EnterpriseKeyIndexVo> getEnterpriseKeyIndex() {
return R.ok(enterpriseBigScreenService.getEnterpriseKeyIndex());
}
/**
* 项目进度分析
*/
@SaCheckPermission("enterprise:bigScreen:projectProgress")
@GetMapping("/projectProgress")
public R<ProjectProgressAnalysisVo> getProjectProgress() {
return R.ok(enterpriseBigScreenService.getProjectProgressAnalysis());
}
/**
* 项目产值对比
*/
@SaCheckPermission("enterprise:bigScreen:projectOutputValueComparison")
@GetMapping("/projectOutputValueComparison")
public R<List<OutputValueComparisonVo>> getProjectOutputValueComparison() {
return R.ok(enterpriseBigScreenService.getProjectOutputValueComparison());
}
/**
* 风险预警
*/
@SaCheckPermission("enterprise:bigScreen:riskEarlyWarning")
@GetMapping("/riskEarlyWarning")
public R<List<RiskEarlyWarningVo>> getRiskEarlyWarning() {
return R.ok(enterpriseBigScreenService.getRiskEarlyWarning());
}
/**
* 查询天气
*/
@SaCheckPermission("enterprise:bigScreen:weather")
@GetMapping("/weather")
public R<List<WeatherVo>> getProjectWeather(WeatherQueryReq req) {
return R.ok(enterpriseBigScreenService.getWeather3DaysList(req));
}
/**
* 查询安全天数
*/
@SaCheckPermission("enterprise:bigScreen:safetyDay")
@GetMapping("/safetyDay")
public R<Long> getProjectSafetyDay() {
LocalDate date = LocalDate.of(2023, 1, 1);
LocalDate now = LocalDate.now();
long days = Math.abs(ChronoUnit.DAYS.between(date, now));
return R.ok(days);
}
/**
* 人数统计
*/
@SaCheckPermission("enterprise:bigScreen:peopleCount")
@GetMapping("/peopleCount")
public R<PeopleCountVo> getProjectPeopleCount() {
PeopleCountVo peopleCountVo = new PeopleCountVo();
List<BusUserProjectRelevancy> list = userProjectRelevancyService.list();
//0系统管理员 1普通人员 2项目管理员 3分包人员
peopleCountVo.setConstructionPersonnelCount(list.stream().filter(item -> "1".equals(item.getUserType()))
.map(BusUserProjectRelevancy::getUserId)
.distinct().count());
peopleCountVo.setManagersCount(list.stream().filter(item -> "2".equals(item.getUserType()))
.map(BusUserProjectRelevancy::getUserId)
.distinct().count());
peopleCountVo.setSubcontractorsCount(list.stream().filter(item -> "3".equals(item.getUserType()))
.map(BusUserProjectRelevancy::getUserId)
.distinct().count());
return R.ok(peopleCountVo);
}
/**
* 出勤人数统计
*/
@SaCheckPermission("enterprise:bigScreen:allAttendanceCount")
@GetMapping("/allAttendanceCount")
public R<TodayAttendanceCountVo> getAllAttendanceCount() {
TodayAttendanceCountVo todayAttendanceCountVo = new TodayAttendanceCountVo();
List<BusAttendance> list = attendanceService.list(Wrappers.<BusAttendance>lambdaQuery()
.eq(BusAttendance::getClockDate, LocalDate.now())
.in(BusAttendance::getClockStatus, Arrays.asList("1", "2", "3"))
);
long attendanceCount = list.stream().map(BusAttendance::getUserId).distinct().count();
todayAttendanceCountVo.setAttendanceCount(attendanceCount);
// 查询总人数
List<BusUserProjectRelevancy> relevancyList = userProjectRelevancyService.list();
long totalUserCount = relevancyList.stream().map(BusUserProjectRelevancy::getUserId).distinct().count();
// 计算考勤率(保留一位小数)
if (totalUserCount > 0) {
BigDecimal rate = new BigDecimal(attendanceCount * 100)
.divide(new BigDecimal(totalUserCount), 1, RoundingMode.HALF_UP);
todayAttendanceCountVo.setAttendanceRate(rate.doubleValue());
} else {
todayAttendanceCountVo.setAttendanceRate(0.0);
}
return R.ok(todayAttendanceCountVo);
}
/**
* 每个项目的出勤人数
*/
@SaCheckPermission("enterprise:bigScreen:projectAttendanceCount")
@GetMapping("/projectAttendanceCount")
public R<List<ProjectAttendanceCountVo>> getProjectAttendanceCount() {
ArrayList<ProjectAttendanceCountVo> projectAttendanceCountVos = new ArrayList<>();
List<BusAttendance> list = attendanceService.list(Wrappers.<BusAttendance>lambdaQuery()
.eq(BusAttendance::getClockDate, LocalDate.now())
.in(BusAttendance::getClockStatus, Arrays.asList("1", "2", "3"))
);
List<BusUserProjectRelevancy> relevancyList = userProjectRelevancyService.list();
// 转换为 Map<projectId, 去重后的 userId 数量>
Map<Long, Integer> projectUserCountMap = relevancyList.stream()
.collect(Collectors.groupingBy(
BusUserProjectRelevancy::getProjectId,
Collectors.mapping(
BusUserProjectRelevancy::getUserId,
Collectors.collectingAndThen(
Collectors.toSet(),
Set::size
)
)
));
for (Long projectId : projectUserCountMap.keySet()) {
ProjectAttendanceCountVo projectAttendanceCountVo = new ProjectAttendanceCountVo();
BusProject byId = projectService.getById(projectId);
if (byId == null) {
continue;
}
projectAttendanceCountVo.setProjectName(byId.getProjectName());
long count = list.stream().filter(item -> item.getProjectId().equals(projectId))
.map(BusAttendance::getUserId)
.distinct()
.count();
Integer i = projectUserCountMap.get(projectId);
BigDecimal rate = new BigDecimal("0.0");
if (i > 0) {
rate = new BigDecimal(count * 100)
.divide(new BigDecimal(projectUserCountMap.get(projectId)), 1, RoundingMode.HALF_UP);
}
projectAttendanceCountVo.setAttendanceRate(rate.doubleValue());
projectAttendanceCountVos.add(projectAttendanceCountVo);
}
return R.ok(projectAttendanceCountVos);
}
}

View File

@ -11,13 +11,13 @@ import org.dromara.ctr.domain.CtrExpensesContract;
import org.dromara.ctr.domain.CtrIncomeContract;
import org.dromara.ctr.service.ICtrExpensesContractService;
import org.dromara.ctr.service.ICtrIncomeContractService;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import org.dromara.out.domain.OutSettlementValueOwner;
import org.dromara.out.domain.OutSettlementValueSubcontract;
import org.dromara.out.service.IOutSettlementValueOwnerService;
import org.dromara.out.service.IOutSettlementValueSubcontractService;
import org.dromara.project.domain.vo.project.BusProjectGisVo;
import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
import org.dromara.project.domain.vo.project.BusProjectWeatherVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -114,7 +114,7 @@ public class MoneyBigScreenController {
.eq(CtrIncomeContract::getProjectId, projectId)
.last("limit 1")
);
if (contract != null && contract.getPayRatio()!= null) {
if (contract != null && contract.getPayRatio() != null) {
actualAmount = actualAmount.add(projectMonthlyAmountMap.get(projectId).multiply(contract.getPayRatio()).divide(HUNDRED));
}
@ -169,7 +169,7 @@ public class MoneyBigScreenController {
.last("limit 1")
);
if (contract != null && contract.getPayRatio()!= null) {
if (contract != null && contract.getPayRatio() != null) {
actualAmount = actualAmount.add(projectAmountMap.get(contractCode).multiply(contract.getPayRatio()).divide(HUNDRED));
}
@ -243,7 +243,7 @@ public class MoneyBigScreenController {
.filter(contract -> contract.getAmount() != null && contract.getAmount().compareTo(THIRD_PHASE) >= 0)
.count();
return R.ok(new MoneyContractCountVo(4, 4, 6, 6));
return R.ok(new MoneyContractCountVo(4, 4, 6, 6));
// return R.ok(new MoneyContractCountVo(lessThan1M, between1MAnd5M, between5MAnd10M, greaterThanOrEqualTo10M));
}
@ -350,7 +350,7 @@ public class MoneyBigScreenController {
.eq(CtrIncomeContract::getProjectId, projectId)
.last("limit 1")
);
if (contract != null && contract.getPayRatio()!= null) {
if (contract != null && contract.getPayRatio() != null) {
incomeAmount = incomeAmount.add(incomeGroupedByProject.get(projectId).multiply(contract.getPayRatio()).divide(HUNDRED));
}
}
@ -380,7 +380,7 @@ public class MoneyBigScreenController {
.last("limit 1")
);
if (contract != null && contract.getPayRatio()!= null) {
if (contract != null && contract.getPayRatio() != null) {
expensesAmount = expensesAmount.add(expenseGroupedByContract.get(contractCode).multiply(contract.getPayRatio()).divide(HUNDRED));
}
}
@ -448,7 +448,7 @@ public class MoneyBigScreenController {
.eq(CtrIncomeContract::getProjectId, projectId)
.last("limit 1")
);
if (contract != null && contract.getPayRatio()!= null) {
if (contract != null && contract.getPayRatio() != null) {
incomeAmount = incomeAmount.add(incomeGroupedByProject.get(projectId).multiply(contract.getPayRatio()).divide(HUNDRED));
}
}
@ -478,7 +478,7 @@ public class MoneyBigScreenController {
.last("limit 1")
);
if (contract != null && contract.getPayRatio()!= null) {
if (contract != null && contract.getPayRatio() != null) {
expensesAmount = expensesAmount.add(expenseGroupedByContract.get(contractCode).multiply(contract.getPayRatio()).divide(HUNDRED));
}
}
@ -511,7 +511,7 @@ public class MoneyBigScreenController {
.filter(java.util.Objects::nonNull) // 过滤掉 null 值
.reduce(BigDecimal.ZERO, BigDecimal::add);
List<OutSettlementValueSubcontract> subcontractList = settlementValueSubcontractService.list();
List<OutSettlementValueSubcontract> subcontractList = settlementValueSubcontractService.list();
BigDecimal expensesCash = subcontractList.stream()
.map(OutSettlementValueSubcontract::getSettlementValue)
@ -526,8 +526,6 @@ public class MoneyBigScreenController {
}
/**
* 获取当前月份的开始时间和结束时间
*
@ -548,8 +546,8 @@ public class MoneyBigScreenController {
*/
@SaCheckPermission("project:bigScreen:weather")
@GetMapping("/weather/{projectId}")
public R<List<BusProjectWeatherVo>> getProjectWeather(@NotNull(message = "主键不能为空")
@PathVariable Long projectId) {
public R<List<WeatherVo>> getProjectWeather(@NotNull(message = "主键不能为空")
@PathVariable Long projectId) {
return R.ok(moneyBigScreenService.getProjectWeather(projectId));
}

View File

@ -11,21 +11,27 @@ import org.dromara.bigscreen.domain.vo.ProjectPeopleVo;
import org.dromara.bigscreen.domain.vo.ProjectSafetyInspectionVo;
import org.dromara.bigscreen.service.ProjectBigScreenService;
import org.dromara.common.core.domain.R;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
import org.dromara.gps.service.IGpsEquipmentService;
import org.dromara.land.domain.BusLandBlock;
import org.dromara.land.domain.BusLandTransferLedger;
import org.dromara.land.service.IBusLandBlockService;
import org.dromara.land.service.IBusLandTransferLedgerService;
import org.dromara.other.domain.OthYs7Device;
import org.dromara.other.service.IOthYs7DeviceService;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
import org.dromara.project.domain.vo.project.BusProjectWeatherVo;
import org.dromara.project.domain.vo.projectnews.BusProjectNewsVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -49,6 +55,10 @@ public class ProjectBigScreenController {
private final IBusLandBlockService busLandBlockService;
private final IGpsEquipmentService gpsEquipmentService;
private final IOthYs7DeviceService othYs7DeviceService;
/**
* 查询项目土地统计
*/
@ -103,8 +113,8 @@ public class ProjectBigScreenController {
*/
@SaCheckPermission("project:bigScreen:weather")
@GetMapping("/weather/{projectId}")
public R<List<BusProjectWeatherVo>> getProjectWeather(@NotNull(message = "主键不能为空")
@PathVariable Long projectId) {
public R<List<WeatherVo>> getProjectWeather(@NotNull(message = "主键不能为空")
@PathVariable Long projectId) {
return R.ok(projectBigScreenService.getProjectWeather(projectId));
}
@ -167,4 +177,179 @@ public class ProjectBigScreenController {
@PathVariable Long projectId) {
return R.ok(projectBigScreenService.getProjectGeneralize(projectId));
}
/**
* 查询设备列表
*/
@SaCheckPermission("project:bigScreen:getClientList")
@GetMapping("/getClientList/{projectId}")
public R<List<Map<String,Object>>> getClientList(@NotNull(message = "主键不能为空")
@PathVariable Long projectId) {
List<GpsEquipmentSonVo> voList = gpsEquipmentService.getClientList(projectId);
// List<OthYs7Device> othYs7DeviceList = othYs7DeviceService.lambdaQuery()
// .eq(OthYs7Device::getProjectId, projectId)
// .list();
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> gpsMap = new HashMap<>();
Map<String, Object> wrjMap = new HashMap<>();
Map<String, Object> sxtMap = new HashMap<>();
List<Map<String, Object>> gpsChildrenMap = new ArrayList<>();
// List<Map<String, Object>> wrjChildrenMap = new ArrayList<>();
// List<Map<String, Object>> sxtChildrenMap = new ArrayList<>();
if (voList != null && !voList.isEmpty()) {
for (GpsEquipmentSonVo item : voList) {
Map<String, Object> gps = new HashMap<>();
gps.put("id", item.getClientId());
gps.put("label", item.getClientId());
gps.put("name", item.getDeviceName());
gps.put("type", "positioningDevice");
gps.put("lat", item.getLocLatitude());
gps.put("lng", item.getLocLongitude());
gps.put("alt", item.getLocAltitude());
gpsChildrenMap.add(gps);
}
}
// if (othYs7DeviceList != null && !othYs7DeviceList.isEmpty()) {
// for (OthYs7Device item : othYs7DeviceList) {
// Map<String, Object> sxt = new HashMap<>();
// sxt.put("id", item.getDeviceSerial());
// sxt.put("label", item.getDeviceSerial());
// sxt.put("name", item.getDeviceName());
// sxt.put("type", "shexiangtou");
//// sxt.put("lat", item.getLocLatitude());
//// sxt.put("lng", item.getLocLongitude());
//// sxt.put("alt", item.getLocAltitude());
// sxtChildrenMap.add(sxt);
// }
// }
List<Map<String, Object>> maps1 = setSxt();
List<Map<String, Object>> maps2 = setWrj();
gpsMap.put("id",1);
gpsMap.put("label","定位设备");
gpsMap.put("children",gpsChildrenMap);
sxtMap.put("id",2);
sxtMap.put("label","摄像头");
// sxtMap.put("children",sxtChildrenMap);
sxtMap.put("children",maps1);
wrjMap.put("id",3);
wrjMap.put("label","无人机");
// wrjMap.put("children",wrjChildrenMap);
wrjMap.put("children",maps2);
maps.add(gpsMap);
maps.add(wrjMap);
maps.add(sxtMap);
return R.ok(maps);
}
/**
* 查询GPS设备用户列表
*/
@SaCheckPermission("project:bigScreen:getList")
@GetMapping("/getList")
public R<List<String>> getList(Long projectId) {
return R.ok(projectBigScreenService.getList(projectId));
}
/**
* 新增GPS设备详细
*/
@SaCheckPermission("project:bigScreen:setList")
@Log(title = "GPS设备详细", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/setList")
public void setList(@RequestBody GpsEquipmentBo bo) {
projectBigScreenService.setList(bo);
}
public List<Map<String, Object>> setSxt(){
List<Map<String, Object>> sxtChildrenMap = new ArrayList<>();
HashMap<String, Object> map1 = new HashMap<>();
map1.put("id", "55");
map1.put("label", "1222222");
map1.put("name", "22");
map1.put("type", "camera");
map1.put("lng", 106.48349615411811);
map1.put("lat", 29.54856374364732);
map1.put("alt", 0);
HashMap<String, Object> map2 = new HashMap<>();
map2.put("id", "56");
map2.put("label", "1222223");
map2.put("name", "23");
map2.put("type", "camera");
map2.put("lng", 106.48442273257676);
map2.put("lat", 29.53841670498476);
map2.put("alt", 0);
HashMap<String, Object> map3 = new HashMap<>();
map3.put("id", "57");
map3.put("label", "1222224");
map3.put("name", "24");
map3.put("type", "camera");
map3.put("lng", 106.49197896482423);
map3.put("lat", 29.52931974282576);
map3.put("alt", 0);
HashMap<String, Object> map4 = new HashMap<>();
map4.put("id", "58");
map4.put("label", "1222225");
map4.put("name", "25");
map4.put("type", "camera");
map4.put("lng", 106.50293584930655);
map4.put("lat", 29.533025743929034);
map4.put("alt", 0);
sxtChildrenMap.add(map1);
sxtChildrenMap.add(map2);
sxtChildrenMap.add(map3);
sxtChildrenMap.add(map4);
return sxtChildrenMap;
}
public List<Map<String, Object>> setWrj(){
List<Map<String, Object>> sxtChildrenMap = new ArrayList<>();
HashMap<String, Object> map1 = new HashMap<>();
map1.put("id", "65");
map1.put("label", "6222222");
map1.put("name", "32");
map1.put("type", "drone");
map1.put("lng", 106.49556855602525);
map1.put("lat", 29.534393226355515);
map1.put("alt", 0);
HashMap<String, Object> map2 = new HashMap<>();
map2.put("id", "66");
map2.put("label", "2222223");
map2.put("name", "33");
map2.put("type", "drone");
map2.put("lng", 106.49142431645038);
map2.put("lat", 29.534472802500083);
map2.put("alt", 0);
HashMap<String, Object> map3 = new HashMap<>();
map3.put("id", "67");
map3.put("label", "2222224");
map3.put("name", "34");
map3.put("type", "drone");
map3.put("lng", 106.49142125177437);
map3.put("lat", 29.541881138875755);
map3.put("alt", 0);
HashMap<String, Object> map4 = new HashMap<>();
map4.put("id", "68");
map4.put("label", "2222225");
map4.put("name", "35");
map4.put("type", "drone");
map4.put("lng", 106.50256649933792);
map4.put("lat", 29.54260793685717);
map4.put("alt", 0);
sxtChildrenMap.add(map1);
sxtChildrenMap.add(map2);
sxtChildrenMap.add(map3);
sxtChildrenMap.add(map4);
return sxtChildrenMap;
}
}

View File

@ -0,0 +1,31 @@
package org.dromara.bigscreen.domain.dto;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* @author lilemy
* @date 2025-09-09 15:16
*/
@Data
public class WeatherQueryReq implements Serializable {
@Serial
private static final long serialVersionUID = -2550570761981859666L;
/**
* 经度
*/
@NotBlank(message = "经度不能为空")
private String lng;
/**
* 纬度
*/
@NotBlank(message = "纬度不能为空")
private String lat;
}

View File

@ -0,0 +1,38 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-09-09 15:59
*/
@Data
public class EnterpriseKeyIndexVo implements Serializable {
@Serial
private static final long serialVersionUID = -3987781906203623727L;
/**
* 在建项目数量
*/
private Long ongoingProject;
/**
* 合同总额(单位:亿元)
*/
private BigDecimal totalContractAmount;
/**
* 总容量
*/
private BigDecimal totalCapacity;
/**
* 今日施工项目数量
*/
private Long todayProject;
}

View File

@ -0,0 +1,38 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-09-09 19:12
*/
@Data
public class OutputValueComparisonVo implements Serializable {
@Serial
private static final long serialVersionUID = -6902563869975528076L;
/**
* 项目id
*/
private Long projectId;
/**
* 项目名称
*/
private String projectName;
/**
* 计划产值
*/
private BigDecimal planValue;
/**
* 实际产值
*/
private BigDecimal actualValue;
}

View File

@ -0,0 +1,22 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
@Data
public class PeopleCountVo {
/**
* 施工人员
*/
private Long constructionPersonnelCount;
/**
* 分包人员
*/
private Long SubcontractorsCount;
/**
* 管理人员
*/
private Long managersCount;
}

View File

@ -0,0 +1,33 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-09-09 16:04
*/
@Data
public class PeopleOverviewVo implements Serializable {
@Serial
private static final long serialVersionUID = -4353811031023888101L;
/**
* 出勤人数
*/
private Long attendanceNumber;
/**
* 出勤率
*/
private BigDecimal attendanceRate;
/**
* 施工人员数量
*/
private Long constructorNumber;
}

View File

@ -0,0 +1,29 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
@Data
public class ProjectAttendanceCountVo {
/**
* 项目id
*/
private Long projectId;
/**
* 项目名称
*/
private String projectName;
/**
* 考勤人数
*/
private Long attendanceCount;
/**
* 考勤率
*/
private Double attendanceRate;
}

View File

@ -0,0 +1,39 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @author lilemy
* @date 2025-09-09 16:51
*/
@Data
public class ProjectProgressAnalysisVo implements Serializable {
@Serial
private static final long serialVersionUID = -2170524608375159201L;
/**
* 并网总容量 (MW)
*/
private BigDecimal gridConnectedCapacity;
/**
* 计划总容量 (MW)
*/
private BigDecimal plannedCapacity;
/**
* 延期项目数量
*/
private Integer delayedProjectCount;
/**
* 项目进度详情
*/
List<ProjectProgressDetailVo> projectProgressDetailList;
}

View File

@ -0,0 +1,33 @@
package org.dromara.bigscreen.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-09-09 16:55
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProjectProgressDetailVo {
/**
* 项目名称
*/
private String projectName;
/**
* 项目容量
*/
private BigDecimal projectCapacity;
/**
* 施工进度百分比 (0~100)
*/
private BigDecimal completionRate;
}

View File

@ -0,0 +1,48 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
/**
* @author lilemy
* @date 2025-09-09 20:04
*/
@Data
public class RiskEarlyWarningVo implements Serializable {
@Serial
private static final long serialVersionUID = 5250172770638676715L;
/**
* 时间
*/
private LocalDate date;
/**
* 风险类型
*/
private String riskType;
/**
* 报警内容
*/
private String alarmContent;
/**
* 威胁等级
*/
private String dangerLevel;
/**
* 来源
*/
private String source;
/**
* 告警等级
*/
private String alarmLevel;
}

View File

@ -0,0 +1,19 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
@Data
public class TodayAttendanceCountVo {
/**
* 考勤人员数量
*/
private Long attendanceCount;
/**
* 出勤率
*/
private Double attendanceRate;
}

View File

@ -0,0 +1,53 @@
package org.dromara.bigscreen.service;
import org.dromara.bigscreen.domain.dto.WeatherQueryReq;
import org.dromara.bigscreen.domain.vo.EnterpriseKeyIndexVo;
import org.dromara.bigscreen.domain.vo.OutputValueComparisonVo;
import org.dromara.bigscreen.domain.vo.ProjectProgressAnalysisVo;
import org.dromara.bigscreen.domain.vo.RiskEarlyWarningVo;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import java.util.List;
/**
* @author lilemy
* @date 2025-09-09 15:31
*/
public interface EnterpriseBigScreenService {
/**
* 获取关键指标
*
* @return 关键指标
*/
EnterpriseKeyIndexVo getEnterpriseKeyIndex();
/**
* 获取项目进度分析
*
* @return 项目进度分析
*/
ProjectProgressAnalysisVo getProjectProgressAnalysis();
/**
* 获取项目产值对比
*
* @return 项目产值对比
*/
List<OutputValueComparisonVo> getProjectOutputValueComparison();
/**
* 获取风险预警
*
* @return 风险预警
*/
List<RiskEarlyWarningVo> getRiskEarlyWarning();
/**
* 获取3天的天气列表
*
* @param req 查询参数
* @return 天气列表
*/
List<WeatherVo> getWeather3DaysList(WeatherQueryReq req);
}

View File

@ -1,8 +1,8 @@
package org.dromara.bigscreen.service;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import org.dromara.project.domain.vo.project.BusProjectGisVo;
import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
import org.dromara.project.domain.vo.project.BusProjectWeatherVo;
import java.util.List;
@ -25,7 +25,7 @@ public interface MoneyBigScreenService {
* @param projectId 项目id
* @return 项目天气
*/
List<BusProjectWeatherVo> getProjectWeather(Long projectId);
List<WeatherVo> getProjectWeather(Long projectId);
/**
* 获取项目安全天数

View File

@ -3,8 +3,9 @@ package org.dromara.bigscreen.service;
import org.dromara.bigscreen.domain.vo.ProjectImageProgressVo;
import org.dromara.bigscreen.domain.vo.ProjectPeopleVo;
import org.dromara.bigscreen.domain.vo.ProjectSafetyInspectionVo;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
import org.dromara.project.domain.vo.project.BusProjectWeatherVo;
import org.dromara.project.domain.vo.projectnews.BusProjectNewsVo;
import java.util.List;
@ -21,7 +22,7 @@ public interface ProjectBigScreenService {
* @param projectId 项目id
* @return 项目天气
*/
List<BusProjectWeatherVo> getProjectWeather(Long projectId);
List<WeatherVo> getProjectWeather(Long projectId);
/**
* 获取项目安全天数
@ -70,4 +71,8 @@ public interface ProjectBigScreenService {
* @return 项目概括
*/
String getProjectGeneralize(Long projectId);
List<String> getList(Long projectId);
void setList(GpsEquipmentBo bo);
}

View File

@ -0,0 +1,383 @@
package org.dromara.bigscreen.service.impl;
import cn.hutool.core.collection.CollUtil;
import jakarta.annotation.Resource;
import org.dromara.bigscreen.domain.dto.WeatherQueryReq;
import org.dromara.bigscreen.domain.vo.*;
import org.dromara.bigscreen.service.EnterpriseBigScreenService;
import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.utils.BigDecimalUtil;
import org.dromara.ctr.domain.CtrExpensesContract;
import org.dromara.ctr.domain.CtrIncomeContract;
import org.dromara.ctr.service.ICtrExpensesContractService;
import org.dromara.ctr.service.ICtrIncomeContractService;
import org.dromara.manager.weathermanager.WeatherConstant;
import org.dromara.manager.weathermanager.WeatherManager;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import org.dromara.out.domain.BusProcurement;
import org.dromara.out.domain.OutConstructionValue;
import org.dromara.out.domain.OutMonthPlanAudit;
import org.dromara.out.domain.OutValueAllocation;
import org.dromara.out.service.IBusProcurementService;
import org.dromara.out.service.IOutConstructionValueService;
import org.dromara.out.service.IOutMonthPlanAuditService;
import org.dromara.out.service.IOutValueAllocationService;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.domain.PgsProgressPlanDetail;
import org.dromara.progress.service.IPgsProgressCategoryService;
import org.dromara.progress.service.IPgsProgressPlanDetailService;
import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusProjectService;
import org.dromara.safety.domain.HseRecognizeRecord;
import org.dromara.safety.domain.HseViolationLevel;
import org.dromara.safety.domain.HseViolationRecord;
import org.dromara.safety.service.IHseRecognizeRecordService;
import org.dromara.safety.service.IHseViolationLevelService;
import org.dromara.safety.service.IHseViolationRecordService;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author lilemy
* @date 2025-09-09 15:32
*/
@Service
public class EnterpriseBigScreenServiceImpl implements EnterpriseBigScreenService {
@Resource
private WeatherManager weatherManager;
@Resource
private IBusProjectService projectService;
@Resource
private IPgsProgressCategoryService progressCategoryService;
@Resource
private IPgsProgressPlanDetailService progressPlanDetailService;
@Resource
private ICtrIncomeContractService incomeContractService;
@Resource
private ICtrExpensesContractService expensesContractService;
@Resource
private IOutValueAllocationService outValueAllocationService;
@Resource
private IOutMonthPlanAuditService outMonthPlanAuditService;
@Resource
private IOutConstructionValueService outConstructionValueService;
@Resource
private IHseViolationRecordService hseViolationRecordService;
@Resource
private IHseViolationLevelService hseViolationLevelService;
@Resource
private IBusProcurementService busProcurementService;
@Resource
private IHseRecognizeRecordService hseRecognizeRecordService;
/**
* 获取关键指标
*
* @return 关键指标
*/
@Override
public EnterpriseKeyIndexVo getEnterpriseKeyIndex() {
EnterpriseKeyIndexVo vo = new EnterpriseKeyIndexVo();
// 在建项目
List<BusProject> projectList = projectService.lambdaQuery()
.eq(BusProject::getStatus, 0)
.eq(BusProject::getPId, 0)
.list();
// 总容量
BigDecimal totalCapacity = projectList.stream().map(BusProject::getActual)
.filter(s -> s != null && !s.isBlank()) // 过滤掉空值
.map(BigDecimal::new) // 转成 BigDecimal
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 总合同金额
List<CtrIncomeContract> incomeContractList = incomeContractService.lambdaQuery()
.select(CtrIncomeContract::getAmount)
.list();
BigDecimal totalIncomeAmount = incomeContractList.stream()
.map(CtrIncomeContract::getAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
List<CtrExpensesContract> expensesContractList = expensesContractService.lambdaQuery()
.select(CtrExpensesContract::getAmount)
.list();
BigDecimal totalExpensesAmount = expensesContractList.stream()
.map(CtrExpensesContract::getAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 今日施工项目数量
Long todayProject = progressPlanDetailService.lambdaQuery()
.select(PgsProgressPlanDetail::getProjectId)
.eq(PgsProgressPlanDetail::getDate, LocalDate.now())
.groupBy(PgsProgressPlanDetail::getProjectId)
.count();
vo.setOngoingProject((long) projectList.size());
vo.setTotalCapacity(totalCapacity);
vo.setTotalContractAmount(totalIncomeAmount.add(totalExpensesAmount));
vo.setTodayProject(todayProject);
return vo;
}
/**
* 获取项目进度分析
*
* @return 项目进度分析
*/
@Override
public ProjectProgressAnalysisVo getProjectProgressAnalysis() {
ProjectProgressAnalysisVo vo = new ProjectProgressAnalysisVo();
// 1. 查询顶级项目
List<BusProject> projectList = projectService.lambdaQuery()
.select(BusProject::getId, BusProject::getProjectName, BusProject::getActual, BusProject::getPlan)
.eq(BusProject::getStatus, 0)
.eq(BusProject::getPId, 0)
.list();
if (CollUtil.isEmpty(projectList)) {
return vo;
}
// 2. 拿到顶级项目 id
List<Long> projectIds = projectList.stream()
.map(BusProject::getId)
.distinct()
.toList();
// 3. 查询子项目pId 在顶级项目id里
List<BusProject> subProject = projectService.lambdaQuery()
.select(BusProject::getId, BusProject::getPId)
.in(BusProject::getPId, projectIds)
.list();
// 4. 按父项目id分组子项目
Map<Long, List<BusProject>> subProjectMap = subProject.stream()
.collect(Collectors.groupingBy(BusProject::getPId));
// 5. 查询所有子项目的进度分类
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.select(PgsProgressCategory::getId,
PgsProgressCategory::getProjectId,
PgsProgressCategory::getCompleted,
PgsProgressCategory::getTotal)
.in(CollUtil.isNotEmpty(subProject),
PgsProgressCategory::getProjectId,
subProject.stream().map(BusProject::getId).toList())
.list();
// 6. 按子项目id分组进度分类
Map<Long, List<PgsProgressCategory>> progressCategoryMap = progressCategoryList.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getProjectId));
// 并网容量 =(完工产值/计划总产值)* 计划容量
List<OutputValueComparisonVo> list = getProjectOutputValueComparison();
BigDecimal actualValue = list.stream()
.map(OutputValueComparisonVo::getActualValue)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal planValue = list.stream()
.map(OutputValueComparisonVo::getPlanValue)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal plannedCapacity = projectList.stream().map(BusProject::getPlan)
.filter(s -> s != null && !s.isBlank()) // 过滤掉空值
.map(BigDecimal::new) // 转成 BigDecimal
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal gridConnectedCapacity = BigDecimal.ZERO;
if (planValue.compareTo(BigDecimal.ZERO) != 0) {
gridConnectedCapacity = plannedCapacity.multiply(actualValue.divide(planValue, 2, RoundingMode.HALF_UP));
}
vo.setGridConnectedCapacity(gridConnectedCapacity);
List<ProjectProgressDetailVo> detailVoList = projectList.stream().map(project -> {
ProjectProgressDetailVo detailVo = new ProjectProgressDetailVo();
detailVo.setProjectName(project.getProjectName());
detailVo.setProjectCapacity(new BigDecimal(project.getActual()));
List<BusProject> children = subProjectMap.getOrDefault(project.getId(), List.of());
List<PgsProgressCategory> categoryList = new ArrayList<>();
for (BusProject child : children) {
categoryList.addAll(progressCategoryMap.getOrDefault(child.getId(), List.of()));
}
if (CollUtil.isNotEmpty(categoryList)) {
BigDecimal completed = categoryList.stream().map(PgsProgressCategory::getCompleted)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal total = categoryList.stream().map(PgsProgressCategory::getTotal)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
detailVo.setCompletionRate(BigDecimalUtil.toPercentage(completed, total));
}
return detailVo;
}).toList();
vo.setGridConnectedCapacity(gridConnectedCapacity);
vo.setPlannedCapacity(plannedCapacity);
// todo 获取延迟项目数
vo.setDelayedProjectCount(0);
vo.setProjectProgressDetailList(detailVoList);
return vo;
}
/**
* 获取项目产值对比
*
* @return 项目产值对比
*/
@Override
public List<OutputValueComparisonVo> getProjectOutputValueComparison() {
// 查询顶级项目
List<BusProject> projectList = projectService.lambdaQuery()
.select(BusProject::getId, BusProject::getProjectName, BusProject::getActual, BusProject::getPlan)
.eq(BusProject::getStatus, 0)
.eq(BusProject::getPId, 0)
.list();
// 计划产值
List<OutValueAllocation> planList = outValueAllocationService.lambdaQuery()
.select(OutValueAllocation::getProjectId, OutValueAllocation::getOwnerTotalValue)
.list();
Map<Long, BigDecimal> planMap = planList.stream()
.collect(Collectors.toMap(OutValueAllocation::getProjectId, OutValueAllocation::getOwnerTotalValue));
// 实际产值
// 施工产值
List<OutConstructionValue> constructionValueList = outConstructionValueService.lambdaQuery()
.select(OutConstructionValue::getProjectId, OutConstructionValue::getOwnerValue)
.eq(OutConstructionValue::getAuditStatus, BusinessStatusEnum.FINISH.getStatus())
.list();
// 采购产值
List<BusProcurement> purchaseValueList = busProcurementService.lambdaQuery()
.select(BusProcurement::getProjectId, BusProcurement::getAcceptedQuantity, BusProcurement::getUnitPrice)
.list();
// 设计产值
List<OutMonthPlanAudit> designValueList = outMonthPlanAuditService.lambdaQuery()
.select(OutMonthPlanAudit::getProjectId, OutMonthPlanAudit::getDesignValue)
.eq(OutMonthPlanAudit::getType, "1")
.list();
// 封装数据
return projectList.stream().map(project -> {
OutputValueComparisonVo vo = new OutputValueComparisonVo();
vo.setProjectId(project.getId());
vo.setProjectName(project.getProjectName());
vo.setPlanValue(planMap.getOrDefault(project.getId(), BigDecimal.ZERO));
BigDecimal actualValue = BigDecimal.ZERO;
// 设计产值
List<OutMonthPlanAudit> designValue = designValueList.stream()
.filter(design -> design.getProjectId().equals(project.getId()))
.toList();
if (CollUtil.isNotEmpty(designValue)) {
BigDecimal dValue = designValue.stream()
.filter(Objects::nonNull)
.map(OutMonthPlanAudit::getDesignValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
actualValue = actualValue.add(dValue);
}
// 施工产值
List<OutConstructionValue> constructionValue = constructionValueList.stream()
.filter(construction -> construction.getProjectId().equals(project.getId()))
.toList();
if (CollUtil.isNotEmpty(constructionValue)) {
BigDecimal cValue = constructionValue.stream()
.filter(Objects::nonNull)
.map(OutConstructionValue::getOwnerValue)
.reduce(BigDecimal.ZERO, BigDecimal::add);
actualValue = actualValue.add(cValue);
}
// 采购产值
List<BusProcurement> purchaseValue = purchaseValueList.stream()
.filter(purchase -> purchase.getProjectId().equals(project.getId()))
.toList();
if (CollUtil.isNotEmpty(purchaseValue)) {
BigDecimal pValue = purchaseValue.stream()
.filter(Objects::nonNull)
.filter(purchase -> purchase.getAcceptedQuantity() != null && purchase.getUnitPrice() != null)
.map(purchase -> purchase.getAcceptedQuantity().multiply(purchase.getUnitPrice()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
actualValue = actualValue.add(pValue);
}
vo.setActualValue(actualValue);
return vo;
}).filter(vo -> vo.getActualValue().compareTo(BigDecimal.ZERO) > 0)
.toList();
}
/**
* 获取风险预警
*
* @return 风险预警
*/
@Override
public List<RiskEarlyWarningVo> getRiskEarlyWarning() {
List<HseViolationRecord> recordList = hseViolationRecordService.lambdaQuery()
.last("limit 10")
.list();
recordList = recordList.stream()
.filter(record -> record.getReviewType() == null || record.getReviewType().equals("2"))
.toList();
if (CollUtil.isEmpty(recordList)) {
return Collections.emptyList();
}
// 项目映射
Set<Long> projectIds = recordList.stream()
.map(HseViolationRecord::getProjectId)
.collect(Collectors.toSet());
List<BusProject> projectList = projectService.lambdaQuery()
.select(BusProject::getId, BusProject::getProjectName)
.in(BusProject::getId, projectIds)
.list();
Map<Long, String> projectMap = projectList.stream()
.collect(Collectors.toMap(BusProject::getId, BusProject::getProjectName));
// 风险映射
Set<Long> levelIds = recordList.stream()
.map(HseViolationRecord::getLevelId)
.collect(Collectors.toSet());
List<HseViolationLevel> levelList = hseViolationLevelService.lambdaQuery()
.select(HseViolationLevel::getId, HseViolationLevel::getRiskType, HseViolationLevel::getViolationLevel)
.in(HseViolationLevel::getId, levelIds)
.list();
Map<Long, HseViolationLevel> levelMap = levelList.stream()
.collect(Collectors.toMap(HseViolationLevel::getId, level -> level));
// 识别记录映射
Set<Long> recognizeIds = recordList.stream()
.map(HseViolationRecord::getRecognizeId)
.collect(Collectors.toSet());
List<HseRecognizeRecord> recognizeRecordList = hseRecognizeRecordService.lambdaQuery()
.in(HseRecognizeRecord::getId, recognizeIds)
.list();
Map<Long, HseRecognizeRecord> recognizeRecordMap = recognizeRecordList.stream()
.collect(Collectors.toMap(HseRecognizeRecord::getId, recognize -> recognize));
return recordList.stream().map(record -> {
RiskEarlyWarningVo vo = new RiskEarlyWarningVo();
Date violationTime = record.getViolationTime() != null ? record.getViolationTime() : record.getCreateTime();
vo.setDate(DateUtils.toLocalDate(violationTime));
vo.setSource(projectMap.getOrDefault(record.getProjectId(), "未知项目"));
vo.setRiskType(record.getViolationType());
if (levelMap.containsKey(record.getLevelId())) {
HseViolationLevel level = levelMap.get(record.getLevelId());
vo.setAlarmLevel(level.getRiskType());
vo.setDangerLevel(level.getViolationLevel());
}
if (recognizeRecordMap.containsKey(record.getRecognizeId())) {
HseRecognizeRecord hseRecognizeRecord = recognizeRecordMap.get(record.getRecognizeId());
vo.setAlarmContent(hseRecognizeRecord.getDescription());
}
return vo;
}).toList();
}
/**
* 获取3天的天气列表
*
* @param req 查询参数
* @return 天气列表
*/
@Override
public List<WeatherVo> getWeather3DaysList(WeatherQueryReq req) {
return weatherManager.getWeatherListVo(req.getLng(), req.getLat(), WeatherConstant.THREE_DAYS_WEATHER_PATH);
}
}

View File

@ -4,10 +4,10 @@ import jakarta.annotation.Resource;
import org.dromara.bigscreen.service.MoneyBigScreenService;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import org.dromara.project.domain.BusProject;
import org.dromara.project.domain.vo.project.BusProjectGisVo;
import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
import org.dromara.project.domain.vo.project.BusProjectWeatherVo;
import org.dromara.project.service.IBusProjectService;
import org.springframework.stereotype.Service;
@ -40,7 +40,7 @@ public class MoneyBigScreenServiceImpl implements MoneyBigScreenService {
* @return 项目天气
*/
@Override
public List<BusProjectWeatherVo> getProjectWeather(Long projectId) {
public List<WeatherVo> getProjectWeather(Long projectId) {
checkProject(projectId);
return projectService.getWeather(projectId);
}

View File

@ -1,8 +1,8 @@
package org.dromara.bigscreen.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import jakarta.annotation.Resource;
import org.dromara.bigscreen.domain.vo.ProjectImageProgressVo;
import org.dromara.bigscreen.domain.vo.ProjectPeopleVo;
@ -11,14 +11,19 @@ import org.dromara.bigscreen.domain.vo.ProjectTeamAttendanceVo;
import org.dromara.bigscreen.service.ProjectBigScreenService;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.utils.BigDecimalUtil;
import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.manager.weathermanager.vo.WeatherVo;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum;
import org.dromara.progress.service.IPgsProgressCategoryService;
import org.dromara.project.domain.BusProject;
import org.dromara.project.domain.BusProjectTeam;
import org.dromara.project.domain.BusProjectTeamMember;
import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
import org.dromara.project.domain.vo.project.BusProjectWeatherVo;
import org.dromara.project.domain.vo.projectnews.BusProjectNewsVo;
import org.dromara.project.service.*;
import org.dromara.safety.domain.HseRecognizeRecord;
@ -27,11 +32,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -62,6 +65,9 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
@Resource
private IBusProjectTeamMemberService projectTeamMemberService;
@Resource
private IPgsProgressCategoryService progressCategoryService;
/**
* 获取项目天气
*
@ -69,7 +75,7 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
* @return 项目天气
*/
@Override
public List<BusProjectWeatherVo> getProjectWeather(Long projectId) {
public List<WeatherVo> getProjectWeather(Long projectId) {
checkProject(projectId);
return projectService.getWeather(projectId);
}
@ -203,50 +209,130 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
@Override
public ProjectImageProgressVo getProjectImageProgress(Long projectId) {
checkProject(projectId);
// 生成 0 ~ 100 的随机 double
double random = RandomUtil.randomDouble(0, 100);
// 保留两位小数(四舍五入)
double result = NumberUtil.round(random, 2).doubleValue();
ProjectImageProgressVo vo = new ProjectImageProgressVo();
vo.setAreaPercentage(BigDecimal.valueOf(result));
// 生成 0 ~ 100 的随机 double
double random1 = RandomUtil.randomDouble(0, 100);
// 保留两位小数(四舍五入)
double result1 = NumberUtil.round(random1, 2).doubleValue();
vo.setRoadPercentage(BigDecimal.valueOf(result1));
// 生成 0 ~ 100 的随机 double
double random2 = RandomUtil.randomDouble(0, 100);
// 保留两位小数(四舍五入)
double result2 = NumberUtil.round(random2, 2).doubleValue();
vo.setCollectorLinePercentage(BigDecimal.valueOf(result2));
// 生成 0 ~ 100 的随机 double
double random3 = RandomUtil.randomDouble(0, 100);
// 保留两位小数(四舍五入)
double result3 = NumberUtil.round(random3, 2).doubleValue();
vo.setExportLinePercentage(BigDecimal.valueOf(result3));
// 生成 0 ~ 100 的随机 double
double random4 = RandomUtil.randomDouble(0, 100);
// 保留两位小数(四舍五入)
double result4 = NumberUtil.round(random4, 2).doubleValue();
vo.setSubstationPercentage(BigDecimal.valueOf(result4));
// 生成 0 ~ 100 的随机 double
double random5 = RandomUtil.randomDouble(0, 100);
// 保留两位小数(四舍五入)
double result5 = NumberUtil.round(random5, 2).doubleValue();
vo.setBoxTransformerPercentage(BigDecimal.valueOf(result5));
// 生成 0 ~ 100 的随机 double
double random6 = RandomUtil.randomDouble(0, 100);
// 保留两位小数(四舍五入)
double result6 = NumberUtil.round(random6, 2).doubleValue();
vo.setTotalPercentage(BigDecimal.valueOf(result6));
// 获取所有子项目列表
List<BusProject> subProjectList = projectService.lambdaQuery()
.eq(BusProject::getPId, projectId)
.list();
if (CollUtil.isEmpty(subProjectList)) {
return vo;
}
// 子项目id列表
List<Long> subProjectIds = subProjectList.stream().map(BusProject::getId).toList();
// 计算集电线路
vo.setCollectorLinePercentage(BigDecimal.valueOf(0.00));
// 计算送出线路
vo.setExportLinePercentage(BigDecimal.valueOf(0.00));
// 计算升压站
vo.setSubstationPercentage(BigDecimal.valueOf(0.00));
// 计算光伏场区
vo.setAreaPercentage(BigDecimal.valueOf(0.00));
// 计算道路
vo.setRoadPercentage(BigDecimal.valueOf(0.00));
// 计算箱变
vo.setBoxTransformerPercentage(BigDecimal.ZERO);
// 获取集电线路、送出线路、升压站数据
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getProjectId, subProjectIds)
.in(PgsProgressCategory::getName, "集电线路", "送出线路", "升压站", "光伏场区")
.eq(PgsProgressCategory::getParentId, 0L)
.list();
if (CollUtil.isNotEmpty(progressCategoryList)) {
List<Long> categoryIds = progressCategoryList.stream().map(PgsProgressCategory::getId).distinct().toList();
List<PgsProgressCategory> leafNodesByTopIds = progressCategoryService.getLeafNodesByTopIds(categoryIds);
Map<String, List<PgsProgressCategory>> categoryMap = progressCategoryList.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
// 计算集电线路
if (categoryMap.containsKey("集电线路")) {
List<PgsProgressCategory> categoryList = categoryMap.get("集电线路");
List<Long> ids = categoryList.stream().map(PgsProgressCategory::getId).distinct().toList();
List<PgsProgressCategory> list = leafNodesByTopIds.stream()
.filter(node -> {
Set<Long> ancestorSet = Arrays.stream(node.getAncestors().split(",")).map(Long::parseLong).collect(Collectors.toSet());
return ids.stream().anyMatch(ancestorSet::contains);
}).toList();
BigDecimal percentage = progressCategoryService.getCompletedPercentage(list);
if (percentage.compareTo(BigDecimal.ZERO) > 0) {
vo.setCollectorLinePercentage(percentage);
}
}
// 计算送出线路
if (categoryMap.containsKey("送出线路")) {
List<PgsProgressCategory> categoryList = categoryMap.get("送出线路");
List<Long> ids = categoryList.stream().map(PgsProgressCategory::getId).distinct().toList();
List<PgsProgressCategory> list = leafNodesByTopIds.stream()
.filter(node -> {
Set<Long> ancestorSet = Arrays.stream(node.getAncestors().split(",")).map(Long::parseLong).collect(Collectors.toSet());
return ids.stream().anyMatch(ancestorSet::contains);
}).toList();
BigDecimal percentage = progressCategoryService.getCompletedPercentage(list);
if (percentage.compareTo(BigDecimal.ZERO) > 0) {
vo.setExportLinePercentage(percentage);
}
}
// 计算升压站
if (categoryMap.containsKey("升压站")) {
List<PgsProgressCategory> categoryList = categoryMap.get("升压站");
List<Long> ids = categoryList.stream().map(PgsProgressCategory::getId).distinct().toList();
List<PgsProgressCategory> list = leafNodesByTopIds.stream()
.filter(node -> {
Set<Long> ancestorSet = Arrays.stream(node.getAncestors().split(",")).map(Long::parseLong).collect(Collectors.toSet());
return ids.stream().anyMatch(ancestorSet::contains);
}).toList();
BigDecimal percentage = progressCategoryService.getCompletedPercentage(list);
if (percentage.compareTo(BigDecimal.ZERO) > 0) {
vo.setSubstationPercentage(percentage);
}
}
// 计算光伏场区
if (categoryMap.containsKey("光伏场区")) {
List<PgsProgressCategory> categoryList = categoryMap.get("光伏场区");
List<Long> ids = categoryList.stream().map(PgsProgressCategory::getId).distinct().toList();
List<PgsProgressCategory> list = leafNodesByTopIds.stream()
.filter(node -> {
Set<Long> ancestorSet = Arrays.stream(node.getAncestors().split(",")).map(Long::parseLong).collect(Collectors.toSet());
return ids.stream().anyMatch(ancestorSet::contains);
}).toList();
BigDecimal percentage = progressCategoryService.getCompletedPercentage(list);
if (percentage.compareTo(BigDecimal.ZERO) > 0) {
vo.setAreaPercentage(percentage);
}
}
}
// 计算道路
List<PgsProgressCategory> roadCategoryList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getProjectId, subProjectIds)
.like(PgsProgressCategory::getName, "道路")
.ne(PgsProgressCategory::getUnitType, PgsProgressUnitTypeEnum.NULL.getValue())
.list();
if (CollUtil.isNotEmpty(roadCategoryList)) {
BigDecimal percentage = progressCategoryService.getCompletedPercentage(roadCategoryList);
if (percentage.compareTo(BigDecimal.ZERO) > 0) {
vo.setRoadPercentage(percentage);
}
}
// 计算箱变
List<PgsProgressCategory> boxTransformerCategoryList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getProjectId, subProjectIds)
.like(PgsProgressCategory::getName, "箱变")
.ne(PgsProgressCategory::getUnitType, PgsProgressUnitTypeEnum.NULL.getValue())
.list();
if (CollUtil.isNotEmpty(boxTransformerCategoryList)) {
BigDecimal percentage = progressCategoryService.getCompletedPercentage(boxTransformerCategoryList);
if (percentage.compareTo(BigDecimal.ZERO) > 0) {
vo.setBoxTransformerPercentage(percentage);
}
}
// 计算总进度
vo.setTotalPercentage(
vo.getCollectorLinePercentage()
.add(vo.getExportLinePercentage())
.add(vo.getSubstationPercentage())
.add(vo.getAreaPercentage())
.add(vo.getRoadPercentage())
.add(vo.getBoxTransformerPercentage())
.divide(BigDecimal.valueOf(6), 2, RoundingMode.HALF_UP) // 保留两位小数
);
return vo;
}
@ -276,4 +362,26 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
}
}
@Override
public List<String> getList(Long projectId) {
if (projectId == null){
throw new ServiceException("项目id不能为空");
}
Object object = RedisUtils.getCacheObject("xmjdp:" + projectId);
if (object == null) {
return null;
}
JSONArray objects = JSONUtil.parseArray(object);
return objects.toList(String.class);
}
@Override
public void setList(GpsEquipmentBo bo) {
if (bo.getProjectId() == null){
throw new ServiceException("项目id不能为空");
}
RedisUtils.setCacheObject("xmjdp:"+bo.getProjectId(), bo.getIdList());
}
}

View File

@ -1,6 +1,7 @@
package org.dromara.cailiaoshebei.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
@ -33,8 +34,12 @@ import org.dromara.design.service.IBusBillofquantitiesVersionsService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 物资-采购联系单
@ -67,6 +72,8 @@ public class BusPurchaseDocController extends BaseController {
return busPurchaseDocService.queryPageList(bo, pageQuery);
}
/**
* 导出物资-采购联系单列表
*/
@ -157,13 +164,23 @@ public class BusPurchaseDocController extends BaseController {
@PathVariable("id") Long id) {
List<BusPlanDocAssociation> list = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
.eq(BusPlanDocAssociation::getDocId, id));
List<Long> list1 = list.stream().map(BusPlanDocAssociation::getPlanId).toList();
if (list1.isEmpty()) {
if (CollectionUtil.isEmpty(list)) {
return R.ok(new ArrayList<>());
}
Map<Long, BigDecimal> collect = list.stream()
.filter(Objects::nonNull) // 过滤空对象
.collect(Collectors.toMap(
BusPlanDocAssociation::getPlanId,
BusPlanDocAssociation::getDemandQuantity,
(existing, replacement) -> existing // 保留第一个遇到的重复键
));
BusMaterialbatchdemandplanBo bo = new BusMaterialbatchdemandplanBo();
bo.setIds(list1);
return R.ok(materialbatchdemandplanService.queryList(bo));
bo.setIds(new ArrayList<>(collect.keySet()));
List<BusMaterialbatchdemandplanVo> busMaterialbatchdemandplanVos = materialbatchdemandplanService.queryList(bo);
for (BusMaterialbatchdemandplanVo busMaterialbatchdemandplanVo : busMaterialbatchdemandplanVos) {
busMaterialbatchdemandplanVo.setDemandQuantity(collect.get(busMaterialbatchdemandplanVo.getId()).longValue());
}
return R.ok(busMaterialbatchdemandplanVos);
}
//

View File

@ -6,6 +6,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.math.BigDecimal;
/**
* 物资-批次需求计划与采购单关联对象 bus_plan_doc_association
@ -37,6 +38,11 @@ public class BusPlanDocAssociation extends BaseEntity {
*/
private Long planId;
/**
* 需求数量
*/
private BigDecimal demandQuantity;
/**
* 采购联系单id
*/

View File

@ -114,4 +114,10 @@ public class BusMaterialbatchdemandplanBo extends BaseEntity {
* 主键集合
*/
private List<Long> ids;
/**
* 供应商id
*/
private Long supplierId;
}

View File

@ -9,6 +9,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
/**
* 物资-批次需求计划与采购单关联业务对象 bus_plan_doc_association
*
@ -41,5 +43,8 @@ public class BusPlanDocAssociationBo extends BaseEntity {
*/
private Long docId;
/**
* 需求数量
*/
private BigDecimal demandQuantity;
}

View File

@ -28,6 +28,11 @@ public class BusTotalsupplyplanBo extends BaseEntity {
@NotNull(message = "主键ID不能为空", groups = { EditGroup.class })
private Long id;
/**
* 项目Id
*/
private Long projectId;
/**
* 批次号
*/

View File

@ -10,6 +10,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@ -52,5 +53,8 @@ public class BusPlanDocAssociationVo implements Serializable {
@ExcelProperty(value = "采购联系单id")
private Long docId;
/**
* 需求数量
*/
private BigDecimal demandQuantity;
}

View File

@ -22,6 +22,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.tender.domain.bo.BusBiddingPlanBo;
import org.dromara.tender.domain.vo.BusBiddingPlanVo;
import org.dromara.tender.domain.vo.BusBillofquantitiesLimitListVo;
import org.dromara.tender.service.IBusBiddingPlanService;
import org.dromara.tender.service.ITenderSupplierInputService;
import org.springframework.context.annotation.Lazy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
@ -34,9 +39,7 @@ import org.dromara.cailiaoshebei.mapper.BusMaterialbatchdemandplanMapper;
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.*;
/**
* 物资-批次需求计划Service业务层处理
@ -60,6 +63,10 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
@Autowired
private IBusMaterialsorderService busMaterialsorderService;
@Lazy
@Autowired
private IBusBiddingPlanService busBiddingPlanService;
/**
* 查询物资-批次需求计划
*
@ -82,6 +89,25 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
public TableDataInfo<BusMaterialbatchdemandplanVo> queryPageList(BusMaterialbatchdemandplanBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<BusMaterialbatchdemandplan> lqw = buildQueryWrapper(bo);
Page<BusMaterialbatchdemandplanVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
if (bo.getSupplierId()!=null){
BusBiddingPlanBo bo1 = new BusBiddingPlanBo();
bo1.setProjectId(bo.getProjectId());
bo1.setType("2");
bo1.setWinningBidderId(bo.getSupplierId());
List<BusBillofquantitiesLimitListVo> busBiddingPlanVos = busBiddingPlanService.getBillofquantitiesLimitListVo(bo1);
if (busBiddingPlanVos == null || busBiddingPlanVos.isEmpty()) {
throw new ServiceException("该供应商暂无材料");
}
Set<String> hashSet = new HashSet<>();
busBiddingPlanVos.stream().forEach(vo -> {
hashSet.add(vo.getName()+"+"+vo.getSpecification());
});
List<BusMaterialbatchdemandplanVo> list = result.getRecords().stream().filter(vo -> {
String key = vo.getName() + "+" + vo.getSpecification(); // 拼接字符串(需与 Set 中格式一致)
return hashSet.contains(key); // 仅保留 Set 中存在的数据
}).toList();
result.setRecords(list);
}
return TableDataInfo.build(result);
}

View File

@ -57,6 +57,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.FileNameMap;
import java.net.URLConnection;
import java.net.URLEncoder;
@ -69,6 +70,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* 物资-采购联系单Service业务层处理
@ -184,6 +186,7 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
BusPurchaseDoc add = MapstructUtils.convert(bo, BusPurchaseDoc.class);
validEntityBeforeSave(add);
validNum(bo.getAssociationList());
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
@ -199,6 +202,30 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
return flag;
}
public void validNum(List<BusPlanDocAssociationBo> associationList){
for (BusPlanDocAssociationBo association : associationList) {
BusMaterialbatchdemandplan byId = materialbatchdemandplanService.getById(association.getPlanId());
List<BusPlanDocAssociation> list = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
.eq(BusPlanDocAssociation::getPlanId, association.getPlanId()));
BigDecimal total = list.stream()
.map(BusPlanDocAssociation::getDemandQuantity)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
if(total.add(association.getDemandQuantity()).compareTo(byId.getDemandQuantity()) > 0){
throw new ServiceException("材料:" + byId.getName() + "已超出计划单的物料批次需求计划数量");
}
}
}
/**
* 修改物资-采购联系单
*
@ -320,8 +347,9 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
.eq(BusPlanDocAssociation::getDocId, purchaseDoc.getId())
.list();
if (CollUtil.isNotEmpty(planDocAssociationList)) {
List<Long> planIds = planDocAssociationList.stream().map(BusPlanDocAssociation::getPlanId).toList();
items = materialbatchdemandplanService.listByIds(planIds);
Map<Long, BigDecimal> map = planDocAssociationList.stream().collect(Collectors.toMap(BusPlanDocAssociation::getPlanId, BusPlanDocAssociation::getDemandQuantity));
items = materialbatchdemandplanService.listByIds(map.keySet());
items.forEach(item -> item.setDemandQuantity(map.get(item.getId())));
}
BusPurchaseDocWordDto data = this.getReplacementDto(purchaseDoc, items);
Path newTargetDir = Paths.get(System.getProperty("user.dir"), constant.getBusPurchaseDocFileUrl(purchaseDoc, now));

View File

@ -104,6 +104,7 @@ public class BusTotalsupplyplanServiceImpl extends ServiceImpl<BusTotalsupplypla
private LambdaQueryWrapper<BusTotalsupplyplan> buildQueryWrapper(BusTotalsupplyplanBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<BusTotalsupplyplan> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getProjectId() != null ,BusTotalsupplyplan::getProjectId,bo.getProjectId());
lqw.eq(StringUtils.isNotBlank(bo.getTexture()), BusTotalsupplyplan::getTexture, bo.getTexture());
lqw.eq(StringUtils.isNotBlank(bo.getBrand()), BusTotalsupplyplan::getBrand, bo.getBrand());
lqw.eq(StringUtils.isNotBlank(bo.getQualityStandard()), BusTotalsupplyplan::getQualityStandard, bo.getQualityStandard());

View File

@ -18,9 +18,11 @@ public class BigDecimalUtil {
*/
public static BigDecimal toPercentage(BigDecimal dividend, BigDecimal divisor) {
if (dividend == null || divisor == null || divisor.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.ZERO;
return BigDecimal.valueOf(0.00);
}
return dividend.divide(divisor, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
return dividend
.multiply(new BigDecimal("100"))
.divide(divisor, 2, RoundingMode.HALF_UP);
}
}

View File

@ -111,12 +111,139 @@ public class PdfBoxQrCodeGenerator {
/**
* 在PDF每一页的指定位置添加二维码并返回数据流根据页面方向自动调整位置
*/
// public static ByteArrayOutputStream addQRCodeToPDFOnAllPages(String srcPdf, byte[] qrCodeBytes, boolean isChangeFile)
// throws IOException {
//
// PdfReader reader;
// if (srcPdf.startsWith("http://") || srcPdf.startsWith("https://")) {
// // 网络地址 PDF
// URL url = new URL(srcPdf);
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// connection.setConnectTimeout(10000);
// connection.setReadTimeout(30000);
// connection.setRequestMethod("GET");
//
// int responseCode = connection.getResponseCode();
// if (responseCode != HttpURLConnection.HTTP_OK) {
// throw new IOException("无法获取 PDF 文件HTTP响应码: " + responseCode);
// }
// InputStream inputStream = connection.getInputStream();
// reader = new PdfReader(inputStream);
// } else {
// // 本地文件 PDF
// File srcFile = new File(srcPdf);
// if (!srcFile.exists()) {
// throw new IOException("源PDF文件不存在: " + srcPdf);
// }
// reader = new PdfReader(srcPdf);
// }
//
// ByteArrayOutputStream pdfOut = new ByteArrayOutputStream();
// PdfWriter writer = new PdfWriter(pdfOut);
// PdfDocument pdfDoc = new PdfDocument(reader, writer);
//
// int numberOfPages = pdfDoc.getNumberOfPages();
//
// for (int pageNum = 1; pageNum <= numberOfPages; pageNum++) {
// PdfPage page = pdfDoc.getPage(pageNum);
// Rectangle pageSize = page.getPageSize();
//
// float pageWidth = pageSize.getWidth();
// float pageHeight = pageSize.getHeight();
//
// float qrX, qrY;
// float newWidth, newHeight;
//
// if (isChangeFile && pageNum == 1) {
// qrX = pageWidth - 143;
// qrY = pageHeight - 213;
// newWidth = 67;
// newHeight = 80;
// } else {
// if (pageWidth > pageHeight) {
// // 横版
// qrX = pageWidth - 90;
// qrY = 24;
// newWidth = 67;
// newHeight = 79;
// } else {
// // 竖版
// qrX = 226;
// qrY = pageHeight - 185;
// newWidth = 69;
// newHeight = 80;
// }
// }
//
// PdfCanvas pdfCanvas = new PdfCanvas(page.newContentStreamAfter(), page.getResources(), pdfDoc);
// try (Canvas canvas = new Canvas(pdfCanvas, page.getPageSize())) {
// ImageData imageData = ImageDataFactory.create(qrCodeBytes);
// Image image = new Image(imageData)
// .scaleAbsolute(newWidth, newHeight)
// .setFixedPosition(qrX, qrY);
// canvas.add(image);
// }
// }
//
// pdfDoc.close();
// return pdfOut;
// }
// public static void main(String[] args) {
// String path = "C:\\Users\\YuanJie\\Desktop\\test.pdf";
// String outputPath = "C:\\Users\\YuanJie\\Desktop\\test1.pdf";
//
// String params = "http://192.168.110.151:7788/codeDetail?id=" + "1957649652924448769";
// byte[] bytes = PdfBoxQrCodeGenerator.generateQRCodeBytes(params);
//
// try {
// System.out.println("二维码字节大小: " + bytes.length + " 字节");
//
// // 在每一页添加二维码
// ByteArrayOutputStream byteArrayOutputStream =
// PdfBoxQrCodeGenerator.addQRCodeToPDFOnAllPages(path, bytes, false);
//
// try (FileOutputStream fileOut = new FileOutputStream(outputPath)) {
// byteArrayOutputStream.writeTo(fileOut);
// }
//
// System.out.println("PDF文件已成功生成到: " + outputPath);
// System.out.println("生成的PDF大小: " + new File(outputPath).length() + " 字节");
//
// } catch (Exception e) {
// e.printStackTrace();
// System.out.println("图纸管理 => 审核结束,向文件添加二维码失败");
// }
// }
// 固定的边距(点)
private static final float MARGIN = 10.0f;
// 二维码大小比例页面宽高中较小值的20%
private static final float QR_SIZE_RATIO = 0.2f;
// 二维码大小比例页面宽高中较小值的20%
private static final float QR_SIZE = 60.0f;
// 竖坐标
private static final float V_QR_X = 232.0f;
// 竖坐标
private static final float V_QR_Y = 679.5f;
// 横坐标
private static final float H_QR_X = 1116.5f;
// 横坐标
private static final float H_QR_Y = 34.0f;
public static ByteArrayOutputStream addQRCodeToPDFOnAllPages(String srcPdf, byte[] qrCodeBytes, boolean isChangeFile)
throws IOException {
PdfReader reader;
if (srcPdf.startsWith("http://") || srcPdf.startsWith("https://")) {
// 网络地址 PDF
URL url = new URL(srcPdf);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(10000);
@ -130,7 +257,6 @@ public class PdfBoxQrCodeGenerator {
InputStream inputStream = connection.getInputStream();
reader = new PdfReader(inputStream);
} else {
// 本地文件 PDF
File srcFile = new File(srcPdf);
if (!srcFile.exists()) {
throw new IOException("源PDF文件不存在: " + srcPdf);
@ -145,43 +271,51 @@ public class PdfBoxQrCodeGenerator {
int numberOfPages = pdfDoc.getNumberOfPages();
for (int pageNum = 1; pageNum <= numberOfPages; pageNum++) {
PdfPage page = pdfDoc.getPage(pageNum);
Rectangle pageSize = page.getPageSize();
float pageWidth = pageSize.getWidth();
float pageHeight = pageSize.getHeight();
float qrX, qrY;
float newWidth, newHeight;
if (isChangeFile && pageNum == 1) {
qrX = pageWidth - 143;
qrY = pageHeight - 213;
newWidth = 67;
newHeight = 80;
} else {
if (pageWidth > pageHeight) {
// 横版
qrX = pageWidth - 90;
qrY = 24;
newWidth = 67;
newHeight = 79;
} else {
// 竖版
qrX = 226;
qrY = pageHeight - 185;
newWidth = 69;
newHeight = 80;
}
if (pageNum == 1 && isChangeFile) {
continue;
}
PdfCanvas pdfCanvas = new PdfCanvas(page.newContentStreamAfter(), page.getResources(), pdfDoc);
try (Canvas canvas = new Canvas(pdfCanvas, page.getPageSize())) {
ImageData imageData = ImageDataFactory.create(qrCodeBytes);
Image image = new Image(imageData)
.scaleAbsolute(newWidth, newHeight)
.setFixedPosition(qrX, qrY);
canvas.add(image);
PdfPage page = pdfDoc.getPage(pageNum);
// 获取页面的所有边界框信息
Rectangle mediaBox = page.getMediaBox();
Rectangle cropBox = page.getCropBox();
// 使用CropBox作为主要参考因为它定义了页面的可见区域
Rectangle visibleArea = (cropBox != null) ? cropBox : mediaBox;
// 计算页面宽高中较小的值
// float minDimension = Math.min(visibleArea.getWidth(), visibleArea.getHeight());
// 动态计算二维码大小页面宽高中较小值的20%
// float qrSize = minDimension * QR_SIZE_RATIO;
// 输出页面尺寸信息
// System.out.println("页面 " + pageNum + " 尺寸: " + visibleArea.getWidth() + "x" + visibleArea.getHeight());
// System.out.println("页面 " + pageNum + " 二维码大小 (点): " + qrSize);
// 计算左上角的位置PDF坐标系原点在左下角
// float qrX = visibleArea.getLeft() + MARGIN;
// float qrY = visibleArea.getTop() - qrSize - MARGIN;
// 打印二维码位置信息
// System.out.println("页面 " + pageNum + " 左上角二维码位置: x=" + qrX + ", y=" + qrY);
float qrX;
float qrY;
if (visibleArea.getWidth() > visibleArea.getHeight()) {
qrX = H_QR_X;
qrY = H_QR_Y;
} else {
qrX = V_QR_X;
qrY = V_QR_Y;
}
try {
// 使用Canvas API添加左上角二维码
addQRCodeWithCanvas(pdfDoc, page, qrCodeBytes, qrX, qrY, QR_SIZE);
} catch (Exception e) {
System.err.println("在页面 " + pageNum + " 添加二维码时出错: " + e.getMessage());
e.printStackTrace();
}
}
@ -189,32 +323,106 @@ public class PdfBoxQrCodeGenerator {
return pdfOut;
}
// 使用Canvas API添加图像
private static void addQRCodeWithCanvas(PdfDocument pdfDoc, PdfPage page,
byte[] qrCodeBytes, float x, float y, float size) throws IOException {
// 创建Canvas对象 - 使用PdfPage和Rectangle构造函数
Canvas canvas = new Canvas(page, page.getPageSize());
// 创建图像数据
ImageData imageData = ImageDataFactory.create(qrCodeBytes);
// 创建Image对象
Image image = new Image(imageData);
// 设置图像位置和大小
image.setFixedPosition(x, y);
image.setWidth(size);
image.setHeight(size);
// 添加图像到Canvas
canvas.add(image);
// 关闭Canvas
canvas.close();
System.out.println("Canvas方法设置位置: x=" + x + ", y=" + y);
}
// main方法示例
public static void main(String[] args) {
String path = "C:\\Users\\YuanJie\\Desktop\\test.pdf";
String outputPath = "C:\\Users\\YuanJie\\Desktop\\test1.pdf";
String params = "http://192.168.110.151:7788/codeDetail?id=" + "1957649652924448769";
byte[] bytes = PdfBoxQrCodeGenerator.generateQRCodeBytes(params);
BufferedImage image = QrCodeUtil.generate(params, 200, 200);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImgUtil.write(image, ImgUtil.IMAGE_TYPE_PNG, out);
byte[] bytes = out.toByteArray();
try {
System.out.println("二维码字节大小: " + bytes.length + " 字节");
// 先保存二维码图片用于验证
try (FileOutputStream qrOut = new FileOutputStream("C:\\Users\\YuanJie\\Desktop\\qrcode.png")) {
qrOut.write(bytes);
System.out.println("二维码图片已保存到桌面,用于验证二维码是否生成正确");
}
// 在每一页添加二维码
ByteArrayOutputStream byteArrayOutputStream =
PdfBoxQrCodeGenerator.addQRCodeToPDFOnAllPages(path, bytes, false);
ByteArrayOutputStream byteArrayOutputStream = addQRCodeToPDFOnAllPages(path, bytes, false);
try (FileOutputStream fileOut = new FileOutputStream(outputPath)) {
byteArrayOutputStream.writeTo(fileOut);
}
File outputFile = new File(outputPath);
System.out.println("PDF文件已成功生成到: " + outputPath);
System.out.println("生成的PDF大小: " + new File(outputPath).length() + " 字节");
System.out.println("生成的PDF大小: " + outputFile.length() + " 字节");
if (outputFile.length() == new File(path).length()) {
System.out.println("警告:输出文件大小与原文件相同,可能二维码未正确添加");
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("图纸管理 => 审核结束,向文件添加二维码失败");
}
}
}

View File

@ -2,6 +2,7 @@ package org.dromara.common.utils.baiduUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.utils.baiduUtil.entity.face.ComparisonRes;
import org.dromara.common.utils.baiduUtil.entity.face.HumanFaceReq;
import org.dromara.common.utils.baiduUtil.entity.face.HumanFaceRes;
@ -23,6 +24,7 @@ import java.util.List;
* @Version 1.0
* 处理百度人脸相关逻辑:人脸检测、人脸对比
*/
@Slf4j
@Service
public class BaiDuFace {
@ -92,7 +94,8 @@ public class BaiDuFace {
// 7. 处理API返回错误
if (faceRep.getErrorCode() != 0) {
throw new RuntimeException("错误码说明:" + faceRep.getErrorMsg());
log.warn("百度人脸API返回错误码{}", faceRep.getErrorCode());
throw new RuntimeException("未检测到有效人脸信息");
}
// 8. 验证人脸信息(无人脸时抛出异常)

View File

@ -17,13 +17,20 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.contractor.domain.dto.constructionuser.*;
import org.dromara.contractor.domain.exportvo.BusConstructionUserExportVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserAttendanceMonthVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserAttendanceTotalVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserGisVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserVo;
import org.dromara.contractor.domain.vo.constructionuser.*;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.project.domain.dto.project.BusProjectQueryReq;
import org.dromara.project.domain.dto.projectteam.BusProjectTeamQueryReq;
import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberCreateReq;
import org.dromara.project.domain.vo.project.BusProjectVo;
import org.dromara.project.domain.vo.projectteam.BusProjectTeamVo;
import org.dromara.project.service.IBusProjectService;
import org.dromara.project.service.IBusProjectTeamMemberService;
import org.dromara.project.service.IBusProjectTeamService;
import org.dromara.system.domain.vo.SysOssVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -41,6 +48,12 @@ public class SubConstructionUserController extends BaseController {
private final ISubConstructionUserService constructionUserService;
private final IBusProjectTeamService busProjectTeamService;
private final IBusProjectTeamMemberService busProjectTeamMemberService;
private final IBusProjectService projectService;
/**
* 查询施工人员列表
*/
@ -190,4 +203,63 @@ public class SubConstructionUserController extends BaseController {
@PathVariable Long[] ids) {
return toAjax(constructionUserService.deleteWithValidByIds(List.of(ids), true));
}
/**
* 查询项目班组列表
*/
@SaCheckPermission("project:projectTeam:addTeam")
@GetMapping("/projectList")
public TableDataInfo<BusProjectVo> list(BusProjectQueryReq req, PageQuery pageQuery) {
return projectService.queryPageList(req, pageQuery);
}
/**
* 查询项目班组列表
*/
@SaCheckPermission("project:projectTeam:addTeam")
@GetMapping("/teamList")
public TableDataInfo<BusProjectTeamVo> teamList(BusProjectTeamQueryReq req, PageQuery pageQuery) {
return busProjectTeamService.queryPageList(req, pageQuery);
}
/**
* 添加项目班组
*/
@SaCheckPermission("project:projectTeam:addTeam")
@RepeatSubmit()
@PostMapping("/addTeam")
public R<Long> add(@Validated(AddGroup.class) @RequestBody BusProjectTeamMemberCreateReq req) {
return R.ok(busProjectTeamMemberService.insertByBo(req));
}
/**
* 根据身份证图片获取身份证信息
*/
@SaCheckPermission("contractor:constructionUser:add")
@Log(title = "施工人员", businessType = BusinessType.OTHER)
@PostMapping("/idCard")
public R<SubConstructionUserOrcIdCardVo> getIdCardMessage(@RequestParam("file") MultipartFile file, String idCardSide) {
return R.ok(constructionUserService.getIdCardMessageByPic(file, idCardSide));
}
/**
* 根据银行卡图片获取银行卡信息
*/
@SaCheckPermission("contractor:constructionUser:add")
@Log(title = "施工人员", businessType = BusinessType.OTHER)
@PostMapping("/bankCard")
public R<SubConstructionUserOrcBankVo> getBankCardMessage(@RequestParam("file") MultipartFile file) {
return R.ok(constructionUserService.getBankCardMessageByPic(file));
}
/**
* 人脸识别
*/
@SaCheckPermission("contractor:constructionUser:add")
@Log(title = "施工人员", businessType = BusinessType.OTHER)
@PostMapping("/face/recognize")
public R<SysOssVo> faceRecognize(@RequestParam("file") MultipartFile file) {
return R.ok(constructionUserService.faceRecognize(file));
}
}

View File

@ -1,8 +1,11 @@
package org.dromara.contractor.controller.app;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
@ -11,10 +14,14 @@ import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.domain.dto.constructionuser.SubConstructionUserAuthenticationReq;
import org.dromara.contractor.domain.dto.constructionuser.SubConstructionUserQueryReq;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserAppVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserOrcBankVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserOrcIdCardVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserVo;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberCreateReq;
import org.dromara.project.service.IBusProjectTeamMemberService;
import org.dromara.system.domain.vo.SysOssVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -33,6 +40,9 @@ public class SubConstructionUserAppController {
@Resource
private ISubConstructionUserService constructionUserService;
@Resource
private IBusProjectTeamMemberService busProjectTeamMemberService;
/**
* 查询施工人员列表
*/
@ -50,6 +60,18 @@ public class SubConstructionUserAppController {
return R.ok(constructionUserService.getVo(constructionUser, false));
}
/**
* 获取当前登录用户实名信息
*/
@GetMapping("/isReal")
public R<SubConstructionUserVo> isReal() {
SubConstructionUser constructionUser = constructionUserService.lambdaQuery()
.eq(SubConstructionUser::getSysUserId, LoginHelper.getUserId())
.last("limit 1")
.one();
return R.ok(constructionUserService.getVo(constructionUser, false));
}
/**
* 根据用户id查询施工人员信息
*/
@ -99,6 +121,15 @@ public class SubConstructionUserAppController {
return R.ok(constructionUserService.insertByAuthentication(req));
}
/**
* 人脸识别
*/
@Log(title = "施工人员", businessType = BusinessType.OTHER)
@PostMapping("/face/recognize")
public R<SysOssVo> faceRecognize(@RequestParam("file") MultipartFile file) {
return R.ok(constructionUserService.faceRecognize(file));
}
/**
* 施工人员人脸比对
*/
@ -108,4 +139,21 @@ public class SubConstructionUserAppController {
return R.ok(constructionUserService.faceComparison(file));
}
/**
* 查询未分配施工人员列表
*/
@GetMapping("/undistributedList")
public TableDataInfo<SubConstructionUserAppVo> queryUndistributedList(SubConstructionUserQueryReq req, PageQuery pageQuery) {
return constructionUserService.queryUndistributedList(req, pageQuery);
}
/**
* 添加项目班组
*/
@RepeatSubmit()
@PostMapping("/addTeam")
public R<Long> add(@Validated(AddGroup.class) @RequestBody BusProjectTeamMemberCreateReq req) {
return R.ok(busProjectTeamMemberService.insertByBo(req));
}
}

View File

@ -1,20 +1,24 @@
package org.dromara.contractor.controller.app;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import org.dromara.common.core.domain.R;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.contractor.domain.dto.salaryperiod.SubSalaryPeriodCreateReq;
import org.dromara.contractor.domain.dto.salaryperiod.SubSalaryPeriodQueryReq;
import org.dromara.contractor.domain.vo.salaryperiod.SubSalaryPeriodVo;
import org.dromara.contractor.service.ISubSalaryPeriodService;
import org.springframework.validation.annotation.Validated;
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;
import org.springframework.web.bind.annotation.*;
/**
* 工资结算周期 app 接口
*
* @author lilemy
* @date 2025-09-04 14:13
*/
@ -26,6 +30,25 @@ public class SubSalaryPeriodAppController extends BaseController {
@Resource
private ISubSalaryPeriodService salaryPeriodService;
/**
* 查询工资结算周期列表
*/
@GetMapping("/list")
public TableDataInfo<SubSalaryPeriodVo> list(SubSalaryPeriodQueryReq req, PageQuery pageQuery) {
return salaryPeriodService.queryPageList(req, pageQuery);
}
/**
* 获取工资结算周期详细信息
*
* @param id 主键
*/
@GetMapping("/{id}")
public R<SubSalaryPeriodVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(salaryPeriodService.queryById(id));
}
/**
* 新增工资结算周期
*/

View File

@ -60,6 +60,11 @@ public class SubSalaryPeriod extends BaseEntity {
*/
private BigDecimal totalWage;
/**
* 总人数
*/
private Integer totalPeople;
/**
* 状态 0-未开始 1-进行中 2-已完成
*/

View File

@ -0,0 +1,85 @@
package org.dromara.contractor.domain.vo.constructionuser;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import org.dromara.common.translation.annotation.Translation;
import org.dromara.common.translation.constant.TransConstant;
import org.dromara.contractor.domain.SubConstructionUser;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
/**
* 施工人员视图对象 bus_construction_user
*
* @author lilemy
* @date 2025-03-07
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = SubConstructionUser.class)
public class SubConstructionUserAppVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@ExcelProperty(value = "主键id")
private Long id;
/**
* 人员姓名
*/
@ExcelProperty(value = "人员姓名")
private String userName;
/**
* 联系电话
*/
@ExcelProperty(value = "联系电话")
private String phone;
/**
* 工种
*/
@ExcelProperty(value = "工种", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "type_of_work")
private String typeOfWork;
/**
* 工种名
*/
@Translation(type = TransConstant.DICT_TYPE_TO_LABEL, mapper = "typeOfWork",other = "type_of_work")
private String typeOfWorkName;
/**
* 用户Id
*/
private Long sysUserId;
/**
* 用户头像
*/
private String avatar;
/**
* 入驻天数
*/
private Long days;
/**
* 用户性别0男 1女 2未知
*/
private String sex;
}

View File

@ -4,12 +4,15 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.common.translation.annotation.Translation;
import org.dromara.common.translation.constant.TransConstant;
import org.dromara.contractor.domain.SubSalaryPeriod;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
/**
@ -44,6 +47,11 @@ public class SubSalaryPeriodVo implements Serializable {
@ExcelProperty(value = "班组id")
private Long teamId;
/**
* 班组名称
*/
private String teamName;
/**
* 开始日期
*/
@ -68,6 +76,11 @@ public class SubSalaryPeriodVo implements Serializable {
@ExcelProperty(value = "总工资")
private BigDecimal totalWage;
/**
* 总人数
*/
private Integer totalPeople;
/**
* 状态 0-未开始 1-进行中 2-已完成
*/
@ -80,4 +93,21 @@ public class SubSalaryPeriodVo implements Serializable {
@ExcelProperty(value = "备注")
private String remark;
/**
* 创建时间
*/
@ExcelProperty(value = "创建时间")
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 创建人名称
*/
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "createBy")
private String createByName;
}

View File

@ -9,6 +9,7 @@ import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.domain.dto.constructionuser.*;
import org.dromara.contractor.domain.exportvo.BusConstructionUserExportVo;
import org.dromara.contractor.domain.vo.constructionuser.*;
import org.dromara.system.domain.vo.SysOssVo;
import org.springframework.web.multipart.MultipartFile;
import java.util.Collection;
@ -198,6 +199,14 @@ public interface ISubConstructionUserService extends IService<SubConstructionUse
*/
Long insertByAuthentication(SubConstructionUserAuthenticationReq req);
/**
* 人脸识别
*
* @param file 图片文件
* @return 人脸识别结果
*/
SysOssVo faceRecognize(MultipartFile file);
/**
* 人脸识别
*
@ -214,4 +223,7 @@ public interface ISubConstructionUserService extends IService<SubConstructionUse
*/
SubConstructionUser getBySysUserId(Long sysUserId);
TableDataInfo<SubConstructionUserAppVo> queryUndistributedList(SubConstructionUserQueryReq req, PageQuery pageQuery);
}

View File

@ -6,7 +6,6 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
@ -320,8 +319,6 @@ public class SubConstructionUserFileServiceImpl extends ServiceImpl<SubConstruct
throw new ServiceException("施工人员不存在", HttpStatus.NOT_FOUND);
}
// 2. 查询当前用户的所有文件记录(一次性查询,避免多次访问数据库)
LambdaQueryWrapper<SubConstructionUserFile> lqw = Wrappers.lambdaQuery(SubConstructionUserFile.class)
.eq(SubConstructionUserFile::getUserId, userId);
List<SubConstructionUserFile> constructionUserFileList = this.lambdaQuery()
.eq(SubConstructionUserFile::getUserId, userId)
.list();

View File

@ -66,10 +66,8 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.YearMonth;
import java.time.*;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
@ -645,9 +643,12 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
// 批量删除施工人员下的文件信息
LambdaQueryWrapper<SubConstructionUserFile> constructionUserFileLqw = Wrappers.lambdaQuery(SubConstructionUserFile.class)
.in(SubConstructionUserFile::getUserId, ids);
boolean removeFile = constructionUserFileService.remove(constructionUserFileLqw);
if (!removeFile) {
throw new ServiceException("删除施工人员信息失败,施工人员文件信息删除失败", HttpStatus.ERROR);
List<SubConstructionUserFile> fileList = constructionUserFileService.list(constructionUserFileLqw);
if (CollUtil.isNotEmpty(fileList)) {
boolean removeFile = constructionUserFileService.remove(constructionUserFileLqw);
if (!removeFile) {
throw new ServiceException("删除施工人员信息失败,施工人员文件信息删除失败", HttpStatus.ERROR);
}
}
// 批量删除施工人员信息
return this.removeBatchByIds(ids);
@ -676,7 +677,10 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
// 关联查询分包公司信息信息
Long contractorId = constructionUser.getContractorId();
if (contractorId != null) {
constructionUserVo.setContractorName(contractorService.getById(contractorId).getName());
SubContractor contractor = contractorService.getById(contractorId);
if (contractor != null) {
constructionUserVo.setContractorName(contractor.getName());
}
}
// 关联查询用户头像url
String facePic = constructionUser.getFacePic();
@ -1195,6 +1199,22 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
return user.getId();
}
/**
* 人脸识别
*
* @param file 图片文件
* @return 人脸识别结果
*/
@Override
public SysOssVo faceRecognize(MultipartFile file) {
String reqBase64 = this.getPicBase64(file);
HumanFaceReq faceReq = new HumanFaceReq();
faceReq.setImage(reqBase64);
// 调用人脸识别接口
baiDuFace.humanFace(faceReq);
return ossService.upload(file);
}
/**
* 人脸识别
*
@ -1203,18 +1223,7 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
*/
@Override
public Boolean faceComparison(MultipartFile file) {
if (file == null) {
throw new ServiceException("请上传图片", HttpStatus.BAD_REQUEST);
}
String reqBase64;
try {
// 获取文件字节数组
byte[] bytes = file.getBytes();
// Base64 编码
reqBase64 = Base64.getEncoder().encodeToString(bytes);
} catch (IOException e) {
throw new ServiceException("图片转换失败,请重新上传");
}
String reqBase64 = this.getPicBase64(file);
HumanFaceReq request = new HumanFaceReq();
request.setImage(reqBase64);
Long userId = LoginHelper.getUserId();
@ -1264,4 +1273,64 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
return constructionUser;
}
/**
* 获取图片的Base64编码
*
* @param file 图片文件
* @return 图片的Base64编码
*/
private String getPicBase64(MultipartFile file) {
if (file == null) {
throw new ServiceException("请上传图片", HttpStatus.BAD_REQUEST);
}
String reqBase64;
try {
// 获取文件字节数组
byte[] bytes = file.getBytes();
// Base64 编码
reqBase64 = Base64.getEncoder().encodeToString(bytes);
} catch (IOException e) {
throw new ServiceException("图片转换失败,请重新上传");
}
return reqBase64;
}
@Override
public TableDataInfo<SubConstructionUserAppVo> queryUndistributedList(SubConstructionUserQueryReq req, PageQuery pageQuery) {
LambdaQueryWrapper<SubConstructionUser> lqw = Wrappers.lambdaQuery();
String userName = req.getUserName();
String typeOfWork = req.getTypeOfWork();
lqw.like(StringUtils.isNotBlank(userName), SubConstructionUser::getUserName, userName);
lqw.eq(ObjectUtils.isNotEmpty(typeOfWork), SubConstructionUser::getTypeOfWork, typeOfWork);
lqw.isNull(SubConstructionUser::getProjectId);
lqw.isNull(SubConstructionUser::getTeamId);
Page<SubConstructionUser> result = this.page(pageQuery.build(), lqw);
ArrayList<SubConstructionUserAppVo> list = new ArrayList<>();
for ( SubConstructionUser constructionUser : result.getRecords()){
SubConstructionUserAppVo subConstructionUserAppVo = new SubConstructionUserAppVo();
BeanUtils.copyProperties(constructionUser, subConstructionUserAppVo);
SysUserVo sysUserVo = userService.selectUserById(subConstructionUserAppVo.getSysUserId());
if(sysUserVo.getAvatar() != null)
subConstructionUserAppVo.setAvatar(ossService.getById(sysUserVo.getAvatar()).getUrl());
//计算日期
Date createTime = sysUserVo.getCreateTime();
Instant createInstant = createTime.toInstant();
Instant nowInstant = Instant.now();
long days = ChronoUnit.DAYS.between(
createInstant.atZone(ZoneId.systemDefault()).toLocalDateTime(),
nowInstant.atZone(ZoneId.systemDefault()).toLocalDateTime()
);
subConstructionUserAppVo.setDays(days);
subConstructionUserAppVo.setSex(sysUserVo.getSex());
list.add(subConstructionUserAppVo);
}
return new TableDataInfo<>(list,result.getTotal());
}
}

View File

@ -21,6 +21,8 @@ import org.dromara.contractor.mapper.SubSalaryPeriodMapper;
import org.dromara.contractor.service.ISubSalaryPeriodService;
import org.dromara.contractor.service.ISubUserSalaryDetailService;
import org.dromara.contractor.service.ISubUserSalaryPeriodService;
import org.dromara.project.domain.BusProjectTeam;
import org.dromara.project.service.IBusProjectTeamService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -28,10 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -50,6 +49,9 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
@Resource
private ISubUserSalaryPeriodService userSalaryPeriodService;
@Resource
private IBusProjectTeamService projectTeamService;
/**
* 查询工资结算周期
*
@ -128,6 +130,7 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
.le(SubUserSalaryDetail::getReportDate, endDate)
.list();
BigDecimal totalWage = BigDecimal.ZERO;
int totalPeople = 0;
List<SubUserSalaryPeriod> periodList = new ArrayList<>();
if (CollUtil.isNotEmpty(detailList)) {
Map<Long, List<SubUserSalaryDetail>> userDetailMap = detailList.stream()
@ -147,6 +150,7 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
// 汇总
totalWage = totalWage.add(total);
periodList.add(period);
totalPeople++;
}
}
// 封装新增数据
@ -157,6 +161,7 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
salaryPeriod.setEndDate(endDate);
salaryPeriod.setTotalDays(days);
salaryPeriod.setTotalWage(totalWage);
salaryPeriod.setTotalPeople(totalPeople);
// 新增
boolean save = this.save(salaryPeriod);
if (!save) {
@ -187,6 +192,14 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
return salaryPeriodVo;
}
BeanUtils.copyProperties(salaryPeriod, salaryPeriodVo);
// 获取班组名称
Long teamId = salaryPeriod.getTeamId();
if (teamId != null) {
BusProjectTeam team = projectTeamService.getById(teamId);
if (team != null) {
salaryPeriodVo.setTeamName(team.getTeamName());
}
}
return salaryPeriodVo;
}
@ -238,9 +251,17 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
if (CollUtil.isEmpty(salaryPeriodList)) {
return salaryPeriodVoPage;
}
// 获取班组
Set<Long> teamIdList = salaryPeriodList.stream().map(SubSalaryPeriod::getTeamId).collect(Collectors.toSet());
List<BusProjectTeam> teamList = projectTeamService.listByIds(teamIdList);
Map<Long, BusProjectTeam> teamMap = teamList.stream().collect(Collectors.toMap(BusProjectTeam::getId, team -> team));
List<SubSalaryPeriodVo> salaryPeriodVoList = salaryPeriodList.stream().map(entity -> {
SubSalaryPeriodVo salaryPeriodVo = new SubSalaryPeriodVo();
BeanUtils.copyProperties(entity, salaryPeriodVo);
// 获取班组名称
if (teamMap.containsKey(entity.getTeamId())) {
salaryPeriodVo.setTeamName(teamMap.get(entity.getTeamId()).getTeamName());
}
return salaryPeriodVo;
}).toList();
salaryPeriodVoPage.setRecords(salaryPeriodVoList);

View File

@ -159,7 +159,7 @@ public class DesVolumeCatalogController extends BaseController {
/**
* 收资清单模板导出
*/
@SaCheckPermission("design:collect:exportExcel")
@SaCheckPermission("design:volumeCatalog:exportExcel")
@Log(title = "收资清单", businessType = BusinessType.EXPORT)
@PostMapping("/exportExcel")
public void exportExcelByProjectId(@RequestParam("projectId") Long projectId, HttpServletResponse response){
@ -181,11 +181,14 @@ public class DesVolumeCatalogController extends BaseController {
List<ExcelData> dataList = readExcel(file);
List<DesVolumeCatalogCreateReq> desVolumeCatalogCreateReqs = BeanUtil.copyToList(dataList, DesVolumeCatalogCreateReq.class);
Collections.reverse(desVolumeCatalogCreateReqs);
List<DesVolumeCatalogCreateReq> list = new ArrayList<>();
for (DesVolumeCatalogCreateReq desVolumeCatalogCreateReq : desVolumeCatalogCreateReqs) {
desVolumeCatalogCreateReq.setProjectId(projectId);
desVolumeCatalogCreateReq.setDesignState("2");
desVolumeCatalogService.insertByBo(desVolumeCatalogCreateReq);
list.add(desVolumeCatalogCreateReq);
// desVolumeCatalogService.insertByBo(desVolumeCatalogCreateReq);
}
desVolumeCatalogService.insertBatchByBo(list);
return toAjax(true);
}
@ -235,17 +238,18 @@ public class DesVolumeCatalogController extends BaseController {
// 从第二行(index=1)开始读取数据,跳过表头
for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
Row row = sheet.getRow(rowIndex);
if (row != null) {
if (hasValidData(row)) {
String designSubitem = getCellValue(row.getCell(0));
// String designState = getCellValue(row.getCell(1));
// String specialty = getCellValue(row.getCell(2));
// String principal = getCellValue(row.getCell(3));
String volumeNumber = getCellValue(row.getCell(1));
String documentName = getCellValue(row.getCell(2));
LocalDate plannedCompletion = getLocalDateValue(row.getCell(3));
String specialty = getCellValue(row.getCell(1));
String specialtyId = getCellValue(row.getCell(2));
String principal = getCellValue(row.getCell(3));
String principalId = getCellValue(row.getCell(4));
String volumeNumber = getCellValue(row.getCell(5));
String documentName = getCellValue(row.getCell(6));
LocalDate plannedCompletion = getLocalDateValue(row.getCell(7));
ExcelData excelData = new ExcelData(
designSubitem, volumeNumber, documentName,
designSubitem,specialtyId,principalId, volumeNumber, documentName,
plannedCompletion
);
dataList.add(excelData);
@ -255,6 +259,19 @@ public class DesVolumeCatalogController extends BaseController {
return dataList;
}
private static boolean hasValidData(Row row) {
// 遍历行中的所有单元格
for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {
Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
String cellValue = getCellValue(cell).trim();
// 只要有一个单元格有非空值,就认为是有效行
if (!cellValue.isEmpty()) {
return true;
}
}
return false;
}
private static String getCellValue(Cell cell) {
if (cell == null) {

View File

@ -40,6 +40,11 @@ public class BusBillofquantitiesVersions extends BaseEntity {
*/
private String versions;
/**
* 版本号名称
*/
private String versionsName;
/**
* exlce文件
*/

View File

@ -29,6 +29,11 @@ public class DesVolumeCatalog extends BaseEntity {
@TableId(value = "design")
private Long design;
/**
* 序号
*/
private Long serialNumber;
/**
* 项目ID
*/

View File

@ -39,4 +39,11 @@ public class BusBillofquantitiesVersionsBo extends BaseEntity {
private String versions;
/**
* 版本号名称
*/
private String versionsName;
}

View File

@ -1,5 +1,7 @@
package org.dromara.design.domain.dto;
import lombok.Data;
import java.time.LocalDate;
/**
@ -7,34 +9,37 @@ import java.time.LocalDate;
* @Date 2025/8/12 22:53
* @Version 1.0
*/
@Data
public class ExcelData {
private String designSubitem;
// private String designState;
// private String specialty;
// private String principal;
private String specialty;
// private String specialtyId;
private String principal;
// private Long principalId;
private String volumeNumber;
private String documentName;
private LocalDate plannedCompletion;
// 构造函数
public ExcelData(String designSubitem, String volumeNumber, String documentName, LocalDate plannedCompletion) {
public ExcelData(String designSubitem, String specialty, String principal, String volumeNumber, String documentName, LocalDate plannedCompletion) {
this.designSubitem = designSubitem;
// this.designState = designState;
// this.specialty = specialty;
// this.principal = principal;
this.specialty = specialty;
// this.specialtyId = specialtyId;
this.principal = principal;
// this.principalId = principalId;
this.volumeNumber = volumeNumber;
this.documentName = documentName;
this.plannedCompletion = plannedCompletion;
}
// Getter和Setter方法
public String getDesignSubitem() {
return designSubitem;
}
public void setDesignSubitem(String designSubitem) {
this.designSubitem = designSubitem;
}
// public String getDesignSubitem() {
// return designSubitem;
// }
//
// public void setDesignSubitem(String designSubitem) {
// this.designSubitem = designSubitem;
// }
// public String getDesignState() {
// return designState;
@ -60,27 +65,27 @@ public class ExcelData {
// this.principal = principal;
// }
public String getVolumeNumber() {
return volumeNumber;
}
public void setVolumeNumber(String volumeNumber) {
this.volumeNumber = volumeNumber;
}
public String getDocumentName() {
return documentName;
}
public void setDocumentName(String documentName) {
this.documentName = documentName;
}
public LocalDate getPlannedCompletion() {
return plannedCompletion;
}
public void setPlannedCompletion(LocalDate plannedCompletion) {
this.plannedCompletion = plannedCompletion;
}
// public String getVolumeNumber() {
// return volumeNumber;
// }
//
// public void setVolumeNumber(String volumeNumber) {
// this.volumeNumber = volumeNumber;
// }
//
// public String getDocumentName() {
// return documentName;
// }
//
// public void setDocumentName(String documentName) {
// this.documentName = documentName;
// }
//
// public LocalDate getPlannedCompletion() {
// return plannedCompletion;
// }
//
// public void setPlannedCompletion(LocalDate plannedCompletion) {
// this.plannedCompletion = plannedCompletion;
// }
}

View File

@ -40,4 +40,7 @@ public class DesVolumeCatalogQueryReq implements Serializable {
private String type;
private String isUpload;
}

View File

@ -48,6 +48,13 @@ public class BusBillofquantitiesVersionsVo implements Serializable {
private String versions;
/**
* 版本号名称
*/
private String versionsName;
/**
* Excel文件
*/

View File

@ -34,6 +34,11 @@ public class DesVolumeCatalogVo implements Serializable {
*/
private Long design;
/**
* 序号
*/
private Long serialNumber;
/**
* 项目ID
*/
@ -124,4 +129,9 @@ public class DesVolumeCatalogVo implements Serializable {
*/
private String opinion;
/**
* 文件数量
*/
private Long fileCount;
}

View File

@ -8,6 +8,8 @@ import org.dromara.design.domain.DesVolumeFile;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
@ -80,4 +82,7 @@ public class DesVolumeFileCodeVo implements Serializable {
* 是否最新
*/
private Boolean isLatest;
private Date createTime;
}

View File

@ -1,5 +1,6 @@
package org.dromara.design.service;
import jakarta.validation.constraints.NotNull;
import org.dromara.design.domain.dto.desUser.DesUserBatchDto;
import org.dromara.design.domain.vo.DesUserVo;
import org.dromara.design.domain.bo.DesUserBo;
@ -8,10 +9,10 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 设计人员Service接口
@ -84,4 +85,15 @@ public interface IDesUserService extends IService<DesUser>{
* 查询用户对应专业
*/
List<String> selectUserMajors(Long userId);
/**
* 查询专业和专业名
* @param desUserBo
* @return
*/
Map<String, String> getUserMajor(DesUserBo desUserBo);
Map<String, String> getUserList(DesUserBo desUserBo);
Long getCount(String principal, String specialty, Long projectId);
}

View File

@ -122,4 +122,6 @@ public interface IDesVolumeCatalogService extends IService<DesVolumeCatalog> {
List<DesVolumeCatalogVo> catalogList(Long projectId);
void exportExcelByProjectId(Long projectId, HttpServletResponse response);
void insertBatchByBo(List<DesVolumeCatalogCreateReq> list);
}

View File

@ -191,8 +191,22 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl<BusBillo
throw new ServiceException("上传文件失败");
}
String banBen = BatchNumberGenerator.generateBatchNumber("GCLBB-");
String[] split = StringUtils.split(wordEntity.getFileName(),".xlsx");
String vName = "";
switch (bo.getWorkOrderType()){
case "0":
vName = "投标工程量清单-"+split[0];
case "1":
vName = "限价工程量清单-"+split[0];
case "2":
vName = "招采工程量清单-"+split[0];
case "3":
vName = "物资设备清单-"+split[0];
}
int insert = baseMapper.insert(new BusBillofquantitiesVersions().
setWorkOrderType(bo.getWorkOrderType()).
setVersionsName(vName).
setVersions(banBen).
setProjectId(bo.getProjectId()).
setExcelFile(wordEntity.getUrl()));

View File

@ -48,6 +48,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.FileNameMap;
import java.net.URLConnection;
@ -446,6 +447,11 @@ public class DesDrawingServiceImpl extends ServiceImpl<DesDrawingMapper, DesDraw
byte[] bytes = PdfBoxQrCodeGenerator.generateQRCodeBytes(params);
try {
ByteArrayOutputStream baos = PdfBoxQrCodeGenerator.addQRCodeToPDFOnAllPages(ossVo.getUrl(), bytes,isChangeFile);
try (FileOutputStream fileOut = new FileOutputStream("C:\\Users\\YuanJie\\Desktop\\test1.pdf")) {
baos.writeTo(fileOut);
}
FileNameMap fileNameMap = URLConnection.getFileNameMap();
String originalName = ossVo.getOriginalName();
String contentType = fileNameMap.getContentTypeFor(originalName);

View File

@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.design.domain.dto.desUser.DesUserBatchDto;
import org.dromara.system.domain.vo.SysDictDataVo;
import org.dromara.system.service.ISysDictDataService;
import org.springframework.stereotype.Service;
import org.dromara.design.domain.bo.DesUserBo;
import org.dromara.design.domain.vo.DesUserVo;
@ -17,9 +19,8 @@ import org.dromara.design.domain.DesUser;
import org.dromara.design.mapper.DesUserMapper;
import org.dromara.design.service.IDesUserService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.*;
import java.util.stream.Collectors;
/**
* 设计人员Service业务层处理
@ -33,6 +34,8 @@ public class DesUserServiceImpl extends ServiceImpl<DesUserMapper, DesUser> impl
private final DesUserMapper baseMapper;
private final ISysDictDataService sysDictDataService;
/**
* 查询设计人员
*
@ -146,4 +149,41 @@ public class DesUserServiceImpl extends ServiceImpl<DesUserMapper, DesUser> impl
public List<String> selectUserMajors(Long userId){
return baseMapper.selectUserMajors(userId);
}
@Override
public Map<String, String> getUserMajor(DesUserBo desUserBo) {
List<DesUserVo> desUserVos = baseMapper.selectVoList(new LambdaQueryWrapper<DesUser>()
.eq(DesUser::getProjectId, desUserBo.getProjectId())
.groupBy(DesUser::getUserMajor));
List<SysDictDataVo> list = sysDictDataService.selectByDictType("des_user_major");
Map<String, String> dictMap = list.stream().filter(Objects::nonNull).collect(Collectors
.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel, (existing, existing1) -> existing));
Map<String, String> map = new HashMap<>();
for (DesUserVo desUserVo : desUserVos) {
if (desUserVo !=null){
map.put(desUserVo.getUserMajor(), dictMap.get(desUserVo.getUserMajor()));
}
}
return map;
}
@Override
public Map<String, String> getUserList(DesUserBo desUserBo) {
List<DesUserVo> desUserVos = baseMapper.selectVoList(new LambdaQueryWrapper<DesUser>()
.eq(DesUser::getProjectId, desUserBo.getProjectId())
.groupBy(DesUser::getUserId));
Map<String, String> map = new HashMap<>();
for (DesUserVo desUserVo : desUserVos) {
map.put(desUserVo.getUserId().toString(), desUserVo.getUserName());
}
return map;
}
@Override
public Long getCount(String principal, String specialty, Long projectId) {
return baseMapper.selectCount(new LambdaQueryWrapper<DesUser>()
.eq(DesUser::getProjectId, projectId)
.eq(DesUser::getUserId, Long.valueOf(principal))
.eq(DesUser::getUserMajor, specialty));
}
}

View File

@ -11,9 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.dromara.cailiaoshebei.domain.BusCailiaoshebeiPici;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.domain.event.ProcessDeleteEvent;
import org.dromara.common.core.domain.event.ProcessEvent;
import org.dromara.common.core.domain.event.ProcessTaskEvent;
@ -23,18 +21,17 @@ import org.dromara.common.core.utils.ObjectUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.design.domain.*;
import org.dromara.design.domain.bo.DesUserBo;
import org.dromara.design.domain.dto.volumecatalog.DesVolumeCatalogCreateReq;
import org.dromara.design.domain.dto.volumecatalog.DesVolumeCatalogQueryReq;
import org.dromara.design.domain.dto.volumecatalog.DesVolumeCatalogUpdateReq;
import org.dromara.design.domain.vo.DesUserVo;
import org.dromara.design.domain.vo.volumecatalog.DesVolumeCatalogVo;
import org.dromara.design.mapper.DesVolumeCatalogMapper;
import org.dromara.design.service.*;
import org.dromara.project.service.IBusProjectService;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.service.ISysUserService;
import org.springframework.beans.BeanUtils;
@ -92,12 +89,12 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
* @return 卷册目录
*/
@Override
public DesVolumeCatalogVo queryById(Long id,String type) {
public DesVolumeCatalogVo queryById(Long id, String type) {
DesVolumeCatalog volumeCatalog = this.getById(id);
if (volumeCatalog == null) {
throw new ServiceException("卷册目录信息不存在", HttpStatus.NOT_FOUND);
}
return this.getVo(volumeCatalog,type);
return this.getVo(volumeCatalog, type);
}
/**
@ -121,7 +118,7 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
*/
@Override
public List<DesVolumeCatalogVo> queryList(DesVolumeCatalogQueryReq req) {
return this.list(this.buildQueryWrapper(req)).stream().map(vo-> this.getVo(vo,req.getType())).toList();
return this.list(this.buildQueryWrapper(req)).stream().map(vo -> this.getVo(vo, req.getType())).toList();
}
/**
@ -131,10 +128,10 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
* @return 卷册目录文件列表
*/
@Override
public List<DesVolumeFile> queryFileListById(Long id,String type) {
public List<DesVolumeFile> queryFileListById(Long id, String type) {
return volumeFileService.lambdaQuery()
.eq(DesVolumeFile::getVolumeCatalogId, id)
.eq(StringUtils.isNotBlank(type),DesVolumeFile::getType, type)
.eq(StringUtils.isNotBlank(type), DesVolumeFile::getType, type)
.orderByAsc(DesVolumeFile::getStatus)
.orderByDesc(DesVolumeFile::getCreateDept)
.list();
@ -148,6 +145,11 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
*/
@Override
public Boolean insertByBo(DesVolumeCatalogCreateReq req) {
Object object = RedisUtils.getCacheObject("DesVolumeCatalog:serialNumber");
long serialNumber = 0L;
if (ObjectUtils.isNotEmpty(object)) {
serialNumber = ((Integer) object).longValue();
}
Long projectId = req.getProjectId();
if (projectService.getById(projectId) == null) {
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
@ -163,15 +165,61 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
if (count > 0) {
throw new ServiceException("卷册目录已存在", HttpStatus.BAD_REQUEST);
}
long count1 = desUserService.count(new LambdaQueryWrapper<DesUser>()
.eq(DesUser::getUserMajor, req.getSpecialty())
.eq(DesUser::getUserId, req.getPrincipal()));
if (count1 == 0) {
throw new ServiceException("所选专业不包含该人员");
}
DesVolumeCatalog volumeCatalog = new DesVolumeCatalog();
BeanUtils.copyProperties(req, volumeCatalog);
volumeCatalog.setSerialNumber(serialNumber);
boolean save = this.save(volumeCatalog);
if (!save) {
RedisUtils.setCacheObject("DesVolumeCatalog:serialNumber", serialNumber);
throw new ServiceException("卷册目录新增失败", HttpStatus.ERROR);
}
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void insertBatchByBo(List<DesVolumeCatalogCreateReq> list) {
Object object = RedisUtils.getCacheObject("DesVolumeCatalog:serialNumber");
long serialNumber = 0L;
if (ObjectUtils.isNotEmpty(object)) {
serialNumber = ((Integer) object).longValue();
}
List<DesVolumeCatalog> desVolumeCatalogs = new ArrayList<>();
for (DesVolumeCatalogCreateReq req : list) {
Long projectId = req.getProjectId();
if (projectService.getById(projectId) == null) {
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
}
// 判断是否重名
Long count = this.lambdaQuery()
.eq(DesVolumeCatalog::getProjectId, projectId)
.and(lqw -> lqw
.eq(DesVolumeCatalog::getVolumeNumber, req.getVolumeNumber())
.or()
.eq(DesVolumeCatalog::getDocumentName, req.getDocumentName()))
.count();
if (count > 0) {
throw new ServiceException("卷册目录已存在", HttpStatus.BAD_REQUEST);
}
Long count1 = desUserService.getCount(req.getPrincipal(), req.getSpecialty(), req.getProjectId());
if (count1 == 0) {
throw new ServiceException("所选专业不包含该人员");
}
DesVolumeCatalog volumeCatalog = new DesVolumeCatalog();
BeanUtils.copyProperties(req, volumeCatalog);
volumeCatalog.setSerialNumber(serialNumber++);
desVolumeCatalogs.add(volumeCatalog);
}
baseMapper.insertBatch(desVolumeCatalogs);
RedisUtils.setCacheObject("DesVolumeCatalog:serialNumber", serialNumber);
}
/**
* 修改卷册目录
*
@ -240,14 +288,14 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
* @return 卷册目录封装对象
*/
@Override
public DesVolumeCatalogVo getVo(DesVolumeCatalog volumeCatalog,String type) {
public DesVolumeCatalogVo getVo(DesVolumeCatalog volumeCatalog, String type) {
DesVolumeCatalogVo vo = new DesVolumeCatalogVo();
if (volumeCatalog == null) {
return vo;
}
BeanUtils.copyProperties(volumeCatalog, vo);
// 关联文件信息
List<DesVolumeFile> volumeFiles = this.queryFileListById(volumeCatalog.getDesign(),type);
List<DesVolumeFile> volumeFiles = this.queryFileListById(volumeCatalog.getDesign(), type);
vo.setFileVoList(volumeFileService.getVoList(volumeFiles));
// 关联查阅人信息
List<DesVolumeFileViewer> allViewerList = volumeFileViewerService.lambdaQuery()
@ -286,12 +334,17 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
String volumeNumber = req.getVolumeNumber();
String documentName = req.getDocumentName();
String auditStatus = req.getAuditStatus();
lqw.orderByDesc(DesVolumeCatalog::getCreateTime);
lqw.orderByAsc(DesVolumeCatalog::getVolumeNumber);
String isUpload = req.getIsUpload();
// lqw.orderByDesc(DesVolumeCatalog::getCreateTime);
lqw.orderByAsc(DesVolumeCatalog::getSerialNumber);
lqw.like(StringUtils.isNotBlank(documentName), DesVolumeCatalog::getDocumentName, documentName);
lqw.eq(StringUtils.isNotBlank(volumeNumber), DesVolumeCatalog::getVolumeNumber, volumeNumber);
lqw.eq(ObjectUtils.isNotEmpty(projectId), DesVolumeCatalog::getProjectId, projectId);
lqw.eq(StringUtils.isNotBlank(auditStatus),DesVolumeCatalog::getAuditStatus, auditStatus);
lqw.eq(StringUtils.isNotBlank(auditStatus), DesVolumeCatalog::getAuditStatus, auditStatus);
lqw.exists("1".equals(isUpload),"SELECT 1 FROM des_volume_file WHERE volume_catalog_id = des_volume_catalog.design");
lqw.notExists("0".equals(isUpload),"SELECT 1 FROM des_volume_file WHERE volume_catalog_id = des_volume_catalog.design");
return lqw;
}
@ -311,7 +364,21 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
if (CollUtil.isEmpty(volumeCatalogList)) {
return volumeCatalogVoPage;
}
List<DesVolumeCatalogVo> volumeCatalogVoList = volumeCatalogList.stream().map(vo-> getVo(vo,null)).toList();
List<DesVolumeCatalogVo> volumeCatalogVoList = volumeCatalogList.stream().map(vo -> getVo(vo, null)).toList();
// 查询文件数量
LambdaQueryWrapper<DesVolumeFile> fileQueryWrapper = new LambdaQueryWrapper<>();
for (DesVolumeCatalogVo desVolumeCatalogVo : volumeCatalogVoList) {
fileQueryWrapper.clear();
fileQueryWrapper.eq(DesVolumeFile::getVolumeCatalogId, desVolumeCatalogVo.getDesign());
List<DesVolumeFile> list = volumeFileService.list(fileQueryWrapper);
if (list != null && !list.isEmpty()) {
desVolumeCatalogVo.setFileCount((long) list.size());
} else {
desVolumeCatalogVo.setFileCount(0L);
}
}
return volumeCatalogVoPage.setRecords(volumeCatalogVoList);
}
@ -352,12 +419,12 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
.orderByDesc(DesVolumeFile::getCreateTime)
);
if(list.isEmpty()){
if (list.isEmpty()) {
return Collections.emptyList();
}
List<Long> list1 = list.stream().map(DesVolumeFile::getVolumeCatalogId).distinct().toList();
return baseMapper.selectVoList(Wrappers.lambdaQuery(DesVolumeCatalog.class)
return baseMapper.selectVoList(Wrappers.lambdaQuery(DesVolumeCatalog.class)
.eq(DesVolumeCatalog::getProjectId, projectId)
.in(DesVolumeCatalog::getDesign, list1)
.orderByDesc(DesVolumeCatalog::getCreateTime)
@ -368,78 +435,127 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
public void exportExcelByProjectId(Long projectId, HttpServletResponse response) {
DesUserBo desUserBo = new DesUserBo();
desUserBo.setProjectId(projectId);
Map<String, List<String>> majorToNames = new HashMap<>();
List<DesUserVo> desUserVos = desUserService.queryList(desUserBo);
List<DesUserVo> uniqueMajors = new ArrayList<>(desUserVos.stream()
.collect(Collectors.toMap(
DesUserVo::getUserMajor,
user -> user,
(existing, replacement) -> existing
))
.values());
uniqueMajors.forEach(desUserVo -> {
desUserBo.setUserMajor(desUserVo.getUserMajor());
List<DesUserVo> desUserVos1 = desUserService.queryList(desUserBo);
List<String> names = desUserVos1.stream()
.map(DesUserVo::getUserName)
.collect(Collectors.toList());
majorToNames.put(desUserVo.getUserMajorName(), names);
});
//TODO 数据绑定下拉
// String[] namesArray = names.toArray(String[]::new);
Map<String, String> uniqueMajors = desUserService.getUserMajor(desUserBo);
Map<String, String> userList = desUserService.getUserList(desUserBo);
// 2. 设置响应头
// 设置响应头指定Excel格式和下载文件名
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode("收资清单模板.xlsx", StandardCharsets.UTF_8));
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("卷册目录模板.xlsx", StandardCharsets.UTF_8));
Workbook workbook = new XSSFWorkbook();
// 创建主 Sheet 和隐藏 Sheet
Sheet mainSheet = workbook.createSheet("收资清单模板");
Sheet dropdownSheet = workbook.createSheet("DropdownData");
workbook.setSheetHidden(workbook.getSheetIndex(dropdownSheet), true);
Sheet mainSheet = workbook.createSheet("卷册目录模板");
Sheet dataSheet = workbook.createSheet("DropdownData");
workbook.setSheetHidden(workbook.getSheetIndex(dataSheet), true);
// 3. 创建单元格样式
//设置下拉列表数据
// for (int i = 0; i < namesArray.length; i++) {
// dropdownSheet.createRow(i).createCell(1).setCellValue(namesArray[i]); // 存到B列
// }
// int rowIdx = 0;
// for (Map.Entry<Long, String> entry : userIdToNameMapByDept.entrySet()) {
// Row row = dropdownSheet.createRow(rowIdx++);
// row.createCell(0).setCellValue(entry.getKey().toString());
// row.createCell(1).setCellValue(entry.getValue());
// }
CellStyle editableStyle = createEditableCellStyle(workbook); // 可编辑单元格样式
CellStyle protectedStyle = createProtectedCellStyle(workbook); // 受保护单元格样式ID列用
//填充隐藏数据Sheet
int rowIndex = 0;
// 填充专业和专业IDA列和B列
for (Map.Entry<String, String> entry : uniqueMajors.entrySet()) {
Row row = dataSheet.createRow(rowIndex++);
row.createCell(0).setCellValue(entry.getValue()); // A列专业ID
row.createCell(1).setCellValue(entry.getKey()); // B列专业名称
}
// 重置行索引填充人员和人员IDC列和D列
rowIndex = 0;
for (Map.Entry<String, String> entry : userList.entrySet()) {
Row row = dataSheet.getRow(rowIndex);
if (row == null) {
row = dataSheet.createRow(rowIndex);
}
row.createCell(2).setCellValue(entry.getValue()); // C列人员ID
row.createCell(3).setCellValue(entry.getKey()); // D列人员名称
rowIndex++;
}
// 主 Sheet 设置表头
Row sheetRow = mainSheet.createRow(0);
sheetRow.createCell(0).setCellValue("子项名称");
sheetRow.createCell(1).setCellValue("卷册号");
sheetRow.createCell(2).setCellValue("资料名称");
sheetRow.createCell(3).setCellValue("计划出图时间");
sheetRow.createCell(4).setCellValue("专业");
sheetRow.createCell(5).setCellValue("人员");
String[] headers = {"子项名称", "专业", "专业编码",
"人员", "人员编码", "卷册号", "资料名称", "计划出图时间"};
for (int i = 0; i < headers.length; i++) {
Cell cell = sheetRow.createCell(i);
cell.setCellValue(headers[i]);
}
// 6. 设置专业下拉列表(第二列)
setMajorDropdown(mainSheet, uniqueMajors.size());
// 8. 设置人员下拉列表(第四列)
setPersonDropdown(mainSheet, userList.size());
String formulaTemplate = "IFERROR(INDEX(DropdownData!$B$1:$B$" + uniqueMajors.size() + ", MATCH(B{rowNum}, DropdownData!$A$1:$A$" + uniqueMajors.size() + ", 0)),\"\")";
String formulaTemplate1 = "IFERROR(INDEX(DropdownData!$D$1:$D$" + userList.size() + ", MATCH(D{rowNum}, DropdownData!$C$1:$C$" + userList.size() + ", 0)),\"\")";
for (int i = 1; i <= 100; i++) { // 从第2行到101行
Row row = mainSheet.createRow(i);
int currentRowNum = i + 1; // Excel行号从1开始
String formula = formulaTemplate.replace("{rowNum}", String.valueOf(currentRowNum));
Cell cell = row.createCell(1);
cell.setCellStyle(editableStyle); //专业不锁定
Cell idCell = row.createCell(2);
idCell.setCellFormula(formula);
idCell.setCellStyle(protectedStyle); // 应用隐藏公式样式
String formula1 = formulaTemplate1.replace("{rowNum}", String.valueOf(currentRowNum));
Cell cell2 = row.createCell(3);
cell2.setCellStyle(editableStyle);
Cell idCell2 = row.createCell(4);
idCell2.setCellFormula(formula1);
idCell2.setCellStyle(protectedStyle);
}
for (int i = 1; i <= 100; i++) {
Row row = mainSheet.getRow(i);
if (row == null) {
row = mainSheet.createRow(i);
}
Cell cell = row.createCell(0);
cell.setCellStyle(editableStyle);
Cell cell1 = row.createCell(5);
cell1.setCellStyle(editableStyle);
Cell cell2 = row.createCell(6);
cell2.setCellStyle(editableStyle);
Cell cell3 = row.createCell(7);
cell3.setCellStyle(editableStyle);
}
// 保护工作表,仅允许编辑未锁定的单元格
mainSheet.protectSheet("123456"); // 空密码
// 核心锁定表头第1行和前1列包含ID列
mainSheet.createFreezePane(0, 1, 0, 0);
mainSheet.createFreezePane(0, 1, 0, 1);
// 绑定下拉列表(关联隐藏 Sheet
DataValidationHelper helper = mainSheet.getDataValidationHelper(); //为主Sheet第二列设置下拉列表关联隐藏Sheet的B列
// String range = "DropdownData!$B$1:$B$" + namesArray.length; //引用隐藏Sheet的B列数据范围DropdownData!$B$1:$B$
// DataValidationConstraint constraint = helper.createFormulaListConstraint(range); //创建下拉约束
CellRangeAddressList addressList = new CellRangeAddressList(1, 300, 1, 1); // 支持100行数据
//添加验证规则
// DataValidation validation = helper.createValidation(constraint, addressList);
// validation.setShowErrorBox(true);
// mainSheet.addValidationData(validation);
// 调整列宽
mainSheet.setColumnWidth(0, 20 * 256);
mainSheet.setColumnWidth(1, 20 * 100);
mainSheet.setColumnWidth(1, 20 * 200);
mainSheet.setColumnWidth(2, 20 * 200);
mainSheet.setColumnWidth(3, 20 * 200);
mainSheet.setColumnWidth(4, 20 * 200);
mainSheet.setColumnWidth(5, 20 * 200);
mainSheet.setColumnWidth(6, 20 * 200);
mainSheet.setColumnWidth(7, 20 * 200);
// 直接写入响应输出流
try {
@ -451,6 +567,69 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
}
/**
* 创建可编辑单元格样式
*/
private CellStyle createEditableCellStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
style.setLocked(false); // 关键:允许编辑
return style;
}
/**
* 创建受保护单元格样式用于ID列
*/
private CellStyle createProtectedCellStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
DataFormat dataFormat = workbook.createDataFormat();
short formatIndex = dataFormat.getFormat("0"); // 匹配“自定义→0”格式
style.setDataFormat(formatIndex);
style.setHidden(true); // 隐藏公式
style.setLocked(true);
return style;
}
/**
* 设置专业下拉列表第二列索引1
*/
private void setMajorDropdown(Sheet mainSheet, int majorCount) {
DataValidationHelper helper = mainSheet.getDataValidationHelper();
// 专业数据范围数据Sheet的A列从第1行到专业数量行
String majorRange = "DropdownData!$A$1:$A$" + majorCount;
DataValidationConstraint constraint = helper.createFormulaListConstraint(majorRange);
// 作用范围第2行到100行第二列
CellRangeAddressList addressList = new CellRangeAddressList(1, 100, 1, 1);
DataValidation validation = helper.createValidation(constraint, addressList);
validation.setShowErrorBox(true);
mainSheet.addValidationData(validation);
}
/**
* 设置人员下拉列表第四列索引3
*/
private void setPersonDropdown(Sheet mainSheet, int personCount) {
DataValidationHelper helper = mainSheet.getDataValidationHelper();
// 人员数据范围数据Sheet的C列从第1行到人员数量行
String personRange = "DropdownData!$C$1:$C$" + personCount;
DataValidationConstraint constraint = helper.createFormulaListConstraint(personRange);
// 作用范围第2行到100行第四列
CellRangeAddressList addressList = new CellRangeAddressList(1, 100, 3, 3);
DataValidation validation = helper.createValidation(constraint, addressList);
validation.setShowErrorBox(true);
mainSheet.addValidationData(validation);
}
/**
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
* 正常使用只需#processEvent.flowCode=='leave1'
@ -469,11 +648,11 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
}
desVolumeCatalog.setAuditStatus(processEvent.getStatus());
//如果完成,变更状态为已完成
if (processEvent.getStatus().equals("finish")){
if (processEvent.getStatus().equals("finish")) {
desVolumeCatalog.setDesignState("1");
}
if(BusinessStatusEnum.FINISH.getStatus().equals(processEvent.getStatus())){
if (BusinessStatusEnum.FINISH.getStatus().equals(processEvent.getStatus())) {
ArrayList<DesDrawing> desDrawings = new ArrayList<>();
List<DesVolumeFile> list = volumeFileService.lambdaQuery().eq(DesVolumeFile::getVolumeCatalogId, id).list();
@ -486,7 +665,7 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
desDrawings.add(desDrawing);
//异步处理二维码
self.addQRCodeToPDF(desVolumeFile.getId(),false)
self.addQRCodeToPDF(desVolumeFile.getId(), false)
.thenAccept(result -> log.info("图纸[{}-{} ]添加二维码成功", desVolumeFile.getFileName(), desVolumeFile.getId()))
.exceptionally(ex -> {
log.error("图纸[{}-{}]添加二维码失败", desVolumeFile.getFileName(), desVolumeFile.getId(), ex);

View File

@ -94,7 +94,9 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
Page<DesVolumeFileVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
for (DesVolumeFileVo vo : result.getRecords()) {
SysOssVo ossVo = ossService.getById(vo.getFileId());
vo.setFileUrl(ossVo.getUrl());
if (ossVo != null) {
vo.setFileUrl(ossVo.getUrl());
}
}
return TableDataInfo.build(result);
}
@ -117,7 +119,9 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
Page<DesVolumeFileJoinVo> page = baseMapper.queryJoinPageList(pageQuery.build(), bo);
for (DesVolumeFileJoinVo vo : page.getRecords()) {
SysOssVo ossVo = ossService.getById(vo.getFileId());
vo.setFileUrl(ossVo.getUrl());
if (ossVo != null) {
vo.setFileUrl(ossVo.getUrl());
}
}
return TableDataInfo.build(page);
}
@ -267,18 +271,18 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
}
}
// 过程文件
if (CollectionUtil.isNotEmpty(req.getCancellationIds())) {
List<DesVolumeFile> existingFiles = baseMapper.selectList(new LambdaQueryWrapper<DesVolumeFile>()
.eq(DesVolumeFile::getVolumeCatalogId, req.getVolumeCatalogId())
.eq(DesVolumeFile::getType, DesVolumeFile.PROCESS)
.orderByDesc(DesVolumeFile::getVersion));
if (!existingFiles.isEmpty()) {
DesVolumeFile first = existingFiles.getFirst();
if (!BusinessStatusEnum.FINISH.getStatus().equals(first.getAuditStatus())) {
throw new ServiceException("文件尚未审核完成,请勿重复上传");
}
}
}
// if (CollectionUtil.isNotEmpty(req.getCancellationIds())) {
// List<DesVolumeFile> existingFiles = baseMapper.selectList(new LambdaQueryWrapper<DesVolumeFile>()
// .eq(DesVolumeFile::getVolumeCatalogId, req.getVolumeCatalogId())
// .eq(DesVolumeFile::getType, DesVolumeFile.PROCESS)
// .orderByDesc(DesVolumeFile::getVersion));
// if (!existingFiles.isEmpty()) {
// DesVolumeFile first = existingFiles.getFirst();
// if (!BusinessStatusEnum.FINISH.getStatus().equals(first.getAuditStatus())) {
// throw new ServiceException("文件尚未审核完成,请勿重复上传");
// }
// }
// }
}
@ -482,6 +486,7 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
return;
}
desVolumeFile.setAuditStatus(processEvent.getStatus());
this.updateById(desVolumeFile);
//如果完成,以前的图纸类型变为作废图纸,状态改为作废 暂定
if (processEvent.getStatus().equals("finish")) {
// this.lambdaUpdate().set(DesVolumeFile::getStatus, "2")
@ -498,8 +503,7 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
return null;
});
}
desVolumeFile.setFileId(null);
this.updateById(desVolumeFile);
}
/**
@ -547,6 +551,7 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
return;
}
desVolumeFile.setAuditStatus(processEvent.getStatus());
this.updateById(desVolumeFile);
if (processEvent.getStatus().equals("finish")) {
//修改目录状态
volumeCatalogService.update(Wrappers.<DesVolumeCatalog>lambdaUpdate()
@ -561,8 +566,7 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
return null;
});
}
desVolumeFile.setFileId(null);
this.updateById(desVolumeFile);
}
/**

View File

@ -13,6 +13,7 @@ import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.utils.JSTUtil;
import org.dromara.facility.constant.FacRedisKeyConstant;
import org.dromara.facility.domain.*;
import org.dromara.facility.domain.dto.geojson.*;
@ -27,7 +28,6 @@ import org.dromara.facility.service.*;
import org.dromara.progress.service.IPgsProgressCategoryService;
import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusProjectService;
import org.dromara.common.utils.JSTUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
@ -659,7 +659,7 @@ public class FacMatrixServiceImpl extends ServiceImpl<FacMatrixMapper, FacMatrix
FacPhotovoltaicPanel::getStatus
)
.eq(FacPhotovoltaicPanel::getProjectId, projectId)
.eq(FacPhotovoltaicPanel::getProgressCategoryName, "光伏板")
.eq(FacPhotovoltaicPanel::getProgressCategoryName, "组件安装")
.in(CollUtil.isNotEmpty(matrixIdList), FacPhotovoltaicPanel::getMatrixId, matrixIdList)
.list();
List<FacFacilityPositionGisVo> panelVoList = panelList.stream().map(obj ->

View File

@ -277,7 +277,7 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
String name = nameProperties.getText();
// ① 获取名称
if (StringUtils.isBlank(name)) return Collections.emptyList();
if (!name.startsWith("G")) return Collections.emptyList();
// if (!name.startsWith("G")) return Collections.emptyList();
List<FacPhotovoltaicPanel> panelList = new ArrayList<>();
// ② 找到该点对应的 polygon优先包含否则最近
FacFeatureByPlane matchedPolygon = JSTUtil.findNearestOrContainingPolygon(nameFeature, locationFeatures);

View File

@ -114,6 +114,11 @@ public class BusFormalitiesAreConsolidatedVo implements Serializable {
*/
private Date createPTime;
/**
* 文件数量
*/
private Long fileCount;
private List<BusFormalitiesAreConsolidatedVo> children = new ArrayList<>();

View File

@ -90,6 +90,18 @@ public class BusFormalitiesAreConsolidatedServiceImpl extends ServiceImpl<BusFor
@Override
public List<BusFormalitiesAreConsolidatedVo> getTree(BusFormalitiesAreConsolidatedBo bo) {
List<BusFormalitiesAreConsolidatedVo> voList = queryList(bo);
//寻找对应文件数量
LambdaQueryWrapper<BusFormalitiesAnnex> lqw = new LambdaQueryWrapper<>();
for (BusFormalitiesAreConsolidatedVo busFormalitiesAreConsolidatedVo : voList) {
lqw.clear();
lqw.eq(BusFormalitiesAnnex::getFormalitiesId, busFormalitiesAreConsolidatedVo.getId());
List<BusFormalitiesAnnex> list = busFormalitiesAnnexService.list(lqw);
if (list != null && !list.isEmpty()){
busFormalitiesAreConsolidatedVo.setFileCount((long) list.size());
}else {
busFormalitiesAreConsolidatedVo.setFileCount(0L);
}
}
return TreeUtil.buildTree1(voList);
}

View File

@ -1,6 +1,7 @@
package org.dromara.gps.controller;
import java.util.List;
import java.util.Map;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -10,14 +11,16 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.domain.dto.constructionuser.SubConstructionUserQueryReq;
import org.dromara.contractor.domain.exportvo.BusConstructionUserExportVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserVo;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.gps.domain.vo.ConstructionUser;
import org.dromara.gps.domain.vo.GpsUserVo;
import org.dromara.gps.domain.vo.*;
import org.dromara.project.service.IBusProjectService;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.vo.SysUserVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
@ -29,7 +32,6 @@ import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.gps.domain.vo.GpsEquipmentVo;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.gps.service.IGpsEquipmentService;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -55,6 +57,19 @@ public class GpsEquipmentController extends BaseController {
private final IBusProjectService projectService;
/**
* 接收设备数据
* @param jsonData
* @return
*/
@PostMapping("/setData")
public R<Void> setData(@RequestBody String jsonData) {
log.info("接收设备数据:{}", jsonData);
gpsEquipmentService.setData(jsonData);
return toAjax(true);
}
/**
* 接收设备数据
* @param jsonData
@ -134,6 +149,11 @@ public class GpsEquipmentController extends BaseController {
/**
* 项目列表
*/
@SaCheckPermission("gps:equipment:getProjectList")
@GetMapping("/getProjectList")
public R<List<GpsProjectVo>> getProjectList() {
return R.ok(gpsEquipmentService.getProjectList());
}
@ -145,6 +165,9 @@ public class GpsEquipmentController extends BaseController {
@RepeatSubmit()
@PostMapping("/bindManmachine")
public R<Void> bindManmachine(@RequestBody GpsEquipmentBo bo) {
if (bo.getClientId() == null) {
throw new ServiceException("设备id不能为空");
}
return toAjax(gpsEquipmentService.bindManmachine(bo));
}
@ -152,7 +175,7 @@ public class GpsEquipmentController extends BaseController {
/**
* 查询施工人员列表
*/
@SaCheckPermission("gps:equipment:bindManmachine")
@SaCheckPermission("gps:equipment:userList")
@GetMapping("/userList")
public R<List<ConstructionUser>> list(SubConstructionUserQueryReq req) {
List<SubConstructionUser> list = constructionUserService.list(Wrappers.<SubConstructionUser>lambdaQuery()
@ -170,6 +193,9 @@ public class GpsEquipmentController extends BaseController {
@RepeatSubmit()
@PostMapping("/unbindManmachine")
public R<Void> unbindManmachine(@RequestBody GpsEquipmentBo bo) {
if (bo.getClientId() == null) {
throw new ServiceException("设备id不能为空");
}
return toAjax(gpsEquipmentService.unbindManmachine(bo));
}

View File

@ -45,6 +45,15 @@ public class GpsEquipmentSonController extends BaseController {
return gpsEquipmentSonService.queryPageList(bo, pageQuery);
}
/**
* 查询GPS设备定位信息列表
*/
@SaCheckPermission("gps:equipmentSon:getList")
@GetMapping("/getList")
public R<List<GpsEquipmentSonVo>> getList(GpsEquipmentSonBo bo) {
return R.ok(gpsEquipmentSonService.queryList(bo));
}
/**
* 导出GPS设备定位信息列表
*/

View File

@ -9,6 +9,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.List;
/**
* GPS设备详细业务对象 gps_equipment
*
@ -76,5 +78,8 @@ public class GpsEquipmentBo extends BaseEntity {
*/
private String remark;
private Integer type;
private List<String> idList;
}

View File

@ -47,6 +47,8 @@ public class GpsEquipmentSonVo implements Serializable {
@ExcelProperty(value = "设备标识")
private String clientId;
private Long projectId;
/**
* 设备名称
*/

View File

@ -40,12 +40,16 @@ public class GpsEquipmentVo implements Serializable {
@ExcelProperty(value = "项目ID")
private Long projectId;
private String projectName;
/**
* 用户id
*/
@ExcelProperty(value = "用户id")
private Long userId;
private String userName;
/**
* 设备标识
*/
@ -96,4 +100,7 @@ public class GpsEquipmentVo implements Serializable {
private String remark;
private Integer type;
}

View File

@ -0,0 +1,30 @@
package org.dromara.gps.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* GPS人机关联视图对象 gps_manmachine
*
* @author Lion Li
* @date 2025-08-28
*/
@Data
public class GpsProjectVo implements Serializable {
/**
*
*/
// @ExcelProperty(value = "")
private Long projectId;
/**
* 用户名
*/
private String projectName;
}

View File

@ -39,6 +39,17 @@ public class GpsUserVo implements Serializable {
* 用户名
*/
private String userName;
/**
*
*/
// @ExcelProperty(value = "")
private Long projectId;
/**
* 用户名
*/
private String projectName;
private String clientId;
}

View File

@ -21,12 +21,15 @@ public interface GpsEquipmentMapper extends BaseMapperPlus<GpsEquipment, GpsEqui
@Select("SELECT\n" +
" gm.user_id AS userId,\n" +
" su.user_name AS userName \n" +
" su.user_name AS userName, \n" +
" gm.project_id AS projectId,\n" +
" bp.project_name AS projectName \n" +
"FROM\n" +
" gps_equipment_son gm\n" +
" LEFT JOIN sys_user su ON gm.user_id = su.user_id \n" +
"LEFT JOIN bus_project bp ON gm.project_id = bp.id \n" +
"WHERE\n" +
" gm.client_id = #{clientId}" +
" GROUP BY gm.user_id")
" GROUP BY gm.user_id,gm.project_id")
List<GpsUserVo> getUserList(@Param("clientId") String clientId);
}

View File

@ -1,9 +1,13 @@
package org.dromara.gps.mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dromara.gps.domain.GpsEquipmentSon;
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import java.util.List;
/**
* GPS设备定位信息Mapper接口
*
@ -12,4 +16,20 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
*/
public interface GpsEquipmentSonMapper extends BaseMapperPlus<GpsEquipmentSon, GpsEquipmentSonVo> {
@Select("WITH RankedData AS (\n" +
" SELECT\n" +
" *,\n" +
" ROW_NUMBER() OVER (PARTITION BY client_id ORDER BY create_time DESC) AS rn\n" +
" FROM\n" +
" gps_equipment_son \n" +
"WHERE \n" +
"project_id = #{projectId}\n" +
")\n" +
"SELECT\n" +
" *\n" +
"FROM\n" +
" RankedData\n" +
"WHERE\n" +
" rn = 1;")
List<GpsEquipmentSonVo> getClientList(@Param("projectId") Long projectId);
}

View File

@ -1,6 +1,6 @@
package org.dromara.gps.service;
import org.dromara.common.core.domain.R;
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
import org.dromara.gps.domain.vo.GpsEquipmentVo;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.gps.domain.GpsEquipment;
@ -8,6 +8,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.gps.domain.vo.GpsProjectVo;
import org.dromara.gps.domain.vo.GpsUserVo;
import java.util.Collection;
@ -92,4 +93,10 @@ public interface IGpsEquipmentService extends IService<GpsEquipment>{
Boolean unbindManmachine(GpsEquipmentBo bo);
List<GpsUserVo> getUserList(GpsEquipmentBo bo);
List<GpsProjectVo> getProjectList();
List<GpsEquipmentSonVo> getClientList(Long projectId);
void setData(String jsonData);
}

View File

@ -67,4 +67,6 @@ public interface IGpsEquipmentSonService extends IService<GpsEquipmentSon>{
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
List<GpsEquipmentSonVo> getClientList(Long projectId);
}

View File

@ -1,12 +1,12 @@
package org.dromara.gps.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
@ -17,15 +17,22 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.gps.domain.GpsEquipmentSon;
import org.dromara.common.websocket.dto.WebSocketMessageDto;
import org.dromara.common.websocket.utils.WebSocketUtils;
import org.dromara.gps.domain.GpsManmachine;
import org.dromara.gps.domain.bo.GpsEquipmentSonBo;
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
import org.dromara.gps.domain.vo.GpsProjectVo;
import org.dromara.gps.domain.vo.GpsUserVo;
import org.dromara.gps.mapper.GpsManmachineMapper;
import org.dromara.gps.service.IGpsEquipmentSonService;
import org.dromara.gps.service.IGpsManmachineService;
import org.plutext.jaxb.svg11.G;
import org.redisson.api.ObjectListener;
import org.dromara.project.domain.vo.project.BusProjectVo;
import org.dromara.project.service.IBusProjectService;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.service.ISysUserService;
import org.redisson.api.DeletedObjectListener;
import org.redisson.api.ExpiredObjectListener;
import org.redisson.api.listener.SetObjectListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
@ -33,8 +40,10 @@ import org.dromara.gps.domain.vo.GpsEquipmentVo;
import org.dromara.gps.domain.GpsEquipment;
import org.dromara.gps.mapper.GpsEquipmentMapper;
import org.dromara.gps.service.IGpsEquipmentService;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Duration;
import java.util.*;
@ -55,6 +64,10 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
private IGpsEquipmentSonService gpsEquipmentSonService;
@Autowired
private GpsManmachineMapper gpsManmachineMapper;
@Autowired
private IBusProjectService projectService;
@Autowired
private ISysUserService userService;
/**
* 查询GPS设备详细
@ -78,6 +91,40 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
public TableDataInfo<GpsEquipmentVo> queryPageList(GpsEquipmentBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<GpsEquipment> lqw = buildQueryWrapper(bo);
Page<GpsEquipmentVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
if (bo.getType() == 1){
List<GpsEquipmentVo> list = result.getRecords().stream()
.filter(gpsEquipment -> gpsEquipment.getProjectId() != null)
.toList();
list.forEach(item -> {
if (item.getUserId() != null){
item.setType(1);
}else{
item.setType(2);
}
SysUserVo sysUserVo = userService.queryById(item.getUserId());
if (sysUserVo != null) {
item.setUserName(sysUserVo.getUserName());
}
BusProjectVo busProjectVo = projectService.selectById(item.getProjectId());
if (busProjectVo != null) {
item.setProjectName(busProjectVo.getProjectName());
}
});
result.setRecords(list);
}else if (bo.getType() == 2){
List<GpsEquipmentVo> list = result.getRecords().stream()
.filter(gpsEquipment -> gpsEquipment.getProjectId() == null).toList();
list.forEach(item ->{
if (item.getProjectId() != null) {
BusProjectVo busProjectVo = projectService.selectById(item.getProjectId());
if (busProjectVo != null) {
item.setProjectName(busProjectVo.getProjectName());
}
}
item.setType(2);
});
result.setRecords(list);
}
return TableDataInfo.build(result);
}
@ -169,8 +216,8 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
GpsEquipmentSonBo gpsEquipmentSon = JSONUtil.toBean(device, GpsEquipmentSonBo.class);
JSONObject location = device.getJSONObject("location");
gpsEquipmentSon.setLocLatitude(location.getBigDecimal("latitude"));
gpsEquipmentSon.setLocLongitude(location.getBigDecimal("longitude"));
gpsEquipmentSon.setLocLatitude(location.getBigDecimal("latitude").divide(new BigDecimal("1000000"),6, RoundingMode.HALF_UP));
gpsEquipmentSon.setLocLongitude(location.getBigDecimal("longitude").divide(new BigDecimal("1000000"),6, RoundingMode.HALF_UP));
if (equipment != null) {
gpsEquipmentSon.setProjectId(equipment.getProjectId());
}
@ -191,43 +238,94 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
gpsEquipmentSonService.insertByBo(gpsEquipmentSon);
//保存到redis如果存在则更新存活时间
// --------------------------
// 发布String类型订阅消息
// --------------------------
// 1. 构造需要推送的消息内容String类型
String pushContent = buildPushMessage(gpsEquipmentSon);
// WebSocketUtils.publishAll(pushContent);
// 2. 发布消息根据是否有用户ID决定发送给指定用户或广播
if (equipment != null && equipment.getProjectId() != null) {
// 发送给指定用户equipment.getUserId()
WebSocketMessageDto messageDto = new WebSocketMessageDto();
messageDto.setMessage(pushContent);
messageDto.setSessionKeys(Collections.singletonList(equipment.getProjectId()));
WebSocketUtils.publishMessage(messageDto);
} else {
// 无用户ID则广播给所有在线客户端
WebSocketUtils.publishAll(pushContent);
}
}
// 保存到Redis并设置过期监听
updateDeviceAliveStatus(gpsEquipment.getClientId());
}
/**
* 构建推送消息内容String类型
*/
private String buildPushMessage(GpsEquipmentSonBo sonBo) {
// 构造消息对象(包含关键信息)
JSONObject messageObj = new JSONObject();
messageObj.put("type", "GPS_DATA_UPDATE"); // 消息类型
messageObj.put("clientId", sonBo.getClientId()); // 设备唯一标识
messageObj.put("projectId", sonBo.getProjectId()); // 项目ID
messageObj.put("userId", sonBo.getUserId()); // 关联用户ID
private static final int DEVICE_ALIVE_TIMEOUT = 180; // 5分钟
// 位置信息
JSONObject locationObj = new JSONObject();
locationObj.put("latitude", sonBo.getLocLatitude()); // 纬度
locationObj.put("longitude", sonBo.getLocLongitude()); // 经度
locationObj.put("altitude", sonBo.getLocAltitude()); // 海拔
messageObj.put("location", locationObj);
// 转换为String类型返回
return messageObj.toString();
}
private static final int DEVICE_ALIVE_TIMEOUT = 120; // 5分钟
/**
* 更新设备存活状态到Redis并添加过期监听
* @param clientId 设备ID
*/
private void updateDeviceAliveStatus(String clientId) {
// String key = "gps_device_alive:" + clientId;
//
// // 先删除可能存在的旧监听器
// if (RedisUtils.isExistsObject(key)) {
// RedisUtils.deleteObject(key);
// }
//
// // 设置缓存对象和过期时间
// RedisUtils.setCacheObject(key, "ALIVE", Duration.ofSeconds(DEVICE_ALIVE_TIMEOUT));
//
// // 添加过期监听器
// RedisUtils.addObjectListener(key, new ObjectListener() {
// @Override
// public void onExpired(String name) {
// log.info("Device {} is offline due to key expiration", clientId);
// handleDeviceOffline(clientId);
// }
//
// @Override
// public void onDeleted(String name) {
// // 可选:处理手动删除的情况
// }
// });
String key = "gps_device_alive:" + clientId;
// 先删除可能存在的旧监听器
if (RedisUtils.isExistsObject(key)) {
RedisUtils.deleteObject(key);
}
// 注册监听器
RedisUtils.addObjectListener(key, new SetObjectListener() {
@Override
public void onSet(String key) {
// 业务逻辑,例如刷新缓存
// 设置缓存对象和过期时间
RedisUtils.setCacheObject(key, "ALIVE", Duration.ofSeconds(DEVICE_ALIVE_TIMEOUT));
}
});
RedisUtils.addObjectListener(key, new ExpiredObjectListener() {
@Override
public void onExpired(String key) {
// 业务逻辑,例如记录日志
handleDeviceOffline(clientId);
}
});
RedisUtils.addObjectListener(key, new DeletedObjectListener() {
@Override
public void onDeleted(String key) {
// 业务逻辑,例如通知其他系统
}
});
}
/**
* 处理设备离线
* @param clientId 设备ID
@ -252,9 +350,17 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean bindManmachine(GpsEquipmentBo bo) {
if (bo.getProjectId() == null) {
throw new ServiceException("请选择绑定项目");
}
if (bo.getUserId() == null) {
throw new ServiceException("请选择绑定用户");
}
baseMapper.update(new LambdaUpdateWrapper<GpsEquipment>()
.set(GpsEquipment::getUserId,bo.getUserId())
.set(GpsEquipment::getProjectId,bo.getProjectId())
.eq(GpsEquipment::getId,bo.getId()));
//只能绑定一个设备
List<GpsManmachine> gpsManmachines = gpsManmachineMapper.selectList(Wrappers.<GpsManmachine>lambdaQuery()
@ -271,16 +377,15 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean unbindManmachine(GpsEquipmentBo bo) {
baseMapper.update(new LambdaUpdateWrapper<GpsEquipment>()
.set(GpsEquipment::getUserId,null)
.eq(GpsEquipment::getId,bo.getId()));
GpsManmachine gpsManmachine = new GpsManmachine();
gpsManmachine.setClientId(bo.getClientId());
gpsManmachine.setUserId(bo.getUserId());
return gpsManmachineMapper.delete(new LambdaQueryWrapper<GpsManmachine>()
.eq(GpsManmachine::getClientId, gpsManmachine.getClientId())
.eq(GpsManmachine::getUserId,gpsManmachine.getUserId()))> 0;
.eq(GpsManmachine::getClientId, gpsManmachine.getClientId()))> 0;
}
/**
@ -298,6 +403,7 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
// GpsEquipment gpsEquipment = baseMapper.selectOne(new LambdaQueryWrapper<GpsEquipment>().eq(GpsEquipment::getClientId, bo.getClientId()));
GpsManmachine gpsManmachine = gpsManmachineMapper.selectOne(new LambdaQueryWrapper<GpsManmachine>().eq(GpsManmachine::getClientId, bo.getClientId()));
for (GpsUserVo item : list) {
item.setClientId(bo.getClientId());
if (gpsManmachine != null && gpsManmachine.getUserId().equals(item.getUserId())) {
item.setType(0);
}else {
@ -306,4 +412,40 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
}
return list;
}
@Override
public List<GpsProjectVo> getProjectList() {
List<BusProjectVo> projectVos = projectService.selectProjectVoList();
if (projectVos == null || projectVos.isEmpty()) {
return null;
}
List<GpsProjectVo> list = new ArrayList<>();
projectVos.forEach(item -> {
GpsProjectVo vo = new GpsProjectVo();
vo.setProjectId(item.getId());
vo.setProjectName(item.getProjectName());
list.add(vo);
});
return list;
}
@Override
public List<GpsEquipmentSonVo> getClientList(Long projectId) {
return gpsEquipmentSonService.getClientList(projectId);
}
@Override
public void setData(String jsonData) {
// 发送给指定用户equipment.getUserId()
WebSocketMessageDto messageDto = new WebSocketMessageDto();
messageDto.setMessage(jsonData);
messageDto.setSessionKeys(Collections.singletonList(1897160897167638522L));
WebSocketUtils.publishMessage(messageDto);
// WebSocketUtils.publishAll(jsonData);
}
}

View File

@ -72,23 +72,10 @@ public class GpsEquipmentSonServiceImpl extends ServiceImpl<GpsEquipmentSonMappe
private LambdaQueryWrapper<GpsEquipmentSon> buildQueryWrapper(GpsEquipmentSonBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<GpsEquipmentSon> lqw = Wrappers.lambdaQuery();
lqw.orderByDesc(GpsEquipmentSon::getId);
lqw.orderByDesc(GpsEquipmentSon::getCreateTime);
lqw.eq(bo.getProjectId() != null, GpsEquipmentSon::getProjectId, bo.getProjectId());
lqw.eq(bo.getUserId() != null, GpsEquipmentSon::getUserId, bo.getUserId());
lqw.eq(StringUtils.isNotBlank(bo.getClientId()), GpsEquipmentSon::getClientId, bo.getClientId());
lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), GpsEquipmentSon::getDeviceName, bo.getDeviceName());
lqw.eq(StringUtils.isNotBlank(bo.getDeviceId()), GpsEquipmentSon::getDeviceId, bo.getDeviceId());
lqw.eq(StringUtils.isNotBlank(bo.getMobileNo()), GpsEquipmentSon::getMobileNo, bo.getMobileNo());
lqw.eq(StringUtils.isNotBlank(bo.getPlateNo()), GpsEquipmentSon::getPlateNo, bo.getPlateNo());
lqw.eq(bo.getProtocolVersion() != null, GpsEquipmentSon::getProtocolVersion, bo.getProtocolVersion());
lqw.eq(bo.getLocWarnBit() != null, GpsEquipmentSon::getLocWarnBit, bo.getLocWarnBit());
lqw.eq(bo.getLocStatusBit() != null, GpsEquipmentSon::getLocStatusBit, bo.getLocStatusBit());
lqw.eq(bo.getLocLatitude() != null, GpsEquipmentSon::getLocLatitude, bo.getLocLatitude());
lqw.eq(bo.getLocLongitude() != null, GpsEquipmentSon::getLocLongitude, bo.getLocLongitude());
lqw.eq(bo.getLocAltitude() != null, GpsEquipmentSon::getLocAltitude, bo.getLocAltitude());
lqw.eq(bo.getLocSpeed() != null, GpsEquipmentSon::getLocSpeed, bo.getLocSpeed());
lqw.eq(bo.getLocSpeedKph() != null, GpsEquipmentSon::getLocSpeedKph, bo.getLocSpeedKph());
lqw.eq(bo.getLocDirection() != null, GpsEquipmentSon::getLocDirection, bo.getLocDirection());
lqw.eq(bo.getLocDeviceTime() != null, GpsEquipmentSon::getLocDeviceTime, bo.getLocDeviceTime());
return lqw;
}
@ -143,4 +130,9 @@ public class GpsEquipmentSonServiceImpl extends ServiceImpl<GpsEquipmentSonMappe
}
return baseMapper.deleteByIds(ids) > 0;
}
@Override
public List<GpsEquipmentSonVo> getClientList(Long projectId) {
return baseMapper.getClientList(projectId);
}
}

View File

@ -138,8 +138,13 @@ public class AttendanceJob {
manageUserIds.add(relevancy.getUserId());
busAttendance.setProjectId(0L);
}
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(relevancy.getUserId());
SubConstructionUser constructionUser = constructionUserService.lambdaQuery()
.eq(SubConstructionUser::getSysUserId, relevancy.getUserId())
.last("limit 1")
.one();
if(constructionUser==null){
continue;
}
busAttendance.setUserId(relevancy.getUserId());
busAttendance.setUserName(constructionUser.getUserName());
@ -251,7 +256,15 @@ public class AttendanceJob {
busAttendance.setProjectId(0L);
}
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(relevancy.getUserId());
SubConstructionUser constructionUser = constructionUserService.lambdaQuery()
.eq(SubConstructionUser::getSysUserId, relevancy.getUserId())
.last("limit 1")
.one();
if(constructionUser==null){
continue;
}
busAttendance.setUserId(relevancy.getUserId());
busAttendance.setUserName(constructionUser.getUserName());

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