From 834601daa8d2dddd94a276ab2f51658868812836 Mon Sep 17 00:00:00 2001 From: dfdg <2710245601@qq.com> Date: Mon, 15 Dec 2025 16:23:18 +0800 Subject: [PATCH 01/38] =?UTF-8?q?=E5=A4=A7=E5=B1=8Fwebsocket=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BigScreenWebSocketServer.java | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java new file mode 100644 index 00000000..7ad43336 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -0,0 +1,229 @@ +package org.dromara.websocket.websocket.service; + +import cn.hutool.json.JSONUtil; +import jakarta.websocket.*; +import jakarta.websocket.server.ServerEndpoint; +import lombok.extern.slf4j.Slf4j; +import org.dromara.common.core.utils.SpringUtils; +import org.dromara.gps.domain.bo.GpsEquipmentSonBo; +import org.dromara.gps.domain.vo.GpsEquipmentSonVo; +import org.dromara.gps.service.IGpsEquipmentSonService; +import org.dromara.websocket.websocket.domain.vo.VehicleVo; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 大屏 WebSocket 服务端(支持订阅消息) + * 端点路径:/websocket/bigScreen + */ +@Slf4j +@ServerEndpoint("/websocket/bigScreen") // 客户端连接时需携带订阅ID参数:ws://xxx/websocket/vehicle?subscriptionId=xxx +@Component +public class BigScreenWebSocketServer { + + // 1. 存储所有在线会话(sessionId -> Session) + private static final Map ONLINE_SESSIONS = new ConcurrentHashMap<>(); + + // 2. 核心:订阅ID与会话的映射(subscriptionId -> Session) + private static final Map SUBSCRIPTION_SESSIONS = new ConcurrentHashMap<>(); + + // 3. 反向映射:会话ID与订阅ID的映射(用于断开连接时清理订阅关系) + private static final Map SESSION_TO_SUBSCRIPTION = new ConcurrentHashMap<>(); + + // 当前会话对应的订阅ID(每个连接实例的专属变量) + private String currentSubscriptionId; + + + static { + log.info("✅ 大屏 WebSocket 服务端已随项目启动初始化!端点路径:/websocket/bigScreen"); + } + + /** + * 客户端连接时触发(解析订阅ID并建立映射关系) + */ + @OnOpen + public void onOpen(Session session) { + // 从连接URL的查询参数中获取订阅ID(客户端连接格式:ws://xxx/websocket/bigScreen?subscriptionId=123) + Map> params = session.getRequestParameterMap(); + List subscriptionIds = params.get("subscriptionId"); + if (subscriptionIds != null && !subscriptionIds.isEmpty()) { + this.currentSubscriptionId = subscriptionIds.get(0); // 取第一个订阅ID + // 建立映射关系 + SUBSCRIPTION_SESSIONS.put(currentSubscriptionId, session); + SESSION_TO_SUBSCRIPTION.put(session.getId(), currentSubscriptionId); + log.info("📌 客户端订阅成功!订阅ID:{},会话ID:{},当前订阅数:{}", + currentSubscriptionId, session.getId(), SUBSCRIPTION_SESSIONS.size()); + } else { + log.warn("📌 客户端连接未携带订阅ID!会话ID:{}", session.getId()); + } + + // 存储会话到在线列表 + ONLINE_SESSIONS.put(session.getId(), session); + log.info("📌 客户端连接成功!会话ID:{},当前在线数:{}", session.getId(), ONLINE_SESSIONS.size()); + + // 异步推送初始化数据(原有逻辑保留) + CompletableFuture.runAsync(() -> { + try { + String[] split = currentSubscriptionId.split("-"); + //todo 填充不同类型大屏获取基础数据的方法判断 + IGpsEquipmentSonService service = SpringUtils.getBean(IGpsEquipmentSonService.class); + GpsEquipmentSonBo bo = new GpsEquipmentSonBo(); + bo.setUserId(Long.parseLong(split[0])); + bo.setTripId(Long.parseLong(split[1])); + List list = service.getNewVehicleList(bo); + if (list == null || list.isEmpty()) { + session.getBasicRemote().sendText("初始化数据为空"); + log.warn("会话[{}]未获取到初始化数据", session.getId()); + return; + } + List vehicleVos = new ArrayList<>(); + for (GpsEquipmentSonVo ueClient : list) { + VehicleVo vo = new VehicleVo(); + vo.setLocLatitude(ueClient.getLocLatitude()); + vo.setLocLongitude(ueClient.getLocLongitude()); + vehicleVos.add(vo); + } + session.getBasicRemote().sendText(JSONUtil.toJsonStr(vehicleVos)); + log.info("📤 已向会话[{}]推送初始化数据,长度:{}字节", session.getId(), vehicleVos.size()); + } catch (Exception e) { + log.error("会话[{}]初始化数据处理失败", session.getId(), e); + try { + if (session.isOpen()) { + session.getBasicRemote().sendText("初始化失败:" + e.getMessage()); + } + } catch (IOException ex) { + log.error("会话[{}]推送错误信息失败", session.getId(), ex); + } + } + }); + } + + /** + * 接收客户端消息 + */ + @OnMessage + public void onMessage(String message, Session session) { + log.info("📥 收到会话[{}](订阅ID:{})消息:{}", session.getId(), currentSubscriptionId, message); + // 可选:回复客户端 + //todo 填充不同类型大屏获取数据的方法判断 + + try { + session.getBasicRemote().sendText("服务端已收到消息:" + message); + } catch (IOException e) { + log.error("📤 回复会话[{}]失败:{}", session.getId(), e.getMessage()); + } + } + + /** + * 客户端断开连接(清理订阅关系) + */ + @OnClose + public void onClose(Session session, CloseReason reason) { + // 1. 移除在线会话 + ONLINE_SESSIONS.remove(session.getId()); + // 2. 清理订阅关系 + String subscriptionId = SESSION_TO_SUBSCRIPTION.get(session.getId()); + if (subscriptionId != null) { + SUBSCRIPTION_SESSIONS.remove(subscriptionId); + SESSION_TO_SUBSCRIPTION.remove(session.getId()); + log.info("🔌 客户端订阅关系已清除!订阅ID:{},会话ID:{}", subscriptionId, session.getId()); + } + log.info("🔌 客户端断开连接!会话ID:{},原因:{},当前在线数:{},当前订阅数:{}", + session.getId(), reason.getReasonPhrase(), + ONLINE_SESSIONS.size(), SUBSCRIPTION_SESSIONS.size()); + } + + /** + * 连接异常 + */ + @OnError + public void onError(Session session, Throwable error) { + log.error("⚠️ 会话[{}](订阅ID:{})异常:{}", session.getId(), currentSubscriptionId, error.getMessage(), error); + } + + + // ------------------------------ 订阅消息发送工具方法(供外部调用) ------------------------------ + + /** + * 向指定订阅ID的客户端发送消息 + * @param subscriptionId 订阅ID + * @param message 消息内容 + * @return 是否发送成功 + */ + public static boolean sendToSubscription(String subscriptionId, String message) { + if (subscriptionId == null || message == null) { + log.warn("⚠️ 订阅ID或消息为空,发送失败"); + return false; + } + // 从订阅映射中获取目标会话 + Session session = SUBSCRIPTION_SESSIONS.get(subscriptionId); + if (session == null || !session.isOpen()) { + log.warn("⚠️ 订阅ID[{}]对应的客户端未连接或已断开", subscriptionId); + return false; + } + // 发送消息 + try { + session.getBasicRemote().sendText(message); + log.info("📤 已向订阅ID[{}]发送消息:{}", subscriptionId, message); + return true; + } catch (IOException e) { + log.error("📤 向订阅ID[{}]发送消息失败", subscriptionId, e); + return false; + } + } + + /** + * 向所有订阅客户端广播消息 + * @param message 消息内容 + */ + public static void broadcastToAllSubscriptions(String message) { + if (SUBSCRIPTION_SESSIONS.isEmpty()) { + log.warn("⚠️ 无订阅客户端,无需广播消息"); + return; + } + SUBSCRIPTION_SESSIONS.forEach((subscriptionId, session) -> { + if (session.isOpen()) { + try { + session.getBasicRemote().sendText(message); + log.info("📤 已向订阅ID[{}]广播消息", subscriptionId); + } catch (IOException e) { + log.error("📤 向订阅ID[{}]广播消息失败", subscriptionId, e); + } + } + }); + } + + /** + * 获取当前订阅数 + */ + public static int getSubscriptionCount() { + return SUBSCRIPTION_SESSIONS.size(); + } + + // 原有工具方法保留 + public static void sendToAll(String message) { + if (ONLINE_SESSIONS.isEmpty()) { + log.warn("⚠️ 无在线客户端,无需发送消息"); + return; + } + ONLINE_SESSIONS.values().forEach(session -> { + if (session.isOpen()) { + try { + session.getBasicRemote().sendText(message); + } catch (IOException e) { + log.error("📤 向会话[{}]发送消息失败:{}", session.getId(), e.getMessage()); + } + } + }); + } + + public static int getOnlineCount() { + return ONLINE_SESSIONS.size(); + } +} From ffe6642d1ccab7d15d5ab538c11e1524faf841b5 Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Mon, 15 Dec 2025 16:26:09 +0800 Subject: [PATCH 02/38] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/bigscreen/enums/DpEnum.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java new file mode 100644 index 00000000..f6137c5b --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java @@ -0,0 +1,21 @@ +package org.dromara.bigscreen.enums; + +public class DpEnum { + + + private final String TypeName; + + private final String TypeValue; + + public String getTypeName() { + return TypeName; + } + public String getTypeValue() { + return TypeValue; + } + + DpEnum(String TypeName, String TypeValue) { + this.TypeName = TypeName; + this.TypeValue = TypeValue; + } +} From deef321c1be35db5d7713c7dbc10e8cfca8d854a Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Mon, 15 Dec 2025 16:32:06 +0800 Subject: [PATCH 03/38] =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/dromara/bigscreen/enums/DpEnum.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java index f6137c5b..2aceaf5a 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java @@ -1,6 +1,10 @@ package org.dromara.bigscreen.enums; -public class DpEnum { +public enum DpEnum { + + ZLGLLX_ZXGL("专项检查", "1"), + ZLGLLX_DQJC("专项检查", "2"), + ZLGLLX_RCXJ("专项检查", "3"); private final String TypeName; From 654623ad1590cd4d967ac6c4b4ca1f138e494549 Mon Sep 17 00:00:00 2001 From: dfdg <2710245601@qq.com> Date: Mon, 15 Dec 2025 16:43:06 +0800 Subject: [PATCH 04/38] =?UTF-8?q?=E6=91=84=E5=83=8F=E5=A4=B4=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E5=85=A8=E5=A4=A9?= =?UTF-8?q?=E5=BD=95=E5=83=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/job/ys7/IncSyncYs7DeviceData.java | 17 +++ .../manager/ys7manager/Ys7Constant.java | 9 ++ .../manager/ys7manager/Ys7RequestUtils.java | 72 ++++++++++++ .../dto/DeviceOneKeySwitchRequstDto.java | 13 +++ .../other/config/ThreadPoolConfig.java | 51 +++++++++ .../controller/OthYs7DeviceController.java | 16 +++ .../dromara/other/domain/OthYs7Device.java | 5 + .../OthYs7DeviceOneKeySwitchReq.java | 24 ++++ .../domain/vo/ys7device/OthYs7DeviceVo.java | 5 + .../other/service/IOthYs7DeviceService.java | 15 +++ .../service/impl/OthYs7DeviceServiceImpl.java | 104 ++++++++++++++++++ 11 files changed, 331 insertions(+) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/dto/DeviceOneKeySwitchRequstDto.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/config/ThreadPoolConfig.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7device/OthYs7DeviceOneKeySwitchReq.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/ys7/IncSyncYs7DeviceData.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/ys7/IncSyncYs7DeviceData.java index 5da170f6..baaf60d1 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/ys7/IncSyncYs7DeviceData.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/ys7/IncSyncYs7DeviceData.java @@ -1,9 +1,11 @@ package org.dromara.job.ys7; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.dromara.manager.ys7manager.Ys7Manager; import org.dromara.manager.ys7manager.vo.Ys7QueryDeviceResponseVo; +import org.dromara.other.domain.OthYs7Device; import org.dromara.other.service.IOthYs7DeviceService; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.scheduling.annotation.Scheduled; @@ -41,4 +43,19 @@ public class IncSyncYs7DeviceData { } } + //同步摄像头全天录像开关状态 + // 每 1 分钟执行一次 + @Scheduled(cron = "1 0 0 * * ?") +// @Scheduled(cron = "0 */10 * * * ?") + public void getEnable() { + log.info("定时同步摄像头设备数据"); + List ys7DeviceList = ys7DeviceService.getBaseMapper().selectList(new LambdaQueryWrapper().orderByDesc(OthYs7Device::getCreateTime)); + Boolean result = ys7DeviceService.saveOrUpdateEnableByDeviceList(ys7DeviceList); + if (result) { + log.info("定时同步摄像头设备数据成功"); + } else { + log.info("没有需要定时同步的设备"); + } + } + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7Constant.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7Constant.java index b15f11f8..42b15191 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7Constant.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7Constant.java @@ -71,4 +71,13 @@ public interface Ys7Constant { */ String getDeviceLappVideoUrlByPost = "https://open.ys7.com/api/lapp/v2/live/address/get"; + /** + * 设置全天录像开关 POST + */ + String UPDATEONEKEYSWITCH = "https://open.ys7.com/api/lapp/device/fullday/record/switch/set"; + /** + * 获取全天录像开关状态 POST + */ + String GETONEKEYSWITCHSTATUS = "https://open.ys7.com/api/lapp/device/fullday/record/switch/status"; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7RequestUtils.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7RequestUtils.java index 636ba096..4cb6e078 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7RequestUtils.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7RequestUtils.java @@ -11,6 +11,7 @@ import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.TimestampUtils; import org.dromara.manager.ys7manager.dto.DeviceLocalVideoRequstDto; +import org.dromara.manager.ys7manager.dto.DeviceOneKeySwitchRequstDto; import org.dromara.manager.ys7manager.dto.DevicePlayBackUrlRequstDto; import org.dromara.manager.ys7manager.vo.*; @@ -448,4 +449,75 @@ public class Ys7RequestUtils { } } + /** + * 设置全天录像开关 + * @param dto + * @return + */ + public static Boolean putDeviceOneKeySwitch(DeviceOneKeySwitchRequstDto dto) { + if (StringUtils.isAnyBlank(dto.getAccessToken(), dto.getDeviceSerial())) { + throw new ServiceException("设置全天录像开关参数为空", HttpStatus.BAD_REQUEST); + } + if (dto.getEnable() == null){ + throw new ServiceException("请选择开关状态", HttpStatus.BAD_REQUEST); + } + HashMap paramMap = new HashMap<>(); + paramMap.put("accessToken", dto.getAccessToken()); + paramMap.put("deviceSerial", dto.getDeviceSerial()); + paramMap.put("enable", dto.getEnable()); + if (dto.getChannelNo() != null) { + paramMap.put("channelNo", dto.getChannelNo()); + } + + String errorMsg = "设置全天录像开关请求失败"; + try (HttpResponse response = HttpRequest.post(Ys7Constant.UPDATEONEKEYSWITCH) + .form(paramMap) + .execute()) { + if (!response.isOk()) { + log.error("{}:{}", errorMsg, response.getStatus()); + throw new ServiceException(errorMsg + response.getStatus()); + } + String body = response.body(); + log.info("设置全天录像开关body{}",body); + Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class); + if (!responseVo.getCode().equals("200")) { + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + throw new ServiceException("序列号:"+dto.getDeviceSerial()+errorMsg + responseVo.getMsg()); + } + return true; + } + } + /** + * 获取全天录像开关状态 + * @param dto + * @return + */ + public static Integer getDeviceSwitchStatus(DeviceOneKeySwitchRequstDto dto) { + if (StringUtils.isAnyBlank(dto.getAccessToken(), dto.getDeviceSerial())) { + throw new ServiceException("获取全天录像开关状态参数为空", HttpStatus.BAD_REQUEST); + } + HashMap paramMap = new HashMap<>(); + paramMap.put("accessToken", dto.getAccessToken()); + paramMap.put("deviceSerial", dto.getDeviceSerial()); + + String errorMsg = "获取全天录像开关状态请求失败"; + try (HttpResponse response = HttpRequest.post(Ys7Constant.GETONEKEYSWITCHSTATUS) + .form(paramMap) + .execute()) { + if (!response.isOk()) { + log.error("{}:{}", errorMsg, response.getStatus()); + throw new ServiceException(errorMsg + response.getStatus()); + } + String body = response.body(); + log.info("获取全天录像开关状态body{}",body); + Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class); + if (!responseVo.getCode().equals("200")) { + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + throw new ServiceException("序列号:"+dto.getDeviceSerial()+errorMsg + responseVo.getMsg()); + } + String data = responseVo.getData(); + return JSONUtil.parseObj(data).getInt("enable"); + } + } + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/dto/DeviceOneKeySwitchRequstDto.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/dto/DeviceOneKeySwitchRequstDto.java new file mode 100644 index 00000000..e40e2730 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/dto/DeviceOneKeySwitchRequstDto.java @@ -0,0 +1,13 @@ +package org.dromara.manager.ys7manager.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class DeviceOneKeySwitchRequstDto implements Serializable { + private String accessToken; //toke + private String deviceSerial; //设备序列号 + private Integer channelNo; // 通道号,默认1 + private Integer enable; // 状态:0-关闭,1-开启 +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/config/ThreadPoolConfig.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/config/ThreadPoolConfig.java new file mode 100644 index 00000000..2250a35c --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/config/ThreadPoolConfig.java @@ -0,0 +1,51 @@ +package org.dromara.other.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import java.util.concurrent.ThreadPoolExecutor; + + +@Configuration +public class ThreadPoolConfig { + + /** + * 摄像头全天录像开关操作专用线程池 + */ + @Bean("deviceSwitchExecutor") + public ThreadPoolTaskExecutor deviceSwitchExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(5); // 核心线程数 + executor.setMaxPoolSize(10); // 最大线程数 + executor.setKeepAliveSeconds(60); // 空闲线程存活时间(秒) + executor.setQueueCapacity(100); // 任务队列容量 + executor.setThreadNamePrefix("device-switch-task-"); // 线程名前缀(替代自定义ThreadFactory) + // 拒绝策略:队列满时由调用线程执行 + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + // 初始化线程池 + executor.initialize(); + // 应用关闭时优雅关闭 + Runtime.getRuntime().addShutdownHook(new Thread(executor::shutdown)); + return executor; + } + + /** + * 获取摄像头全天录像开关状态操作专用线程池 + */ + @Bean("getDeviceSwitchExecutor") + public ThreadPoolTaskExecutor getDeviceSwitchExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(5); // 核心线程数 + executor.setMaxPoolSize(10); // 最大线程数 + executor.setKeepAliveSeconds(60); // 空闲线程存活时间(秒) + executor.setQueueCapacity(100); // 任务队列容量 + executor.setThreadNamePrefix("get-device-switch-task-"); // 线程名前缀(替代自定义ThreadFactory) + // 拒绝策略:队列满时由调用线程执行 + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + // 初始化线程池 + executor.initialize(); + // 应用关闭时优雅关闭 + Runtime.getRuntime().addShutdownHook(new Thread(executor::shutdown)); + return executor; + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/controller/OthYs7DeviceController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/controller/OthYs7DeviceController.java index e3c1e25c..9b47e08f 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/controller/OthYs7DeviceController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/controller/OthYs7DeviceController.java @@ -282,4 +282,20 @@ public class OthYs7DeviceController extends BaseController { return R.ok(othYs7DeviceService.getDateAndDeviceLocalVideo(req)); } + /** + * 一键开关萤石摄像头全天录像开关 + * @return + */ + @SaCheckPermission("other:ys7Device:edit") + @PostMapping("/updateOneKeySwitch") + public R updateOneKeySwitch(@RequestBody OthYs7DeviceOneKeySwitchReq req){ + if (req.getDeviceSerial() == null){ + throw new ServiceException("设备序列号不能为空!!!"); + } + if (req.getEnable() == null){ + throw new ServiceException("状态不能为空!!!"); + } + int i = othYs7DeviceService.updateOneKeySwitch(req); + return R.ok(i>0?"正在处理中,请稍后刷新页面查看":"操作失败"); + } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/OthYs7Device.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/OthYs7Device.java index 897045cc..22a3b643 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/OthYs7Device.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/OthYs7Device.java @@ -53,6 +53,11 @@ public class OthYs7Device implements Serializable { */ private Integer status; + /** + * 状态:0-关闭,1-开启 + */ + private Integer enable; + /** * 布撤防状态 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7device/OthYs7DeviceOneKeySwitchReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7device/OthYs7DeviceOneKeySwitchReq.java new file mode 100644 index 00000000..6574c0b1 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7device/OthYs7DeviceOneKeySwitchReq.java @@ -0,0 +1,24 @@ +package org.dromara.other.domain.dto.ys7device; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author lilemy + * @date 2025/6/13 10:19 + */ +@Data +public class OthYs7DeviceOneKeySwitchReq implements Serializable { + + /** + * 设备序列号 + */ + private List deviceSerial; + + /** + * 状态:0-关闭,1-开启 + */ + private Integer enable; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/vo/ys7device/OthYs7DeviceVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/vo/ys7device/OthYs7DeviceVo.java index ef621e51..84a57db3 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/vo/ys7device/OthYs7DeviceVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/vo/ys7device/OthYs7DeviceVo.java @@ -69,6 +69,11 @@ public class OthYs7DeviceVo implements Serializable { @ExcelProperty(value = "设备在线状态(0离线 1在线)") private Integer status; + /** + * 状态:0-关闭,1-开启 + */ + private Integer enable; + /** * 固件版本号 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/IOthYs7DeviceService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/IOthYs7DeviceService.java index fbeb8637..7ff1618b 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/IOthYs7DeviceService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/IOthYs7DeviceService.java @@ -165,4 +165,19 @@ public interface IOthYs7DeviceService extends IService { * @return */ DateAndDeviceLocalVideoVo getDateAndDeviceLocalVideo(OthYs7DevicePlayBackUrlReq req); + + /** + * 一键开关 + * @param req + * @return + */ + int updateOneKeySwitch(OthYs7DeviceOneKeySwitchReq req); + + /** + * 保存或更新萤石摄像开关状态对象列表 + * + * @param ys7DeviceList 萤石摄像对象列表 + * @return 是否有值发生更改 + */ + Boolean saveOrUpdateEnableByDeviceList(List ys7DeviceList); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceServiceImpl.java index ff26b69b..5e16777e 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -19,6 +20,7 @@ import org.dromara.manager.ys7manager.Ys7Constant; import org.dromara.manager.ys7manager.Ys7Manager; import org.dromara.manager.ys7manager.Ys7RequestUtils; import org.dromara.manager.ys7manager.dto.DeviceLocalVideoRequstDto; +import org.dromara.manager.ys7manager.dto.DeviceOneKeySwitchRequstDto; import org.dromara.manager.ys7manager.dto.DevicePlayBackUrlRequstDto; import org.dromara.manager.ys7manager.enums.DeviceOnOffLineEnum; import org.dromara.manager.ys7manager.vo.DeviceLocalVideoRecordsVo; @@ -35,10 +37,12 @@ import org.dromara.other.utils.DateRangeUtils; import org.dromara.project.domain.BusProject; import org.dromara.project.service.IBusProjectService; import org.springframework.beans.BeanUtils; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.stream.Collectors; @@ -59,6 +63,11 @@ public class OthYs7DeviceServiceImpl extends ServiceImpl deviceSerials = req.getDeviceSerial(); + Integer enable = req.getEnable(); + for (String deviceSerial : deviceSerials) { + // lambda内变量需为final/有效final,重新赋值 + String finalDeviceSerial = deviceSerial; + Integer finalEnable = enable; + String finalToken = token; + + // 4. 异步执行单个设备的开关操作 + CompletableFuture.runAsync(() -> { + try { + // 构建请求DTO + DeviceOneKeySwitchRequstDto dto = new DeviceOneKeySwitchRequstDto(); + dto.setAccessToken(finalToken); + dto.setDeviceSerial(finalDeviceSerial); + dto.setEnable(finalEnable); + + // 调用第三方接口(可能抛出异常,已被try-catch捕获) + Boolean b = Ys7RequestUtils.putDeviceOneKeySwitch(dto); + if (b != null && b) { + // 接口调用成功,更新数据库 + int updateRows = baseMapper.update(new LambdaUpdateWrapper() + .set(OthYs7Device::getEnable, finalEnable) + .eq(OthYs7Device::getDeviceSerial, finalDeviceSerial)); + log.info("设备{}一键开关更新成功,开关状态:{},影响行数:{}", + finalDeviceSerial, finalEnable, updateRows); + } else { + log.warn("设备{}一键开关接口返回false,未更新数据库,开关状态:{}", + finalDeviceSerial, finalEnable); + } + } catch (Exception e) { + // 捕获所有异常,确保单个设备失败不影响其他设备 + log.error("设备{}一键开关处理失败,开关状态:{}", finalDeviceSerial, finalEnable, e); + } + }, deviceSwitchExecutor); // 指定自定义线程池 + } + + // 5. 主线程快速返回(异步任务后台执行) + log.info("已提交{}个设备的一键开关异步任务,开关状态:{}", deviceSerials.size(), enable); + return 1; + } + + @Override + public Boolean saveOrUpdateEnableByDeviceList(List ys7DeviceList) { + if (CollectionUtils.isEmpty(ys7DeviceList)) { + return false; + } + String token = ys7Manager.getToken(); + + if (token == null || token.isEmpty()) { + log.error("updateOneKeySwitch获取token失败,无法执行设备开关操作"); + return false; + } + for (OthYs7Device ys7Device : ys7DeviceList) { + // lambda内变量需为final/有效final,重新赋值 + String finalDeviceSerial = ys7Device.getDeviceSerial(); + String finalToken = token; + + // 4. 异步执行单个设备的开关操作 + CompletableFuture.runAsync(() -> { + try { + // 构建请求DTO + DeviceOneKeySwitchRequstDto dto = new DeviceOneKeySwitchRequstDto(); + dto.setAccessToken(finalToken); + dto.setDeviceSerial(finalDeviceSerial); + + // 调用第三方接口(可能抛出异常,已被try-catch捕获) + Integer b = Ys7RequestUtils.getDeviceSwitchStatus(dto); + if (b != null) { + // 接口调用成功,更新数据库 + int updateRows = baseMapper.update(new LambdaUpdateWrapper() + .set(OthYs7Device::getEnable, b) + .eq(OthYs7Device::getDeviceSerial, finalDeviceSerial)); + log.info("设备{}全天录像开关状态更新成功,开关状态:{},影响行数:{}", + finalDeviceSerial, b, updateRows); + } + } catch (Exception e) { + // 捕获所有异常,确保单个设备失败不影响其他设备 + log.error("设备{}全天录像开关状态获取失败", finalDeviceSerial, e); + } + }, getDeviceSwitchExecutor); // 指定自定义线程池 + } + return true; + } + /** * 验证萤石摄像对象是否发生更改 * From aa3628f041ca94edafc421561c78ab11f65fbab0 Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Tue, 16 Dec 2025 10:14:00 +0800 Subject: [PATCH 05/38] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F=EF=BC=8C=E6=91=84=E5=83=8F=E5=A4=B4=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProgressBigScreenController.java | 77 +++++ .../progress/DesignProgressMajorVo.java | 27 ++ .../domain/progress/DesignProgressVo.java | 94 ++++++ .../domain/progress/MilestoneProgressVo.java | 64 ++++ .../ProjectTotalProgressDetailVo.java | 37 +++ .../progress/ProjectTotalProgressVo.java | 49 +++ .../service/ProgressBigScreenService.java | 38 +++ .../impl/ProgressBigScreenServiceImpl.java | 295 ++++++++++++++++++ .../impl/ProjectBigScreenServiceImpl.java | 2 +- .../dromara/common/utils/BigDecimalUtil.java | 20 ++ .../design/domain/DesVolumeCatalog.java | 6 + .../dromara/design/domain/DesVolumeFile.java | 12 +- .../vo/volumecatalog/DesVolumeCatalogVo.java | 5 + .../domain/vo/volumefile/DesVolumeFileVo.java | 6 + .../impl/DesVolumeFileServiceImpl.java | 9 +- .../dromara/job/ys7/IncSyncYs7DeviceData.java | 9 +- .../dromara/other/domain/OthYs7Device.java | 5 + .../dto/ys7device/OthYs7DeviceUpdateReq.java | 5 + .../domain/vo/ys7device/OthYs7DeviceVo.java | 5 + .../service/impl/OthYs7DeviceServiceImpl.java | 6 +- .../PgsProgressCategoryValueTotalVo.java | 28 ++ .../progressplan/PgsProgressPlanDateVo.java | 28 ++ .../IPgsConstructionSchedulePlanService.java | 9 + .../service/IPgsProgressCategoryService.java | 2 +- .../service/IPgsProgressPlanService.java | 9 + ...gsConstructionSchedulePlanServiceImpl.java | 20 ++ .../impl/PgsProgressCategoryServiceImpl.java | 22 +- .../impl/PgsProgressPlanServiceImpl.java | 19 ++ 28 files changed, 887 insertions(+), 21 deletions(-) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/DesignProgressMajorVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/DesignProgressVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MilestoneProgressVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/ProjectTotalProgressDetailVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/ProjectTotalProgressVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryValueTotalVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanDateVo.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java new file mode 100644 index 00000000..caf962be --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java @@ -0,0 +1,77 @@ +package org.dromara.bigscreen.controller; + +import cn.dev33.satoken.annotation.SaIgnore; +import jakarta.annotation.Resource; +import jakarta.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; +import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq; +import org.dromara.bigscreen.domain.progress.DesignProgressVo; +import org.dromara.bigscreen.domain.progress.MilestoneProgressVo; +import org.dromara.bigscreen.domain.progress.ProjectTotalProgressVo; +import org.dromara.bigscreen.domain.vo.ProjectImageProgressDetailVo; +import org.dromara.bigscreen.service.ProgressBigScreenService; +import org.dromara.bigscreen.service.ProjectBigScreenService; +import org.dromara.common.core.domain.R; +import org.dromara.common.web.core.BaseController; +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 java.util.List; + +/** + * 进度管理大屏接口 + * + * @author lilemy + * @date 2025-12-15 11:35 + */ +@SaIgnore +@Validated +@RestController +@RequiredArgsConstructor +@RequestMapping("/progress/big/screen") +public class ProgressBigScreenController extends BaseController { + + @Resource + private ProgressBigScreenService progressBigScreenService; + + @Resource + private ProjectBigScreenService projectBigScreenService; + + /** + * 获取项目总进度 + */ + @GetMapping("/projectTotalProgress/{projectId}") + public R getProjectTotalProgress(@NotNull(message = "项目主键不能为空") + @PathVariable Long projectId) { + return R.ok(progressBigScreenService.getProjectTotalProgress(projectId)); + } + + /** + * 获取里程碑进度 + */ + @GetMapping("/milestoneProgress/{projectId}") + public R> getMilestoneProgress(@NotNull(message = "项目主键不能为空") + @PathVariable Long projectId) { + return R.ok(progressBigScreenService.getMilestoneProgress(projectId)); + } + + /** + * 获取设计进度 + */ + @GetMapping("/designProgress/{projectId}") + public R getDesignProgress(@NotNull(message = "项目主键不能为空") + @PathVariable Long projectId) { + return R.ok(progressBigScreenService.getDesignProgress(projectId)); + } + + /** + * 获取施工进度详情 + */ + @GetMapping("/constructionProgress/detail") + public R> getProjectImageProgressDetail(@Validated ProjectImageProgressDetailReq req) { + return R.ok(projectBigScreenService.getProjectImageProgressDetail(req)); + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/DesignProgressMajorVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/DesignProgressMajorVo.java new file mode 100644 index 00000000..829b35aa --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/DesignProgressMajorVo.java @@ -0,0 +1,27 @@ +package org.dromara.bigscreen.domain.progress; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * @author lilemy + * @date 2025-12-15 17:30 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DesignProgressMajorVo { + + /** + * 专业名称 + */ + private String majorName; + + /** + * 完成率 + */ + private BigDecimal completionRate; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/DesignProgressVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/DesignProgressVo.java new file mode 100644 index 00000000..55b717d4 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/DesignProgressVo.java @@ -0,0 +1,94 @@ +package org.dromara.bigscreen.domain.progress; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * @author lilemy + * @date 2025-12-15 17:07 + */ +@Data +public class DesignProgressVo implements Serializable { + + @Serial + private static final long serialVersionUID = 379443600182489913L; + + /** + * 总设计任务进度 + */ + private Long totalDesignProgress; + + /** + * 当前设计任务进度 + */ + private Long currentDesignProgress; + + /** + * 设计任务进度趋势 + */ + private Boolean designProgressTrend; + + /** + * 设计任务进度环比 + */ + private BigDecimal designProgressRate; + + /** + * 总设计 + */ + private Long totalDesign; + + /** + * 已审核设计 + */ + private Long reviewedDesign; + + /** + * 已审核设计进度趋势 + */ + private Boolean reviewedDesignTrend; + + /** + * 已审核设计进度环比 + */ + private BigDecimal reviewedDesignRate; + + /** + * 待审核设计 + */ + private Long pendingDesignReview; + + /** + * 待审核设计进度趋势 + */ + private Boolean pendingDesignReviewTrend; + + /** + * 待审核设计进度环比 + */ + private BigDecimal pendingDesignReviewRate; + + /** + * 已逾期设计 + */ + private Long delayedDesign; + + /** + * 已逾期设计进度趋势 + */ + private Boolean delayedDesignTrend; + + /** + * 已逾期设计进度环比 + */ + private BigDecimal delayedDesignRate; + + /** + * 设计专业详情 + */ + List majorList; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MilestoneProgressVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MilestoneProgressVo.java new file mode 100644 index 00000000..0465b6f9 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MilestoneProgressVo.java @@ -0,0 +1,64 @@ +package org.dromara.bigscreen.domain.progress; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDate; + +/** + * @author lilemy + * @date 2025-12-15 16:15 + */ +@Data +public class MilestoneProgressVo implements Serializable { + + @Serial + private static final long serialVersionUID = 5731146976460407811L; + + /** + * 主键 ID + */ + private Long id; + + /** + * 节点名称 + */ + private String nodeName; + + /** + * 对应项目结构 + */ + private Long projectStructure; + + /** + * 对应项目结构名称 + */ + private String projectStructureName; + + /** + * 预计开始时间 + */ + private LocalDate planStartDate; + + /** + * 预计结束时间 + */ + private LocalDate planEndDate; + + /** + * 实际开始时间 + */ + private LocalDate practicalStartDate; + + /** + * 实际结束时间 + */ + private LocalDate practicalEndDate; + + /** + * 当前进度 + */ + private BigDecimal currentProgress; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/ProjectTotalProgressDetailVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/ProjectTotalProgressDetailVo.java new file mode 100644 index 00000000..50ff1f1b --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/ProjectTotalProgressDetailVo.java @@ -0,0 +1,37 @@ +package org.dromara.bigscreen.domain.progress; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * @author lilemy + * @date 2025-12-15 14:40 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ProjectTotalProgressDetailVo { + + /** + * 名称 + */ + private String name; + + /** + * 实际进度 + */ + private BigDecimal actualProgress; + + /** + * 计划进度 + */ + private BigDecimal planProgress; + + /** + * 完成率 + */ + private BigDecimal completionRate; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/ProjectTotalProgressVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/ProjectTotalProgressVo.java new file mode 100644 index 00000000..82fad871 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/ProjectTotalProgressVo.java @@ -0,0 +1,49 @@ +package org.dromara.bigscreen.domain.progress; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * @author lilemy + * @date 2025-12-15 14:23 + */ +@Data +public class ProjectTotalProgressVo implements Serializable { + + @Serial + private static final long serialVersionUID = -5706098940478706815L; + + /** + * 总进度 + */ + private BigDecimal totalProgress; + + /** + * 总计划工期(天) + */ + private Long totalPlannedDuration; + + /** + * 当前计划工期(天) + */ + private Long currentPlannedDuration; + + /** + * 总完成情况(万元) + */ + private BigDecimal totalCompletionAmount; + + /** + * 当前完成情况(万元) + */ + private BigDecimal currentCompletionAmount; + + /** + * 详情 + */ + private List detailList; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java new file mode 100644 index 00000000..e2f749f9 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java @@ -0,0 +1,38 @@ +package org.dromara.bigscreen.service; + +import org.dromara.bigscreen.domain.progress.DesignProgressVo; +import org.dromara.bigscreen.domain.progress.MilestoneProgressVo; +import org.dromara.bigscreen.domain.progress.ProjectTotalProgressVo; + +import java.util.List; + +/** + * @author lilemy + * @date 2025-12-15 14:18 + */ +public interface ProgressBigScreenService { + + /** + * 获取项目总进度 + * + * @param projectId 项目 id + * @return 项目总进度 + */ + ProjectTotalProgressVo getProjectTotalProgress(Long projectId); + + /** + * 获取里程碑进度 + * + * @param projectId 项目 id + * @return 里程碑进度 + */ + List getMilestoneProgress(Long projectId); + + /** + * 获取设计进度 + * + * @param projectId 项目 id + * @return 设计进度 + */ + DesignProgressVo getDesignProgress(Long projectId); +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java new file mode 100644 index 00000000..f453d5b9 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java @@ -0,0 +1,295 @@ +package org.dromara.bigscreen.service.impl; + +import cn.hutool.core.collection.CollUtil; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.dromara.bigscreen.domain.progress.*; +import org.dromara.bigscreen.service.ProgressBigScreenService; +import org.dromara.common.core.enums.BusinessStatusEnum; +import org.dromara.common.utils.BigDecimalUtil; +import org.dromara.design.domain.DesVolumeCatalog; +import org.dromara.design.domain.DesVolumeFile; +import org.dromara.design.service.IDesVolumeCatalogService; +import org.dromara.design.service.IDesVolumeFileService; +import org.dromara.progress.constant.PgsProgressCategoryConstant; +import org.dromara.progress.domain.PgsConstructionSchedulePlan; +import org.dromara.progress.domain.PgsProgressCategory; +import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanQueryReq; +import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryValueTotalVo; +import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanDateVo; +import org.dromara.progress.service.IPgsConstructionSchedulePlanService; +import org.dromara.progress.service.IPgsProgressCategoryService; +import org.dromara.progress.service.IPgsProgressPlanService; +import org.dromara.project.domain.BusProject; +import org.dromara.project.service.IBusProjectService; +import org.dromara.system.domain.vo.SysDictDataVo; +import org.dromara.system.service.ISysDictDataService; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author lilemy + * @date 2025-12-15 14:18 + */ +@Slf4j +@Service +public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { + + @Resource + private IBusProjectService projectService; + + @Resource + private IPgsProgressCategoryService progressCategoryService; + + @Resource + private IPgsProgressPlanService progressPlanService; + + @Resource + private IPgsConstructionSchedulePlanService constructionSchedulePlanService; + + @Resource + private IDesVolumeCatalogService volumeCatalogService; + + @Resource + private IDesVolumeFileService volumeFileService; + + @Resource + private ISysDictDataService dictDataService; + + /** + * 获取项目总进度 + * + * @param projectId 项目 id + * @return 项目总进度 + */ + @Override + public ProjectTotalProgressVo getProjectTotalProgress(Long projectId) { + ProjectTotalProgressVo vo = new ProjectTotalProgressVo(); + // 获取项目和项目子项 + BusProject project = projectService.getById(projectId); + if (project == null) { + return vo; + } + List projects = projectService.lambdaQuery() + .eq(BusProject::getPId, projectId) + .list(); + projects.add(project); + List projectIds = projects.stream().map(BusProject::getId).toList(); + // 获取当前项目所有父级类别 + List topList = progressCategoryService.lambdaQuery() + .in(PgsProgressCategory::getProjectId, projectIds) + .eq(PgsProgressCategory::getParentId, PgsProgressCategoryConstant.TOP_PARENT_ID) + .list(); + if (CollUtil.isEmpty(topList)) { + return vo; + } + List topIds = topList.stream().map(PgsProgressCategory::getId).toList(); + List children = progressCategoryService.getLeafNodesByTopIds(topIds); + BigDecimal completedPercentage = progressCategoryService.getCompletedPercentage(children); + vo.setTotalProgress(completedPercentage); + // 获取总计划工期 + PgsProgressPlanQueryReq queryDate = new PgsProgressPlanQueryReq(); + queryDate.setProjectId(projectId); + PgsProgressPlanDateVo dateVo = progressPlanService.queryDate(queryDate); + if (dateVo != null && dateVo.getStartDate() != null && dateVo.getEndDate() != null) { + LocalDate startDate = dateVo.getStartDate(); + LocalDate endDate = dateVo.getEndDate(); + LocalDate now = LocalDate.now(); + long totalDays = ChronoUnit.DAYS.between(startDate, endDate); + vo.setTotalPlannedDuration(totalDays); + if (now.isAfter(endDate)) { + vo.setCurrentPlannedDuration(totalDays); + } else if (now.isBefore(startDate)) { + vo.setCurrentPlannedDuration(0L); + } else { + vo.setCurrentPlannedDuration(ChronoUnit.DAYS.between(startDate, now) + 1); + } + } + // 获取整体完成情况 + PgsProgressCategoryValueTotalVo valueTotal = progressCategoryService.getValueTotal(children, true); + vo.setTotalCompletionAmount(valueTotal.getTotalValue()); + vo.setCurrentCompletionAmount(valueTotal.getCurrentValue()); + // 获取详情 + Map> nameMap = topList.stream() + .collect(Collectors.groupingBy(PgsProgressCategory::getName)); + List detailList = new ArrayList<>(); + for (Map.Entry> entry : nameMap.entrySet()) { + ProjectTotalProgressDetailVo detailVo = new ProjectTotalProgressDetailVo(); + String name = entry.getKey(); + detailVo.setName(name); + List value = entry.getValue(); + List top = value.stream().map(PgsProgressCategory::getId).toList(); + List nameChildren = progressCategoryService.getLeafNodesByTopIds(top, children); + BigDecimal completedTotal = nameChildren.stream().map(PgsProgressCategory::getCompleted) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal planTotal = nameChildren.stream().map(PgsProgressCategory::getPlanTotal) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal total = nameChildren.stream().map(PgsProgressCategory::getTotal) + .reduce(BigDecimal.ZERO, BigDecimal::add); + detailVo.setActualProgress(completedTotal); + detailVo.setPlanProgress(planTotal); + detailVo.setCompletionRate(BigDecimalUtil.toPercentage(completedTotal, total)); + detailList.add(detailVo); + } + vo.setDetailList(detailList); + return vo; + } + + /** + * 获取里程碑进度 + * + * @param projectId 项目 id + * @return 里程碑进度 + */ + @Override + public List getMilestoneProgress(Long projectId) { + List voList = new ArrayList<>(); + List planList = constructionSchedulePlanService.lambdaQuery() + .eq(PgsConstructionSchedulePlan::getProjectId, projectId) + .list(); + if (CollUtil.isEmpty(planList)) { + return voList; + } + List topList = planList.stream().filter(plan -> plan.getParentId().equals(0L)).toList(); + return topList.stream().map(plan -> { + MilestoneProgressVo vo = new MilestoneProgressVo(); + BeanUtils.copyProperties(plan, vo); + // 获取子节点 + List allChildren = constructionSchedulePlanService.getAllChildren(plan.getId(), planList); + long count = allChildren.stream().filter(child -> child.getStatus().equals("4")).count(); + BigDecimal percentage = BigDecimalUtil.toPercentage(new BigDecimal(count), new BigDecimal(allChildren.size())); + vo.setCurrentProgress(percentage); + return vo; + }).toList(); + } + + /** + * 获取设计进度 + * + * @param projectId 项目 id + * @return 设计进度 + */ + @Override + public DesignProgressVo getDesignProgress(Long projectId) { + DesignProgressVo vo = new DesignProgressVo(); + List catalogList = volumeCatalogService.lambdaQuery() + .eq(DesVolumeCatalog::getProjectId, projectId).list(); + if (CollUtil.isEmpty(catalogList)) { + return vo; + } + LocalDate nowDate = LocalDate.now(); + long currentDesignProgress = 0L; + BigDecimal designProgressThisM = BigDecimal.ZERO; + BigDecimal designProgressLastM = BigDecimal.ZERO; + long currentDelay = 0L; + BigDecimal delayThisD = BigDecimal.ZERO; + BigDecimal delayLastD = BigDecimal.ZERO; + // 总数量 + vo.setTotalDesignProgress((long) catalogList.size()); + LocalDateTime firstDayOfMonth = LocalDateTime.now().withDayOfMonth(1).with(LocalTime.MIN); + LocalDateTime lastMonthFirstDay = LocalDateTime.now().minusMonths(1).withDayOfMonth(1).with(LocalTime.MIN); + for (DesVolumeCatalog catalog : catalogList) { + // 已出图状态 + if (catalog.getDesignState().equals("1")) { + currentDesignProgress++; + // 获取当月和上月的完成数量 + LocalDateTime finishTime = catalog.getFinishTime(); + if (finishTime != null) { + if (finishTime.isAfter(firstDayOfMonth)) { + designProgressThisM = designProgressThisM.add(BigDecimal.ONE); + } else if (finishTime.isBefore(lastMonthFirstDay)) { + designProgressLastM = designProgressLastM.add(BigDecimal.ONE); + } + } + } else if (!catalog.getPlannedCompletion().isAfter(nowDate) && catalog.getDesignState().equals("2")) { + currentDelay++; + if (catalog.getPlannedCompletion().isEqual(nowDate)) { + delayThisD = delayThisD.add(BigDecimal.ONE); + } else if (catalog.getPlannedCompletion().isEqual(nowDate.minusDays(1))) { + delayLastD = delayLastD.add(BigDecimal.ONE); + } + } + } + // 计算完成情况 + vo.setCurrentDesignProgress(currentDesignProgress); + vo.setDesignProgressTrend(designProgressThisM.compareTo(designProgressLastM) >= 0); + vo.setDesignProgressRate(BigDecimalUtil.toLoopPercentage(designProgressThisM, designProgressLastM)); + // 总逾期数量 + vo.setDelayedDesign(currentDelay); + vo.setDelayedDesignTrend(delayThisD.compareTo(delayLastD) >= 0); + vo.setDelayedDesignRate(BigDecimalUtil.toLoopPercentage(delayThisD, delayLastD)); + // 获取各专业完成情况 + List majorList = new ArrayList<>(); + Map> specialtyMap = catalogList.stream() + .collect(Collectors.groupingBy(DesVolumeCatalog::getSpecialty)); + List desUserMajor = dictDataService.selectByDictType("des_user_major"); + if (CollUtil.isEmpty(desUserMajor)) { + log.error("专业字典 des_user_major 数据不存在"); + } else { + Map dictMap = desUserMajor.stream() + .collect(Collectors.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel)); + specialtyMap.forEach((specialty, list) -> { + DesignProgressMajorVo majorVo = new DesignProgressMajorVo(); + majorVo.setMajorName(dictMap.getOrDefault(specialty, specialty)); + BigDecimal total = new BigDecimal(list.size()); + long count = list.stream().filter(catalog -> catalog.getDesignState().equals("1")).count(); + majorVo.setCompletionRate(BigDecimalUtil.toPercentage(new BigDecimal(count), total)); + majorList.add(majorVo); + }); + } + vo.setMajorList(majorList); + // 审核信息 + Set ids = catalogList.stream().map(DesVolumeCatalog::getDesign).collect(Collectors.toSet()); + List fileList = volumeFileService.lambdaQuery() + .in(DesVolumeFile::getVolumeCatalogId, ids) + .list(); + long reviewedDesign = 0L; + BigDecimal reviewedDesignThisM = BigDecimal.ZERO; + BigDecimal reviewedDesignLastM = BigDecimal.ZERO; + long pendingReviewDesign = 0L; + BigDecimal pendingReviewDesignThisD = BigDecimal.ZERO; + BigDecimal pendingReviewDesignLastD = BigDecimal.ZERO; + for (DesVolumeFile file : fileList) { + String status = file.getStatus(); + if (BusinessStatusEnum.FINISH.getStatus().equals(status)) { + reviewedDesign++; + // 获取当月和上月的完成数量 + LocalDateTime finishTime = file.getFinishTime(); + if (finishTime != null) { + if (finishTime.isAfter(firstDayOfMonth)) { + reviewedDesignThisM = reviewedDesignThisM.add(BigDecimal.ONE); + } else if (finishTime.isBefore(lastMonthFirstDay)) { + reviewedDesignLastM = reviewedDesignLastM.add(BigDecimal.ONE); + } + } + } else if (BusinessStatusEnum.WAITING.getStatus().equals(status)) { + pendingReviewDesign++; + Date createTime = file.getCreateTime(); + LocalDate createDate = createTime.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + if (createDate.isEqual(nowDate)) { + pendingReviewDesignThisD = pendingReviewDesignThisD.add(BigDecimal.ONE); + } else if (createDate.isEqual(nowDate.minusDays(1))) { + pendingReviewDesignLastD = pendingReviewDesignLastD.add(BigDecimal.ONE); + } + } + } + vo.setReviewedDesign(reviewedDesign); + vo.setReviewedDesignTrend(reviewedDesignThisM.compareTo(reviewedDesignLastM) >= 0); + vo.setReviewedDesignRate(BigDecimalUtil.toLoopPercentage(reviewedDesignThisM, reviewedDesignLastM)); + vo.setPendingDesignReview(pendingReviewDesign); + vo.setPendingDesignReviewTrend(pendingReviewDesignThisD.compareTo(pendingReviewDesignLastD) >= 0); + vo.setPendingDesignReviewRate(BigDecimalUtil.toLoopPercentage(pendingReviewDesignThisD, pendingReviewDesignLastD)); + return vo; + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java index 95c9e4ab..6896bb4e 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java @@ -370,7 +370,7 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService { // 如果有叶子节点,统计进度和状态;否则初始化为未完成 if (CollUtil.isNotEmpty(leafNodesByTopIds)) { topVo.setProgressTotal(progressCategoryService.getCompletedPercentage(leafNodesByTopIds)); - topVo.setValueTotal(progressCategoryService.getValueTotal(leafNodesByTopIds, true)); + topVo.setValueTotal(progressCategoryService.getValueTotal(leafNodesByTopIds, true).getCurrentValue()); } else { topVo.setProgressTotal(BigDecimal.ZERO); topVo.setValueTotal(BigDecimal.ZERO); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/BigDecimalUtil.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/BigDecimalUtil.java index 53307861..228d03c3 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/BigDecimalUtil.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/BigDecimalUtil.java @@ -25,4 +25,24 @@ public class BigDecimalUtil { .divide(divisor, 2, RoundingMode.HALF_UP); } + /** + * 计算环比 = (本次 - 上次) / 上次 × 100% 的绝对值 + * + * @param thisNum 本次数量 + * @param lastNum 上次数量 + * @return 环比 = (本次 - 上次) / 上次 × 100% 的绝对值 + */ + public static BigDecimal toLoopPercentage(BigDecimal thisNum, BigDecimal lastNum) { + if (thisNum == null || lastNum == null) { + return BigDecimal.valueOf(0.00); + } + if (lastNum.compareTo(BigDecimal.ZERO) == 0) { + return BigDecimal.valueOf(100.00); + } + return thisNum.subtract(lastNum) + .multiply(new BigDecimal("100")) + .divide(lastNum, 2, RoundingMode.HALF_UP) + .abs(); + } + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/DesVolumeCatalog.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/DesVolumeCatalog.java index 5cbd5ac0..8251d609 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/DesVolumeCatalog.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/DesVolumeCatalog.java @@ -8,6 +8,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity; import java.io.Serial; import java.time.LocalDate; +import java.time.LocalDateTime; /** * 卷册目录对象 des_volume_catalog @@ -74,6 +75,11 @@ public class DesVolumeCatalog extends BaseEntity { */ private LocalDate plannedCompletion; + /** + * 实际完成时间 + */ + private LocalDateTime finishTime; + /** * 状态(字典) */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/DesVolumeFile.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/DesVolumeFile.java index fe3c3b03..3bb5ee4a 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/DesVolumeFile.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/DesVolumeFile.java @@ -1,11 +1,13 @@ package org.dromara.design.domain; -import org.dromara.common.mybatis.core.domain.BaseEntity; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; +import org.dromara.common.mybatis.core.domain.BaseEntity; import java.io.Serial; +import java.time.LocalDateTime; /** * 卷册文件对象 des_volume_file @@ -28,7 +30,6 @@ public class DesVolumeFile extends BaseEntity { public static final String WASTE = "4"; - /** * 主键ID */ @@ -80,4 +81,9 @@ public class DesVolumeFile extends BaseEntity { */ private String auditStatus; + /** + * 实际完成时间 + */ + private LocalDateTime finishTime; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/volumecatalog/DesVolumeCatalogVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/volumecatalog/DesVolumeCatalogVo.java index 1ddda84e..e61959cc 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/volumecatalog/DesVolumeCatalogVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/volumecatalog/DesVolumeCatalogVo.java @@ -89,6 +89,11 @@ public class DesVolumeCatalogVo implements Serializable { */ private LocalDate plannedCompletion; + /** + * 实际完成时间 + */ + private LocalDateTime finishTime; + /** * 状态(字典) */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/volumefile/DesVolumeFileVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/volumefile/DesVolumeFileVo.java index a9e911e5..a8ae1021 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/volumefile/DesVolumeFileVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/volumefile/DesVolumeFileVo.java @@ -6,6 +6,7 @@ import org.dromara.design.domain.DesVolumeFile; import java.io.Serial; import java.io.Serializable; +import java.time.LocalDateTime; /** @@ -76,6 +77,11 @@ public class DesVolumeFileVo implements Serializable { */ private String auditStatus; + /** + * 实际完成时间 + */ + private LocalDateTime finishTime; + /** * 是否弹窗 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeFileServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeFileServiceImpl.java index 9550739a..f665bd02 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeFileServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeFileServiceImpl.java @@ -12,7 +12,6 @@ import io.micrometer.common.util.StringUtils; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.constant.HttpStatus; -import org.dromara.common.core.domain.dto.UserDTO; import org.dromara.common.core.domain.event.ProcessDeleteEvent; import org.dromara.common.core.domain.event.ProcessEvent; import org.dromara.common.core.domain.event.ProcessTaskEvent; @@ -48,8 +47,8 @@ import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.*; -import java.util.stream.Collectors; /** * 卷册文件Service业务层处理 @@ -602,9 +601,12 @@ public class DesVolumeFileServiceImpl extends ServiceImpllambdaUpdate() .set(DesVolumeCatalog::getDesignState, "1") + .set(DesVolumeCatalog::getFinishTime, LocalDateTime.now()) .eq(DesVolumeCatalog::getDesign, desVolumeFile.getVolumeCatalogId()) ); //异步处理二维码 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/ys7/IncSyncYs7DeviceData.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/ys7/IncSyncYs7DeviceData.java index baaf60d1..db3339fb 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/ys7/IncSyncYs7DeviceData.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/ys7/IncSyncYs7DeviceData.java @@ -43,18 +43,17 @@ public class IncSyncYs7DeviceData { } } - //同步摄像头全天录像开关状态 - // 每 1 分钟执行一次 + //同步摄像头全天录像开关状态 每 1 天执行一次 @Scheduled(cron = "1 0 0 * * ?") // @Scheduled(cron = "0 */10 * * * ?") public void getEnable() { - log.info("定时同步摄像头设备数据"); + log.info("定时同步摄像头全天录像开关状态"); List ys7DeviceList = ys7DeviceService.getBaseMapper().selectList(new LambdaQueryWrapper().orderByDesc(OthYs7Device::getCreateTime)); Boolean result = ys7DeviceService.saveOrUpdateEnableByDeviceList(ys7DeviceList); if (result) { - log.info("定时同步摄像头设备数据成功"); + log.info("定时同步摄像头全天录像开关状态成功"); } else { - log.info("没有需要定时同步的设备"); + log.info("没有需要定时同步的摄像头全天录像开关状态"); } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/OthYs7Device.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/OthYs7Device.java index 22a3b643..e50131b2 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/OthYs7Device.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/OthYs7Device.java @@ -111,6 +111,11 @@ public class OthYs7Device implements Serializable { */ private String detail; + /** + * 排序 + */ + private Integer sortData; + /** * 备注 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7device/OthYs7DeviceUpdateReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7device/OthYs7DeviceUpdateReq.java index b30d84b4..eb559663 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7device/OthYs7DeviceUpdateReq.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7device/OthYs7DeviceUpdateReq.java @@ -40,6 +40,11 @@ public class OthYs7DeviceUpdateReq implements Serializable { */ private String detail; + /** + * 排序 + */ + private Integer sortData; + /** * 备注 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/vo/ys7device/OthYs7DeviceVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/vo/ys7device/OthYs7DeviceVo.java index 84a57db3..bdaf0758 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/vo/ys7device/OthYs7DeviceVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/vo/ys7device/OthYs7DeviceVo.java @@ -97,6 +97,11 @@ public class OthYs7DeviceVo implements Serializable { */ private String detail; + /** + * 排序 + */ + private Integer sortData; + /** * 备注 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceServiceImpl.java index 5e16777e..fd478665 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceServiceImpl.java @@ -290,6 +290,7 @@ public class OthYs7DeviceServiceImpl extends ServiceImpl 1) { String first = dateList.getFirst(); - req.setStartTime(first+" 00:00:00"); - req.setEndTime(first+" 23:59:59"); + req.setStartTime(first + " 00:00:00"); + req.setEndTime(first + " 23:59:59"); } List deviceLocalVideo = getDeviceLocalVideo(req); vo.setDeviceList(deviceLocalVideo); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryValueTotalVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryValueTotalVo.java new file mode 100644 index 00000000..0b83c29b --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryValueTotalVo.java @@ -0,0 +1,28 @@ +package org.dromara.progress.domain.vo.progresscategory; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author lilemy + * @date 2025-12-15 15:28 + */ +@Data +public class PgsProgressCategoryValueTotalVo implements Serializable { + + @Serial + private static final long serialVersionUID = 3568038376181464491L; + + /** + * 总产值 + */ + private BigDecimal totalValue; + + /** + * 当前产值 + */ + private BigDecimal currentValue; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanDateVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanDateVo.java new file mode 100644 index 00000000..f9aaaf93 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanDateVo.java @@ -0,0 +1,28 @@ +package org.dromara.progress.domain.vo.progressplan; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDate; + +/** + * @author lilemy + * @date 2025-12-15 15:01 + */ +@Data +public class PgsProgressPlanDateVo implements Serializable { + + @Serial + private static final long serialVersionUID = -2179633422685929795L; + + /** + * 计划开始时间 + */ + private LocalDate startDate; + + /** + * 计划结束时间 + */ + private LocalDate endDate; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsConstructionSchedulePlanService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsConstructionSchedulePlanService.java index 385e2f7e..57cb1c68 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsConstructionSchedulePlanService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsConstructionSchedulePlanService.java @@ -91,6 +91,15 @@ public interface IPgsConstructionSchedulePlanService extends IService getVoList(List constructionSchedulePlanList); + /** + * 获取所有子节点 + * + * @param parentId 父节点 ID + * @param allList 所有节点列表 + * @return 所有子节点列表 + */ + List getAllChildren(Long parentId, List allList); + /** * 导出Excel * diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressCategoryService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressCategoryService.java index 827b7190..a58ee870 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressCategoryService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressCategoryService.java @@ -220,7 +220,7 @@ public interface IPgsProgressCategoryService extends IService categoryList, Boolean selectValue); + PgsProgressCategoryValueTotalVo getValueTotal(List categoryList, Boolean selectValue); /** * 获取项目进度类别未完成数量 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanService.java index 6259bfd4..845d10f7 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanService.java @@ -9,6 +9,7 @@ import org.dromara.progress.domain.PgsProgressCategory; import org.dromara.progress.domain.PgsProgressPlan; import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanCreateReq; import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanQueryReq; +import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanDateVo; import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanVo; import java.math.BigDecimal; @@ -47,6 +48,14 @@ public interface IPgsProgressPlanService extends IService { */ List queryList(PgsProgressPlanQueryReq req); + /** + * 查询进度计划日期(最早的开始时间和最晚的结束时间) + * + * @param req 查询条件 + * @return 进度计划日期(最早的开始时间和最晚的结束时间) + */ + PgsProgressPlanDateVo queryDate(PgsProgressPlanQueryReq req); + /** * 新增进度计划 * diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsConstructionSchedulePlanServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsConstructionSchedulePlanServiceImpl.java index e6bfbc70..e98abb14 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsConstructionSchedulePlanServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsConstructionSchedulePlanServiceImpl.java @@ -199,6 +199,26 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl getAllChildren(Long parentId, List allList) { + List result = new ArrayList<>(); + for (PgsConstructionSchedulePlan node : allList) { + if (Objects.equals(node.getParentId(), parentId)) { + result.add(node); + // 递归找子节点 + result.addAll(getAllChildren(node.getId(), allList)); + } + } + return result; + } + // region 导出 excel /** diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java index 86c3cfb9..360ae0c3 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java @@ -1547,10 +1547,14 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl categoryList, Boolean selectValue) { + public PgsProgressCategoryValueTotalVo getValueTotal(List categoryList, Boolean selectValue) { + PgsProgressCategoryValueTotalVo vo = new PgsProgressCategoryValueTotalVo(); + vo.setCurrentValue(BigDecimal.ZERO); + vo.setTotalValue(BigDecimal.ZERO); // 如果没有数据,则返回0 if (CollUtil.isEmpty(categoryList)) { - return BigDecimal.ZERO; + return vo; } + BigDecimal currentValue = BigDecimal.ZERO; BigDecimal totalValue = BigDecimal.ZERO; - // 遍历所有项目进度,计算总完成数和总数 for (PgsProgressCategory category : categoryList) { BigDecimal completed = category.getCompleted(); @@ -1662,9 +1669,12 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl planList = this.list(this.buildQueryWrapper(req)); + PgsProgressPlanDateVo dateVo = new PgsProgressPlanDateVo(); + if (CollUtil.isEmpty(planList)) { + return dateVo; + } + dateVo.setStartDate(planList.stream().map(PgsProgressPlan::getStartDate).min(LocalDate::compareTo).orElse(null)); + dateVo.setEndDate(planList.stream().map(PgsProgressPlan::getEndDate).max(LocalDate::compareTo).orElse(null)); + return dateVo; + } + /** * 新增进度计划 * From de6d100f792c610246b27ecd6d123094b621a4e5 Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Tue, 16 Dec 2025 11:34:41 +0800 Subject: [PATCH 06/38] =?UTF-8?q?=E8=B4=A8=E5=AE=89=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DpzaglController.java | 66 ++++++ .../dromara/bigscreen/domain/bo/DpznglBo.java | 28 +++ .../bigscreen/domain/vo/DpznglAqyVo.java | 31 +++ .../dromara/bigscreen/domain/vo/DpznglVo.java | 103 +++++++++ .../org/dromara/bigscreen/enums/DpEnum.java | 6 +- .../bigscreen/service/DpzaglService.java | 28 +++ .../service/impl/DpzaglServiceImpl.java | 198 ++++++++++++++++++ .../gps/mapper/GpsEquipmentSonMapper.java | 13 ++ 8 files changed, 471 insertions(+), 2 deletions(-) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/DpzaglController.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/bo/DpznglBo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/DpzaglService.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/DpzaglController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/DpzaglController.java new file mode 100644 index 00000000..82f4c579 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/DpzaglController.java @@ -0,0 +1,66 @@ +package org.dromara.bigscreen.controller; + + +import lombok.RequiredArgsConstructor; +import org.dromara.bigscreen.domain.bo.DpznglBo; +import org.dromara.bigscreen.domain.vo.DpznglAqyVo; +import org.dromara.bigscreen.domain.vo.DpznglVo; +import org.dromara.bigscreen.service.DpzaglService; +import org.dromara.common.core.domain.R; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 大屏-质安管理 + * + * @author Lion Li + * @date 2025-11-05 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/dpzagl") +public class DpzaglController { + + private final DpzaglService dpzaglService; + + + + /** + * 查询大屏-质安管理-站班会,巡检工单,整改情况 + */ + @GetMapping("/list") + public R list(DpznglBo bo) { + return R.ok(dpzaglService.queryList(bo)); + } + + /** + * 查询大屏-质安管理-站班会 + */ + @GetMapping("/listByzbh") + public R listByzbh(DpznglBo bo) { + return R.ok(dpzaglService.listByzbh(bo)); + } + + + /** + * 查询大屏-质安管理-安全员分布情况 + */ + @GetMapping("/listByAqy") + public R> listByAqy(DpznglBo bo) { + return R.ok(dpzaglService.listByAqy(bo)); + } + + + + + + + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/bo/DpznglBo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/bo/DpznglBo.java new file mode 100644 index 00000000..c7aadd36 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/bo/DpznglBo.java @@ -0,0 +1,28 @@ +package org.dromara.bigscreen.domain.bo; + + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class DpznglBo implements Serializable { + + /** + * 分页大小 + */ + private Integer pageSize = 10; + + /** + * 当前页数 + */ + private Integer pageNum = 1; + + + /** + * 项目id + */ + private Long projectId; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java new file mode 100644 index 00000000..308b1ed4 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java @@ -0,0 +1,31 @@ +package org.dromara.bigscreen.domain.vo; + + +import com.google.type.Decimal; +import lombok.Data; +import org.dromara.common.translation.annotation.Translation; +import org.dromara.common.translation.constant.TransConstant; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class DpznglAqyVo implements Serializable { + + private Long userId; + + @Translation(type = TransConstant.XZD_KHXX_ID_TO_NAME, mapper = "userId") + private String userName; + + /** + * 经度 + */ + private BigDecimal locLatitude; + + /** + * 纬度 + */ + private BigDecimal locLongitude; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglVo.java new file mode 100644 index 00000000..c84c1a02 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglVo.java @@ -0,0 +1,103 @@ +package org.dromara.bigscreen.domain.vo; + + +import lombok.Data; +import org.dromara.quality.domain.vo.qualityinspection.QltQualityInspectionVo; +import org.dromara.safety.domain.vo.safetyinspection.HseSafetyInspectionVo; +import org.dromara.safety.domain.vo.teammeeting.HseTeamMeetingVo; + +import java.io.Serializable; +import java.util.List; + +@Data +public class DpznglVo implements Serializable { + + /** + * 站班会 + */ + private List zbhList; + + +// 质量管理 + + /** + * 质量总数 + */ + private Long zlZS; + /** + * 质量数据 + */ + private List zlList; + + /** + * 质量 专项检查 + */ + private Long zxjcZl; + + /** + * 质量 定期检查 + */ + private Long dqjcZl; + + /** + * 质量 日常巡检 + */ + private Long rcxjZl; + + /** + * 质量 整改数量 + */ + private Long zlZgsl; + + /** + * 质量数据-整改 + */ + private List zlZgList; + + + + // 安全管理 + + /** + * 安全总数 + */ + private Long aqZS; + /** + * 安全数据 + */ + private List aqList; + + /** + * 安全 专项检查 + */ + private Long zxjcAq; + + /** + * 安全定期检查 + */ + private Long dqjcAq; + + /** + * 安全 日常巡检 + */ + private Long rcxjAq; + + /** + * 安全 整改数量 + */ + private Long aqZgsl; + + /** + * 安全数据-整改 + */ + private List aqZgList; + + + + + + + + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java index 2aceaf5a..090c1c82 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java @@ -3,8 +3,10 @@ package org.dromara.bigscreen.enums; public enum DpEnum { ZLGLLX_ZXGL("专项检查", "1"), - ZLGLLX_DQJC("专项检查", "2"), - ZLGLLX_RCXJ("专项检查", "3"); + ZLGLLX_DQJC("定期检查", "2"), + ZLGLLX_RCXJ("日常巡检", "3"), + ZLGDZT_ZG("工单状态-整改", "2"), + JSLX_AQY("角色类型-安全员", "SAFETY_OFFICER"); private final String TypeName; diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/DpzaglService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/DpzaglService.java new file mode 100644 index 00000000..58a922aa --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/DpzaglService.java @@ -0,0 +1,28 @@ +package org.dromara.bigscreen.service; + + +import org.dromara.bigscreen.domain.bo.DpznglBo; +import org.dromara.bigscreen.domain.vo.DpznglAqyVo; +import org.dromara.bigscreen.domain.vo.DpznglVo; + +import java.util.List; + +/** + * 大屏-质安管理 + * + * @author Lion Li + * @date 2025-11-05 + */ +public interface DpzaglService { + /** + * 查询大屏-质安管理-站班会,巡检工单,整改情况 + */ + DpznglVo queryList(DpznglBo bo); + + /** + * 查询大屏-质安管理-安全员分布情况 + */ + List listByAqy(DpznglBo bo); + + DpznglVo listByzbh(DpznglBo bo); +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java new file mode 100644 index 00000000..30edcc08 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java @@ -0,0 +1,198 @@ +package org.dromara.bigscreen.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.dromara.bigscreen.domain.bo.DpznglBo; +import org.dromara.bigscreen.domain.vo.DpznglAqyVo; +import org.dromara.bigscreen.domain.vo.DpznglVo; +import org.dromara.bigscreen.enums.DpEnum; +import org.dromara.bigscreen.service.DpzaglService; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.gps.domain.GpsEquipmentSon; +import org.dromara.gps.mapper.GpsEquipmentSonMapper; +import org.dromara.gps.service.IGpsEquipmentSonService; +import org.dromara.project.domain.BusUserProjectRelevancy; +import org.dromara.project.mapper.BusUserProjectRelevancyMapper; +import org.dromara.quality.domain.QltQualityInspection; +import org.dromara.quality.domain.dto.qualityinspection.QltQualityInspectionQueryReq; +import org.dromara.quality.domain.vo.qualityinspection.QltQualityInspectionVo; +import org.dromara.quality.service.IQltQualityInspectionService; +import org.dromara.safety.domain.HseSafetyInspection; +import org.dromara.safety.domain.dto.safetyinspection.HseSafetyInspectionQueryReq; +import org.dromara.safety.domain.dto.teammeeting.HseTeamMeetingQueryReq; +import org.dromara.safety.domain.vo.safetyinspection.HseSafetyInspectionVo; +import org.dromara.safety.domain.vo.teammeeting.HseTeamMeetingVo; +import org.dromara.safety.service.IHseSafetyInspectionService; +import org.dromara.safety.service.IHseTeamMeetingService; +import org.dromara.system.domain.SysRole; +import org.dromara.system.domain.SysUserRole; +import org.dromara.system.mapper.SysRoleMapper; +import org.dromara.system.mapper.SysUserRoleMapper; +import org.dromara.system.service.ISysRoleService; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + + +/** + * 大屏-质安管理 + * + * @author Lion Li + * @date 2025-11-05 + */ +@RequiredArgsConstructor +@Service +@Slf4j +public class DpzaglServiceImpl implements DpzaglService { + + //站班会 + private final IHseTeamMeetingService teamMeetingService; + //质量-检查工单 + private final IQltQualityInspectionService qualityInspectionService; + +// 安全工单 + private final IHseSafetyInspectionService safetyInspectionService; + + + private final SysRoleMapper sysRoleMapper; + + + private final SysUserRoleMapper sysUserRoleMapper; + + + private final GpsEquipmentSonMapper gpsEquipmentSonMapper; + + + private final BusUserProjectRelevancyMapper busUserProjectRelevancyMapper; + + + @Override + public DpznglVo queryList(DpznglBo bo) { + DpznglVo dpznglVo = new DpznglVo(); + PageQuery pageQuery = new PageQuery(bo.getPageSize(),bo.getPageNum()); +// 质量 + saveZl(pageQuery,dpznglVo); +// 安全 + saveAq(pageQuery,dpznglVo); + + + return dpznglVo; + } + + @Override + public List listByAqy(DpznglBo bo) { + List dpznglAqyVos = new ArrayList<>(); + if (bo == null || bo.getProjectId() == null) throw new RuntimeException("项目不能为空"); + +//// 查询该项目下的人员id +// List busUserProjectRelevancies = busUserProjectRelevancyMapper.selectList(new LambdaQueryWrapper().eq(BusUserProjectRelevancy::getProjectId, bo.getProjectId())); +// if (busUserProjectRelevancies == null || busUserProjectRelevancies.size() == 0){ +// return dpznglAqyVos; +// } + +// 查询拥有安全员的角色 + List sysRoles = sysRoleMapper.selectList(new LambdaQueryWrapper().eq(SysRole::getRoleIdentity, DpEnum.JSLX_AQY.getTypeValue())); + if (sysRoles == null || sysRoles.size() == 0){ + return dpznglAqyVos; + } + +// 根据角色查询人员 + List roles = sysRoles.stream().map(SysRole::getRoleId).collect(Collectors.toList()); + List sysUserRoles = sysUserRoleMapper.selectList(new LambdaQueryWrapper().in(SysUserRole::getRoleId, roles).groupBy(SysUserRole::getUserId)); + if (sysUserRoles == null && sysUserRoles.size() == 0){ + return dpznglAqyVos; + } + +// 查询人员的最新经纬度 + List collect = sysUserRoles.stream().map(SysUserRole::getUserId).collect(Collectors.toList()); + if (collect == null || collect.size() == 0){ + return dpznglAqyVos; + } + List temp = gpsEquipmentSonMapper.listByAqy(collect,bo.getProjectId()); + if (temp != null && temp.size() > 0){ +// 回填数据 + dpznglAqyVos = temp.stream().map(gpsEquipmentSon -> { + DpznglAqyVo dpznglAqyVo = new DpznglAqyVo(); + dpznglAqyVo.setUserId(gpsEquipmentSon.getUserId()); + dpznglAqyVo.setLocLatitude(gpsEquipmentSon.getLocLatitude()); + dpznglAqyVo.setLocLongitude(gpsEquipmentSon.getLocLongitude()); + return dpznglAqyVo; + }).collect(Collectors.toList()); +// 判断是否离岗 + } + + return dpznglAqyVos; + } + + @Override + public DpznglVo listByzbh(DpznglBo bo) { + DpznglVo dpznglVo = new DpznglVo(); + + // 站班会 + HseTeamMeetingQueryReq hseTeamMeetingQueryReq = new HseTeamMeetingQueryReq(); + List hseTeamMeetingVos = teamMeetingService.queryList(hseTeamMeetingQueryReq); + dpznglVo.setZbhList(hseTeamMeetingVos); + return dpznglVo; + } + + + private void saveAq(PageQuery pageQuery, DpznglVo dpznglVo) { + + // 安全 巡检工单,整改情况 + HseSafetyInspectionQueryReq req = new HseSafetyInspectionQueryReq(); +// 质量展示数据 + TableDataInfo anList = safetyInspectionService.queryPageList(req, pageQuery); +// 质量展示数据-整改 + req.setStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); + TableDataInfo aqZgList = safetyInspectionService.queryPageList(req, pageQuery); +// 质量总数(用于判断巡检类型) + List list = safetyInspectionService.list(); + + List rows = anList.getRows(); + + if (rows != null && rows.size() > 0){ + dpznglVo.setAqZS(anList.getTotal()); + dpznglVo.setAqList(rows); + dpznglVo.setZxjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_ZXGL.getTypeValue().equals(zl.getCheckType())).count()); + dpznglVo.setDqjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getCheckType())).count()); + dpznglVo.setRcxjAq(list.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getCheckType())).count()); + dpznglVo.setAqZgsl(list.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getStatus())).count()); + } + if (aqZgList.getRows() != null && aqZgList.getRows().size() > 0){ + dpznglVo.setAqZgList(aqZgList.getRows()); + } + + + } + + private void saveZl(PageQuery pageQuery,DpznglVo dpznglVo) { + +// 质量 巡检工单,整改情况 + QltQualityInspectionQueryReq req = new QltQualityInspectionQueryReq(); +// 质量展示数据 + TableDataInfo zlLists = qualityInspectionService.queryPageList(req, pageQuery); +// 质量展示数据-整改 + req.setInspectionStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); + TableDataInfo zlZgLists = qualityInspectionService.queryPageList(req, pageQuery); +// 质量总数(用于判断巡检类型) + List zsZl = qualityInspectionService.list(); + + + List rows = zlLists.getRows(); + if (rows != null && rows.size() > 0){ + dpznglVo.setZlZS(zlLists.getTotal()); + dpznglVo.setZlList(rows); + dpznglVo.setZxjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_ZXGL.getTypeValue().equals(zl.getInspectionType())).count()); + dpznglVo.setDqjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getInspectionType())).count()); + dpznglVo.setRcxjZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getInspectionType())).count()); + dpznglVo.setZlZgsl(zsZl.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getInspectionStatus())).count()); + } + if (zlZgLists.getRows() != null && zlZgLists.getRows().size() > 0){ + dpznglVo.setZlZgList(zlZgLists.getRows()); + } + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/gps/mapper/GpsEquipmentSonMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/gps/mapper/GpsEquipmentSonMapper.java index 8d46c768..aed02b38 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/gps/mapper/GpsEquipmentSonMapper.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/gps/mapper/GpsEquipmentSonMapper.java @@ -154,4 +154,17 @@ public interface GpsEquipmentSonMapper extends BaseMapperPlus getUeUserListByProjectId(@Param("startTime") LocalDateTime startOfDay, @Param("endTime") LocalDateTime now); + + + + @Select("") + List listByAqy(@Param("collect") List collect, @Param("projectId") Long projectId); } From 76595c151007f327c7cf062f66bcca8413742d23 Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Tue, 16 Dec 2025 14:59:45 +0800 Subject: [PATCH 07/38] =?UTF-8?q?=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/bigscreen/domain/bo/DpznglBo.java | 13 +++++ .../bigscreen/domain/vo/DpznglAqyVo.java | 6 ++ .../org/dromara/bigscreen/enums/DpEnum.java | 2 + .../service/impl/DpzaglServiceImpl.java | 57 +++++++++++++++---- 4 files changed, 67 insertions(+), 11 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/bo/DpznglBo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/bo/DpznglBo.java index c7aadd36..7ea8cf1d 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/bo/DpznglBo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/bo/DpznglBo.java @@ -4,6 +4,7 @@ package org.dromara.bigscreen.domain.bo; import lombok.Data; import java.io.Serializable; +import java.time.LocalDate; @Data public class DpznglBo implements Serializable { @@ -25,4 +26,16 @@ public class DpznglBo implements Serializable { private Long projectId; + + /** + * 开始时间 + */ + private LocalDate startDate; + + /** + * 结束时间 + */ + private LocalDate endDate; + + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java index 308b1ed4..55dfb928 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java @@ -28,4 +28,10 @@ public class DpznglAqyVo implements Serializable { private BigDecimal locLongitude; + /** + * 是否在岗 + */ + private String sfzg ; + + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java index 090c1c82..130bd61b 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/DpEnum.java @@ -6,6 +6,8 @@ public enum DpEnum { ZLGLLX_DQJC("定期检查", "2"), ZLGLLX_RCXJ("日常巡检", "3"), ZLGDZT_ZG("工单状态-整改", "2"), + RYZT_ZG("人员状态-在岗", "1"), + RYZT_LG("工单状态-离岗", "0"), JSLX_AQY("角色类型-安全员", "SAFETY_OFFICER"); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java index 30edcc08..3f45b224 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java @@ -8,13 +8,18 @@ import org.dromara.bigscreen.domain.vo.DpznglAqyVo; import org.dromara.bigscreen.domain.vo.DpznglVo; import org.dromara.bigscreen.enums.DpEnum; import org.dromara.bigscreen.service.DpzaglService; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.domain.GeoPoint; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.utils.JSTUtil; import org.dromara.gps.domain.GpsEquipmentSon; import org.dromara.gps.mapper.GpsEquipmentSonMapper; import org.dromara.gps.service.IGpsEquipmentSonService; +import org.dromara.project.domain.BusProjectPunchrange; import org.dromara.project.domain.BusUserProjectRelevancy; import org.dromara.project.mapper.BusUserProjectRelevancyMapper; +import org.dromara.project.service.IBusProjectPunchrangeService; import org.dromara.quality.domain.QltQualityInspection; import org.dromara.quality.domain.dto.qualityinspection.QltQualityInspectionQueryReq; import org.dromara.quality.domain.vo.qualityinspection.QltQualityInspectionVo; @@ -66,6 +71,8 @@ public class DpzaglServiceImpl implements DpzaglService { private final GpsEquipmentSonMapper gpsEquipmentSonMapper; + private final IBusProjectPunchrangeService busProjectPunchrangeService; + private final BusUserProjectRelevancyMapper busUserProjectRelevancyMapper; @@ -75,9 +82,9 @@ public class DpzaglServiceImpl implements DpzaglService { DpznglVo dpznglVo = new DpznglVo(); PageQuery pageQuery = new PageQuery(bo.getPageSize(),bo.getPageNum()); // 质量 - saveZl(pageQuery,dpznglVo); + saveZl(pageQuery,dpznglVo,bo); // 安全 - saveAq(pageQuery,dpznglVo); + saveAq(pageQuery,dpznglVo,bo); return dpznglVo; @@ -123,11 +130,36 @@ public class DpzaglServiceImpl implements DpzaglService { return dpznglAqyVo; }).collect(Collectors.toList()); // 判断是否离岗 + judgeFw(dpznglAqyVos,bo.getProjectId()); } return dpznglAqyVos; } + private void judgeFw(List dpznglAqyVos, Long projectId) { +// 获取该项目的打卡范围 + List busProjectPunchranges = busProjectPunchrangeService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(BusProjectPunchrange::getProjectId, projectId)); + if (busProjectPunchranges == null || busProjectPunchranges.size() == 0){ + return; + } + + for (DpznglAqyVo dpznglAqyVo : dpznglAqyVos) { + dpznglAqyVo.setSfzg(DpEnum.RYZT_LG.getTypeValue()); + + for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) { + List coordinates = List.of(busProjectPunchrange.getPunchRange()); + List matchingRange = JSTUtil.findMatchingRange(dpznglAqyVo.getLocLatitude().toString(), dpznglAqyVo.getLocLongitude().toString(), coordinates); + if (matchingRange != null && matchingRange.size() > 0){ + dpznglAqyVo.setSfzg(DpEnum.RYZT_ZG.getTypeValue()); + } + + } + } + + + + } + @Override public DpznglVo listByzbh(DpznglBo bo) { DpznglVo dpznglVo = new DpznglVo(); @@ -140,7 +172,7 @@ public class DpzaglServiceImpl implements DpzaglService { } - private void saveAq(PageQuery pageQuery, DpznglVo dpznglVo) { + private void saveAq(PageQuery pageQuery, DpznglVo dpznglVo,DpznglBo bo) { // 安全 巡检工单,整改情况 HseSafetyInspectionQueryReq req = new HseSafetyInspectionQueryReq(); @@ -169,23 +201,26 @@ public class DpzaglServiceImpl implements DpzaglService { } - private void saveZl(PageQuery pageQuery,DpznglVo dpznglVo) { + private void saveZl(PageQuery pageQuery,DpznglVo dpznglVo,DpznglBo bo) { // 质量 巡检工单,整改情况 QltQualityInspectionQueryReq req = new QltQualityInspectionQueryReq(); -// 质量展示数据 - TableDataInfo zlLists = qualityInspectionService.queryPageList(req, pageQuery); + +//// 质量展示数据 +// TableDataInfo zlLists = qualityInspectionService.queryPageList(req, pageQuery); // 质量展示数据-整改 req.setInspectionStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); TableDataInfo zlZgLists = qualityInspectionService.queryPageList(req, pageQuery); // 质量总数(用于判断巡检类型) - List zsZl = qualityInspectionService.list(); + List zsZl = qualityInspectionService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .eq(QltQualityInspection::getInspectionType,DpEnum.ZLGDZT_ZG.getTypeValue())); - List rows = zlLists.getRows(); - if (rows != null && rows.size() > 0){ - dpznglVo.setZlZS(zlLists.getTotal()); - dpznglVo.setZlList(rows); +// List rows = zlLists.getRows(); + if (zsZl != null && zsZl.size() > 0){ + dpznglVo.setZlZS(Long.valueOf(zsZl.size())); + dpznglVo.setZlList(MapstructUtils.convert(zsZl, QltQualityInspectionVo.class)); dpznglVo.setZxjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_ZXGL.getTypeValue().equals(zl.getInspectionType())).count()); dpznglVo.setDqjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getInspectionType())).count()); dpznglVo.setRcxjZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getInspectionType())).count()); From 975d3e6f32948cf8ac43300c0243033079f893e6 Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Tue, 16 Dec 2025 16:08:23 +0800 Subject: [PATCH 08/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BB=E5=8F=96=20CA?= =?UTF-8?q?D=20=E6=A1=A9=E7=82=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/common/utils/JtsPointMatcher.java | 32 ++++++ .../domain/dto/geojson/FacFeature.java | 8 +- .../domain/dto/geojson/FacGeometry.java | 7 +- ...tovoltaicPanelPartsCreateByGeoJsonReq.java | 3 +- .../FacPhotovoltaicPanelPartsServiceImpl.java | 99 +++++++++++++++---- 5 files changed, 129 insertions(+), 20 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/JtsPointMatcher.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/JtsPointMatcher.java index c5001a21..0f77ae72 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/JtsPointMatcher.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/JtsPointMatcher.java @@ -79,6 +79,38 @@ public class JtsPointMatcher { return matched; } + /** + * 计算多边形的中心点 + * + * @param points 多边形的顶点坐标 + * @return 中心点的坐标 + */ + public static List polygonCentroid(List> points) { + double area = 0; + double cx = 0; + double cy = 0; + + int size = points.size(); + for (int i = 0; i < size - 1; i++) { + double x0 = points.get(i).get(0); + double y0 = points.get(i).get(1); + double x1 = points.get(i + 1).get(0); + double y1 = points.get(i + 1).get(1); + + double cross = x0 * y1 - x1 * y0; + area += cross; + cx += (x0 + x1) * cross; + cy += (y0 + y1) * cross; + } + + area *= 0.5; + cx /= (6 * area); + cy /= (6 * area); + + return List.of(cx, cy); + } + + public static void main(String[] args) { // A列表:待匹配点 List listA = List.of( diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/geojson/FacFeature.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/geojson/FacFeature.java index 17402135..a1741421 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/geojson/FacFeature.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/geojson/FacFeature.java @@ -4,6 +4,9 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serial; +import java.io.Serializable; + /** * @author lilemy * @date 2025/4/24 17:38 @@ -11,7 +14,10 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor -public class FacFeature { +public class FacFeature implements Serializable { + + @Serial + private static final long serialVersionUID = -6103275857879306244L; private String type; diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/geojson/FacGeometry.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/geojson/FacGeometry.java index 5cedddae..079d2ea5 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/geojson/FacGeometry.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/geojson/FacGeometry.java @@ -4,6 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serial; +import java.io.Serializable; import java.util.List; /** @@ -13,7 +15,10 @@ import java.util.List; @Data @NoArgsConstructor @AllArgsConstructor -public class FacGeometry { +public class FacGeometry implements Serializable { + + @Serial + private static final long serialVersionUID = -2582318447932685848L; private String type; diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/photovoltaicpanelparts/FacPhotovoltaicPanelPartsCreateByGeoJsonReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/photovoltaicpanelparts/FacPhotovoltaicPanelPartsCreateByGeoJsonReq.java index 80fd1645..84ed1927 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/photovoltaicpanelparts/FacPhotovoltaicPanelPartsCreateByGeoJsonReq.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/dto/photovoltaicpanelparts/FacPhotovoltaicPanelPartsCreateByGeoJsonReq.java @@ -1,6 +1,7 @@ package org.dromara.facility.domain.dto.photovoltaicpanelparts; import lombok.Data; +import org.dromara.facility.domain.dto.geojson.FacGeoJson; import org.dromara.facility.domain.dto.geojson.FacGeoJsonByPoint; import java.io.Serial; @@ -24,7 +25,7 @@ public class FacPhotovoltaicPanelPartsCreateByGeoJsonReq implements Serializable /** * 桩点、立柱、支架 GeoJson */ - private FacGeoJsonByPoint locationGeoJson; + private FacGeoJson locationGeoJson; /** * 批次上传标识 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacPhotovoltaicPanelPartsServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacPhotovoltaicPanelPartsServiceImpl.java index 2581071c..733dadcd 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacPhotovoltaicPanelPartsServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacPhotovoltaicPanelPartsServiceImpl.java @@ -24,7 +24,7 @@ import org.dromara.facility.domain.FacPhotovoltaicPanel; import org.dromara.facility.domain.FacPhotovoltaicPanelColumn; import org.dromara.facility.domain.FacPhotovoltaicPanelPoint; import org.dromara.facility.domain.FacPhotovoltaicPanelSupport; -import org.dromara.facility.domain.dto.geojson.FacFeatureByPoint; +import org.dromara.facility.domain.dto.geojson.FacFeature; import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsCreateByGeoJsonReq; import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsCreateReq; import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsQueryReq; @@ -38,6 +38,7 @@ import org.dromara.progress.constant.PgsProgressCategoryConstant; import org.dromara.progress.domain.PgsProgressCategory; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailRecognizerVo; import org.dromara.progress.service.IPgsProgressCategoryService; +import org.dromara.project.domain.BusProject; import org.dromara.project.service.IBusProjectService; import org.locationtech.jts.geom.Coordinate; import org.springframework.beans.BeanUtils; @@ -146,12 +147,19 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan // 第一次接收请求,进行数据校验 int batchNum = geoJson.getBatchNum(); if (batchNum == 1) { - if (projectService.getById(projectId) == null) { + BusProject project = projectService.getById(projectId); + if (project == null) { throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND); } + Long pId = project.getPId(); + List subProject = projectService.lambdaQuery() + .eq(BusProject::getPId, pId) + .list(); + List projectIds = subProject.stream().map(BusProject::getId).collect(Collectors.toList()); + projectIds.add(projectId); // 查询项目下光伏板 Long count = photovoltaicPanelService.lambdaQuery() - .eq(FacPhotovoltaicPanel::getProjectId, projectId).count(); + .in(FacPhotovoltaicPanel::getProjectId, projectIds).count(); if (count <= 0) { throw new ServiceException("项目下无光伏板信息,请先创建光伏板信息后再添加桩点、立柱、支架信息", HttpStatus.NOT_FOUND); } @@ -159,7 +167,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan // 获取 redis key String sessionId = geoJson.getSessionId(); int totalBatch = geoJson.getTotalBatch(); - List dataList = geoJson.getLocationGeoJson().getFeatures(); + List dataList = geoJson.getLocationGeoJson().getFeatures(); String redisKey = FacRedisKeyConstant.getBatchUploadPartsRedisKey(sessionId, batchNum); // 存储到 Redis,设置过期时间 30 分钟 redisTemplate.opsForValue().set(redisKey, dataList, 1800, TimeUnit.SECONDS); @@ -172,13 +180,13 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan messageDto.setProjectId(projectId); // 如果是最后一批,开始合并 if (batchNum == totalBatch) { - List allData = new ArrayList<>(); + List allData = new ArrayList<>(); for (int i = 1; i <= totalBatch; i++) { String batchKey = FacRedisKeyConstant.getBatchUploadPartsRedisKey(sessionId, i); Object batchObj = redisTemplate.opsForValue().get(batchKey); if (batchObj instanceof List) { @SuppressWarnings("unchecked") - List batch = (List) batchObj; + List batch = (List) batchObj; allData.addAll(batch); } } @@ -222,11 +230,19 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan * @param features 数据 * @param userId 操作用户id */ - private void saveBatch(Long projectId, List features, Long userId) { + private void saveBatch(Long projectId, List features, Long userId) { + BusProject project = projectService.getById(projectId); + Long pId = project.getPId(); + List subProject = projectService.lambdaQuery() + .eq(BusProject::getPId, pId) + .list(); + List projectIds = subProject.stream().map(BusProject::getId).collect(Collectors.toList()); + projectIds.add(projectId); // 获取进度类别 Map List progressCategoryList = progressCategoryService.lambdaQuery() - .select(PgsProgressCategory::getId, PgsProgressCategory::getName, PgsProgressCategory::getMatrixId, PgsProgressCategory::getWorkType) - .eq(PgsProgressCategory::getProjectId, projectId) + .select(PgsProgressCategory::getId, PgsProgressCategory::getName, PgsProgressCategory::getProjectId, + PgsProgressCategory::getMatrixId, PgsProgressCategory::getWorkType) + .in(PgsProgressCategory::getProjectId, projectIds) .and(lqw -> lqw .likeRight(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE + "_") .or() @@ -241,7 +257,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan )); // 查询项目下光伏板 List photovoltaicPanelList = photovoltaicPanelService.lambdaQuery() - .eq(FacPhotovoltaicPanel::getProjectId, projectId) + .in(FacPhotovoltaicPanel::getProjectId, projectIds) .list(); Map photovoltaicPanelMap = photovoltaicPanelList.stream() .collect(Collectors.toMap( @@ -256,7 +272,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan FacPhotovoltaicPanelPoint::getFinishType, FacPhotovoltaicPanelPoint::getFinishDate, FacPhotovoltaicPanelPoint::getStatus) - .eq(FacPhotovoltaicPanelPoint::getProjectId, projectId) + .in(FacPhotovoltaicPanelPoint::getProjectId, projectIds) .list(); Map oldPointMap = oldPointList.stream() .collect(Collectors.toMap( @@ -270,7 +286,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan FacPhotovoltaicPanelColumn::getFinishType, FacPhotovoltaicPanelColumn::getFinishDate, FacPhotovoltaicPanelColumn::getStatus) - .eq(FacPhotovoltaicPanelColumn::getProjectId, projectId) + .in(FacPhotovoltaicPanelColumn::getProjectId, projectIds) .list(); Map oldColumnMap = oldColumnList.stream() .collect(Collectors.toMap( @@ -284,7 +300,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan FacPhotovoltaicPanelSupport::getFinishType, FacPhotovoltaicPanelSupport::getFinishDate, FacPhotovoltaicPanelSupport::getStatus) - .eq(FacPhotovoltaicPanelSupport::getProjectId, projectId) + .in(FacPhotovoltaicPanelSupport::getProjectId, projectIds) .list(); Map oldSupportMap = oldSupportList.stream() .collect(Collectors.toMap( @@ -299,7 +315,15 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan try (ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())) { // 所有点列表 List> pointPositionList = new ArrayList<>(features.stream() - .map(featureByPoint -> featureByPoint.getGeometry().getCoordinates()) + .map(feature -> { + String type = feature.getProperties().getType(); + List coordinates = feature.getGeometry().getCoordinates(); + if (type.equalsIgnoreCase("CIRCLE")) { + return JtsPointMatcher.polygonCentroid(castToDoubleList(coordinates)); + } else { + return toDoubleList(coordinates); + } + }) .toList()); // 多线程处理 List> futures = new ArrayList<>(); @@ -324,7 +348,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan if (CollUtil.isNotEmpty(categoryList)) { for (PgsProgressCategory category : categoryList) { FacPhotovoltaicPanelPoint point = new FacPhotovoltaicPanelPoint(); - point.setProjectId(projectId); + point.setProjectId(category.getProjectId()); point.setMatrixId(matrixId); point.setName(name); point.setPositions(jsonStr); @@ -349,7 +373,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan if (CollUtil.isNotEmpty(categoryList)) { for (PgsProgressCategory category : categoryList) { FacPhotovoltaicPanelColumn column = new FacPhotovoltaicPanelColumn(); - column.setProjectId(projectId); + column.setProjectId(category.getProjectId()); column.setMatrixId(matrixId); column.setName(name); column.setPositions(jsonStr); @@ -374,7 +398,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan if (CollUtil.isNotEmpty(categoryList)) { for (PgsProgressCategory category : categoryList) { FacPhotovoltaicPanelSupport support = new FacPhotovoltaicPanelSupport(); - support.setProjectId(projectId); + support.setProjectId(category.getProjectId()); support.setMatrixId(matrixId); support.setName(name); support.setPositions(jsonStr); @@ -941,4 +965,45 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan } } + /** + * 将原始数据转换为List> + * + * @param rawList 原始数据 + * @return 转换后的数据 + */ + public static List> castToDoubleList(List rawList) { + List> result = new ArrayList<>(); + + for (Object item : rawList) { + if (item instanceof List innerList) { + List point = new ArrayList<>(); + for (Object value : innerList) { + if (value instanceof Number num) { + point.add(num.doubleValue()); + } + } + result.add(point); + } + } + return result; + } + + /** + * 将原始数据转换为 List + * + * @param list 原始数据 + * @return 转换后的数据 + */ + public static List toDoubleList(List list) { + return list.stream() + .filter(Objects::nonNull) + .map(o -> { + if (o instanceof Number n) { + return n.doubleValue(); + } + throw new IllegalArgumentException("非数字类型:" + o); + }) + .toList(); + } + } From ea626dfeff4f979dda4a6f15ce1415df90435d85 Mon Sep 17 00:00:00 2001 From: dfdg <2710245601@qq.com> Date: Tue, 16 Dec 2025 17:09:10 +0800 Subject: [PATCH 09/38] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialsManagementController.java | 105 +++++++++ .../vo/InventoryStructureAnalysisVo.java | 68 ++++++ .../vo/designAndArrivalComparisonVo.java | 40 ++++ .../bigscreen/domain/vo/wzxqysjdhdbVo.java | 35 +++ .../dromara/bigscreen/enums/WuZhiEnum.java | 22 ++ .../service/IMaterialsManagementService.java | 20 ++ .../impl/MaterialsManagementServiceImpl.java | 203 ++++++++++++++++++ .../domain/BusMaterialbatchdemandplan.java | 6 + .../bo/BusMaterialbatchdemandplanBo.java | 5 + .../vo/BusMaterialbatchdemandplanVo.java | 5 + .../service/IBusMrpBaseService.java | 12 ++ .../service/IBusPurchaseDocService.java | 2 + .../service/impl/BusMrpBaseServiceImpl.java | 87 ++++++++ .../impl/BusPurchaseDocServiceImpl.java | 9 + .../domain/MatMaterialIssueItem.java | 5 + .../domain/MatMaterialReceiveItem.java | 5 + .../materials/domain/MatMaterials.java | 6 + .../MatMaterialIssueItemDto.java | 5 + .../MatMaterialIssueItemWordDto.java | 3 + .../MatMaterialReceiveItemDto.java | 5 + .../MatMaterialReceiveItemWordDto.java | 7 + .../dto/materials/MatMaterialsCreateReq.java | 6 + .../dto/materials/MatMaterialsQueryReq.java | 6 + .../dto/materials/MatMaterialsUpdateReq.java | 7 + .../MatMaterialIssueItemVo.java | 6 + .../MatMaterialReceiveItemVo.java | 5 + .../vo/materials/MatMaterialsNumberVo.java | 5 + .../domain/vo/materials/MatMaterialsVo.java | 6 + .../service/IMatMaterialsService.java | 24 +++ .../impl/MatMaterialIssueServiceImpl.java | 1 + .../impl/MatMaterialReceiveServiceImpl.java | 1 + .../service/impl/MatMaterialsServiceImpl.java | 105 +++++++++ .../service/BigScreenWebSocketServer.java | 98 +++++++-- 33 files changed, 910 insertions(+), 15 deletions(-) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/InventoryStructureAnalysisVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/designAndArrivalComparisonVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/wzxqysjdhdbVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/WuZhiEnum.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java new file mode 100644 index 00000000..2ba79053 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java @@ -0,0 +1,105 @@ +package org.dromara.bigscreen.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import lombok.RequiredArgsConstructor; +import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; +import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo; +import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.dromara.bigscreen.service.IMaterialsManagementService; +import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo; +import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; +import org.dromara.cailiaoshebei.service.IBusMrpBaseService; +import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; +import org.dromara.common.core.domain.R; +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.materials.domain.dto.materials.MatMaterialsQueryReq; +import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; +import org.dromara.materials.service.IMatMaterialsService; +import org.dromara.project.domain.vo.project.BusProjectGisVo; +import org.springframework.beans.factory.annotation.Autowired; +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.util.List; + + +/** + * 物资管理 + */ +@Validated +@RestController +@RequiredArgsConstructor +@RequestMapping("/materialsManagement") +public class MaterialsManagementController extends BaseController { + + @Autowired + private IMaterialsManagementService materialsManagementService; + @Autowired + private IBusPurchaseDocService busPurchaseDocService; + @Autowired + private IBusMrpBaseService busMrpBaseService; + @Autowired + private IMatMaterialsService materialsService; + + /** + * 库存结构分析 + * @return + */ + @GetMapping("/inventoryStructureAnalysis") + public R inventoryStructureAnalysis(Long projectId) { + return R.ok(materialsManagementService.inventoryStructureAnalysis(projectId)); + } + + /** + * 采购单 + * @return + */ + @GetMapping("/purchaseNote") + public R> purchaseNote(Long projectId) { + return R.ok(busPurchaseDocService.purchaseNote(projectId)); + } + /** + * 获取采购单详情 + * @return + */ + @GetMapping("/purchaseNoteDetail") + public R purchaseNoteDetail(Long id) { + return R.ok(busPurchaseDocService.queryById(id)); + } + + /** + * 获取采购单详情PDF + */ + @GetMapping("/purchaseNoteDetailPdf") + public R purchaseNoteDetailPdf(Long id) { + return R.ok(busPurchaseDocService.queryPicBase64ById(id)); + } + + /** + * 设计量与到货量对比 + */ + @GetMapping("/designAndArrivalComparison") + public R> designAndArrivalComparison(Long projectId) { + return R.ok(busMrpBaseService.designAndArrivalComparison(projectId)); + } + /** + * 物资需求与实际到货对比 + */ + @GetMapping("/wzxqysjdhdb") + public R> wzxqysjdhdb(Long projectId) { + return R.ok(busMrpBaseService.wzxqysjdhdb(projectId)); + } + + /** + * 获取材料使用详情列表 + */ + @GetMapping("/listUseDetail") + public R> listUseDetail(Long projectId) { + return R.ok(materialsService.listUseDetail(projectId)); + } + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/InventoryStructureAnalysisVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/InventoryStructureAnalysisVo.java new file mode 100644 index 00000000..ca98bdb1 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/InventoryStructureAnalysisVo.java @@ -0,0 +1,68 @@ +package org.dromara.bigscreen.domain.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class InventoryStructureAnalysisVo implements Serializable { + + /** + * 本月入库总价 + */ + public BigDecimal enterTotalPrices; + + /** + * 上月入库总价 + */ + public BigDecimal oldEnterTotalPrices; + + + /** + * 本月出库总价 + */ + public BigDecimal leaveTotalPrices; + + /** + * 上月出库总价 + */ + public BigDecimal oldLeaveTotalPrices; + + /** + * 库存总价 + */ + public BigDecimal inventoryTotalPrices; + + /** + * 出库总价 + */ + public BigDecimal outTotalPrices; + + /** + * 库存逆变器总价 + */ + public BigDecimal inventoryInverterTotalPrices; + + /** + * 库存箱变总价 + */ + public BigDecimal inventoryBoxTransformerTotalPrices; + + /** + * 库存光伏支架总价 + */ + public BigDecimal inventoryPhotovoltaicSupportTotalPrices; + + /** + * 库存环网柜总价 + */ + public BigDecimal inventoryCircuitBreakerTotalPrices; + + /** + * 当前库存总价 + */ + public BigDecimal nowInventoryTotalPrices; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/designAndArrivalComparisonVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/designAndArrivalComparisonVo.java new file mode 100644 index 00000000..3a26c5d9 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/designAndArrivalComparisonVo.java @@ -0,0 +1,40 @@ +package org.dromara.bigscreen.domain.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 设计量与到货量对比 + */ +@Data +public class designAndArrivalComparisonVo implements Serializable { + + /** + * 名称 + */ + public String name; + + /** + * 规格 + */ + public String specification; + + + /** + * 单位 + */ + public String unit; + + /** + * 设计量 + */ + public BigDecimal designTotalPrices; + + /** + * 到货量 + */ + public BigDecimal arrivalTotalPrices; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/wzxqysjdhdbVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/wzxqysjdhdbVo.java new file mode 100644 index 00000000..44e776ad --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/wzxqysjdhdbVo.java @@ -0,0 +1,35 @@ +package org.dromara.bigscreen.domain.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 物资需求与实际到货对比vo + */ +@Data +public class wzxqysjdhdbVo implements Serializable { + + /** + * 名称 + */ + public String name; + + /** + * 规格 + */ + public String specification; + + + /** + * 设计量 + */ + public BigDecimal designTotalPrices; + + /** + * 到货量 + */ + public BigDecimal arrivalTotalPrices; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/WuZhiEnum.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/WuZhiEnum.java new file mode 100644 index 00000000..3aee50d8 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/enums/WuZhiEnum.java @@ -0,0 +1,22 @@ +package org.dromara.bigscreen.enums; + +public enum WuZhiEnum { + + LBQ("逆变器"), + GFZJ("光伏支架"), + XB("箱变"), + HWG("环网柜"); + + + private final String TypeName; + + + + public String getTypeName() { + return TypeName; + } + + WuZhiEnum(String TypeName) { + this.TypeName = TypeName; + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java new file mode 100644 index 00000000..226d317c --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java @@ -0,0 +1,20 @@ +package org.dromara.bigscreen.service; + + +import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; +import org.dromara.project.domain.vo.project.BusProjectGisVo; + +import java.util.List; + +/** + * 物资管理大屏Service接口 + */ +public interface IMaterialsManagementService { + + /** + * 库存结构分析 + * @param projectId + * @return + */ + InventoryStructureAnalysisVo inventoryStructureAnalysis(Long projectId); +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java new file mode 100644 index 00000000..713106b9 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java @@ -0,0 +1,203 @@ +package org.dromara.bigscreen.service.impl; + + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import jakarta.annotation.Resource; +import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; +import org.dromara.bigscreen.enums.WuZhiEnum; +import org.dromara.bigscreen.service.IMaterialsManagementService; +import org.dromara.materials.domain.MatMaterialIssueItem; +import org.dromara.materials.domain.MatMaterialReceiveItem; +import org.dromara.materials.service.IMatMaterialIssueItemService; +import org.dromara.materials.service.IMatMaterialReceiveItemService; +import org.dromara.materials.service.IMatMaterialsInventoryService; +import org.dromara.materials.service.IMatMaterialsService; +import org.dromara.project.domain.vo.project.BusProjectGisVo; +import org.dromara.tender.domain.BusBillofquantitiesLimitList; +import org.dromara.tender.service.IBusBillofquantitiesLimitListService; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.temporal.TemporalAdjusters; +import java.util.ArrayList; +import java.util.List; + +@Service +public class MaterialsManagementServiceImpl implements IMaterialsManagementService { + + @Lazy + @Resource + private IMatMaterialReceiveItemService materialReceiveItemService; + + @Lazy + @Resource + private IMatMaterialIssueItemService materialIssueItemService; + + @Lazy + @Resource + private IMatMaterialsService materialsService; + @Lazy + @Resource + private IBusBillofquantitiesLimitListService billofquantitiesLimitListService; + + + @Override + public InventoryStructureAnalysisVo inventoryStructureAnalysis(Long projectId) { + InventoryStructureAnalysisVo vo = new InventoryStructureAnalysisVo(); + // 获取当月第一天 + LocalDateTime monthStart = LocalDateTime.now() + // 调整到当月第一天 + .with(TemporalAdjusters.firstDayOfMonth()) + // 重置时分秒毫秒为0 + .withHour(0) + .withMinute(0) + .withSecond(0) + .withNano(0); + // 获取当前时间 + LocalDateTime currentTime = LocalDateTime.now(); + // 获取上月第一天 + LocalDateTime lastMonthFirstDay = LocalDateTime.now() + // 先回退一个月 + .minusMonths(1) + // 调整到当月第一天 + .with(TemporalAdjusters.firstDayOfMonth()) + // 重置时间为 00:00:00.000000000 + .withHour(0) + .withMinute(0) + .withSecond(0); + // 获取上月最后一天 + LocalDateTime lastMonthLastDay = LocalDateTime.now() + // 先回退一个月 + .minusMonths(1) + // 调整到当月最后一天 + .with(TemporalAdjusters.lastDayOfMonth()) + // 设置时间为 23:59:59.999999999(纳秒最大值,对应毫秒级的999) + .withHour(23) + .withMinute(59) + .withSecond(59); + // 获取当月入库数据 + List matMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(MatMaterialReceiveItem::getProjectId, projectId) + .ne(MatMaterialReceiveItem::getAcceptedQuantity, BigDecimal.ZERO) + .between(MatMaterialReceiveItem::getCreateTime, monthStart, currentTime)); + if (CollUtil.isEmpty(matMaterialReceiveItems)){ + vo.setEnterTotalPrices(BigDecimal.ZERO); + } + // 计算本月入库金额 + matMaterialReceiveItems.forEach(item -> { + vo.setEnterTotalPrices(vo.getEnterTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice()))); + }); + vo.setEnterTotalPrices(vo.getEnterTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); + // 获取上月入库数据 + List oldMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(MatMaterialReceiveItem::getProjectId, projectId) + .ne(MatMaterialReceiveItem::getAcceptedQuantity, BigDecimal.ZERO) + .between(MatMaterialReceiveItem::getCreateTime, lastMonthFirstDay, lastMonthLastDay)); + if (CollUtil.isEmpty(oldMatMaterialReceiveItems)){ + vo.setOldEnterTotalPrices(BigDecimal.ZERO); + } + // 计算上月入库金额 + oldMatMaterialReceiveItems.forEach(item -> { + vo.setOldEnterTotalPrices(vo.getOldEnterTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice()))); + }); + vo.setOldEnterTotalPrices(vo.getOldEnterTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); + // 获取当月出库数据 + List matMaterialIssueItems = materialIssueItemService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .eq(MatMaterialIssueItem::getProjectId, projectId) + .ne(MatMaterialIssueItem::getIssuedQuantity, BigDecimal.ZERO) + .between(MatMaterialIssueItem::getCreateTime, monthStart, currentTime)); + + //计算本月出库金额 + if (CollUtil.isEmpty(matMaterialIssueItems)){ + vo.setLeaveTotalPrices(BigDecimal.ZERO); + } + matMaterialIssueItems.forEach(item -> { + vo.setLeaveTotalPrices(vo.getLeaveTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice()))); + }); + vo.setLeaveTotalPrices(vo.getLeaveTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); + // 获取上月出库数据 + List oldMatMaterialIssueItems = materialIssueItemService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .eq(MatMaterialIssueItem::getProjectId, projectId) + .ne(MatMaterialIssueItem::getIssuedQuantity, BigDecimal.ZERO) + .between(MatMaterialIssueItem::getCreateTime, lastMonthFirstDay, lastMonthLastDay)); + //计算上月出库金额 + if (CollUtil.isEmpty(oldMatMaterialIssueItems)){ + vo.setOldLeaveTotalPrices(BigDecimal.ZERO); + } + oldMatMaterialIssueItems.forEach(item -> { + vo.setOldLeaveTotalPrices(vo.getOldLeaveTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice()))); + }); + vo.setOldLeaveTotalPrices(vo.getOldLeaveTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); + //获取总入库存金额 入库 * 单价 + List totalMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(MatMaterialReceiveItem::getProjectId, projectId)); + if (CollUtil.isEmpty(totalMatMaterialReceiveItems)){ + vo.setInventoryTotalPrices(BigDecimal.ZERO); + } + totalMatMaterialReceiveItems.forEach(item -> { + vo.setInventoryTotalPrices(vo.getInventoryTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice()))); + }); + vo.setInventoryTotalPrices(vo.getInventoryTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); + // 获取总出库金额 出库 * 单价 + List totalMatMaterialIssueItems = materialIssueItemService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(MatMaterialIssueItem::getProjectId, projectId)); + if (CollUtil.isEmpty(totalMatMaterialIssueItems)){ + vo.setOutTotalPrices(BigDecimal.ZERO); + } + totalMatMaterialIssueItems.forEach(item -> { + vo.setOutTotalPrices(vo.getOutTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice()))); + }); + vo.setOutTotalPrices(vo.getOutTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); + + // 获取施工图一览大类名下所有小类名 + List limitLists = billofquantitiesLimitListService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(BusBillofquantitiesLimitList::getProjectId, projectId) + .eq(BusBillofquantitiesLimitList::getPid, "0") + .eq(BusBillofquantitiesLimitList::getType, "3") + .eq(BusBillofquantitiesLimitList::getName, WuZhiEnum.LBQ.getTypeName()).or() + .eq(BusBillofquantitiesLimitList::getName, WuZhiEnum.GFZJ.getTypeName()).or() + .eq(BusBillofquantitiesLimitList::getName, WuZhiEnum.XB.getTypeName()).or() + .eq(BusBillofquantitiesLimitList::getName, WuZhiEnum.HWG.getTypeName()) + ); + List lBQNames = new ArrayList<>(); + List sFZJNames = new ArrayList<>(); + List xBNames = new ArrayList<>(); + List hWGNames = new ArrayList<>(); + for (BusBillofquantitiesLimitList item : limitLists) { + if (item.getName().equals(WuZhiEnum.LBQ.getTypeName())) { + lBQNames.add(item.getName()); + continue; + } + if (item.getName().equals(WuZhiEnum.GFZJ.getTypeName())) { + sFZJNames.add(item.getName()); + continue; + } + if (item.getName().equals(WuZhiEnum.XB.getTypeName())) { + xBNames.add(item.getName()); + continue; + } + if (item.getName().equals(WuZhiEnum.HWG.getTypeName())) { + hWGNames.add(item.getName()); + } + } + //获取库存逆变器总价 + BigDecimal inventoryInverterTotalPrices = materialsService.selectTotalPricesByNames(projectId,lBQNames); + vo.setInventoryInverterTotalPrices(inventoryInverterTotalPrices); + //获取库存箱变总价 + BigDecimal inventoryBoxTransformerTotalPrices = materialsService.selectTotalPricesByNames(projectId,xBNames); + vo.setInventoryBoxTransformerTotalPrices(inventoryBoxTransformerTotalPrices); + //获取库存光伏支架总价 + BigDecimal inventoryPhotovoltaicSupportTotalPrices = materialsService.selectTotalPricesByNames(projectId,sFZJNames); + vo.setInventoryPhotovoltaicSupportTotalPrices(inventoryPhotovoltaicSupportTotalPrices); + //获取库存环网柜总价 + BigDecimal inventoryCircuitBreakerTotalPrices = materialsService.selectTotalPricesByNames(projectId,hWGNames); + vo.setInventoryCircuitBreakerTotalPrices(inventoryCircuitBreakerTotalPrices); + //获取当前库存总价 + BigDecimal nowInventoryTotalPrices = materialsService.selectTotalPrices(projectId); + vo.setNowInventoryTotalPrices(nowInventoryTotalPrices); + return vo; + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/BusMaterialbatchdemandplan.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/BusMaterialbatchdemandplan.java index 8c33e469..41c86c36 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/BusMaterialbatchdemandplan.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/BusMaterialbatchdemandplan.java @@ -94,6 +94,12 @@ public class BusMaterialbatchdemandplan extends BaseEntity { */ private BigDecimal demandQuantity; + + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 计划到场时间 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/bo/BusMaterialbatchdemandplanBo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/bo/BusMaterialbatchdemandplanBo.java index 90bf40fa..ea5b474e 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/bo/BusMaterialbatchdemandplanBo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/bo/BusMaterialbatchdemandplanBo.java @@ -93,6 +93,11 @@ public class BusMaterialbatchdemandplanBo extends BaseEntity { */ private BigDecimal demandQuantity; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 计划到场时间 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/vo/BusMaterialbatchdemandplanVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/vo/BusMaterialbatchdemandplanVo.java index 32443c22..dbdd4c4b 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/vo/BusMaterialbatchdemandplanVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/domain/vo/BusMaterialbatchdemandplanVo.java @@ -118,6 +118,11 @@ public class BusMaterialbatchdemandplanVo implements Serializable { @ExcelProperty(value = "需求数量") private BigDecimal demandQuantity; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 计划到场时间 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/IBusMrpBaseService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/IBusMrpBaseService.java index f2bf59e0..3506622e 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/IBusMrpBaseService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/IBusMrpBaseService.java @@ -1,5 +1,7 @@ package org.dromara.cailiaoshebei.service; +import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo; +import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseReq; import org.dromara.cailiaoshebei.domain.dto.BusMrpDto; import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto; @@ -90,4 +92,14 @@ public interface IBusMrpBaseService extends IService{ Map remaining(Long projectId,Long limitListId,Long mrpBaseId); List getListByName(BusMrpBaseReq req); + + /** + * 设计量与到货量对比 + */ + List designAndArrivalComparison(Long projectId); + + /** + * 物资需求与实际到货对比 + */ + List wzxqysjdhdb(Long projectId); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/IBusPurchaseDocService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/IBusPurchaseDocService.java index e0568498..4263c891 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/IBusPurchaseDocService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/IBusPurchaseDocService.java @@ -105,4 +105,6 @@ public interface IBusPurchaseDocService extends IService { * @return 是否修改成功 */ Boolean updateFeedback(FeedbackDto dto); + + List purchaseNote(Long projectId); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java index b2ae9a83..57f291b8 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java @@ -4,7 +4,10 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; +import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo; +import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; import org.dromara.cailiaoshebei.domain.BusMaterialbatchdemandplan; import org.dromara.cailiaoshebei.domain.BusPlanDocAssociation; import org.dromara.cailiaoshebei.domain.bo.BusMaterialbatchdemandplanBo; @@ -32,10 +35,15 @@ import lombok.RequiredArgsConstructor; import org.dromara.common.utils.excel.ExcelDynamicReader; import org.dromara.design.domain.BusBillofquantities; import org.dromara.design.service.IBusBillofquantitiesService; +import org.dromara.materials.domain.MatMaterialReceiveItem; +import org.dromara.materials.service.IMatMaterialReceiveItemService; import org.dromara.tender.domain.BusBillofquantitiesLimitList; import org.dromara.tender.domain.BusTenderPlanningLimitList; +import org.dromara.tender.enums.LimitListTypeEnum; import org.dromara.tender.service.IBusBillofquantitiesLimitListService; import org.dromara.tender.service.IBusTenderPlanningLimitListService; +import org.jetbrains.annotations.NotNull; +import org.springframework.context.annotation.Lazy; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo; @@ -70,6 +78,10 @@ public class BusMrpBaseServiceImpl extends ServiceImpl designAndArrivalComparison(Long projectId) { + // 获取施工图一览的所有材料数据 + List limitLists = busBillofquantitiesService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(BusBillofquantitiesLimitList::getProjectId, projectId) + .eq(BusBillofquantitiesLimitList::getType, LimitListTypeEnum.SPECIAL.getCode()) + .isNotNull(BusBillofquantitiesLimitList::getQuantity)); + Map wuZiMap = getWuZiMap(projectId); + // 根据批次需求计划的物资id获取到施工图一览对应数据 + List list = new ArrayList<>(); + limitLists.forEach(limitList -> { + designAndArrivalComparisonVo vo = new designAndArrivalComparisonVo(); + vo.setName(limitList.getName()); + vo.setSpecification(limitList.getSpecification()); + vo.setUnit(limitList.getUnit()); + vo.setDesignTotalPrices(limitList.getQuantity()); + vo.setArrivalTotalPrices(wuZiMap.getOrDefault(limitList.getId(), BigDecimal.ZERO)); + list.add(vo); + }); + return list; + } + + @NotNull + private Map getWuZiMap(Long projectId) { + // 获取所有入库数据 mat_material_receive_item + List matMaterialReceiveItems = matMaterialReceiveItemService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .eq(MatMaterialReceiveItem::getProjectId, projectId)); + //将相同计划批次数据进行分组合并 + Set planIds = matMaterialReceiveItems.stream() + .map(MatMaterialReceiveItem::getPlanId) + .collect(Collectors.toSet()); + Map planMap = matMaterialReceiveItems.stream() + .collect(Collectors.groupingBy( + MatMaterialReceiveItem::getPlanId, + Collectors.reducing(BigDecimal.ZERO, MatMaterialReceiveItem::getQuantity, BigDecimal::add) + )); + // 根据入库数据反查批次需求计划数据 bus_materialbatchdemandplan + List materialbatchdemandplans = planservice.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(BusMaterialbatchdemandplan::getProjectId, projectId) + .in(BusMaterialbatchdemandplan::getId, planIds)); + Map wuZiMap = new HashMap<>(); + materialbatchdemandplans.forEach(materialbatchdemandplan -> { + //merge()方法如果键存在则合并值,否则直接放入 + wuZiMap.merge( + materialbatchdemandplan.getSuppliespriceId(), + planMap.get(materialbatchdemandplan.getId()), + BigDecimal::add + ); + }); + return wuZiMap; + } + + @Override + public List wzxqysjdhdb(Long projectId) { + // 获取施工图一览的所有材料数据 + List limitLists = busBillofquantitiesService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(BusBillofquantitiesLimitList::getProjectId, projectId) + .eq(BusBillofquantitiesLimitList::getType, LimitListTypeEnum.SPECIAL.getCode()) + .isNotNull(BusBillofquantitiesLimitList::getQuantity)); + Map wuZiMap = getWuZiMap(projectId); + // 根据批次需求计划的物资id获取到施工图一览对应数据 + List list = new ArrayList<>(); + limitLists.forEach(limitList -> { + wzxqysjdhdbVo vo = new wzxqysjdhdbVo(); + vo.setName(limitList.getName()); + vo.setSpecification(limitList.getSpecification()); + vo.setDesignTotalPrices(limitList.getQuantity()); + vo.setArrivalTotalPrices(wuZiMap.getOrDefault(limitList.getId(), BigDecimal.ZERO)); + list.add(vo); + }); + return list; + } + /** * 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等) * 正常使用只需#processEvent.flowCode=='leave1' diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java index 00f3eef6..8d347e46 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java @@ -575,6 +575,15 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl purchaseNote(Long projectId) { + return baseMapper.selectVoList(new LambdaQueryWrapper() + .eq(BusPurchaseDoc::getProjectId, projectId) + .eq(BusPurchaseDoc::getDocType, "1") + .eq(BusPurchaseDoc::getStatus, BusinessStatusEnum.FINISH.getStatus()) + .orderByDesc(BusPurchaseDoc::getCreateTime)); + } + /** * 根据实体获取替换数据 * diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialIssueItem.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialIssueItem.java index b25fd8cc..feef1847 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialIssueItem.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialIssueItem.java @@ -54,6 +54,11 @@ public class MatMaterialIssueItem extends BaseEntity { */ private String unit; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 库存 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialReceiveItem.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialReceiveItem.java index 0062099b..a904fac3 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialReceiveItem.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialReceiveItem.java @@ -59,6 +59,11 @@ public class MatMaterialReceiveItem extends BaseEntity { */ private BigDecimal quantity; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 验收 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterials.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterials.java index 8cd58fa9..0d619716 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterials.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterials.java @@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode; import org.dromara.common.mybatis.core.domain.BaseEntity; import java.io.Serial; +import java.math.BigDecimal; /** * 材料名称对象 mat_materials @@ -68,6 +69,11 @@ public class MatMaterials extends BaseEntity { */ private String weightId; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 备注 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialissueitem/MatMaterialIssueItemDto.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialissueitem/MatMaterialIssueItemDto.java index 36c77066..4fc59f56 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialissueitem/MatMaterialIssueItemDto.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialissueitem/MatMaterialIssueItemDto.java @@ -45,6 +45,11 @@ public class MatMaterialIssueItemDto { @NotBlank(message = "单位不能为空") private String unit; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 库存 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialissueitem/MatMaterialIssueItemWordDto.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialissueitem/MatMaterialIssueItemWordDto.java index d47d7602..4cb744b3 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialissueitem/MatMaterialIssueItemWordDto.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialissueitem/MatMaterialIssueItemWordDto.java @@ -4,6 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.math.BigDecimal; + @Data @NoArgsConstructor @AllArgsConstructor @@ -13,6 +15,7 @@ public class MatMaterialIssueItemWordDto { private String name; // 名称 private String specification; // 规格 private String unit; // 单位 + private BigDecimal unitPrice; //单价 private Integer stockQuantity; // 库存数量 private Integer issuedQuantity; // 领取数量 private Integer remainingQuantity;// 剩余数量 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialreceiveitem/MatMaterialReceiveItemDto.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialreceiveitem/MatMaterialReceiveItemDto.java index 052bcceb..b356e076 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialreceiveitem/MatMaterialReceiveItemDto.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialreceiveitem/MatMaterialReceiveItemDto.java @@ -50,6 +50,11 @@ public class MatMaterialReceiveItemDto { */ private BigDecimal shortageQuantity; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 备注 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialreceiveitem/MatMaterialReceiveItemWordDto.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialreceiveitem/MatMaterialReceiveItemWordDto.java index 3509b27a..3eb45e7c 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialreceiveitem/MatMaterialReceiveItemWordDto.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materialreceiveitem/MatMaterialReceiveItemWordDto.java @@ -4,6 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.math.BigDecimal; + /** * @author lilemy * @date 2025/7/6 14:04 @@ -38,6 +40,11 @@ public class MatMaterialReceiveItemWordDto { */ private Integer quantity; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 验收 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsCreateReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsCreateReq.java index eacea168..922ec9f5 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsCreateReq.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsCreateReq.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Map; /** @@ -61,6 +62,11 @@ public class MatMaterialsCreateReq implements Serializable { */ private String weightId; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 备注 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsQueryReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsQueryReq.java index b861e7de..1e688ca8 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsQueryReq.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsQueryReq.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; /** * @author lilemy @@ -50,6 +51,11 @@ public class MatMaterialsQueryReq implements Serializable { */ private String weightId; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 预计材料数量 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsUpdateReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsUpdateReq.java index faf70848..90958f0f 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsUpdateReq.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/dto/materials/MatMaterialsUpdateReq.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Map; /** @@ -61,6 +62,12 @@ public class MatMaterialsUpdateReq implements Serializable { */ private String weightId; + + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 备注 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialissueitem/MatMaterialIssueItemVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialissueitem/MatMaterialIssueItemVo.java index 35274c99..9112b656 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialissueitem/MatMaterialIssueItemVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialissueitem/MatMaterialIssueItemVo.java @@ -52,6 +52,12 @@ public class MatMaterialIssueItemVo implements Serializable { */ private String unit; + + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 库存 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialreceiveitem/MatMaterialReceiveItemVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialreceiveitem/MatMaterialReceiveItemVo.java index 340d8448..d9b2f75e 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialreceiveitem/MatMaterialReceiveItemVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialreceiveitem/MatMaterialReceiveItemVo.java @@ -52,6 +52,11 @@ public class MatMaterialReceiveItemVo implements Serializable { */ private String unit; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 数量 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materials/MatMaterialsNumberVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materials/MatMaterialsNumberVo.java index 0456be65..da13ff0a 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materials/MatMaterialsNumberVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materials/MatMaterialsNumberVo.java @@ -37,6 +37,11 @@ public class MatMaterialsNumberVo implements Serializable { */ private String weightId; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 库存数量 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materials/MatMaterialsVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materials/MatMaterialsVo.java index 82557233..88b17429 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materials/MatMaterialsVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materials/MatMaterialsVo.java @@ -11,6 +11,7 @@ import org.dromara.tender.domain.vo.TenderSupplierInputVo; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; import java.util.Map; @@ -93,6 +94,11 @@ public class MatMaterialsVo implements Serializable { @ExcelProperty(value = "备注") private String remark; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** * 预计材料数量 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/IMatMaterialsService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/IMatMaterialsService.java index 29358d15..284e4b18 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/IMatMaterialsService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/IMatMaterialsService.java @@ -3,6 +3,7 @@ package org.dromara.materials.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import org.dromara.common.core.domain.R; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.materials.domain.MatMaterials; @@ -16,6 +17,7 @@ import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq; import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq; import org.dromara.materials.domain.vo.materials.*; +import java.math.BigDecimal; import java.util.Collection; import java.util.List; @@ -187,4 +189,26 @@ public interface IMatMaterialsService extends IService { * @return 材料库存数据列表 */ List queryExcelList(MatMaterialsQueryReq req); + + /** + * 根据项目id和材料名称获取当前库存总价 + * @param projectId + * @param lBQNames + * @return + */ + BigDecimal selectTotalPricesByNames(Long projectId, List lBQNames); + + /** + * 根据项目id获取当前库存总价 + * @param projectId + * @return + */ + BigDecimal selectTotalPrices(Long projectId); + + /** + * 大屏获取物资跟踪管理台账 + * @param projectId + * @return + */ + List listUseDetail(Long projectId); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialIssueServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialIssueServiceImpl.java index b27faa28..f800b99c 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialIssueServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialIssueServiceImpl.java @@ -565,6 +565,7 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl lBQNames) { + if (CollUtil.isEmpty(lBQNames)) { + return BigDecimal.ZERO; + } + // 根据材料名称获取材料列表数据 + List matMaterials = baseMapper.selectList(new LambdaQueryWrapper().eq(MatMaterials::getProjectId, projectId).in(MatMaterials::getMaterialsName, lBQNames)); + if (CollUtil.isEmpty(matMaterials)) { + return BigDecimal.ZERO; + } + // 获取材料id和单价 + Map map = matMaterials.stream() + .collect(Collectors.toMap( + MatMaterials::getId, + MatMaterials::getUnitPrice + )); + // 获取材料id + List ids = matMaterials.stream().map(MatMaterials::getId).toList(); + // 获取材料库存数据 + List inventories = materialsInventoryService.selectLatestByMaterialIds(ids); + if (CollUtil.isEmpty(inventories)){ + return BigDecimal.ZERO; + } + // 计算材料总价 + return inventories.stream() + .map(inventory -> map.getOrDefault(inventory.getMaterialsId(), BigDecimal.ZERO) + .multiply(BigDecimal.valueOf(inventory.getNumber()))) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + + @Override + public BigDecimal selectTotalPrices(Long projectId) { + // 根据材料名称获取材料列表数据 + List matMaterials = baseMapper.selectList(new LambdaQueryWrapper().eq(MatMaterials::getProjectId, projectId)); + if (CollUtil.isEmpty(matMaterials)) { + return BigDecimal.ZERO; + } + // 获取材料id和单价 + Map map = matMaterials.stream() + .collect(Collectors.toMap( + MatMaterials::getId, + MatMaterials::getUnitPrice + )); + // 获取材料id + List ids = matMaterials.stream().map(MatMaterials::getId).toList(); + // 获取材料库存数据 + List inventories = materialsInventoryService.selectLatestByMaterialIds(ids); + if (CollUtil.isEmpty(inventories)){ + return BigDecimal.ZERO; + } + // 计算材料总价 + return inventories.stream() + .map(inventory -> map.getOrDefault(inventory.getMaterialsId(), BigDecimal.ZERO) + .multiply(BigDecimal.valueOf(inventory.getNumber()))) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + + @Override + public List listUseDetail(Long projectId) { + // 查询数据库 + + List matMaterials = baseMapper.selectList(new LambdaQueryWrapper().eq(MatMaterials::getProjectId, projectId)); + if (CollUtil.isEmpty(matMaterials)) { + return List.of(); + } + // 查询材料出入库列表 + List ids = matMaterials.stream().map(MatMaterials::getId).toList(); + List materialsInventoryList = materialsInventoryService.lambdaQuery() + .in(MatMaterialsInventory::getMaterialsId, ids) + .list(); + List putList = materialsInventoryList.stream() + .filter(inventory -> inventory.getOutPut().equals(MatMaterialsInventoryOutPutEnum.PUT.getValue())) + .toList(); + // 查询使用列表 + List outList = materialsInventoryList.stream() + .filter(inventory -> inventory.getOutPut().equals(MatMaterialsInventoryOutPutEnum.OUT.getValue())) + .toList(); + List useList = new ArrayList<>(); + if (CollUtil.isNotEmpty(outList)) { + List outIds = outList.stream().map(MatMaterialsInventory::getId).toList(); + useList = materialsUseRecordService.lambdaQuery() + .in(MatMaterialsUseRecord::getInventoryId, outIds) + .list(); + } + // 查询仓库列表 + Set warehouseIds = matMaterials.stream().map(MatMaterials::getWarehouseId).collect(Collectors.toSet()); + List warehouseList = new ArrayList<>(); + if (CollUtil.isNotEmpty(warehouseIds)) { + warehouseList = warehouseService.lambdaQuery() + .in(MatWarehouse::getId, warehouseIds) + .list(); + } + List useDetailList = this.getUseDetailList(matMaterials, putList, outList, useList, warehouseList); + return useDetailList; + + } + /** * 构建一行导出数据 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index 7ad43336..ab35926a 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -4,20 +4,32 @@ import cn.hutool.json.JSONUtil; import jakarta.websocket.*; import jakarta.websocket.server.ServerEndpoint; import lombok.extern.slf4j.Slf4j; +import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; +import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo; +import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.dromara.bigscreen.service.IMaterialsManagementService; +import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; +import org.dromara.cailiaoshebei.service.IBusMrpBaseService; +import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; import org.dromara.common.core.utils.SpringUtils; import org.dromara.gps.domain.bo.GpsEquipmentSonBo; import org.dromara.gps.domain.vo.GpsEquipmentSonVo; import org.dromara.gps.service.IGpsEquipmentSonService; +import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; +import org.dromara.materials.service.IMatMaterialsService; import org.dromara.websocket.websocket.domain.vo.VehicleVo; import org.springframework.stereotype.Component; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; +import static kotlin.reflect.jvm.internal.impl.builtins.StandardNames.FqNames.list; + /** * 大屏 WebSocket 服务端(支持订阅消息) * 端点路径:/websocket/bigScreen @@ -72,25 +84,81 @@ public class BigScreenWebSocketServer { try { String[] split = currentSubscriptionId.split("-"); //todo 填充不同类型大屏获取基础数据的方法判断 - IGpsEquipmentSonService service = SpringUtils.getBean(IGpsEquipmentSonService.class); - GpsEquipmentSonBo bo = new GpsEquipmentSonBo(); - bo.setUserId(Long.parseLong(split[0])); - bo.setTripId(Long.parseLong(split[1])); - List list = service.getNewVehicleList(bo); - if (list == null || list.isEmpty()) { + IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class); + IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class); + IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class); + IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class); + Long projectId = Long.parseLong(split[0]); + long type = Long.parseLong(split[1]); + List> maps = new ArrayList<>(); + switch ((int) type){ + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + if (materialsService != null){ + InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId); + if (vo != null){ + Map map = new HashMap<>(); + map.put("type","inventoryStructureAnalysis"); + map.put("data", JSONUtil.toJsonStr(vo)); + maps.add(map); + } + } + if (purchaseDocService != null){ + List purchaseDocVos = purchaseDocService.purchaseNote(projectId); + if (purchaseDocVos != null && !purchaseDocVos.isEmpty()){ + Map map = new HashMap<>(); + map.put("type","purchaseNote"); + map.put("data", JSONUtil.toJsonStr(purchaseDocVos)); + maps.add(map); + } + } + if (mrpBaseService != null){ + List designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId); + if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()){ + Map map = new HashMap<>(); + map.put("type","designAndArrivalComparison"); + map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos)); + maps.add(map); + } + List wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId); + if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()){ + Map map = new HashMap<>(); + map.put("type","wzxqysjdhdb"); + map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos)); + maps.add(map); + } + } + if (materialsService != null){ + List useDetailVos = materialsService.listUseDetail(projectId); + if (useDetailVos != null && !useDetailVos.isEmpty()){ + Map map = new HashMap<>(); + map.put("type","listUseDetail"); + map.put("data", JSONUtil.toJsonStr(useDetailVos)); + maps.add(map); + } + } + break; + case 6: + break; + case 7: + break; + default: + break; + } + if (maps.isEmpty()) { session.getBasicRemote().sendText("初始化数据为空"); log.warn("会话[{}]未获取到初始化数据", session.getId()); return; } - List vehicleVos = new ArrayList<>(); - for (GpsEquipmentSonVo ueClient : list) { - VehicleVo vo = new VehicleVo(); - vo.setLocLatitude(ueClient.getLocLatitude()); - vo.setLocLongitude(ueClient.getLocLongitude()); - vehicleVos.add(vo); - } - session.getBasicRemote().sendText(JSONUtil.toJsonStr(vehicleVos)); - log.info("📤 已向会话[{}]推送初始化数据,长度:{}字节", session.getId(), vehicleVos.size()); + session.getBasicRemote().sendText(JSONUtil.toJsonStr(maps)); + log.info("📤 已向会话[{}]推送初始化数据,长度:{}字节", session.getId(), maps.size()); } catch (Exception e) { log.error("会话[{}]初始化数据处理失败", session.getId(), e); try { From b35f6d6fd25ad38e3bd80ce3359bb4968848cf21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Tue, 16 Dec 2025 17:25:31 +0800 Subject: [PATCH 10/38] =?UTF-8?q?12-16-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SysRoleWorkServiceImpl.java | 1 + .../dromara/system/domain/vo/SysUserVo.java | 5 + .../system/service/ISysUserService.java | 5 + .../service/impl/SysUserServiceImpl.java | 264 ++++++++++++++++++ .../websocket/domain/vo/RyglWebSocketVo.java | 35 +++ .../service/BigScreenWebSocketServer.java | 22 +- 6 files changed, 326 insertions(+), 6 deletions(-) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/domain/vo/RyglWebSocketVo.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/SysRoleWorkServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/SysRoleWorkServiceImpl.java index 040b3a9b..cae4e236 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/SysRoleWorkServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/SysRoleWorkServiceImpl.java @@ -94,6 +94,7 @@ public class SysRoleWorkServiceImpl extends ServiceImpl lqw = Wrappers.lambdaQuery(); lqw.orderByDesc(SysRoleWork::getCreateTime); lqw.eq(bo.getRoleId() != null, SysRoleWork::getRoleId, bo.getRoleId()); + lqw.eq(bo.getProjectId() != null, SysRoleWork::getProjectId, bo.getProjectId()); lqw.eq(StringUtils.isNotBlank(bo.getLcmc()), SysRoleWork::getLcmc, bo.getLcmc()); lqw.eq(StringUtils.isNotBlank(bo.getLcms()), SysRoleWork::getLcms, bo.getLcms()); lqw.eq(StringUtils.isNotBlank(bo.getLcxq()), SysRoleWork::getLcxq, bo.getLcxq()); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysUserVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysUserVo.java index 24db5876..e17d7c72 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysUserVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysUserVo.java @@ -208,4 +208,9 @@ public class SysUserVo implements Serializable { */ private String avatarUrl; + /** + * 角色类型 分包 施工 + */ + private String jslx; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysUserService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysUserService.java index ed7d7a13..e27c6a70 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysUserService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysUserService.java @@ -320,4 +320,9 @@ public interface ISysUserService { List selectUserListByContractorId(Long contractorId); void deleteContractorIdByUserId(Long userId); + + Map getRyglOnlineUserInfoData(Long projectId); + + void getAttendanceInfo(Long projectId,Long timeType,Map map); + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java index 270cc271..f812d048 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java @@ -26,6 +26,7 @@ import org.dromara.common.core.utils.*; import org.dromara.common.enums.AppUserTypeEnum; 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.contractor.domain.SubConstructionUser; import org.dromara.contractor.domain.SubContractor; @@ -38,11 +39,14 @@ import org.dromara.design.service.IDesDesignChangeService; import org.dromara.design.service.IDesUserService; import org.dromara.design.service.IDesVolumeCatalogService; import org.dromara.design.service.IDesVolumeFileService; +import org.dromara.project.domain.BusAttendance; import org.dromara.project.domain.BusUserProjectRelevancy; import org.dromara.project.domain.dto.attendance.SubTodayUserDto; import org.dromara.project.domain.dto.attendance.SubTwoWeekDto; import org.dromara.project.domain.dto.attendance.SubUserAttendanceQueryReq; +import org.dromara.project.domain.enums.BusAttendanceClockStatusEnum; import org.dromara.project.domain.vo.projectteam.BusProjectTeamAppVo; +import org.dromara.project.service.IBusAttendanceService; import org.dromara.project.service.IBusProjectTeamService; import org.dromara.project.service.IBusUserProjectRelevancyService; import org.dromara.system.domain.*; @@ -58,6 +62,8 @@ import org.dromara.system.mapper.*; import org.dromara.system.service.ISysRoleService; import org.dromara.system.service.ISysUserFileService; import org.dromara.system.service.ISysUserService; +import org.dromara.websocket.ChatServerHandler; +import org.dromara.websocket.websocket.domain.vo.RyglWebSocketVo; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; @@ -65,9 +71,17 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.temporal.TemporalAdjusters; import java.util.*; +import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; +import static org.dromara.project.domain.enums.BusAttendanceClockStatusEnum.LATE; +import static org.dromara.project.domain.enums.BusAttendanceClockStatusEnum.LEAVEEARLY; + /** * 用户 业务层处理 * @@ -120,6 +134,13 @@ public class SysUserServiceImpl implements ISysUserService, UserService { @Resource private ISysRoleService roleService; + @Resource + private ISubConstructionUserService subConstructionUserService; + @Resource + private ISubContractorService subContractorService; + @Resource + private IBusAttendanceService busAttendanceService; + @Override public TableDataInfo selectPageUserList(SysUserBo user, PageQuery pageQuery) { Page page = baseMapper.selectPageUserList(pageQuery.build(), this.buildQueryWrapper(user)); @@ -1570,4 +1591,247 @@ public class SysUserServiceImpl implements ISysUserService, UserService { wrapper.eq(SysUser::getUserId, userId).set(SysUser::getContractorId, null); baseMapper.update(null, wrapper); } + + /** + * 获取手机app在线离线数据 + 在线人员坐标 + 分包和施工在线人员数量 + */ + @Override + public Map getRyglOnlineUserInfoData(Long projectId){ + //获取该项目的在线人员 再分辨出种类 + //先获取该项目所有人员 + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(SubConstructionUser::getProjectId, projectId); + //未入场人员也要统计坐标 打卡不统计(存疑) +// lqw.and(lqw1 -> +// lqw1.isNotNull(SubConstructionUser::getTeamId) +// .or() +// .isNotNull(SubConstructionUser::getContractorId)); + List list = subConstructionUserService.list(lqw); + //再去从聊天服务中获取在线的ID + List onlineUserList = ChatServerHandler.getOnlineUserList(); + //构建将要返回的 数据 + List info = new ArrayList<>(); + long zx = 0; //在线 + long lx = 0; //离线 + AtomicLong fb = new AtomicLong(); //分包 + AtomicLong sg = new AtomicLong(); //施工 + //将属于该项目的在线ID过滤出来 + for (SubConstructionUser constructionUser : list) { + if (onlineUserList.contains(constructionUser.getSysUserId().toString())){ + //如果是此项目的在线人员 没有缓存信息 应该是还没来得及发送坐标信息进行缓存 + zx++; + //此项目 在线的 userId 去获取缓存的坐标信息 GpsEquipmentServiceImpl.setData() + String key = "rydw_userId_:" + constructionUser.getSysUserId(); + SysUserVo cacheUserVo = RedisUtils.getCacheObject(key); + if (cacheUserVo == null){ + continue; + } + //去判断是什么种类的用户 + list.stream().filter(item -> item.getSysUserId().equals(constructionUser.getSysUserId())) + .findFirst().ifPresent(item -> { + if (item.getUserRole().equals("0")){ + cacheUserVo.setJslx("施工"); + sg.getAndIncrement(); + } else if (item.getUserRole().equals("2")) { + cacheUserVo.setJslx("分包"); + fb.getAndIncrement(); + } + }); + info.add(cacheUserVo); + }else { + lx++; + } + } + //将数据返回 + Map map = new HashMap<>(); + map.put("zx", String.valueOf(zx)); + map.put("lx", String.valueOf(lx)); + map.put("fb", String.valueOf(fb.get())); + map.put("sg", String.valueOf(sg.get())); + map.put("info", info.toString()); + return map; + } + + @Override + public void getAttendanceInfo(Long projectId,Long timeType,Map map){ + //构建数据 + //timeType 1:今天 2:本周 3:本月 + Long zrs = 0L; //总人数 + Long cqr = 0L; //出勤人数 + BigDecimal cql = BigDecimal.ZERO; //出勤率 + //查询此项目的所有人员 + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(SubConstructionUser::getProjectId, projectId); + List list = subConstructionUserService.list(lqw); + //根据分包和班组的id进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数 + List fbList = new ArrayList<>(); + List bzList = new ArrayList<>(); + for (SubConstructionUser constructionUser : list) { + //统计该项目下的分包和班组各应有多少人 + if (constructionUser.getTeamId() != null && constructionUser.getContractorId() != null){ + //两个都有的情况 + //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 + if (constructionUser.getUserRole().equals("2")){ + checkAndSetValue(fbList,constructionUser,2,timeType,projectId); + } else if (constructionUser.getUserRole().equals("0")) { + checkAndSetValue(bzList,constructionUser,0,timeType,projectId); + } + }else if (constructionUser.getTeamId() == null && constructionUser.getContractorId() != null){ + //班组为空,分包不为空的情况 两个都为空不统计 班组不空分包空 不存在这种情况 + //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 + if (constructionUser.getUserRole().equals("2")){ + checkAndSetValue(fbList,constructionUser,2,timeType,projectId); + } + } + } + + //总人数 + zrs = (long) fbList.size() + bzList.size(); + //总出勤人 + long fbcqr = 0L; + long bzcqr = 0L; + //统计两个列表里的 到岗率 + for (RyglWebSocketVo vo : fbList) { + if (vo.getZrs()>0){ + vo.setDgl( + //到岗人数/总人数 四舍五入 一位小数 + BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 1, RoundingMode.HALF_UP) + ); + }else { + vo.setDgl(BigDecimal.ZERO); + } + fbcqr = fbcqr + vo.getDgrs(); + } + + for (RyglWebSocketVo vo : bzList) { + if (vo.getZrs()>0){ + vo.setDgl( + //到岗人数/总人数 四舍五入 一位小数 + BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 1, RoundingMode.HALF_UP) + ); + }else { + vo.setDgl(BigDecimal.ZERO); + } + bzcqr = bzcqr + vo.getDgrs(); + } + //出勤率 + if (zrs != 0L){ + cql = (BigDecimal.valueOf(fbcqr).add(BigDecimal.valueOf(bzcqr))).divide(BigDecimal.valueOf(zrs),1,RoundingMode.HALF_UP); + } + + map.put("zrs", zrs.toString()); + map.put("cqr", cqr.toString()); + map.put("cql", cql.toString()); + map.put("fb", fbList.toString()); + map.put("bz", bzList.toString()); + } + + /** + * getAttendanceInfo附属方法 + */ + private void checkAndSetValue(List ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId){ + //timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验 + if (time == 2L){ + time = 7L; + }else if (time == 3L){ + time = 30L; + } + + Long finalTime = time; + switch (type){ + case 2 -> { + //分包 + //首先判断传入的列表中是否存在该条数据 + ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getContractorId())).findFirst().ifPresentOrElse( + item -> { + item.setZrs(item.getZrs() + finalTime); + item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); + }, () -> { + RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); + //分包组织id + ryglWebSocketVo.setZzId(info.getContractorId()); + //分包组织名称 + if (info.getContractorId() != null) { + SubContractor byId = subContractorService.getById(info.getContractorId()); + if (byId != null) { + ryglWebSocketVo.setZzmc(byId.getName()); + } + } + //总人数 先设置1 + ryglWebSocketVo.setZrs(finalTime); + ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId)); + ryglWebSocketVoList.add(ryglWebSocketVo); + }); + } + + case 0 -> + //班组 + //首先判断传入的列表中是否存在该条数据 + ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getTeamId())).findFirst().ifPresentOrElse( + item -> { + item.setZrs(item.getZrs() + finalTime); + item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); + }, () -> { + RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); + //分包组织id + ryglWebSocketVo.setZzId(info.getContractorId()); + //分包组织名称 + ryglWebSocketVo.setZzmc(info.getTeamName()); + //总人数 先设置1 + ryglWebSocketVo.setZrs(finalTime); + ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId)); + ryglWebSocketVoList.add(ryglWebSocketVo); + }); + } + } + + // 出勤状态(正常、迟到、早退) + private static final Set ATTENDANCE_STATUS = new HashSet<>(Arrays.asList(BusAttendanceClockStatusEnum.NORMAL.getValue(), + LATE.getValue(), LEAVEEARLY.getValue() + , BusAttendanceClockStatusEnum.REISSUE.getValue())); + + /** + * 获取到岗人数 根据时间类型 返回到岗次数 + */ + private Long getDgrs(Long userId,Long time,Long projectId) { + // 今天所有用户的打卡记录 + List attendanceList; + LambdaQueryWrapper lqw = new LambdaQueryWrapper() + .eq(BusAttendance::getProjectId, projectId) + .eq(BusAttendance::getUserId, userId); + if (time == 1L) { + lqw.eq(BusAttendance::getClockDate, LocalDate.now()); + } else if (time == 2L) { + // 获取本周一和周日的日期 + LocalDate today = LocalDate.now(); + LocalDate monday = today.with(DayOfWeek.MONDAY); + LocalDate sunday = today.with(DayOfWeek.SUNDAY); + lqw.between(BusAttendance::getClockDate, monday, sunday); + }else if (time == 3L){ + // 获取本月第一天和最后一天 + LocalDate today = LocalDate.now(); + LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); + lqw.between(BusAttendance::getClockDate, firstDayOfMonth, lastDayOfMonth); + } + lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) + .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); + attendanceList = busAttendanceService.list(lqw); + if (attendanceList == null || attendanceList.isEmpty()){ + return 0L; + } + + final Long[] count = {0L}; + //根据日期分组 + Map> collect = attendanceList.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate)); + collect.forEach((key, value) -> { + //每一天分组 同一天去重 + List list = value.stream().map(BusAttendance::getUserId).distinct().toList(); + count[0] = count[0] + list.size(); + }); + + return count[0]; + } + + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/domain/vo/RyglWebSocketVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/domain/vo/RyglWebSocketVo.java new file mode 100644 index 00000000..87910217 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/domain/vo/RyglWebSocketVo.java @@ -0,0 +1,35 @@ +package org.dromara.websocket.websocket.domain.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class RyglWebSocketVo { + + /** + * 组织id + */ + private Long zzId; + + /** + * 组织名称 + */ + private String zzmc; + + /** + * 总人数 + */ + private Long zrs; + + /** + * 到岗人数 + */ + private Long dgrs; + + /** + * 到岗率 + */ + private BigDecimal dgl; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index ab35926a..b241eb9c 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -12,12 +12,9 @@ import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; import org.dromara.common.core.utils.SpringUtils; -import org.dromara.gps.domain.bo.GpsEquipmentSonBo; -import org.dromara.gps.domain.vo.GpsEquipmentSonVo; -import org.dromara.gps.service.IGpsEquipmentSonService; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; -import org.dromara.websocket.websocket.domain.vo.VehicleVo; +import org.dromara.system.service.impl.SysUserServiceImpl; import org.springframework.stereotype.Component; import java.io.IOException; @@ -28,8 +25,6 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; -import static kotlin.reflect.jvm.internal.impl.builtins.StandardNames.FqNames.list; - /** * 大屏 WebSocket 服务端(支持订阅消息) * 端点路径:/websocket/bigScreen @@ -63,15 +58,18 @@ public class BigScreenWebSocketServer { public void onOpen(Session session) { // 从连接URL的查询参数中获取订阅ID(客户端连接格式:ws://xxx/websocket/bigScreen?subscriptionId=123) Map> params = session.getRequestParameterMap(); + Long timeType; List subscriptionIds = params.get("subscriptionId"); if (subscriptionIds != null && !subscriptionIds.isEmpty()) { this.currentSubscriptionId = subscriptionIds.get(0); // 取第一个订阅ID + timeType = Long.parseLong(params.get("timeType").getFirst()); // 建立映射关系 SUBSCRIPTION_SESSIONS.put(currentSubscriptionId, session); SESSION_TO_SUBSCRIPTION.put(session.getId(), currentSubscriptionId); log.info("📌 客户端订阅成功!订阅ID:{},会话ID:{},当前订阅数:{}", currentSubscriptionId, session.getId(), SUBSCRIPTION_SESSIONS.size()); } else { + timeType = null; log.warn("📌 客户端连接未携带订阅ID!会话ID:{}", session.getId()); } @@ -88,6 +86,8 @@ public class BigScreenWebSocketServer { IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class); IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class); IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class); + SysUserServiceImpl sysUserService = SpringUtils.getBean(SysUserServiceImpl.class); + Long projectId = Long.parseLong(split[0]); long type = Long.parseLong(split[1]); List> maps = new ArrayList<>(); @@ -95,6 +95,16 @@ public class BigScreenWebSocketServer { case 1: break; case 2: + //判断参数 + if (timeType == null || (timeType != 1L && timeType != 2L && timeType != 3L)){ + throw new RuntimeException("时间类型参数错误"); + } + //先获取左边坐标得到map + Map infoData = sysUserService.getRyglOnlineUserInfoData(projectId); + //获取右边数据 + sysUserService.getAttendanceInfo(projectId,timeType,infoData); + //返回数据 + maps.add(infoData); break; case 3: break; From 7bc2f1c832d5e62386cdc0f95cdbabeb6d4b3582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Tue, 16 Dec 2025 18:06:07 +0800 Subject: [PATCH 11/38] =?UTF-8?q?12-16-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/mapper/BusAttendanceMapper.java | 6 +- .../service/IBusAttendanceService.java | 18 +- .../service/IBusProjectTeamMemberService.java | 1 - .../impl/BusAttendanceServiceImpl.java | 254 ++++++++++++++++- .../impl/BusProjectTeamMemberServiceImpl.java | 3 + .../system/service/ISysUserService.java | 4 - .../service/impl/SysUserServiceImpl.java | 265 +----------------- .../service/BigScreenWebSocketServer.java | 8 +- .../service/MessageWebSocketServer.java | 207 ++++++++++++++ 9 files changed, 484 insertions(+), 282 deletions(-) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/MessageWebSocketServer.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/mapper/BusAttendanceMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/mapper/BusAttendanceMapper.java index 6a957402..04930bf7 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/mapper/BusAttendanceMapper.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/mapper/BusAttendanceMapper.java @@ -1,11 +1,13 @@ package org.dromara.project.mapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Select; +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.contractor.domain.SubContractor; import org.dromara.project.domain.BusAttendance; import org.dromara.project.domain.bo.BusAttendanceBo; import org.dromara.project.domain.vo.BusAttendanceVo; -import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; /** * 考勤Mapper接口 @@ -18,4 +20,6 @@ public interface BusAttendanceMapper extends BaseMapperPlus queryPageList(BusAttendanceBo bo, PageQuery pageQuery); + @Select("select * from sub_contractor where id = #{id}") + SubContractor getSubContractor(Long id); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/IBusAttendanceService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/IBusAttendanceService.java index 489f7aa3..eb673ff1 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/IBusAttendanceService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/IBusAttendanceService.java @@ -1,24 +1,21 @@ package org.dromara.project.service; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.constraints.NotNull; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.project.domain.BusAttendance; +import org.dromara.project.domain.bo.BusAttendanceBo; import org.dromara.project.domain.dto.attendance.*; import org.dromara.project.domain.vo.BusAttendanceVo; -import org.dromara.project.domain.bo.BusAttendanceBo; -import org.dromara.project.domain.BusAttendance; -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.project.domain.vo.BusMonthAttendanceVo; import org.dromara.project.domain.vo.attendance.*; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.multipart.MultipartFile; import java.time.LocalDate; import java.util.Collection; import java.util.List; +import java.util.Map; /** * 考勤Service接口 @@ -232,5 +229,8 @@ public interface IBusAttendanceService extends IService{ */ Long getAttendanceUserCountByDate(Long projectId,LocalDate startDate, LocalDate endDate); + Map getRyglOnlineUserInfoData(Long projectId); + + void getAttendanceInfo(Long projectId,Long timeType,Map map); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/IBusProjectTeamMemberService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/IBusProjectTeamMemberService.java index aeb99c54..a1051f97 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/IBusProjectTeamMemberService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/IBusProjectTeamMemberService.java @@ -11,7 +11,6 @@ import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberExit import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberQueryReq; import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberUpdateReq; import org.dromara.project.domain.vo.projectteammember.BusProjectTeamMemberVo; -import org.springframework.web.bind.annotation.PathVariable; import java.util.List; diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index 1e5f4cd1..03af5ec3 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -27,13 +27,14 @@ import org.dromara.common.core.utils.StringUtils; import org.dromara.common.domain.GeoPoint; 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.common.utils.BigDecimalUtil; import org.dromara.common.utils.IdCardEncryptorUtil; import org.dromara.common.utils.JSTUtil; import org.dromara.contractor.domain.SubConstructionUser; +import org.dromara.contractor.domain.SubContractor; import org.dromara.contractor.service.ISubConstructionUserService; -import org.dromara.contractor.service.ISubUserSalaryDetailService; import org.dromara.project.domain.*; import org.dromara.project.domain.bo.BusAttendanceBo; import org.dromara.project.domain.dto.attendance.*; @@ -53,18 +54,20 @@ import org.dromara.system.domain.vo.SysUserVo; import org.dromara.system.service.ISysOssService; import org.dromara.system.service.ISysUserService; import org.dromara.websocket.ChatServerHandler; +import org.dromara.websocket.websocket.domain.vo.RyglWebSocketVo; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.*; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; -import java.time.temporal.ValueRange; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import static org.dromara.project.domain.enums.BusAttendanceClockStatusEnum.*; @@ -111,12 +114,14 @@ public class BusAttendanceServiceImpl extends ServiceImpl getRyglOnlineUserInfoData(Long projectId){ + //获取该项目的在线人员 再分辨出种类 + //先获取该项目所有人员 + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(SubConstructionUser::getProjectId, projectId); + //未入场人员也要统计坐标 打卡不统计(存疑) +// lqw.and(lqw1 -> +// lqw1.isNotNull(SubConstructionUser::getTeamId) +// .or() +// .isNotNull(SubConstructionUser::getContractorId)); + List list = constructionUserService.list(lqw); + //再去从聊天服务中获取在线的ID + List onlineUserList = ChatServerHandler.getOnlineUserList(); + //构建将要返回的 数据 + List info = new ArrayList<>(); + long zx = 0; //在线 + long lx = 0; //离线 + AtomicLong fb = new AtomicLong(); //分包 + AtomicLong sg = new AtomicLong(); //施工 + //将属于该项目的在线ID过滤出来 + for (SubConstructionUser constructionUser : list) { + if (onlineUserList.contains(constructionUser.getSysUserId().toString())){ + //如果是此项目的在线人员 没有缓存信息 应该是还没来得及发送坐标信息进行缓存 + zx++; + //此项目 在线的 userId 去获取缓存的坐标信息 GpsEquipmentServiceImpl.setData() + String key = "rydw_userId_:" + constructionUser.getSysUserId(); + SysUserVo cacheUserVo = RedisUtils.getCacheObject(key); + if (cacheUserVo == null){ + continue; + } + //去判断是什么种类的用户 + list.stream().filter(item -> item.getSysUserId().equals(constructionUser.getSysUserId())) + .findFirst().ifPresent(item -> { + if (item.getUserRole().equals("0")){ + cacheUserVo.setJslx("施工"); + sg.getAndIncrement(); + } else if (item.getUserRole().equals("2")) { + cacheUserVo.setJslx("分包"); + fb.getAndIncrement(); + } + }); + info.add(cacheUserVo); + }else { + lx++; + } + } + //将数据返回 + Map map = new HashMap<>(); + map.put("zx", String.valueOf(zx)); + map.put("lx", String.valueOf(lx)); + map.put("fb", String.valueOf(fb.get())); + map.put("sg", String.valueOf(sg.get())); + map.put("info", info.toString()); + return map; + } + + @Override + public void getAttendanceInfo(Long projectId,Long timeType,Map map){ + //构建数据 + //timeType 1:今天 2:本周 3:本月 + Long zrs = 0L; //总人数 + Long cqr = 0L; //出勤人数 + BigDecimal cql = BigDecimal.ZERO; //出勤率 + //查询此项目的所有人员 + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(SubConstructionUser::getProjectId, projectId); + List list = constructionUserService.list(lqw); + //根据分包和班组的id进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数 + List fbList = new ArrayList<>(); + List bzList = new ArrayList<>(); + for (SubConstructionUser constructionUser : list) { + //统计该项目下的分包和班组各应有多少人 + if (constructionUser.getTeamId() != null && constructionUser.getContractorId() != null){ + //两个都有的情况 + //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 + if (constructionUser.getUserRole().equals("2")){ + checkAndSetValue(fbList,constructionUser,2,timeType,projectId); + } else if (constructionUser.getUserRole().equals("0")) { + checkAndSetValue(bzList,constructionUser,0,timeType,projectId); + } + }else if (constructionUser.getTeamId() == null && constructionUser.getContractorId() != null){ + //班组为空,分包不为空的情况 两个都为空不统计 班组不空分包空 不存在这种情况 + //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 + if (constructionUser.getUserRole().equals("2")){ + checkAndSetValue(fbList,constructionUser,2,timeType,projectId); + } + } + } + + //总人数 + zrs = (long) fbList.size() + bzList.size(); + //总出勤人 + long fbcqr = 0L; + long bzcqr = 0L; + //统计两个列表里的 到岗率 + for (RyglWebSocketVo vo : fbList) { + if (vo.getZrs()>0){ + vo.setDgl( + //到岗人数/总人数 四舍五入 一位小数 + BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 1, RoundingMode.HALF_UP) + ); + }else { + vo.setDgl(BigDecimal.ZERO); + } + fbcqr = fbcqr + vo.getDgrs(); + } + + for (RyglWebSocketVo vo : bzList) { + if (vo.getZrs()>0){ + vo.setDgl( + //到岗人数/总人数 四舍五入 一位小数 + BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 1, RoundingMode.HALF_UP) + ); + }else { + vo.setDgl(BigDecimal.ZERO); + } + bzcqr = bzcqr + vo.getDgrs(); + } + //出勤率 + if (zrs != 0L){ + cql = (BigDecimal.valueOf(fbcqr).add(BigDecimal.valueOf(bzcqr))).divide(BigDecimal.valueOf(zrs),1,RoundingMode.HALF_UP); + } + + map.put("zrs", zrs.toString()); + map.put("cqr", cqr.toString()); + map.put("cql", cql.toString()); + map.put("fb", fbList.toString()); + map.put("bz", bzList.toString()); + } + + /** + * getAttendanceInfo附属方法 + */ + private void checkAndSetValue(List ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId){ + //timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验 + if (time == 2L){ + time = 7L; + }else if (time == 3L){ + time = 30L; + } + + Long finalTime = time; + switch (type){ + case 2 -> { + //分包 + //首先判断传入的列表中是否存在该条数据 + ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getContractorId())).findFirst().ifPresentOrElse( + item -> { + item.setZrs(item.getZrs() + finalTime); + item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); + }, () -> { + RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); + //分包组织id + ryglWebSocketVo.setZzId(info.getContractorId()); + //分包组织名称 + if (info.getContractorId() != null) { +// SubContractor byId = subContractorService.getById(info.getContractorId()); + SubContractor byId = baseMapper.getSubContractor(info.getContractorId()); + if (byId != null) { + ryglWebSocketVo.setZzmc(byId.getName()); + } + } + //总人数 先设置1 + ryglWebSocketVo.setZrs(finalTime); + ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId)); + ryglWebSocketVoList.add(ryglWebSocketVo); + }); + } + + case 0 -> + //班组 + //首先判断传入的列表中是否存在该条数据 + ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getTeamId())).findFirst().ifPresentOrElse( + item -> { + item.setZrs(item.getZrs() + finalTime); + item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); + }, () -> { + RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); + //分包组织id + ryglWebSocketVo.setZzId(info.getContractorId()); + //分包组织名称 + ryglWebSocketVo.setZzmc(info.getTeamName()); + //总人数 先设置1 + ryglWebSocketVo.setZrs(finalTime); + ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId)); + ryglWebSocketVoList.add(ryglWebSocketVo); + }); + } + } + +// // 出勤状态(正常、迟到、早退) +// private static final Set ATTENDANCE_STATUS = new HashSet<>(Arrays.asList(BusAttendanceClockStatusEnum.NORMAL.getValue(), +// LATE.getValue(), LEAVEEARLY.getValue() +// , BusAttendanceClockStatusEnum.REISSUE.getValue())); + + /** + * 获取到岗人数 根据时间类型 返回到岗次数 + */ + private Long getDgrs(Long userId,Long time,Long projectId) { + // 今天所有用户的打卡记录 + List attendanceList; + LambdaQueryWrapper lqw = new LambdaQueryWrapper() + .eq(BusAttendance::getProjectId, projectId) + .eq(BusAttendance::getUserId, userId); + if (time == 1L) { + lqw.eq(BusAttendance::getClockDate, LocalDate.now()); + } else if (time == 2L) { + // 获取本周一和周日的日期 + LocalDate today = LocalDate.now(); + LocalDate monday = today.with(DayOfWeek.MONDAY); + LocalDate sunday = today.with(DayOfWeek.SUNDAY); + lqw.between(BusAttendance::getClockDate, monday, sunday); + }else if (time == 3L){ + // 获取本月第一天和最后一天 + LocalDate today = LocalDate.now(); + LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); + lqw.between(BusAttendance::getClockDate, firstDayOfMonth, lastDayOfMonth); + } + lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) + .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); + attendanceList = this.list(lqw); + if (attendanceList == null || attendanceList.isEmpty()){ + return 0L; + } + + final Long[] count = {0L}; + //根据日期分组 + Map> collect = attendanceList.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate)); + collect.forEach((key, value) -> { + //每一天分组 同一天去重 + List list = value.stream().map(BusAttendance::getUserId).distinct().toList(); + count[0] = count[0] + list.size(); + }); + + return count[0]; + } + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusProjectTeamMemberServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusProjectTeamMemberServiceImpl.java index 65c8e8e6..e7bb52cc 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusProjectTeamMemberServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusProjectTeamMemberServiceImpl.java @@ -98,6 +98,9 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl getRyglOnlineUserInfoData(Long projectId); - - void getAttendanceInfo(Long projectId,Long timeType,Map map); - } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java index f812d048..ce47163c 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java @@ -26,7 +26,6 @@ import org.dromara.common.core.utils.*; import org.dromara.common.enums.AppUserTypeEnum; 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.contractor.domain.SubConstructionUser; import org.dromara.contractor.domain.SubContractor; @@ -39,14 +38,11 @@ import org.dromara.design.service.IDesDesignChangeService; import org.dromara.design.service.IDesUserService; import org.dromara.design.service.IDesVolumeCatalogService; import org.dromara.design.service.IDesVolumeFileService; -import org.dromara.project.domain.BusAttendance; import org.dromara.project.domain.BusUserProjectRelevancy; import org.dromara.project.domain.dto.attendance.SubTodayUserDto; import org.dromara.project.domain.dto.attendance.SubTwoWeekDto; import org.dromara.project.domain.dto.attendance.SubUserAttendanceQueryReq; -import org.dromara.project.domain.enums.BusAttendanceClockStatusEnum; import org.dromara.project.domain.vo.projectteam.BusProjectTeamAppVo; -import org.dromara.project.service.IBusAttendanceService; import org.dromara.project.service.IBusProjectTeamService; import org.dromara.project.service.IBusUserProjectRelevancyService; import org.dromara.system.domain.*; @@ -62,8 +58,6 @@ import org.dromara.system.mapper.*; import org.dromara.system.service.ISysRoleService; import org.dromara.system.service.ISysUserFileService; import org.dromara.system.service.ISysUserService; -import org.dromara.websocket.ChatServerHandler; -import org.dromara.websocket.websocket.domain.vo.RyglWebSocketVo; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; @@ -71,17 +65,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.math.RoundingMode; -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.temporal.TemporalAdjusters; import java.util.*; -import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; -import static org.dromara.project.domain.enums.BusAttendanceClockStatusEnum.LATE; -import static org.dromara.project.domain.enums.BusAttendanceClockStatusEnum.LEAVEEARLY; - /** * 用户 业务层处理 * @@ -134,12 +120,11 @@ public class SysUserServiceImpl implements ISysUserService, UserService { @Resource private ISysRoleService roleService; - @Resource - private ISubConstructionUserService subConstructionUserService; - @Resource - private ISubContractorService subContractorService; - @Resource - private IBusAttendanceService busAttendanceService; +// @Resource +// private ISubConstructionUserService subConstructionUserService; +// @Resource +// private ISubContractorService subContractorService; + @Override public TableDataInfo selectPageUserList(SysUserBo user, PageQuery pageQuery) { @@ -1592,246 +1577,6 @@ public class SysUserServiceImpl implements ISysUserService, UserService { baseMapper.update(null, wrapper); } - /** - * 获取手机app在线离线数据 + 在线人员坐标 + 分包和施工在线人员数量 - */ - @Override - public Map getRyglOnlineUserInfoData(Long projectId){ - //获取该项目的在线人员 再分辨出种类 - //先获取该项目所有人员 - LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); - lqw.eq(SubConstructionUser::getProjectId, projectId); - //未入场人员也要统计坐标 打卡不统计(存疑) -// lqw.and(lqw1 -> -// lqw1.isNotNull(SubConstructionUser::getTeamId) -// .or() -// .isNotNull(SubConstructionUser::getContractorId)); - List list = subConstructionUserService.list(lqw); - //再去从聊天服务中获取在线的ID - List onlineUserList = ChatServerHandler.getOnlineUserList(); - //构建将要返回的 数据 - List info = new ArrayList<>(); - long zx = 0; //在线 - long lx = 0; //离线 - AtomicLong fb = new AtomicLong(); //分包 - AtomicLong sg = new AtomicLong(); //施工 - //将属于该项目的在线ID过滤出来 - for (SubConstructionUser constructionUser : list) { - if (onlineUserList.contains(constructionUser.getSysUserId().toString())){ - //如果是此项目的在线人员 没有缓存信息 应该是还没来得及发送坐标信息进行缓存 - zx++; - //此项目 在线的 userId 去获取缓存的坐标信息 GpsEquipmentServiceImpl.setData() - String key = "rydw_userId_:" + constructionUser.getSysUserId(); - SysUserVo cacheUserVo = RedisUtils.getCacheObject(key); - if (cacheUserVo == null){ - continue; - } - //去判断是什么种类的用户 - list.stream().filter(item -> item.getSysUserId().equals(constructionUser.getSysUserId())) - .findFirst().ifPresent(item -> { - if (item.getUserRole().equals("0")){ - cacheUserVo.setJslx("施工"); - sg.getAndIncrement(); - } else if (item.getUserRole().equals("2")) { - cacheUserVo.setJslx("分包"); - fb.getAndIncrement(); - } - }); - info.add(cacheUserVo); - }else { - lx++; - } - } - //将数据返回 - Map map = new HashMap<>(); - map.put("zx", String.valueOf(zx)); - map.put("lx", String.valueOf(lx)); - map.put("fb", String.valueOf(fb.get())); - map.put("sg", String.valueOf(sg.get())); - map.put("info", info.toString()); - return map; - } - - @Override - public void getAttendanceInfo(Long projectId,Long timeType,Map map){ - //构建数据 - //timeType 1:今天 2:本周 3:本月 - Long zrs = 0L; //总人数 - Long cqr = 0L; //出勤人数 - BigDecimal cql = BigDecimal.ZERO; //出勤率 - //查询此项目的所有人员 - LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); - lqw.eq(SubConstructionUser::getProjectId, projectId); - List list = subConstructionUserService.list(lqw); - //根据分包和班组的id进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数 - List fbList = new ArrayList<>(); - List bzList = new ArrayList<>(); - for (SubConstructionUser constructionUser : list) { - //统计该项目下的分包和班组各应有多少人 - if (constructionUser.getTeamId() != null && constructionUser.getContractorId() != null){ - //两个都有的情况 - //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 - if (constructionUser.getUserRole().equals("2")){ - checkAndSetValue(fbList,constructionUser,2,timeType,projectId); - } else if (constructionUser.getUserRole().equals("0")) { - checkAndSetValue(bzList,constructionUser,0,timeType,projectId); - } - }else if (constructionUser.getTeamId() == null && constructionUser.getContractorId() != null){ - //班组为空,分包不为空的情况 两个都为空不统计 班组不空分包空 不存在这种情况 - //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 - if (constructionUser.getUserRole().equals("2")){ - checkAndSetValue(fbList,constructionUser,2,timeType,projectId); - } - } - } - - //总人数 - zrs = (long) fbList.size() + bzList.size(); - //总出勤人 - long fbcqr = 0L; - long bzcqr = 0L; - //统计两个列表里的 到岗率 - for (RyglWebSocketVo vo : fbList) { - if (vo.getZrs()>0){ - vo.setDgl( - //到岗人数/总人数 四舍五入 一位小数 - BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 1, RoundingMode.HALF_UP) - ); - }else { - vo.setDgl(BigDecimal.ZERO); - } - fbcqr = fbcqr + vo.getDgrs(); - } - - for (RyglWebSocketVo vo : bzList) { - if (vo.getZrs()>0){ - vo.setDgl( - //到岗人数/总人数 四舍五入 一位小数 - BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 1, RoundingMode.HALF_UP) - ); - }else { - vo.setDgl(BigDecimal.ZERO); - } - bzcqr = bzcqr + vo.getDgrs(); - } - //出勤率 - if (zrs != 0L){ - cql = (BigDecimal.valueOf(fbcqr).add(BigDecimal.valueOf(bzcqr))).divide(BigDecimal.valueOf(zrs),1,RoundingMode.HALF_UP); - } - - map.put("zrs", zrs.toString()); - map.put("cqr", cqr.toString()); - map.put("cql", cql.toString()); - map.put("fb", fbList.toString()); - map.put("bz", bzList.toString()); - } - - /** - * getAttendanceInfo附属方法 - */ - private void checkAndSetValue(List ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId){ - //timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验 - if (time == 2L){ - time = 7L; - }else if (time == 3L){ - time = 30L; - } - - Long finalTime = time; - switch (type){ - case 2 -> { - //分包 - //首先判断传入的列表中是否存在该条数据 - ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getContractorId())).findFirst().ifPresentOrElse( - item -> { - item.setZrs(item.getZrs() + finalTime); - item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); - }, () -> { - RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); - //分包组织id - ryglWebSocketVo.setZzId(info.getContractorId()); - //分包组织名称 - if (info.getContractorId() != null) { - SubContractor byId = subContractorService.getById(info.getContractorId()); - if (byId != null) { - ryglWebSocketVo.setZzmc(byId.getName()); - } - } - //总人数 先设置1 - ryglWebSocketVo.setZrs(finalTime); - ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId)); - ryglWebSocketVoList.add(ryglWebSocketVo); - }); - } - - case 0 -> - //班组 - //首先判断传入的列表中是否存在该条数据 - ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getTeamId())).findFirst().ifPresentOrElse( - item -> { - item.setZrs(item.getZrs() + finalTime); - item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); - }, () -> { - RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); - //分包组织id - ryglWebSocketVo.setZzId(info.getContractorId()); - //分包组织名称 - ryglWebSocketVo.setZzmc(info.getTeamName()); - //总人数 先设置1 - ryglWebSocketVo.setZrs(finalTime); - ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId)); - ryglWebSocketVoList.add(ryglWebSocketVo); - }); - } - } - - // 出勤状态(正常、迟到、早退) - private static final Set ATTENDANCE_STATUS = new HashSet<>(Arrays.asList(BusAttendanceClockStatusEnum.NORMAL.getValue(), - LATE.getValue(), LEAVEEARLY.getValue() - , BusAttendanceClockStatusEnum.REISSUE.getValue())); - - /** - * 获取到岗人数 根据时间类型 返回到岗次数 - */ - private Long getDgrs(Long userId,Long time,Long projectId) { - // 今天所有用户的打卡记录 - List attendanceList; - LambdaQueryWrapper lqw = new LambdaQueryWrapper() - .eq(BusAttendance::getProjectId, projectId) - .eq(BusAttendance::getUserId, userId); - if (time == 1L) { - lqw.eq(BusAttendance::getClockDate, LocalDate.now()); - } else if (time == 2L) { - // 获取本周一和周日的日期 - LocalDate today = LocalDate.now(); - LocalDate monday = today.with(DayOfWeek.MONDAY); - LocalDate sunday = today.with(DayOfWeek.SUNDAY); - lqw.between(BusAttendance::getClockDate, monday, sunday); - }else if (time == 3L){ - // 获取本月第一天和最后一天 - LocalDate today = LocalDate.now(); - LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); - LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); - lqw.between(BusAttendance::getClockDate, firstDayOfMonth, lastDayOfMonth); - } - lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) - .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); - attendanceList = busAttendanceService.list(lqw); - if (attendanceList == null || attendanceList.isEmpty()){ - return 0L; - } - - final Long[] count = {0L}; - //根据日期分组 - Map> collect = attendanceList.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate)); - collect.forEach((key, value) -> { - //每一天分组 同一天去重 - List list = value.stream().map(BusAttendance::getUserId).distinct().toList(); - count[0] = count[0] + list.size(); - }); - - return count[0]; - } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index b241eb9c..39b539fb 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -14,7 +14,7 @@ import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; import org.dromara.common.core.utils.SpringUtils; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; -import org.dromara.system.service.impl.SysUserServiceImpl; +import org.dromara.project.service.impl.BusAttendanceServiceImpl; import org.springframework.stereotype.Component; import java.io.IOException; @@ -86,7 +86,7 @@ public class BigScreenWebSocketServer { IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class); IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class); IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class); - SysUserServiceImpl sysUserService = SpringUtils.getBean(SysUserServiceImpl.class); + BusAttendanceServiceImpl busAttendanceService = SpringUtils.getBean(BusAttendanceServiceImpl.class); Long projectId = Long.parseLong(split[0]); long type = Long.parseLong(split[1]); @@ -100,9 +100,9 @@ public class BigScreenWebSocketServer { throw new RuntimeException("时间类型参数错误"); } //先获取左边坐标得到map - Map infoData = sysUserService.getRyglOnlineUserInfoData(projectId); + Map infoData = busAttendanceService.getRyglOnlineUserInfoData(projectId); //获取右边数据 - sysUserService.getAttendanceInfo(projectId,timeType,infoData); + busAttendanceService.getAttendanceInfo(projectId,timeType,infoData); //返回数据 maps.add(infoData); break; diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/MessageWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/MessageWebSocketServer.java new file mode 100644 index 00000000..28f4afcf --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/MessageWebSocketServer.java @@ -0,0 +1,207 @@ +package org.dromara.websocket.websocket.service; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import jakarta.websocket.*; +import jakarta.websocket.server.ServerEndpoint; +import lombok.extern.slf4j.Slf4j; +import org.dromara.common.core.domain.model.LoginUser; +import org.dromara.common.core.utils.SpringUtils; +import org.dromara.common.satoken.utils.LoginHelper; +import org.dromara.system.service.impl.SysOssServiceImpl; +import org.dromara.system.service.impl.SysUserServiceImpl; +import org.dromara.websocket.domain.ChatGroup; +import org.dromara.websocket.domain.ChatHistory; +import org.dromara.websocket.domain.enums.ChatRoomEnum; +import org.dromara.websocket.service.Impl.ChatGroupServiceImpl; +import org.dromara.websocket.service.Impl.ChatHistoryServiceImpl; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 项目启动即自动启动的 WebSocket 服务端 + * 端点路径:/websocket/message(可自定义) + */ +@Slf4j +@ServerEndpoint("/websocket/message") // 定义 WebSocket 端点路径 +@Component +public class MessageWebSocketServer { + + private static ChatHistoryServiceImpl chatHistoryService = SpringUtils.getBean(ChatHistoryServiceImpl.class); + private static ChatGroupServiceImpl chatGroupService = SpringUtils.getBean(ChatGroupServiceImpl.class); + private static SysUserServiceImpl sysUserService = SpringUtils.getBean(SysUserServiceImpl.class); + private static SysOssServiceImpl sysOssService = SpringUtils.getBean(SysOssServiceImpl.class); + + // 2. 静态会话存储(线程安全,项目启动时即初始化) + private static final Map ONLINE_SESSIONS = new ConcurrentHashMap<>(); + + + // 3. 静态代码块:项目启动时执行(初始化资源、打印启动日志) + static { + // 此处可添加启动时的初始化逻辑(如加载配置、连接外部资源等) + log.info("✅ 聊天&信息WebSocket 服务端已随项目启动初始化!端点路径:/websocket/message"); + } + + // 使用内存映射替代Redis存储 + private static final ConcurrentHashMap> userSessionMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap sessionUserMap = new ConcurrentHashMap<>(); + //维护用户房间未读数量的映射表 用户+房间->Count + private static final ConcurrentHashMap userRoomCountMap = new ConcurrentHashMap<>(); + //维护一个在线用户列表 + private static final List onlineUserList = new ArrayList<>(); + //对外部暴露方法 + public static List getOnlineUserList() { + return onlineUserList; + } + + /** + * 客户端连接时触发(无需手动启动,有客户端连接时自动调用) + */ + @OnOpen + public void onOpen(Session session) { + // 存储新会话 + ONLINE_SESSIONS.put(session.getId(), session); + log.info("📌 客户端连接成功!会话ID:{},当前在线数:{}", session.getId(), ONLINE_SESSIONS.size()); + // 2. 异步获取并推送初始化数据(避免阻塞连接) + CompletableFuture.runAsync(() -> { + try { + //连接成功过后 获取当前连接携带的token + Map> params = session.getRequestParameterMap(); + String token; + List tokens = params.get("token"); + if (tokens != null && !tokens.isEmpty()) { + token = tokens.getFirst(); + }else { + throw new RuntimeException("未获取到token"); + } + + LoginUser loginUser = LoginHelper.getLoginUser(token.replace("Bearer ", "")); +// log.info("token:{}",token.replace("Bearer%20", "")); +// log.info("用户信息:{}", loginUser); + if (loginUser == null){ + throw new RuntimeException("token过期或失效,请重新获取"); + } + + //userChannelMap -> userSessionMap channelHandlerContexts -> sessions channelUserMap -> sessionUserMap + + //判断是否存在该账号的通道实例列表 + List sessions = userSessionMap.computeIfAbsent(loginUser.getUserId().toString(), k -> new ArrayList<>()); +// List sessions = userSessionMap.get(loginUser.getUserId().toString()); + if (!sessions.contains(session)) { + sessions.add(session); + } + + //把该账号的session实例列表跟账号id关联 一个账号有多个通道实例 + userSessionMap.put(loginUser.getUserId().toString(), sessions); + //把通道实例跟账号id关联 + sessionUserMap.put(session, loginUser.getUserId().toString()); + + if (!onlineUserList.contains(loginUser.getUserId().toString())) { + onlineUserList.add(loginUser.getUserId().toString()); + } +// Channel channel = ctx.channel(); +// channelGroup.add(channel); + + //构建各个聊天房间未读 数量 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(ChatGroup::getMembers, loginUser.getUserId() + ",").or().like(ChatGroup::getMembers, loginUser.getUserId() + "]"); + //拿到该用户所参与的房间列表 + List chatGroups = chatGroupService.list(queryWrapper); + boolean isHaveSystemRoom = false; + if (chatGroups != null && !chatGroups.isEmpty()) { + HashMap roomCounts = new HashMap<>(); + for (ChatGroup chatGroup : chatGroups) { + LambdaQueryWrapper historyLambdaQueryWrapper = new LambdaQueryWrapper<>(); + historyLambdaQueryWrapper.eq(ChatHistory::getGeterId, chatGroup.getId()); + historyLambdaQueryWrapper.ne(ChatHistory::getSenderId, loginUser.getUserId()); + historyLambdaQueryWrapper.eq(ChatHistory::getIsRead, "1"); + List list = chatHistoryService.list(historyLambdaQueryWrapper); + if (list != null && !list.isEmpty()) { + roomCounts.put(loginUser.getUserId() + "+" + chatGroup.getId().toString(), list.size()); + //连接后同步未读消息到内存中 + userRoomCountMap.put(loginUser.getUserId() + "+" + chatGroup.getId().toString(), list.size()); + } + //在遍历的同时寻找是否有系统消息房间 + if (!isHaveSystemRoom && chatGroup.getMembers().contains("[" + ChatRoomEnum.SYSTEM.getRoomId())) { + isHaveSystemRoom = true; + } + } + JSONObject message = new JSONObject(); + message.put("type", "3"); + message.put("messageType", "txt"); + message.put("unReadCount", roomCounts); +// log.info("发送所有未读消息:{}", message); + if (message.get("unReadCount") != null && !roomCounts.isEmpty()) { +// sendMessage(ctx, message.toJSONString()); + } + } + + } catch (Exception e) { + log.error("会话[{}]初始化数据处理失败", session.getId(), e); + } + }); + } + + /** + * 接收客户端消息 + */ + @OnMessage + public void onMessage(String message, Session session) { + log.info("📥 收到会话[{}]消息:{}", session.getId(), message); + // 可选:回复客户端(示例) + + } + + /** + * 客户端断开连接 + */ + @OnClose + public void onClose(Session session, CloseReason reason) { + ONLINE_SESSIONS.remove(session.getId()); + log.info("🔌 客户端断开连接!会话ID:{},原因:{},当前在线数:{}", + session.getId(), reason.getReasonPhrase(), ONLINE_SESSIONS.size()); + } + + /** + * 连接异常 + */ + @OnError + public void onError(Session session, Throwable error) { + log.error("⚠️ 会话[{}]异常:{}", session.getId(), error.getMessage(), error); + } + + // ------------------------------ 工具方法(可选,供其他服务调用) ------------------------------ + /** + * 向所有在线客户端发送消息(项目启动后,其他服务可直接调用) + */ + public static void sendToAll(String message) { + if (ONLINE_SESSIONS.isEmpty()) { + log.warn("⚠️ 无在线客户端,无需发送消息"); + return; + } + ONLINE_SESSIONS.values().forEach(session -> { + if (session.isOpen()) { + try { + session.getBasicRemote().sendText(message); + } catch (IOException e) { + log.error("📤 向会话[{}]发送消息失败:{}", session.getId(), e.getMessage()); + } + } + }); + } + + /** + * 获取当前在线数(供外部查询) + */ + public static int getOnlineCount() { + return ONLINE_SESSIONS.size(); + } + +} From ebb8f09a754527708a2a6ce4d1c8c71880fe9a81 Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Tue, 16 Dec 2025 18:31:50 +0800 Subject: [PATCH 12/38] =?UTF-8?q?=E8=B4=A8=E5=AE=89=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigscreen/domain/vo/DpznglAqyVo.java | 2 +- .../service/impl/DpzaglServiceImpl.java | 21 ++++---- .../gps/mapper/GpsEquipmentSonMapper.java | 8 +-- .../service/BigScreenWebSocketServer.java | 49 +++++++++++++++++-- 4 files changed, 60 insertions(+), 20 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java index 55dfb928..849b3962 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/DpznglAqyVo.java @@ -14,7 +14,7 @@ public class DpznglAqyVo implements Serializable { private Long userId; - @Translation(type = TransConstant.XZD_KHXX_ID_TO_NAME, mapper = "userId") + @Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "userId") private String userName; /** diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java index 3f45b224..f5c02f99 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java @@ -142,7 +142,7 @@ public class DpzaglServiceImpl implements DpzaglService { if (busProjectPunchranges == null || busProjectPunchranges.size() == 0){ return; } - +//判断是否在岗 for (DpznglAqyVo dpznglAqyVo : dpznglAqyVos) { dpznglAqyVo.setSfzg(DpEnum.RYZT_LG.getTypeValue()); @@ -155,9 +155,6 @@ public class DpzaglServiceImpl implements DpzaglService { } } - - - } @Override @@ -177,18 +174,18 @@ public class DpzaglServiceImpl implements DpzaglService { // 安全 巡检工单,整改情况 HseSafetyInspectionQueryReq req = new HseSafetyInspectionQueryReq(); // 质量展示数据 - TableDataInfo anList = safetyInspectionService.queryPageList(req, pageQuery); +// TableDataInfo anList = safetyInspectionService.queryPageList(req, pageQuery); // 质量展示数据-整改 req.setStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); TableDataInfo aqZgList = safetyInspectionService.queryPageList(req, pageQuery); // 质量总数(用于判断巡检类型) - List list = safetyInspectionService.list(); + List list = safetyInspectionService.list(new LambdaQueryWrapper().ge(bo.getStartDate() != null ,HseSafetyInspection::getCreateTime, bo.getStartDate()).le(bo.getEndDate() != null ,HseSafetyInspection::getCreateTime, bo.getEndDate())); - List rows = anList.getRows(); +// List rows = anList.getRows(); - if (rows != null && rows.size() > 0){ - dpznglVo.setAqZS(anList.getTotal()); - dpznglVo.setAqList(rows); + if (list != null && list.size() > 0){ + dpznglVo.setAqZS(Long.valueOf(list.size())); + dpznglVo.setAqList(MapstructUtils.convert(list, HseSafetyInspectionVo.class)); dpznglVo.setZxjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_ZXGL.getTypeValue().equals(zl.getCheckType())).count()); dpznglVo.setDqjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getCheckType())).count()); dpznglVo.setRcxjAq(list.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getCheckType())).count()); @@ -211,10 +208,10 @@ public class DpzaglServiceImpl implements DpzaglService { // 质量展示数据-整改 req.setInspectionStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); TableDataInfo zlZgLists = qualityInspectionService.queryPageList(req, pageQuery); -// 质量总数(用于判断巡检类型) +// 质量总数 List zsZl = qualityInspectionService.getBaseMapper() .selectList(new LambdaQueryWrapper() - .eq(QltQualityInspection::getInspectionType,DpEnum.ZLGDZT_ZG.getTypeValue())); + .ge(bo.getStartDate() != null ,QltQualityInspection::getCreateTime, bo.getStartDate()).le(bo.getEndDate() != null ,QltQualityInspection::getCreateTime, bo.getEndDate())); // List rows = zlLists.getRows(); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/gps/mapper/GpsEquipmentSonMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/gps/mapper/GpsEquipmentSonMapper.java index aed02b38..bb686633 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/gps/mapper/GpsEquipmentSonMapper.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/gps/mapper/GpsEquipmentSonMapper.java @@ -157,14 +157,14 @@ public interface GpsEquipmentSonMapper extends BaseMapperPlus SELECT a.user_id , a.loc_latitude, a.loc_longitude" + - "FROM (\n" + + @Select("") + " GROUP BY a.user_id ") List listByAqy(@Param("collect") List collect, @Param("projectId") Long projectId); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index 39b539fb..0bb1123e 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -4,9 +4,9 @@ import cn.hutool.json.JSONUtil; import jakarta.websocket.*; import jakarta.websocket.server.ServerEndpoint; import lombok.extern.slf4j.Slf4j; -import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; -import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo; -import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.dromara.bigscreen.domain.bo.DpznglBo; +import org.dromara.bigscreen.domain.vo.*; +import org.dromara.bigscreen.service.DpzaglService; import org.dromara.bigscreen.service.IMaterialsManagementService; import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; import org.dromara.cailiaoshebei.service.IBusMrpBaseService; @@ -15,6 +15,7 @@ import org.dromara.common.core.utils.SpringUtils; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; import org.dromara.project.service.impl.BusAttendanceServiceImpl; +import org.dromara.system.service.impl.SysUserServiceImpl; import org.springframework.stereotype.Component; import java.io.IOException; @@ -87,6 +88,8 @@ public class BigScreenWebSocketServer { IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class); IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class); BusAttendanceServiceImpl busAttendanceService = SpringUtils.getBean(BusAttendanceServiceImpl.class); +// 大屏-质安管理 + DpzaglService dpzaglService = SpringUtils.getBean(DpzaglService.class); Long projectId = Long.parseLong(split[0]); long type = Long.parseLong(split[1]); @@ -107,6 +110,9 @@ public class BigScreenWebSocketServer { maps.add(infoData); break; case 3: + if (dpzaglService != null){ + saveDateDpzagl(dpzaglService,params,projectId,maps); + } break; case 4: break; @@ -304,4 +310,41 @@ public class BigScreenWebSocketServer { public static int getOnlineCount() { return ONLINE_SESSIONS.size(); } + + + private void saveDateDpzagl(DpzaglService dpzaglService, Map> params,Long projectId,List> maps) { + DpznglBo dpznglBo = new DpznglBo(); + dpznglBo.setProjectId(projectId); + // 查询大屏-质安管理-安全员分布情况 + + List dpznglAqyVos = dpzaglService.listByAqy(dpznglBo); + if (dpznglAqyVos != null && dpznglAqyVos.size() > 0){ + Map map = new HashMap<>(); + map.put("type","aqy"); + map.put("data", JSONUtil.toJsonStr(dpznglAqyVos)); + maps.add(map); + } + // 查询大屏-质安管理-站班会,巡检工单,整改情况 + DpznglVo dpznglVo = dpzaglService.queryList(dpznglBo); + + if (dpznglVo != null){ + Map map = new HashMap<>(); + map.put("type","zagl"); + map.put("data", JSONUtil.toJsonStr(dpznglVo)); + maps.add(map); + } + //查询大屏-质安管理-站班会 + DpznglVo byzbh = dpzaglService.listByzbh(dpznglBo); + if (byzbh != null){ + Map map = new HashMap<>(); + map.put("type","zbh"); + map.put("data", JSONUtil.toJsonStr(byzbh)); + maps.add(map); + } + + } + + + + } From dd6402d8b615a3758721e6cdb4864ccda665ef92 Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Tue, 16 Dec 2025 18:46:37 +0800 Subject: [PATCH 13/38] =?UTF-8?q?=E8=B4=A8=E5=AE=89=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../websocket/service/BigScreenWebSocketServer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index 0bb1123e..caf8dd18 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -59,18 +59,16 @@ public class BigScreenWebSocketServer { public void onOpen(Session session) { // 从连接URL的查询参数中获取订阅ID(客户端连接格式:ws://xxx/websocket/bigScreen?subscriptionId=123) Map> params = session.getRequestParameterMap(); - Long timeType; + List subscriptionIds = params.get("subscriptionId"); if (subscriptionIds != null && !subscriptionIds.isEmpty()) { this.currentSubscriptionId = subscriptionIds.get(0); // 取第一个订阅ID - timeType = Long.parseLong(params.get("timeType").getFirst()); // 建立映射关系 SUBSCRIPTION_SESSIONS.put(currentSubscriptionId, session); SESSION_TO_SUBSCRIPTION.put(session.getId(), currentSubscriptionId); log.info("📌 客户端订阅成功!订阅ID:{},会话ID:{},当前订阅数:{}", currentSubscriptionId, session.getId(), SUBSCRIPTION_SESSIONS.size()); } else { - timeType = null; log.warn("📌 客户端连接未携带订阅ID!会话ID:{}", session.getId()); } @@ -98,6 +96,8 @@ public class BigScreenWebSocketServer { case 1: break; case 2: + Long timeType; + timeType = Long.parseLong(params.get("timeType").getFirst()); //判断参数 if (timeType == null || (timeType != 1L && timeType != 2L && timeType != 3L)){ throw new RuntimeException("时间类型参数错误"); From bb63e7464d30f984b97856496639c9ffcfadc6c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Tue, 16 Dec 2025 18:49:19 +0800 Subject: [PATCH 14/38] =?UTF-8?q?12-16-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../websocket/service/BigScreenWebSocketServer.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index caf8dd18..b9acd761 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -15,7 +15,6 @@ import org.dromara.common.core.utils.SpringUtils; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; import org.dromara.project.service.impl.BusAttendanceServiceImpl; -import org.dromara.system.service.impl.SysUserServiceImpl; import org.springframework.stereotype.Component; import java.io.IOException; @@ -96,10 +95,9 @@ public class BigScreenWebSocketServer { case 1: break; case 2: - Long timeType; - timeType = Long.parseLong(params.get("timeType").getFirst()); + Long timeType = Long.parseLong(params.get("timeType").getFirst()); //判断参数 - if (timeType == null || (timeType != 1L && timeType != 2L && timeType != 3L)){ + if (timeType != 1L && timeType != 2L && timeType != 3L){ throw new RuntimeException("时间类型参数错误"); } //先获取左边坐标得到map From 5fc35e1a4cbb0d3febebe8be2710fb7635d0877c Mon Sep 17 00:00:00 2001 From: dfdg <2710245601@qq.com> Date: Tue, 16 Dec 2025 19:06:44 +0800 Subject: [PATCH 15/38] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MaterialsManagementServiceImpl.java | 82 +++++++++++-------- .../service/BigScreenWebSocketServer.java | 8 +- 2 files changed, 50 insertions(+), 40 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java index 713106b9..70bb2aa0 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java @@ -83,27 +83,29 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi .eq(MatMaterialReceiveItem::getProjectId, projectId) .ne(MatMaterialReceiveItem::getAcceptedQuantity, BigDecimal.ZERO) .between(MatMaterialReceiveItem::getCreateTime, monthStart, currentTime)); - if (CollUtil.isEmpty(matMaterialReceiveItems)){ + if (CollUtil.isEmpty(matMaterialReceiveItems)) { vo.setEnterTotalPrices(BigDecimal.ZERO); + }else { + // 计算本月入库金额 + BigDecimal enterTotalPrices = matMaterialReceiveItems.stream() + .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setEnterTotalPrices(enterTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } - // 计算本月入库金额 - matMaterialReceiveItems.forEach(item -> { - vo.setEnterTotalPrices(vo.getEnterTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice()))); - }); - vo.setEnterTotalPrices(vo.getEnterTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); // 获取上月入库数据 List oldMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper() .eq(MatMaterialReceiveItem::getProjectId, projectId) .ne(MatMaterialReceiveItem::getAcceptedQuantity, BigDecimal.ZERO) .between(MatMaterialReceiveItem::getCreateTime, lastMonthFirstDay, lastMonthLastDay)); - if (CollUtil.isEmpty(oldMatMaterialReceiveItems)){ + if (CollUtil.isEmpty(oldMatMaterialReceiveItems)) { vo.setOldEnterTotalPrices(BigDecimal.ZERO); + }else { + // 计算上月入库金额 + BigDecimal oldEnterTotalPrices = oldMatMaterialReceiveItems.stream() + .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setOldEnterTotalPrices(oldEnterTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } - // 计算上月入库金额 - oldMatMaterialReceiveItems.forEach(item -> { - vo.setOldEnterTotalPrices(vo.getOldEnterTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice()))); - }); - vo.setOldEnterTotalPrices(vo.getOldEnterTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); // 获取当月出库数据 List matMaterialIssueItems = materialIssueItemService.getBaseMapper() .selectList(new LambdaQueryWrapper() @@ -112,13 +114,14 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi .between(MatMaterialIssueItem::getCreateTime, monthStart, currentTime)); //计算本月出库金额 - if (CollUtil.isEmpty(matMaterialIssueItems)){ + if (CollUtil.isEmpty(matMaterialIssueItems)) { vo.setLeaveTotalPrices(BigDecimal.ZERO); + }else { + BigDecimal leaveTotalPrices = matMaterialIssueItems.stream() + .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setLeaveTotalPrices(leaveTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } - matMaterialIssueItems.forEach(item -> { - vo.setLeaveTotalPrices(vo.getLeaveTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice()))); - }); - vo.setLeaveTotalPrices(vo.getLeaveTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); // 获取上月出库数据 List oldMatMaterialIssueItems = materialIssueItemService.getBaseMapper() .selectList(new LambdaQueryWrapper() @@ -126,31 +129,38 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi .ne(MatMaterialIssueItem::getIssuedQuantity, BigDecimal.ZERO) .between(MatMaterialIssueItem::getCreateTime, lastMonthFirstDay, lastMonthLastDay)); //计算上月出库金额 - if (CollUtil.isEmpty(oldMatMaterialIssueItems)){ + if (CollUtil.isEmpty(oldMatMaterialIssueItems)) { vo.setOldLeaveTotalPrices(BigDecimal.ZERO); + }else { + BigDecimal oldLeaveTotalPrices = oldMatMaterialIssueItems.stream() + .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setOldLeaveTotalPrices(oldLeaveTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } - oldMatMaterialIssueItems.forEach(item -> { - vo.setOldLeaveTotalPrices(vo.getOldLeaveTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice()))); - }); - vo.setOldLeaveTotalPrices(vo.getOldLeaveTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); //获取总入库存金额 入库 * 单价 List totalMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(MatMaterialReceiveItem::getProjectId, projectId)); - if (CollUtil.isEmpty(totalMatMaterialReceiveItems)){ + if (CollUtil.isEmpty(totalMatMaterialReceiveItems)) { vo.setInventoryTotalPrices(BigDecimal.ZERO); + }else { + // 计算总入库存金额 + BigDecimal inventoryTotalPrices = totalMatMaterialReceiveItems.stream() + .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setInventoryTotalPrices(inventoryTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } - totalMatMaterialReceiveItems.forEach(item -> { - vo.setInventoryTotalPrices(vo.getInventoryTotalPrices().add(item.getAcceptedQuantity().multiply(item.getUnitPrice()))); - }); - vo.setInventoryTotalPrices(vo.getInventoryTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); + // 获取总出库金额 出库 * 单价 List totalMatMaterialIssueItems = materialIssueItemService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(MatMaterialIssueItem::getProjectId, projectId)); - if (CollUtil.isEmpty(totalMatMaterialIssueItems)){ + if (CollUtil.isEmpty(totalMatMaterialIssueItems)) { vo.setOutTotalPrices(BigDecimal.ZERO); + }else { + // 计算总出库金额 + BigDecimal outTotalPrices = totalMatMaterialIssueItems.stream() + .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setOutTotalPrices(outTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } - totalMatMaterialIssueItems.forEach(item -> { - vo.setOutTotalPrices(vo.getOutTotalPrices().add(item.getIssuedQuantity().multiply(item.getUnitPrice()))); - }); - vo.setOutTotalPrices(vo.getOutTotalPrices().setScale(4, BigDecimal.ROUND_HALF_UP)); + // 获取施工图一览大类名下所有小类名 List limitLists = billofquantitiesLimitListService.getBaseMapper().selectList(new LambdaQueryWrapper() @@ -184,16 +194,16 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi } } //获取库存逆变器总价 - BigDecimal inventoryInverterTotalPrices = materialsService.selectTotalPricesByNames(projectId,lBQNames); + BigDecimal inventoryInverterTotalPrices = materialsService.selectTotalPricesByNames(projectId, lBQNames); vo.setInventoryInverterTotalPrices(inventoryInverterTotalPrices); //获取库存箱变总价 - BigDecimal inventoryBoxTransformerTotalPrices = materialsService.selectTotalPricesByNames(projectId,xBNames); + BigDecimal inventoryBoxTransformerTotalPrices = materialsService.selectTotalPricesByNames(projectId, xBNames); vo.setInventoryBoxTransformerTotalPrices(inventoryBoxTransformerTotalPrices); //获取库存光伏支架总价 - BigDecimal inventoryPhotovoltaicSupportTotalPrices = materialsService.selectTotalPricesByNames(projectId,sFZJNames); + BigDecimal inventoryPhotovoltaicSupportTotalPrices = materialsService.selectTotalPricesByNames(projectId, sFZJNames); vo.setInventoryPhotovoltaicSupportTotalPrices(inventoryPhotovoltaicSupportTotalPrices); //获取库存环网柜总价 - BigDecimal inventoryCircuitBreakerTotalPrices = materialsService.selectTotalPricesByNames(projectId,hWGNames); + BigDecimal inventoryCircuitBreakerTotalPrices = materialsService.selectTotalPricesByNames(projectId, hWGNames); vo.setInventoryCircuitBreakerTotalPrices(inventoryCircuitBreakerTotalPrices); //获取当前库存总价 BigDecimal nowInventoryTotalPrices = materialsService.selectTotalPrices(projectId); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index b9acd761..4bbbbd20 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -74,11 +74,12 @@ public class BigScreenWebSocketServer { // 存储会话到在线列表 ONLINE_SESSIONS.put(session.getId(), session); log.info("📌 客户端连接成功!会话ID:{},当前在线数:{}", session.getId(), ONLINE_SESSIONS.size()); - + String[] split = currentSubscriptionId.split("-"); + Long projectId = Long.parseLong(split[0]); + long type = Long.parseLong(split[1]); // 异步推送初始化数据(原有逻辑保留) CompletableFuture.runAsync(() -> { try { - String[] split = currentSubscriptionId.split("-"); //todo 填充不同类型大屏获取基础数据的方法判断 IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class); IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class); @@ -88,8 +89,7 @@ public class BigScreenWebSocketServer { // 大屏-质安管理 DpzaglService dpzaglService = SpringUtils.getBean(DpzaglService.class); - Long projectId = Long.parseLong(split[0]); - long type = Long.parseLong(split[1]); + List> maps = new ArrayList<>(); switch ((int) type){ case 1: From f9b8ae5dbbeb4d2581be06aa847072e75f765458 Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Tue, 16 Dec 2025 19:10:57 +0800 Subject: [PATCH 16/38] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProgressBigScreenController.java | 18 ++- .../progress/MaterialProgressDetailVo.java | 68 +++++++++++ .../service/ProgressBigScreenService.java | 29 +++++ .../impl/ProgressBigScreenServiceImpl.java | 93 ++++++++++++++- .../impl/BusPurchaseDocServiceImpl.java | 15 ++- .../dromara/common/utils/BigDecimalUtil.java | 4 +- .../service/BigScreenWebSocketServer.java | 109 ++++++++++++------ 7 files changed, 289 insertions(+), 47 deletions(-) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MaterialProgressDetailVo.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java index caf962be..4c4b5600 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java @@ -6,11 +6,11 @@ import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq; import org.dromara.bigscreen.domain.progress.DesignProgressVo; +import org.dromara.bigscreen.domain.progress.MaterialProgressDetailVo; import org.dromara.bigscreen.domain.progress.MilestoneProgressVo; import org.dromara.bigscreen.domain.progress.ProjectTotalProgressVo; import org.dromara.bigscreen.domain.vo.ProjectImageProgressDetailVo; import org.dromara.bigscreen.service.ProgressBigScreenService; -import org.dromara.bigscreen.service.ProjectBigScreenService; import org.dromara.common.core.domain.R; import org.dromara.common.web.core.BaseController; import org.springframework.validation.annotation.Validated; @@ -37,9 +37,6 @@ public class ProgressBigScreenController extends BaseController { @Resource private ProgressBigScreenService progressBigScreenService; - @Resource - private ProjectBigScreenService projectBigScreenService; - /** * 获取项目总进度 */ @@ -71,7 +68,16 @@ public class ProgressBigScreenController extends BaseController { * 获取施工进度详情 */ @GetMapping("/constructionProgress/detail") - public R> getProjectImageProgressDetail(@Validated ProjectImageProgressDetailReq req) { - return R.ok(projectBigScreenService.getProjectImageProgressDetail(req)); + public R> getProjectTotalProgressDetail(@Validated ProjectImageProgressDetailReq req) { + return R.ok(progressBigScreenService.getProjectTotalProgressDetail(req)); + } + + /** + * 获取材料进度详情 + */ + @GetMapping("/materialProgress/detail/{projectId}") + public R> getMaterialProgressDetail(@NotNull(message = "项目主键不能为空") + @PathVariable Long projectId) { + return R.ok(progressBigScreenService.getMaterialProgressDetail(projectId)); } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MaterialProgressDetailVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MaterialProgressDetailVo.java new file mode 100644 index 00000000..a643f4fb --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MaterialProgressDetailVo.java @@ -0,0 +1,68 @@ +package org.dromara.bigscreen.domain.progress; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDate; + +/** + * @author lilemy + * @date 2025-12-16 17:03 + */ +@Data +public class MaterialProgressDetailVo implements Serializable { + + @Serial + private static final long serialVersionUID = -4499381537680421083L; + + /** + * 主键id + */ + private Long id; + + /** + * 名称 + */ + private String name; + + /** + * 数量 + */ + private BigDecimal quantity; + + /** + * 验收 + */ + private BigDecimal acceptedQuantity; + + /** + * 缺件 + */ + private BigDecimal shortageQuantity; + + // region 接收单数据 + + /** + * 合同名称 + */ + private String contractName; + + /** + * 订货单位 + */ + private String orderingUnit; + + /** + * 供货单位 + */ + private String supplierUnit; + + /** + * 到货时间 + */ + private LocalDate arrivalDate; + + // endregion +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java index e2f749f9..5d11397b 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java @@ -1,8 +1,13 @@ package org.dromara.bigscreen.service; +import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq; import org.dromara.bigscreen.domain.progress.DesignProgressVo; +import org.dromara.bigscreen.domain.progress.MaterialProgressDetailVo; import org.dromara.bigscreen.domain.progress.MilestoneProgressVo; import org.dromara.bigscreen.domain.progress.ProjectTotalProgressVo; +import org.dromara.bigscreen.domain.vo.ProjectImageProgressDetailVo; +import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.springframework.validation.annotation.Validated; import java.util.List; @@ -20,6 +25,14 @@ public interface ProgressBigScreenService { */ ProjectTotalProgressVo getProjectTotalProgress(Long projectId); + /** + * 获取施工进度详情 + * + * @param req 请求参数 + * @return 施工进度详情 + */ + List getProjectTotalProgressDetail(@Validated ProjectImageProgressDetailReq req); + /** * 获取里程碑进度 * @@ -35,4 +48,20 @@ public interface ProgressBigScreenService { * @return 设计进度 */ DesignProgressVo getDesignProgress(Long projectId); + + /** + * 获取物料进度详情 + * + * @param projectId 项目 id + * @return 物料进度详情 + */ + List getMaterialProgressDetail(Long projectId); + + /** + * 获取物资进度 + * + * @param projectId 项目 id + * @return 物资进度 + */ + List getMaterialProgress(Long projectId); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java index f453d5b9..ab3ee2fd 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java @@ -3,14 +3,24 @@ package org.dromara.bigscreen.service.impl; import cn.hutool.core.collection.CollUtil; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; +import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq; import org.dromara.bigscreen.domain.progress.*; +import org.dromara.bigscreen.domain.vo.ProjectImageProgressDetailVo; +import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; import org.dromara.bigscreen.service.ProgressBigScreenService; +import org.dromara.bigscreen.service.ProjectBigScreenService; +import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.common.core.enums.BusinessStatusEnum; +import org.dromara.common.core.utils.DateUtils; import org.dromara.common.utils.BigDecimalUtil; import org.dromara.design.domain.DesVolumeCatalog; import org.dromara.design.domain.DesVolumeFile; import org.dromara.design.service.IDesVolumeCatalogService; import org.dromara.design.service.IDesVolumeFileService; +import org.dromara.materials.domain.MatMaterialReceive; +import org.dromara.materials.domain.MatMaterialReceiveItem; +import org.dromara.materials.service.IMatMaterialReceiveItemService; +import org.dromara.materials.service.IMatMaterialReceiveService; import org.dromara.progress.constant.PgsProgressCategoryConstant; import org.dromara.progress.domain.PgsConstructionSchedulePlan; import org.dromara.progress.domain.PgsProgressCategory; @@ -28,6 +38,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; @@ -44,6 +55,9 @@ import java.util.stream.Collectors; @Service public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { + @Resource + private ProjectBigScreenService projectBigScreenService; + @Resource private IBusProjectService projectService; @@ -65,6 +79,15 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { @Resource private ISysDictDataService dictDataService; + @Resource + private IMatMaterialReceiveService materialReceiveService; + + @Resource + private IMatMaterialReceiveItemService materialReceiveItemService; + + @Resource + private IBusMrpBaseService mrpBaseService; + /** * 获取项目总进度 * @@ -116,8 +139,8 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { } // 获取整体完成情况 PgsProgressCategoryValueTotalVo valueTotal = progressCategoryService.getValueTotal(children, true); - vo.setTotalCompletionAmount(valueTotal.getTotalValue()); - vo.setCurrentCompletionAmount(valueTotal.getCurrentValue()); + vo.setTotalCompletionAmount(valueTotal.getTotalValue().divide(BigDecimal.valueOf(10000), 0, RoundingMode.HALF_UP)); + vo.setCurrentCompletionAmount(valueTotal.getCurrentValue().divide(BigDecimal.valueOf(10000), 0, RoundingMode.HALF_UP)); // 获取详情 Map> nameMap = topList.stream() .collect(Collectors.groupingBy(PgsProgressCategory::getName)); @@ -144,6 +167,17 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { return vo; } + /** + * 获取施工进度详情 + * + * @param req 请求参数 + * @return 施工进度详情 + */ + @Override + public List getProjectTotalProgressDetail(ProjectImageProgressDetailReq req) { + return projectBigScreenService.getProjectImageProgressDetail(req); + } + /** * 获取里程碑进度 * @@ -284,6 +318,7 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { } } } + vo.setTotalDesign((long) fileList.size()); vo.setReviewedDesign(reviewedDesign); vo.setReviewedDesignTrend(reviewedDesignThisM.compareTo(reviewedDesignLastM) >= 0); vo.setReviewedDesignRate(BigDecimalUtil.toLoopPercentage(reviewedDesignThisM, reviewedDesignLastM)); @@ -292,4 +327,58 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { vo.setPendingDesignReviewRate(BigDecimalUtil.toLoopPercentage(pendingReviewDesignThisD, pendingReviewDesignLastD)); return vo; } + + /** + * 获取物料进度详情 + * + * @param projectId 项目 id + * @return 物料进度详情 + */ + @Override + public List getMaterialProgressDetail(Long projectId) { + List receiveList = materialReceiveService.lambdaQuery() + .eq(MatMaterialReceive::getProjectId, projectId) + .list(); + if (CollUtil.isEmpty(receiveList)) { + return List.of(); + } + List ids = receiveList.stream().map(MatMaterialReceive::getId).toList(); + List itemList = materialReceiveItemService.lambdaQuery() + .in(MatMaterialReceiveItem::getReceiveId, ids) + .list(); + if (CollUtil.isEmpty(itemList)) { + return List.of(); + } + Map receiveMap = receiveList.stream() + .collect(Collectors.toMap(MatMaterialReceive::getId, receive -> receive)); + return itemList.stream().map(item -> { + Long receiveId = item.getReceiveId(); + MatMaterialReceive receive = receiveMap.get(receiveId); + if (receive == null) { + return null; + } + MaterialProgressDetailVo vo = new MaterialProgressDetailVo(); + vo.setId(item.getId()); + vo.setName(item.getName()); + vo.setQuantity(item.getQuantity()); + vo.setAcceptedQuantity(item.getAcceptedQuantity()); + vo.setShortageQuantity(item.getShortageQuantity()); + vo.setContractName(receive.getContractName()); + vo.setOrderingUnit(receive.getOrderingUnit()); + vo.setSupplierUnit(receive.getSupplierUnit()); + vo.setArrivalDate(DateUtils.toLocalDate(receive.getCreateTime())); + return vo; + }).filter(Objects::nonNull).toList(); + } + + /** + * 获取物资进度 + * + * @param projectId 项目 id + * @return 物资进度 + */ + @Override + public List getMaterialProgress(Long projectId) { + return mrpBaseService.wzxqysjdhdb(projectId); + } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java index 8d347e46..9fde9ed4 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java @@ -191,7 +191,7 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl 0; if (flag) { bo.setId(add.getId()); @@ -212,7 +212,7 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl { planids.add(busMaterialbatchdemandplan.getId()); }); - if (!ids1.isEmpty()){ + if (!ids1.isEmpty()) { List list1 = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class) .in(BusPlanDocAssociation::getDocId, ids1)); //计算材料已存在的数量 BigDecimal cltotal = list1.stream() .filter(Objects::nonNull) - .filter(item->planids.contains(item.getPlanId())) + .filter(item -> planids.contains(item.getPlanId())) .map(BusPlanDocAssociation::getDemandQuantity) .reduce(BigDecimal.ZERO, BigDecimal::add); if (cltotal.add(association.getDemandQuantity()).compareTo(quantity) > 0) { @@ -411,7 +411,12 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl map = planDocAssociationList.stream().collect(Collectors.toMap(BusPlanDocAssociation::getPlanId, BusPlanDocAssociation::getDemandQuantity)); + Map map = planDocAssociationList.stream() + .peek(item -> { + if (item.getDemandQuantity() == null) { + item.setDemandQuantity(BigDecimal.ZERO); + } + }).collect(Collectors.toMap(BusPlanDocAssociation::getPlanId, BusPlanDocAssociation::getDemandQuantity)); items = materialbatchdemandplanService.listByIds(map.keySet()); items.forEach(item -> item.setDemandQuantity(map.get(item.getId()))); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/BigDecimalUtil.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/BigDecimalUtil.java index 228d03c3..1768946f 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/BigDecimalUtil.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/common/utils/BigDecimalUtil.java @@ -36,8 +36,10 @@ public class BigDecimalUtil { if (thisNum == null || lastNum == null) { return BigDecimal.valueOf(0.00); } - if (lastNum.compareTo(BigDecimal.ZERO) == 0) { + if (lastNum.compareTo(BigDecimal.ZERO) == 0 && thisNum.compareTo(BigDecimal.ZERO) > 0) { return BigDecimal.valueOf(100.00); + } else if (lastNum.compareTo(BigDecimal.ZERO) == 0) { + return BigDecimal.valueOf(0.00); } return thisNum.subtract(lastNum) .multiply(new BigDecimal("100")) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index 4bbbbd20..e8be939f 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -5,9 +5,13 @@ import jakarta.websocket.*; import jakarta.websocket.server.ServerEndpoint; import lombok.extern.slf4j.Slf4j; import org.dromara.bigscreen.domain.bo.DpznglBo; +import org.dromara.bigscreen.domain.progress.DesignProgressVo; +import org.dromara.bigscreen.domain.progress.MilestoneProgressVo; +import org.dromara.bigscreen.domain.progress.ProjectTotalProgressVo; import org.dromara.bigscreen.domain.vo.*; import org.dromara.bigscreen.service.DpzaglService; import org.dromara.bigscreen.service.IMaterialsManagementService; +import org.dromara.bigscreen.service.ProgressBigScreenService; import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; @@ -66,7 +70,7 @@ public class BigScreenWebSocketServer { SUBSCRIPTION_SESSIONS.put(currentSubscriptionId, session); SESSION_TO_SUBSCRIPTION.put(session.getId(), currentSubscriptionId); log.info("📌 客户端订阅成功!订阅ID:{},会话ID:{},当前订阅数:{}", - currentSubscriptionId, session.getId(), SUBSCRIPTION_SESSIONS.size()); + currentSubscriptionId, session.getId(), SUBSCRIPTION_SESSIONS.size()); } else { log.warn("📌 客户端连接未携带订阅ID!会话ID:{}", session.getId()); } @@ -91,69 +95,71 @@ public class BigScreenWebSocketServer { List> maps = new ArrayList<>(); - switch ((int) type){ + switch ((int) type) { case 1: break; case 2: Long timeType = Long.parseLong(params.get("timeType").getFirst()); //判断参数 - if (timeType != 1L && timeType != 2L && timeType != 3L){ + if (timeType != 1L && timeType != 2L && timeType != 3L) { throw new RuntimeException("时间类型参数错误"); } //先获取左边坐标得到map Map infoData = busAttendanceService.getRyglOnlineUserInfoData(projectId); //获取右边数据 - busAttendanceService.getAttendanceInfo(projectId,timeType,infoData); + busAttendanceService.getAttendanceInfo(projectId, timeType, infoData); //返回数据 maps.add(infoData); break; case 3: - if (dpzaglService != null){ - saveDateDpzagl(dpzaglService,params,projectId,maps); + if (dpzaglService != null) { + saveDateDpzagl(dpzaglService, params, projectId, maps); } break; case 4: + // 进度管理大屏 + getProgressBigScreenData(maps, projectId); break; case 5: - if (materialsService != null){ + if (materialsService != null) { InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId); - if (vo != null){ + if (vo != null) { Map map = new HashMap<>(); - map.put("type","inventoryStructureAnalysis"); + map.put("type", "inventoryStructureAnalysis"); map.put("data", JSONUtil.toJsonStr(vo)); maps.add(map); } } - if (purchaseDocService != null){ + if (purchaseDocService != null) { List purchaseDocVos = purchaseDocService.purchaseNote(projectId); - if (purchaseDocVos != null && !purchaseDocVos.isEmpty()){ + if (purchaseDocVos != null && !purchaseDocVos.isEmpty()) { Map map = new HashMap<>(); - map.put("type","purchaseNote"); + map.put("type", "purchaseNote"); map.put("data", JSONUtil.toJsonStr(purchaseDocVos)); maps.add(map); } } - if (mrpBaseService != null){ + if (mrpBaseService != null) { List designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId); - if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()){ + if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()) { Map map = new HashMap<>(); - map.put("type","designAndArrivalComparison"); + map.put("type", "designAndArrivalComparison"); map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos)); maps.add(map); } List wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId); - if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()){ + if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()) { Map map = new HashMap<>(); - map.put("type","wzxqysjdhdb"); + map.put("type", "wzxqysjdhdb"); map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos)); maps.add(map); } } - if (materialsService != null){ + if (materialsService != null) { List useDetailVos = materialsService.listUseDetail(projectId); - if (useDetailVos != null && !useDetailVos.isEmpty()){ + if (useDetailVos != null && !useDetailVos.isEmpty()) { Map map = new HashMap<>(); - map.put("type","listUseDetail"); + map.put("type", "listUseDetail"); map.put("data", JSONUtil.toJsonStr(useDetailVos)); maps.add(map); } @@ -217,8 +223,8 @@ public class BigScreenWebSocketServer { log.info("🔌 客户端订阅关系已清除!订阅ID:{},会话ID:{}", subscriptionId, session.getId()); } log.info("🔌 客户端断开连接!会话ID:{},原因:{},当前在线数:{},当前订阅数:{}", - session.getId(), reason.getReasonPhrase(), - ONLINE_SESSIONS.size(), SUBSCRIPTION_SESSIONS.size()); + session.getId(), reason.getReasonPhrase(), + ONLINE_SESSIONS.size(), SUBSCRIPTION_SESSIONS.size()); } /** @@ -234,8 +240,9 @@ public class BigScreenWebSocketServer { /** * 向指定订阅ID的客户端发送消息 + * * @param subscriptionId 订阅ID - * @param message 消息内容 + * @param message 消息内容 * @return 是否发送成功 */ public static boolean sendToSubscription(String subscriptionId, String message) { @@ -262,6 +269,7 @@ public class BigScreenWebSocketServer { /** * 向所有订阅客户端广播消息 + * * @param message 消息内容 */ public static void broadcastToAllSubscriptions(String message) { @@ -310,39 +318,74 @@ public class BigScreenWebSocketServer { } - private void saveDateDpzagl(DpzaglService dpzaglService, Map> params,Long projectId,List> maps) { + private void saveDateDpzagl(DpzaglService dpzaglService, Map> params, Long projectId, List> maps) { DpznglBo dpznglBo = new DpznglBo(); dpznglBo.setProjectId(projectId); // 查询大屏-质安管理-安全员分布情况 List dpznglAqyVos = dpzaglService.listByAqy(dpznglBo); - if (dpznglAqyVos != null && dpznglAqyVos.size() > 0){ + if (dpznglAqyVos != null && dpznglAqyVos.size() > 0) { Map map = new HashMap<>(); - map.put("type","aqy"); + map.put("type", "aqy"); map.put("data", JSONUtil.toJsonStr(dpznglAqyVos)); maps.add(map); } - // 查询大屏-质安管理-站班会,巡检工单,整改情况 + // 查询大屏-质安管理-站班会,巡检工单,整改情况 DpznglVo dpznglVo = dpzaglService.queryList(dpznglBo); - if (dpznglVo != null){ + if (dpznglVo != null) { Map map = new HashMap<>(); - map.put("type","zagl"); + map.put("type", "zagl"); map.put("data", JSONUtil.toJsonStr(dpznglVo)); maps.add(map); } - //查询大屏-质安管理-站班会 + //查询大屏-质安管理-站班会 DpznglVo byzbh = dpzaglService.listByzbh(dpznglBo); - if (byzbh != null){ + if (byzbh != null) { Map map = new HashMap<>(); - map.put("type","zbh"); + map.put("type", "zbh"); map.put("data", JSONUtil.toJsonStr(byzbh)); maps.add(map); } } - + /** + * 获取进度大屏数据 + */ + private static void getProgressBigScreenData(List> maps, Long projectId) { + ProgressBigScreenService service = SpringUtils.getBean(ProgressBigScreenService.class); + if (service != null) { + DesignProgressVo designProgress = service.getDesignProgress(projectId); + if (designProgress != null) { + Map map = new HashMap<>(); + map.put("type", "progressDesignProgress"); + map.put("data", JSONUtil.toJsonStr(designProgress)); + maps.add(map); + } + ProjectTotalProgressVo projectTotalProgress = service.getProjectTotalProgress(projectId); + if (projectTotalProgress != null) { + Map map = new HashMap<>(); + map.put("type", "progressProjectTotalProgress"); + map.put("data", JSONUtil.toJsonStr(projectTotalProgress)); + maps.add(map); + } + List milestoneProgress = service.getMilestoneProgress(projectId); + if (milestoneProgress != null) { + Map map = new HashMap<>(); + map.put("type", "progressMilestoneProgress"); + map.put("data", JSONUtil.toJsonStr(milestoneProgress)); + maps.add(map); + } + List materialProgress = service.getMaterialProgress(projectId); + if (materialProgress != null) { + Map map = new HashMap<>(); + map.put("type", "progressMaterialProgress"); + map.put("data", JSONUtil.toJsonStr(materialProgress)); + maps.add(map); + } + } + } } From d3a1f667a75248fb3410c32c763996558ec81a78 Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Tue, 16 Dec 2025 20:02:58 +0800 Subject: [PATCH 17/38] =?UTF-8?q?=E8=B4=A8=E5=AE=89=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DpzaglServiceImpl.java | 17 +++++++++--- .../service/BigScreenWebSocketServer.java | 27 ++++++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java index f5c02f99..be22b42f 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java @@ -8,6 +8,7 @@ import org.dromara.bigscreen.domain.vo.DpznglAqyVo; import org.dromara.bigscreen.domain.vo.DpznglVo; import org.dromara.bigscreen.enums.DpEnum; import org.dromara.bigscreen.service.DpzaglService; +import org.dromara.common.core.service.UserService; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.domain.GeoPoint; import org.dromara.common.mybatis.core.page.PageQuery; @@ -25,6 +26,7 @@ import org.dromara.quality.domain.dto.qualityinspection.QltQualityInspectionQuer import org.dromara.quality.domain.vo.qualityinspection.QltQualityInspectionVo; import org.dromara.quality.service.IQltQualityInspectionService; import org.dromara.safety.domain.HseSafetyInspection; +import org.dromara.safety.domain.HseTeamMeeting; import org.dromara.safety.domain.dto.safetyinspection.HseSafetyInspectionQueryReq; import org.dromara.safety.domain.dto.teammeeting.HseTeamMeetingQueryReq; import org.dromara.safety.domain.vo.safetyinspection.HseSafetyInspectionVo; @@ -36,6 +38,7 @@ import org.dromara.system.domain.SysUserRole; import org.dromara.system.mapper.SysRoleMapper; import org.dromara.system.mapper.SysUserRoleMapper; import org.dromara.system.service.ISysRoleService; +import org.dromara.system.service.ISysUserService; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -65,6 +68,8 @@ public class DpzaglServiceImpl implements DpzaglService { private final SysRoleMapper sysRoleMapper; + private final UserService userService; + private final SysUserRoleMapper sysUserRoleMapper; @@ -145,7 +150,7 @@ public class DpzaglServiceImpl implements DpzaglService { //判断是否在岗 for (DpznglAqyVo dpznglAqyVo : dpznglAqyVos) { dpznglAqyVo.setSfzg(DpEnum.RYZT_LG.getTypeValue()); - + dpznglAqyVo.setUserName(userService.selectNicknameByIds(dpznglAqyVo.getUserId().toString())); for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) { List coordinates = List.of(busProjectPunchrange.getPunchRange()); List matchingRange = JSTUtil.findMatchingRange(dpznglAqyVo.getLocLatitude().toString(), dpznglAqyVo.getLocLongitude().toString(), coordinates); @@ -163,8 +168,10 @@ public class DpzaglServiceImpl implements DpzaglService { // 站班会 HseTeamMeetingQueryReq hseTeamMeetingQueryReq = new HseTeamMeetingQueryReq(); - List hseTeamMeetingVos = teamMeetingService.queryList(hseTeamMeetingQueryReq); - dpznglVo.setZbhList(hseTeamMeetingVos); +// List hseTeamMeetingVos = teamMeetingService.queryList(hseTeamMeetingQueryReq); + List hseTeamMeetings = teamMeetingService.getBaseMapper().selectList(new LambdaQueryWrapper().ge(HseTeamMeeting::getProjectId, bo.getProjectId())); + dpznglVo.setZbhList(MapstructUtils.convert(hseTeamMeetings, HseTeamMeetingVo.class)); + dpznglVo.getZbhList().forEach(hseTeamMeetingVo -> {hseTeamMeetingVo.setCreateByName(userService.selectNicknameByIds(hseTeamMeetingVo.getCreateBy().toString()));}); return dpznglVo; } @@ -186,12 +193,14 @@ public class DpzaglServiceImpl implements DpzaglService { if (list != null && list.size() > 0){ dpznglVo.setAqZS(Long.valueOf(list.size())); dpznglVo.setAqList(MapstructUtils.convert(list, HseSafetyInspectionVo.class)); + dpznglVo.getAqList().forEach(zl ->{zl.setCreatorName(userService.selectNicknameByIds(zl.getCreateBy().toString()));}); dpznglVo.setZxjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_ZXGL.getTypeValue().equals(zl.getCheckType())).count()); dpznglVo.setDqjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getCheckType())).count()); dpznglVo.setRcxjAq(list.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getCheckType())).count()); dpznglVo.setAqZgsl(list.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getStatus())).count()); } if (aqZgList.getRows() != null && aqZgList.getRows().size() > 0){ + aqZgList.getRows().forEach(zl ->{zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}); dpznglVo.setAqZgList(aqZgList.getRows()); } @@ -218,12 +227,14 @@ public class DpzaglServiceImpl implements DpzaglService { if (zsZl != null && zsZl.size() > 0){ dpznglVo.setZlZS(Long.valueOf(zsZl.size())); dpznglVo.setZlList(MapstructUtils.convert(zsZl, QltQualityInspectionVo.class)); + dpznglVo.getZlList().forEach(zl ->{zl.setCreateByName(userService.selectNicknameByIds(zl.getCreateBy().toString()));}); dpznglVo.setZxjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_ZXGL.getTypeValue().equals(zl.getInspectionType())).count()); dpznglVo.setDqjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getInspectionType())).count()); dpznglVo.setRcxjZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getInspectionType())).count()); dpznglVo.setZlZgsl(zsZl.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getInspectionStatus())).count()); } if (zlZgLists.getRows() != null && zlZgLists.getRows().size() > 0){ + zlZgLists.getRows().forEach(zl ->{zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}); dpznglVo.setZlZgList(zlZgLists.getRows()); } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index e8be939f..9913bce0 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -15,6 +15,7 @@ import org.dromara.bigscreen.service.ProgressBigScreenService; import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; +import org.dromara.common.core.utils.DateUtils; import org.dromara.common.core.utils.SpringUtils; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; @@ -22,10 +23,10 @@ import org.dromara.project.service.impl.BusAttendanceServiceImpl; import org.springframework.stereotype.Component; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; @@ -318,9 +319,27 @@ public class BigScreenWebSocketServer { } + /** + * 查询大屏质保管理 + */ private void saveDateDpzagl(DpzaglService dpzaglService, Map> params, Long projectId, List> maps) { DpznglBo dpznglBo = new DpznglBo(); dpznglBo.setProjectId(projectId); + + List startDate = params.get("startDate"); + List endDate = params.get("endDate"); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); + + + if (startDate != null && startDate.size() > 0){ + String first = startDate.getFirst(); + dpznglBo.setStartDate(LocalDate.parse(first, formatter)); + } + if (endDate != null && endDate.size() > 0){ + String first = endDate.getFirst(); + dpznglBo.setEndDate(LocalDate.parse(first, formatter)); + } + // 查询大屏-质安管理-安全员分布情况 List dpznglAqyVos = dpzaglService.listByAqy(dpznglBo); From c1f5cc33b0548f6e52afe26ddde041dade91d628 Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Tue, 16 Dec 2025 20:32:21 +0800 Subject: [PATCH 18/38] =?UTF-8?q?=E8=B4=A8=E5=AE=89=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/bigscreen/service/impl/DpzaglServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java index be22b42f..67685613 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java @@ -171,7 +171,7 @@ public class DpzaglServiceImpl implements DpzaglService { // List hseTeamMeetingVos = teamMeetingService.queryList(hseTeamMeetingQueryReq); List hseTeamMeetings = teamMeetingService.getBaseMapper().selectList(new LambdaQueryWrapper().ge(HseTeamMeeting::getProjectId, bo.getProjectId())); dpznglVo.setZbhList(MapstructUtils.convert(hseTeamMeetings, HseTeamMeetingVo.class)); - dpznglVo.getZbhList().forEach(hseTeamMeetingVo -> {hseTeamMeetingVo.setCreateByName(userService.selectNicknameByIds(hseTeamMeetingVo.getCreateBy().toString()));}); + dpznglVo.getZbhList().forEach(hseTeamMeetingVo -> {if ( hseTeamMeetingVo.getCompereId() != null){hseTeamMeetingVo.setCompereName(userService.selectNicknameByIds(hseTeamMeetingVo.getCompereId().toString()));}}); return dpznglVo; } @@ -200,7 +200,7 @@ public class DpzaglServiceImpl implements DpzaglService { dpznglVo.setAqZgsl(list.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getStatus())).count()); } if (aqZgList.getRows() != null && aqZgList.getRows().size() > 0){ - aqZgList.getRows().forEach(zl ->{zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}); + aqZgList.getRows().forEach(zl ->{if (zl.getCorrectorId() != null){zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}}); dpznglVo.setAqZgList(aqZgList.getRows()); } @@ -234,7 +234,7 @@ public class DpzaglServiceImpl implements DpzaglService { dpznglVo.setZlZgsl(zsZl.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getInspectionStatus())).count()); } if (zlZgLists.getRows() != null && zlZgLists.getRows().size() > 0){ - zlZgLists.getRows().forEach(zl ->{zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}); + zlZgLists.getRows().forEach(zl ->{if (zl.getCorrectorId() != null){zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}}); dpznglVo.setZlZgList(zlZgLists.getRows()); } } From 2fd173676650b41c5d9f8ab4c6ddc7065f152722 Mon Sep 17 00:00:00 2001 From: dfdg <2710245601@qq.com> Date: Wed, 17 Dec 2025 09:28:27 +0800 Subject: [PATCH 19/38] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E6=B6=88=E8=80=97=E8=B6=8B=E5=8A=BF=E5=AF=B9?= =?UTF-8?q?=E6=AF=94=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialsManagementController.java | 9 ++ .../dromara/bigscreen/domain/vo/xhqsdbVo.java | 35 +++++ .../service/IMaterialsManagementService.java | 9 ++ .../impl/MaterialsManagementServiceImpl.java | 108 +++++++++++--- .../impl/BusPurchaseDocServiceImpl.java | 15 +- .../service/BigScreenWebSocketServer.java | 136 ++++++++++++------ 6 files changed, 248 insertions(+), 64 deletions(-) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/xhqsdbVo.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java index 2ba79053..5f230cdd 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo; import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.dromara.bigscreen.domain.vo.xhqsdbVo; import org.dromara.bigscreen.service.IMaterialsManagementService; import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo; import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; @@ -94,6 +95,14 @@ public class MaterialsManagementController extends BaseController { return R.ok(busMrpBaseService.wzxqysjdhdb(projectId)); } + /** + * 消耗趋势对比 + */ + @GetMapping("/xhqsdb") + public R> xhqsdb(Long projectId) { + return R.ok(materialsManagementService.xhqsdb(projectId)); + } + /** * 获取材料使用详情列表 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/xhqsdbVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/xhqsdbVo.java new file mode 100644 index 00000000..f2661d03 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/xhqsdbVo.java @@ -0,0 +1,35 @@ +package org.dromara.bigscreen.domain.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 物资需求与实际到货对比vo + */ +@Data +public class xhqsdbVo implements Serializable { + + /** + * 名称 + */ + public String name; + + /** + * 规格 + */ + public String specification; + + + /** + * 出库量 + */ + public BigDecimal outTotalPrices; + + /** + * 使用量 + */ + public BigDecimal useTotalPrices; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java index 226d317c..a6d71b04 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java @@ -2,6 +2,8 @@ package org.dromara.bigscreen.service; import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; +import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.dromara.bigscreen.domain.vo.xhqsdbVo; import org.dromara.project.domain.vo.project.BusProjectGisVo; import java.util.List; @@ -17,4 +19,11 @@ public interface IMaterialsManagementService { * @return */ InventoryStructureAnalysisVo inventoryStructureAnalysis(Long projectId); + + /** + * 消耗趋势对比 + * @param projectId + * @return + */ + List xhqsdb(Long projectId); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java index 70bb2aa0..3169a9e5 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java @@ -5,14 +5,12 @@ import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import jakarta.annotation.Resource; import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; +import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.dromara.bigscreen.domain.vo.xhqsdbVo; import org.dromara.bigscreen.enums.WuZhiEnum; import org.dromara.bigscreen.service.IMaterialsManagementService; -import org.dromara.materials.domain.MatMaterialIssueItem; -import org.dromara.materials.domain.MatMaterialReceiveItem; -import org.dromara.materials.service.IMatMaterialIssueItemService; -import org.dromara.materials.service.IMatMaterialReceiveItemService; -import org.dromara.materials.service.IMatMaterialsInventoryService; -import org.dromara.materials.service.IMatMaterialsService; +import org.dromara.materials.domain.*; +import org.dromara.materials.service.*; import org.dromara.project.domain.vo.project.BusProjectGisVo; import org.dromara.tender.domain.BusBillofquantitiesLimitList; import org.dromara.tender.service.IBusBillofquantitiesLimitListService; @@ -22,8 +20,8 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.temporal.TemporalAdjusters; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; @Service public class MaterialsManagementServiceImpl implements IMaterialsManagementService { @@ -42,6 +40,12 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi @Lazy @Resource private IBusBillofquantitiesLimitListService billofquantitiesLimitListService; + @Lazy + @Resource + private IMatMaterialsInventoryService materialsInventoryService; + @Lazy + @Resource + private IMatMaterialsUseRecordService matMaterialsUseRecordService; @Override @@ -85,10 +89,10 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi .between(MatMaterialReceiveItem::getCreateTime, monthStart, currentTime)); if (CollUtil.isEmpty(matMaterialReceiveItems)) { vo.setEnterTotalPrices(BigDecimal.ZERO); - }else { + } else { // 计算本月入库金额 BigDecimal enterTotalPrices = matMaterialReceiveItems.stream() - .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO)) .reduce(BigDecimal.ZERO, BigDecimal::add); vo.setEnterTotalPrices(enterTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } @@ -99,10 +103,10 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi .between(MatMaterialReceiveItem::getCreateTime, lastMonthFirstDay, lastMonthLastDay)); if (CollUtil.isEmpty(oldMatMaterialReceiveItems)) { vo.setOldEnterTotalPrices(BigDecimal.ZERO); - }else { + } else { // 计算上月入库金额 BigDecimal oldEnterTotalPrices = oldMatMaterialReceiveItems.stream() - .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO)) .reduce(BigDecimal.ZERO, BigDecimal::add); vo.setOldEnterTotalPrices(oldEnterTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } @@ -116,9 +120,9 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi //计算本月出库金额 if (CollUtil.isEmpty(matMaterialIssueItems)) { vo.setLeaveTotalPrices(BigDecimal.ZERO); - }else { + } else { BigDecimal leaveTotalPrices = matMaterialIssueItems.stream() - .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO)) .reduce(BigDecimal.ZERO, BigDecimal::add); vo.setLeaveTotalPrices(leaveTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } @@ -131,9 +135,9 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi //计算上月出库金额 if (CollUtil.isEmpty(oldMatMaterialIssueItems)) { vo.setOldLeaveTotalPrices(BigDecimal.ZERO); - }else { + } else { BigDecimal oldLeaveTotalPrices = oldMatMaterialIssueItems.stream() - .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO)) .reduce(BigDecimal.ZERO, BigDecimal::add); vo.setOldLeaveTotalPrices(oldLeaveTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } @@ -141,10 +145,10 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi List totalMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(MatMaterialReceiveItem::getProjectId, projectId)); if (CollUtil.isEmpty(totalMatMaterialReceiveItems)) { vo.setInventoryTotalPrices(BigDecimal.ZERO); - }else { + } else { // 计算总入库存金额 BigDecimal inventoryTotalPrices = totalMatMaterialReceiveItems.stream() - .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO)) .reduce(BigDecimal.ZERO, BigDecimal::add); vo.setInventoryTotalPrices(inventoryTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } @@ -153,10 +157,10 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi List totalMatMaterialIssueItems = materialIssueItemService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(MatMaterialIssueItem::getProjectId, projectId)); if (CollUtil.isEmpty(totalMatMaterialIssueItems)) { vo.setOutTotalPrices(BigDecimal.ZERO); - }else { + } else { // 计算总出库金额 BigDecimal outTotalPrices = totalMatMaterialIssueItems.stream() - .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null? item.getUnitPrice() : BigDecimal.ZERO)) + .map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO)) .reduce(BigDecimal.ZERO, BigDecimal::add); vo.setOutTotalPrices(outTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP)); } @@ -210,4 +214,68 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi vo.setNowInventoryTotalPrices(nowInventoryTotalPrices); return vo; } + + /** + * 消耗趋势对比 + * + * @param projectId + * @return + */ + @Override + public List xhqsdb(Long projectId) { + List list = new ArrayList<>(); + List inventories = materialsInventoryService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .eq(MatMaterialsInventory::getProjectId, projectId) + .eq(MatMaterialsInventory::getOutPut, "2")); + if (CollUtil.isEmpty(inventories)) { + return List.of(); + } + HashMap inventoryHashMap = new HashMap<>(); + inventories.forEach(item -> { + if (inventoryHashMap.containsKey(item.getMaterialsId())){ + inventoryHashMap.put(item.getMaterialsId(), inventoryHashMap.get(item.getMaterialsId()).add(new BigDecimal(item.getNumber()))); + }else { + inventoryHashMap.put(item.getMaterialsId(), new BigDecimal(item.getNumber())); + } + }); + Set mids = inventories.stream().map(MatMaterialsInventory::getMaterialsId).collect(Collectors.toSet()); + if (CollUtil.isEmpty(mids)){ + return List.of(); + } + List materials = materialsService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(MatMaterials::getProjectId, projectId) + .in(MatMaterials::getId, mids)); + if (CollUtil.isEmpty(materials)) { + return List.of(); + } + Map map1 = materials.stream() + .collect(Collectors.toMap(MatMaterials::getId, MatMaterials::getMaterialsName)); + Set ids = inventories.stream() + .map(MatMaterialsInventory::getId) + .collect(Collectors.toSet()); + if (CollUtil.isEmpty(ids)) { + return List.of(); + } + List useRecords = matMaterialsUseRecordService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .eq(MatMaterialsUseRecord::getProjectId, projectId) + .in(MatMaterialsUseRecord::getInventoryId, ids)); + if (CollUtil.isEmpty(useRecords)) { + return List.of(); + } + Map map = useRecords.stream() + .collect(Collectors.groupingBy( + MatMaterialsUseRecord::getInventoryId, + Collectors.reducing(BigDecimal.ZERO, MatMaterialsUseRecord::getUseNumber, BigDecimal::add) + )); + inventoryHashMap.forEach((key, value) -> { + xhqsdbVo vo = new xhqsdbVo(); + vo.setName(map1.get(key)); + vo.setOutTotalPrices( value); + vo.setUseTotalPrices(map.getOrDefault(key, BigDecimal.ZERO)); + list.add(vo); + }); + return list; + } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java index 9fde9ed4..72af6ad4 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusPurchaseDocServiceImpl.java @@ -111,6 +111,9 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl busPlanDocAssociationVos = planDocAssociationService.queryList(busPlanDocAssociationBo); @@ -582,11 +585,21 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl purchaseNote(Long projectId) { - return baseMapper.selectVoList(new LambdaQueryWrapper() + List busPurchaseDocVos = baseMapper.selectVoList(new LambdaQueryWrapper() .eq(BusPurchaseDoc::getProjectId, projectId) .eq(BusPurchaseDoc::getDocType, "1") .eq(BusPurchaseDoc::getStatus, BusinessStatusEnum.FINISH.getStatus()) .orderByDesc(BusPurchaseDoc::getCreateTime)); + if (busPurchaseDocVos == null){ + return List.of(); + } + busPurchaseDocVos.forEach(v -> { + BusMrpBase byId = mrpBaseService.getById(v.getMrpBaseId()); + if (byId != null) { + v.setPlanCode(byId.getPlanCode()); + } + }); + return busPurchaseDocVos; } /** diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index 9913bce0..f1eded0c 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -122,49 +122,8 @@ public class BigScreenWebSocketServer { getProgressBigScreenData(maps, projectId); break; case 5: - if (materialsService != null) { - InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId); - if (vo != null) { - Map map = new HashMap<>(); - map.put("type", "inventoryStructureAnalysis"); - map.put("data", JSONUtil.toJsonStr(vo)); - maps.add(map); - } - } - if (purchaseDocService != null) { - List purchaseDocVos = purchaseDocService.purchaseNote(projectId); - if (purchaseDocVos != null && !purchaseDocVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "purchaseNote"); - map.put("data", JSONUtil.toJsonStr(purchaseDocVos)); - maps.add(map); - } - } - if (mrpBaseService != null) { - List designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId); - if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "designAndArrivalComparison"); - map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos)); - maps.add(map); - } - List wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId); - if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "wzxqysjdhdb"); - map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos)); - maps.add(map); - } - } - if (materialsService != null) { - List useDetailVos = materialsService.listUseDetail(projectId); - if (useDetailVos != null && !useDetailVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "listUseDetail"); - map.put("data", JSONUtil.toJsonStr(useDetailVos)); - maps.add(map); - } - } + //物资管理大屏 + generateLargeScreenData(materialsService, managementService, projectId, maps, purchaseDocService, mrpBaseService); break; case 6: break; @@ -193,6 +152,68 @@ public class BigScreenWebSocketServer { }); } + /** + * 获取物资管理大屏数据 + */ + private static void generateLargeScreenData(IMatMaterialsService materialsService, IMaterialsManagementService managementService, Long projectId, List> maps, IBusPurchaseDocService purchaseDocService, IBusMrpBaseService mrpBaseService) { + if (materialsService != null) { + //库存结构分析 + InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId); + if (vo != null) { + Map map = new HashMap<>(); + map.put("type", "inventoryStructureAnalysis"); + map.put("data", JSONUtil.toJsonStr(vo)); + maps.add(map); + } + //消耗趋势对比 + List xhqsdb = managementService.xhqsdb(projectId); + if (xhqsdb != null && !xhqsdb.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "xhqsdb"); + map.put("data", JSONUtil.toJsonStr(xhqsdb)); + maps.add(map); + } + } + if (purchaseDocService != null) { + //采购单 + List purchaseDocVos = purchaseDocService.purchaseNote(projectId); + if (purchaseDocVos != null && !purchaseDocVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "purchaseNote"); + map.put("data", JSONUtil.toJsonStr(purchaseDocVos)); + maps.add(map); + } + } + if (mrpBaseService != null) { + //设计量与到货量对比 + List designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId); + if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "designAndArrivalComparison"); + map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos)); + maps.add(map); + } + //物资需求与实际到货对比 + List wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId); + if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "wzxqysjdhdb"); + map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos)); + maps.add(map); + } + } + if (materialsService != null) { + //物资跟踪管理台账 + List useDetailVos = materialsService.listUseDetail(projectId); + if (useDetailVos != null && !useDetailVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "listUseDetail"); + map.put("data", JSONUtil.toJsonStr(useDetailVos)); + maps.add(map); + } + } + } + /** * 接收客户端消息 */ @@ -201,6 +222,35 @@ public class BigScreenWebSocketServer { log.info("📥 收到会话[{}](订阅ID:{})消息:{}", session.getId(), currentSubscriptionId, message); // 可选:回复客户端 //todo 填充不同类型大屏获取数据的方法判断 + String subscriptionId = SESSION_TO_SUBSCRIPTION.get(session.getId()); + if (subscriptionId == null || subscriptionId.isEmpty()) { + log.warn("⚠️ 订阅ID为空,发送失败"); + return; + } + String[] split = subscriptionId.split("-"); + Long projectId = Long.parseLong(split[0]); + long type = Long.parseLong(split[1]); + switch ((int) type) { + case 1: + break; + case 2: + break; + case 3: + + break; + case 4: + // 进度管理大屏 + break; + case 5: + //物资管理大屏 + break; + case 6: + break; + case 7: + break; + default: + break; + } try { session.getBasicRemote().sendText("服务端已收到消息:" + message); From 667a460258c1546fa439d177449a2b06f441fba8 Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Wed, 17 Dec 2025 11:16:51 +0800 Subject: [PATCH 20/38] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/ProjectImageProgressDetailReq.java | 5 + .../impl/ProgressBigScreenServiceImpl.java | 1 + .../impl/ProjectBigScreenServiceImpl.java | 102 ++++++++++++------ 3 files changed, 75 insertions(+), 33 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/dto/ProjectImageProgressDetailReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/dto/ProjectImageProgressDetailReq.java index 0aafb0a5..67240a80 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/dto/ProjectImageProgressDetailReq.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/dto/ProjectImageProgressDetailReq.java @@ -27,4 +27,9 @@ public class ProjectImageProgressDetailReq implements Serializable { */ @NotNull(message = "进度名称不能为空") private String progressName; + + /** + * 是否查询光伏场区所有数据 + */ + private Boolean isAll = false; } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java index ab3ee2fd..49a8b6b3 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java @@ -175,6 +175,7 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { */ @Override public List getProjectTotalProgressDetail(ProjectImageProgressDetailReq req) { + req.setIsAll(true); return projectBigScreenService.getProjectImageProgressDetail(req); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java index 6896bb4e..77547d18 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import jakarta.annotation.Resource; import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq; @@ -530,25 +531,38 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService { Set projectIds = subProjects.stream().map(BusProject::getId).collect(Collectors.toSet()); projectIds.add(projectId); // 获取对应进度 - PgsProgressCategory progressCategory = progressCategoryService.lambdaQuery() + List progressCategoryList = progressCategoryService.lambdaQuery() .in(PgsProgressCategory::getProjectId, projectIds) .eq(PgsProgressCategory::getName, progressName) - .last("limit 1") - .one(); - if (progressCategory == null) { + .list(); + if (CollUtil.isEmpty(progressCategoryList)) { return List.of(); } - Long topId = progressCategory.getId(); - final List gfcqName = List.of("场地平整", "桩基成孔", "桩基浇筑", "支架安装", "组件安装"); // 查出所有属于该顶级节点的子孙节点 - List allChildren = progressCategoryService.list( - Wrappers.lambdaQuery() - .in(progressName.equals("光伏场区"), PgsProgressCategory::getName, gfcqName) - .and(wrapper -> - wrapper.like(PgsProgressCategory::getAncestors, "," + topId + ",") - .or() - .like(PgsProgressCategory::getAncestors, "," + topId)) - ); + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + List allChildren; + if (progressName.equals("光伏场区")) { + final List gfcqName = List.of("场地平整", "桩基成孔", "桩基浇筑", "支架安装", "组件安装"); + List topIds = progressCategoryList.stream().map(PgsProgressCategory::getId).toList(); + // 查出所有属于这些顶级节点的子孙节点 + allChildren = progressCategoryService.list( + Wrappers.lambdaQuery() + .in(!req.getIsAll(), PgsProgressCategory::getName, gfcqName) + .and(wrapper -> { + for (Long topId : topIds) { + wrapper.or(q -> q.like(PgsProgressCategory::getAncestors, "," + topId + ",")) + .or(q -> q.like(PgsProgressCategory::getAncestors, "," + topId)); + } + }) + ); + } else { + PgsProgressCategory first = progressCategoryList.getFirst(); + lqw.and(wrapper -> + wrapper.like(PgsProgressCategory::getAncestors, "," + first.getId() + ",") + .or() + .like(PgsProgressCategory::getAncestors, "," + first.getId())); + allChildren = progressCategoryService.list(lqw); + } if (allChildren.isEmpty()) { return Collections.emptyList(); } @@ -556,7 +570,6 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService { Set parentIds = allChildren.stream() .map(PgsProgressCategory::getParentId) .collect(Collectors.toSet()); - List dierList = allChildren.stream() .filter(item -> !parentIds.contains(item.getId())) .toList(); @@ -575,26 +588,47 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService { Set parentIds = allChildren.stream() .map(PgsProgressCategory::getParentId) .collect(Collectors.toSet()); - List dierList = allChildren.stream() .filter(item -> parentIds.contains(item.getId())) .toList(); + List detailVoList = new ArrayList<>(); if (CollUtil.isEmpty(dierList)) { - return allChildren.stream().map(c -> { + // 根据名称进行分类汇总 + Map> childrenMap = allChildren.stream() + .collect(Collectors.groupingBy(PgsProgressCategory::getName)); + childrenMap.forEach((name, children) -> { + if (CollUtil.isEmpty(children)) { + return; + } ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo(); - vo.setId(c.getId()); - vo.setUnit(c.getUnit()); - vo.setProgressName(c.getName()); - vo.setPlanProgress(c.getPlanTotal()); - vo.setActualProgress(c.getCompleted()); - vo.setTotalProgress(c.getTotal()); - return vo; - }).toList(); + String unit = children.stream().map(PgsProgressCategory::getUnit) + .filter(Objects::nonNull) + .findFirst().orElse(null); + vo.setUnit(unit); + vo.setProgressName(name); + BigDecimal plan = children.stream().map(PgsProgressCategory::getPlanTotal) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setPlanProgress(plan); + BigDecimal completed = children.stream().map(PgsProgressCategory::getCompleted) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setActualProgress(completed); + BigDecimal total = children.stream().map(PgsProgressCategory::getTotal) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setTotalProgress(total); + detailVoList.add(vo); + }); } else { - return dierList.stream().map(c -> { + // 根据名称进行分类汇总 + Map> dierMap = dierList.stream() + .collect(Collectors.groupingBy(PgsProgressCategory::getName)); + dierMap.forEach((name, value) -> { + ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo(); + Set parentIdSet = value.stream() + .map(PgsProgressCategory::getId) + .collect(Collectors.toSet()); // 获取子集 List children = allChildren.stream() - .filter(item -> item.getParentId().equals(c.getId())) + .filter(item -> parentIdSet.contains(item.getParentId())) .toList(); // 计算 BigDecimal plan = children.stream().map(PgsProgressCategory::getPlanTotal) @@ -603,16 +637,18 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService { .reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal total = children.stream().map(PgsProgressCategory::getTotal) .reduce(BigDecimal.ZERO, BigDecimal::add); - ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo(); - vo.setId(c.getId()); - vo.setUnit(c.getUnit()); - vo.setProgressName(c.getName()); vo.setPlanProgress(plan); vo.setActualProgress(actual); vo.setTotalProgress(total); - return vo; - }).toList(); + vo.setProgressName(name); + String unit = value.stream().map(PgsProgressCategory::getUnit) + .filter(Objects::nonNull) + .findFirst().orElse(null); + vo.setUnit(unit); + detailVoList.add(vo); + }); } + return detailVoList; } /** From 98db0647ca86a5b8cfe94fe617c4199695020fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Wed, 17 Dec 2025 11:21:41 +0800 Subject: [PATCH 21/38] =?UTF-8?q?12-17-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BusAttendanceServiceImpl.java | 158 +++++++++--------- .../service/BigScreenWebSocketServer.java | 17 +- 2 files changed, 95 insertions(+), 80 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index 03af5ec3..a47f1105 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -38,7 +38,6 @@ import org.dromara.contractor.service.ISubConstructionUserService; import org.dromara.project.domain.*; import org.dromara.project.domain.bo.BusAttendanceBo; import org.dromara.project.domain.dto.attendance.*; -import org.dromara.project.domain.enums.BusAttendanceClockStatusEnum; import org.dromara.project.domain.enums.BusAttendanceCommuterEnum; import org.dromara.project.domain.enums.BusAttendanceStatusEnum; import org.dromara.project.domain.vo.BusAttendanceRuleVo; @@ -125,9 +124,9 @@ public class BusAttendanceServiceImpl extends ServiceImpl ATTENDANCE_STATUS = new HashSet<>(Arrays.asList(BusAttendanceClockStatusEnum.NORMAL.getValue(), + private static final Set ATTENDANCE_STATUS = new HashSet<>(Arrays.asList(NORMAL.getValue(), LATE.getValue(), LEAVEEARLY.getValue() - , BusAttendanceClockStatusEnum.REISSUE.getValue())); + , REISSUE.getValue())); /** @@ -203,7 +202,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl sysOssVos = ossService.listByIds(longList); Map ossMap = sysOssVos.stream().collect(Collectors.toMap(SysOssVo::getOssId, SysOssVo::getUrl)); @@ -244,13 +243,13 @@ public class BusAttendanceServiceImpl extends ServiceImpl abnormalList = Arrays.asList(LATE.getValue(), LEAVEEARLY.getValue(), - BusAttendanceClockStatusEnum.UNCLOCK.getValue()); + UNCLOCK.getValue()); // 获取当前用户ID Long userId = LoginHelper.getUserId(); @@ -1957,7 +1956,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl unlocks = list(Wrappers.lambdaQuery() .eq(BusAttendance::getClockDate, date) .eq(BusAttendance::getProjectId, dto.getProjectId()) - .eq(BusAttendance::getClockStatus, BusAttendanceClockStatusEnum.UNCLOCK.getValue()) + .eq(BusAttendance::getClockStatus, UNCLOCK.getValue()) ); List list11 = new ArrayList<>(unlocks.stream().map(BusAttendance::getUserId).distinct().toList()); list11.removeAll(list1); @@ -2031,7 +2030,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl unlocks = list(Wrappers.lambdaQuery() .eq(BusAttendance::getClockDate, date) .eq(BusAttendance::getProjectId, dto.getProjectId()) - .eq(BusAttendance::getClockStatus, BusAttendanceClockStatusEnum.UNCLOCK.getValue()) + .eq(BusAttendance::getClockStatus, UNCLOCK.getValue()) ); List list11 = new ArrayList<>(unlocks.stream().map(BusAttendance::getUserId).distinct().toList()); list11.removeAll(list1); @@ -2721,7 +2720,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl unlocks = list(Wrappers.lambdaQuery() .eq(BusAttendance::getClockDate, date) .eq(BusAttendance::getProjectId, dto.getProjectId()) - .eq(BusAttendance::getClockStatus, BusAttendanceClockStatusEnum.UNCLOCK.getValue()) + .eq(BusAttendance::getClockStatus, UNCLOCK.getValue()) ); List list11 = new ArrayList<>(unlocks.stream().map(BusAttendance::getUserId).distinct().toList()); list11.removeAll(list1); @@ -2794,7 +2793,9 @@ public class BusAttendanceServiceImpl extends ServiceImpl item.getSysUserId().equals(constructionUser.getSysUserId())) .findFirst().ifPresent(item -> { - if (item.getUserRole().equals("0")){ - cacheUserVo.setJslx("施工"); - sg.getAndIncrement(); - } else if (item.getUserRole().equals("2")) { - cacheUserVo.setJslx("分包"); - fb.getAndIncrement(); + SysUserVo sysUserVo = userService.queryById(item.getSysUserId()); + if (sysUserVo != null){ + //app用户类型 0-施工人员 1-管理人员 2-分包人员 + if (sysUserVo.getAppUserType().equals("0")){ + cacheUserVo.setJslx("施工"); + sg.set(sg.getAndIncrement()+1); + }else if (sysUserVo.getAppUserType().equals("2")){ + cacheUserVo.setJslx("分包"); + fb.set(fb.getAndIncrement()+1); + } } }); info.add(cacheUserVo); @@ -2824,11 +2829,12 @@ public class BusAttendanceServiceImpl extends ServiceImpl map = new HashMap<>(); - map.put("zx", String.valueOf(zx)); - map.put("lx", String.valueOf(lx)); - map.put("fb", String.valueOf(fb.get())); - map.put("sg", String.valueOf(sg.get())); - map.put("info", info.toString()); + map.put("zs",String.valueOf(zx+lx)); //总数 + map.put("zx", String.valueOf(zx)); //在线 + map.put("lx", String.valueOf(lx)); //离线 + map.put("fbsl", String.valueOf(fb.get())); //分包 + map.put("sg", String.valueOf(sg.get())); //施工 + map.put("info", JSONUtil.toJsonStr(info)); //jd经度 wd维度 jslx角色类型 return map; } @@ -2846,27 +2852,22 @@ public class BusAttendanceServiceImpl extends ServiceImpl fbList = new ArrayList<>(); List bzList = new ArrayList<>(); + for (SubConstructionUser constructionUser : list) { //统计该项目下的分包和班组各应有多少人 - if (constructionUser.getTeamId() != null && constructionUser.getContractorId() != null){ - //两个都有的情况 - //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 - if (constructionUser.getUserRole().equals("2")){ - checkAndSetValue(fbList,constructionUser,2,timeType,projectId); - } else if (constructionUser.getUserRole().equals("0")) { - checkAndSetValue(bzList,constructionUser,0,timeType,projectId); - } - }else if (constructionUser.getTeamId() == null && constructionUser.getContractorId() != null){ - //班组为空,分包不为空的情况 两个都为空不统计 班组不空分包空 不存在这种情况 - //根据其角色来区分 0-施工人员 1-管理人员 2-分包管理人员 - if (constructionUser.getUserRole().equals("2")){ - checkAndSetValue(fbList,constructionUser,2,timeType,projectId); - } + SysUserVo sysUserVo = userService.queryById(constructionUser.getSysUserId()); + if (sysUserVo == null){ + continue; + } + //判断userType app用户类型 0-施工人员 1-管理人员 2-分包人员 + if (sysUserVo.getAppUserType().equals("0")){ + checkAndSetValue(bzList,constructionUser,0,timeType,projectId); + }else if (sysUserVo.getAppUserType().equals("2")){ + checkAndSetValue(fbList,constructionUser,2,timeType,projectId); } } - //总人数 - zrs = (long) fbList.size() + bzList.size(); + //总出勤人 long fbcqr = 0L; long bzcqr = 0L; @@ -2881,8 +2882,8 @@ public class BusAttendanceServiceImpl extends ServiceImpl0){ vo.setDgl( @@ -2893,17 +2894,20 @@ public class BusAttendanceServiceImpl extends ServiceImpl { + case 2 -> //分包 //首先判断传入的列表中是否存在该条数据 - ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getContractorId())).findFirst().ifPresentOrElse( + ryglWebSocketVoList.stream().filter(item -> Objects.equals(item.getZzId(), info.getContractorId())).findFirst().ifPresentOrElse( item -> { item.setZrs(item.getZrs() + finalTime); item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); @@ -2932,7 +2936,6 @@ public class BusAttendanceServiceImpl extends ServiceImpl //班组 //首先判断传入的列表中是否存在该条数据 - ryglWebSocketVoList.stream().filter(item -> item.getZzId().equals(info.getTeamId())).findFirst().ifPresentOrElse( + ryglWebSocketVoList.stream().filter(item -> Objects.equals(item.getZzId(), info.getTeamId())).findFirst().ifPresentOrElse( item -> { item.setZrs(item.getZrs() + finalTime); item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); }, () -> { RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); - //分包组织id - ryglWebSocketVo.setZzId(info.getContractorId()); - //分包组织名称 + //班组组织id + ryglWebSocketVo.setZzId(info.getTeamId()); + //班组组织名称 ryglWebSocketVo.setZzmc(info.getTeamName()); - //总人数 先设置1 + //总人数 ryglWebSocketVo.setZrs(finalTime); ryglWebSocketVo.setDgrs(getDgrs(info.getSysUserId(),finalTime,projectId)); ryglWebSocketVoList.add(ryglWebSocketVo); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index f1eded0c..d11d122d 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -15,7 +15,6 @@ import org.dromara.bigscreen.service.ProgressBigScreenService; import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; -import org.dromara.common.core.utils.DateUtils; import org.dromara.common.core.utils.SpringUtils; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; @@ -24,7 +23,6 @@ import org.springframework.stereotype.Component; import java.io.IOException; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -230,10 +228,25 @@ public class BigScreenWebSocketServer { String[] split = subscriptionId.split("-"); Long projectId = Long.parseLong(split[0]); long type = Long.parseLong(split[1]); + List> maps = new ArrayList<>(); + //所需service + BusAttendanceServiceImpl busAttendanceService = SpringUtils.getBean(BusAttendanceServiceImpl.class); switch ((int) type) { case 1: break; case 2: + int timeType = Math.toIntExact((Long) JSONUtil.parseObj(message).get("timeType")); + //判断参数 + if (timeType != 1L && timeType != 2L && timeType != 3L) { + throw new RuntimeException("时间类型参数错误"); + } + //先获取左边坐标得到map + Map infoData = busAttendanceService.getRyglOnlineUserInfoData(projectId); + //获取右边数据 + busAttendanceService.getAttendanceInfo(projectId, (long) timeType, infoData); + //返回数据 + maps.add(infoData); + message = JSONUtil.toJsonStr(maps); break; case 3: From be4e5ba0496ef82947a7bd768dc028af9cba9e6c Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Wed, 17 Dec 2025 11:49:15 +0800 Subject: [PATCH 22/38] =?UTF-8?q?=E8=B4=A8=E5=AE=89=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BigScreenWebSocketServer.java | 75 ++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index d11d122d..dd8599a7 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -1,6 +1,9 @@ package org.dromara.websocket.websocket.service; import cn.hutool.json.JSONUtil; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.websocket.*; import jakarta.websocket.server.ServerEndpoint; import lombok.extern.slf4j.Slf4j; @@ -16,6 +19,7 @@ import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; import org.dromara.common.core.utils.SpringUtils; +import org.dromara.common.core.utils.StringUtils; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; import org.dromara.project.service.impl.BusAttendanceServiceImpl; @@ -111,6 +115,7 @@ public class BigScreenWebSocketServer { maps.add(infoData); break; case 3: +// 质安管理 if (dpzaglService != null) { saveDateDpzagl(dpzaglService, params, projectId, maps); } @@ -246,9 +251,10 @@ public class BigScreenWebSocketServer { busAttendanceService.getAttendanceInfo(projectId, (long) timeType, infoData); //返回数据 maps.add(infoData); - message = JSONUtil.toJsonStr(maps); break; case 3: +// 质安管理 + jxzagl(projectId,message,maps); break; case 4: @@ -266,7 +272,8 @@ public class BigScreenWebSocketServer { } try { - session.getBasicRemote().sendText("服务端已收到消息:" + message); + message = JSONUtil.toJsonStr(maps); + session.getBasicRemote().sendText( message); } catch (IOException e) { log.error("📤 回复会话[{}]失败:{}", session.getId(), e.getMessage()); } @@ -382,6 +389,70 @@ public class BigScreenWebSocketServer { } + /** + * 查询大屏-质量管理-接收消息 + */ + private void jxzagl(Long projectId, String message,List> maps) { + DpzaglService dpzaglService = SpringUtils.getBean(DpzaglService.class); + + ObjectMapper objectMapper = new ObjectMapper(); + + try { + Map dateMap = objectMapper.readValue( + message, + new TypeReference>() {} + ); + + // 3. 获取数据(两种方式) + String startDate = dateMap.get("startDate"); + String endDate = dateMap.get("endDate"); + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); + + + if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)){ + throw new RuntimeException("时间获取异常"); + } + + DpznglBo dpznglBo = new DpznglBo(); + dpznglBo.setStartDate(LocalDate.parse(startDate, formatter)); + dpznglBo.setEndDate(LocalDate.parse(endDate, formatter)); + dpznglBo.setProjectId(projectId); + + // 查询大屏-质安管理-安全员分布情况 + + List dpznglAqyVos = dpzaglService.listByAqy(dpznglBo); + if (dpznglAqyVos != null && dpznglAqyVos.size() > 0) { + Map map = new HashMap<>(); + map.put("type", "aqy"); + map.put("data", JSONUtil.toJsonStr(dpznglAqyVos)); + maps.add(map); + } + // 查询大屏-质安管理-站班会,巡检工单,整改情况 + DpznglVo dpznglVo = dpzaglService.queryList(dpznglBo); + + if (dpznglVo != null) { + Map map = new HashMap<>(); + map.put("type", "zagl"); + map.put("data", JSONUtil.toJsonStr(dpznglVo)); + maps.add(map); + } + //查询大屏-质安管理-站班会 + DpznglVo byzbh = dpzaglService.listByzbh(dpznglBo); + if (byzbh != null) { + Map map = new HashMap<>(); + map.put("type", "zbh"); + map.put("data", JSONUtil.toJsonStr(byzbh)); + maps.add(map); + } + + + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + + } + /** * 查询大屏质保管理 */ From 48117eb5d4f4786d817a3e76932e9b829a8a1bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Wed, 17 Dec 2025 14:47:44 +0800 Subject: [PATCH 23/38] =?UTF-8?q?12-17-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D-=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/BusAttendanceServiceImpl.java | 18 +++++++++++------- .../service/BigScreenWebSocketServer.java | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index a47f1105..d4709dec 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -2842,7 +2842,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl map){ //构建数据 //timeType 1:今天 2:本周 3:本月 - Long zrs = 0L; //总人数 + Long zrs; //总人数 Long cqr = 0L; //出勤人数 BigDecimal cql = BigDecimal.ZERO; //出勤率 //查询此项目的所有人员 @@ -2875,8 +2875,8 @@ public class BusAttendanceServiceImpl extends ServiceImpl0){ vo.setDgl( - //到岗人数/总人数 四舍五入 一位小数 - BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 1, RoundingMode.HALF_UP) + //到岗人数/总人数 四舍五入 2位小数 + BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)) ); }else { vo.setDgl(BigDecimal.ZERO); @@ -2887,8 +2887,8 @@ public class BusAttendanceServiceImpl extends ServiceImpl0){ vo.setDgl( - //到岗人数/总人数 四舍五入 一位小数 - BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 1, RoundingMode.HALF_UP) + //到岗人数/总人数 四舍五入 2位小数 + BigDecimal.valueOf(vo.getDgrs()).divide(BigDecimal.valueOf(vo.getZrs()), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)) ); }else { vo.setDgl(BigDecimal.ZERO); @@ -2897,12 +2897,16 @@ public class BusAttendanceServiceImpl extends ServiceImpl infoData = busAttendanceService.getRyglOnlineUserInfoData(projectId); //获取右边数据 - busAttendanceService.getAttendanceInfo(projectId, (long) timeType, infoData); + busAttendanceService.getAttendanceInfo(projectId, Long.valueOf(timeType) , infoData); //返回数据 maps.add(infoData); break; From 86951d43b4689d9f24d034af7afc3fe4ef82d158 Mon Sep 17 00:00:00 2001 From: zt Date: Wed, 17 Dec 2025 14:57:13 +0800 Subject: [PATCH 24/38] =?UTF-8?q?=E7=8F=AD=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/vo/projectteammember/BusProjectTeamMemberVo.java | 1 + .../project/service/impl/BusAttendanceServiceImpl.java | 4 ++-- .../project/service/impl/BusProjectTeamMemberServiceImpl.java | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/projectteammember/BusProjectTeamMemberVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/projectteammember/BusProjectTeamMemberVo.java index 98fd137a..576ba926 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/projectteammember/BusProjectTeamMemberVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/projectteammember/BusProjectTeamMemberVo.java @@ -81,6 +81,7 @@ public class BusProjectTeamMemberVo implements Serializable { /** * 头像 */ + @Translation(type = TransConstant.OSS_ID_TO_URL) private String avatar; /** diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index d4709dec..dd650bbd 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -596,8 +596,8 @@ public class BusAttendanceServiceImpl extends ServiceImpl Date: Wed, 17 Dec 2025 16:36:08 +0800 Subject: [PATCH 25/38] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigscreen/controller/ProgressBigScreenController.java | 2 -- .../bigscreen/domain/vo/ProjectImageProgressDetailVo.java | 5 +++++ .../bigscreen/service/impl/ProjectBigScreenServiceImpl.java | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java index 4c4b5600..f6d19401 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java @@ -1,6 +1,5 @@ package org.dromara.bigscreen.controller; -import cn.dev33.satoken.annotation.SaIgnore; import jakarta.annotation.Resource; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; @@ -27,7 +26,6 @@ import java.util.List; * @author lilemy * @date 2025-12-15 11:35 */ -@SaIgnore @Validated @RestController @RequiredArgsConstructor diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/ProjectImageProgressDetailVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/ProjectImageProgressDetailVo.java index 8c113b3b..c96f65d1 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/ProjectImageProgressDetailVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/ProjectImageProgressDetailVo.java @@ -41,6 +41,11 @@ public class ProjectImageProgressDetailVo implements Serializable { */ private BigDecimal totalProgress; + /** + * 完成率 + */ + private BigDecimal completionRate; + /** * 单位 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java index 77547d18..eed36584 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProjectBigScreenServiceImpl.java @@ -581,6 +581,7 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService { vo.setPlanProgress(c.getPlanTotal()); vo.setActualProgress(c.getCompleted()); vo.setTotalProgress(c.getTotal()); + vo.setCompletionRate(BigDecimalUtil.toPercentage(c.getCompleted(), c.getTotal())); return vo; }).toList(); } @@ -615,6 +616,7 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService { BigDecimal total = children.stream().map(PgsProgressCategory::getTotal) .reduce(BigDecimal.ZERO, BigDecimal::add); vo.setTotalProgress(total); + vo.setCompletionRate(BigDecimalUtil.toPercentage(completed, total)); detailVoList.add(vo); }); } else { @@ -645,6 +647,7 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService { .filter(Objects::nonNull) .findFirst().orElse(null); vo.setUnit(unit); + vo.setCompletionRate(BigDecimalUtil.toPercentage(actual, total)); detailVoList.add(vo); }); } From e134e77d0054091240554d63d911ba8e475bbc20 Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Wed, 17 Dec 2025 17:02:38 +0800 Subject: [PATCH 26/38] =?UTF-8?q?=E8=B4=A8=E5=AE=89=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DpzaglServiceImpl.java | 29 ++++++++++--------- .../service/BigScreenWebSocketServer.java | 14 ++++----- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java index 67685613..46ff89d2 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java @@ -183,9 +183,9 @@ public class DpzaglServiceImpl implements DpzaglService { // 质量展示数据 // TableDataInfo anList = safetyInspectionService.queryPageList(req, pageQuery); // 质量展示数据-整改 - req.setStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); - TableDataInfo aqZgList = safetyInspectionService.queryPageList(req, pageQuery); -// 质量总数(用于判断巡检类型) +// req.setStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); +// TableDataInfo aqZgList = safetyInspectionService.queryPageList(req, pageQuery); +// 安全总数(用于判断巡检类型) List list = safetyInspectionService.list(new LambdaQueryWrapper().ge(bo.getStartDate() != null ,HseSafetyInspection::getCreateTime, bo.getStartDate()).le(bo.getEndDate() != null ,HseSafetyInspection::getCreateTime, bo.getEndDate())); // List rows = anList.getRows(); @@ -198,11 +198,14 @@ public class DpzaglServiceImpl implements DpzaglService { dpznglVo.setDqjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getCheckType())).count()); dpznglVo.setRcxjAq(list.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getCheckType())).count()); dpznglVo.setAqZgsl(list.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getStatus())).count()); + List convert = MapstructUtils.convert(list.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getStatus())).collect(Collectors.toList()), HseSafetyInspectionVo.class); + convert.forEach(zl ->{if (zl.getCorrectorId() != null)zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}); + dpznglVo.setAqZgList(convert); } - if (aqZgList.getRows() != null && aqZgList.getRows().size() > 0){ - aqZgList.getRows().forEach(zl ->{if (zl.getCorrectorId() != null){zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}}); - dpznglVo.setAqZgList(aqZgList.getRows()); - } +// if (aqZgList.getRows() != null && aqZgList.getRows().size() > 0){ +// aqZgList.getRows().forEach(zl ->{if (zl.getCorrectorId() != null){zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}}); +// dpznglVo.setAqZgList(aqZgList.getRows()); +// } } @@ -215,8 +218,8 @@ public class DpzaglServiceImpl implements DpzaglService { //// 质量展示数据 // TableDataInfo zlLists = qualityInspectionService.queryPageList(req, pageQuery); // 质量展示数据-整改 - req.setInspectionStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); - TableDataInfo zlZgLists = qualityInspectionService.queryPageList(req, pageQuery); +// req.setInspectionStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); +// TableDataInfo zlZgLists = qualityInspectionService.queryPageList(req, pageQuery); // 质量总数 List zsZl = qualityInspectionService.getBaseMapper() .selectList(new LambdaQueryWrapper() @@ -232,10 +235,10 @@ public class DpzaglServiceImpl implements DpzaglService { dpznglVo.setDqjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getInspectionType())).count()); dpznglVo.setRcxjZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getInspectionType())).count()); dpznglVo.setZlZgsl(zsZl.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getInspectionStatus())).count()); - } - if (zlZgLists.getRows() != null && zlZgLists.getRows().size() > 0){ - zlZgLists.getRows().forEach(zl ->{if (zl.getCorrectorId() != null){zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}}); - dpznglVo.setZlZgList(zlZgLists.getRows()); + List collect = zsZl.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getInspectionStatus())).collect(Collectors.toList()); + List convert = MapstructUtils.convert(collect, QltQualityInspectionVo.class); + convert.forEach(zl ->{if (zl.getCorrectorId() != null)zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}); + dpznglVo.setZlZgList(convert); } } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index 353a2f70..94abc378 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -409,16 +409,16 @@ public class BigScreenWebSocketServer { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); - - if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)){ - throw new RuntimeException("时间获取异常"); - } - DpznglBo dpznglBo = new DpznglBo(); - dpznglBo.setStartDate(LocalDate.parse(startDate, formatter)); - dpznglBo.setEndDate(LocalDate.parse(endDate, formatter)); + if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)){ + dpznglBo.setStartDate(LocalDate.parse(startDate, formatter)); + dpznglBo.setEndDate(LocalDate.parse(endDate, formatter)); + + } dpznglBo.setProjectId(projectId); + + // 查询大屏-质安管理-安全员分布情况 List dpznglAqyVos = dpzaglService.listByAqy(dpznglBo); From 0f2d1bcc387707f36fefdda6a7f9870383dd8c26 Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Wed, 17 Dec 2025 17:11:47 +0800 Subject: [PATCH 27/38] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BigScreenWebSocketServer.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index 94abc378..edd266c8 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -248,17 +248,18 @@ public class BigScreenWebSocketServer { //先获取左边坐标得到map Map infoData = busAttendanceService.getRyglOnlineUserInfoData(projectId); //获取右边数据 - busAttendanceService.getAttendanceInfo(projectId, Long.valueOf(timeType) , infoData); + busAttendanceService.getAttendanceInfo(projectId, Long.valueOf(timeType), infoData); //返回数据 maps.add(infoData); break; case 3: // 质安管理 - jxzagl(projectId,message,maps); + jxzagl(projectId, message, maps); break; case 4: // 进度管理大屏 + getProgressBigScreenData(maps, projectId); break; case 5: //物资管理大屏 @@ -273,7 +274,7 @@ public class BigScreenWebSocketServer { try { message = JSONUtil.toJsonStr(maps); - session.getBasicRemote().sendText( message); + session.getBasicRemote().sendText(message); } catch (IOException e) { log.error("📤 回复会话[{}]失败:{}", session.getId(), e.getMessage()); } @@ -392,7 +393,7 @@ public class BigScreenWebSocketServer { /** * 查询大屏-质量管理-接收消息 */ - private void jxzagl(Long projectId, String message,List> maps) { + private void jxzagl(Long projectId, String message, List> maps) { DpzaglService dpzaglService = SpringUtils.getBean(DpzaglService.class); ObjectMapper objectMapper = new ObjectMapper(); @@ -400,7 +401,8 @@ public class BigScreenWebSocketServer { try { Map dateMap = objectMapper.readValue( message, - new TypeReference>() {} + new TypeReference>() { + } ); // 3. 获取数据(两种方式) @@ -410,15 +412,13 @@ public class BigScreenWebSocketServer { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); DpznglBo dpznglBo = new DpznglBo(); - if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)){ + if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)) { dpznglBo.setStartDate(LocalDate.parse(startDate, formatter)); dpznglBo.setEndDate(LocalDate.parse(endDate, formatter)); } dpznglBo.setProjectId(projectId); - - // 查询大屏-质安管理-安全员分布情况 List dpznglAqyVos = dpzaglService.listByAqy(dpznglBo); @@ -465,11 +465,11 @@ public class BigScreenWebSocketServer { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); - if (startDate != null && startDate.size() > 0){ + if (startDate != null && startDate.size() > 0) { String first = startDate.getFirst(); dpznglBo.setStartDate(LocalDate.parse(first, formatter)); } - if (endDate != null && endDate.size() > 0){ + if (endDate != null && endDate.size() > 0) { String first = endDate.getFirst(); dpznglBo.setEndDate(LocalDate.parse(first, formatter)); } From e36b76f3dc3fb40fc899f22282cd8d86969a142d Mon Sep 17 00:00:00 2001 From: dfdg <2710245601@qq.com> Date: Wed, 17 Dec 2025 17:35:47 +0800 Subject: [PATCH 28/38] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E4=BB=93=E5=BA=93=E5=AE=9E=E6=97=B6=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialsManagementController.java | 39 +++-- .../domain/vo/StockInAndStockOutRecordVo.java | 46 +++++ .../domain/vo/WarehouseMonitoringVo.java | 52 ++++++ .../service/IMaterialsManagementService.java | 20 ++- .../impl/MaterialsManagementServiceImpl.java | 164 +++++++++++++++++- .../service/impl/BusMrpBaseServiceImpl.java | 4 + .../controller/MatWarehouseController.java | 17 ++ .../domain/MatMaterialReceiveItem.java | 5 + .../materials/domain/MatWarehouseCamera.java | 36 ++++ .../materials/domain/bo/MatWarehouseBo.java | 7 + .../domain/bo/MatWarehouseCameraBo.java | 34 ++++ .../domain/vo/MatWarehouseCameraVo.java | 41 +++++ .../materials/domain/vo/MatWarehouseVo.java | 13 ++ .../MatMaterialReceiveItemVo.java | 5 + .../mapper/MatWarehouseCameraMapper.java | 16 ++ .../service/IMatWarehouseCameraService.java | 71 ++++++++ .../impl/MatMaterialIssueServiceImpl.java | 38 ++-- .../impl/MatWarehouseCameraServiceImpl.java | 129 ++++++++++++++ .../service/impl/MatWarehouseServiceImpl.java | 69 +++++++- .../service/BigScreenWebSocketServer.java | 146 +++++++++------- .../materials/MatWarehouseCameraMapper.xml | 7 + 21 files changed, 855 insertions(+), 104 deletions(-) create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/StockInAndStockOutRecordVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/WarehouseMonitoringVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatWarehouseCamera.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/bo/MatWarehouseCameraBo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/MatWarehouseCameraVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/mapper/MatWarehouseCameraMapper.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/IMatWarehouseCameraService.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatWarehouseCameraServiceImpl.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/materials/MatWarehouseCameraMapper.xml diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java index 5f230cdd..67b850ad 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/MaterialsManagementController.java @@ -1,24 +1,17 @@ package org.dromara.bigscreen.controller; -import cn.dev33.satoken.annotation.SaCheckPermission; +import jakarta.annotation.Resource; import lombok.RequiredArgsConstructor; -import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; -import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo; -import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; -import org.dromara.bigscreen.domain.vo.xhqsdbVo; +import org.dromara.bigscreen.domain.vo.*; import org.dromara.bigscreen.service.IMaterialsManagementService; -import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo; import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo; import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.cailiaoshebei.service.IBusPurchaseDocService; import org.dromara.common.core.domain.R; -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.materials.domain.dto.materials.MatMaterialsQueryReq; +import org.dromara.manager.ys7manager.Ys7Manager; import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo; import org.dromara.materials.service.IMatMaterialsService; -import org.dromara.project.domain.vo.project.BusProjectGisVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; @@ -45,6 +38,8 @@ public class MaterialsManagementController extends BaseController { private IBusMrpBaseService busMrpBaseService; @Autowired private IMatMaterialsService materialsService; + @Resource + private Ys7Manager ys7Manager; /** * 库存结构分析 @@ -111,4 +106,28 @@ public class MaterialsManagementController extends BaseController { return R.ok(materialsService.listUseDetail(projectId)); } + /** + * 仓库实时监控 + */ + @GetMapping("/warehouseMonitoring") + public R> warehouseMonitoring(Long projectId) { + return R.ok(materialsManagementService.warehouseMonitoring(projectId)); + } + + /** + * 监控以及仓库出入库详情 + */ + @GetMapping("/warehouseInAndOutDetail") + public R> warehouseInAndOutDetail(Long projectId, Long warehouseId) { + return R.ok(materialsManagementService.warehouseInAndOutDetail(projectId, warehouseId)); + } + + /** + * 获取YS7摄像头token + */ + @GetMapping("/get/token") + public R getToken() { + return R.ok("操作成功", ys7Manager.getToken()); + } + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/StockInAndStockOutRecordVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/StockInAndStockOutRecordVo.java new file mode 100644 index 00000000..e3701e04 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/StockInAndStockOutRecordVo.java @@ -0,0 +1,46 @@ +package org.dromara.bigscreen.domain.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 仓库出入库列表 + */ +@Data +public class StockInAndStockOutRecordVo implements Serializable { + + /** + * id + */ + public Long id; + + /** + * 材料名称 + */ + public String name; + + /** + * 库存数量 + */ + public Long inventoryNumber; + /** + * 出入库数量 + */ + public Long inAndOutNumber; + /** + * 出入库类型(0、入库,1、出库) + */ + public String type; + /** + * 出入库时间 + */ + public Date time; + + /** + * 操作人 + */ + public String operator; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/WarehouseMonitoringVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/WarehouseMonitoringVo.java new file mode 100644 index 00000000..bbb7cbd1 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/vo/WarehouseMonitoringVo.java @@ -0,0 +1,52 @@ +package org.dromara.bigscreen.domain.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 物资需求与实际到货对比vo + */ +@Data +public class WarehouseMonitoringVo implements Serializable { + + /** + * 摄像头id + */ + public Long cameraId; + /** + * 仓库id + */ + public Long warehouseId; + + /** + * 仓库名称 + */ + public String name; + + /** + * 摄像头序列号 + */ + public String cameraSerial; + + /** + * 摄像头名称 + */ + public String cameraName; + + /** + * 设备在线状态(0离线 1在线) + */ + private Integer status; + + /** + * 状态:0-关闭,1-开启 + */ + private Integer enable; + + /** + * 摄像头最后一张抓图地址 + */ + public String imgUrl; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java index a6d71b04..75a327ad 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/IMaterialsManagementService.java @@ -2,9 +2,9 @@ package org.dromara.bigscreen.service; import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; -import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.dromara.bigscreen.domain.vo.StockInAndStockOutRecordVo; +import org.dromara.bigscreen.domain.vo.WarehouseMonitoringVo; import org.dromara.bigscreen.domain.vo.xhqsdbVo; -import org.dromara.project.domain.vo.project.BusProjectGisVo; import java.util.List; @@ -26,4 +26,20 @@ public interface IMaterialsManagementService { * @return */ List xhqsdb(Long projectId); + + /** + * 仓库实时监控 + * @param projectId + * @return + */ + List warehouseMonitoring(Long projectId); + + /** + * 仓库出入库详情 + * + * @param projectId + * @param warehouseId + * @return + */ + List warehouseInAndOutDetail(Long projectId, Long warehouseId); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java index 3169a9e5..ee9fd562 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java @@ -5,13 +5,17 @@ import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import jakarta.annotation.Resource; import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo; -import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; +import org.dromara.bigscreen.domain.vo.StockInAndStockOutRecordVo; +import org.dromara.bigscreen.domain.vo.WarehouseMonitoringVo; import org.dromara.bigscreen.domain.vo.xhqsdbVo; import org.dromara.bigscreen.enums.WuZhiEnum; import org.dromara.bigscreen.service.IMaterialsManagementService; import org.dromara.materials.domain.*; import org.dromara.materials.service.*; -import org.dromara.project.domain.vo.project.BusProjectGisVo; +import org.dromara.other.domain.OthYs7Device; +import org.dromara.other.domain.OthYs7DeviceImg; +import org.dromara.other.service.IOthYs7DeviceImgService; +import org.dromara.other.service.IOthYs7DeviceService; import org.dromara.tender.domain.BusBillofquantitiesLimitList; import org.dromara.tender.service.IBusBillofquantitiesLimitListService; import org.springframework.context.annotation.Lazy; @@ -46,6 +50,24 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi @Lazy @Resource private IMatMaterialsUseRecordService matMaterialsUseRecordService; + @Lazy + @Resource + private IMatMaterialIssueService materialIssueService; + + @Resource + private IMatWarehouseService warehouseService; + @Lazy + @Resource + private IMatWarehouseCameraService warehouseCameraService; + @Lazy + @Resource + private IOthYs7DeviceService othYs7DeviceService; + @Lazy + @Resource + private IOthYs7DeviceImgService ys7DeviceImgService; + @Lazy + @Resource + private IMatMaterialReceiveService materialReceiveService; @Override @@ -224,13 +246,36 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi @Override public List xhqsdb(Long projectId) { List list = new ArrayList<>(); + //获取出库记录 + List issuesList = materialIssueService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .eq(MatMaterialIssue::getProjectId, projectId) + .eq(MatMaterialIssue::getMaterialSource, "1")); + if (CollUtil.isEmpty(issuesList)) { + return List.of(); + } + Set issueIds = issuesList.stream().map(MatMaterialIssue::getId).collect(Collectors.toSet()); + if (CollUtil.isEmpty(issueIds)){ + return List.of(); + } + //获取领料明细列表 + List issueItems = materialIssueItemService.getBaseMapper().selectList(new LambdaQueryWrapper() + .in(MatMaterialIssueItem::getIssueId, issueIds)); + if (CollUtil.isEmpty(issueItems)){ + return List.of(); + } + Set iIds = issueItems.stream().filter(item -> item.getInventoryId() != null).map(MatMaterialIssueItem::getInventoryId).collect(Collectors.toSet()); + if (CollUtil.isEmpty(iIds)){ + return List.of(); + } + //获取出入库表中出库记录 List inventories = materialsInventoryService.getBaseMapper() .selectList(new LambdaQueryWrapper() - .eq(MatMaterialsInventory::getProjectId, projectId) - .eq(MatMaterialsInventory::getOutPut, "2")); + .in(MatMaterialsInventory::getId, iIds)); if (CollUtil.isEmpty(inventories)) { return List.of(); } + //获取每个材料的库存数量 HashMap inventoryHashMap = new HashMap<>(); inventories.forEach(item -> { if (inventoryHashMap.containsKey(item.getMaterialsId())){ @@ -243,27 +288,28 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi if (CollUtil.isEmpty(mids)){ return List.of(); } + //获取材料名称列表 List materials = materialsService.getBaseMapper().selectList(new LambdaQueryWrapper() .eq(MatMaterials::getProjectId, projectId) .in(MatMaterials::getId, mids)); if (CollUtil.isEmpty(materials)) { return List.of(); } + //获取材料名称 Map map1 = materials.stream() .collect(Collectors.toMap(MatMaterials::getId, MatMaterials::getMaterialsName)); + //获取所有出入库记录id Set ids = inventories.stream() .map(MatMaterialsInventory::getId) .collect(Collectors.toSet()); if (CollUtil.isEmpty(ids)) { return List.of(); } + //根据出入库id获取使用记录 List useRecords = matMaterialsUseRecordService.getBaseMapper() .selectList(new LambdaQueryWrapper() .eq(MatMaterialsUseRecord::getProjectId, projectId) .in(MatMaterialsUseRecord::getInventoryId, ids)); - if (CollUtil.isEmpty(useRecords)) { - return List.of(); - } Map map = useRecords.stream() .collect(Collectors.groupingBy( MatMaterialsUseRecord::getInventoryId, @@ -278,4 +324,108 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi }); return list; } + + @Override + public List warehouseMonitoring(Long projectId) { + List list = new ArrayList<>(); + //根据项目id获取仓库列表 + List warehouseList = warehouseService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(MatWarehouse::getProjectId, projectId)); + //构建仓库id与仓库对象映射 + if (CollUtil.isEmpty(warehouseList)){ + return list; + } + Map warehouseMap = warehouseList.stream().collect(Collectors.toMap(MatWarehouse::getId, item -> item)); + //根据仓库列表获取仓库id + Set warehouseIds = warehouseList.stream().map(MatWarehouse::getId).collect(Collectors.toSet()); + //根据仓库id获取摄像头id列表 + List warehouseCameraList = warehouseCameraService.getBaseMapper().selectList(new LambdaQueryWrapper() + .in(MatWarehouseCamera::getWarehouseId, warehouseIds)); + if (CollUtil.isEmpty(warehouseCameraList)){ + return list; + } + Set cameraIds = warehouseCameraList.stream().map(MatWarehouseCamera::getCameraId).collect(Collectors.toSet()); + //生成摄像头与仓库关系 + Map warehouseCameraMap = warehouseCameraList.stream().collect(Collectors.toMap(MatWarehouseCamera::getCameraId, MatWarehouseCamera::getWarehouseId)); + //根据摄像头id列表获取摄像头列表 + List cameraList = othYs7DeviceService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .in(OthYs7Device::getId, cameraIds)); + if (CollUtil.isEmpty(cameraList)){ + return list; + } + //获取摄像头最后一张抓拍图片 + Set deviceSerialSet = cameraList.stream().map(OthYs7Device::getDeviceSerial).collect(Collectors.toSet()); + List deviceImgs = ys7DeviceImgService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .in(OthYs7DeviceImg::getDeviceSerial, deviceSerialSet)); + Map deviceImgMap = new HashMap<>(); + if (CollUtil.isNotEmpty(deviceImgs)){ + //构建摄像头与图片关系 + deviceImgMap = deviceImgs.stream().collect(Collectors.toMap(OthYs7DeviceImg::getDeviceSerial, OthYs7DeviceImg::getUrl)); + } + //遍历摄像头列表组装返回数据 + for (OthYs7Device item : cameraList) { + WarehouseMonitoringVo vo = new WarehouseMonitoringVo(); + vo.setCameraId(item.getId()); + vo.setWarehouseId(warehouseCameraMap.get(item.getId())); + vo.setCameraSerial(item.getDeviceSerial()); + vo.setCameraName(item.getDeviceName()); + vo.setStatus(item.getStatus()); + vo.setEnable(item.getEnable()); + vo.setName(warehouseMap.get(vo.getWarehouseId()).getWarehouseName()); + vo.setImgUrl(deviceImgMap.get(item.getDeviceSerial()) != null ? deviceImgMap.get(item.getDeviceSerial()) : ""); + list.add(vo); + } + return list; + } + + /** + * 仓库出入库明细 + * + * @param projectId + * @param warehouseId + * @return + */ + @Override + public List warehouseInAndOutDetail(Long projectId, Long warehouseId) { + List list = new ArrayList<>(); + //根据项目id和仓库id获取入库列表 + List matMaterials = materialsService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(MatMaterials::getProjectId, projectId) + .eq(MatMaterials::getWarehouseId, warehouseId)); + if (CollUtil.isEmpty(matMaterials)) { + return list; + } + //生成材料id与材料名称关系 + Map map1 = matMaterials.stream().collect(Collectors.toMap(MatMaterials::getId, MatMaterials::getMaterialsName)); + //获取入库的材料id列表 + Set mIds = matMaterials.stream() + .map(MatMaterials::getId) + .collect(Collectors.toSet()); + if (CollUtil.isEmpty(mIds)){ + return list; + } + //根据材料id列表查询出入库记录表,获取到所有材料的出入库记录 + List materialsInventoryList = materialsInventoryService.getBaseMapper() + .selectList(new LambdaQueryWrapper() + .in(MatMaterialsInventory::getMaterialsId, mIds) + .orderByDesc(MatMaterialsInventory::getCreateTime)); + if (CollUtil.isEmpty(materialsInventoryList)){ + return list; + } + //遍历出入库记录列表,组装返回数据 + for (MatMaterialsInventory item : materialsInventoryList) { + StockInAndStockOutRecordVo vo = new StockInAndStockOutRecordVo(); + vo.setId(item.getId()); + vo.setName(map1.get(item.getMaterialsId())); + vo.setInventoryNumber(item.getResidue()); + vo.setInAndOutNumber(item.getNumber()); + vo.setType(item.getOutPut()); + vo.setTime(item.getOutPutTime()); + vo.setOperator(item.getOperator()); + list.add(vo); + } + return list; + } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java index 57f291b8..68bd1ffb 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java @@ -1,6 +1,7 @@ package org.dromara.cailiaoshebei.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -410,6 +411,9 @@ public class BusMrpBaseServiceImpl extends ServiceImpl planIds = matMaterialReceiveItems.stream() .map(MatMaterialReceiveItem::getPlanId) .collect(Collectors.toSet()); + if (CollUtil.isEmpty(planIds)){ + return new HashMap<>(); + } Map planMap = matMaterialReceiveItems.stream() .collect(Collectors.groupingBy( MatMaterialReceiveItem::getPlanId, diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/controller/MatWarehouseController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/controller/MatWarehouseController.java index c8a9c649..95559a6e 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/controller/MatWarehouseController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/controller/MatWarehouseController.java @@ -1,6 +1,8 @@ package org.dromara.materials.controller; import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.annotation.SaMode; +import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; @@ -18,6 +20,8 @@ import org.dromara.common.web.core.BaseController; import org.dromara.materials.domain.bo.MatWarehouseBo; import org.dromara.materials.domain.vo.MatWarehouseVo; import org.dromara.materials.service.IMatWarehouseService; +import org.dromara.other.domain.vo.ys7device.OthYs7DeviceVo; +import org.dromara.other.service.IOthYs7DeviceService; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -37,6 +41,19 @@ public class MatWarehouseController extends BaseController { private final IMatWarehouseService matWarehouseService; + @Resource + private IOthYs7DeviceService othYs7DeviceService; + + + /** + * 根据项目查询萤石摄像头列表 + */ + @SaCheckPermission( value = {"materials:warehouse:list","materials:warehouse:add","materials:warehouse:edit"}, mode = SaMode.OR) + @GetMapping("/device/project") + public TableDataInfo listByProject(Long projectId, PageQuery pageQuery) { + return othYs7DeviceService.queryPageListByProject(projectId, pageQuery); + } + /** * 查询物资仓库列表 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialReceiveItem.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialReceiveItem.java index a904fac3..d60e26e8 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialReceiveItem.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatMaterialReceiveItem.java @@ -84,4 +84,9 @@ public class MatMaterialReceiveItem extends BaseEntity { */ private Long planId; + /** + * 仓库id + */ + private Long warehouseId; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatWarehouseCamera.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatWarehouseCamera.java new file mode 100644 index 00000000..ba63c7a4 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/MatWarehouseCamera.java @@ -0,0 +1,36 @@ +package org.dromara.materials.domain; + +import org.dromara.common.mybatis.core.domain.BaseEntity; +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 物资仓库与摄像头绑定对象 mat_warehouse_camera + * + * @author Lion Li + * @date 2025-12-17 + */ +@Data +@TableName("mat_warehouse_camera") +public class MatWarehouseCamera implements Serializable{ + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 仓库id + */ + @TableId(value = "warehouse_id") + private Long warehouseId; + + /** + * 摄像头id + */ + private Long cameraId; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/bo/MatWarehouseBo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/bo/MatWarehouseBo.java index a59a978a..f3c0b71b 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/bo/MatWarehouseBo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/bo/MatWarehouseBo.java @@ -10,6 +10,8 @@ import org.dromara.common.core.validate.EditGroup; import org.dromara.common.mybatis.core.domain.BaseEntity; import org.dromara.materials.domain.MatWarehouse; +import java.util.List; + /** * 物资仓库业务对象 mat_warehouse * @@ -91,4 +93,9 @@ public class MatWarehouseBo extends BaseEntity { */ private String remark; + /** + * 萤石设备id + */ + private List ys7DeviceIds; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/bo/MatWarehouseCameraBo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/bo/MatWarehouseCameraBo.java new file mode 100644 index 00000000..1b7aae49 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/bo/MatWarehouseCameraBo.java @@ -0,0 +1,34 @@ +package org.dromara.materials.domain.bo; + + +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import lombok.Data; +import jakarta.validation.constraints.*; + + +import java.io.Serializable; + +/** + * 物资仓库与摄像头绑定业务对象 mat_warehouse_camera + * + * @author Lion Li + * @date 2025-12-17 + */ +@Data +public class MatWarehouseCameraBo implements Serializable { + + /** + * 仓库id + */ + @NotNull(message = "仓库id不能为空", groups = { EditGroup.class }) + private Long warehouseId; + + /** + * 摄像头id + */ + @NotNull(message = "摄像头id不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long cameraId; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/MatWarehouseCameraVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/MatWarehouseCameraVo.java new file mode 100644 index 00000000..22aaf062 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/MatWarehouseCameraVo.java @@ -0,0 +1,41 @@ +package org.dromara.materials.domain.vo; + + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import org.dromara.materials.domain.MatWarehouseCamera; + +import java.io.Serial; +import java.io.Serializable; + + +/** + * 物资仓库与摄像头绑定视图对象 mat_warehouse_camera + * + * @author Lion Li + * @date 2025-12-17 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = MatWarehouseCamera.class) +public class MatWarehouseCameraVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 仓库id + */ + @ExcelProperty(value = "仓库id") + private Long warehouseId; + + /** + * 摄像头id + */ + @ExcelProperty(value = "摄像头id") + private Long cameraId; + + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/MatWarehouseVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/MatWarehouseVo.java index c9e45d91..bc4dac14 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/MatWarehouseVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/MatWarehouseVo.java @@ -7,9 +7,12 @@ import lombok.Data; import org.dromara.common.excel.annotation.ExcelDictFormat; import org.dromara.common.excel.convert.ExcelDictConvert; import org.dromara.materials.domain.MatWarehouse; +import org.dromara.other.domain.OthYs7Device; +import org.dromara.other.domain.vo.ys7device.OthYs7DeviceVo; import java.io.Serial; import java.io.Serializable; +import java.util.List; /** @@ -105,4 +108,14 @@ public class MatWarehouseVo implements Serializable { @ExcelProperty(value = "备注") private String remark; + /** + * 萤石设备id + */ + private List ys7DeviceIds; + + /** + * 萤石摄像头信息 + */ + private List ys7DeviceList; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialreceiveitem/MatMaterialReceiveItemVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialreceiveitem/MatMaterialReceiveItemVo.java index d9b2f75e..bc1d11cc 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialreceiveitem/MatMaterialReceiveItemVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/domain/vo/materialreceiveitem/MatMaterialReceiveItemVo.java @@ -77,4 +77,9 @@ public class MatMaterialReceiveItemVo implements Serializable { */ private String remark; + /** + * 仓库id + */ + private Long warehouseId; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/mapper/MatWarehouseCameraMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/mapper/MatWarehouseCameraMapper.java new file mode 100644 index 00000000..a8d06d0e --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/mapper/MatWarehouseCameraMapper.java @@ -0,0 +1,16 @@ +package org.dromara.materials.mapper; + + +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.dromara.materials.domain.MatWarehouseCamera; +import org.dromara.materials.domain.vo.MatWarehouseCameraVo; + +/** + * 物资仓库与摄像头绑定Mapper接口 + * + * @author Lion Li + * @date 2025-12-17 + */ +public interface MatWarehouseCameraMapper extends BaseMapperPlus { + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/IMatWarehouseCameraService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/IMatWarehouseCameraService.java new file mode 100644 index 00000000..4eed3400 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/IMatWarehouseCameraService.java @@ -0,0 +1,71 @@ +package org.dromara.materials.service; + +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.materials.domain.MatWarehouseCamera; +import org.dromara.materials.domain.bo.MatWarehouseCameraBo; +import org.dromara.materials.domain.vo.MatWarehouseCameraVo; + +import java.util.Collection; +import java.util.List; + +/** + * 物资仓库与摄像头绑定Service接口 + * + * @author Lion Li + * @date 2025-12-17 + */ +public interface IMatWarehouseCameraService extends IService{ + + /** + * 查询物资仓库与摄像头绑定 + * + * @param warehouseId 主键 + * @return 物资仓库与摄像头绑定 + */ + MatWarehouseCameraVo queryById(Long warehouseId); + + /** + * 分页查询物资仓库与摄像头绑定列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 物资仓库与摄像头绑定分页列表 + */ + TableDataInfo queryPageList(MatWarehouseCameraBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的物资仓库与摄像头绑定列表 + * + * @param bo 查询条件 + * @return 物资仓库与摄像头绑定列表 + */ + List queryList(MatWarehouseCameraBo bo); + + /** + * 新增物资仓库与摄像头绑定 + * + * @param bo 物资仓库与摄像头绑定 + * @return 是否新增成功 + */ + Boolean insertByBo(MatWarehouseCameraBo bo); + + /** + * 修改物资仓库与摄像头绑定 + * + * @param bo 物资仓库与摄像头绑定 + * @return 是否修改成功 + */ + Boolean updateByBo(MatWarehouseCameraBo bo); + + /** + * 校验并批量删除物资仓库与摄像头绑定信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialIssueServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialIssueServiceImpl.java index f800b99c..6db38987 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialIssueServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialIssueServiceImpl.java @@ -253,18 +253,6 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl itemList = req.getItemList(); if (CollUtil.isNotEmpty(itemList)) { List materialIssueItemList = itemList.stream().map(item -> { - MatMaterialIssueItem materialIssueItem = new MatMaterialIssueItem(); - BeanUtils.copyProperties(item, materialIssueItem); - materialIssueItem.setIssueId(materialIssue.getId()); - materialIssueItem.setProjectId(materialIssue.getProjectId()); - return materialIssueItem; - }).toList(); - boolean result = materialIssueItemService.saveBatch(materialIssueItemList); - if (!result) { - throw new ServiceException("物料领料单明细项新增失败", HttpStatus.ERROR); - } - // 创建设备材料出库记录 - List inventoryList = itemList.stream().map(item -> { MatMaterialsInventory inventory = new MatMaterialsInventory(); inventory.setNumber(item.getIssuedQuantity().longValue()); inventory.setOutPutTime(new Date()); @@ -278,12 +266,30 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl inventoryList = itemList.stream().map(item -> { +// +// return inventory; +// }).toList(); +// boolean saved = materialsInventoryService.saveBatch(inventoryList); +// if (!saved) { +// throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR); +// } } return true; } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatWarehouseCameraServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatWarehouseCameraServiceImpl.java new file mode 100644 index 00000000..70f120c2 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatWarehouseCameraServiceImpl.java @@ -0,0 +1,129 @@ +package org.dromara.materials.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.mybatis.core.page.PageQuery; +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.materials.domain.MatWarehouseCamera; +import org.dromara.materials.domain.bo.MatWarehouseCameraBo; +import org.dromara.materials.domain.vo.MatWarehouseCameraVo; +import org.dromara.materials.mapper.MatWarehouseCameraMapper; +import org.dromara.materials.service.IMatWarehouseCameraService; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 物资仓库与摄像头绑定Service业务层处理 + * + * @author Lion Li + * @date 2025-12-17 + */ +@RequiredArgsConstructor +@Service +public class MatWarehouseCameraServiceImpl extends ServiceImpl implements IMatWarehouseCameraService { + + private final MatWarehouseCameraMapper baseMapper; + + /** + * 查询物资仓库与摄像头绑定 + * + * @param warehouseId 主键 + * @return 物资仓库与摄像头绑定 + */ + @Override + public MatWarehouseCameraVo queryById(Long warehouseId){ + return baseMapper.selectVoById(warehouseId); + } + + /** + * 分页查询物资仓库与摄像头绑定列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 物资仓库与摄像头绑定分页列表 + */ + @Override + public TableDataInfo queryPageList(MatWarehouseCameraBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的物资仓库与摄像头绑定列表 + * + * @param bo 查询条件 + * @return 物资仓库与摄像头绑定列表 + */ + @Override + public List queryList(MatWarehouseCameraBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(MatWarehouseCameraBo bo) { + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByDesc(MatWarehouseCamera::getWarehouseId); + lqw.eq(bo.getCameraId() != null, MatWarehouseCamera::getCameraId, bo.getCameraId()); + return lqw; + } + + /** + * 新增物资仓库与摄像头绑定 + * + * @param bo 物资仓库与摄像头绑定 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(MatWarehouseCameraBo bo) { + MatWarehouseCamera add = MapstructUtils.convert(bo, MatWarehouseCamera.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setWarehouseId(add.getWarehouseId()); + } + return flag; + } + + /** + * 修改物资仓库与摄像头绑定 + * + * @param bo 物资仓库与摄像头绑定 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(MatWarehouseCameraBo bo) { + MatWarehouseCamera update = MapstructUtils.convert(bo, MatWarehouseCamera.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(MatWarehouseCamera entity){ + //TODO 做一些数据校验,如唯一约束 + } + + /** + * 校验并批量删除物资仓库与摄像头绑定信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatWarehouseServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatWarehouseServiceImpl.java index 4abce933..3985f637 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatWarehouseServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatWarehouseServiceImpl.java @@ -4,21 +4,25 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import jakarta.annotation.Resource; import lombok.RequiredArgsConstructor; import org.dromara.common.core.utils.MapstructUtils; 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.materials.domain.MatWarehouse; +import org.dromara.materials.domain.MatWarehouseCamera; import org.dromara.materials.domain.bo.MatWarehouseBo; import org.dromara.materials.domain.vo.MatWarehouseVo; import org.dromara.materials.mapper.MatWarehouseMapper; +import org.dromara.materials.service.IMatWarehouseCameraService; import org.dromara.materials.service.IMatWarehouseService; +import org.dromara.other.domain.OthYs7Device; +import org.dromara.other.service.IOthYs7DeviceService; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 物资仓库Service业务层处理 @@ -31,6 +35,12 @@ import java.util.Map; public class MatWarehouseServiceImpl extends ServiceImpl implements IMatWarehouseService { + @Resource + private IMatWarehouseCameraService matWarehouseCameraService; + + @Resource + private IOthYs7DeviceService othYs7DeviceService; + /** * 查询物资仓库 * @@ -39,7 +49,22 @@ public class MatWarehouseServiceImpl extends ServiceImpl list = matWarehouseCameraService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(MatWarehouseCamera::getWarehouseId, id)); + if (list != null && !list.isEmpty()){ + Set cameraIds = new HashSet<>(); + for (MatWarehouseCamera item : list) { + cameraIds.add(item.getCameraId()); + } + List ys7DeviceList = othYs7DeviceService.getBaseMapper().selectList(new LambdaQueryWrapper().in(OthYs7Device::getId, cameraIds)); + if (ys7DeviceList != null && !ys7DeviceList.isEmpty()){ + vo.setYs7DeviceList(ys7DeviceList); + } + vo.setYs7DeviceIds(cameraIds.stream().toList()); + } + } + return vo; } /** @@ -93,12 +118,29 @@ public class MatWarehouseServiceImpl extends ServiceImpl 0; if (flag) { bo.setId(add.getId()); + if (bo.getYs7DeviceIds() != null){ + Long count = matWarehouseCameraService.getBaseMapper() + .selectCount(new LambdaQueryWrapper() + .in(MatWarehouseCamera::getCameraId, bo.getYs7DeviceIds())); + if (count > 0){ + throw new RuntimeException("摄像头已与仓库绑定请重新选择摄像头"); + } + List list = new ArrayList<>(); + for (Long item : bo.getYs7DeviceIds()) { + MatWarehouseCamera matWarehouseCamera = new MatWarehouseCamera(); + matWarehouseCamera.setWarehouseId(add.getId()); + matWarehouseCamera.setCameraId(item); + list.add(matWarehouseCamera); + } + matWarehouseCameraService.saveBatch(list); + } } return flag; } @@ -110,9 +152,27 @@ public class MatWarehouseServiceImpl extends ServiceImpl().eq(MatWarehouseCamera::getWarehouseId, bo.getId())); + if (bo.getYs7DeviceIds() != null){ + Long count = matWarehouseCameraService.getBaseMapper() + .selectCount(new LambdaQueryWrapper() + .in(MatWarehouseCamera::getCameraId, bo.getYs7DeviceIds())); + if (count > 0){ + throw new RuntimeException("摄像头已与仓库绑定请重新选择摄像头"); + } + List list = new ArrayList<>(); + for (Long item : bo.getYs7DeviceIds()) { + MatWarehouseCamera matWarehouseCamera = new MatWarehouseCamera(); + matWarehouseCamera.setWarehouseId(bo.getId()); + matWarehouseCamera.setCameraId(item); + list.add(matWarehouseCamera); + } + matWarehouseCameraService.saveBatch(list); + } return baseMapper.updateById(update) > 0; } @@ -135,6 +195,7 @@ public class MatWarehouseServiceImpl extends ServiceImpl().in(MatWarehouseCamera::getWarehouseId, ids)); return baseMapper.deleteByIds(ids) > 0; } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index edd266c8..ce29b543 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -88,10 +88,7 @@ public class BigScreenWebSocketServer { CompletableFuture.runAsync(() -> { try { //todo 填充不同类型大屏获取基础数据的方法判断 - IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class); - IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class); - IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class); - IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class); + BusAttendanceServiceImpl busAttendanceService = SpringUtils.getBean(BusAttendanceServiceImpl.class); // 大屏-质安管理 DpzaglService dpzaglService = SpringUtils.getBean(DpzaglService.class); @@ -126,6 +123,10 @@ public class BigScreenWebSocketServer { break; case 5: //物资管理大屏 + IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class); + IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class); + IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class); + IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class); generateLargeScreenData(materialsService, managementService, projectId, maps, purchaseDocService, mrpBaseService); break; case 6: @@ -155,67 +156,6 @@ public class BigScreenWebSocketServer { }); } - /** - * 获取物资管理大屏数据 - */ - private static void generateLargeScreenData(IMatMaterialsService materialsService, IMaterialsManagementService managementService, Long projectId, List> maps, IBusPurchaseDocService purchaseDocService, IBusMrpBaseService mrpBaseService) { - if (materialsService != null) { - //库存结构分析 - InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId); - if (vo != null) { - Map map = new HashMap<>(); - map.put("type", "inventoryStructureAnalysis"); - map.put("data", JSONUtil.toJsonStr(vo)); - maps.add(map); - } - //消耗趋势对比 - List xhqsdb = managementService.xhqsdb(projectId); - if (xhqsdb != null && !xhqsdb.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "xhqsdb"); - map.put("data", JSONUtil.toJsonStr(xhqsdb)); - maps.add(map); - } - } - if (purchaseDocService != null) { - //采购单 - List purchaseDocVos = purchaseDocService.purchaseNote(projectId); - if (purchaseDocVos != null && !purchaseDocVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "purchaseNote"); - map.put("data", JSONUtil.toJsonStr(purchaseDocVos)); - maps.add(map); - } - } - if (mrpBaseService != null) { - //设计量与到货量对比 - List designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId); - if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "designAndArrivalComparison"); - map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos)); - maps.add(map); - } - //物资需求与实际到货对比 - List wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId); - if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "wzxqysjdhdb"); - map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos)); - maps.add(map); - } - } - if (materialsService != null) { - //物资跟踪管理台账 - List useDetailVos = materialsService.listUseDetail(projectId); - if (useDetailVos != null && !useDetailVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "listUseDetail"); - map.put("data", JSONUtil.toJsonStr(useDetailVos)); - maps.add(map); - } - } - } /** * 接收客户端消息 @@ -263,6 +203,11 @@ public class BigScreenWebSocketServer { break; case 5: //物资管理大屏 + IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class); + IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class); + IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class); + IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class); + generateLargeScreenData(materialsService, managementService, projectId, maps, purchaseDocService, mrpBaseService); break; case 6: break; @@ -540,5 +485,76 @@ public class BigScreenWebSocketServer { } } + /** + * 获取物资管理大屏数据 + */ + private static void generateLargeScreenData(IMatMaterialsService materialsService, IMaterialsManagementService managementService, Long projectId, List> maps, IBusPurchaseDocService purchaseDocService, IBusMrpBaseService mrpBaseService) { + if (materialsService != null) { + //库存结构分析 + InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId); + if (vo != null) { + Map map = new HashMap<>(); + map.put("type", "inventoryStructureAnalysis"); + map.put("data", JSONUtil.toJsonStr(vo)); + maps.add(map); + } + //消耗趋势对比 + List xhqsdb = managementService.xhqsdb(projectId); + if (xhqsdb != null && !xhqsdb.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "xhqsdb"); + map.put("data", JSONUtil.toJsonStr(xhqsdb)); + maps.add(map); + } + //仓库监控 + List warehouseMonitoringVos = managementService.warehouseMonitoring(projectId); + if (warehouseMonitoringVos != null && !warehouseMonitoringVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "warehouseMonitoring"); + map.put("data", JSONUtil.toJsonStr(warehouseMonitoringVos)); + maps.add(map); + } + } + if (purchaseDocService != null) { + //采购单 + List purchaseDocVos = purchaseDocService.purchaseNote(projectId); + if (purchaseDocVos != null && !purchaseDocVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "purchaseNote"); + map.put("data", JSONUtil.toJsonStr(purchaseDocVos)); + maps.add(map); + } + } + if (mrpBaseService != null) { + //设计量与到货量对比 + List designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId); + if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "designAndArrivalComparison"); + map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos)); + maps.add(map); + } + //物资需求与实际到货对比 + List wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId); + if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "wzxqysjdhdb"); + map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos)); + maps.add(map); + } + } + if (materialsService != null) { + //物资跟踪管理台账 + List useDetailVos = materialsService.listUseDetail(projectId); + if (useDetailVos != null && !useDetailVos.isEmpty()) { + Map map = new HashMap<>(); + map.put("type", "listUseDetail"); + map.put("data", JSONUtil.toJsonStr(useDetailVos)); + maps.add(map); + } + } + } + + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/materials/MatWarehouseCameraMapper.xml b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/materials/MatWarehouseCameraMapper.xml new file mode 100644 index 00000000..c753635e --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/materials/MatWarehouseCameraMapper.xml @@ -0,0 +1,7 @@ + + + + + From e7ce0875d414a1a9a4db7f3acdca072dab8499fc Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Wed, 17 Dec 2025 19:11:22 +0800 Subject: [PATCH 29/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MaterialsManagementServiceImpl.java | 4 +- .../service/impl/BusMrpBaseServiceImpl.java | 1 + .../service/impl/MatMaterialsServiceImpl.java | 2 +- .../service/BigScreenWebSocketServer.java | 183 ++++++++++-------- 4 files changed, 110 insertions(+), 80 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java index ee9fd562..95f865d3 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/MaterialsManagementServiceImpl.java @@ -284,7 +284,7 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi inventoryHashMap.put(item.getMaterialsId(), new BigDecimal(item.getNumber())); } }); - Set mids = inventories.stream().map(MatMaterialsInventory::getMaterialsId).collect(Collectors.toSet()); + Set mids = inventories.stream().filter(item -> item.getMaterialsId() != null).map(MatMaterialsInventory::getMaterialsId).collect(Collectors.toSet()); if (CollUtil.isEmpty(mids)){ return List.of(); } @@ -344,7 +344,7 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi if (CollUtil.isEmpty(warehouseCameraList)){ return list; } - Set cameraIds = warehouseCameraList.stream().map(MatWarehouseCamera::getCameraId).collect(Collectors.toSet()); + Set cameraIds = warehouseCameraList.stream().filter(item -> item.getCameraId() != null).map(MatWarehouseCamera::getCameraId).collect(Collectors.toSet()); //生成摄像头与仓库关系 Map warehouseCameraMap = warehouseCameraList.stream().collect(Collectors.toMap(MatWarehouseCamera::getCameraId, MatWarehouseCamera::getWarehouseId)); //根据摄像头id列表获取摄像头列表 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java index 68bd1ffb..e4d423ce 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java @@ -415,6 +415,7 @@ public class BusMrpBaseServiceImpl extends ServiceImpl(); } Map planMap = matMaterialReceiveItems.stream() + .filter(matMaterialReceiveItem -> matMaterialReceiveItem.getPlanId() != null) .collect(Collectors.groupingBy( MatMaterialReceiveItem::getPlanId, Collectors.reducing(BigDecimal.ZERO, MatMaterialReceiveItem::getQuantity, BigDecimal::add) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialsServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialsServiceImpl.java index dc8e0e33..c1ce37a5 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialsServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/materials/service/impl/MatMaterialsServiceImpl.java @@ -862,7 +862,7 @@ public class MatMaterialsServiceImpl extends ServiceImpl warehouseIds = matMaterials.stream().map(MatMaterials::getWarehouseId).collect(Collectors.toSet()); + Set warehouseIds = matMaterials.stream().filter(material -> material.getWarehouseId() != null).map(MatMaterials::getWarehouseId).collect(Collectors.toSet()); List warehouseList = new ArrayList<>(); if (CollUtil.isNotEmpty(warehouseIds)) { warehouseList = warehouseService.lambdaQuery() diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java index ce29b543..30c247bf 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/websocket/websocket/service/BigScreenWebSocketServer.java @@ -1,5 +1,6 @@ package org.dromara.websocket.websocket.service; +import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONUtil; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -367,31 +368,34 @@ public class BigScreenWebSocketServer { // 查询大屏-质安管理-安全员分布情况 List dpznglAqyVos = dpzaglService.listByAqy(dpznglBo); - if (dpznglAqyVos != null && dpznglAqyVos.size() > 0) { - Map map = new HashMap<>(); - map.put("type", "aqy"); - map.put("data", JSONUtil.toJsonStr(dpznglAqyVos)); - maps.add(map); + Map map1 = new HashMap<>(); + map1.put("type", "aqy"); + if (CollUtil.isNotEmpty(dpznglAqyVos)) { + map1.put("data", JSONUtil.toJsonStr(dpznglAqyVos)); + } else { + map1.put("data", "[]"); } + maps.add(map1); // 查询大屏-质安管理-站班会,巡检工单,整改情况 DpznglVo dpznglVo = dpzaglService.queryList(dpznglBo); - + Map map2 = new HashMap<>(); + map2.put("type", "zagl"); if (dpznglVo != null) { - Map map = new HashMap<>(); - map.put("type", "zagl"); - map.put("data", JSONUtil.toJsonStr(dpznglVo)); - maps.add(map); + map2.put("data", JSONUtil.toJsonStr(dpznglVo)); + } else { + map2.put("data", "{}"); } + maps.add(map2); //查询大屏-质安管理-站班会 DpznglVo byzbh = dpzaglService.listByzbh(dpznglBo); + Map map3 = new HashMap<>(); + map3.put("type", "zbh"); if (byzbh != null) { - Map map = new HashMap<>(); - map.put("type", "zbh"); - map.put("data", JSONUtil.toJsonStr(byzbh)); - maps.add(map); + map3.put("data", JSONUtil.toJsonStr(byzbh)); + } else { + map3.put("data", "{}"); } - - + maps.add(map3); } catch (JsonProcessingException e) { throw new RuntimeException(e); } @@ -410,11 +414,11 @@ public class BigScreenWebSocketServer { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA); - if (startDate != null && startDate.size() > 0) { + if (CollUtil.isNotEmpty(startDate)) { String first = startDate.getFirst(); dpznglBo.setStartDate(LocalDate.parse(first, formatter)); } - if (endDate != null && endDate.size() > 0) { + if (CollUtil.isNotEmpty(endDate)) { String first = endDate.getFirst(); dpznglBo.setEndDate(LocalDate.parse(first, formatter)); } @@ -422,30 +426,34 @@ public class BigScreenWebSocketServer { // 查询大屏-质安管理-安全员分布情况 List dpznglAqyVos = dpzaglService.listByAqy(dpznglBo); - if (dpznglAqyVos != null && dpznglAqyVos.size() > 0) { - Map map = new HashMap<>(); - map.put("type", "aqy"); - map.put("data", JSONUtil.toJsonStr(dpznglAqyVos)); - maps.add(map); + Map map1 = new HashMap<>(); + map1.put("type", "aqy"); + if (CollUtil.isNotEmpty(dpznglAqyVos)) { + map1.put("data", JSONUtil.toJsonStr(dpznglAqyVos)); + } else { + map1.put("data", "[]"); } + maps.add(map1); // 查询大屏-质安管理-站班会,巡检工单,整改情况 DpznglVo dpznglVo = dpzaglService.queryList(dpznglBo); - + Map map2 = new HashMap<>(); + map2.put("type", "zagl"); if (dpznglVo != null) { - Map map = new HashMap<>(); - map.put("type", "zagl"); - map.put("data", JSONUtil.toJsonStr(dpznglVo)); - maps.add(map); + map2.put("data", JSONUtil.toJsonStr(dpznglVo)); + } else { + map2.put("data", "{}"); } + maps.add(map2); //查询大屏-质安管理-站班会 DpznglVo byzbh = dpzaglService.listByzbh(dpznglBo); + Map map3 = new HashMap<>(); + map3.put("type", "zbh"); if (byzbh != null) { - Map map = new HashMap<>(); - map.put("type", "zbh"); - map.put("data", JSONUtil.toJsonStr(byzbh)); - maps.add(map); + map3.put("data", JSONUtil.toJsonStr(byzbh)); + } else { + map3.put("data", "{}"); } - + maps.add(map3); } /** @@ -455,33 +463,41 @@ public class BigScreenWebSocketServer { ProgressBigScreenService service = SpringUtils.getBean(ProgressBigScreenService.class); if (service != null) { DesignProgressVo designProgress = service.getDesignProgress(projectId); + Map map1 = new HashMap<>(); + map1.put("type", "progressDesignProgress"); if (designProgress != null) { - Map map = new HashMap<>(); - map.put("type", "progressDesignProgress"); - map.put("data", JSONUtil.toJsonStr(designProgress)); - maps.add(map); + map1.put("data", JSONUtil.toJsonStr(designProgress)); + } else { + map1.put("data", "{}"); } + maps.add(map1); ProjectTotalProgressVo projectTotalProgress = service.getProjectTotalProgress(projectId); + Map map2 = new HashMap<>(); + map2.put("type", "progressProjectTotalProgress"); if (projectTotalProgress != null) { - Map map = new HashMap<>(); - map.put("type", "progressProjectTotalProgress"); - map.put("data", JSONUtil.toJsonStr(projectTotalProgress)); - maps.add(map); + map2.put("data", JSONUtil.toJsonStr(projectTotalProgress)); + } else { + map2.put("data", "{}"); } + maps.add(map2); List milestoneProgress = service.getMilestoneProgress(projectId); + Map map3 = new HashMap<>(); + map3.put("type", "progressMilestoneProgress"); if (milestoneProgress != null) { - Map map = new HashMap<>(); - map.put("type", "progressMilestoneProgress"); - map.put("data", JSONUtil.toJsonStr(milestoneProgress)); - maps.add(map); + map3.put("data", JSONUtil.toJsonStr(milestoneProgress)); + } else { + map3.put("data", "[]"); } + maps.add(map3); List materialProgress = service.getMaterialProgress(projectId); + Map map4 = new HashMap<>(); + map4.put("type", "progressMaterialProgress"); if (materialProgress != null) { - Map map = new HashMap<>(); - map.put("type", "progressMaterialProgress"); - map.put("data", JSONUtil.toJsonStr(materialProgress)); - maps.add(map); + map4.put("data", JSONUtil.toJsonStr(materialProgress)); + } else { + map4.put("data", "[]"); } + maps.add(map4); } } @@ -492,69 +508,82 @@ public class BigScreenWebSocketServer { if (materialsService != null) { //库存结构分析 InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId); + Map map = new HashMap<>(); + map.put("type", "inventoryStructureAnalysis"); if (vo != null) { - Map map = new HashMap<>(); - map.put("type", "inventoryStructureAnalysis"); map.put("data", JSONUtil.toJsonStr(vo)); - maps.add(map); + } else { + map.put("data", "{}"); } + maps.add(map); //消耗趋势对比 List xhqsdb = managementService.xhqsdb(projectId); + Map map1 = new HashMap<>(); + map1.put("type", "xhqsdb"); if (xhqsdb != null && !xhqsdb.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "xhqsdb"); - map.put("data", JSONUtil.toJsonStr(xhqsdb)); - maps.add(map); + map1.put("data", JSONUtil.toJsonStr(xhqsdb)); + } else { + map1.put("data", "[]"); } + maps.add(map1); //仓库监控 List warehouseMonitoringVos = managementService.warehouseMonitoring(projectId); + Map map2 = new HashMap<>(); + map2.put("type", "warehouseMonitoring"); if (warehouseMonitoringVos != null && !warehouseMonitoringVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "warehouseMonitoring"); - map.put("data", JSONUtil.toJsonStr(warehouseMonitoringVos)); - maps.add(map); + map2.put("data", JSONUtil.toJsonStr(warehouseMonitoringVos)); + } else { + map2.put("data", "[]"); } + maps.add(map2); } if (purchaseDocService != null) { //采购单 List purchaseDocVos = purchaseDocService.purchaseNote(projectId); + Map map3 = new HashMap<>(); + map3.put("type", "purchaseNote"); if (purchaseDocVos != null && !purchaseDocVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "purchaseNote"); - map.put("data", JSONUtil.toJsonStr(purchaseDocVos)); - maps.add(map); + map3.put("data", JSONUtil.toJsonStr(purchaseDocVos)); + } else { + map3.put("data", "[]"); } + maps.add(map3); } if (mrpBaseService != null) { //设计量与到货量对比 List designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId); + Map map4 = new HashMap<>(); + map4.put("type", "designAndArrivalComparison"); if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "designAndArrivalComparison"); - map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos)); - maps.add(map); + map4.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos)); + } else { + map4.put("data", "[]"); } + maps.add(map4); //物资需求与实际到货对比 List wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId); + Map map5 = new HashMap<>(); + map5.put("type", "wzxqysjdhdb"); if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "wzxqysjdhdb"); - map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos)); - maps.add(map); + map5.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos)); + } else { + map5.put("data", "[]"); } + maps.add(map5); } if (materialsService != null) { //物资跟踪管理台账 List useDetailVos = materialsService.listUseDetail(projectId); + Map map6 = new HashMap<>(); + map6.put("type", "listUseDetail"); if (useDetailVos != null && !useDetailVos.isEmpty()) { - Map map = new HashMap<>(); - map.put("type", "listUseDetail"); - map.put("data", JSONUtil.toJsonStr(useDetailVos)); - maps.add(map); + map6.put("data", JSONUtil.toJsonStr(useDetailVos)); + } else { + map6.put("data", "[]"); } + maps.add(map6); } } - } From 2cdabd7b20855ccedfd25b7b986dc72a37b5933f Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Wed, 17 Dec 2025 19:19:33 +0800 Subject: [PATCH 30/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/drone/controller/DroProjectDroneController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/drone/controller/DroProjectDroneController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/drone/controller/DroProjectDroneController.java index 21156bbe..8ad9ba01 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/drone/controller/DroProjectDroneController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/drone/controller/DroProjectDroneController.java @@ -53,7 +53,6 @@ public class DroProjectDroneController extends BaseController { /** * 查询项目无人机信息列表 */ - @SaCheckPermission("drone:projectDrone:list") @GetMapping("/list") public TableDataInfo list(DroProjectDroneBo bo, PageQuery pageQuery) { return droProjectDroneService.queryPageList(bo, pageQuery); From 5de6dff86bfcaecbe48c84d59f7079c1b7c6929d Mon Sep 17 00:00:00 2001 From: zzz <1720989295@qq.com> Date: Wed, 17 Dec 2025 19:43:30 +0800 Subject: [PATCH 31/38] =?UTF-8?q?=E8=B4=A8=E5=AE=89=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A1=B9=E7=9B=AE=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java index 46ff89d2..a0dcf41a 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/DpzaglServiceImpl.java @@ -186,7 +186,7 @@ public class DpzaglServiceImpl implements DpzaglService { // req.setStatus(DpEnum.ZLGDZT_ZG.getTypeValue()); // TableDataInfo aqZgList = safetyInspectionService.queryPageList(req, pageQuery); // 安全总数(用于判断巡检类型) - List list = safetyInspectionService.list(new LambdaQueryWrapper().ge(bo.getStartDate() != null ,HseSafetyInspection::getCreateTime, bo.getStartDate()).le(bo.getEndDate() != null ,HseSafetyInspection::getCreateTime, bo.getEndDate())); + List list = safetyInspectionService.list(new LambdaQueryWrapper().eq(HseSafetyInspection::getProjectId, bo.getProjectId()).ge(bo.getStartDate() != null ,HseSafetyInspection::getCreateTime, bo.getStartDate()).le(bo.getEndDate() != null ,HseSafetyInspection::getCreateTime, bo.getEndDate())); // List rows = anList.getRows(); @@ -222,7 +222,7 @@ public class DpzaglServiceImpl implements DpzaglService { // TableDataInfo zlZgLists = qualityInspectionService.queryPageList(req, pageQuery); // 质量总数 List zsZl = qualityInspectionService.getBaseMapper() - .selectList(new LambdaQueryWrapper() + .selectList(new LambdaQueryWrapper().eq(QltQualityInspection::getProjectId, bo.getProjectId()) .ge(bo.getStartDate() != null ,QltQualityInspection::getCreateTime, bo.getStartDate()).le(bo.getEndDate() != null ,QltQualityInspection::getCreateTime, bo.getEndDate())); From c5bf75a6eb32f410cf192abf355a89c1f65f3e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Wed, 17 Dec 2025 19:47:48 +0800 Subject: [PATCH 32/38] =?UTF-8?q?12-17-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D-=E5=AE=8C?= =?UTF-8?q?=E5=96=84-=E4=BF=AE=E5=A4=8D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BusAttendanceServiceImpl.java | 101 ++++++++++++++---- 1 file changed, 78 insertions(+), 23 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index dd650bbd..2b8e5fcc 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -50,6 +50,7 @@ import org.dromara.project.service.*; import org.dromara.system.domain.SysUser; import org.dromara.system.domain.vo.SysOssVo; import org.dromara.system.domain.vo.SysUserVo; +import org.dromara.system.mapper.SysUserMapper; import org.dromara.system.service.ISysOssService; import org.dromara.system.service.ISysUserService; import org.dromara.websocket.ChatServerHandler; @@ -63,6 +64,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.*; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -111,6 +113,8 @@ public class BusAttendanceServiceImpl extends ServiceImpl list = constructionUserService.list(lqw); //再去从聊天服务中获取在线的ID List onlineUserList = ChatServerHandler.getOnlineUserList(); + //先查询出用户列表 + List users = userMapper.selectVoList(Wrappers.lambdaQuery()); //构建将要返回的 数据 List info = new ArrayList<>(); long zx = 0; //在线 @@ -2803,26 +2809,46 @@ public class BusAttendanceServiceImpl extends ServiceImpl item.getSysUserId().equals(constructionUser.getSysUserId())) - .findFirst().ifPresent(item -> { - SysUserVo sysUserVo = userService.queryById(item.getSysUserId()); - if (sysUserVo != null){ - //app用户类型 0-施工人员 1-管理人员 2-分包人员 - if (sysUserVo.getAppUserType().equals("0")){ - cacheUserVo.setJslx("施工"); - sg.set(sg.getAndIncrement()+1); - }else if (sysUserVo.getAppUserType().equals("2")){ - cacheUserVo.setJslx("分包"); - fb.set(fb.getAndIncrement()+1); - } - } - }); - info.add(cacheUserVo); +// list.stream().filter(item -> item.getSysUserId().equals(constructionUser.getSysUserId())) +// .findFirst().ifPresent(item -> { +// //app用户类型 0-施工人员 1-管理人员 2-分包人员 +// if (cacheSysUserVo.getAppUserType().equals("0")){ +// cacheSysUserVo.setJslx("施工"); +// sg.set(sg.getAndIncrement()+1); +// }else if (cacheSysUserVo.getAppUserType().equals("2")){ +// cacheSysUserVo.setJslx("分包"); +// fb.set(fb.getAndIncrement()+1); +// } +// }); + //app用户类型 0-施工人员 1-管理人员 2-分包人员 + if (cacheSysUserVo.getAppUserType().equals("0")){ + cacheSysUserVo.setJslx("施工"); + sg.set(sg.getAndIncrement()+1); + }else if (cacheSysUserVo.getAppUserType().equals("2")){ + cacheSysUserVo.setJslx("分包"); + fb.set(fb.getAndIncrement()+1); + } + info.add(cacheSysUserVo); }else { lx++; } @@ -2849,16 +2875,28 @@ public class BusAttendanceServiceImpl extends ServiceImpl lqw = new LambdaQueryWrapper<>(); lqw.eq(SubConstructionUser::getProjectId, projectId); List list = constructionUserService.list(lqw); + //先查询出用户列表 + List users = userMapper.selectVoList(Wrappers.lambdaQuery()); //根据分包和班组的id进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数 List fbList = new ArrayList<>(); List bzList = new ArrayList<>(); for (SubConstructionUser constructionUser : list) { //统计该项目下的分包和班组各应有多少人 - SysUserVo sysUserVo = userService.queryById(constructionUser.getSysUserId()); + SysUserVo sysUserVo = null; + for (SysUserVo user : users) { + if (user.getUserId().equals(constructionUser.getSysUserId())){ + sysUserVo = user; + break; + } + } if (sysUserVo == null){ continue; } +// SysUserVo sysUserVo = userService.queryById(constructionUser.getSysUserId()); +// if (sysUserVo == null){ +// continue; +// } //判断userType app用户类型 0-施工人员 1-管理人员 2-分包人员 if (sysUserVo.getAppUserType().equals("0")){ checkAndSetValue(bzList,constructionUser,0,timeType,projectId); @@ -2898,12 +2936,23 @@ public class BusAttendanceServiceImpl extends ServiceImpl ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId){ //timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验 - if (time == 2L){ - time = 7L; - }else if (time == 3L){ - time = 30L; + if (time == 2L) { + // 获取本周一到今天的天数 + LocalDate today = LocalDate.now(); + LocalDate monday = today.with(DayOfWeek.MONDAY); + time = ChronoUnit.DAYS.between(monday, today) + 1; + } else if (time == 3L) { + // 获取本月1日到今天的天数 + LocalDate today = LocalDate.now(); + LocalDate firstDay = today.withDayOfMonth(1); + time = ChronoUnit.DAYS.between(firstDay, today) + 1; } Long finalTime = time; From 61c2cdd56aef0cc3006f30a13fc6a8e539f3bc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Wed, 17 Dec 2025 20:09:00 +0800 Subject: [PATCH 33/38] =?UTF-8?q?12-17-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D-=E5=AE=8C?= =?UTF-8?q?=E5=96=84-=E4=BF=AE=E5=A4=8D=E7=89=88-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=88=86=E5=8C=85=E5=85=AC=E5=8F=B8=E6=9F=A5=E8=AF=A2=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/mapper/BusAttendanceMapper.java | 6 ++++-- .../impl/BusAttendanceServiceImpl.java | 20 +++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/mapper/BusAttendanceMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/mapper/BusAttendanceMapper.java index 04930bf7..80690984 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/mapper/BusAttendanceMapper.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/mapper/BusAttendanceMapper.java @@ -9,6 +9,8 @@ import org.dromara.project.domain.BusAttendance; import org.dromara.project.domain.bo.BusAttendanceBo; import org.dromara.project.domain.vo.BusAttendanceVo; +import java.util.List; + /** * 考勤Mapper接口 * @@ -20,6 +22,6 @@ public interface BusAttendanceMapper extends BaseMapperPlus queryPageList(BusAttendanceBo bo, PageQuery pageQuery); - @Select("select * from sub_contractor where id = #{id}") - SubContractor getSubContractor(Long id); + @Select("select * from sub_contractor") + List getSubContractor(); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index 2b8e5fcc..2d5b6fb1 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -2877,6 +2877,8 @@ public class BusAttendanceServiceImpl extends ServiceImpl list = constructionUserService.list(lqw); //先查询出用户列表 List users = userMapper.selectVoList(Wrappers.lambdaQuery()); + //查询分包公司用于填充名称 + List subContractors = baseMapper.getSubContractor(); //根据分包和班组的id进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数 List fbList = new ArrayList<>(); List bzList = new ArrayList<>(); @@ -2893,15 +2895,11 @@ public class BusAttendanceServiceImpl extends ServiceImpl ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId){ + private void checkAndSetValue(List ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId,List SubContractors){ //timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验 if (time == 2L) { // 获取本周一到今天的天数 @@ -2995,9 +2993,11 @@ public class BusAttendanceServiceImpl extends ServiceImpl Date: Wed, 17 Dec 2025 20:35:29 +0800 Subject: [PATCH 34/38] =?UTF-8?q?12-17-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D-=E5=AE=8C?= =?UTF-8?q?=E5=96=84-=E4=BF=AE=E5=A4=8D=E7=89=88-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=88=86=E5=8C=85=E5=85=AC=E5=8F=B8=E6=9F=A5=E8=AF=A2=E7=89=88?= =?UTF-8?q?-=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BusAttendanceServiceImpl.java | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index 2d5b6fb1..bb6b3be2 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -2868,7 +2868,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl map){ //构建数据 //timeType 1:今天 2:本周 3:本月 - Long zrs; //总人数 + Long zrs = 0L; //总人数 Long cqr = 0L; //出勤人数 BigDecimal cql = BigDecimal.ZERO; //出勤率 //查询此项目的所有人员 @@ -2918,7 +2918,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl0){ @@ -2930,22 +2930,22 @@ public class BusAttendanceServiceImpl extends ServiceImpl Date: Wed, 17 Dec 2025 21:05:36 +0800 Subject: [PATCH 35/38] =?UTF-8?q?12-17-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D-=E5=AE=8C?= =?UTF-8?q?=E5=96=84-=E4=BF=AE=E5=A4=8D=E7=89=88-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=88=86=E5=8C=85=E5=85=AC=E5=8F=B8=E6=9F=A5=E8=AF=A2=E7=89=88?= =?UTF-8?q?-=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BusAttendanceServiceImpl.java | 96 ++++++++++--------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index bb6b3be2..a761c392 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -2879,6 +2879,28 @@ public class BusAttendanceServiceImpl extends ServiceImpl users = userMapper.selectVoList(Wrappers.lambdaQuery()); //查询分包公司用于填充名称 List subContractors = baseMapper.getSubContractor(); + //查询打卡表进行优化 + // 今天所有用户的打卡记录 + List attendanceList = new ArrayList<>(); + LambdaQueryWrapper lqw1 = new LambdaQueryWrapper() + .eq(BusAttendance::getProjectId, projectId); +// .eq(BusAttendance::getUserId, userId); + if (timeType == 1L) { + lqw1.eq(BusAttendance::getClockDate, LocalDate.now()); + } else if (timeType == 2L) { + // 获取本周一到今天的日期 + LocalDate today = LocalDate.now(); + LocalDate monday = today.with(DayOfWeek.MONDAY); + lqw1.between(BusAttendance::getClockDate, monday, today); + }else if (timeType == 3L){ + // 获取本月1号到今天的日期 + LocalDate today = LocalDate.now(); + LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); + lqw1.between(BusAttendance::getClockDate, firstDayOfMonth, today); + } + lqw1.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) + .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); + attendanceList = this.list(lqw1); //根据分包和班组的id进行分类 统计都有多少人 未入场人员没有两项数据 无法统计 仅能计算为总数 List fbList = new ArrayList<>(); List bzList = new ArrayList<>(); @@ -2897,9 +2919,9 @@ public class BusAttendanceServiceImpl extends ServiceImpl ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId,List SubContractors){ + private void checkAndSetValue(List ryglWebSocketVoList, SubConstructionUser info,int type,Long time,Long projectId,List SubContractors,List attendanceList){ //timeType 1:今天 2:本周 3:本月 此参数的校验放在连接时获取参数进行校验 if (time == 2L) { // 获取本周一到今天的天数 @@ -2986,7 +2995,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl Objects.equals(item.getZzId(), info.getContractorId())).findFirst().ifPresentOrElse( item -> { item.setZrs(item.getZrs() + finalTime); - item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); + item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId,attendanceList)); }, () -> { RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); //分包组织id @@ -3002,7 +3011,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl Objects.equals(item.getZzId(), info.getTeamId())).findFirst().ifPresentOrElse( item -> { item.setZrs(item.getZrs() + finalTime); - item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId)); + item.setDgrs(item.getDgrs() + getDgrs(info.getSysUserId(),finalTime,projectId,attendanceList)); }, () -> { RyglWebSocketVo ryglWebSocketVo = new RyglWebSocketVo(); //班组组织id @@ -3021,7 +3030,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl attendanceList) { // 今天所有用户的打卡记录 - List attendanceList; - LambdaQueryWrapper lqw = new LambdaQueryWrapper() - .eq(BusAttendance::getProjectId, projectId) - .eq(BusAttendance::getUserId, userId); - if (time == 1L) { - lqw.eq(BusAttendance::getClockDate, LocalDate.now()); - } else if (time == 2L) { - // 获取本周一到今天的日期 - LocalDate today = LocalDate.now(); - LocalDate monday = today.with(DayOfWeek.MONDAY); - lqw.between(BusAttendance::getClockDate, monday, today); - }else if (time == 3L){ - // 获取本月1号到今天的日期 - LocalDate today = LocalDate.now(); - LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); - lqw.between(BusAttendance::getClockDate, firstDayOfMonth, today); - } - lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) - .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); - attendanceList = this.list(lqw); - if (attendanceList == null || attendanceList.isEmpty()){ + List busAttendances = attendanceList.stream().filter(item -> Objects.equals(item.getUserId(), userId)).toList(); +// List attendanceList; +// LambdaQueryWrapper lqw = new LambdaQueryWrapper() +// .eq(BusAttendance::getProjectId, projectId) +// .eq(BusAttendance::getUserId, userId); +// if (time == 1L) { +// lqw.eq(BusAttendance::getClockDate, LocalDate.now()); +// } else if (time == 2L) { +// // 获取本周一到今天的日期 +// LocalDate today = LocalDate.now(); +// LocalDate monday = today.with(DayOfWeek.MONDAY); +// lqw.between(BusAttendance::getClockDate, monday, today); +// }else if (time == 3L){ +// // 获取本月1号到今天的日期 +// LocalDate today = LocalDate.now(); +// LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); +// lqw.between(BusAttendance::getClockDate, firstDayOfMonth, today); +// } +// lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) +// .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); +// attendanceList = this.list(lqw); + if (busAttendances.isEmpty()){ return 0L; } final Long[] count = {0L}; //根据日期分组 - Map> collect = attendanceList.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate)); + Map> collect = busAttendances.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate)); collect.forEach((key, value) -> { //每一天分组 同一天去重 List list = value.stream().map(BusAttendance::getUserId).distinct().toList(); From 731b8bb1d234884764d14f78ec20cb5c062dbbab Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Thu, 18 Dec 2025 09:27:02 +0800 Subject: [PATCH 36/38] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProgressBigScreenController.java | 7 +- .../progress/MaterialProgressDetailVo.java | 5 ++ .../service/ProgressBigScreenService.java | 2 +- .../impl/ProgressBigScreenServiceImpl.java | 38 ++++++++--- .../service/impl/BusMrpBaseServiceImpl.java | 65 +++++++++---------- 5 files changed, 68 insertions(+), 49 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java index f6d19401..db45560b 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/controller/ProgressBigScreenController.java @@ -73,9 +73,8 @@ public class ProgressBigScreenController extends BaseController { /** * 获取材料进度详情 */ - @GetMapping("/materialProgress/detail/{projectId}") - public R> getMaterialProgressDetail(@NotNull(message = "项目主键不能为空") - @PathVariable Long projectId) { - return R.ok(progressBigScreenService.getMaterialProgressDetail(projectId)); + @GetMapping("/materialProgress/detail") + public R> getMaterialProgressDetail(Long project, String name, String specification) { + return R.ok(progressBigScreenService.getMaterialProgressDetail(project, name, specification)); } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MaterialProgressDetailVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MaterialProgressDetailVo.java index a643f4fb..eddfa0f4 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MaterialProgressDetailVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/domain/progress/MaterialProgressDetailVo.java @@ -44,6 +44,11 @@ public class MaterialProgressDetailVo implements Serializable { // region 接收单数据 + /** + * 表单编号 + */ + private String formCode; + /** * 合同名称 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java index 5d11397b..c69cfcab 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/ProgressBigScreenService.java @@ -55,7 +55,7 @@ public interface ProgressBigScreenService { * @param projectId 项目 id * @return 物料进度详情 */ - List getMaterialProgressDetail(Long projectId); + List getMaterialProgressDetail(Long projectId, String name, String specification); /** * 获取物资进度 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java index 49a8b6b3..95baefc4 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/bigscreen/service/impl/ProgressBigScreenServiceImpl.java @@ -21,6 +21,7 @@ import org.dromara.materials.domain.MatMaterialReceive; import org.dromara.materials.domain.MatMaterialReceiveItem; import org.dromara.materials.service.IMatMaterialReceiveItemService; import org.dromara.materials.service.IMatMaterialReceiveService; +import org.dromara.materials.service.IMatMaterialsService; import org.dromara.progress.constant.PgsProgressCategoryConstant; import org.dromara.progress.domain.PgsConstructionSchedulePlan; import org.dromara.progress.domain.PgsProgressCategory; @@ -88,6 +89,9 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { @Resource private IBusMrpBaseService mrpBaseService; + @Resource + private IMatMaterialsService matMaterialsService; + /** * 获取项目总进度 * @@ -336,20 +340,19 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { * @return 物料进度详情 */ @Override - public List getMaterialProgressDetail(Long projectId) { - List receiveList = materialReceiveService.lambdaQuery() - .eq(MatMaterialReceive::getProjectId, projectId) - .list(); - if (CollUtil.isEmpty(receiveList)) { - return List.of(); - } - List ids = receiveList.stream().map(MatMaterialReceive::getId).toList(); + public List getMaterialProgressDetail(Long projectId, String name, String specification) { + // 根据名称 规格获取材料 List itemList = materialReceiveItemService.lambdaQuery() - .in(MatMaterialReceiveItem::getReceiveId, ids) + .eq(MatMaterialReceiveItem::getName, name) + .eq(MatMaterialReceiveItem::getSpecification, specification) .list(); if (CollUtil.isEmpty(itemList)) { return List.of(); } + Set ids = itemList.stream().map(MatMaterialReceiveItem::getReceiveId).collect(Collectors.toSet()); + List receiveList = materialReceiveService.lambdaQuery() + .in(MatMaterialReceive::getId, ids) + .list(); Map receiveMap = receiveList.stream() .collect(Collectors.toMap(MatMaterialReceive::getId, receive -> receive)); return itemList.stream().map(item -> { @@ -364,6 +367,7 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { vo.setQuantity(item.getQuantity()); vo.setAcceptedQuantity(item.getAcceptedQuantity()); vo.setShortageQuantity(item.getShortageQuantity()); + vo.setFormCode(receive.getFormCode()); vo.setContractName(receive.getContractName()); vo.setOrderingUnit(receive.getOrderingUnit()); vo.setSupplierUnit(receive.getSupplierUnit()); @@ -380,6 +384,20 @@ public class ProgressBigScreenServiceImpl implements ProgressBigScreenService { */ @Override public List getMaterialProgress(Long projectId) { - return mrpBaseService.wzxqysjdhdb(projectId); + List wzxqysjdhdb = mrpBaseService.wzxqysjdhdb(projectId); + Map> map = wzxqysjdhdb.stream() + .collect(Collectors.groupingBy(o -> o.getName() + o.getSpecification())); + List wzxqysjdhdbList = new ArrayList<>(); + map.forEach((k, v) -> { + wzxqysjdhdbVo vo = new wzxqysjdhdbVo(); + vo.setName(v.getFirst().getName()); + vo.setSpecification(v.getFirst().getSpecification()); + BigDecimal design = v.stream().map(wzxqysjdhdbVo::getDesignTotalPrices).reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setDesignTotalPrices(design); + BigDecimal arrival = v.stream().map(wzxqysjdhdbVo::getArrivalTotalPrices).reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setArrivalTotalPrices(arrival); + wzxqysjdhdbList.add(vo); + }); + return wzxqysjdhdbList; } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java index e4d423ce..d7f408ab 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cailiaoshebei/service/impl/BusMrpBaseServiceImpl.java @@ -4,21 +4,30 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jakarta.annotation.Resource; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo; import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo; import org.dromara.cailiaoshebei.domain.BusMaterialbatchdemandplan; +import org.dromara.cailiaoshebei.domain.BusMrpBase; import org.dromara.cailiaoshebei.domain.BusPlanDocAssociation; import org.dromara.cailiaoshebei.domain.bo.BusMaterialbatchdemandplanBo; +import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo; import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseReq; import org.dromara.cailiaoshebei.domain.dto.BusMaterialbatchdemandplanExportDto; import org.dromara.cailiaoshebei.domain.dto.BusMrpDto; import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto; import org.dromara.cailiaoshebei.domain.vo.BusMaterialbatchdemandplanVo; +import org.dromara.cailiaoshebei.domain.vo.BusMrpBaseVo; import org.dromara.cailiaoshebei.domain.vo.BusMrpVo; +import org.dromara.cailiaoshebei.mapper.BusMrpBaseMapper; import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService; +import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.dromara.cailiaoshebei.service.IBusPlanDocAssociationService; import org.dromara.common.core.domain.event.ProcessDeleteEvent; import org.dromara.common.core.domain.event.ProcessEvent; @@ -27,15 +36,9 @@ import org.dromara.common.core.enums.BusinessStatusEnum; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; -import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.PageQuery; -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.common.mybatis.core.page.TableDataInfo; import org.dromara.common.utils.excel.ExcelDynamicReader; -import org.dromara.design.domain.BusBillofquantities; -import org.dromara.design.service.IBusBillofquantitiesService; import org.dromara.materials.domain.MatMaterialReceiveItem; import org.dromara.materials.service.IMatMaterialReceiveItemService; import org.dromara.tender.domain.BusBillofquantitiesLimitList; @@ -47,11 +50,6 @@ import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Lazy; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; -import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo; -import org.dromara.cailiaoshebei.domain.vo.BusMrpBaseVo; -import org.dromara.cailiaoshebei.domain.BusMrpBase; -import org.dromara.cailiaoshebei.mapper.BusMrpBaseMapper; -import org.dromara.cailiaoshebei.service.IBusMrpBaseService; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; @@ -77,14 +75,13 @@ public class BusMrpBaseServiceImpl extends ServiceImpl { String name = item.getName() != null ? item.getName() : ""; - return "名称:“"+name + "”"; + return "名称:“" + name + "”"; }) .orElse("未知物料"); throw new ServiceException(itemName + "超出数量"); @@ -312,7 +309,7 @@ public class BusMrpBaseServiceImpl extends ServiceImpl remaining(Long projectId, Long limitListId,Long mrpBaseId) { + public Map remaining(Long projectId, Long limitListId, Long mrpBaseId) { Map map = new HashMap<>(); List busTenderPlanningLimitLists = tenderPlanningLimitListService.getBaseMapper() .selectList(new LambdaQueryWrapper() @@ -326,23 +323,23 @@ public class BusMrpBaseServiceImpl extends ServiceImpl existingList = planservice.list( Wrappers.lambdaQuery(BusMaterialbatchdemandplan.class) - .eq(BusMaterialbatchdemandplan::getSuppliespriceId ,limitListId) - .ne(mrpBaseId!=null,BusMaterialbatchdemandplan::getMrpBaseId, mrpBaseId)// 排除当前批次 + .eq(BusMaterialbatchdemandplan::getSuppliespriceId, limitListId) + .ne(mrpBaseId != null, BusMaterialbatchdemandplan::getMrpBaseId, mrpBaseId)// 排除当前批次 ); BigDecimal reduce = BigDecimal.ZERO; - if(CollectionUtil.isNotEmpty(existingList)){ - reduce = existingList.stream() + if (CollectionUtil.isNotEmpty(existingList)) { + reduce = existingList.stream() .map(BusMaterialbatchdemandplan::getDemandQuantity) .reduce(BigDecimal.ZERO, BigDecimal::add); } - map.put("remainingQuantity",quantity.subtract(reduce)); - map.put("suppliespriceId",limitListId); + map.put("remainingQuantity", quantity.subtract(reduce)); + map.put("suppliespriceId", limitListId); if (busBillofquantities != null) { - map.put("specification",busBillofquantities.getSpecification()); - map.put("unit",busBillofquantities.getUnit()); - map.put("unitPrice",busBillofquantities.getUnitPrice()); - map.put("remark",busBillofquantities.getRemark()); - map.put("name",busBillofquantities.getName()); + map.put("specification", busBillofquantities.getSpecification()); + map.put("unit", busBillofquantities.getUnit()); + map.put("unitPrice", busBillofquantities.getUnitPrice()); + map.put("remark", busBillofquantities.getRemark()); + map.put("name", busBillofquantities.getName()); } return map; } @@ -357,26 +354,26 @@ public class BusMrpBaseServiceImpl extends ServiceImpl iterator = busMaterialbatchdemandplans.iterator(); Set mrpIds = new HashSet<>(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { BusMaterialbatchdemandplan next = iterator.next(); List busPlanDocAssociations = planDocAssociationService.getBaseMapper().selectList(new LambdaQueryWrapper() .eq(BusPlanDocAssociation::getProjectId, req.getProjectId()) .eq(BusPlanDocAssociation::getPlanId, next.getId())); BigDecimal demandQuantity = BigDecimal.ZERO; busPlanDocAssociations.forEach(busPlanDocAssociation -> { - demandQuantity.add(busPlanDocAssociation.getDemandQuantity()); + demandQuantity.add(busPlanDocAssociation.getDemandQuantity()); }); if (demandQuantity.compareTo(next.getDemandQuantity()) >= 0) { iterator.remove(); - }else { + } else { mrpIds.add(next.getMrpBaseId()); } } - if (mrpIds.isEmpty()){ + if (mrpIds.isEmpty()) { return null; } return baseMapper.selectVoList(new LambdaQueryWrapper() - .eq(BusMrpBase::getStatus,BusinessStatusEnum.FINISH.getStatus()).in(BusMrpBase::getId,mrpIds)); + .eq(BusMrpBase::getStatus, BusinessStatusEnum.FINISH.getStatus()).in(BusMrpBase::getId, mrpIds)); } @Override @@ -411,14 +408,14 @@ public class BusMrpBaseServiceImpl extends ServiceImpl planIds = matMaterialReceiveItems.stream() .map(MatMaterialReceiveItem::getPlanId) .collect(Collectors.toSet()); - if (CollUtil.isEmpty(planIds)){ + if (CollUtil.isEmpty(planIds)) { return new HashMap<>(); } Map planMap = matMaterialReceiveItems.stream() .filter(matMaterialReceiveItem -> matMaterialReceiveItem.getPlanId() != null) .collect(Collectors.groupingBy( MatMaterialReceiveItem::getPlanId, - Collectors.reducing(BigDecimal.ZERO, MatMaterialReceiveItem::getQuantity, BigDecimal::add) + Collectors.reducing(BigDecimal.ZERO, MatMaterialReceiveItem::getAcceptedQuantity, BigDecimal::add) )); // 根据入库数据反查批次需求计划数据 bus_materialbatchdemandplan List materialbatchdemandplans = planservice.getBaseMapper().selectList(new LambdaQueryWrapper() From b550753d6fc53c7a79c9ee2b056619a9cf834249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Thu, 18 Dec 2025 10:29:55 +0800 Subject: [PATCH 37/38] =?UTF-8?q?12-18-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D-=E5=AE=8C?= =?UTF-8?q?=E5=96=84-=E4=BF=AE=E5=A4=8D=E7=89=88-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=88=86=E5=8C=85=E5=85=AC=E5=8F=B8=E6=9F=A5=E8=AF=A2=E7=89=88?= =?UTF-8?q?-=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2-=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BusAttendanceServiceImpl.java | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index a761c392..43f36cc4 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -3002,12 +3002,17 @@ public class BusAttendanceServiceImpl extends ServiceImpl attendanceList) { - // 今天所有用户的打卡记录 + // 过滤出该用户的打卡记录 List busAttendances = attendanceList.stream().filter(item -> Objects.equals(item.getUserId(), userId)).toList(); -// List attendanceList; -// LambdaQueryWrapper lqw = new LambdaQueryWrapper() -// .eq(BusAttendance::getProjectId, projectId) -// .eq(BusAttendance::getUserId, userId); -// if (time == 1L) { -// lqw.eq(BusAttendance::getClockDate, LocalDate.now()); -// } else if (time == 2L) { -// // 获取本周一到今天的日期 -// LocalDate today = LocalDate.now(); -// LocalDate monday = today.with(DayOfWeek.MONDAY); -// lqw.between(BusAttendance::getClockDate, monday, today); -// }else if (time == 3L){ -// // 获取本月1号到今天的日期 -// LocalDate today = LocalDate.now(); -// LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); -// lqw.between(BusAttendance::getClockDate, firstDayOfMonth, today); -// } -// lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) -// .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); -// attendanceList = this.list(lqw); + if (busAttendances.isEmpty()){ return 0L; } From f19dd2099557b3862cc1b294d790741019aefc13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Thu, 18 Dec 2025 10:29:55 +0800 Subject: [PATCH 38/38] =?UTF-8?q?12-18-=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A4=A7=E5=B1=8F-=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B3=A8=E5=85=A5=E7=89=88-=E4=BF=AE=E5=A4=8DtimeType?= =?UTF-8?q?=E7=89=88-=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D-=E5=AE=8C?= =?UTF-8?q?=E5=96=84-=E4=BF=AE=E5=A4=8D=E7=89=88-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=88=86=E5=8C=85=E5=85=AC=E5=8F=B8=E6=9F=A5=E8=AF=A2=E7=89=88?= =?UTF-8?q?-=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2-=E5=AE=8C=E5=96=84-=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BusAttendanceServiceImpl.java | 48 +++++-------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java index a761c392..2a5a5479 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusAttendanceServiceImpl.java @@ -2806,7 +2806,6 @@ public class BusAttendanceServiceImpl extends ServiceImpl item.getSysUserId().equals(constructionUser.getSysUserId())) -// .findFirst().ifPresent(item -> { -// //app用户类型 0-施工人员 1-管理人员 2-分包人员 -// if (cacheSysUserVo.getAppUserType().equals("0")){ -// cacheSysUserVo.setJslx("施工"); -// sg.set(sg.getAndIncrement()+1); -// }else if (cacheSysUserVo.getAppUserType().equals("2")){ -// cacheSysUserVo.setJslx("分包"); -// fb.set(fb.getAndIncrement()+1); -// } -// }); //app用户类型 0-施工人员 1-管理人员 2-分包人员 if (cacheSysUserVo.getAppUserType().equals("0")){ cacheSysUserVo.setJslx("施工"); @@ -2848,6 +2835,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl attendanceList) { - // 今天所有用户的打卡记录 + // 过滤出该用户的打卡记录 List busAttendances = attendanceList.stream().filter(item -> Objects.equals(item.getUserId(), userId)).toList(); -// List attendanceList; -// LambdaQueryWrapper lqw = new LambdaQueryWrapper() -// .eq(BusAttendance::getProjectId, projectId) -// .eq(BusAttendance::getUserId, userId); -// if (time == 1L) { -// lqw.eq(BusAttendance::getClockDate, LocalDate.now()); -// } else if (time == 2L) { -// // 获取本周一到今天的日期 -// LocalDate today = LocalDate.now(); -// LocalDate monday = today.with(DayOfWeek.MONDAY); -// lqw.between(BusAttendance::getClockDate, monday, today); -// }else if (time == 3L){ -// // 获取本月1号到今天的日期 -// LocalDate today = LocalDate.now(); -// LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); -// lqw.between(BusAttendance::getClockDate, firstDayOfMonth, today); -// } -// lqw.in(BusAttendance::getClockStatus, ATTENDANCE_STATUS) -// .apply(" user_id not in (select sys_user_id from sub_construction_user where project_id = {0} and user_role != '0' )", projectId); -// attendanceList = this.list(lqw); + if (busAttendances.isEmpty()){ return 0L; }