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
247fcbd2
Commit
247fcbd2
authored
Mar 12, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
滚动排产
parent
994fc45b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
2239 additions
and
111 deletions
+2239
-111
SwaggerMapParamConfig.java
src/main/java/com/aps/config/SwaggerMapParamConfig.java
+22
-0
LanuchController.java
src/main/java/com/aps/controller/LanuchController.java
+26
-0
ScheduleResultDetail.java
...n/java/com/aps/entity/Algorithm/ScheduleResultDetail.java
+2
-0
Dispatch.java
src/main/java/com/aps/entity/Dispatch.java
+2
-0
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+10
-14
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+17
-17
LanuchService.java
src/main/java/com/aps/service/LanuchService.java
+17
-0
ChromosomeDataService.java
...in/java/com/aps/service/common/ChromosomeDataService.java
+7
-0
LanuchServiceImpl.java
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
+234
-27
LockedOrderProcessorService.java
...ava/com/aps/service/plan/LockedOrderProcessorService.java
+981
-0
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+921
-53
No files found.
src/main/java/com/aps/config/SwaggerMapParamConfig.java
View file @
247fcbd2
...
...
@@ -133,6 +133,28 @@ public class SwaggerMapParamConfig {
));
break
;
case
"insertOrder"
:
properties
.
put
(
"sceneId"
,
new
StringSchema
().
description
(
"场景ID"
).
example
(
"B571EF6682DB463AB2977B1055A74112"
));
properties
.
put
(
"orderCode"
,
new
StringSchema
().
description
(
"订单编码"
).
example
(
"ORDER-2026-001"
));
properties
.
put
(
"materialId"
,
new
StringSchema
().
description
(
"物料ID"
).
example
(
"MAT001"
));
properties
.
put
(
"startDate"
,
new
StringSchema
().
description
(
"开始时间(ISO格式)"
).
example
(
"2026-03-10T08:00:00"
));
properties
.
put
(
"endDate"
,
new
StringSchema
().
description
(
"结束时间(ISO格式)"
).
example
(
"2026-03-20T18:00:00"
));
properties
.
put
(
"priority"
,
new
StringSchema
().
description
(
"优先级"
).
example
(
"1"
));
properties
.
put
(
"quantity"
,
new
StringSchema
().
description
(
"数量"
).
example
(
"100.0"
));
examples
.
put
(
"插单示例"
,
createExample
(
"向现有场景添加新订单"
,
"{\n"
+
" \"sceneId\": \"B571EF6682DB463AB2977B1055A74112\",\n"
+
" \"orderCode\": \"ORDER-2026-001\",\n"
+
" \"materialId\": \"MAT001\",\n"
+
" \"startDate\": \"2026-03-10T08:00:00\",\n"
+
" \"endDate\": \"2026-03-20T18:00:00\",\n"
+
" \"priority\": 1,\n"
+
" \"quantity\": 100.0\n"
+
"}"
));
break
;
case
"getResourceGantt"
:
case
"getProductGantt"
:
...
...
src/main/java/com/aps/controller/LanuchController.java
View file @
247fcbd2
...
...
@@ -187,4 +187,30 @@ public class LanuchController {
return
lanuchService
.
savePlan
(
sceneId
);
}
/**
* 插单:向现有场景添加新订单
*/
@PostMapping
(
"/insertOrder"
)
@Operation
(
summary
=
"插单"
,
description
=
"向现有场景添加新订单,订单ID会自动生成UUID格式"
)
public
R
<
String
>
insertOrder
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
String
sceneId
=
(
String
)
params
.
get
(
"sceneId"
);
String
orderCode
=
(
String
)
params
.
get
(
"orderCode"
);
String
materialId
=
(
String
)
params
.
get
(
"materialId"
);
// 解析时间参数
String
startDateStr
=
(
String
)
params
.
get
(
"startDate"
);
String
endDateStr
=
(
String
)
params
.
get
(
"endDate"
);
java
.
time
.
LocalDateTime
startDate
=
java
.
time
.
LocalDateTime
.
parse
(
startDateStr
);
java
.
time
.
LocalDateTime
endDate
=
java
.
time
.
LocalDateTime
.
parse
(
endDateStr
);
// 解析优先级和数量
Integer
priority
=
params
.
get
(
"priority"
)
!=
null
?
Integer
.
valueOf
(
params
.
get
(
"priority"
).
toString
())
:
1
;
Double
quantity
=
params
.
get
(
"quantity"
)
!=
null
?
Double
.
valueOf
(
params
.
get
(
"quantity"
).
toString
())
:
0.0
;
return
lanuchService
.
insertOrder
(
sceneId
,
orderCode
,
materialId
,
startDate
,
endDate
,
priority
,
quantity
);
}
}
\ No newline at end of file
src/main/java/com/aps/entity/Algorithm/ScheduleResultDetail.java
View file @
247fcbd2
...
...
@@ -51,4 +51,6 @@ public class ScheduleResultDetail {
public
int
getProcessingTime
()
{
return
EndTime
-
StartTime
;
// 绝对处理时间(分钟)
}
}
src/main/java/com/aps/entity/Dispatch.java
View file @
247fcbd2
...
...
@@ -66,4 +66,6 @@ private Long issplit;
private
Long
parentid
;
private
Long
statusOrtems
;
private
LocalDateTime
actualEndTimeOrtems
;
private
String
sceneId
;
}
\ No newline at end of file
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
View file @
247fcbd2
package
com
.
aps
.
service
.
Algorithm
;
import
com.aps.common.util.DateTimeUtil
;
import
com.aps.common.util.DeepCopyUtil
;
import
com.aps.common.util.FileHelper
;
import
com.aps.common.util.ProductionDeepCopyUtil
;
import
com.aps.common.util.*
;
import
com.aps.entity.Algorithm.*
;
import
com.aps.entity.Algorithm.IDAndChildID.GroupResult
;
import
com.aps.entity.basic.*
;
...
...
@@ -82,16 +79,6 @@ public class GeneticAlgorithm {
throw
new
RuntimeException
(
"没有待排产工单"
);
}
// if(materials!=null&&materials.size()>0) {
//
// materialRequirementService.init(materials, orders, allOperations, _entryRel, machineScheduler, machines,_GlobalParam);
//
// orderMaterials = materialRequirementService.buildMultiLevelRequirementNetwork(param.getBaseTime());
// Set<Long> existIds = new HashSet<>();
// machines=machines.stream()
// .filter(t->existIds.add(t.getId()))//HashSet.add() 方法:添加成功返回 true,重复返回 false;
// .collect(Collectors.toList());
// }
LocalDateTime
starttime
=
LocalDateTime
.
now
();
FileHelper
.
writeLogFile
(
"排产-----------开始-----------"
+
allOperations
.
get
(
0
).
getSceneId
());
...
...
@@ -424,6 +411,15 @@ return population;
// chromosome.setInitMachines(ProductionDeepCopyUtil.deepCopyList(machines,Machine.class)); // 简单拷贝,实际可能需要深拷贝
// _sceneService.saveChromosomeToFile(chromosome, "12345679");
// 加载锁定工单到ResultOld
List
<
GAScheduleResult
>
lockedOrders
=
GlobalCacheUtil
.
get
(
"locked_orders_"
+
sceneId
);
if
(
lockedOrders
!=
null
&&
!
lockedOrders
.
isEmpty
())
{
chromosome
.
setResultOld
(
ProductionDeepCopyUtil
.
deepCopyList
(
lockedOrders
,
GAScheduleResult
.
class
));
FileHelper
.
writeLogFile
(
"将 "
+
lockedOrders
.
size
()
+
" 个锁定工单加载到初始种群中"
);
}
else
{
chromosome
.
setResultOld
(
new
CopyOnWriteArrayList
<>());
}
decoder
.
decodeChromosomeWithCache
(
chromosome
);
if
(
chromosome
.
getFitness
()
==
0
)
{
chromosome
.
setFitness
(
_fitnessCalculator
.
calculateFitness
(
chromosome
,
_objectiveWeights
));
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
247fcbd2
...
...
@@ -371,16 +371,6 @@ if(finishedOrder==null||finishedOrder.size()==0)
Entry
currentOp
=
orderOps
.
get
(
scheduledCount
);
int
opSequence
=
currentOp
.
getSequence
();
GAScheduleResult
existingResult
=
chromosome
.
getResultOld
().
stream
()
.
filter
(
r
->
r
.
getOperationId
()
==
currentOp
.
getId
())
.
findFirst
().
orElse
(
null
);
if
(
existingResult
!=
null
)
{
if
(
existingResult
.
isIsLocked
())
{
continue
;
}
}
// 从映射表中获取机器和加工时间
OpMachine
machineOption
=
opMachineMap
.
stream
()
.
filter
(
m
->
m
.
getGroupId
()
==
groupId
&&
m
.
getSequence
()==
opSequence
)
...
...
@@ -1509,15 +1499,22 @@ if(MaterialRequirements==null||MaterialRequirements.size()==0)
.
filter
(
t
->
orderIds
.
contains
(
t
.
getOrderId
()))
.
max
(
Comparator
.
comparing
(
Order:
:
getDueDate
))
.
orElse
(
null
);
if
(
order
.
isNewCreate
())
{
continue
;}
// 如果找不到对应的工单,跳过此工单组
if
(
order
==
null
)
{
continue
;
}
// 如果是新创建的工单,跳过延迟计算
if
(
order
.
isNewCreate
())
{
continue
;
}
LocalDateTime
dueDateTime
=
order
.
getDueDate
();
// 如果交付期为空,跳过延迟计算
if
(
dueDateTime
==
null
)
{
continue
;
}
LocalDateTime
completionTime
=
baseTime
.
plusSeconds
(
orderCompletion
);
if
(
completionTime
.
isAfter
(
dueDateTime
))
{
// 计算延迟小时数(修复时间计算)
long
hours
=
ChronoUnit
.
HOURS
.
between
(
dueDateTime
,
completionTime
);
...
...
@@ -1583,8 +1580,6 @@ if(order.isNewCreate())
.
mapToInt
(
g
->
g
.
getFlowTime
())
.
sum
();
machineUtilization
.
put
(
machine
.
getId
(),
busyTime
/
sumWork
);
}
...
...
@@ -1592,6 +1587,11 @@ if(order.isNewCreate())
.
mapToDouble
(
Double:
:
doubleValue
)
.
sum
()/
chromosome
.
getMachines
().
size
();
// 如果平均利用率为0,返回0
if
(
avgUtilization
==
0
)
{
return
0
;
}
double
variance
=
machineUtilization
.
values
().
stream
()
.
mapToDouble
(
u
->
Math
.
pow
(
u
-
avgUtilization
,
2
))
.
sum
()
/
chromosome
.
getMachines
().
size
();
...
...
src/main/java/com/aps/service/LanuchService.java
View file @
247fcbd2
...
...
@@ -3,6 +3,7 @@ package com.aps.service;
import
com.aps.common.util.R
;
import
com.aps.entity.*
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -67,4 +68,20 @@ public interface LanuchService {
*/
R
<
String
>
savePlan
(
String
sceneId
);
/**
* 插单功能:向现有场景添加新订单
* orderId 会在方法内部自动生成 UUID
*
* @param sceneId 场景ID
* @param orderCode 订单编码
* @param materialId 物料ID
* @param startDate 开始时间
* @param endDate 结束时间
* @param priority 优先级
* @param quantity 数量
* @return 结果
*/
R
<
String
>
insertOrder
(
String
sceneId
,
String
orderCode
,
String
materialId
,
LocalDateTime
startDate
,
LocalDateTime
endDate
,
Integer
priority
,
Double
quantity
);
}
\ No newline at end of file
src/main/java/com/aps/service/common/ChromosomeDataService.java
View file @
247fcbd2
...
...
@@ -1169,6 +1169,13 @@ public class ChromosomeDataService {
config
.
setEntityName
(
entityName
);
config
.
setDataSource
(
DataSourceType
.
FILE
);
config
.
setFieldName
(
"Machines"
);
}
// 特殊处理:当实体是Order时,映射到orders字段
else
if
(
"order"
.
equalsIgnoreCase
(
key
))
{
config
=
new
EntityConfig
();
config
.
setEntityName
(
entityName
);
config
.
setDataSource
(
DataSourceType
.
FILE
);
config
.
setFieldName
(
"orders"
);
}
else
{
// 自动创建数据库配置(默认行为)
config
=
createDefaultDbConfig
(
entityName
);
...
...
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
View file @
247fcbd2
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/plan/LockedOrderProcessorService.java
0 → 100644
View file @
247fcbd2
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
247fcbd2
This diff is collapsed.
Click to expand it.
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