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
8ceb95e8
Commit
8ceb95e8
authored
Jan 21, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/jdt'
parents
a6b17e54
08d4180a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
258 additions
and
21 deletions
+258
-21
ResourceGanttController.java
...ava/com/aps/controller/gantt/ResourceGanttController.java
+84
-3
RoutingDataService.java
...in/java/com/aps/service/Algorithm/RoutingDataService.java
+39
-13
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+103
-5
SceneService.java
src/main/java/com/aps/service/plan/SceneService.java
+32
-0
No files found.
src/main/java/com/aps/controller/gantt/ResourceGanttController.java
View file @
8ceb95e8
...
@@ -33,9 +33,6 @@ import java.util.stream.Collectors;
...
@@ -33,9 +33,6 @@ import java.util.stream.Collectors;
@Tag
(
name
=
"甘特图管理"
,
description
=
"甘特图管理"
)
@Tag
(
name
=
"甘特图管理"
,
description
=
"甘特图管理"
)
public
class
ResourceGanttController
{
public
class
ResourceGanttController
{
@Autowired
private
PlanSchedulerService
schedulingService
;
@Autowired
@Autowired
private
PlanResultService
planResultService
;
private
PlanResultService
planResultService
;
...
@@ -756,6 +753,7 @@ public class ResourceGanttController {
...
@@ -756,6 +753,7 @@ public class ResourceGanttController {
}
}
@PostMapping
(
"/getSceneVersion"
)
@PostMapping
(
"/getSceneVersion"
)
@Operation
(
summary
=
"获取版本号"
,
description
=
"获取所有版本号"
)
@Operation
(
summary
=
"获取版本号"
,
description
=
"获取所有版本号"
)
public
R
<
List
<
Integer
>>
getSceneVersion
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
public
R
<
List
<
Integer
>>
getSceneVersion
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
...
@@ -765,6 +763,56 @@ public class ResourceGanttController {
...
@@ -765,6 +763,56 @@ public class ResourceGanttController {
}
}
@PostMapping
(
"/getSceneVersionWithIndex"
)
@Operation
(
summary
=
"获取版本号及当前索引"
,
description
=
"获取版本号列表及当前版本在列表中的索引"
,
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
description
=
"获取版本号及当前索引参数"
,
content
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
media
.
Content
(
mediaType
=
"application/json"
,
examples
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
media
.
ExampleObject
(
name
=
"获取版本号及当前索引示例"
,
value
=
"{\n \"sceneId\": \"B571EF6682DB463AB2977B1055A74112\"\n}"
)
)
)
)
public
R
<
Map
<
String
,
Object
>>
getSceneVersionWithIndex
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
String
sceneId
=
ParamValidator
.
getString
(
params
,
"sceneId"
,
"场景ID"
);
Map
<
String
,
Object
>
versionData
=
planResultService
.
getSceneVersion
(
sceneId
);
return
R
.
ok
(
versionData
);
}
@PostMapping
(
"/revertVersion"
)
@Operation
(
summary
=
"撤销操作"
,
description
=
"撤销操作"
,
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
description
=
"撤销操作参数"
,
content
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
media
.
Content
(
mediaType
=
"application/json"
,
examples
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
media
.
ExampleObject
(
name
=
"撤销操作示例"
,
value
=
"{\n \"sceneId\": \"B571EF6682DB463AB2977B1055A74112\",\n \"version\": 1\n}"
)
)
)
)
public
R
<
String
>
revertVersion
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
String
sceneId
=
ParamValidator
.
getString
(
params
,
"sceneId"
,
"场景ID不能为空"
);
Integer
version
=
ParamValidator
.
getInteger
(
params
,
"version"
,
"版本号不能为空"
);
if
(
sceneId
==
null
)
{
return
R
.
failed
(
"场景ID和版本号不能为空"
);
}
Chromosome
result
=
planResultService
.
revertVersion
(
sceneId
,
version
);
return
R
.
ok
(
"撤销成功"
);
}
@PostMapping
(
"/unFixStartDate"
)
@PostMapping
(
"/unFixStartDate"
)
@Operation
(
summary
=
"取消固定开始日期"
,
description
=
"取消固定开始日期"
,
@Operation
(
summary
=
"取消固定开始日期"
,
description
=
"取消固定开始日期"
,
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
...
@@ -794,5 +842,38 @@ public class ResourceGanttController {
...
@@ -794,5 +842,38 @@ public class ResourceGanttController {
}
}
@PostMapping
(
"/operationDrag"
)
@Operation
(
summary
=
"工单拖拽排序"
,
description
=
"工单拖拽排序"
,
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
description
=
"工单拖拽排序"
,
content
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
media
.
Content
(
mediaType
=
"application/json"
,
examples
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
media
.
ExampleObject
(
name
=
"工单拖拽排序示例"
,
value
=
"{\n \"sceneId\": \"F2EAE9B2786349A2B950CEB0FD108807\",\n \"id\": [9,3],\n \"targetOpId\": 13,\n \"isFront\": true,\n \"newMachineId\": 1263\n}"
)
)
)
)
public
R
<
String
>
operationDrag
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
log
.
info
(
"operationDrag 请求参数: {}"
,
params
);
// 验证场景
String
sceneId
=
ParamValidator
.
getString
(
params
,
"sceneId"
,
"场景ID"
);
Integer
targetOpId
=
ParamValidator
.
getInteger
(
params
,
"targetOpId"
,
"目标操作ID"
);
Boolean
isFront
=
ParamValidator
.
getBoolean
(
params
,
"isFront"
,
"是否前置"
);
Long
newMachineId
=
ParamValidator
.
getLong
(
params
,
"newMachineId"
,
"新机器ID"
);
List
opId
=
ParamValidator
.
getList
(
params
,
"id"
,
"操作ID"
);
List
<
Integer
>
opIds
=
ParamValidator
.
convertToIntArray
(
opId
,
"操作IDS"
);
ParamValidator
.
validateSceneExists
(
sceneService
,
sceneId
);
// 执行拖拽操作
Chromosome
result
=
planResultService
.
Drag
(
sceneId
,
opIds
,
targetOpId
,
isFront
,
newMachineId
);
return
R
.
ok
(
"工单拖拽排序成功"
);
}
}
}
\ No newline at end of file
src/main/java/com/aps/service/Algorithm/RoutingDataService.java
View file @
8ceb95e8
...
@@ -27,28 +27,19 @@ import java.util.stream.Collectors;
...
@@ -27,28 +27,19 @@ import java.util.stream.Collectors;
@Service
@Service
public
class
RoutingDataService
{
public
class
RoutingDataService
{
@Autowired
private
ProdLaunchOrderService
_prodLaunchOrderService
;
@Autowired
@Autowired
private
ProdProcessExecService
_prodProcessExecService
;
private
ProdProcessExecService
_prodProcessExecService
;
@Autowired
private
ProdEquipmentService
_prodEquipmentService
;
@Autowired
@Autowired
private
PlanResourceService
_PlanResourceService
;
private
PlanResourceService
_PlanResourceService
;
@Autowired
private
SceneService
_sceneService
;
@Autowired
@Autowired
private
ProdOrderProcessService
_prodOrderProcessService
;
private
ProdOrderProcessService
_prodOrderProcessService
;
@Autowired
@Autowired
private
RoutingDiscreteParamService
_routingDiscreteParamService
;
private
RoutingDiscreteParamService
_routingDiscreteParamService
;
@Autowired
private
DiscreteParameterMatrixService
_discreteParameterMatrixService
;
@Autowired
@Autowired
private
ProdEquipSpecialCalService
_prodEquipSpecialCalService
;
private
ProdEquipSpecialCalService
_prodEquipSpecialCalService
;
...
@@ -67,6 +58,8 @@ public class RoutingDataService {
...
@@ -67,6 +58,8 @@ public class RoutingDataService {
@Autowired
@Autowired
private
MesShiftWorkSchedService
_MesShiftWorkSchedService
;
private
MesShiftWorkSchedService
_MesShiftWorkSchedService
;
@Autowired
private
EquipinfoService
_equipinfoService
;
public
Map
<
Integer
,
Object
>
InitEntrys
(
String
SceneId
,
List
<
ProdEquipment
>
ProdEquipments
,
List
<
Order
>
ProdLaunchOrders
)
public
Map
<
Integer
,
Object
>
InitEntrys
(
String
SceneId
,
List
<
ProdEquipment
>
ProdEquipments
,
List
<
Order
>
ProdLaunchOrders
)
{
{
...
@@ -301,14 +294,23 @@ public class RoutingDataService {
...
@@ -301,14 +294,23 @@ public class RoutingDataService {
List
<
PlanResource
>
PlanResources
=
_PlanResourceService
.
lambdaQuery
()
List
<
PlanResource
>
PlanResources
=
_PlanResourceService
.
lambdaQuery
()
.
eq
(
PlanResource:
:
getIsdeleted
,
0
)
.
eq
(
PlanResource:
:
getIsdeleted
,
0
)
.
list
();
.
list
();
List
<
Equipinfo
>
equipinfoList
=
_equipinfoService
.
lambdaQuery
()
.
eq
(
Equipinfo:
:
getIsdeleted
,
0
)
.
list
();
for
(
Long
id
:
MachineIds
)
{
for
(
Long
id
:
MachineIds
)
{
Machine
machine
=
new
Machine
();
Machine
machine
=
new
Machine
();
machine
.
setId
(
id
);
machine
.
setId
(
id
);
machine
.
setCode
(
""
);
machine
.
setCode
(
""
);
machine
.
setName
(
""
);
machine
.
setName
(
""
);
machines
.
add
(
machine
);
machines
.
add
(
machine
);
}
}
//节假日
//节假日
// List<MesHoliday> holidays= _MesHolidayService.list();
// List<MesHoliday> holidays= _MesHolidayService.list();
if
(
IsUseCalendar
)
{
if
(
IsUseCalendar
)
{
...
@@ -352,9 +354,21 @@ public class RoutingDataService {
...
@@ -352,9 +354,21 @@ public class RoutingDataService {
PlanResource
PlanResource
=
PlanResources
.
stream
()
PlanResource
PlanResource
=
PlanResources
.
stream
()
.
filter
(
t
->
t
.
getId
()
==
machine
.
getId
())
.
filter
(
t
->
t
.
getId
()
==
machine
.
getId
())
.
findFirst
().
orElse
(
null
);
.
findFirst
().
orElse
(
null
);
if
(
PlanResource
!=
null
)
{
if
(
PlanResource
!=
null
)
{
machine
.
setCode
(
PlanResource
.
getCode
());
Equipinfo
equipinfo
=
equipinfoList
.
stream
()
.
filter
(
t
->
t
.
getId
().
equals
(
PlanResource
.
getReferenceId
()))
.
findFirst
().
orElse
(
null
);
if
(
equipinfo
!=
null
)
{
machine
.
setCode
(
equipinfo
.
getEquipId
());
machine
.
setName
(
equipinfo
.
getEquipName
());
}
else
{
machine
.
setCode
(
PlanResource
.
getReferenceCode
());
machine
.
setName
(
PlanResource
.
getTitle
());
machine
.
setName
(
PlanResource
.
getTitle
());
}
List
<
MesShiftWorkSched
>
ShiftWorkScheds
=
MesShiftWorkScheds
.
stream
()
List
<
MesShiftWorkSched
>
ShiftWorkScheds
=
MesShiftWorkScheds
.
stream
()
.
filter
(
t
->
(
long
)
t
.
getWeekWorkSchedId
()
==
PlanResource
.
getWorkSchedId
())
.
filter
(
t
->
(
long
)
t
.
getWeekWorkSchedId
()
==
PlanResource
.
getWorkSchedId
())
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
@@ -434,6 +448,7 @@ public class RoutingDataService {
...
@@ -434,6 +448,7 @@ public class RoutingDataService {
List
<
PlanResource
>
PlanResources
=
_PlanResourceService
.
lambdaQuery
()
List
<
PlanResource
>
PlanResources
=
_PlanResourceService
.
lambdaQuery
()
.
eq
(
PlanResource:
:
getIsdeleted
,
0
)
.
eq
(
PlanResource:
:
getIsdeleted
,
0
)
.
list
();
.
list
();
List
<
MesShiftWorkSched
>
MesShiftWorkScheds
=
_MesShiftWorkSchedService
.
lambdaQuery
()
List
<
MesShiftWorkSched
>
MesShiftWorkScheds
=
_MesShiftWorkSchedService
.
lambdaQuery
()
.
eq
(
MesShiftWorkSched:
:
getIsdeleted
,
0
).
list
();
.
eq
(
MesShiftWorkSched:
:
getIsdeleted
,
0
).
list
();
...
@@ -463,14 +478,25 @@ public class RoutingDataService {
...
@@ -463,14 +478,25 @@ public class RoutingDataService {
// SpecialCalendarDetailWrapper.ge(SpecialCalendarDetail::getEndTime, baseTime);
// SpecialCalendarDetailWrapper.ge(SpecialCalendarDetail::getEndTime, baseTime);
List
<
SpecialCalendarDetail
>
SpecialCalendarDetails
=
_specialCalendarDetailService
.
list
(
SpecialCalendarDetailWrapper
);
List
<
SpecialCalendarDetail
>
SpecialCalendarDetails
=
_specialCalendarDetailService
.
list
(
SpecialCalendarDetailWrapper
);
List
<
Equipinfo
>
equipinfoList
=
_equipinfoService
.
lambdaQuery
()
.
eq
(
Equipinfo:
:
getIsdeleted
,
0
)
.
list
();
for
(
PlanResource
resource
:
PlanResources
)
{
for
(
PlanResource
resource
:
PlanResources
)
{
Machine
machine
=
new
Machine
();
Machine
machine
=
new
Machine
();
machine
.
setId
(
resource
.
getId
());
machine
.
setId
(
resource
.
getId
());
Equipinfo
equipinfo
=
equipinfoList
.
stream
()
.
filter
(
t
->
t
.
getId
().
equals
(
resource
.
getReferenceId
()))
.
findFirst
().
orElse
(
null
);
if
(
equipinfo
!=
null
)
{
machine
.
setCode
(
equipinfo
.
getEquipId
());
machine
.
setName
(
equipinfo
.
getEquipName
());
}
else
{
machine
.
setCode
(
resource
.
getReferenceCode
());
machine
.
setCode
(
resource
.
getReferenceCode
());
machine
.
setName
(
resource
.
getTitle
());
machine
.
setName
(
resource
.
getTitle
());
}
List
<
EquipCapacityDef
>
machineProdEquipSpecialCals
=
ProdEquipSpecialCals
.
stream
()
List
<
EquipCapacityDef
>
machineProdEquipSpecialCals
=
ProdEquipSpecialCals
.
stream
()
.
filter
(
t
->
t
.
getPlanResourceId
()
!=
null
&&
t
.
getReferenceId
()
!=
null
&&
t
.
getPlanResourceId
()
==
machine
.
getId
()
&&
t
.
getReferenceType
()
==
1
)
.
filter
(
t
->
t
.
getPlanResourceId
()
!=
null
&&
t
.
getReferenceId
()
!=
null
&&
t
.
getPlanResourceId
()
==
machine
.
getId
()
&&
t
.
getReferenceType
()
==
1
)
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
8ceb95e8
...
@@ -7,6 +7,7 @@ import com.aps.entity.*;
...
@@ -7,6 +7,7 @@ import com.aps.entity.*;
import
com.aps.entity.Algorithm.*
;
import
com.aps.entity.Algorithm.*
;
import
com.aps.entity.Algorithm.IDAndChildID.GroupResult
;
import
com.aps.entity.Algorithm.IDAndChildID.GroupResult
;
import
com.aps.entity.Algorithm.IDAndChildID.NodeInfo
;
import
com.aps.entity.Algorithm.IDAndChildID.NodeInfo
;
import
com.aps.entity.Gantt.ResourceGanttVO
;
import
com.aps.entity.Gantt.TaskVO
;
import
com.aps.entity.Gantt.TaskVO
;
import
com.aps.entity.Schedule.SceneChromsome
;
import
com.aps.entity.Schedule.SceneChromsome
;
import
com.aps.entity.basic.ScheduleChromosome
;
import
com.aps.entity.basic.ScheduleChromosome
;
...
@@ -784,11 +785,24 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
...
@@ -784,11 +785,24 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
{
{
return
_sceneService
.
moveChromosome
(
sceneId
,
version
);
return
_sceneService
.
moveChromosome
(
sceneId
,
version
);
}
}
//场景下所有操作版本
//场景下所有操作版本
public
SceneChromsome
getSceneChromsome
(
String
sceneId
)
public
SceneChromsome
getSceneChromsome
(
String
sceneId
)
{
{
return
_sceneService
.
getSceneChromsome
(
sceneId
);
return
_sceneService
.
getSceneChromsome
(
sceneId
);
}
}
public
Chromosome
revertVersion
(
String
sceneId
,
Integer
version
)
{
return
_sceneService
.
revertVersion
(
sceneId
,
version
);
}
public
void
testSceneChromsome
(
String
sceneId
)
public
void
testSceneChromsome
(
String
sceneId
)
{
{
Chromosome
chromosome
=
new
Chromosome
();
Chromosome
chromosome
=
new
Chromosome
();
...
@@ -1705,8 +1719,8 @@ private GlobalParam InitGlobalParam()
...
@@ -1705,8 +1719,8 @@ private GlobalParam InitGlobalParam()
* @param machineList 机器列表
* @param machineList 机器列表
* @return 转换后的数据
* @return 转换后的数据
*/
*/
public
List
<
com
.
aps
.
entity
.
Gantt
.
ResourceGanttVO
>
convertToResourceGanttVO1
(
Chromosome
scheduleChromosome
,
List
<
Machine
>
machineList
)
{
public
List
<
ResourceGanttVO
>
convertToResourceGanttVO1
(
Chromosome
scheduleChromosome
,
List
<
Machine
>
machineList
)
{
List
<
com
.
aps
.
entity
.
Gantt
.
ResourceGanttVO
>
resourceGanttVOList
=
new
ArrayList
<>();
List
<
ResourceGanttVO
>
resourceGanttVOList
=
new
ArrayList
<>();
List
<
Entry
>
allOperations
=
scheduleChromosome
.
getAllOperations
();
List
<
Entry
>
allOperations
=
scheduleChromosome
.
getAllOperations
();
...
@@ -1727,7 +1741,6 @@ private GlobalParam InitGlobalParam()
...
@@ -1727,7 +1741,6 @@ private GlobalParam InitGlobalParam()
List
<
GAScheduleResult
>
machineGenes
=
scheduleChromosome
.
getResult
().
stream
()
List
<
GAScheduleResult
>
machineGenes
=
scheduleChromosome
.
getResult
().
stream
()
.
filter
(
gene
->
gene
.
getMachineId
()==(
machine
.
getId
()))
.
filter
(
gene
->
gene
.
getMachineId
()==(
machine
.
getId
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
"machineGenes: "
+
machineGenes
.
size
());
// 按开始时间排序
// 按开始时间排序
machineGenes
.
sort
((
g1
,
g2
)
->
Integer
.
compare
(
g1
.
getStartTime
(),
g2
.
getStartTime
()));
machineGenes
.
sort
((
g1
,
g2
)
->
Integer
.
compare
(
g1
.
getStartTime
(),
g2
.
getStartTime
()));
...
@@ -2247,7 +2260,92 @@ private GlobalParam InitGlobalParam()
...
@@ -2247,7 +2260,92 @@ private GlobalParam InitGlobalParam()
// 对数字列表进行排序(从小到大)
// 对数字列表进行排序(从小到大)
Collections
.
sort
(
numbers
);
Collections
.
sort
(
numbers
);
return
numbers
;
return
numbers
;
}
}
public
Map
<
String
,
Object
>
getSceneVersion
(
String
sceneId
)
{
List
<
Integer
>
numbers
=
new
ArrayList
<>();
SceneChromsome
sceneChromsome
=(
SceneChromsome
)
redisUtils
.
get
(
"SceneId."
+
sceneId
);
if
(
sceneChromsome
==
null
){
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"list"
,
numbers
);
result
.
put
(
"index"
,
-
1
);
return
result
;
}
Integer
currultVersion
=
sceneChromsome
.
getVersion
();
// 获取结果目录
File
resultDir
=
new
File
(
"result"
);
if
(!
resultDir
.
exists
()
||
!
resultDir
.
isDirectory
())
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"list"
,
numbers
);
result
.
put
(
"index"
,
-
1
);
return
result
;
}
// 获取目录中的所有文件
File
[]
files
=
resultDir
.
listFiles
();
if
(
files
==
null
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"list"
,
numbers
);
result
.
put
(
"index"
,
-
1
);
return
result
;
}
// 定义要查找的前缀
String
prefix
=
"chromosome_result_"
+
sceneId
+
"_"
;
String
suffix
=
"_.json"
;
for
(
File
file
:
files
)
{
if
(
file
.
isFile
())
{
String
fileName
=
file
.
getName
();
// 检查文件名是否以指定前缀开始,并以指定后缀结束
if
(
fileName
.
startsWith
(
prefix
)
&&
fileName
.
endsWith
(
suffix
))
{
// 提取前缀和后缀之间的部分
String
middlePart
=
fileName
.
substring
(
prefix
.
length
(),
fileName
.
length
()
-
suffix
.
length
()
);
// 尝试将中间部分解析为数字
try
{
int
number
=
Integer
.
parseInt
(
middlePart
);
numbers
.
add
(
number
);
}
catch
(
NumberFormatException
e
)
{
// 如果中间部分不是数字,则跳过该文件
continue
;
}
}
}
}
// 对数字列表进行排序(从小到大)
Collections
.
sort
(
numbers
);
// 查找当前版本在numbers中的索引
int
index
=
numbers
.
indexOf
(
currultVersion
);
if
(
index
==
-
1
&&
!
numbers
.
isEmpty
())
{
// 如果当前版本不在历史版本列表中,返回列表长度作为位置
index
=
numbers
.
size
();
}
else
if
(
numbers
.
isEmpty
())
{
index
=
-
1
;
// 如果列表为空,索引为-1
}
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"list"
,
numbers
);
result
.
put
(
"index"
,
index
);
return
result
;
}
}
}
src/main/java/com/aps/service/plan/SceneService.java
View file @
8ceb95e8
...
@@ -239,6 +239,38 @@ public class SceneService {
...
@@ -239,6 +239,38 @@ public class SceneService {
}
}
public
Chromosome
revertVersion
(
String
sceneId
,
Integer
version
)
{
SceneChromsome
sceneChromsome
=(
SceneChromsome
)
redisUtils
.
get
(
"SceneId."
+
sceneId
);
Integer
currentVersion
=
sceneChromsome
.
getVersion
();
if
(
sceneChromsome
==
null
)
{
return
null
;
}
else
{
sceneChromsome
.
setVersion
(
version
);
redisUtils
.
set
(
"SceneId."
+
sceneId
,
sceneChromsome
);
Chromosome
chromosome
=
loadChromosomeFromFile
(
sceneId
);
if
(
chromosome
==
null
)
{
sceneChromsome
.
setVersion
(
currentVersion
);
redisUtils
.
set
(
"SceneId."
+
sceneId
,
sceneChromsome
);
throw
new
RuntimeException
(
"撤销操作失败,未找到上一版本"
);
}
return
chromosome
;
}
}
/**
/**
* 检查染色体文件是否存在
* 检查染色体文件是否存在
*/
*/
...
...
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