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
bf07ccef
Commit
bf07ccef
authored
Jan 27, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
info接口修改,增加订单供给关系接口
parent
5330e8fc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
516 additions
and
94 deletions
+516
-94
ResourceGanttController.java
...ava/com/aps/controller/gantt/ResourceGanttController.java
+26
-0
ChromosomeDataService.java
...in/java/com/aps/service/common/ChromosomeDataService.java
+262
-94
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+228
-0
No files found.
src/main/java/com/aps/controller/gantt/ResourceGanttController.java
View file @
bf07ccef
...
...
@@ -8,6 +8,7 @@ import com.aps.entity.Algorithm.Chromosome;
import
com.aps.entity.basic.ScheduleChromosome
;
import
com.aps.entity.Gantt.ProductGanttVO
;
import
com.aps.entity.Gantt.ResourceGanttVO
;
import
com.aps.entity.Gantt.SupplyRelationResponse
;
import
com.aps.entity.Gantt.TaskVO
;
import
com.aps.entity.basic.*
;
import
com.aps.service.plan.PlanResultService
;
...
...
@@ -875,5 +876,30 @@ public class ResourceGanttController {
return
R
.
ok
(
"工单拖拽排序成功"
);
}
@PostMapping
(
"/supplyRelation"
)
@Operation
(
summary
=
"获取供给关系"
,
description
=
"根据工单工序ID获取其供给关系"
,
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 \"entryId\": 472\n}"
)
)
)
)
public
R
<
SupplyRelationResponse
>
getSupplyRelation
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
log
.
info
(
"getSupplyRelation 请求参数: {}"
,
params
);
// 提取参数
String
sceneId
=
ParamValidator
.
getString
(
params
,
"sceneId"
,
"场景ID"
);
Integer
entryId
=
ParamValidator
.
getInteger
(
params
,
"entryId"
,
"工序ID"
);
ParamValidator
.
validateSceneExists
(
sceneService
,
sceneId
);
// 调用服务获取供给关系
List
<
Object
>
data
=
planResultService
.
getSupplyRelation
(
sceneId
,
entryId
,
sceneService
);
return
R
.
ok
(
SupplyRelationResponse
.
success
(
data
));
}
}
\ No newline at end of file
src/main/java/com/aps/service/common/ChromosomeDataService.java
View file @
bf07ccef
...
...
@@ -314,6 +314,42 @@ public class ChromosomeDataService {
public
List
<
FieldInfo
>
getEntityInfo
(
String
entityName
)
{
List
<
FieldInfo
>
fieldInfos
=
new
ArrayList
<>();
// 检查是否有对应的实体类
Class
<?>
entityClass
=
getEntityClass
(
entityName
);
if
(
entityClass
!=
null
)
{
// 通过反射获取所有字段(包括父类字段)
List
<
Field
>
fields
=
new
ArrayList
<>();
Class
<?>
currentClass
=
entityClass
;
while
(
currentClass
!=
null
&&
currentClass
!=
Object
.
class
)
{
fields
.
addAll
(
Arrays
.
asList
(
currentClass
.
getDeclaredFields
()));
currentClass
=
currentClass
.
getSuperclass
();
}
// 获取字段描述映射
Map
<
String
,
String
>
fieldDescriptions
=
getFieldDescriptions
(
entityName
);
// 遍历字段,生成FieldInfo
for
(
Field
field
:
fields
)
{
// 跳过静态字段
if
(
Modifier
.
isStatic
(
field
.
getModifiers
()))
{
continue
;
}
FieldInfo
fieldInfo
=
new
FieldInfo
();
fieldInfo
.
setFieldName
(
field
.
getName
());
fieldInfo
.
setFieldType
(
field
.
getType
().
getSimpleName
());
// 设置字段描述
fieldInfo
.
setDescription
(
fieldDescriptions
.
getOrDefault
(
field
.
getName
(),
""
));
fieldInfo
.
setDataSource
(
"ENTITY"
);
fieldInfo
.
setEntityName
(
entityName
);
fieldInfos
.
add
(
fieldInfo
);
}
return
fieldInfos
;
}
// 获取实体配置
EntityConfig
config
=
getEntityConfig
(
entityName
);
...
...
@@ -330,16 +366,16 @@ public class ChromosomeDataService {
fileEntityClassMap
.
put
(
"groupresult"
,
GroupResult
.
class
);
// 获取实体类
Class
<?>
e
ntityClass
=
fileEntityClassMap
.
get
(
entityName
.
toLowerCase
());
Class
<?>
fileE
ntityClass
=
fileEntityClassMap
.
get
(
entityName
.
toLowerCase
());
// 如果没有找到实体类,返回空列表
if
(
e
ntityClass
==
null
)
{
if
(
fileE
ntityClass
==
null
)
{
return
fieldInfos
;
}
// 通过反射获取所有字段(包括父类字段)
List
<
Field
>
fields
=
new
ArrayList
<>();
Class
<?>
currentClass
=
e
ntityClass
;
Class
<?>
currentClass
=
fileE
ntityClass
;
while
(
currentClass
!=
null
&&
currentClass
!=
Object
.
class
)
{
fields
.
addAll
(
Arrays
.
asList
(
currentClass
.
getDeclaredFields
()));
currentClass
=
currentClass
.
getSuperclass
();
...
...
@@ -386,7 +422,8 @@ public class ChromosomeDataService {
while
(
columns
.
next
())
{
FieldInfo
fieldInfo
=
new
FieldInfo
();
fieldInfo
.
setFieldName
(
columns
.
getString
(
"COLUMN_NAME"
));
fieldInfo
.
setFieldType
(
columns
.
getString
(
"TYPE_NAME"
));
// 将数据库字段类型转换为Java类型
fieldInfo
.
setFieldType
(
mapDbTypeToJavaType
(
columns
.
getString
(
"TYPE_NAME"
)));
fieldInfo
.
setDescription
(
columns
.
getString
(
"REMARKS"
));
fieldInfo
.
setDataSource
(
config
.
getDataSource
().
name
());
fieldInfo
.
setEntityName
(
entityName
);
...
...
@@ -405,6 +442,54 @@ public class ChromosomeDataService {
return
fieldInfos
;
}
/**
* 获取实体对应的Java类
* @param entityName 实体名称
* @return 实体类,无对应类时返回null
*/
private
Class
<?>
getEntityClass
(
String
entityName
)
{
// 实体类映射
Map
<
String
,
Class
<?>>
entityClassMap
=
new
HashMap
<>();
// 数据库实体类映射
entityClassMap
.
put
(
"materialinfo"
,
MaterialInfo
.
class
);
// 文件实体类映射
entityClassMap
.
put
(
"order"
,
Order
.
class
);
entityClassMap
.
put
(
"entry"
,
Entry
.
class
);
entityClassMap
.
put
(
"machine"
,
Machine
.
class
);
entityClassMap
.
put
(
"machineoption"
,
MachineOption
.
class
);
entityClassMap
.
put
(
"prodprocessexec"
,
ProdProcessExec
.
class
);
entityClassMap
.
put
(
"globaloperationinfo"
,
GlobalOperationInfo
.
class
);
entityClassMap
.
put
(
"groupresult"
,
GroupResult
.
class
);
return
entityClassMap
.
get
(
entityName
.
toLowerCase
());
}
/**
* 将数据库字段类型转换为Java类型
* @param dbType 数据库字段类型
* @return Java类型
*/
private
String
mapDbTypeToJavaType
(
String
dbType
)
{
// 简单的类型映射
Map
<
String
,
String
>
typeMap
=
new
HashMap
<>();
typeMap
.
put
(
"VARCHAR"
,
"String"
);
typeMap
.
put
(
"NVARCHAR"
,
"String"
);
typeMap
.
put
(
"CHAR"
,
"String"
);
typeMap
.
put
(
"TEXT"
,
"String"
);
typeMap
.
put
(
"NUMBER"
,
"Integer"
);
typeMap
.
put
(
"INT"
,
"Integer"
);
typeMap
.
put
(
"INTEGER"
,
"Integer"
);
typeMap
.
put
(
"BIGINT"
,
"Long"
);
typeMap
.
put
(
"FLOAT"
,
"Float"
);
typeMap
.
put
(
"DOUBLE"
,
"Double"
);
typeMap
.
put
(
"DECIMAL"
,
"BigDecimal"
);
typeMap
.
put
(
"BOOLEAN"
,
"Boolean"
);
typeMap
.
put
(
"DATE"
,
"Date"
);
typeMap
.
put
(
"TIMESTAMP"
,
"Timestamp"
);
return
typeMap
.
getOrDefault
(
dbType
.
toUpperCase
(),
dbType
);
}
/**
* 获取指定实体的字段描述映射
* @param entityName 实体名称
...
...
@@ -413,57 +498,138 @@ public class ChromosomeDataService {
private
Map
<
String
,
String
>
getFieldDescriptions
(
String
entityName
)
{
Map
<
String
,
String
>
fieldDescriptions
=
new
HashMap
<>();
// 根据实体名称返回对应的字段描述
switch
(
entityName
.
toLowerCase
())
{
case
"order"
:
// Order实体字段描述
fieldDescriptions
.
put
(
"id"
,
"自增主键"
);
fieldDescriptions
.
put
(
"orderId"
,
"订单ID"
);
fieldDescriptions
.
put
(
"orderCode"
,
"订单编码"
);
fieldDescriptions
.
put
(
"productId"
,
"产品ID"
);
fieldDescriptions
.
put
(
"materialId"
,
"物料ID"
);
fieldDescriptions
.
put
(
"materialCode"
,
"物料编码"
);
fieldDescriptions
.
put
(
"materialName"
,
"物料名称"
);
fieldDescriptions
.
put
(
"serie"
,
"系列"
);
fieldDescriptions
.
put
(
"routingId"
,
"工艺路线ID"
);
fieldDescriptions
.
put
(
"routingCode"
,
"工艺路线编码"
);
fieldDescriptions
.
put
(
"quantity"
,
"订单数量,默认值:100"
);
fieldDescriptions
.
put
(
"sYQuantity"
,
"生产数量"
);
fieldDescriptions
.
put
(
"startDate"
,
"开始日期"
);
fieldDescriptions
.
put
(
"dueDate"
,
"到期日期"
);
fieldDescriptions
.
put
(
"groupStartDate"
,
"组开始日期"
);
fieldDescriptions
.
put
(
"groupDueDate"
,
"组到期日期"
);
fieldDescriptions
.
put
(
"orderCompletion"
,
"订单完成时间"
);
fieldDescriptions
.
put
(
"orderStart"
,
"订单开始时间"
);
fieldDescriptions
.
put
(
"machineProcessingTime"
,
"机器加工时间"
);
fieldDescriptions
.
put
(
"orderFlow"
,
"订单流程"
);
fieldDescriptions
.
put
(
"orderProductTime"
,
"订单生产时间"
);
fieldDescriptions
.
put
(
"tardiness"
,
"延误时间"
);
fieldDescriptions
.
put
(
"priority"
,
"优先级"
);
fieldDescriptions
.
put
(
"canSplit"
,
"是否可拆分,默认值:false"
);
fieldDescriptions
.
put
(
"canInterrupt"
,
"是否可中断,默认值:false"
);
fieldDescriptions
.
put
(
"actualPriority"
,
"实际优先级"
);
fieldDescriptions
.
put
(
"mainId"
,
"主ID"
);
fieldDescriptions
.
put
(
"FinishOrderId"
,
"使用这个半成品的成品工单"
);
fieldDescriptions
.
put
(
"newCreate"
,
"是否新创建,默认值:false"
);
fieldDescriptions
.
put
(
"createBom"
,
"是否创建BOM,默认值:false"
);
fieldDescriptions
.
put
(
"TargetFinishedOperationId"
,
"关联的成品工序ID(核心:明确该半成品服务于哪个成品工序)"
);
fieldDescriptions
.
put
(
"delayHours"
,
"延迟时间"
);
fieldDescriptions
.
put
(
"materialRequirementList"
,
"物料需求"
);
break
;
// 可以继续添加其他实体的字段描述
case
"entry"
:
// Entry实体字段描述
// 后续可以补充
break
;
case
"machine"
:
// Machine实体字段描述
// 后续可以补充
break
;
// 首先尝试从实体类注解和JavaDoc注释中提取字段描述
Class
<?>
entityClass
=
getEntityClass
(
entityName
);
if
(
entityClass
!=
null
)
{
// 通过反射获取所有字段(包括父类字段)
List
<
Field
>
fields
=
new
ArrayList
<>();
Class
<?>
currentClass
=
entityClass
;
while
(
currentClass
!=
null
&&
currentClass
!=
Object
.
class
)
{
fields
.
addAll
(
Arrays
.
asList
(
currentClass
.
getDeclaredFields
()));
currentClass
=
currentClass
.
getSuperclass
();
}
// 提取字段注释
for
(
Field
field
:
fields
)
{
// 3. 尝试从JavaDoc注释中提取描述
String
javaDocComment
=
getJavaDocComment
(
entityClass
,
field
.
getName
());
if
(
javaDocComment
!=
null
&&
!
javaDocComment
.
isEmpty
()
&&
!
fieldDescriptions
.
containsKey
(
field
.
getName
()))
{
fieldDescriptions
.
put
(
field
.
getName
(),
javaDocComment
);
}
}
// 如果成功提取到字段描述,直接返回
if
(!
fieldDescriptions
.
isEmpty
())
{
return
fieldDescriptions
;
}
}
//
// // 传统方式:手动维护字段描述(作为备用)
// switch (entityName.toLowerCase()) {
// case "order":
// // Order实体字段描述
// fieldDescriptions.put("id", "自增主键");
// fieldDescriptions.put("orderId", "订单ID");
// fieldDescriptions.put("orderCode", "订单编码");
// fieldDescriptions.put("productId", "产品ID");
// fieldDescriptions.put("materialId", "物料ID");
// fieldDescriptions.put("materialCode", "物料编码");
// fieldDescriptions.put("materialName", "物料名称");
// fieldDescriptions.put("serie", "系列");
// fieldDescriptions.put("routingId", "工艺路线ID");
// fieldDescriptions.put("routingCode", "工艺路线编码");
// fieldDescriptions.put("quantity", "订单数量,默认值:100");
// fieldDescriptions.put("sYQuantity", "生产数量");
// fieldDescriptions.put("startDate", "开始日期");
// fieldDescriptions.put("dueDate", "到期日期");
// fieldDescriptions.put("groupStartDate", "组开始日期");
// fieldDescriptions.put("groupDueDate", "组到期日期");
// fieldDescriptions.put("orderCompletion", "订单完成时间");
// fieldDescriptions.put("orderStart", "订单开始时间");
// fieldDescriptions.put("machineProcessingTime", "机器加工时间");
// fieldDescriptions.put("orderFlow", "订单流程");
// fieldDescriptions.put("orderProductTime", "订单生产时间");
// fieldDescriptions.put("tardiness", "延误时间");
// fieldDescriptions.put("priority", "优先级");
// fieldDescriptions.put("canSplit", "是否可拆分,默认值:false");
// fieldDescriptions.put("canInterrupt", "是否可中断,默认值:false");
// fieldDescriptions.put("actualPriority", "实际优先级");
// fieldDescriptions.put("mainId", "主ID");
// fieldDescriptions.put("FinishOrderId", "使用这个半成品的成品工单");
// fieldDescriptions.put("newCreate", "是否新创建,默认值:false");
// fieldDescriptions.put("createBom", "是否创建BOM,默认值:false");
// fieldDescriptions.put("TargetFinishedOperationId", "关联的成品工序ID(核心:明确该半成品服务于哪个成品工序)");
// fieldDescriptions.put("delayHours", "延迟时间");
// fieldDescriptions.put("materialRequirementList", "物料需求");
// break;
// // 可以继续添加其他实体的字段描述
// case "entry":
// // Entry实体字段描述
// // 后续可以补充
// break;
// case "machine":
// // Machine实体字段描述
// // 后续可以补充
// break;
// }
return
fieldDescriptions
;
}
/**
* 尝试从JavaDoc注释中提取字段描述
* @param entityClass 实体类
* @param fieldName 字段名
* @return 字段描述,提取失败返回null
*/
private
String
getJavaDocComment
(
Class
<?>
entityClass
,
String
fieldName
)
{
try
{
// 这里使用简单的方式模拟JavaDoc注释提取
// 实际项目中可以使用JavaDoc API或第三方库来解析
Map
<
String
,
String
>
orderFieldComments
=
new
HashMap
<>();
orderFieldComments
.
put
(
"id"
,
"自增主键"
);
orderFieldComments
.
put
(
"orderId"
,
"订单ID"
);
orderFieldComments
.
put
(
"orderCode"
,
"订单编码"
);
orderFieldComments
.
put
(
"productId"
,
"产品ID"
);
orderFieldComments
.
put
(
"materialId"
,
"物料ID"
);
orderFieldComments
.
put
(
"materialCode"
,
"物料编码"
);
orderFieldComments
.
put
(
"materialName"
,
"物料名称"
);
orderFieldComments
.
put
(
"serie"
,
"系列"
);
orderFieldComments
.
put
(
"routingId"
,
"工艺路线ID"
);
orderFieldComments
.
put
(
"routingCode"
,
"工艺路线编码"
);
orderFieldComments
.
put
(
"quantity"
,
"订单数量,默认值:100"
);
orderFieldComments
.
put
(
"sYQuantity"
,
"生产数量"
);
orderFieldComments
.
put
(
"startDate"
,
"开始日期"
);
orderFieldComments
.
put
(
"dueDate"
,
"到期日期"
);
orderFieldComments
.
put
(
"groupStartDate"
,
"组开始日期"
);
orderFieldComments
.
put
(
"groupDueDate"
,
"组到期日期"
);
orderFieldComments
.
put
(
"orderCompletion"
,
"订单完成时间"
);
orderFieldComments
.
put
(
"orderStart"
,
"订单开始时间"
);
orderFieldComments
.
put
(
"machineProcessingTime"
,
"机器加工时间"
);
orderFieldComments
.
put
(
"orderFlow"
,
"订单流程"
);
orderFieldComments
.
put
(
"orderProductTime"
,
"订单生产时间"
);
orderFieldComments
.
put
(
"tardiness"
,
"延误时间"
);
orderFieldComments
.
put
(
"priority"
,
"优先级"
);
orderFieldComments
.
put
(
"canSplit"
,
"是否可拆分,默认值:false"
);
orderFieldComments
.
put
(
"canInterrupt"
,
"是否可中断,默认值:false"
);
orderFieldComments
.
put
(
"actualPriority"
,
"实际优先级"
);
orderFieldComments
.
put
(
"mainId"
,
"主ID"
);
orderFieldComments
.
put
(
"FinishOrderId"
,
"使用这个半成品的成品工单"
);
orderFieldComments
.
put
(
"newCreate"
,
"是否新创建,默认值:false"
);
orderFieldComments
.
put
(
"createBom"
,
"是否创建BOM,默认值:false"
);
orderFieldComments
.
put
(
"TargetFinishedOperationId"
,
"关联的成品工序ID(核心:明确该半成品服务于哪个成品工序)"
);
orderFieldComments
.
put
(
"delayHours"
,
"延迟时间"
);
orderFieldComments
.
put
(
"materialRequirementList"
,
"物料需求"
);
return
orderFieldComments
.
get
(
fieldName
);
}
catch
(
Exception
e
)
{
log
.
error
(
"提取JavaDoc注释失败: {}"
,
e
.
getMessage
(),
e
);
return
null
;
}
}
/**
* 创建空的分页结果
*/
...
...
@@ -1023,6 +1189,8 @@ public class ChromosomeDataService {
filteredMachine
.
setActualWorkTime
(
originalMachine
.
getActualWorkTime
());
filteredMachine
.
setRate
(
originalMachine
.
getRate
());
filteredMachine
.
setDepartment
(
originalMachine
.
getDepartment
());
filteredMachine
.
setShifts
(
originalMachine
.
getShifts
());
filteredMachine
.
setAvailability
(
originalMachine
.
getAvailability
());
// 不设置不需要的字段:shifts, maintenanceWindows, availability, holidays, shiftsChanged, maintenanceWindowsChanged
return
filteredMachine
;
}
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
bf07ccef
...
...
@@ -34,7 +34,10 @@ import java.util.*;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.Comparator
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Service
public
class
PlanResultService
{
// 注入FileUploadController
...
...
@@ -1443,6 +1446,231 @@ private GlobalParam InitGlobalParam()
return
materials
;
}
/**
* 获取供给关系
* @param sceneId 场景ID
* @param entryId 工序ID
* @param sceneService 场景服务
* @return 供给关系列表
*/
public
List
<
Object
>
getSupplyRelation
(
String
sceneId
,
Integer
entryId
,
SceneService
sceneService
)
{
List
<
Object
>
supplyRelations
=
new
ArrayList
<>();
try
{
Chromosome
chromosome
=
sceneService
.
loadChromosomeFromFile
(
sceneId
);
if
(
chromosome
==
null
||
chromosome
.
getAllOperations
()
==
null
)
return
supplyRelations
;
List
<
Entry
>
entries
=
chromosome
.
getAllOperations
();
List
<
Order
>
orders
=
chromosome
.
getOrders
();
List
<
GAScheduleResult
>
results
=
chromosome
.
getResult
();
LocalDateTime
baseTime
=
chromosome
.
getBaseTime
();
Entry
currentEntry
=
entries
.
stream
().
filter
(
e
->
e
.
getId
()
==
entryId
).
findFirst
().
orElse
(
null
);
if
(
currentEntry
!=
null
)
{
// 处理DependentOnOrderIds
if
(
currentEntry
.
getDependentOnOrderIds
()
!=
null
&&
!
currentEntry
.
getDependentOnOrderIds
().
isEmpty
())
{
for
(
Integer
orderId
:
currentEntry
.
getDependentOnOrderIds
())
{
// 首先找到对应的Order对象
Order
targetOrder
;
if
(
orders
!=
null
)
{
targetOrder
=
orders
.
stream
().
filter
(
o
->
o
.
getId
()
==
orderId
).
findFirst
().
orElse
(
null
);
}
else
{
targetOrder
=
null
;
}
// 如果找到了Order对象,再找到对应的Entry
if
(
targetOrder
!=
null
)
{
// 找到该订单的所有工序
List
<
Entry
>
orderEntries
=
entries
.
stream
()
.
filter
(
e
->
e
.
getOrderId
()
!=
null
&&
e
.
getOrderId
().
equals
(
targetOrder
.
getOrderId
()))
.
collect
(
Collectors
.
toList
());
if
(!
orderEntries
.
isEmpty
())
{
// 找到该订单的最后一道工序(按Sequence排序)
Entry
lastEntry
=
orderEntries
.
stream
()
.
max
(
Comparator
.
comparingInt
(
Entry:
:
getSequence
))
.
orElse
(
null
);
if
(
lastEntry
!=
null
)
{
// 找到当前工序的开始时间
LocalDateTime
currentStartTime
=
getEntryStartTime
(
currentEntry
,
results
,
baseTime
);
// 找到上一道工序的结束时间
LocalDateTime
lastEntryEndTime
=
getEntryEndTime
(
lastEntry
,
results
,
baseTime
);
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"taskIdFrom"
,
String
.
valueOf
(
lastEntry
.
getId
()));
item
.
put
(
"taskIdTo"
,
String
.
valueOf
(
currentEntry
.
getId
()));
item
.
put
(
"fromTime"
,
lastEntryEndTime
!=
null
?
lastEntryEndTime
.
toString
()
:
"2025-12-13"
);
item
.
put
(
"toTime"
,
currentStartTime
!=
null
?
currentStartTime
.
toString
()
:
"2026-12-13"
);
item
.
put
(
"fromIdFrom"
,
String
.
valueOf
(
lastEntry
.
getId
()));
item
.
put
(
"toIdTo"
,
currentEntry
.
getId
());
supplyRelations
.
add
(
item
);
// 递归检查上一个订单的依赖关系
checkAndAddDependentRelations
(
entries
,
orders
,
results
,
baseTime
,
lastEntry
,
supplyRelations
);
}
}
}
}
}
// 处理TargetFinishedOperationId
if
(
currentEntry
.
getTargetFinishedOperationId
()
!=
null
&&
!
currentEntry
.
getTargetFinishedOperationId
().
isEmpty
())
{
for
(
Integer
targetId
:
currentEntry
.
getTargetFinishedOperationId
())
{
Entry
targetEntry
=
entries
.
stream
().
filter
(
e
->
e
.
getId
()
==
targetId
).
findFirst
().
orElse
(
null
);
if
(
targetEntry
!=
null
)
{
// 找到当前工序的结束时间
LocalDateTime
currentEndTime
=
getEntryEndTime
(
currentEntry
,
results
,
baseTime
);
// 找到目标工序的开始时间
LocalDateTime
targetStartTime
=
getEntryStartTime
(
targetEntry
,
results
,
baseTime
);
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"taskIdFrom"
,
String
.
valueOf
(
currentEntry
.
getId
()));
item
.
put
(
"taskIdTo"
,
String
.
valueOf
(
targetEntry
.
getId
()));
item
.
put
(
"fromTime"
,
currentEndTime
!=
null
?
currentEndTime
.
toString
()
:
"2025-12-13"
);
item
.
put
(
"toTime"
,
targetStartTime
!=
null
?
targetStartTime
.
toString
()
:
"2026-12-13"
);
item
.
put
(
"fromIdFrom"
,
String
.
valueOf
(
currentEntry
.
getId
()));
item
.
put
(
"toIdTo"
,
targetEntry
.
getId
());
supplyRelations
.
add
(
item
);
checkAndAddTargetRelations
(
entries
,
results
,
baseTime
,
targetEntry
,
supplyRelations
);
// 检查后置工序
}
}
}
// 添加from和to对象结构
Map
<
String
,
Object
>
item2
=
new
HashMap
<>();
item2
.
put
(
"from"
,
new
HashMap
<>());
item2
.
put
(
"to"
,
new
HashMap
<>());
supplyRelations
.
add
(
item2
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"获取供给关系失败: {}"
,
e
.
getMessage
(),
e
);
}
return
supplyRelations
;
}
/**
* 获取工单的开始时间
* @param entry 工单
* @param results 调度结果列表
* @param baseTime 基准时间
* @return 开始时间
*/
private
LocalDateTime
getEntryStartTime
(
Entry
entry
,
List
<
GAScheduleResult
>
results
,
LocalDateTime
baseTime
)
{
if
(
results
==
null
||
baseTime
==
null
)
return
null
;
GAScheduleResult
result
=
results
.
stream
()
.
filter
(
r
->
r
.
getOperationId
()
==
entry
.
getId
())
.
findFirst
()
.
orElse
(
null
);
if
(
result
!=
null
)
{
return
baseTime
.
plusSeconds
(
result
.
getStartTime
());
}
return
null
;
}
/**
* 获取工单的结束时间
* @param entry 工单
* @param results 调度结果列表
* @param baseTime 基准时间
* @return 结束时间
*/
private
LocalDateTime
getEntryEndTime
(
Entry
entry
,
List
<
GAScheduleResult
>
results
,
LocalDateTime
baseTime
)
{
if
(
results
==
null
||
baseTime
==
null
)
return
null
;
GAScheduleResult
result
=
results
.
stream
()
.
filter
(
r
->
r
.
getOperationId
()
==
entry
.
getId
())
.
findFirst
()
.
orElse
(
null
);
if
(
result
!=
null
)
{
return
baseTime
.
plusSeconds
(
result
.
getEndTime
());
}
return
null
;
}
/**
* 递归检查并添加依赖关系
* @param entries 所有工序列表
* @param orders 所有订单列表
* @param results 调度结果列表
* @param baseTime 基准时间
* @param currentEntry 当前工序
* @param supplyRelations 供给关系列表
*/
private
void
checkAndAddDependentRelations
(
List
<
Entry
>
entries
,
List
<
Order
>
orders
,
List
<
GAScheduleResult
>
results
,
LocalDateTime
baseTime
,
Entry
currentEntry
,
List
<
Object
>
supplyRelations
)
{
if
(
currentEntry
.
getDependentOnOrderIds
()
!=
null
&&
!
currentEntry
.
getDependentOnOrderIds
().
isEmpty
())
{
for
(
Integer
orderId
:
currentEntry
.
getDependentOnOrderIds
())
{
// 首先找到对应的Order对象
Order
targetOrder
;
if
(
orders
!=
null
)
{
targetOrder
=
orders
.
stream
().
filter
(
o
->
o
.
getId
()
==
orderId
).
findFirst
().
orElse
(
null
);
}
else
{
targetOrder
=
null
;
}
// 如果找到了Order对象,再找到对应的Entry
if
(
targetOrder
!=
null
)
{
// 找到该订单的所有工序
List
<
Entry
>
orderEntries
=
entries
.
stream
()
.
filter
(
e
->
e
.
getOrderId
()
!=
null
&&
e
.
getOrderId
().
equals
(
targetOrder
.
getOrderId
()))
.
collect
(
Collectors
.
toList
());
if
(!
orderEntries
.
isEmpty
())
{
// 找到该订单的最后一道工序(按Sequence排序)
Entry
lastEntry
=
orderEntries
.
stream
()
.
max
(
Comparator
.
comparingInt
(
Entry:
:
getSequence
))
.
orElse
(
null
);
if
(
lastEntry
!=
null
)
{
// 找到当前工序的开始时间
LocalDateTime
currentStartTime
=
getEntryStartTime
(
currentEntry
,
results
,
baseTime
);
// 找到上一道工序的结束时间
LocalDateTime
lastEntryEndTime
=
getEntryEndTime
(
lastEntry
,
results
,
baseTime
);
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"taskIdFrom"
,
String
.
valueOf
(
lastEntry
.
getId
()));
item
.
put
(
"taskIdTo"
,
String
.
valueOf
(
currentEntry
.
getId
()));
item
.
put
(
"fromTime"
,
lastEntryEndTime
!=
null
?
lastEntryEndTime
.
toString
()
:
"2025-12-13"
);
item
.
put
(
"toTime"
,
currentStartTime
!=
null
?
currentStartTime
.
toString
()
:
"2026-12-13"
);
item
.
put
(
"fromIdFrom"
,
String
.
valueOf
(
lastEntry
.
getId
()));
item
.
put
(
"toIdTo"
,
currentEntry
.
getId
());
supplyRelations
.
add
(
item
);
// 递归调用,处理上一个订单的最后一道工序的依赖关系
checkAndAddDependentRelations
(
entries
,
orders
,
results
,
baseTime
,
lastEntry
,
supplyRelations
);
}
}
}
}
}
}
/**
* 递归检查并添加目标关系
* @param entries 所有工序列表
* @param results 调度结果列表
* @param baseTime 基准时间
* @param currentEntry 当前工序
* @param supplyRelations 供给关系列表
*/
private
void
checkAndAddTargetRelations
(
List
<
Entry
>
entries
,
List
<
GAScheduleResult
>
results
,
LocalDateTime
baseTime
,
Entry
currentEntry
,
List
<
Object
>
supplyRelations
)
{
if
(
currentEntry
.
getTargetFinishedOperationId
()
!=
null
&&
!
currentEntry
.
getTargetFinishedOperationId
().
isEmpty
())
{
for
(
Integer
targetId
:
currentEntry
.
getTargetFinishedOperationId
())
{
Entry
targetEntry
=
entries
.
stream
().
filter
(
e
->
e
.
getId
()
==
targetId
).
findFirst
().
orElse
(
null
);
if
(
targetEntry
!=
null
)
{
// 找到当前工序的结束时间
LocalDateTime
currentEndTime
=
getEntryEndTime
(
currentEntry
,
results
,
baseTime
);
// 找到目标工序的开始时间
LocalDateTime
targetStartTime
=
getEntryStartTime
(
targetEntry
,
results
,
baseTime
);
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"taskIdFrom"
,
String
.
valueOf
(
currentEntry
.
getId
()));
item
.
put
(
"taskIdTo"
,
String
.
valueOf
(
targetEntry
.
getId
()));
item
.
put
(
"fromTime"
,
currentEndTime
!=
null
?
currentEndTime
.
toString
()
:
"2025-12-13"
);
item
.
put
(
"toTime"
,
targetStartTime
!=
null
?
targetStartTime
.
toString
()
:
"2026-12-13"
);
item
.
put
(
"fromIdFrom"
,
String
.
valueOf
(
currentEntry
.
getId
()));
item
.
put
(
"toIdTo"
,
targetEntry
.
getId
());
supplyRelations
.
add
(
item
);
checkAndAddTargetRelations
(
entries
,
results
,
baseTime
,
targetEntry
,
supplyRelations
);
// 递归调用
}
}
}
}
private
Map
<
Integer
,
Object
>
InitEntrys
(
String
SceneId
,
List
<
ProdEquipment
>
ProdEquipments
,
List
<
Order
>
ProdLaunchOrders
)
{
FileHelper
.
writeLogFile
(
"初始化工单-----------开始-------"
);
...
...
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