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
9b615f1b
Commit
9b615f1b
authored
Jan 13, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单修改
parent
4148b970
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
160 additions
and
64 deletions
+160
-64
GlobalExceptionHandler.java
...java/com/aps/common/exception/GlobalExceptionHandler.java
+16
-16
SwaggerMapParamConfig.java
src/main/java/com/aps/config/SwaggerMapParamConfig.java
+3
-3
ResourceGanttController.java
...ava/com/aps/controller/gantt/ResourceGanttController.java
+31
-11
Entry.java
src/main/java/com/aps/entity/basic/Entry.java
+3
-0
KpiCalculator.java
src/main/java/com/aps/service/Algorithm/KpiCalculator.java
+12
-6
MachineCalculator.java
...ain/java/com/aps/service/Algorithm/MachineCalculator.java
+8
-8
OrderSortService.java
...main/java/com/aps/service/Algorithm/OrderSortService.java
+6
-3
RoutingDataService.java
...in/java/com/aps/service/Algorithm/RoutingDataService.java
+2
-0
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+79
-17
No files found.
src/main/java/com/aps/common/exception/GlobalExceptionHandler.java
View file @
9b615f1b
...
@@ -36,7 +36,7 @@ public class GlobalExceptionHandler {
...
@@ -36,7 +36,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
IllegalArgumentException
.
class
)
@ExceptionHandler
(
IllegalArgumentException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
R
<
Void
>
handleIllegalArgumentException
(
IllegalArgumentException
e
)
{
public
R
<
Void
>
handleIllegalArgumentException
(
IllegalArgumentException
e
)
{
log
.
debug
(
"参数校验失败: {}"
,
e
.
getMessage
()
);
log
.
error
(
"参数校验失败:"
,
e
);
return
R
.
failed
(
500
,
e
.
getMessage
());
return
R
.
failed
(
500
,
e
.
getMessage
());
}
}
...
@@ -46,7 +46,7 @@ public class GlobalExceptionHandler {
...
@@ -46,7 +46,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
SceneGenerationException
.
class
)
@ExceptionHandler
(
SceneGenerationException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
R
<
Void
>
handleSceneGenerationException
(
SceneGenerationException
e
)
{
public
R
<
Void
>
handleSceneGenerationException
(
SceneGenerationException
e
)
{
log
.
debug
(
"场景生成异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"场景生成异常:"
,
e
);
return
R
.
failed
(
500
,
e
.
getMessage
());
return
R
.
failed
(
500
,
e
.
getMessage
());
}
}
...
@@ -56,7 +56,7 @@ public class GlobalExceptionHandler {
...
@@ -56,7 +56,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
RuntimeException
.
class
)
@ExceptionHandler
(
RuntimeException
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
R
<
Void
>
handleRuntimeException
(
RuntimeException
e
)
{
public
R
<
Void
>
handleRuntimeException
(
RuntimeException
e
)
{
log
.
debug
(
"运行时异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"运行时异常:"
,
e
);
return
R
.
failed
(
500
,
e
.
getMessage
());
return
R
.
failed
(
500
,
e
.
getMessage
());
}
}
...
@@ -66,7 +66,7 @@ public class GlobalExceptionHandler {
...
@@ -66,7 +66,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
BindingException
.
class
)
@ExceptionHandler
(
BindingException
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
R
<
Void
>
handleBindingException
(
BindingException
e
)
{
public
R
<
Void
>
handleBindingException
(
BindingException
e
)
{
log
.
debug
(
"MyBatis绑定异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"MyBatis绑定异常:"
,
e
);
return
R
.
failed
(
500
,
"数据绑定异常: "
+
e
.
getMessage
());
return
R
.
failed
(
500
,
"数据绑定异常: "
+
e
.
getMessage
());
}
}
...
@@ -76,7 +76,7 @@ public class GlobalExceptionHandler {
...
@@ -76,7 +76,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
MyBatisSystemException
.
class
)
@ExceptionHandler
(
MyBatisSystemException
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
R
<
Void
>
handleMyBatisSystemException
(
MyBatisSystemException
e
)
{
public
R
<
Void
>
handleMyBatisSystemException
(
MyBatisSystemException
e
)
{
log
.
debug
(
"MyBatis系统异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"MyBatis系统异常:"
,
e
);
Throwable
cause
=
e
.
getCause
();
Throwable
cause
=
e
.
getCause
();
if
(
cause
!=
null
&&
cause
.
getMessage
().
contains
(
"ORA-17004"
))
{
if
(
cause
!=
null
&&
cause
.
getMessage
().
contains
(
"ORA-17004"
))
{
return
R
.
failed
(
500
,
"数据库列类型无效,请检查查询参数是否正确"
);
return
R
.
failed
(
500
,
"数据库列类型无效,请检查查询参数是否正确"
);
...
@@ -90,7 +90,7 @@ public class GlobalExceptionHandler {
...
@@ -90,7 +90,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
SQLException
.
class
)
@ExceptionHandler
(
SQLException
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
R
<
Void
>
handleSQLException
(
SQLException
e
)
{
public
R
<
Void
>
handleSQLException
(
SQLException
e
)
{
log
.
debug
(
"SQL异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"SQL异常:"
,
e
);
return
R
.
failed
(
500
,
"数据库访问异常: "
+
e
.
getMessage
());
return
R
.
failed
(
500
,
"数据库访问异常: "
+
e
.
getMessage
());
}
}
...
@@ -100,7 +100,7 @@ public class GlobalExceptionHandler {
...
@@ -100,7 +100,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
DataAccessException
.
class
)
@ExceptionHandler
(
DataAccessException
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
R
<
Void
>
handleDataAccessException
(
DataAccessException
e
)
{
public
R
<
Void
>
handleDataAccessException
(
DataAccessException
e
)
{
log
.
debug
(
"数据访问异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"数据访问异常:"
,
e
);
return
R
.
failed
(
500
,
"数据访问异常: "
+
e
.
getMessage
());
return
R
.
failed
(
500
,
"数据访问异常: "
+
e
.
getMessage
());
}
}
...
@@ -110,7 +110,7 @@ public class GlobalExceptionHandler {
...
@@ -110,7 +110,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
R
<
Void
>
handleMethodArgumentNotValidException
(
MethodArgumentNotValidException
e
)
{
public
R
<
Void
>
handleMethodArgumentNotValidException
(
MethodArgumentNotValidException
e
)
{
log
.
debug
(
"参数验证异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"参数验证异常:"
,
e
);
FieldError
fieldError
=
e
.
getBindingResult
().
getFieldError
();
FieldError
fieldError
=
e
.
getBindingResult
().
getFieldError
();
if
(
fieldError
!=
null
)
{
if
(
fieldError
!=
null
)
{
return
R
.
failed
(
400
,
Objects
.
requireNonNull
(
fieldError
.
getDefaultMessage
()));
return
R
.
failed
(
400
,
Objects
.
requireNonNull
(
fieldError
.
getDefaultMessage
()));
...
@@ -124,7 +124,7 @@ public class GlobalExceptionHandler {
...
@@ -124,7 +124,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
BindException
.
class
)
@ExceptionHandler
(
BindException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
R
<
Void
>
handleBindException
(
BindException
e
)
{
public
R
<
Void
>
handleBindException
(
BindException
e
)
{
log
.
debug
(
"参数绑定异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"参数绑定异常:"
,
e
);
FieldError
fieldError
=
e
.
getBindingResult
().
getFieldError
();
FieldError
fieldError
=
e
.
getBindingResult
().
getFieldError
();
if
(
fieldError
!=
null
)
{
if
(
fieldError
!=
null
)
{
return
R
.
failed
(
500
,
Objects
.
requireNonNull
(
fieldError
.
getDefaultMessage
()));
return
R
.
failed
(
500
,
Objects
.
requireNonNull
(
fieldError
.
getDefaultMessage
()));
...
@@ -138,7 +138,7 @@ public class GlobalExceptionHandler {
...
@@ -138,7 +138,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
MissingServletRequestParameterException
.
class
)
@ExceptionHandler
(
MissingServletRequestParameterException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
R
<
Void
>
handleMissingServletRequestParameterException
(
MissingServletRequestParameterException
e
)
{
public
R
<
Void
>
handleMissingServletRequestParameterException
(
MissingServletRequestParameterException
e
)
{
log
.
debug
(
"请求参数缺失: {}"
,
e
.
getMessage
()
);
log
.
error
(
"请求参数缺失:"
,
e
);
return
R
.
failed
(
500
,
"缺少必要参数: "
+
e
.
getParameterName
());
return
R
.
failed
(
500
,
"缺少必要参数: "
+
e
.
getParameterName
());
}
}
...
@@ -148,7 +148,7 @@ public class GlobalExceptionHandler {
...
@@ -148,7 +148,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
MethodArgumentTypeMismatchException
.
class
)
@ExceptionHandler
(
MethodArgumentTypeMismatchException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
R
<
Void
>
handleMethodArgumentTypeMismatchException
(
MethodArgumentTypeMismatchException
e
)
{
public
R
<
Void
>
handleMethodArgumentTypeMismatchException
(
MethodArgumentTypeMismatchException
e
)
{
log
.
debug
(
"参数类型不匹配: {}"
,
e
.
getMessage
()
);
log
.
error
(
"参数类型不匹配:"
,
e
);
return
R
.
failed
(
500
,
"参数类型不匹配: "
+
e
.
getName
());
return
R
.
failed
(
500
,
"参数类型不匹配: "
+
e
.
getName
());
}
}
...
@@ -158,7 +158,7 @@ public class GlobalExceptionHandler {
...
@@ -158,7 +158,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
HttpMessageNotReadableException
.
class
)
@ExceptionHandler
(
HttpMessageNotReadableException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
R
<
Void
>
handleHttpMessageNotReadableException
(
HttpMessageNotReadableException
e
)
{
public
R
<
Void
>
handleHttpMessageNotReadableException
(
HttpMessageNotReadableException
e
)
{
log
.
debug
(
"HTTP消息不可读: {}"
,
e
.
getMessage
()
);
log
.
error
(
"HTTP消息不可读:"
,
e
);
return
R
.
failed
(
500
,
"请求体格式错误"
);
return
R
.
failed
(
500
,
"请求体格式错误"
);
}
}
...
@@ -168,7 +168,7 @@ public class GlobalExceptionHandler {
...
@@ -168,7 +168,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
HttpRequestMethodNotSupportedException
.
class
)
@ExceptionHandler
(
HttpRequestMethodNotSupportedException
.
class
)
@ResponseStatus
(
HttpStatus
.
METHOD_NOT_ALLOWED
)
@ResponseStatus
(
HttpStatus
.
METHOD_NOT_ALLOWED
)
public
R
<
Void
>
handleHttpRequestMethodNotSupportedException
(
HttpRequestMethodNotSupportedException
e
)
{
public
R
<
Void
>
handleHttpRequestMethodNotSupportedException
(
HttpRequestMethodNotSupportedException
e
)
{
log
.
debug
(
"HTTP请求方法不支持: {}"
,
e
.
getMessage
()
);
log
.
error
(
"HTTP请求方法不支持:"
,
e
);
return
R
.
failed
(
405
,
"请求方法不支持: "
+
e
.
getMethod
());
return
R
.
failed
(
405
,
"请求方法不支持: "
+
e
.
getMethod
());
}
}
...
@@ -178,7 +178,7 @@ public class GlobalExceptionHandler {
...
@@ -178,7 +178,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
HttpMediaTypeNotSupportedException
.
class
)
@ExceptionHandler
(
HttpMediaTypeNotSupportedException
.
class
)
@ResponseStatus
(
HttpStatus
.
UNSUPPORTED_MEDIA_TYPE
)
@ResponseStatus
(
HttpStatus
.
UNSUPPORTED_MEDIA_TYPE
)
public
R
<
Void
>
handleHttpMediaTypeNotSupportedException
(
HttpMediaTypeNotSupportedException
e
)
{
public
R
<
Void
>
handleHttpMediaTypeNotSupportedException
(
HttpMediaTypeNotSupportedException
e
)
{
log
.
debug
(
"HTTP媒体类型不支持: {}"
,
e
.
getMessage
()
);
log
.
error
(
"HTTP媒体类型不支持:"
,
e
);
return
R
.
failed
(
415
,
"媒体类型不支持: "
+
e
.
getContentType
());
return
R
.
failed
(
415
,
"媒体类型不支持: "
+
e
.
getContentType
());
}
}
...
@@ -188,7 +188,7 @@ public class GlobalExceptionHandler {
...
@@ -188,7 +188,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
NoHandlerFoundException
.
class
)
@ExceptionHandler
(
NoHandlerFoundException
.
class
)
@ResponseStatus
(
HttpStatus
.
NOT_FOUND
)
@ResponseStatus
(
HttpStatus
.
NOT_FOUND
)
public
R
<
Void
>
handleNoHandlerFoundException
(
NoHandlerFoundException
e
)
{
public
R
<
Void
>
handleNoHandlerFoundException
(
NoHandlerFoundException
e
)
{
log
.
debug
(
"404异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"404异常:"
,
e
);
return
R
.
failed
(
404
,
"请求的资源不存在: "
+
e
.
getRequestURL
());
return
R
.
failed
(
404
,
"请求的资源不存在: "
+
e
.
getRequestURL
());
}
}
...
@@ -198,7 +198,7 @@ public class GlobalExceptionHandler {
...
@@ -198,7 +198,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
R
<
Void
>
handleException
(
Exception
e
)
{
public
R
<
Void
>
handleException
(
Exception
e
)
{
log
.
debug
(
"未知异常: {}"
,
e
.
getMessage
()
);
log
.
error
(
"未知异常:"
,
e
);
return
R
.
failed
(
500
,
"系统异常,请联系管理员"
);
return
R
.
failed
(
500
,
"系统异常,请联系管理员"
);
}
}
}
}
\ No newline at end of file
src/main/java/com/aps/config/SwaggerMapParamConfig.java
View file @
9b615f1b
...
@@ -167,14 +167,14 @@ public class SwaggerMapParamConfig {
...
@@ -167,14 +167,14 @@ public class SwaggerMapParamConfig {
));
));
break
;
break
;
case
"operation
e
dit"
:
case
"operation
E
dit"
:
properties
.
put
(
"sceneId"
,
new
StringSchema
().
description
(
"场景ID"
).
example
(
"B571EF6682DB463AB2977B1055A74112"
));
properties
.
put
(
"sceneId"
,
new
StringSchema
().
description
(
"场景ID"
).
example
(
"B571EF6682DB463AB2977B1055A74112"
));
properties
.
put
(
"
operation
"
,
new
StringSchema
().
description
(
"操作对象"
));
properties
.
put
(
"
entry
"
,
new
StringSchema
().
description
(
"操作对象"
));
examples
.
put
(
"编辑操作示例"
,
createExample
(
examples
.
put
(
"编辑操作示例"
,
createExample
(
"编辑指定的操作"
,
"编辑指定的操作"
,
"{\n"
+
"{\n"
+
" \"sceneId\": \"B571EF6682DB463AB2977B1055A74112\",\n"
+
" \"sceneId\": \"B571EF6682DB463AB2977B1055A74112\",\n"
+
" \"
operation
\": {}\n"
+
" \"
entry
\": {}\n"
+
"}"
"}"
));
));
break
;
break
;
...
...
src/main/java/com/aps/controller/gantt/ResourceGanttController.java
View file @
9b615f1b
package
com
.
aps
.
controller
.
gantt
;
package
com
.
aps
.
controller
.
gantt
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.aps.common.util.NumberUtils
;
import
com.aps.common.util.NumberUtils
;
import
com.aps.common.util.ParamValidator
;
import
com.aps.common.util.ParamValidator
;
import
com.aps.common.util.R
;
import
com.aps.common.util.R
;
...
@@ -146,11 +147,31 @@ public class ResourceGanttController {
...
@@ -146,11 +147,31 @@ public class ResourceGanttController {
}
}
@GetMapping
(
"/SyncMachines"
)
@PostMapping
(
"/editOrder"
)
@Operation
(
summary
=
"更新设备信息缓存"
,
description
=
"更新设备信息缓存"
)
@Operation
(
summary
=
"修改订单"
,
description
=
"编辑场景中的订单信息"
,
public
void
SyncMachines
()
{
requestBody
=
@io
.
swagger
.
v3
.
oas
.
annotations
.
parameters
.
RequestBody
(
// 调用 PlanResultService 获取 ScheduleChromosome 列表
description
=
"编辑订单参数"
,
planResultService
.
InitCalendarToAllMachines
();
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 \"order\": { }\n}"
)
)
)
)
public
R
<
Chromosome
>
editOrder
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
log
.
info
(
"editOrder 请求参数: {}"
,
params
);
String
sceneId
=
ParamValidator
.
getString
(
params
,
"sceneId"
,
"场景ID"
);
ParamValidator
.
validateSceneExists
(
sceneService
,
sceneId
);
// 使用BeanUtil转换LinkedHashMap为Order对象
Order
order
=
BeanUtil
.
toBean
(
params
.
get
(
"order"
),
Order
.
class
);
Chromosome
result
=
planResultService
.
EditOrder
(
sceneId
,
order
);
return
R
.
ok
(
result
);
}
}
...
@@ -231,17 +252,16 @@ public class ResourceGanttController {
...
@@ -231,17 +252,16 @@ public class ResourceGanttController {
@PostMapping
(
"/operation
e
dit"
)
@PostMapping
(
"/operation
E
dit"
)
@Operation
(
summary
=
"修改工单"
,
description
=
"修改工单"
)
@Operation
(
summary
=
"修改工单"
,
description
=
"修改工单"
)
public
R
<
Chromosome
>
operation
e
dit
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
public
R
<
Chromosome
>
operation
E
dit
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
log
.
info
(
"operation
e
dit 请求参数: {}"
,
params
);
log
.
info
(
"operation
E
dit 请求参数: {}"
,
params
);
String
sceneId
=
ParamValidator
.
getString
(
params
,
"sceneId"
,
"场景ID"
);
String
sceneId
=
ParamValidator
.
getString
(
params
,
"sceneId"
,
"场景ID"
);
ParamValidator
.
validateSceneExists
(
sceneService
,
sceneId
);
ParamValidator
.
validateSceneExists
(
sceneService
,
sceneId
);
// 处理Entry对象
// 使用BeanUtil转换LinkedHashMap为Entry对象
Entry
entry
=
(
Entry
)
params
.
get
(
"operation"
);
Entry
entry
=
BeanUtil
.
toBean
(
params
.
get
(
"entry"
),
Entry
.
class
);
Chromosome
result
=
planResultService
.
EditOperation
(
sceneId
,
entry
);
Chromosome
result
=
planResultService
.
EditOperation
(
sceneId
,
entry
);
return
R
.
ok
(
result
);
return
R
.
ok
(
result
);
...
...
src/main/java/com/aps/entity/basic/Entry.java
View file @
9b615f1b
...
@@ -140,4 +140,7 @@ public class Entry {
...
@@ -140,4 +140,7 @@ public class Entry {
private
BigDecimal
runtime
;
//持续时间
private
BigDecimal
runtime
;
//持续时间
private
BigDecimal
singleOut
;
//单件产出
private
BigDecimal
singleOut
;
//单件产出
private
double
changeLineTime
;
//换模时间
private
double
changeLineTime
;
//换模时间
private
BigDecimal
setupTime
;
private
int
constTime
;
}
}
src/main/java/com/aps/service/Algorithm/KpiCalculator.java
View file @
9b615f1b
...
@@ -141,10 +141,13 @@ public class KpiCalculator {
...
@@ -141,10 +141,13 @@ public class KpiCalculator {
*/
*/
private
void
calculateMachine
()
{
private
void
calculateMachine
()
{
// 按设备ID分组工序列表(对应C# GroupBy + ToList)
// 按设备ID分组工序列表(对应C# GroupBy + ToList)
- Java 8兼容方式,处理null键
List
<
GAScheduleResult
>
list
=
chromosome
.
getResult
()
;
List
<
GAScheduleResult
>
list
=
chromosome
.
getResult
()
;
Map
<
Long
,
List
<
GAScheduleResult
>>
machineTasks
=
list
.
stream
()
Map
<
Long
,
List
<
GAScheduleResult
>>
machineTasks
=
new
HashMap
<>();
.
collect
(
Collectors
.
groupingBy
(
GAScheduleResult:
:
getMachineId
));
list
.
forEach
(
result
->
{
Long
machineId
=
result
.
getMachineId
();
machineTasks
.
computeIfAbsent
(
machineId
,
k
->
new
ArrayList
<>()).
add
(
result
);
});
// 计划工作时间:最后一个任务结束时间 - 第一个任务开始时间
// 计划工作时间:最后一个任务结束时间 - 第一个任务开始时间
int
firstTaskStart
=
list
.
stream
()
int
firstTaskStart
=
list
.
stream
()
...
@@ -202,9 +205,12 @@ public class KpiCalculator {
...
@@ -202,9 +205,12 @@ public class KpiCalculator {
*/
*/
private
void
calculateOrder
()
{
private
void
calculateOrder
()
{
List
<
GAScheduleResult
>
list
=
chromosome
.
getResult
();
List
<
GAScheduleResult
>
list
=
chromosome
.
getResult
();
// 按GroupId(订单ID)分组 - 对应C#的GroupBy
// 按GroupId(订单ID)分组 - Java 8兼容方式,处理null键
Map
<
String
,
List
<
GAScheduleResult
>>
orderGroups
=
list
.
stream
()
Map
<
String
,
List
<
GAScheduleResult
>>
orderGroups
=
new
HashMap
<>();
.
collect
(
Collectors
.
groupingBy
(
GAScheduleResult:
:
getOrderId
));
list
.
forEach
(
result
->
{
String
orderId
=
result
.
getOrderId
();
orderGroups
.
computeIfAbsent
(
orderId
,
k
->
new
ArrayList
<>()).
add
(
result
);
});
for
(
Map
.
Entry
<
String
,
List
<
GAScheduleResult
>>
entry
:
orderGroups
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
GAScheduleResult
>>
entry
:
orderGroups
.
entrySet
())
{
String
orderId
=
entry
.
getKey
();
String
orderId
=
entry
.
getKey
();
...
...
src/main/java/com/aps/service/Algorithm/MachineCalculator.java
View file @
9b615f1b
...
@@ -65,7 +65,7 @@ public class MachineCalculator {
...
@@ -65,7 +65,7 @@ public class MachineCalculator {
Machine
machine
,
int
processingTime
,
LocalDateTime
currentTime
,
Machine
machine
,
int
processingTime
,
LocalDateTime
currentTime
,
String
prevtime
,
List
<
GAScheduleResult
>
existingTasks
,
double
oneTime
,
double
quantity
,
boolean
checkprevtime
,
boolean
islockMachineTime
String
prevtime
,
List
<
GAScheduleResult
>
existingTasks
,
double
oneTime
,
double
quantity
,
boolean
checkprevtime
,
boolean
islockMachineTime
,
boolean
isInterrupt
)
{
,
boolean
isInterrupt
)
{
List
<
GAScheduleResult
>
machineTasks
=
existingTasks
.
stream
()
List
<
GAScheduleResult
>
machineTasks
=
new
ArrayList
<>(
existingTasks
)
.
stream
()
.
filter
(
t
->
t
.
getMachineId
()
==
machine
.
getId
())
.
filter
(
t
->
t
.
getMachineId
()
==
machine
.
getId
())
.
sorted
(
Comparator
.
comparingInt
(
GAScheduleResult:
:
getStartTime
))
.
sorted
(
Comparator
.
comparingInt
(
GAScheduleResult:
:
getStartTime
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
@@ -307,7 +307,7 @@ public class MachineCalculator {
...
@@ -307,7 +307,7 @@ public class MachineCalculator {
LocalDateTime
current
=
start
;
LocalDateTime
current
=
start
;
// 预先排序设备可用片段,避免后续遍历混乱
// 预先排序设备可用片段,避免后续遍历混乱
List
<
TimeSegment
>
allUseTimeSegment
=
machine
.
getAvailability
(
).
stream
()
List
<
TimeSegment
>
allUseTimeSegment
=
new
ArrayList
<>(
machine
.
getAvailability
()
).
stream
()
.
filter
(
slot
->
!
slot
.
isUsed
()
&&
slot
.
getType
()
!=
SegmentType
.
MAINTENANCE
)
.
filter
(
slot
->
!
slot
.
isUsed
()
&&
slot
.
getType
()
!=
SegmentType
.
MAINTENANCE
)
.
sorted
(
Comparator
.
comparing
(
TimeSegment:
:
getStart
,
(
a
,
b
)
->
a
.
compareTo
(
b
)))
.
sorted
(
Comparator
.
comparing
(
TimeSegment:
:
getStart
,
(
a
,
b
)
->
a
.
compareTo
(
b
)))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
@@ -627,7 +627,7 @@ public class MachineCalculator {
...
@@ -627,7 +627,7 @@ public class MachineCalculator {
// 2. 已有任务冲突
// 2. 已有任务冲突
if
(
machineTasks
!=
null
&&
machineTasks
.
size
()>
0
)
{
if
(
machineTasks
!=
null
&&
machineTasks
.
size
()>
0
)
{
// 第一步:转换任务为TimeSegment并过滤重叠冲突
// 第一步:转换任务为TimeSegment并过滤重叠冲突
List
<
TimeSegment
>
taskConflicts
=
machineTasks
.
stream
()
List
<
TimeSegment
>
taskConflicts
=
new
ArrayList
<>(
machineTasks
)
.
stream
()
.
map
(
w
->
{
.
map
(
w
->
{
// 计算任务起始和结束时间:baseTime.AddMinutes(w.StartTime)/w.EndTime
// 计算任务起始和结束时间:baseTime.AddMinutes(w.StartTime)/w.EndTime
LocalDateTime
taskStart
=
baseTime
.
plusSeconds
(
w
.
getStartTime
());
LocalDateTime
taskStart
=
baseTime
.
plusSeconds
(
w
.
getStartTime
());
...
@@ -664,10 +664,10 @@ public class MachineCalculator {
...
@@ -664,10 +664,10 @@ public class MachineCalculator {
double
requiredMinutes
)
{
double
requiredMinutes
)
{
// 遍历所有冲突片段
// 遍历所有冲突片段
for
(
TimeSegment
conflict
:
conflictSegments
)
{
for
(
TimeSegment
conflict
:
new
ArrayList
<>(
conflictSegments
)
)
{
LocalDateTime
currentTime1
=
currentTime
;
LocalDateTime
currentTime1
=
currentTime
;
// 过滤冲突前的可用片段(
// 过滤冲突前的可用片段(
List
<
TimeSegment
>
preConflictSegments
=
useSegments
.
stream
()
List
<
TimeSegment
>
preConflictSegments
=
new
ArrayList
<>(
useSegments
)
.
stream
()
.
filter
(
slot
->
.
filter
(
slot
->
(
slot
.
getStart
().
compareTo
(
currentTime1
)
>=
0
||
slot
.
getEnd
().
compareTo
(
currentTime1
)
>
0
)
(
slot
.
getStart
().
compareTo
(
currentTime1
)
>=
0
||
slot
.
getEnd
().
compareTo
(
currentTime1
)
>
0
)
&&
slot
.
getEnd
().
compareTo
(
conflict
.
getStart
())
<=
0
&&
slot
.
getEnd
().
compareTo
(
conflict
.
getStart
())
<=
0
...
@@ -712,7 +712,7 @@ public class MachineCalculator {
...
@@ -712,7 +712,7 @@ public class MachineCalculator {
private
boolean
CheckTask
(
Machine
machine
,
List
<
GAScheduleResult
>
machineTasks
,
LocalDateTime
prevEnd
,
LocalDateTime
shiftStart
)
{
private
boolean
CheckTask
(
Machine
machine
,
List
<
GAScheduleResult
>
machineTasks
,
LocalDateTime
prevEnd
,
LocalDateTime
shiftStart
)
{
LocalDateTime
finalPrevEnd
=
prevEnd
;
LocalDateTime
finalPrevEnd
=
prevEnd
;
boolean
hasTask
=
machineTasks
.
stream
()
boolean
hasTask
=
new
ArrayList
<>(
machineTasks
)
.
stream
()
.
anyMatch
(
t
->
{
.
anyMatch
(
t
->
{
LocalDateTime
taskStart
=
baseTime
.
plusSeconds
(
t
.
getStartTime
());
LocalDateTime
taskStart
=
baseTime
.
plusSeconds
(
t
.
getStartTime
());
return
taskStart
.
isAfter
(
finalPrevEnd
)
&&
taskStart
.
isBefore
(
shiftStart
);
return
taskStart
.
isAfter
(
finalPrevEnd
)
&&
taskStart
.
isBefore
(
shiftStart
);
...
@@ -721,7 +721,7 @@ public class MachineCalculator {
...
@@ -721,7 +721,7 @@ public class MachineCalculator {
// 检查班次间维修窗口
// 检查班次间维修窗口
if
(
machine
.
getMaintenanceWindows
()
!=
null
)
{
if
(
machine
.
getMaintenanceWindows
()
!=
null
)
{
LocalDateTime
finalPrevEnd1
=
prevEnd
;
LocalDateTime
finalPrevEnd1
=
prevEnd
;
boolean
hasMaintenance
=
machine
.
getMaintenanceWindows
(
).
stream
()
boolean
hasMaintenance
=
new
ArrayList
<>(
machine
.
getMaintenanceWindows
()
).
stream
()
.
anyMatch
(
w
->
w
.
getStartTime
().
isAfter
(
finalPrevEnd1
)
&&
w
.
getStartTime
().
isBefore
(
shiftStart
));
.
anyMatch
(
w
->
w
.
getStartTime
().
isAfter
(
finalPrevEnd1
)
&&
w
.
getStartTime
().
isBefore
(
shiftStart
));
return
hasMaintenance
;
return
hasMaintenance
;
...
@@ -785,7 +785,7 @@ public class MachineCalculator {
...
@@ -785,7 +785,7 @@ public class MachineCalculator {
LocalDateTime
currentTime
,
LocalDateTime
startTime
,
LocalDateTime
currentTime
,
LocalDateTime
startTime
,
List
<
GAScheduleResult
>
existingTasks
)
{
List
<
GAScheduleResult
>
existingTasks
)
{
// 获取设备上已有任务并按开始时间排序
// 获取设备上已有任务并按开始时间排序
List
<
GAScheduleResult
>
machineTasks
=
existingTasks
.
stream
()
List
<
GAScheduleResult
>
machineTasks
=
new
ArrayList
<>(
existingTasks
)
.
stream
()
.
filter
(
t
->
t
.
getMachineId
()
==
machine
.
getId
())
.
filter
(
t
->
t
.
getMachineId
()
==
machine
.
getId
())
.
sorted
(
Comparator
.
comparing
(
GAScheduleResult:
:
getStartTime
))
.
sorted
(
Comparator
.
comparing
(
GAScheduleResult:
:
getStartTime
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/aps/service/Algorithm/OrderSortService.java
View file @
9b615f1b
...
@@ -179,9 +179,12 @@ public class OrderSortService {
...
@@ -179,9 +179,12 @@ public class OrderSortService {
return
;
return
;
}
}
// 1. 按当前条件分组
// 1. 按当前条件分组 处理null键
Map
<
Object
,
List
<
Order
>>
groups
=
orders
.
stream
()
Map
<
Object
,
List
<
Order
>>
groups
=
new
HashMap
<>();
.
collect
(
Collectors
.
groupingBy
(
keyExtractor
));
orders
.
forEach
(
order
->
{
Object
key
=
keyExtractor
.
apply
(
order
);
groups
.
computeIfAbsent
(
key
,
k
->
new
ArrayList
<>()).
add
(
order
);
});
// 2. 对分组键排序(关键:按条件配置的方向排序)
// 2. 对分组键排序(关键:按条件配置的方向排序)
List
<
Object
>
sortedKeys
=
getSortedKeys
(
groups
,
currentCondition
);
List
<
Object
>
sortedKeys
=
getSortedKeys
(
groups
,
currentCondition
);
...
...
src/main/java/com/aps/service/Algorithm/RoutingDataService.java
View file @
9b615f1b
...
@@ -213,6 +213,8 @@ public class RoutingDataService {
...
@@ -213,6 +213,8 @@ public class RoutingDataService {
entry
.
setEquipTypeCode
(
op
.
getEquipTypeCode
());
entry
.
setEquipTypeCode
(
op
.
getEquipTypeCode
());
entry
.
setRuntime
(
op
.
getRuntime
());
entry
.
setRuntime
(
op
.
getRuntime
());
entry
.
setSingleOut
(
op
.
getSingleOut
());
entry
.
setSingleOut
(
op
.
getSingleOut
());
entry
.
setSetupTime
(
op
.
getSetupTime
());
entry
.
setConstTime
(
op
.
getConstTime
());
entry
.
setOrderId
(
op
.
getOrderId
());
entry
.
setOrderId
(
op
.
getOrderId
());
entry
.
setOrderCode
(
op
.
getOrderCode
());
entry
.
setOrderCode
(
op
.
getOrderCode
());
entry
.
setQuantity
(
op
.
getPlanQty
());
entry
.
setQuantity
(
op
.
getPlanQty
());
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
9b615f1b
...
@@ -388,31 +388,93 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
...
@@ -388,31 +388,93 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
public
Chromosome
EditOperation
(
String
SceneId
,
Entry
operation
)
{
public
Chromosome
EditOperation
(
String
SceneId
,
Entry
operation
)
{
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
if
(
chromosome
==
null
||
chromosome
.
getAllOperations
()
==
null
)
{
if
(
chromosome
==
null
||
chromosome
.
getAllOperations
()
==
null
)
{
return
chromosome
;
// 直接返回,空值由上层处理
return
chromosome
;
}
}
List
<
Entry
>
operations
=
chromosome
.
getAllOperations
();
List
<
Entry
>
operations
=
chromosome
.
getAllOperations
();
// 直接查找匹配元素的索引(避免先找元素再查索引的冗余)
int
position
=
IntStream
.
range
(
0
,
operations
.
size
())
int
position
=
IntStream
.
range
(
0
,
operations
.
size
())
.
filter
(
i
->
{
.
filter
(
i
->
operations
.
get
(
i
).
getId
()
==
operation
.
getId
())
Entry
t
=
operations
.
get
(
i
);
return
t
.
getId
()==
operation
.
getId
();
})
.
findFirst
()
.
findFirst
()
.
orElse
(-
1
);
.
orElse
(-
1
);
// 索引有效时替换
if
(
position
!=
-
1
)
{
if
(
position
!=
-
1
)
{
operations
.
set
(
position
,
operation
);
Entry
oldEntry
=
operations
.
set
(
position
,
operation
);
List
<
GlobalOperationInfo
>
globalOpList
=
chromosome
.
getGlobalOpList
();
if
(
globalOpList
!=
null
)
{
globalOpList
.
stream
()
.
filter
(
opInfo
->
opInfo
.
getOp
()
==
oldEntry
)
.
forEach
(
opInfo
->
opInfo
.
setOp
(
operation
));
}
}
}
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
return
redecodeChromosome
(
chromosome
);
}
GlobalParam
globalParam
=
new
GlobalParam
();
ScheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
public
Chromosome
EditOrder
(
String
SceneId
,
Order
order
)
{
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
return
chromosome
;
if
(
chromosome
==
null
||
chromosome
.
getOrders
()
==
null
)
{
return
chromosome
;
}
List
<
Order
>
orders
=
chromosome
.
getOrders
();
int
position
=
IntStream
.
range
(
0
,
orders
.
size
())
.
filter
(
i
->
orders
.
get
(
i
).
getId
()
==
order
.
getId
())
.
findFirst
()
.
orElse
(-
1
);
if
(
position
!=
-
1
)
{
orders
.
set
(
position
,
order
);
}
orderSortService
.
initializeFieldExtractors
();
OrderSortRule
rule
=
createMultiConditionRule
(
orders
);
orderSortService
.
assignPriority
(
orders
,
rule
);
updateOrderRelatedEntries
(
chromosome
,
order
);
return
redecodeChromosome
(
chromosome
);
}
/**
* 更新订单相关的所有Entry的数量和优先级
*/
private
void
updateOrderRelatedEntries
(
Chromosome
chromosome
,
Order
order
)
{
// 更新所有操作中的Entry
List
<
Entry
>
allOperations
=
chromosome
.
getAllOperations
();
if
(
allOperations
!=
null
)
{
allOperations
.
stream
()
.
filter
(
entry
->
entry
.
getOrderId
()
!=
null
&&
entry
.
getOrderId
().
equals
(
order
.
getOrderId
()))
.
forEach
(
entry
->
{
entry
.
setQuantity
(
order
.
getQuantity
());
entry
.
setPriority
(
order
.
getActualPriority
());
});
}
// 更新GlobalOperationInfo中的Entry
List
<
GlobalOperationInfo
>
globalOpList
=
chromosome
.
getGlobalOpList
();
if
(
globalOpList
!=
null
)
{
globalOpList
.
stream
()
.
map
(
GlobalOperationInfo:
:
getOp
)
.
filter
(
entry
->
entry
!=
null
&&
entry
.
getOrderId
()
!=
null
&&
entry
.
getOrderId
().
equals
(
order
.
getOrderId
()))
.
forEach
(
entry
->
{
entry
.
setQuantity
(
order
.
getQuantity
());
entry
.
setPriority
(
order
.
getActualPriority
());
});
}
}
/**
* 重新解码染色体
*/
private
Chromosome
redecodeChromosome
(
Chromosome
chromosome
)
{
GlobalParam
globalParam
=
new
GlobalParam
();
ScheduleOperationService
scheduleOperation
=
new
ScheduleOperationService
();
scheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
return
chromosome
;
}
}
public
Chromosome
ChangeBaseTime
(
String
SceneId
,
LocalDateTime
BaseTime
)
{
public
Chromosome
ChangeBaseTime
(
String
SceneId
,
LocalDateTime
BaseTime
)
{
...
...
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