From bfdb42b0c871e08062464d44d58fc5c65c44ee06 Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期三, 19 三月 2025 10:22:42 +0800 Subject: [PATCH] 预测数据接口 --- /dev/null | 82 -------------------- ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java | 4 ansteel-biz/src/main/resources/application-dev.yaml | 19 +--- ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java | 17 --- ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java | 1 pom.xml | 38 +++----- ansteel-biz/pom.xml | 37 +++----- ansteel-biz/src/main/resources/application.yaml | 5 8 files changed, 43 insertions(+), 160 deletions(-) diff --git a/ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java b/ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java index 3082460..5775b20 100644 --- a/ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java +++ b/ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java @@ -4,7 +4,6 @@ import com.iailab.module.api.mcs.dto.PreDataChartRespVO; import com.iailab.module.enums.ApiConstants; import com.iailab.module.model.api.mcs.dto.PreDataSingleChartReqVO; -import com.iailab.module.model.api.mcs.dto.PreDataSingleChartRespVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.cloud.openfeign.FeignClient; diff --git a/ansteel-biz/pom.xml b/ansteel-biz/pom.xml index c172627..f696ba6 100644 --- a/ansteel-biz/pom.xml +++ b/ansteel-biz/pom.xml @@ -118,34 +118,27 @@ <dependency> <groupId>com.iailab</groupId> - <artifactId>iailab-common-mq</artifactId> - </dependency> - <dependency> - <groupId>com.iailab</groupId> <artifactId>ansteel-api</artifactId> <version>1.0.0</version> </dependency> - </dependencies> <build> - <!-- 设置构建的 jar 包名 --> - <finalName>${project.artifactId}</finalName> - <plugins> - <!-- 打包 --> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring.boot.version}</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> <!-- 将引入的 jar 打入其中 --> - </goals> - </execution> - </executions> - </plugin> - </plugins> + <pluginManagement> + <plugins> + <!-- maven-surefire-plugin 插件,用于运行单元测试。 --> + <!-- 注意,需要使用 3.0.X+,因为要支持 Junit 5 版本 --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${maven-surefire-plugin.version}</version> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <!-- maven-compiler-plugin 插件,解决 Lombok + MapStruct 组合 --> + </plugins> + </pluginManagement> </build> </project> diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java index 8cb1be3..1610651 100644 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java @@ -99,9 +99,7 @@ return null; } String resultIndex = tMap.get(CommonConstant.RESULT_INDEX); - if (resultIndex == null) { - return null; - } + PredictItemVO predictItem = mcsApi.getPredictItemByItemNo(itemCode); if (predictItem == null || predictItem.getLastTime() == null) { return null; diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java index 650a9f5..d2b2f45 100644 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java @@ -1,21 +1,14 @@ package com.iailab.module.ansteel.api.controller; import com.iailab.framework.common.pojo.CommonResult; -import com.iailab.module.ansteel.util.ApiSecurityUtils; import com.iailab.module.api.mcs.AnSteelApi; import com.iailab.module.api.mcs.dto.PowerRunStateDTO; import com.iailab.module.api.mcs.dto.PreDataChartRespVO; -import com.iailab.module.model.api.mcs.dto.PreDataItemChartReqVO; -import com.iailab.module.model.api.mcs.dto.PreDataItemChartRespVO; import com.iailab.module.model.api.mcs.dto.PreDataSingleChartReqVO; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -25,7 +18,6 @@ * @author: lirm * @date: 2025/03/17 **/ -@Tag(name = "发电厂机组运行情况") @RestController @RequestMapping("/ansteel/api/mcs") public class McsController { @@ -33,19 +25,16 @@ @Autowired private AnSteelApi anSteelApi; - @Resource - private ApiSecurityUtils apiSecurityUtils; - @GetMapping("/power-run-state/list") - public CommonResult<List<PowerRunStateDTO>> list(@RequestParam Map<String, Object> params) { + @Operation(summary = "发电厂机组运行情况") + public CommonResult<List<PowerRunStateDTO>> getPowerRunState(@RequestParam Map<String, Object> params) { List<PowerRunStateDTO> list = anSteelApi.getPowerRunState(); return success(list); } @PostMapping("/predict-data/charts") @Operation(summary = "预测数据图表") - public CommonResult<PreDataChartRespVO> getPreDataChart(HttpServletResponse response, HttpServletRequest request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception { - apiSecurityUtils.validate(request); + public CommonResult<PreDataChartRespVO> getPreDataChart(@RequestBody PreDataSingleChartReqVO reqVO) { PreDataChartRespVO respVO = anSteelApi.getPreDataChart(reqVO); return CommonResult.success(respVO); } diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/util/ApiSecurityUtils.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/util/ApiSecurityUtils.java deleted file mode 100644 index b1bf747..0000000 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/util/ApiSecurityUtils.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.iailab.module.ansteel.util; - - -import com.iailab.framework.common.constant.Constant; -import com.iailab.framework.tenant.core.context.TenantContextHolder; -import com.iailab.module.system.api.user.AdminUserApi; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.regex.Pattern; - -/** - * @author PanZhibao - * @Description - * @createTime 2023年12月06日 15:55:00 - */ -@Component -public class ApiSecurityUtils { - - /*@Resource - private ApiAppService apiAppService;*/ - - @Resource - private AdminUserApi adminUserApi; - - private Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); - - private String getRequestToken(HttpServletRequest httpRequest) { - //从header中获取token - String token = httpRequest.getHeader(Constant.TOKEN_HEADER); - - //如果header中不存在token,则从参数中获取token - if (StringUtils.isBlank(token)) { - token = httpRequest.getParameter(Constant.TOKEN_HEADER); - } - - return token; - } - - private void setTenantId(HttpServletRequest httpRequest) { - String tenantId = httpRequest.getHeader(Constant.HEAD_TENANT_ID); - - if (StringUtils.isNotBlank(tenantId)) { - TenantContextHolder.setTenantId(Long.parseLong(tenantId)); - } - } - - - public void validate(HttpServletRequest httpRequest) throws Exception { - setTenantId(httpRequest); - /*String token = getRequestToken(httpRequest); - if (StringUtils.isBlank(token)) { - throw new Exception("token 不能为空!"); - } - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - if (ObjectUtils.isEmpty(loginUser)) { - throw new RuntimeException("用户不能为空"); - } - CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(loginUser.getId()); - if(ObjectUtils.isEmpty(user)) { - throw new RuntimeException("用户不存在"); - } - AdminUserRespDTO userData = user.getData(); - String username = userData.getUsername();*/ - /*ApiAppEntity appInfo = apiAppService.getInfoByAppKey(username); - if (appInfo == null) { - throw new RuntimeException("应用未授权"); - }*/ - //TODO 验证签名 -// if(!com.iailab.common.utils.JwtUtils.verify(token, appInfo.getAppSecret())){ -// throw new RuntimeException("签名错误"); -// } - } - - private boolean isInteger(String str) { - return pattern.matcher(str).matches(); - } - - -} diff --git a/ansteel-biz/src/main/resources/application-dev.yaml b/ansteel-biz/src/main/resources/application-dev.yaml index a0c48de..ad9a6d7 100644 --- a/ansteel-biz/src/main/resources/application-dev.yaml +++ b/ansteel-biz/src/main/resources/application-dev.yaml @@ -35,21 +35,14 @@ primary: master datasource: master: - url: jdbc:mysql://172.16.8.100:3306/iailab_expert_tenant_ansteel?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + url: jdbc:mysql://172.16.8.100:3306/iailab_fast_tenant_ansteel?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 username: root password: 123456 slave: # 模拟从库,可根据自己需要修改 lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/iailab_expert_tenant_ansteel?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + url: jdbc:mysql://127.0.0.1:3306/iailab_fast_tenant_ansteel?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true username: root password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 172.16.8.100 # 地址 - port: 6379 # 端口 - database: 10 # 数据库索引 - password: 123456 # 密码,建议生产环境开启 --- #################### 平台相关配置 #################### @@ -65,9 +58,9 @@ enable: false token: base-url: http://127.0.0.1:48080/admin-api/system - tenant-id: 172 - client-id: shasteel - client-secret: shasteel111111111111111 - username: shasteel + tenant-id: 176 + client-id: ansteel + client-secret: ansteel111111111111111 + username: ansteel password: 123456 diff --git a/ansteel-biz/src/main/resources/application.yaml b/ansteel-biz/src/main/resources/application.yaml index 9d45e52..703867d 100644 --- a/ansteel-biz/src/main/resources/application.yaml +++ b/ansteel-biz/src/main/resources/application.yaml @@ -4,7 +4,7 @@ name: ansteel-server profiles: - active: prod + active: dev cloud: nacos: @@ -150,10 +150,11 @@ - qrtz_triggers - schedule_job - schedule_job_log + - t_power_run_state swagger: title: 选煤厂安全管理平台 description: 选煤厂安全管理平台 version: ${iailab.info.version} log-path: D:\DLUT\ansteel -debug: true +debug: false diff --git a/pom.xml b/pom.xml index 31d413a..1df6e42 100644 --- a/pom.xml +++ b/pom.xml @@ -154,12 +154,6 @@ <version>${revision}</version> </dependency> - <!-- 消息队列相关 --> - <dependency> - <groupId>com.iailab</groupId> - <artifactId>iailab-common-mq</artifactId> - <version>${revision}</version> - </dependency> <!-- Web 相关 --> <dependency> @@ -374,23 +368,21 @@ </dependencyManagement> <build> - <!-- 设置构建的 jar 包名 --> - <finalName>${project.artifactId}</finalName> - <plugins> - <!-- 打包 --> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring.boot.version}</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> <!-- 将引入的 jar 打入其中 --> - </goals> - </execution> - </executions> - </plugin> - </plugins> + <pluginManagement> + <plugins> + <!-- maven-surefire-plugin 插件,用于运行单元测试。 --> + <!-- 注意,需要使用 3.0.X+,因为要支持 Junit 5 版本 --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${maven-surefire-plugin.version}</version> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <!-- maven-compiler-plugin 插件,解决 Lombok + MapStruct 组合 --> + </plugins> + </pluginManagement> </build> -- Gitblit v1.9.3