数据贯通完成,规程重构

This commit is contained in:
2026-04-27 20:37:59 +08:00
parent 5b38ef734a
commit b7161e9541
13 changed files with 1492 additions and 861 deletions

View File

@@ -1,5 +1,6 @@
package com.klp.framework.client;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.klp.framework.config.SqlServerApiProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
@@ -73,7 +74,9 @@ public class SqlServerApiClient {
}
public static class TableSchemaRequest {
@JsonProperty("table_type")
private String tableType;
@JsonProperty("table_name")
private String tableName;
public TableSchemaRequest() {
@@ -102,6 +105,7 @@ public class SqlServerApiClient {
}
public static class ExecuteSqlRequest {
@JsonProperty("table_type")
private String tableType;
private String sql;
private Map<String, Object> params;
@@ -311,10 +315,23 @@ public class SqlServerApiClient {
);
}
public ExecuteSqlResponse queryPlanList() {
public ExecuteSqlResponse queryPlanList(int page, int pageSize) {
int endRow = page * pageSize;
int startRow = endRow - pageSize;
Map<String, Object> params = new java.util.HashMap<>();
params.put("startRow", startRow);
params.put("endRow", endRow);
return executeSql(
"oracle",
"select * from JXPLTCM.PLTCM_PDI_PLAN order by INSDATE desc",
"select * from (select t.*, ROWNUM rn from (select * from JXPLTCM.PLTCM_PDI_PLAN order by INSDATE desc) t where ROWNUM <= :endRow) where rn > :startRow",
params
);
}
public ExecuteSqlResponse queryPlanCount() {
return executeSql(
"oracle",
"select count(*) as total from JXPLTCM.PLTCM_PDI_PLAN",
emptyParams()
);
}

View File

@@ -17,7 +17,7 @@ public class SqlServerApiClientConfig {
public RestTemplate sqlServerApiRestTemplate(RestTemplateBuilder builder) {
return builder
.setConnectTimeout(Duration.ofSeconds(5))
.setReadTimeout(Duration.ofSeconds(30))
.setReadTimeout(Duration.ofSeconds(60))
.build();
}
}

View File

@@ -32,12 +32,24 @@ public class SqlServerApiBusinessService {
}
/**
* 计划列表:查询所有计划,按时间倒序
* <p>
* 这是后续按 coilId 关联 SEG、实时数据的入口。
* 计划列表分页按时间倒序page 从 1 开始
*/
public PlanListView getPlanList() {
return PlanListView.fromExecuteSqlResponse(client.queryPlanList());
public PlanListView getPlanList(int page, int pageSize) {
return PlanListView.fromExecuteSqlResponse(client.queryPlanList(page, pageSize));
}
/**
* 计划总数。
*/
public long getPlanCount() {
SqlServerApiClient.ExecuteSqlResponse resp = client.queryPlanCount();
List<Map<String, Object>> rows = asRowList(resp);
if (rows.isEmpty()) {
return 0L;
}
Object total = rows.get(0).get("total");
Number n = asNumber(total);
return n == null ? 0L : n.longValue();
}
/**

View File

@@ -1,4 +1,4 @@
package com.klp.web.controller.sqlserver;
package com.klp.framework.sqlserver;
import com.klp.common.core.domain.R;
import com.klp.framework.service.SqlServerApiBusinessService;
@@ -6,8 +6,12 @@ import lombok.RequiredArgsConstructor;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* sql-server-api 业务查询接口。
* <p>
@@ -21,11 +25,24 @@ public class SqlServerApiController {
private final SqlServerApiBusinessService businessService;
/**
* 计划列表。
* 计划列表(分页)
* page 从 1 开始,默认第 1 页,每页 20 条。
*/
@GetMapping("/plans")
public R<SqlServerApiBusinessService.PlanListView> planList() {
return R.ok(businessService.getPlanList());
public R<SqlServerApiBusinessService.PlanListView> planList(
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "20") int pageSize) {
return R.ok(businessService.getPlanList(page, pageSize));
}
/**
* 计划总数,用于前端分页器。
*/
@GetMapping("/plans/count")
public R<Map<String, Long>> planCount() {
Map<String, Long> result = new HashMap<>();
result.put("total", businessService.getPlanCount());
return R.ok(result);
}
/**

View File

@@ -7,6 +7,12 @@ klp:
# 开发环境文件存储目录
directory-path: testDirectory
--- # sql-server-api 中间件配置(开发/测试环境)
sql-server-api:
host: 140.143.206.120
port: 15000
base-url: http://${sql-server-api.host}:${sql-server-api.port}
--- # OEE 聚合klp-da多服务地址配置
da:
oee:

View File

@@ -7,6 +7,12 @@ klp:
# 生产环境文件存储目录
directory-path: /home/ubuntu/oa/folder
--- # sql-server-api 中间件配置(生产环境)
sql-server-api:
host: 192.168.0.219
port: 15000
base-url: http://${sql-server-api.host}:${sql-server-api.port}
--- # OEE 聚合klp-da多服务地址配置
da:
oee:

View File

@@ -66,14 +66,6 @@ user:
lockTime: 10
# sql-server-api 中间件配置
sql-server-api:
# 请求地址,请替换为实际 IP
host: 127.0.0.1
# 请求端口,请替换为实际端口
port: 8080
# 基础访问地址(可直接注入使用)
base-url: http://${sql-server-api.host}:${sql-server-api.port}
# Spring配置
spring:
application: