Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HYH.APSJ
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
佟礼
HYH.APSJ
Commits
96bd6495
Commit
96bd6495
authored
May 25, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
2841516f
05cc1a4d
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
47 deletions
+78
-47
SwaggerMapParamConfig.java
src/main/java/com/aps/config/SwaggerMapParamConfig.java
+1
-1
LanuchController.java
src/main/java/com/aps/controller/LanuchController.java
+3
-0
UserStrategyRuleController.java
...n/java/com/aps/controller/UserStrategyRuleController.java
+19
-17
ChromosomeDataController.java
...a/com/aps/controller/common/ChromosomeDataController.java
+3
-3
ResourceGanttController.java
...ava/com/aps/controller/gantt/ResourceGanttController.java
+4
-4
Paged.java
src/main/java/com/aps/entity/common/Paged.java
+1
-1
ChromosomeDataService.java
...in/java/com/aps/service/common/ChromosomeDataService.java
+6
-6
DatabaseQueryService.java
...ain/java/com/aps/service/common/DatabaseQueryService.java
+11
-9
UserStrategyRuleServiceImpl.java
...ava/com/aps/service/impl/UserStrategyRuleServiceImpl.java
+30
-6
No files found.
src/main/java/com/aps/config/SwaggerMapParamConfig.java
View file @
96bd6495
...
@@ -363,7 +363,7 @@ public class SwaggerMapParamConfig {
...
@@ -363,7 +363,7 @@ public class SwaggerMapParamConfig {
"带条件分页查询订单数据"
,
"带条件分页查询订单数据"
,
"{\n"
+
"{\n"
+
" \"sceneId\": \"SCENE001\",\n"
+
" \"sceneId\": \"SCENE001\",\n"
+
" \"pageIndex\":
0
,\n"
+
" \"pageIndex\":
1
,\n"
+
" \"pageSize\": 10,\n"
+
" \"pageSize\": 10,\n"
+
" \"conditions\": [\n"
+
" \"conditions\": [\n"
+
" {\n"
+
" {\n"
+
...
...
src/main/java/com/aps/controller/LanuchController.java
View file @
96bd6495
...
@@ -88,6 +88,9 @@ public class LanuchController {
...
@@ -88,6 +88,9 @@ public class LanuchController {
// 这些参数前端可以不传;不传时后端会根据 sceneId 找场景创建人,再查这个人的策略。
// 这些参数前端可以不传;不传时后端会根据 sceneId 找场景创建人,再查这个人的策略。
Long
userId
=
getLongParam
(
params
,
"userId"
);
Long
userId
=
getLongParam
(
params
,
"userId"
);
Long
baseRuleId
=
getLongParam
(
params
,
"baseRuleId"
);
Long
baseRuleId
=
getLongParam
(
params
,
"baseRuleId"
);
if
(
baseRuleId
==
null
)
{
baseRuleId
=
getLongParam
(
params
,
"ruleId"
);
}
if
(
baseRuleId
==
null
)
{
if
(
baseRuleId
==
null
)
{
baseRuleId
=
getLongParam
(
params
,
"referenceId"
);
baseRuleId
=
getLongParam
(
params
,
"referenceId"
);
}
}
...
...
src/main/java/com/aps/controller/UserStrategyRuleController.java
View file @
96bd6495
...
@@ -31,16 +31,16 @@ public class UserStrategyRuleController {
...
@@ -31,16 +31,16 @@ public class UserStrategyRuleController {
@Operation
(
@Operation
(
summary
=
"获取当前生效策略"
,
summary
=
"获取当前生效策略"
,
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
description
=
"
未传 userRuleId 时按 userId 获取用户最后保存的策略;旧的 USER:id 入参会被忽略。需要指定某条用户策略时传 userRuleId
。"
,
description
=
"
前端传 userId + baseRuleId,baseRuleId 为 STRATEGY_RULE.ID;后端优先返回该基础策略对应的用户策略,没有则返回全局策略
。"
,
required
=
true
,
required
=
true
,
content
=
@Content
(
content
=
@Content
(
mediaType
=
"application/json"
,
mediaType
=
"application/json"
,
examples
=
{
examples
=
{
@ExampleObject
(
@ExampleObject
(
name
=
"
获取用户最后保存
策略"
,
name
=
"
按基础策略获取生效
策略"
,
value
=
"{\n"
+
value
=
"{\n"
+
" \"userId\": 10001,\n"
+
" \"userId\": 10001,\n"
+
" \"
id\": \"USER:f3d7e0f0-3b8a-4d0c-8f2a-7d4e64f4c901\"
\n"
+
" \"
baseRuleId\": 1
\n"
+
"}"
"}"
),
),
@ExampleObject
(
@ExampleObject
(
...
@@ -64,11 +64,12 @@ public class UserStrategyRuleController {
...
@@ -64,11 +64,12 @@ public class UserStrategyRuleController {
" \"code\": 200,\n"
+
" \"code\": 200,\n"
+
" \"msg\": \"success\",\n"
+
" \"msg\": \"success\",\n"
+
" \"data\": {\n"
+
" \"data\": {\n"
+
" \"id\": 1,\n"
+
" \"source\": \"USER\",\n"
+
" \"source\": \"USER\",\n"
+
" \"userRuleId\": \"f3d7e0f0-3b8a-4d0c-8f2a-7d4e64f4c901\",\n"
+
" \"userRuleId\": \"f3d7e0f0-3b8a-4d0c-8f2a-7d4e64f4c901\",\n"
+
" \"baseRuleId\": 1,\n"
+
" \"baseRuleId\": 1,\n"
+
" \"sceneId\": null,\n"
+
" \"sceneId\": null,\n"
+
" \"name\": \"交期优先
-用户规则
\",\n"
+
" \"name\": \"交期优先\",\n"
+
" \"isjit\": false,\n"
+
" \"isjit\": false,\n"
+
" \"forwardScheduling\": [\n"
+
" \"forwardScheduling\": [\n"
+
" {\n"
+
" {\n"
+
...
@@ -107,7 +108,7 @@ public class UserStrategyRuleController {
...
@@ -107,7 +108,7 @@ public class UserStrategyRuleController {
@Operation
(
@Operation
(
summary
=
"保存用户策略"
,
summary
=
"保存用户策略"
,
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
description
=
"
保存当前用户策略。传下拉选项 id;如果是 GLOBAL:id,后端会创建/更新该用户对应全局策略的用户规则
。"
,
description
=
"
前端传 userId + baseRuleId 保存用户策略,baseRuleId 为 STRATEGY_RULE.ID;后端按 userId + baseRuleId 新增或更新 USER_STRATEGY_RULE
。"
,
required
=
true
,
required
=
true
,
content
=
@Content
(
content
=
@Content
(
mediaType
=
"application/json"
,
mediaType
=
"application/json"
,
...
@@ -116,7 +117,7 @@ public class UserStrategyRuleController {
...
@@ -116,7 +117,7 @@ public class UserStrategyRuleController {
name
=
"从全局策略保存用户规则"
,
name
=
"从全局策略保存用户规则"
,
value
=
"{\n"
+
value
=
"{\n"
+
" \"userId\": 10001,\n"
+
" \"userId\": 10001,\n"
+
" \"
id\": \"GLOBAL:1\"
,\n"
+
" \"
baseRuleId\": 1
,\n"
+
" \"isjit\": \"true\",\n"
+
" \"isjit\": \"true\",\n"
+
" \"forwardScheduling\": [\n"
+
" \"forwardScheduling\": [\n"
+
" {\n"
+
" {\n"
+
...
@@ -146,7 +147,7 @@ public class UserStrategyRuleController {
...
@@ -146,7 +147,7 @@ public class UserStrategyRuleController {
name
=
"更新已有用户规则"
,
name
=
"更新已有用户规则"
,
value
=
"{\n"
+
value
=
"{\n"
+
" \"userId\": 10001,\n"
+
" \"userId\": 10001,\n"
+
" \"
id\": \"USER:f3d7e0f0-3b8a-4d0c-8f2a-7d4e64f4c901\"
,\n"
+
" \"
baseRuleId\": 1
,\n"
+
" \"isjit\": \"false\",\n"
+
" \"isjit\": \"false\",\n"
+
" \"forwardScheduling\": [],\n"
+
" \"forwardScheduling\": [],\n"
+
" \"kpiConfig\": []\n"
+
" \"kpiConfig\": []\n"
+
...
@@ -194,7 +195,7 @@ public class UserStrategyRuleController {
...
@@ -194,7 +195,7 @@ public class UserStrategyRuleController {
@GetMapping
(
"/globalList"
)
@GetMapping
(
"/globalList"
)
@Operation
(
@Operation
(
summary
=
"获取策略下拉选项"
,
summary
=
"获取策略下拉选项"
,
description
=
"按
全局策略生成下拉。全局有几条就返回几条;当前用户已保存过的全局策略返回 USER,否则返回 GLOBAL
。"
,
description
=
"按
STRATEGY_RULE 生成下拉。全局有几条就返回几条;当前用户已保存过的基础策略返回 USER,否则返回 GLOBAL。id/baseRuleId 都是 STRATEGY_RULE.ID
。"
,
responses
=
@ApiResponse
(
responses
=
@ApiResponse
(
responseCode
=
"200"
,
responseCode
=
"200"
,
description
=
"查询成功"
,
description
=
"查询成功"
,
...
@@ -207,10 +208,11 @@ public class UserStrategyRuleController {
...
@@ -207,10 +208,11 @@ public class UserStrategyRuleController {
" \"msg\": \"success\",\n"
+
" \"msg\": \"success\",\n"
+
" \"data\": [\n"
+
" \"data\": [\n"
+
" {\n"
+
" {\n"
+
" \"id\":
\"USER:f3d7e0f0-3b8a-4d0c-8f2a-7d4e64f4c901\"
,\n"
+
" \"id\":
1
,\n"
+
" \"source\": \"USER\",\n"
+
" \"source\": \"USER\",\n"
+
" \"ruleId\": \"f3d7e0f0-3b8a-4d0c-8f2a-7d4e64f4c901\",\n"
+
" \"baseRuleId\": 1,\n"
+
" \"name\": \"交期优先-用户规则\",\n"
+
" \"userRuleId\": \"f3d7e0f0-3b8a-4d0c-8f2a-7d4e64f4c901\",\n"
+
" \"name\": \"交期优先\",\n"
+
" \"globalRuleId\": 1,\n"
+
" \"globalRuleId\": 1,\n"
+
" \"globalRuleName\": \"交期优先\",\n"
+
" \"globalRuleName\": \"交期优先\",\n"
+
" \"isjit\": false,\n"
+
" \"isjit\": false,\n"
+
...
@@ -227,9 +229,9 @@ public class UserStrategyRuleController {
...
@@ -227,9 +229,9 @@ public class UserStrategyRuleController {
" \"isDefault\": 1\n"
+
" \"isDefault\": 1\n"
+
" },\n"
+
" },\n"
+
" {\n"
+
" {\n"
+
" \"id\":
\"GLOBAL:2\"
,\n"
+
" \"id\":
2
,\n"
+
" \"source\": \"GLOBAL\",\n"
+
" \"source\": \"GLOBAL\",\n"
+
" \"
r
uleId\": 2,\n"
+
" \"
baseR
uleId\": 2,\n"
+
" \"name\": \"齐套优先\",\n"
+
" \"name\": \"齐套优先\",\n"
+
" \"globalRuleId\": 2,\n"
+
" \"globalRuleId\": 2,\n"
+
" \"globalRuleName\": \"齐套优先\",\n"
+
" \"globalRuleName\": \"齐套优先\",\n"
+
...
@@ -237,18 +239,18 @@ public class UserStrategyRuleController {
...
@@ -237,18 +239,18 @@ public class UserStrategyRuleController {
" \"forwardScheduling\": []\n"
+
" \"forwardScheduling\": []\n"
+
" },\n"
+
" },\n"
+
" {\n"
+
" {\n"
+
" \"id\":
\"GLOBAL:3\"
,\n"
+
" \"id\":
3
,\n"
+
" \"source\": \"GLOBAL\",\n"
+
" \"source\": \"GLOBAL\",\n"
+
" \"
r
uleId\": 3,\n"
+
" \"
baseR
uleId\": 3,\n"
+
" \"name\": \"换型最少\",\n"
+
" \"name\": \"换型最少\",\n"
+
" \"globalRuleId\": 3,\n"
+
" \"globalRuleId\": 3,\n"
+
" \"globalRuleName\": \"换型最少\",\n"
+
" \"globalRuleName\": \"换型最少\",\n"
+
" \"forwardScheduling\": []\n"
+
" \"forwardScheduling\": []\n"
+
" },\n"
+
" },\n"
+
" {\n"
+
" {\n"
+
" \"id\":
\"GLOBAL:4\"
,\n"
+
" \"id\":
4
,\n"
+
" \"source\": \"GLOBAL\",\n"
+
" \"source\": \"GLOBAL\",\n"
+
" \"
r
uleId\": 4,\n"
+
" \"
baseR
uleId\": 4,\n"
+
" \"name\": \"设备负载均衡\",\n"
+
" \"name\": \"设备负载均衡\",\n"
+
" \"globalRuleId\": 4,\n"
+
" \"globalRuleId\": 4,\n"
+
" \"globalRuleName\": \"设备负载均衡\",\n"
+
" \"globalRuleName\": \"设备负载均衡\",\n"
+
...
...
src/main/java/com/aps/controller/common/ChromosomeDataController.java
View file @
96bd6495
...
@@ -46,9 +46,9 @@ public class ChromosomeDataController {
...
@@ -46,9 +46,9 @@ public class ChromosomeDataController {
* 通用接口,根据实体名称查询Chromosome中的数据,支持分页和条件过滤
* 通用接口,根据实体名称查询Chromosome中的数据,支持分页和条件过滤
* 示例:
* 示例:
* - 文件实体: POST /queryChromosome/order/page
* - 文件实体: POST /queryChromosome/order/page
* Body: { "sceneId": "SCENE001", "pageIndex":
0
, "pageSize": 10, "conditions": [...] }
* Body: { "sceneId": "SCENE001", "pageIndex":
1
, "pageSize": 10, "conditions": [...] }
* - 数据库实体: POST /queryChromosome/user/page
* - 数据库实体: POST /queryChromosome/user/page
* Body: { "pageIndex":
0
, "pageSize": 10, "conditions": [...] }
* Body: { "pageIndex":
1
, "pageSize": 10, "conditions": [...] }
*
*
* @param entityName 实体名称 (如: order, entry, machine, user, department等)
* @param entityName 实体名称 (如: order, entry, machine, user, department等)
* @param paged 分页和条件对象
* @param paged 分页和条件对象
...
@@ -235,7 +235,7 @@ public class ChromosomeDataController {
...
@@ -235,7 +235,7 @@ public class ChromosomeDataController {
* "name": "订单列表",
* "name": "订单列表",
* "table": "order",
* "table": "order",
* "data": {
* "data": {
* "pageIndex":
0
,
* "pageIndex":
1
,
* "pageSize": 10,
* "pageSize": 10,
* "conditions": [
* "conditions": [
* { "fieldName": "sceneId", "fieldValue": "SCENE001", "conditionalType": "EQUAL" }
* { "fieldName": "sceneId", "fieldValue": "SCENE001", "conditionalType": "EQUAL" }
...
...
src/main/java/com/aps/controller/gantt/ResourceGanttController.java
View file @
96bd6495
...
@@ -849,7 +849,7 @@ public class ResourceGanttController {
...
@@ -849,7 +849,7 @@ public class ResourceGanttController {
}
}
// 获取分页参数
// 获取分页参数
Integer
pageindex
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
0
,
paged
.
getPageIndex
())
:
0
;
Integer
pageindex
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
1
,
paged
.
getPageIndex
())
:
1
;
Integer
pagesize
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
1000
;
Integer
pagesize
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
1000
;
// 校验能否获取对应的文件
// 校验能否获取对应的文件
...
@@ -888,7 +888,7 @@ public class ResourceGanttController {
...
@@ -888,7 +888,7 @@ public class ResourceGanttController {
int
totalOrders
=
orderList
.
size
();
int
totalOrders
=
orderList
.
size
();
// 执行工单分页
// 执行工单分页
int
startIndex
=
pageindex
*
pagesize
;
int
startIndex
=
(
pageindex
-
1
)
*
pagesize
;
int
endIndex
=
Math
.
min
(
startIndex
+
pagesize
,
totalOrders
);
int
endIndex
=
Math
.
min
(
startIndex
+
pagesize
,
totalOrders
);
List
<
TaskVO
>
pageOrders
;
List
<
TaskVO
>
pageOrders
;
if
(
startIndex
<
totalOrders
)
{
if
(
startIndex
<
totalOrders
)
{
...
@@ -953,7 +953,7 @@ public class ResourceGanttController {
...
@@ -953,7 +953,7 @@ public class ResourceGanttController {
}
}
// 获取分页参数
// 获取分页参数
Integer
pageindex
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
0
,
paged
.
getPageIndex
())
:
0
;
Integer
pageindex
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
1
,
paged
.
getPageIndex
())
:
1
;
Integer
pagesize
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
1000
;
Integer
pagesize
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
1000
;
// 校验能否获取对应的文件
// 校验能否获取对应的文件
...
@@ -969,7 +969,7 @@ public class ResourceGanttController {
...
@@ -969,7 +969,7 @@ public class ResourceGanttController {
int
total
=
productGanttVOs
.
size
();
int
total
=
productGanttVOs
.
size
();
// 计算分页参数
// 计算分页参数
int
startIndex
=
pageindex
*
pagesize
;
int
startIndex
=
(
pageindex
-
1
)
*
pagesize
;
int
endIndex
=
Math
.
min
(
startIndex
+
pagesize
,
total
);
int
endIndex
=
Math
.
min
(
startIndex
+
pagesize
,
total
);
// 执行分页
// 执行分页
...
...
src/main/java/com/aps/entity/common/Paged.java
View file @
96bd6495
...
@@ -17,7 +17,7 @@ import java.util.Optional;
...
@@ -17,7 +17,7 @@ import java.util.Optional;
*/
*/
public
class
Paged
{
public
class
Paged
{
private
Integer
pageIndex
=
0
;
//当前页
private
Integer
pageIndex
=
1
;
//当前页
private
Integer
pageSize
=
1000
;
//每页多少条
private
Integer
pageSize
=
1000
;
//每页多少条
private
Integer
total
=
0
;
// 特殊设置,总记录数,如果前台带有此值,则分页查询时不查询总数。
private
Integer
total
=
0
;
// 特殊设置,总记录数,如果前台带有此值,则分页查询时不查询总数。
private
List
<
String
>
sortByList
=
new
ArrayList
<>();
// 多字段排序列表,格式如["type asc", "id desc"]
private
List
<
String
>
sortByList
=
new
ArrayList
<>();
// 多字段排序列表,格式如["type asc", "id desc"]
...
...
src/main/java/com/aps/service/common/ChromosomeDataService.java
View file @
96bd6495
...
@@ -418,7 +418,7 @@ public class ChromosomeDataService {
...
@@ -418,7 +418,7 @@ public class ChromosomeDataService {
Map
<
String
,
Object
>
emptyResult
=
new
HashMap
<>();
Map
<
String
,
Object
>
emptyResult
=
new
HashMap
<>();
emptyResult
.
put
(
"records"
,
Collections
.
emptyList
());
emptyResult
.
put
(
"records"
,
Collections
.
emptyList
());
emptyResult
.
put
(
"totalCount"
,
0
);
emptyResult
.
put
(
"totalCount"
,
0
);
emptyResult
.
put
(
"pageIndex"
,
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
0
,
paged
.
getPageIndex
())
:
0
);
emptyResult
.
put
(
"pageIndex"
,
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
1
,
paged
.
getPageIndex
())
:
1
);
emptyResult
.
put
(
"size"
,
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
);
emptyResult
.
put
(
"size"
,
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
);
return
emptyResult
;
return
emptyResult
;
}
}
...
@@ -817,9 +817,9 @@ public class ChromosomeDataService {
...
@@ -817,9 +817,9 @@ public class ChromosomeDataService {
}
}
// 应用分页
// 应用分页
if
(
paged
.
getPageIndex
()
!=
null
&&
paged
.
getPageSize
()
!=
null
&&
paged
.
getPageSize
()
>
0
)
{
if
(
paged
.
getPageIndex
()
!=
null
&&
paged
.
getPageSize
()
!=
null
&&
paged
.
getPageSize
()
>
0
)
{
int
pageIndex
=
Math
.
max
(
0
,
paged
.
getPageIndex
());
int
pageIndex
=
Math
.
max
(
1
,
paged
.
getPageIndex
());
int
pageSize
=
paged
.
getPageSize
();
int
pageSize
=
paged
.
getPageSize
();
int
start
=
pageIndex
*
pageSize
;
int
start
=
(
pageIndex
-
1
)
*
pageSize
;
int
end
=
Math
.
min
(
start
+
pageSize
,
result
.
size
());
int
end
=
Math
.
min
(
start
+
pageSize
,
result
.
size
());
if
(
start
>=
result
.
size
())
{
if
(
start
>=
result
.
size
())
{
return
new
ArrayList
<>();
return
new
ArrayList
<>();
...
@@ -1573,7 +1573,7 @@ public class ChromosomeDataService {
...
@@ -1573,7 +1573,7 @@ public class ChromosomeDataService {
}
}
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
int
page
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
0
,
paged
.
getPageIndex
())
:
0
;
int
page
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
1
,
paged
.
getPageIndex
())
:
1
;
int
size
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
;
int
size
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
;
if
(
data
instanceof
List
)
{
if
(
data
instanceof
List
)
{
...
@@ -1601,7 +1601,7 @@ public class ChromosomeDataService {
...
@@ -1601,7 +1601,7 @@ public class ChromosomeDataService {
}
}
int
total
=
dataList
.
size
();
int
total
=
dataList
.
size
();
int
fromIndex
=
page
*
size
;
int
fromIndex
=
(
page
-
1
)
*
size
;
fromIndex
=
Math
.
min
(
fromIndex
,
total
);
fromIndex
=
Math
.
min
(
fromIndex
,
total
);
int
toIndex
=
Math
.
min
(
fromIndex
+
size
,
total
);
int
toIndex
=
Math
.
min
(
fromIndex
+
size
,
total
);
...
@@ -1620,7 +1620,7 @@ public class ChromosomeDataService {
...
@@ -1620,7 +1620,7 @@ public class ChromosomeDataService {
}
else
{
}
else
{
result
.
put
(
"records"
,
data
);
result
.
put
(
"records"
,
data
);
result
.
put
(
"totalCount"
,
1
);
result
.
put
(
"totalCount"
,
1
);
result
.
put
(
"pageIndex"
,
0
);
result
.
put
(
"pageIndex"
,
1
);
result
.
put
(
"size"
,
1
);
result
.
put
(
"size"
,
1
);
}
}
...
...
src/main/java/com/aps/service/common/DatabaseQueryService.java
View file @
96bd6495
...
@@ -65,7 +65,7 @@ public class DatabaseQueryService {
...
@@ -65,7 +65,7 @@ public class DatabaseQueryService {
String
orderBy
=
buildOrderBy
(
paged
);
String
orderBy
=
buildOrderBy
(
paged
);
// 分页参数
// 分页参数
int
page
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
0
,
paged
.
getPageIndex
())
:
0
;
int
page
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
1
,
paged
.
getPageIndex
())
:
1
;
int
size
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
;
int
size
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
;
// 返回列:fields 有值时只查指定列,否则 SELECT *
// 返回列:fields 有值时只查指定列,否则 SELECT *
...
@@ -157,7 +157,7 @@ public class DatabaseQueryService {
...
@@ -157,7 +157,7 @@ public class DatabaseQueryService {
Map
<
String
,
Object
>
empty
=
new
HashMap
<>();
Map
<
String
,
Object
>
empty
=
new
HashMap
<>();
empty
.
put
(
"records"
,
Collections
.
emptyList
());
empty
.
put
(
"records"
,
Collections
.
emptyList
());
empty
.
put
(
"totalCount"
,
0
);
empty
.
put
(
"totalCount"
,
0
);
empty
.
put
(
"pageIndex"
,
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
0
,
paged
.
getPageIndex
())
:
0
);
empty
.
put
(
"pageIndex"
,
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
1
,
paged
.
getPageIndex
())
:
1
);
empty
.
put
(
"size"
,
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
);
empty
.
put
(
"size"
,
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
);
return
empty
;
return
empty
;
}
}
...
@@ -165,7 +165,7 @@ public class DatabaseQueryService {
...
@@ -165,7 +165,7 @@ public class DatabaseQueryService {
String
groupColsStr
=
String
.
join
(
", "
,
groupCols
);
String
groupColsStr
=
String
.
join
(
", "
,
groupCols
);
// 修复分组查询时的ORDER BY语法错误
// 修复分组查询时的ORDER BY语法错误
String
orderBy
=
buildOrderByForGroupBy
(
paged
,
groupCols
);
String
orderBy
=
buildOrderByForGroupBy
(
paged
,
groupCols
);
int
page
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
0
,
paged
.
getPageIndex
())
:
0
;
int
page
=
paged
.
getPageIndex
()
!=
null
?
Math
.
max
(
1
,
paged
.
getPageIndex
())
:
1
;
int
size
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
;
int
size
=
paged
.
getPageSize
()
!=
null
?
paged
.
getPageSize
()
:
10
;
String
countSql
=
"SELECT COUNT(*) FROM (SELECT "
+
groupColsStr
+
" FROM "
+
tableName
+
whereClause
+
" GROUP BY "
+
groupColsStr
+
")"
;
String
countSql
=
"SELECT COUNT(*) FROM (SELECT "
+
groupColsStr
+
" FROM "
+
tableName
+
whereClause
+
" GROUP BY "
+
groupColsStr
+
")"
;
...
@@ -218,9 +218,10 @@ public class DatabaseQueryService {
...
@@ -218,9 +218,10 @@ public class DatabaseQueryService {
}
}
private
String
buildOraclePaginationSqlForGroupBy
(
String
innerSql
,
int
page
,
int
size
)
{
private
String
buildOraclePaginationSqlForGroupBy
(
String
innerSql
,
int
page
,
int
size
)
{
int
safePage
=
Math
.
max
(
0
,
page
);
int
safePage
=
Math
.
max
(
1
,
page
);
int
startRow
=
safePage
*
size
+
1
;
int
offsetPage
=
safePage
-
1
;
int
endRow
=
(
safePage
+
1
)
*
size
;
int
startRow
=
offsetPage
*
size
+
1
;
int
endRow
=
safePage
*
size
;
return
"SELECT * FROM (SELECT a.*, ROWNUM rn FROM ("
+
innerSql
+
") a WHERE ROWNUM <= "
+
endRow
+
") WHERE rn >= "
+
startRow
;
return
"SELECT * FROM (SELECT a.*, ROWNUM rn FROM ("
+
innerSql
+
") a WHERE ROWNUM <= "
+
endRow
+
") WHERE rn >= "
+
startRow
;
}
}
...
@@ -442,9 +443,10 @@ public class DatabaseQueryService {
...
@@ -442,9 +443,10 @@ public class DatabaseQueryService {
* 构建Oracle分页SQL;selectClause 为 null 或空时使用 *。
* 构建Oracle分页SQL;selectClause 为 null 或空时使用 *。
*/
*/
private
String
buildOraclePaginationSql
(
String
tableName
,
String
whereClause
,
String
orderBy
,
int
page
,
int
size
,
String
selectClause
)
{
private
String
buildOraclePaginationSql
(
String
tableName
,
String
whereClause
,
String
orderBy
,
int
page
,
int
size
,
String
selectClause
)
{
int
safePage
=
Math
.
max
(
0
,
page
);
int
safePage
=
Math
.
max
(
1
,
page
);
int
startRow
=
safePage
*
size
+
1
;
int
offsetPage
=
safePage
-
1
;
int
endRow
=
(
safePage
+
1
)
*
size
;
int
startRow
=
offsetPage
*
size
+
1
;
int
endRow
=
safePage
*
size
;
String
cols
=
(
selectClause
!=
null
&&
!
selectClause
.
trim
().
isEmpty
())
?
selectClause
:
"*"
;
String
cols
=
(
selectClause
!=
null
&&
!
selectClause
.
trim
().
isEmpty
())
?
selectClause
:
"*"
;
StringBuilder
sql
=
new
StringBuilder
();
StringBuilder
sql
=
new
StringBuilder
();
...
...
src/main/java/com/aps/service/impl/UserStrategyRuleServiceImpl.java
View file @
96bd6495
...
@@ -66,13 +66,26 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
...
@@ -66,13 +66,26 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
String
source
=
getSource
(
params
);
String
source
=
getSource
(
params
);
String
ruleId
=
getRuleId
(
params
);
String
ruleId
=
getRuleId
(
params
);
String
userRuleId
=
"USER"
.
equalsIgnoreCase
(
source
)
?
ruleId
:
getString
(
params
,
"userRuleId"
);
Long
baseRuleId
=
resolveBaseRuleId
(
params
,
source
,
ruleId
);
Long
baseRuleId
=
resolveBaseRuleId
(
params
,
source
,
ruleId
);
UserStrategyRule
userRule
=
findUserRuleById
(
userRuleId
,
userId
);
if
(
baseRuleId
==
null
&&
userRule
!=
null
)
{
baseRuleId
=
userRule
.
getBaseRuleId
();
}
if
(
baseRuleId
==
null
)
{
userRule
=
findUserRule
(
userId
,
null
);
if
(
userRule
!=
null
)
{
baseRuleId
=
userRule
.
getBaseRuleId
();
}
}
if
(
baseRuleId
==
null
)
{
if
(
baseRuleId
==
null
)
{
throw
new
RuntimeException
(
"baseRuleId不能为空"
);
throw
new
RuntimeException
(
"baseRuleId不能为空"
);
}
}
UserStrategyRule
userRule
=
findUserRule
(
userId
,
baseRuleId
);
if
(
userRule
==
null
||
!
baseRuleId
.
equals
(
userRule
.
getBaseRuleId
()))
{
userRule
=
findUserRule
(
userId
,
baseRuleId
);
}
StrategyRule
globalRule
=
strategyRuleService
.
getById
(
baseRuleId
);
StrategyRule
globalRule
=
strategyRuleService
.
getById
(
baseRuleId
);
if
(
globalRule
==
null
||
isDeleted
(
globalRule
.
getIsDeleted
()))
{
if
(
globalRule
==
null
||
isDeleted
(
globalRule
.
getIsDeleted
()))
{
throw
new
RuntimeException
(
"baseRuleId不存在"
);
throw
new
RuntimeException
(
"baseRuleId不存在"
);
...
@@ -195,11 +208,10 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
...
@@ -195,11 +208,10 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
private
Map
<
String
,
Object
>
buildGlobalOption
(
StrategyRule
rule
)
{
private
Map
<
String
,
Object
>
buildGlobalOption
(
StrategyRule
rule
)
{
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"id"
,
"GLOBAL:"
+
rule
.
getId
());
item
.
put
(
"id"
,
rule
.
getId
());
item
.
put
(
"source"
,
"GLOBAL"
);
item
.
put
(
"source"
,
"GLOBAL"
);
item
.
put
(
"userRuleId"
,
null
);
item
.
put
(
"userRuleId"
,
null
);
item
.
put
(
"baseRuleId"
,
rule
.
getId
());
item
.
put
(
"baseRuleId"
,
rule
.
getId
());
item
.
put
(
"ruleId"
,
rule
.
getId
());
item
.
put
(
"name"
,
rule
.
getName
());
item
.
put
(
"name"
,
rule
.
getName
());
item
.
put
(
"globalRuleId"
,
rule
.
getId
());
item
.
put
(
"globalRuleId"
,
rule
.
getId
());
item
.
put
(
"globalRuleName"
,
rule
.
getName
());
item
.
put
(
"globalRuleName"
,
rule
.
getName
());
...
@@ -210,11 +222,10 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
...
@@ -210,11 +222,10 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
private
Map
<
String
,
Object
>
buildUserOption
(
UserStrategyRule
rule
,
StrategyRule
globalRule
)
{
private
Map
<
String
,
Object
>
buildUserOption
(
UserStrategyRule
rule
,
StrategyRule
globalRule
)
{
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"id"
,
"USER:"
+
r
ule
.
getId
());
item
.
put
(
"id"
,
globalR
ule
.
getId
());
item
.
put
(
"source"
,
"USER"
);
item
.
put
(
"source"
,
"USER"
);
item
.
put
(
"userRuleId"
,
rule
.
getId
());
item
.
put
(
"userRuleId"
,
rule
.
getId
());
item
.
put
(
"baseRuleId"
,
rule
.
getBaseRuleId
());
item
.
put
(
"baseRuleId"
,
rule
.
getBaseRuleId
());
item
.
put
(
"ruleId"
,
rule
.
getId
());
item
.
put
(
"name"
,
rule
.
getName
());
item
.
put
(
"name"
,
rule
.
getName
());
item
.
put
(
"isDefault"
,
rule
.
getIsDefault
());
item
.
put
(
"isDefault"
,
rule
.
getIsDefault
());
item
.
put
(
"globalRuleId"
,
globalRule
.
getId
());
item
.
put
(
"globalRuleId"
,
globalRule
.
getId
());
...
@@ -316,6 +327,7 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
...
@@ -316,6 +327,7 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
private
Map
<
String
,
Object
>
buildUserResult
(
UserStrategyRule
rule
)
{
private
Map
<
String
,
Object
>
buildUserResult
(
UserStrategyRule
rule
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"id"
,
rule
.
getBaseRuleId
());
result
.
put
(
"source"
,
"USER"
);
result
.
put
(
"source"
,
"USER"
);
result
.
put
(
"userRuleId"
,
rule
.
getId
());
result
.
put
(
"userRuleId"
,
rule
.
getId
());
result
.
put
(
"baseRuleId"
,
rule
.
getBaseRuleId
());
result
.
put
(
"baseRuleId"
,
rule
.
getBaseRuleId
());
...
@@ -329,6 +341,7 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
...
@@ -329,6 +341,7 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
private
Map
<
String
,
Object
>
buildGlobalResult
(
StrategyRule
rule
)
{
private
Map
<
String
,
Object
>
buildGlobalResult
(
StrategyRule
rule
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"id"
,
rule
==
null
?
null
:
rule
.
getId
());
result
.
put
(
"source"
,
"GLOBAL"
);
result
.
put
(
"source"
,
"GLOBAL"
);
result
.
put
(
"userRuleId"
,
null
);
result
.
put
(
"userRuleId"
,
null
);
result
.
put
(
"baseRuleId"
,
rule
==
null
?
null
:
rule
.
getId
());
result
.
put
(
"baseRuleId"
,
rule
==
null
?
null
:
rule
.
getId
());
...
@@ -461,13 +474,16 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
...
@@ -461,13 +474,16 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
private
String
resolveName
(
Map
<
String
,
Object
>
params
,
StrategyRule
globalRule
,
boolean
newUserRule
)
{
private
String
resolveName
(
Map
<
String
,
Object
>
params
,
StrategyRule
globalRule
,
boolean
newUserRule
)
{
String
name
=
getString
(
params
,
"name"
);
String
name
=
getString
(
params
,
"name"
);
if
(!
StringUtils
.
hasText
(
name
))
{
name
=
getString
(
params
,
"referenceName"
);
}
if
(
StringUtils
.
hasText
(
name
))
{
if
(
StringUtils
.
hasText
(
name
))
{
return
name
;
return
name
;
}
}
if
(
globalRule
==
null
)
{
if
(
globalRule
==
null
)
{
return
null
;
return
null
;
}
}
return
newUserRule
?
globalRule
.
getName
()
+
"-用户规则"
:
globalRule
.
getName
();
return
globalRule
.
getName
();
}
}
private
Long
getLong
(
Map
<
String
,
Object
>
params
,
String
key
)
{
private
Long
getLong
(
Map
<
String
,
Object
>
params
,
String
key
)
{
...
@@ -481,6 +497,14 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
...
@@ -481,6 +497,14 @@ public class UserStrategyRuleServiceImpl extends ServiceImpl<UserStrategyRuleMap
if
(
"GLOBAL"
.
equalsIgnoreCase
(
source
))
{
if
(
"GLOBAL"
.
equalsIgnoreCase
(
source
))
{
return
toLong
(
ruleId
);
return
toLong
(
ruleId
);
}
}
Long
strategyRuleId
=
getLongIfNumeric
(
params
,
"ruleId"
);
if
(
strategyRuleId
!=
null
)
{
return
strategyRuleId
;
}
Long
numericId
=
getLongIfNumeric
(
params
,
"id"
);
if
(
numericId
!=
null
)
{
return
numericId
;
}
Long
baseRuleId
=
getLong
(
params
,
"baseRuleId"
);
Long
baseRuleId
=
getLong
(
params
,
"baseRuleId"
);
// 前端保存策略时可能传 referenceId;只有纯数字时才兼容成基础策略 ID,UUID 行引用要忽略。
// 前端保存策略时可能传 referenceId;只有纯数字时才兼容成基础策略 ID,UUID 行引用要忽略。
if
(
baseRuleId
!=
null
)
{
if
(
baseRuleId
!=
null
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment