From e42f1a0b8c9bed1257184098fbce99cd21870783 Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Fri, 20 Jun 2025 19:56:47 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20=E6=96=B0=E5=A2=9EAI=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E4=B8=8E=E5=B2=97=E4=BD=8D=E5=85=B3=E8=81=94?= =?UTF-8?q?=EF=BC=8C=E6=96=AF=E5=B7=B4=E8=BE=BE=E8=AF=86=E5=88=AB=E8=8E=B7?= =?UTF-8?q?=E5=8F=96token=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yml | 11 +- .../src/main/resources/application-prod.yml | 8 +- .../java/org/dromara/test/SpartaTest.java | 25 ++ .../constant/FacRedisKeyConstant.java | 5 + .../cycle/IncSyncYs7DeviceCapturePicData.java | 9 +- .../manager/spartamanager/SpartaConstant.java | 24 ++ .../manager/spartamanager/SpartaManager.java | 45 +++ .../spartamanager/SpartaProperties.java | 30 ++ .../spartamanager/SpartaRequestUtils.java | 54 +++ .../spartamanager/vo/SpartaResponseVo.java | 27 ++ .../spartamanager/vo/SpartaTokenVo.java | 21 ++ .../manager/ys7manager/Ys7Manager.java | 10 +- .../manager/ys7manager/Ys7RequestUtils.java | 14 +- .../OthYs7DeviceImgCreateByCapture.java | 6 + .../impl/OthYs7DeviceImgServiceImpl.java | 1 + .../HseViolationLevelController.java | 107 ++++++ .../safety/domain/HseViolationLevel.java | 56 ++++ .../safety/domain/HseViolationLevelPost.java | 35 ++ .../HseViolationLevelCreateReq.java | 53 +++ .../HseViolationLevelQueryReq.java | 38 +++ .../HseViolationLevelUpdateReq.java | 51 +++ .../HseViolationLevelByPostVo.java | 61 ++++ .../violationlevel/HseViolationLevelVo.java | 74 ++++ .../HseViolationLevelPostVo.java | 39 +++ .../mapper/HseViolationLevelMapper.java | 15 + .../mapper/HseViolationLevelPostMapper.java | 15 + .../IHseViolationLevelPostService.java | 13 + .../service/IHseViolationLevelService.java | 100 ++++++ .../HseViolationLevelPostServiceImpl.java | 19 ++ .../impl/HseViolationLevelServiceImpl.java | 316 ++++++++++++++++++ .../mapper/safety/HseViolationLevelMapper.xml | 7 + .../safety/HseViolationLevelPostMapper.xml | 7 + xinnengyuan/script/sql/menuInitValue.sql | 40 +++ xinnengyuan/script/sql/xinnengyuan.sql | 8 + 34 files changed, 1320 insertions(+), 24 deletions(-) create mode 100644 xinnengyuan/ruoyi-admin/src/test/java/org/dromara/test/SpartaTest.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaConstant.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaManager.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaProperties.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaRequestUtils.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/vo/SpartaResponseVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/vo/SpartaTokenVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/controller/HseViolationLevelController.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HseViolationLevel.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HseViolationLevelPost.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelCreateReq.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelQueryReq.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelUpdateReq.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevel/HseViolationLevelByPostVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevel/HseViolationLevelVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevelpost/HseViolationLevelPostVo.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HseViolationLevelMapper.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HseViolationLevelPostMapper.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHseViolationLevelPostService.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHseViolationLevelService.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseViolationLevelPostServiceImpl.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseViolationLevelServiceImpl.java create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HseViolationLevelMapper.xml create mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HseViolationLevelPostMapper.xml diff --git a/xinnengyuan/ruoyi-admin/src/main/resources/application-dev.yml b/xinnengyuan/ruoyi-admin/src/main/resources/application-dev.yml index 5fa9cd10..16a496e3 100644 --- a/xinnengyuan/ruoyi-admin/src/main/resources/application-dev.yml +++ b/xinnengyuan/ruoyi-admin/src/main/resources/application-dev.yml @@ -49,9 +49,9 @@ spring: driverClassName: com.mysql.cj.jdbc.Driver # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562 # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题) - url: jdbc:mysql://192.168.110.119:3306/xinnengyuan?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: 123456 + url: jdbc:mysql://192.168.110.2:13386/xinnengyuandev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: xinnengyuandev + password: StRWCZdZirysNSs2 # # 从库数据源 # slave: # lazy: true @@ -278,3 +278,8 @@ ys7: #ys7: # app-key: f01490bd5d5241b7809d8fc5fe84f7f8 # app-secret: d468f270699de855fd85fe7fd6f9595f +# 斯巴达算法 +sparta: + url: http://119.3.204.120:8040 + client-id: test + client-secret: 115fcb08fa6742a1b086d9bb80a6ad59 diff --git a/xinnengyuan/ruoyi-admin/src/main/resources/application-prod.yml b/xinnengyuan/ruoyi-admin/src/main/resources/application-prod.yml index 7d314af8..c1c3c3c2 100644 --- a/xinnengyuan/ruoyi-admin/src/main/resources/application-prod.yml +++ b/xinnengyuan/ruoyi-admin/src/main/resources/application-prod.yml @@ -267,10 +267,10 @@ justauth: redirect-uri: ${justauth.address}/social-callback?source=gitlab # 和风天气 https://dev.qweather.com/ weather: - key-id: T65EAABUXC - project-id: 2JTHPUQ5YY - private-key: MC4CAQAwBQYDK2VwBCIEIMAglX7IsxYiTeM+FXXnvCUsIggajeP4s8gAllewm6BN - api-host: n35rk53njv.re.qweatherapi.com + key-id: xx + project-id: xx + private-key: xx + api-host: xx # dxf转 geojson 执行文件名 dxf2GeoJson: file-name: main diff --git a/xinnengyuan/ruoyi-admin/src/test/java/org/dromara/test/SpartaTest.java b/xinnengyuan/ruoyi-admin/src/test/java/org/dromara/test/SpartaTest.java new file mode 100644 index 00000000..5cb4e8ad --- /dev/null +++ b/xinnengyuan/ruoyi-admin/src/test/java/org/dromara/test/SpartaTest.java @@ -0,0 +1,25 @@ +package org.dromara.test; + +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.dromara.manager.spartamanager.SpartaManager; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +/** + * @author lcj + * @date 2025/6/20 19:40 + */ +@Slf4j +@SpringBootTest +public class SpartaTest { + + @Resource + private SpartaManager spartaManager; + + @Test + public void test() { + String token = spartaManager.getToken(); + log.info("token: {}", token); + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/constant/FacRedisKeyConstant.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/constant/FacRedisKeyConstant.java index 18d832ec..cc657d6a 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/constant/FacRedisKeyConstant.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/constant/FacRedisKeyConstant.java @@ -28,6 +28,11 @@ public interface FacRedisKeyConstant { */ String GEO_TYPE_NAME = "name"; + /** + * 设施模块位置 GIS Redis 缓存前缀 + */ + String POSITION_GIS_REDIS_KEY_PREFIX = FAC_REDIS_PREFIX + "gis:" + "position:"; + /** * 批量上传桩点、支架、立柱 Redis 缓存 key * diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/cycle/IncSyncYs7DeviceCapturePicData.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/cycle/IncSyncYs7DeviceCapturePicData.java index 9c005fde..acd3f036 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/cycle/IncSyncYs7DeviceCapturePicData.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/cycle/IncSyncYs7DeviceCapturePicData.java @@ -13,10 +13,7 @@ import org.dromara.other.service.IOthYs7DeviceService; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -29,7 +26,7 @@ import java.util.stream.Collectors; * @date 2025/6/18 15:59 */ @Slf4j -@Component +//@Component public class IncSyncYs7DeviceCapturePicData { @Resource @@ -98,6 +95,7 @@ public class IncSyncYs7DeviceCapturePicData { // 抓取当前画面图片 try { String url = ys7Manager.getCaptureDevicePic(deviceSerial, channelNo, 2); + img.setCreateTime(new Date()); img.setUrl(url); imgList.add(img); } catch (Exception e) { @@ -111,6 +109,7 @@ public class IncSyncYs7DeviceCapturePicData { img.setDeviceName(ys7Device.getDeviceName()); try { String url = ys7Manager.getCaptureDevicePic(deviceSerial, 1, 2); + img.setCreateTime(new Date()); img.setUrl(url); imgList.add(img); } catch (Exception e) { diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaConstant.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaConstant.java new file mode 100644 index 00000000..ded167be --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaConstant.java @@ -0,0 +1,24 @@ +package org.dromara.manager.spartamanager; + +/** + * @author lcj + * @date 2025/6/20 19:05 + */ +public interface SpartaConstant { + + /** + * token redis 缓存 key 前缀 + */ + String TOKEN_REDIS_KEY = "sparta:token"; + + /** + * 获取 token api 路径 + */ + String GET_TOKEN_API_PATH_GET = "/token"; + + /** + * 识别 api 路径 + */ + String RECOGNIZE_API_PATH_GET = "/api/recognize"; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaManager.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaManager.java new file mode 100644 index 00000000..0d0892f6 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaManager.java @@ -0,0 +1,45 @@ +package org.dromara.manager.spartamanager; + +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.dromara.manager.spartamanager.vo.SpartaTokenVo; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +/** + * @author lcj + * @date 2025/6/20 19:27 + */ +@Slf4j +@Component +public class SpartaManager { + + @Resource + private SpartaProperties spartaProperties; + + @Resource + private StringRedisTemplate stringRedisTemplate; + + /** + * 获取token + * + * @return token + */ + public String getToken() { + String token = stringRedisTemplate.opsForValue().get(SpartaConstant.TOKEN_REDIS_KEY); + if (token != null) { + return token; + } + SpartaTokenVo tokenVo = SpartaRequestUtils.getToken( + spartaProperties.getUrl(), + spartaProperties.getClientId(), + spartaProperties.getClientSecret() + ); + token = tokenVo.getToken(); + Long expiresAt = tokenVo.getExpiresAt(); + stringRedisTemplate.opsForValue().set(SpartaConstant.TOKEN_REDIS_KEY, token, (expiresAt - 3600), TimeUnit.SECONDS); + return token; + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaProperties.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaProperties.java new file mode 100644 index 00000000..7d1a552d --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaProperties.java @@ -0,0 +1,30 @@ +package org.dromara.manager.spartamanager; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * @author lcj + * @date 2025/6/20 19:01 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "sparta") +public class SpartaProperties { + + /** + * 请求地址 + */ + private String url; + + /** + * 客户端id + */ + private String clientId; + + /** + * 客户端密钥 + */ + private String clientSecret; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaRequestUtils.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaRequestUtils.java new file mode 100644 index 00000000..d6cb8cec --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/SpartaRequestUtils.java @@ -0,0 +1,54 @@ +package org.dromara.manager.spartamanager; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import lombok.extern.slf4j.Slf4j; +import org.dromara.common.core.exception.ServiceException; +import org.dromara.manager.spartamanager.vo.SpartaResponseVo; +import org.dromara.manager.spartamanager.vo.SpartaTokenVo; + +import java.util.HashMap; + +/** + * @author lcj + * @date 2025/6/20 19:06 + */ +@Slf4j +public class SpartaRequestUtils { + + /** + * 获取斯巴达 Token + * + * @param host 域名 + * @param clientId 客户端id + * @param clientSecret 客户端密钥 + * @return token + */ + public static SpartaTokenVo getToken(String host, String clientId, String clientSecret) { + HashMap paramMap = new HashMap<>(); + paramMap.put("clientId", clientId); + paramMap.put("clientSecret", clientSecret); + String errorMsg = "斯巴达 Token 请求失败"; + String url = host + SpartaConstant.GET_TOKEN_API_PATH_GET; + try (HttpResponse response = HttpRequest.get(url) + .form(paramMap) + .execute()) { + if (!response.isOk()) { + log.error("{}:{}", errorMsg, response.getStatus()); + throw new ServiceException(errorMsg + response.getStatus()); + } + String body = response.body(); + if (body == null) { + log.error("{}:{}", errorMsg, "返回参数为空"); + } + log.info("斯巴达 Token 请求成功:{}", body); + JSONObject jsonObject = JSONUtil.parseObj(body); + SpartaTokenVo tokenVo = new SpartaTokenVo(); + tokenVo.setToken(jsonObject.get("token", String.class)); + tokenVo.setExpiresAt(jsonObject.get("expires_at", Long.class)); + return tokenVo; + } + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/vo/SpartaResponseVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/vo/SpartaResponseVo.java new file mode 100644 index 00000000..8d5712f9 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/vo/SpartaResponseVo.java @@ -0,0 +1,27 @@ +package org.dromara.manager.spartamanager.vo; + +import lombok.Data; + +/** + * @author lcj + * @date 2025/6/20 19:25 + */ +@Data +public class SpartaResponseVo { + + /** + * 响应码 + */ + private String code; + + /** + * 响应数据 + */ + private String data; + + /** + * 响应信息 + */ + private String msg; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/vo/SpartaTokenVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/vo/SpartaTokenVo.java new file mode 100644 index 00000000..318e9230 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/spartamanager/vo/SpartaTokenVo.java @@ -0,0 +1,21 @@ +package org.dromara.manager.spartamanager.vo; + +import lombok.Data; + +/** + * @author lcj + * @date 2025/6/20 19:36 + */ +@Data +public class SpartaTokenVo { + + /** + * token + */ + private String token; + + /** + * 过期时间 + */ + private Long expiresAt; +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7Manager.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7Manager.java index 3c3f3734..3d3f5166 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7Manager.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/manager/ys7manager/Ys7Manager.java @@ -54,11 +54,11 @@ public class Ys7Manager { */ public String getToken() { String tokenRedisKey = Ys7Constant.TOKEN_REDIS_KEY; - String token = stringRedisTemplate.opsForValue().get(tokenRedisKey); - // 不为空,直接返回 token - if (token != null) { - return token; - } + String token = stringRedisTemplate.opsForValue().get(tokenRedisKey); + // 不为空,直接返回 token + if (token != null) { + return token; + } // 向云服务商请求新的 token String newToken = Ys7RequestUtils.getToken(ys7Properties.getAppKey(), ys7Properties.getAppSecret()); // 设置有效期 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 d0a3c3a8..ab974d75 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 @@ -45,7 +45,7 @@ public class Ys7RequestUtils { String body = response.body(); Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class); if (!responseVo.getCode().equals("200")) { - log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); throw new ServiceException(errorMsg + responseVo.getMsg()); } log.info("Ys7 Token 请求成功:{}", body); @@ -85,7 +85,7 @@ public class Ys7RequestUtils { String body = response.body(); Ys7PageResponseVo responseVo = JSONUtil.toBean(body, Ys7PageResponseVo.class); if (!responseVo.getCode().equals("200")) { - log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); throw new ServiceException(errorMsg + responseVo.getMsg()); } log.info("Ys7 分页查询设备列表 第{}页大小{} 响应数据:{}", pageStart, pageSize, responseVo.getData()); @@ -127,7 +127,7 @@ public class Ys7RequestUtils { String body = response.body(); Ys7NoDataResponseVo responseVo = JSONUtil.toBean(body, Ys7NoDataResponseVo.class); if (!responseVo.getCode().equals("200")) { - log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); throw new ServiceException(errorMsg + responseVo.getMsg()); } log.info("修改设备名称请求成功,设备 {} 名称修改为 {}", deviceSerial, deviceName); @@ -162,7 +162,7 @@ public class Ys7RequestUtils { String body = response.body(); Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class); if (!responseVo.getCode().equals("200")) { - log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); throw new ServiceException(errorMsg + responseVo.getMsg()); } // 获取 data 中的 index @@ -204,7 +204,7 @@ public class Ys7RequestUtils { String body = response.body(); Ys7NoDataResponseVo responseVo = JSONUtil.toBean(body, Ys7NoDataResponseVo.class); if (!responseVo.getCode().equals("200")) { - log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); throw new ServiceException(errorMsg + responseVo.getMsg()); } log.info("调用设备预置点请求成功,设备 {} 调用预置点成功,通道:{},序号 {}", deviceSerial, channelNo, index); @@ -241,7 +241,7 @@ public class Ys7RequestUtils { String body = response.body(); Ys7NoDataResponseVo responseVo = JSONUtil.toBean(body, Ys7NoDataResponseVo.class); if (!responseVo.getCode().equals("200")) { - log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); throw new ServiceException(errorMsg + responseVo.getMsg()); } log.info("删除设备预置点请求成功,设备 {} 删除预置点成功,通道:{},序号 {}", deviceSerial, channelNo, index); @@ -281,7 +281,7 @@ public class Ys7RequestUtils { String body = response.body(); Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class); if (!responseVo.getCode().equals("200")) { - log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); + log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg()); throw new ServiceException(errorMsg + responseVo.getMsg()); } String data = responseVo.getData(); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7deviceimg/OthYs7DeviceImgCreateByCapture.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7deviceimg/OthYs7DeviceImgCreateByCapture.java index 76d51e52..b02916ac 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7deviceimg/OthYs7DeviceImgCreateByCapture.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/domain/dto/ys7deviceimg/OthYs7DeviceImgCreateByCapture.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.util.Date; /** * @author lcj @@ -30,4 +31,9 @@ public class OthYs7DeviceImgCreateByCapture implements Serializable { */ private String url; + /** + * 图片创建时间 + */ + private Date createTime; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceImgServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceImgServiceImpl.java index 0839f925..ea760bbb 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceImgServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/other/service/impl/OthYs7DeviceImgServiceImpl.java @@ -174,6 +174,7 @@ public class OthYs7DeviceImgServiceImpl extends ServiceImpl list(HseViolationLevelQueryReq req, PageQuery pageQuery) { + return hseViolationLevelService.queryPageList(req, pageQuery); + } + + /** + * 导出违章等级列表 + */ + @SaCheckPermission("safety:violationLevel:export") + @Log(title = "违章等级", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HseViolationLevelQueryReq req, HttpServletResponse response) { + List list = hseViolationLevelService.queryList(req); + ExcelUtil.exportExcel(list, "违章等级", HseViolationLevelVo.class, response); + } + + /** + * 获取违章等级详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("safety:violationLevel:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(hseViolationLevelService.queryById(id)); + } + + /** + * 新增违章等级 + */ + @SaCheckPermission("safety:violationLevel:add") + @Log(title = "违章等级", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated @RequestBody HseViolationLevelCreateReq req) { + return R.ok(hseViolationLevelService.insertByBo(req)); + } + + /** + * 修改违章等级 + */ + @SaCheckPermission("safety:violationLevel:edit") + @Log(title = "违章等级", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated @RequestBody HseViolationLevelUpdateReq req) { + return toAjax(hseViolationLevelService.updateByBo(req)); + } + + /** + * 删除违章等级 + * + * @param ids 主键串 + */ + @SaCheckPermission("safety:violationLevel:remove") + @Log(title = "违章等级", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(hseViolationLevelService.deleteWithValidByIds(List.of(ids), true)); + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HseViolationLevel.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HseViolationLevel.java new file mode 100644 index 00000000..eeacd8ab --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HseViolationLevel.java @@ -0,0 +1,56 @@ +package org.dromara.safety.domain; + +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; + +/** + * 违章等级对象 hse_violation_level + * + * @author lcj + * @date 2025-06-20 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hse_violation_level") +public class HseViolationLevel extends BaseEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + @TableId(value = "id") + private Long id; + + /** + * 项目id + */ + private Long projectId; + + /** + * 违章等级 + */ + private String violationLevel; + + /** + * 颜色 + */ + private String color; + + /** + * 风险等级 + */ + private String riskType; + + /** + * 违章类型(多个逗号分隔) + */ + private String violationType; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HseViolationLevelPost.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HseViolationLevelPost.java new file mode 100644 index 00000000..b400ba5e --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/HseViolationLevelPost.java @@ -0,0 +1,35 @@ +package org.dromara.safety.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 等级与岗位关联对象 hse_violation_level_post + * + * @author lcj + * @date 2025-06-20 + */ +@Data +@TableName("hse_violation_level_post") +public class HseViolationLevelPost implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 等级 + */ + @TableId(type = IdType.INPUT) + private Long level; + + /** + * 岗位 + */ + private Long post; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelCreateReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelCreateReq.java new file mode 100644 index 00000000..ed918eb0 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelCreateReq.java @@ -0,0 +1,53 @@ +package org.dromara.safety.domain.dto.violationlevel; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +/** + * @author lcj + * @date 2025/6/20 11:17 + */ +@Data +public class HseViolationLevelCreateReq implements Serializable { + + @Serial + private static final long serialVersionUID = -4225755294412571262L; + + /** + * 项目id + */ + @NotNull(message = "项目id不能为空") + private Long projectId; + + /** + * 违章等级 + */ + @NotNull(message = "违章等级不能为空") + private String violationLevel; + + /** + * 颜色 + */ + private String color; + + /** + * 风险等级 + */ + private String riskType; + + /** + * 岗位 + */ + @NotNull(message = "岗位不能为空") + private List postIdList; + + /** + * 违章类型(多个逗号分隔) + */ + private String violationType; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelQueryReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelQueryReq.java new file mode 100644 index 00000000..9650734b --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelQueryReq.java @@ -0,0 +1,38 @@ +package org.dromara.safety.domain.dto.violationlevel; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author lcj + * @date 2025/6/20 11:17 + */ +@Data +public class HseViolationLevelQueryReq implements Serializable { + + @Serial + private static final long serialVersionUID = -988722207116292047L; + + /** + * 项目id + */ + private Long projectId; + + /** + * 违章等级 + */ + private String violationLevel; + + /** + * 风险等级 + */ + private String riskType; + + /** + * 违章类型(多个逗号分隔) + */ + private String violationType; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelUpdateReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelUpdateReq.java new file mode 100644 index 00000000..1b02a71f --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/dto/violationlevel/HseViolationLevelUpdateReq.java @@ -0,0 +1,51 @@ +package org.dromara.safety.domain.dto.violationlevel; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +/** + * @author lcj + * @date 2025/6/20 11:18 + */ +@Data +public class HseViolationLevelUpdateReq implements Serializable { + + @Serial + private static final long serialVersionUID = -5859829053886378192L; + + /** + * 主键id + */ + @NotNull(message = "主键id不能为空") + private Long id; + + /** + * 违章等级 + */ + private String violationLevel; + + /** + * 颜色 + */ + private String color; + + /** + * 风险等级 + */ + private String riskType; + + /** + * 岗位 + */ + private List postIdList; + + /** + * 违章类型(多个逗号分隔) + */ + private String violationType; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevel/HseViolationLevelByPostVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevel/HseViolationLevelByPostVo.java new file mode 100644 index 00000000..3f40faab --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevel/HseViolationLevelByPostVo.java @@ -0,0 +1,61 @@ +package org.dromara.safety.domain.vo.violationlevel; + +import lombok.Data; +import org.dromara.system.domain.vo.SysPostVo; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @author lcj + * @date 2025/6/20 14:22 + */ +@Data +public class HseViolationLevelByPostVo implements Serializable { + + @Serial + private static final long serialVersionUID = -5927532440663249467L; + + /** + * 主键id + */ + private Long id; + + /** + * 项目id + */ + private Long projectId; + + /** + * 违章等级 + */ + private String violationLevel; + + /** + * 颜色 + */ + private String color; + + /** + * 风险等级 + */ + private String riskType; + + /** + * 违章类型(多个逗号分隔) + */ + private String violationType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 岗位 + */ + private List postList; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevel/HseViolationLevelVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevel/HseViolationLevelVo.java new file mode 100644 index 00000000..f552035b --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevel/HseViolationLevelVo.java @@ -0,0 +1,74 @@ +package org.dromara.safety.domain.vo.violationlevel; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; +import org.dromara.safety.domain.HseViolationLevel; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + +/** + * 违章等级视图对象 hse_violation_level + * + * @author lcj + * @date 2025-06-20 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = HseViolationLevel.class) +public class HseViolationLevelVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + @ExcelProperty(value = "主键id") + private Long id; + + /** + * 项目id + */ + @ExcelProperty(value = "项目id") + private Long projectId; + + /** + * 违章等级 + */ + @ExcelProperty(value = "违章等级") + private String violationLevel; + + /** + * 颜色 + */ + @ExcelProperty(value = "颜色") + private String color; + + /** + * 风险等级 + */ + @ExcelProperty(value = "风险等级", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "risk_level_type") + private String riskType; + + /** + * 违章类型(多个逗号分隔) + */ + @ExcelProperty(value = "违章类型", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "violation_level_type") + private String violationType; + + /** + * 创建时间 + */ + @ExcelProperty(value = "创建时间") + private Date createTime; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevelpost/HseViolationLevelPostVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevelpost/HseViolationLevelPostVo.java new file mode 100644 index 00000000..da473369 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/domain/vo/violationlevelpost/HseViolationLevelPostVo.java @@ -0,0 +1,39 @@ +package org.dromara.safety.domain.vo.violationlevelpost; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import org.dromara.safety.domain.HseViolationLevelPost; + +import java.io.Serial; +import java.io.Serializable; + + +/** + * 等级与岗位关联视图对象 hse_violation_level_post + * + * @author lcj + * @date 2025-06-20 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = HseViolationLevelPost.class) +public class HseViolationLevelPostVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 等级 + */ + @ExcelProperty(value = "等级") + private Long level; + + /** + * 岗位 + */ + @ExcelProperty(value = "岗位") + private Long post; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HseViolationLevelMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HseViolationLevelMapper.java new file mode 100644 index 00000000..2c059a1c --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HseViolationLevelMapper.java @@ -0,0 +1,15 @@ +package org.dromara.safety.mapper; + +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.dromara.safety.domain.HseViolationLevel; +import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelVo; + +/** + * 违章等级Mapper接口 + * + * @author lcj + * @date 2025-06-20 + */ +public interface HseViolationLevelMapper extends BaseMapperPlus { + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HseViolationLevelPostMapper.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HseViolationLevelPostMapper.java new file mode 100644 index 00000000..de58dac1 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/mapper/HseViolationLevelPostMapper.java @@ -0,0 +1,15 @@ +package org.dromara.safety.mapper; + +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.dromara.safety.domain.HseViolationLevelPost; +import org.dromara.safety.domain.vo.violationlevelpost.HseViolationLevelPostVo; + +/** + * 等级与岗位关联Mapper接口 + * + * @author lcj + * @date 2025-06-20 + */ +public interface HseViolationLevelPostMapper extends BaseMapperPlus { + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHseViolationLevelPostService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHseViolationLevelPostService.java new file mode 100644 index 00000000..ef4a5186 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHseViolationLevelPostService.java @@ -0,0 +1,13 @@ +package org.dromara.safety.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.dromara.safety.domain.HseViolationLevelPost; + +/** + * 等级与岗位关联Service接口 + * + * @author lcj + * @date 2025-06-20 + */ +public interface IHseViolationLevelPostService extends IService { +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHseViolationLevelService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHseViolationLevelService.java new file mode 100644 index 00000000..4cd79d87 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/IHseViolationLevelService.java @@ -0,0 +1,100 @@ +package org.dromara.safety.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.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.safety.domain.HseViolationLevel; +import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelCreateReq; +import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelQueryReq; +import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelUpdateReq; +import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelByPostVo; +import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelVo; + +import java.util.Collection; +import java.util.List; + +/** + * 违章等级Service接口 + * + * @author lcj + * @date 2025-06-20 + */ +public interface IHseViolationLevelService extends IService { + + /** + * 查询违章等级 + * + * @param id 主键 + * @return 违章等级 + */ + HseViolationLevelByPostVo queryById(Long id); + + /** + * 分页查询违章等级列表 + * + * @param req 查询条件 + * @param pageQuery 分页参数 + * @return 违章等级分页列表 + */ + TableDataInfo queryPageList(HseViolationLevelQueryReq req, PageQuery pageQuery); + + /** + * 查询符合条件的违章等级列表 + * + * @param req 查询条件 + * @return 违章等级列表 + */ + List queryList(HseViolationLevelQueryReq req); + + /** + * 新增违章等级 + * + * @param req 违章等级 + * @return 新增违章等级主键id + */ + Long insertByBo(HseViolationLevelCreateReq req); + + /** + * 修改违章等级 + * + * @param req 违章等级 + * @return 是否修改成功 + */ + Boolean updateByBo(HseViolationLevelUpdateReq req); + + /** + * 校验并批量删除违章等级信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * 获取违章等级视图对象 + * + * @param violationLevel 违章等级对象 + * @return 违章等级视图对象 + */ + HseViolationLevelByPostVo getVo(HseViolationLevel violationLevel); + + /** + * 获取违章等级查询条件封装 + * + * @param req 违章等级查询条件 + * @return 违章等级查询条件封装 + */ + LambdaQueryWrapper buildQueryWrapper(HseViolationLevelQueryReq req); + + /** + * 获取违章等级分页对象视图 + * + * @param violationLevelPage 违章等级分页对象 + * @return 违章等级分页对象视图 + */ + Page getVoPage(Page violationLevelPage); + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseViolationLevelPostServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseViolationLevelPostServiceImpl.java new file mode 100644 index 00000000..7206894b --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseViolationLevelPostServiceImpl.java @@ -0,0 +1,19 @@ +package org.dromara.safety.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.dromara.safety.domain.HseViolationLevelPost; +import org.dromara.safety.mapper.HseViolationLevelPostMapper; +import org.dromara.safety.service.IHseViolationLevelPostService; +import org.springframework.stereotype.Service; + +/** + * 等级与岗位关联Service业务层处理 + * + * @author lcj + * @date 2025-06-20 + */ +@Service +public class HseViolationLevelPostServiceImpl extends ServiceImpl + implements IHseViolationLevelPostService { + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseViolationLevelServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseViolationLevelServiceImpl.java new file mode 100644 index 00000000..4c67c1a1 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseViolationLevelServiceImpl.java @@ -0,0 +1,316 @@ +package org.dromara.safety.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import jakarta.annotation.Resource; +import org.dromara.common.core.constant.HttpStatus; +import org.dromara.common.core.exception.ServiceException; +import org.dromara.common.core.utils.ObjectUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.satoken.utils.LoginHelper; +import org.dromara.project.service.IBusProjectService; +import org.dromara.safety.domain.HseViolationLevel; +import org.dromara.safety.domain.HseViolationLevelPost; +import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelCreateReq; +import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelQueryReq; +import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelUpdateReq; +import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelByPostVo; +import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelVo; +import org.dromara.safety.mapper.HseViolationLevelMapper; +import org.dromara.safety.service.IHseViolationLevelPostService; +import org.dromara.safety.service.IHseViolationLevelService; +import org.dromara.system.domain.vo.SysPostVo; +import org.dromara.system.service.ISysPostService; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * 违章等级Service业务层处理 + * + * @author lcj + * @date 2025-06-20 + */ +@Service +public class HseViolationLevelServiceImpl extends ServiceImpl + implements IHseViolationLevelService { + + @Resource + private IBusProjectService projectService; + + @Resource + private IHseViolationLevelPostService violationLevelPostService; + + @Resource + private ISysPostService postService; + + /** + * 查询违章等级 + * + * @param id 主键 + * @return 违章等级 + */ + @Override + public HseViolationLevelByPostVo queryById(Long id) { + HseViolationLevel violationLevel = this.getById(id); + if (violationLevel == null) { + throw new ServiceException("违章等级信息不存在", HttpStatus.NOT_FOUND); + } + return this.getVo(violationLevel); + } + + /** + * 分页查询违章等级列表 + * + * @param req 查询条件 + * @param pageQuery 分页参数 + * @return 违章等级分页列表 + */ + @Override + public TableDataInfo queryPageList(HseViolationLevelQueryReq req, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(req); + Page result = this.page(pageQuery.build(), lqw); + return TableDataInfo.build(this.getVoPage(result)); + } + + /** + * 查询符合条件的违章等级列表 + * + * @param req 查询条件 + * @return 违章等级列表 + */ + @Override + public List queryList(HseViolationLevelQueryReq req) { + LambdaQueryWrapper lqw = buildQueryWrapper(req); + return this.list(lqw).stream().map(violationLevel -> { + HseViolationLevelVo vo = new HseViolationLevelVo(); + BeanUtils.copyProperties(violationLevel, vo); + return vo; + }).toList(); + } + + /** + * 新增违章等级 + * + * @param req 违章等级 + * @return 新增违章等级主键id + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Long insertByBo(HseViolationLevelCreateReq req) { + HseViolationLevel violationLevel = new HseViolationLevel(); + BeanUtils.copyProperties(req, violationLevel); + // 校验参数 + validEntityBeforeSave(violationLevel, true); + List postIdList = req.getPostIdList(); + if (CollUtil.isEmpty(postIdList)) { + throw new ServiceException("岗位不能为空", HttpStatus.BAD_REQUEST); + } + // 判断违章等级是否存在 + Long count = this.lambdaQuery() + .eq(HseViolationLevel::getViolationLevel, violationLevel) + .count(); + if (count > 0) { + throw new ServiceException("违章等级已存在", HttpStatus.BAD_REQUEST); + } + boolean result = this.save(violationLevel); + if (!result) { + throw new ServiceException("新增违章等级失败", HttpStatus.ERROR); + } + Long id = violationLevel.getId(); + // 新增岗位与违章等级关联 + List postList = postIdList.stream().map(postId -> { + HseViolationLevelPost violationLevelPost = new HseViolationLevelPost(); + violationLevelPost.setLevel(id); + violationLevelPost.setPost(postId); + return violationLevelPost; + }).toList(); + boolean saveRelevancy = violationLevelPostService.saveBatch(postList); + if (!saveRelevancy) { + throw new ServiceException("新增岗位与违章等级关联失败,数据库异常", HttpStatus.ERROR); + } + return id; + } + + /** + * 修改违章等级 + * + * @param req 违章等级 + * @return 是否修改成功 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean updateByBo(HseViolationLevelUpdateReq req) { + HseViolationLevel violationLevel = new HseViolationLevel(); + BeanUtils.copyProperties(req, violationLevel); + validEntityBeforeSave(violationLevel, false); + Long id = req.getId(); + HseViolationLevel oldViolationLevel = this.getById(id); + if (oldViolationLevel == null) { + throw new ServiceException("修改的违章等级信息不存在", HttpStatus.NOT_FOUND); + } + List postIdList = req.getPostIdList(); + if (CollUtil.isNotEmpty(postIdList)) { + List oldPostIdList = violationLevelPostService.lambdaQuery() + .eq(HseViolationLevelPost::getLevel, id) + .select(HseViolationLevelPost::getPost) + .list().stream().map(HseViolationLevelPost::getPost).toList(); + // 转换为 Set + Set newSet = new HashSet<>(postIdList); + Set oldSet = new HashSet<>(oldPostIdList); + // 需要添加的岗位ID(在 new 中有,但在 old 中没有) + Set needAdd = new HashSet<>(newSet); + needAdd.removeAll(oldSet); + // 需要删除的岗位ID(在 old 中有,但在 new 中没有) + Set needDelete = new HashSet<>(oldSet); + needDelete.removeAll(newSet); + // 执行新增 + if (CollUtil.isNotEmpty(needAdd)) { + List addList = needAdd.stream().map(postId -> { + HseViolationLevelPost item = new HseViolationLevelPost(); + item.setLevel(id); + item.setPost(postId); + return item; + }).toList(); + boolean result = violationLevelPostService.saveBatch(addList); + if (!result) { + throw new ServiceException("新增岗位与违章等级关联失败,数据库异常", HttpStatus.ERROR); + } + } + // 执行删除 + if (CollUtil.isNotEmpty(needDelete)) { + boolean remove = violationLevelPostService.lambdaUpdate() + .eq(HseViolationLevelPost::getLevel, id) + .in(HseViolationLevelPost::getPost, needDelete) + .remove(); + if (!remove) { + throw new ServiceException("删除岗位与违章等级关联失败,数据库异常", HttpStatus.ERROR); + } + } + } + boolean result = this.updateById(violationLevel); + if (!result) { + throw new ServiceException("修改违章等级失败", HttpStatus.ERROR); + } + return true; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(HseViolationLevel entity, Boolean create) { + //TODO 做一些数据校验,如唯一约束 + Long projectId = entity.getProjectId(); + String violationLevel = entity.getViolationLevel(); + if (create) { + if (projectId == null) { + throw new ServiceException("项目id不能为空", HttpStatus.BAD_REQUEST); + } + if (StringUtils.isEmpty(violationLevel)) { + throw new ServiceException("违章等级不能为空", HttpStatus.BAD_REQUEST); + } + } + if (projectId != null && projectService.getById(projectId) == null) { + throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND); + } + } + + /** + * 校验并批量删除违章等级信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + Long userId = LoginHelper.getUserId(); + List violationLevelList = this.listByIds(ids); + if (isValid) { + // TODO 做一些业务上的校验,判断是否需要校验 + List projectIds = violationLevelList.stream().map(HseViolationLevel::getProjectId).distinct().toList(); + projectService.validAuth(projectIds, userId); + } + return this.removeBatchByIds(ids); + } + + /** + * 获取违章等级视图对象 + * + * @param violationLevel 违章等级对象 + * @return 违章等级视图对象 + */ + @Override + public HseViolationLevelByPostVo getVo(HseViolationLevel violationLevel) { + HseViolationLevelByPostVo vo = new HseViolationLevelByPostVo(); + if (violationLevel == null) { + return vo; + } + BeanUtils.copyProperties(violationLevel, vo); + List levelPostList = violationLevelPostService.lambdaQuery() + .eq(HseViolationLevelPost::getLevel, violationLevel.getId()) + .list(); + if (CollUtil.isNotEmpty(levelPostList)) { + List postIdList = levelPostList.stream().map(HseViolationLevelPost::getPost).toList(); + List postList = postService.selectPostByIds(postIdList); + vo.setPostList(postList); + } + return vo; + } + + /** + * 获取违章等级查询条件封装 + * + * @param req 违章等级查询条件 + * @return 违章等级查询条件封装 + */ + @Override + public LambdaQueryWrapper buildQueryWrapper(HseViolationLevelQueryReq req) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + Long projectId = req.getProjectId(); + String violationLevel = req.getViolationLevel(); + String riskType = req.getRiskType(); + String violationType = req.getViolationType(); + lqw.eq(ObjectUtils.isNotEmpty(projectId), HseViolationLevel::getProjectId, projectId); + lqw.like(StringUtils.isNotBlank(violationLevel), HseViolationLevel::getViolationLevel, violationLevel); + lqw.eq(StringUtils.isNotBlank(riskType), HseViolationLevel::getRiskType, riskType); + // todo + lqw.eq(StringUtils.isNotBlank(violationType), HseViolationLevel::getViolationType, violationType); + return lqw; + } + + /** + * 获取违章等级分页对象视图 + * + * @param violationLevelPage 违章等级分页对象 + * @return 违章等级分页对象视图 + */ + @Override + public Page getVoPage(Page violationLevelPage) { + List violationLevelList = violationLevelPage.getRecords(); + Page violationLevelVoPage = new Page<>( + violationLevelPage.getCurrent(), + violationLevelPage.getSize(), + violationLevelPage.getTotal()); + if (CollUtil.isEmpty(violationLevelList)) { + return violationLevelVoPage; + } + List violationLevelVoList = violationLevelList.stream().map(violationLevel -> { + HseViolationLevelVo vo = new HseViolationLevelVo(); + BeanUtils.copyProperties(violationLevel, vo); + return vo; + }).toList(); + violationLevelVoPage.setRecords(violationLevelVoList); + return violationLevelVoPage; + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HseViolationLevelMapper.xml b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HseViolationLevelMapper.xml new file mode 100644 index 00000000..6bfe818a --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HseViolationLevelMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HseViolationLevelPostMapper.xml b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HseViolationLevelPostMapper.xml new file mode 100644 index 00000000..30d8624f --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/resources/mapper/safety/HseViolationLevelPostMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/xinnengyuan/script/sql/menuInitValue.sql b/xinnengyuan/script/sql/menuInitValue.sql index 742e66ea..dbf18dfe 100644 --- a/xinnengyuan/script/sql/menuInitValue.sql +++ b/xinnengyuan/script/sql/menuInitValue.sql @@ -557,3 +557,43 @@ values(1935231471757307910, '萤石摄像头图片删除', 1935231471757307906, insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) values(1935231471757307911, '萤石摄像头图片导出', 1935231471757307906, '5', '#', '', 1, 0, 'F', '0', '0', 'other:ys7DeviceImg:export', '#', 103, 1, sysdate(), null, null, ''); + +-- 菜单 SQL +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935896590929661954, '违章等级', '1935597155897143297', '1', 'violationLevel', 'safety/violationLevel/index', 1, 0, 'C', '0', '0', 'safety:violationLevel:list', '#', 103, 1, sysdate(), null, null, '违章等级菜单'); + +-- 按钮 SQL +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935896590929661955, '违章等级查询', 1935896590929661954, '1', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:query', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935896590929661956, '违章等级新增', 1935896590929661954, '2', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:add', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935896590929661957, '违章等级修改', 1935896590929661954, '3', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:edit', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935896590929661958, '违章等级删除', 1935896590929661954, '4', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:remove', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935896590929661959, '违章等级导出', 1935896590929661954, '5', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:export', '#', 103, 1, sysdate(), null, null, ''); + +-- 菜单 SQL +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935909171354439681, '等级与岗位关联', '1935896590929661954', '1', 'violationLevelPost', 'safety/violationLevelPost/index', 1, 0, 'C', '0', '0', 'safety:violationLevelPost:list', '#', 103, 1, sysdate(), null, null, '等级与岗位关联菜单'); + +-- 按钮 SQL +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935909171354439682, '等级与岗位关联查询', 1935909171354439681, '1', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:query', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935909171354439683, '等级与岗位关联新增', 1935909171354439681, '2', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:add', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935909171354439684, '等级与岗位关联修改', 1935909171354439681, '3', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:edit', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935909171354439685, '等级与岗位关联删除', 1935909171354439681, '4', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:remove', '#', 103, 1, sysdate(), null, null, ''); + +insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) +values(1935909171354439686, '等级与岗位关联导出', 1935909171354439681, '5', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:export', '#', 103, 1, sysdate(), null, null, ''); diff --git a/xinnengyuan/script/sql/xinnengyuan.sql b/xinnengyuan/script/sql/xinnengyuan.sql index d29e03a9..980c8280 100644 --- a/xinnengyuan/script/sql/xinnengyuan.sql +++ b/xinnengyuan/script/sql/xinnengyuan.sql @@ -1136,3 +1136,11 @@ CREATE TABLE `hse_violation_level` primary key (`id`) using btree, index `idx_project_id` (`project_id` asc) using btree comment '项目id' ) comment = '违章等级' collate = utf8mb4_unicode_ci; + +DROP TABLE IF EXISTS `hse_violation_level_post`; +CREATE TABLE `hse_violation_level_post` +( + `level` bigint not null comment '等级', + `post` bigint not null comment '岗位', + primary key (`level`, `post`) using btree +) comment = '等级与岗位关联' collate = utf8mb4_unicode_ci;