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
Hide 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;
...
@@ -8,6 +8,7 @@ import com.aps.entity.Algorithm.Chromosome;
import
com.aps.entity.basic.ScheduleChromosome
;
import
com.aps.entity.basic.ScheduleChromosome
;
import
com.aps.entity.Gantt.ProductGanttVO
;
import
com.aps.entity.Gantt.ProductGanttVO
;
import
com.aps.entity.Gantt.ResourceGanttVO
;
import
com.aps.entity.Gantt.ResourceGanttVO
;
import
com.aps.entity.Gantt.SupplyRelationResponse
;
import
com.aps.entity.Gantt.TaskVO
;
import
com.aps.entity.Gantt.TaskVO
;
import
com.aps.entity.basic.*
;
import
com.aps.entity.basic.*
;
import
com.aps.service.plan.PlanResultService
;
import
com.aps.service.plan.PlanResultService
;
...
@@ -875,5 +876,30 @@ public class ResourceGanttController {
...
@@ -875,5 +876,30 @@ public class ResourceGanttController {
return
R
.
ok
(
"工单拖拽排序成功"
);
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
...
@@ -56,7 +56,7 @@ public class ChromosomeDataService {
...
@@ -56,7 +56,7 @@ public class ChromosomeDataService {
@Autowired
@Autowired
private
NamedParameterJdbcTemplate
namedParameterJdbcTemplate
;
private
NamedParameterJdbcTemplate
namedParameterJdbcTemplate
;
@Autowired
@Autowired
private
JdbcTemplate
jdbcTemplate
;
private
JdbcTemplate
jdbcTemplate
;
...
@@ -115,7 +115,7 @@ public class ChromosomeDataService {
...
@@ -115,7 +115,7 @@ public class ChromosomeDataService {
return
result
.
toString
();
return
result
.
toString
();
}
}
/**
/**
* 查询当前场景排产的成品/半成品物料信息
* 查询当前场景排产的成品/半成品物料信息
*/
*/
...
@@ -173,7 +173,7 @@ public class ChromosomeDataService {
...
@@ -173,7 +173,7 @@ public class ChromosomeDataService {
String
[]
parts
=
sortBy
.
split
(
" "
);
String
[]
parts
=
sortBy
.
split
(
" "
);
String
fieldName
=
parts
[
0
];
String
fieldName
=
parts
[
0
];
boolean
isAsc
=
parts
.
length
<=
1
||
!
"desc"
.
equalsIgnoreCase
(
parts
[
1
]);
boolean
isAsc
=
parts
.
length
<=
1
||
!
"desc"
.
equalsIgnoreCase
(
parts
[
1
]);
// 根据字段名添加排序
// 根据字段名添加排序
switch
(
fieldName
.
toLowerCase
())
{
switch
(
fieldName
.
toLowerCase
())
{
case
"id"
:
case
"id"
:
...
@@ -196,7 +196,7 @@ public class ChromosomeDataService {
...
@@ -196,7 +196,7 @@ public class ChromosomeDataService {
// 查询数据
// 查询数据
List
<
MaterialInfo
>
materialInfos
;
List
<
MaterialInfo
>
materialInfos
;
long
total
=
0
;
long
total
=
0
;
if
(
paged
.
getPageSize
()
>
0
)
{
if
(
paged
.
getPageSize
()
>
0
)
{
// Oracle分页查询 - 使用MyBatis-Plus的Page对象
// Oracle分页查询 - 使用MyBatis-Plus的Page对象
Page
<
MaterialInfo
>
page
=
new
Page
<>(
paged
.
getPageIndex
(),
paged
.
getPageSize
());
Page
<
MaterialInfo
>
page
=
new
Page
<>(
paged
.
getPageIndex
(),
paged
.
getPageSize
());
...
@@ -210,7 +210,7 @@ public class ChromosomeDataService {
...
@@ -210,7 +210,7 @@ public class ChromosomeDataService {
// 将总数存储到paged对象中,供buildPageResult使用
// 将总数存储到paged对象中,供buildPageResult使用
paged
.
setTotal
((
int
)
total
);
paged
.
setTotal
((
int
)
total
);
return
materialInfos
;
return
materialInfos
;
}
}
...
@@ -283,9 +283,9 @@ public class ChromosomeDataService {
...
@@ -283,9 +283,9 @@ public class ChromosomeDataService {
LambdaQueryWrapper
<
MaterialInfo
>
wrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
MaterialInfo
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
MaterialInfo:
:
getId
,
id
)
wrapper
.
eq
(
MaterialInfo:
:
getId
,
id
)
.
eq
(
MaterialInfo:
:
getIsdeleted
,
0
);
.
eq
(
MaterialInfo:
:
getIsdeleted
,
0
);
MaterialInfo
materialInfo
=
materialInfoService
.
getOne
(
wrapper
);
MaterialInfo
materialInfo
=
materialInfoService
.
getOne
(
wrapper
);
return
materialInfo
;
return
materialInfo
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -313,10 +313,46 @@ public class ChromosomeDataService {
...
@@ -313,10 +313,46 @@ public class ChromosomeDataService {
*/
*/
public
List
<
FieldInfo
>
getEntityInfo
(
String
entityName
)
{
public
List
<
FieldInfo
>
getEntityInfo
(
String
entityName
)
{
List
<
FieldInfo
>
fieldInfos
=
new
ArrayList
<>();
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
);
EntityConfig
config
=
getEntityConfig
(
entityName
);
// 处理文件实体
// 处理文件实体
if
(
config
.
getDataSource
()
==
DataSourceType
.
FILE
)
{
if
(
config
.
getDataSource
()
==
DataSourceType
.
FILE
)
{
// 实体类映射
// 实体类映射
...
@@ -328,46 +364,46 @@ public class ChromosomeDataService {
...
@@ -328,46 +364,46 @@ public class ChromosomeDataService {
fileEntityClassMap
.
put
(
"prodprocessexec"
,
ProdProcessExec
.
class
);
fileEntityClassMap
.
put
(
"prodprocessexec"
,
ProdProcessExec
.
class
);
fileEntityClassMap
.
put
(
"globaloperationinfo"
,
GlobalOperationInfo
.
class
);
fileEntityClassMap
.
put
(
"globaloperationinfo"
,
GlobalOperationInfo
.
class
);
fileEntityClassMap
.
put
(
"groupresult"
,
GroupResult
.
class
);
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
;
return
fieldInfos
;
}
}
// 通过反射获取所有字段(包括父类字段)
// 通过反射获取所有字段(包括父类字段)
List
<
Field
>
fields
=
new
ArrayList
<>();
List
<
Field
>
fields
=
new
ArrayList
<>();
Class
<?>
currentClass
=
e
ntityClass
;
Class
<?>
currentClass
=
fileE
ntityClass
;
while
(
currentClass
!=
null
&&
currentClass
!=
Object
.
class
)
{
while
(
currentClass
!=
null
&&
currentClass
!=
Object
.
class
)
{
fields
.
addAll
(
Arrays
.
asList
(
currentClass
.
getDeclaredFields
()));
fields
.
addAll
(
Arrays
.
asList
(
currentClass
.
getDeclaredFields
()));
currentClass
=
currentClass
.
getSuperclass
();
currentClass
=
currentClass
.
getSuperclass
();
}
}
// 获取字段描述映射
// 获取字段描述映射
Map
<
String
,
String
>
fieldDescriptions
=
getFieldDescriptions
(
entityName
);
Map
<
String
,
String
>
fieldDescriptions
=
getFieldDescriptions
(
entityName
);
// 遍历字段,生成FieldInfo
// 遍历字段,生成FieldInfo
for
(
Field
field
:
fields
)
{
for
(
Field
field
:
fields
)
{
// 跳过静态字段
// 跳过静态字段
if
(
Modifier
.
isStatic
(
field
.
getModifiers
()))
{
if
(
Modifier
.
isStatic
(
field
.
getModifiers
()))
{
continue
;
continue
;
}
}
FieldInfo
fieldInfo
=
new
FieldInfo
();
FieldInfo
fieldInfo
=
new
FieldInfo
();
fieldInfo
.
setFieldName
(
field
.
getName
());
fieldInfo
.
setFieldName
(
field
.
getName
());
fieldInfo
.
setFieldType
(
field
.
getType
().
getSimpleName
());
fieldInfo
.
setFieldType
(
field
.
getType
().
getSimpleName
());
// 设置字段描述
// 设置字段描述
fieldInfo
.
setDescription
(
fieldDescriptions
.
getOrDefault
(
field
.
getName
(),
""
));
fieldInfo
.
setDescription
(
fieldDescriptions
.
getOrDefault
(
field
.
getName
(),
""
));
fieldInfo
.
setDataSource
(
config
.
getDataSource
().
name
());
fieldInfo
.
setDataSource
(
config
.
getDataSource
().
name
());
fieldInfo
.
setEntityName
(
entityName
);
fieldInfo
.
setEntityName
(
entityName
);
fieldInfos
.
add
(
fieldInfo
);
fieldInfos
.
add
(
fieldInfo
);
}
}
}
}
// 处理数据库实体
// 处理数据库实体
else
{
else
{
try
{
try
{
...
@@ -375,25 +411,26 @@ public class ChromosomeDataService {
...
@@ -375,25 +411,26 @@ public class ChromosomeDataService {
java
.
sql
.
Connection
connection
=
jdbcTemplate
.
getDataSource
().
getConnection
();
java
.
sql
.
Connection
connection
=
jdbcTemplate
.
getDataSource
().
getConnection
();
// 获取数据库元数据
// 获取数据库元数据
java
.
sql
.
DatabaseMetaData
metaData
=
connection
.
getMetaData
();
java
.
sql
.
DatabaseMetaData
metaData
=
connection
.
getMetaData
();
// 获取表名
// 获取表名
String
tableName
=
config
.
getTableName
();
String
tableName
=
config
.
getTableName
();
// 获取表的列信息
// 获取表的列信息
java
.
sql
.
ResultSet
columns
=
metaData
.
getColumns
(
null
,
null
,
tableName
,
null
);
java
.
sql
.
ResultSet
columns
=
metaData
.
getColumns
(
null
,
null
,
tableName
,
null
);
// 遍历列信息,生成FieldInfo
// 遍历列信息,生成FieldInfo
while
(
columns
.
next
())
{
while
(
columns
.
next
())
{
FieldInfo
fieldInfo
=
new
FieldInfo
();
FieldInfo
fieldInfo
=
new
FieldInfo
();
fieldInfo
.
setFieldName
(
columns
.
getString
(
"COLUMN_NAME"
));
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
.
setDescription
(
columns
.
getString
(
"REMARKS"
));
fieldInfo
.
setDataSource
(
config
.
getDataSource
().
name
());
fieldInfo
.
setDataSource
(
config
.
getDataSource
().
name
());
fieldInfo
.
setEntityName
(
entityName
);
fieldInfo
.
setEntityName
(
entityName
);
fieldInfos
.
add
(
fieldInfo
);
fieldInfos
.
add
(
fieldInfo
);
}
}
// 关闭资源
// 关闭资源
columns
.
close
();
columns
.
close
();
connection
.
close
();
connection
.
close
();
...
@@ -401,10 +438,58 @@ public class ChromosomeDataService {
...
@@ -401,10 +438,58 @@ public class ChromosomeDataService {
log
.
error
(
"获取数据库表字段信息失败: {}"
,
e
.
getMessage
(),
e
);
log
.
error
(
"获取数据库表字段信息失败: {}"
,
e
.
getMessage
(),
e
);
}
}
}
}
return
fieldInfos
;
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 实体名称
* @param entityName 实体名称
...
@@ -412,58 +497,139 @@ public class ChromosomeDataService {
...
@@ -412,58 +497,139 @@ public class ChromosomeDataService {
*/
*/
private
Map
<
String
,
String
>
getFieldDescriptions
(
String
entityName
)
{
private
Map
<
String
,
String
>
getFieldDescriptions
(
String
entityName
)
{
Map
<
String
,
String
>
fieldDescriptions
=
new
HashMap
<>();
Map
<
String
,
String
>
fieldDescriptions
=
new
HashMap
<>();
// 根据实体名称返回对应的字段描述
// 首先尝试从实体类注解和JavaDoc注释中提取字段描述
switch
(
entityName
.
toLowerCase
())
{
Class
<?>
entityClass
=
getEntityClass
(
entityName
);
case
"order"
:
if
(
entityClass
!=
null
)
{
// Order实体字段描述
// 通过反射获取所有字段(包括父类字段)
fieldDescriptions
.
put
(
"id"
,
"自增主键"
);
List
<
Field
>
fields
=
new
ArrayList
<>();
fieldDescriptions
.
put
(
"orderId"
,
"订单ID"
);
Class
<?>
currentClass
=
entityClass
;
fieldDescriptions
.
put
(
"orderCode"
,
"订单编码"
);
while
(
currentClass
!=
null
&&
currentClass
!=
Object
.
class
)
{
fieldDescriptions
.
put
(
"productId"
,
"产品ID"
);
fields
.
addAll
(
Arrays
.
asList
(
currentClass
.
getDeclaredFields
()));
fieldDescriptions
.
put
(
"materialId"
,
"物料ID"
);
currentClass
=
currentClass
.
getSuperclass
();
fieldDescriptions
.
put
(
"materialCode"
,
"物料编码"
);
}
fieldDescriptions
.
put
(
"materialName"
,
"物料名称"
);
fieldDescriptions
.
put
(
"serie"
,
"系列"
);
// 提取字段注释
fieldDescriptions
.
put
(
"routingId"
,
"工艺路线ID"
);
for
(
Field
field
:
fields
)
{
fieldDescriptions
.
put
(
"routingCode"
,
"工艺路线编码"
);
fieldDescriptions
.
put
(
"quantity"
,
"订单数量,默认值:100"
);
fieldDescriptions
.
put
(
"sYQuantity"
,
"生产数量"
);
fieldDescriptions
.
put
(
"startDate"
,
"开始日期"
);
// 3. 尝试从JavaDoc注释中提取描述
fieldDescriptions
.
put
(
"dueDate"
,
"到期日期"
);
String
javaDocComment
=
getJavaDocComment
(
entityClass
,
field
.
getName
());
fieldDescriptions
.
put
(
"groupStartDate"
,
"组开始日期"
);
if
(
javaDocComment
!=
null
&&
!
javaDocComment
.
isEmpty
()
&&
!
fieldDescriptions
.
containsKey
(
field
.
getName
()))
{
fieldDescriptions
.
put
(
"groupDueDate"
,
"组到期日期"
);
fieldDescriptions
.
put
(
field
.
getName
(),
javaDocComment
);
fieldDescriptions
.
put
(
"orderCompletion"
,
"订单完成时间"
);
}
fieldDescriptions
.
put
(
"orderStart"
,
"订单开始时间"
);
}
fieldDescriptions
.
put
(
"machineProcessingTime"
,
"机器加工时间"
);
fieldDescriptions
.
put
(
"orderFlow"
,
"订单流程"
);
// 如果成功提取到字段描述,直接返回
fieldDescriptions
.
put
(
"orderProductTime"
,
"订单生产时间"
);
if
(!
fieldDescriptions
.
isEmpty
())
{
fieldDescriptions
.
put
(
"tardiness"
,
"延误时间"
);
return
fieldDescriptions
;
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
;
}
}
//
// // 传统方式:手动维护字段描述(作为备用)
// 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
;
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
;
}
}
/**
/**
* 创建空的分页结果
* 创建空的分页结果
*/
*/
...
@@ -553,7 +719,7 @@ public class ChromosomeDataService {
...
@@ -553,7 +719,7 @@ public class ChromosomeDataService {
}
}
EntityConfig
config
=
getEntityConfig
(
entityName
);
EntityConfig
config
=
getEntityConfig
(
entityName
);
if
(
config
.
getDataSource
()
==
DataSourceType
.
FILE
)
{
if
(
config
.
getDataSource
()
==
DataSourceType
.
FILE
)
{
...
@@ -610,7 +776,7 @@ public class ChromosomeDataService {
...
@@ -610,7 +776,7 @@ public class ChromosomeDataService {
}
}
}
}
}
}
EntityConfig
config
=
getEntityConfig
(
entityName
);
EntityConfig
config
=
getEntityConfig
(
entityName
);
if
(
config
.
getDataSource
()
==
DataSourceType
.
FILE
)
{
if
(
config
.
getDataSource
()
==
DataSourceType
.
FILE
)
{
...
@@ -627,7 +793,7 @@ public class ChromosomeDataService {
...
@@ -627,7 +793,7 @@ public class ChromosomeDataService {
if
(
entryData
instanceof
List
)
{
if
(
entryData
instanceof
List
)
{
List
<?>
entryList
=
(
List
<?>)
entryData
;
List
<?>
entryList
=
(
List
<?>)
entryData
;
List
<
Object
>
resultEntries
=
new
ArrayList
<>();
List
<
Object
>
resultEntries
=
new
ArrayList
<>();
// 先将Entry对象转换为Object对象,方便后续处理
// 先将Entry对象转换为Object对象,方便后续处理
for
(
Object
obj
:
entryList
)
{
for
(
Object
obj
:
entryList
)
{
if
(
obj
instanceof
Entry
)
{
if
(
obj
instanceof
Entry
)
{
...
@@ -638,12 +804,12 @@ public class ChromosomeDataService {
...
@@ -638,12 +804,12 @@ public class ChromosomeDataService {
}
}
}
}
}
}
// 应用条件过滤,支持AND/OR关系
// 应用条件过滤,支持AND/OR关系
if
(!
CollectionUtils
.
isEmpty
(
paged
.
getConditions
()))
{
if
(!
CollectionUtils
.
isEmpty
(
paged
.
getConditions
()))
{
resultEntries
=
filterDataByConditions
(
resultEntries
,
paged
.
getConditions
(),
paged
.
getAnd
());
resultEntries
=
filterDataByConditions
(
resultEntries
,
paged
.
getConditions
(),
paged
.
getAnd
());
}
}
// 提取符合条件的Entry的MachineOptions
// 提取符合条件的Entry的MachineOptions
List
<
MachineOption
>
resultMachineOptions
=
new
ArrayList
<>();
List
<
MachineOption
>
resultMachineOptions
=
new
ArrayList
<>();
for
(
Object
obj
:
resultEntries
)
{
for
(
Object
obj
:
resultEntries
)
{
...
@@ -666,7 +832,7 @@ public class ChromosomeDataService {
...
@@ -666,7 +832,7 @@ public class ChromosomeDataService {
if
(
data
instanceof
List
)
{
if
(
data
instanceof
List
)
{
List
<?>
orderList
=
(
List
<?>)
data
;
List
<?>
orderList
=
(
List
<?>)
data
;
List
<
Object
>
resultOrders
=
new
ArrayList
<>();
List
<
Object
>
resultOrders
=
new
ArrayList
<>();
// 先将Order对象转换为Object对象,方便后续处理
// 先将Order对象转换为Object对象,方便后续处理
for
(
Object
obj
:
orderList
)
{
for
(
Object
obj
:
orderList
)
{
if
(
obj
instanceof
Order
)
{
if
(
obj
instanceof
Order
)
{
...
@@ -720,7 +886,7 @@ public class ChromosomeDataService {
...
@@ -720,7 +886,7 @@ public class ChromosomeDataService {
return
null
;
return
null
;
}
}
}
}
EntityConfig
config
=
getEntityConfig
(
entityName
);
EntityConfig
config
=
getEntityConfig
(
entityName
);
if
(
config
.
getDataSource
()
==
DataSourceType
.
FILE
)
{
if
(
config
.
getDataSource
()
==
DataSourceType
.
FILE
)
{
...
@@ -898,7 +1064,7 @@ public class ChromosomeDataService {
...
@@ -898,7 +1064,7 @@ public class ChromosomeDataService {
if
(
entryData
instanceof
List
)
{
if
(
entryData
instanceof
List
)
{
List
<?>
entryList
=
(
List
<?>)
entryData
;
List
<?>
entryList
=
(
List
<?>)
entryData
;
List
<
Object
>
resultEntries
=
new
ArrayList
<>();
List
<
Object
>
resultEntries
=
new
ArrayList
<>();
// 先将Entry对象转换为Object对象,方便后续处理
// 先将Entry对象转换为Object对象,方便后续处理
for
(
Object
obj
:
entryList
)
{
for
(
Object
obj
:
entryList
)
{
if
(
obj
instanceof
Entry
)
{
if
(
obj
instanceof
Entry
)
{
...
@@ -909,12 +1075,12 @@ public class ChromosomeDataService {
...
@@ -909,12 +1075,12 @@ public class ChromosomeDataService {
}
}
}
}
}
}
// 应用条件过滤,支持AND/OR关系
// 应用条件过滤,支持AND/OR关系
if
(!
CollectionUtils
.
isEmpty
(
paged
.
getConditions
()))
{
if
(!
CollectionUtils
.
isEmpty
(
paged
.
getConditions
()))
{
resultEntries
=
filterDataByConditions
(
resultEntries
,
paged
.
getConditions
(),
paged
.
getAnd
());
resultEntries
=
filterDataByConditions
(
resultEntries
,
paged
.
getConditions
(),
paged
.
getAnd
());
}
}
// 提取符合条件的Entry的MachineOptions
// 提取符合条件的Entry的MachineOptions
List
<
MachineOption
>
resultMachineOptions
=
new
ArrayList
<>();
List
<
MachineOption
>
resultMachineOptions
=
new
ArrayList
<>();
for
(
Object
obj
:
resultEntries
)
{
for
(
Object
obj
:
resultEntries
)
{
...
@@ -937,7 +1103,7 @@ public class ChromosomeDataService {
...
@@ -937,7 +1103,7 @@ public class ChromosomeDataService {
if
(
orderData
instanceof
List
)
{
if
(
orderData
instanceof
List
)
{
List
<?>
orderList
=
(
List
<?>)
orderData
;
List
<?>
orderList
=
(
List
<?>)
orderData
;
List
<
Object
>
resultOrders
=
new
ArrayList
<>();
List
<
Object
>
resultOrders
=
new
ArrayList
<>();
// 先将Order对象转换为Object对象,方便后续处理
// 先将Order对象转换为Object对象,方便后续处理
for
(
Object
obj
:
orderList
)
{
for
(
Object
obj
:
orderList
)
{
if
(
obj
instanceof
Order
)
{
if
(
obj
instanceof
Order
)
{
...
@@ -969,12 +1135,12 @@ public class ChromosomeDataService {
...
@@ -969,12 +1135,12 @@ public class ChromosomeDataService {
// 应用排序
// 应用排序
List
<
Object
>
sortedData
=
sortData
(
dataList
,
paged
);
List
<
Object
>
sortedData
=
sortData
(
dataList
,
paged
);
// 特殊处理:当实体是Machine时,过滤不需要的字段
// 特殊处理:当实体是Machine时,过滤不需要的字段
if
(
"machine"
.
equalsIgnoreCase
(
config
.
getEntityName
()))
{
if
(
"machine"
.
equalsIgnoreCase
(
config
.
getEntityName
()))
{
sortedData
=
filterMachineData
(
sortedData
);
sortedData
=
filterMachineData
(
sortedData
);
}
}
data
=
sortedData
;
data
=
sortedData
;
}
}
}
}
...
@@ -1023,6 +1189,8 @@ public class ChromosomeDataService {
...
@@ -1023,6 +1189,8 @@ public class ChromosomeDataService {
filteredMachine
.
setActualWorkTime
(
originalMachine
.
getActualWorkTime
());
filteredMachine
.
setActualWorkTime
(
originalMachine
.
getActualWorkTime
());
filteredMachine
.
setRate
(
originalMachine
.
getRate
());
filteredMachine
.
setRate
(
originalMachine
.
getRate
());
filteredMachine
.
setDepartment
(
originalMachine
.
getDepartment
());
filteredMachine
.
setDepartment
(
originalMachine
.
getDepartment
());
filteredMachine
.
setShifts
(
originalMachine
.
getShifts
());
filteredMachine
.
setAvailability
(
originalMachine
.
getAvailability
());
// 不设置不需要的字段:shifts, maintenanceWindows, availability, holidays, shiftsChanged, maintenanceWindowsChanged
// 不设置不需要的字段:shifts, maintenanceWindows, availability, holidays, shiftsChanged, maintenanceWindowsChanged
return
filteredMachine
;
return
filteredMachine
;
}
}
...
@@ -1150,12 +1318,12 @@ public class ChromosomeDataService {
...
@@ -1150,12 +1318,12 @@ public class ChromosomeDataService {
}
else
{
}
else
{
List
<
Object
>
resultList
=
new
ArrayList
<>();
List
<
Object
>
resultList
=
new
ArrayList
<>();
resultList
.
add
(
data
);
resultList
.
add
(
data
);
// 特殊处理:当实体是Machine时,过滤不需要的字段
// 特殊处理:当实体是Machine时,过滤不需要的字段
if
(
"machine"
.
equalsIgnoreCase
(
entityName
)
&&
data
instanceof
Machine
)
{
if
(
"machine"
.
equalsIgnoreCase
(
entityName
)
&&
data
instanceof
Machine
)
{
resultList
=
filterMachineData
(
resultList
);
resultList
=
filterMachineData
(
resultList
);
}
}
return
resultList
;
return
resultList
;
}
}
}
}
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
bf07ccef
...
@@ -34,7 +34,10 @@ import java.util.*;
...
@@ -34,7 +34,10 @@ import java.util.*;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.stream.IntStream
;
import
java.util.Comparator
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Service
@Service
public
class
PlanResultService
{
public
class
PlanResultService
{
// 注入FileUploadController
// 注入FileUploadController
...
@@ -1443,6 +1446,231 @@ private GlobalParam InitGlobalParam()
...
@@ -1443,6 +1446,231 @@ private GlobalParam InitGlobalParam()
return
materials
;
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
)
private
Map
<
Integer
,
Object
>
InitEntrys
(
String
SceneId
,
List
<
ProdEquipment
>
ProdEquipments
,
List
<
Order
>
ProdLaunchOrders
)
{
{
FileHelper
.
writeLogFile
(
"初始化工单-----------开始-------"
);
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