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
9e6f7171
Commit
9e6f7171
authored
Sep 23, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MP-订单未满足原因
parent
a8a8f6ea
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
79 deletions
+115
-79
MacroPlannerResultController.java
...java/com/aps/controller/MacroPlannerResultController.java
+30
-43
MacroPlannerDataConverterRunner.java
...com/aps/macroplanner/MacroPlannerDataConverterRunner.java
+2
-2
ResultWriter.java
src/main/java/com/aps/macroplanner/output/ResultWriter.java
+54
-25
OptimizationResult.java
...a/com/aps/macroplanner/output/dto/OptimizationResult.java
+6
-0
RiskItem.java
src/main/java/com/aps/macroplanner/output/dto/RiskItem.java
+18
-6
SalesDemandResult.java
...va/com/aps/macroplanner/output/dto/SalesDemandResult.java
+5
-3
No files found.
src/main/java/com/aps/controller/MacroPlannerResultController.java
View file @
9e6f7171
...
...
@@ -165,12 +165,30 @@ public class MacroPlannerResultController {
.
skip
((
long
)(
pageNumber
-
1
)*
pageSize
)
.
limit
(
pageSize
)
.
collect
(
Collectors
.
toList
());
if
(
SalesDemandSummaries
!=
null
&&
SalesDemandSummaries
.
size
()>
0
)
{
List
<
String
>
SalesDemandids
=
SalesDemandSummaries
.
stream
()
.
map
(
SalesDemandResult:
:
getSalesDemandId
)
.
collect
(
Collectors
.
toList
());
List
<
RiskItem
>
Risks
=
getSalesDemandReason
(
sceneId
,
SalesDemandids
);
if
(
Risks
!=
null
&&
Risks
.
size
()>
0
)
{
for
(
SalesDemandResult
entry
:
SalesDemandSummaries
)
{
List
<
RiskItem
>
Risks1
=
Risks
.
stream
()
.
filter
(
t
->
t
.
getSalesDemandId
().
equals
(
entry
.
getSalesDemandId
())&&
t
.
getType
()==
1
)
.
collect
(
Collectors
.
toList
());
entry
.
setUnmetReasons
(
Risks1
);
List
<
RiskItem
>
Risks2
=
Risks
.
stream
()
.
filter
(
t
->
t
.
getSalesDemandId
().
equals
(
entry
.
getSalesDemandId
())&&
t
.
getType
()==
2
)
.
collect
(
Collectors
.
toList
());
entry
.
setRisks
(
Risks2
);
}
}
}
// List<Map<String, Object>> summaries = new ArrayList<>();
// for (SalesDemandResult entry : SalesDemandSummaries) {
//
// }
double
totalDemand
=
lists
.
stream
().
mapToDouble
(
SalesDemandResult:
:
getDemandQty
).
sum
();
double
totalFulfilled
=
lists
.
stream
().
mapToDouble
(
SalesDemandResult:
:
getFulfilledQty
).
sum
();
...
...
@@ -188,32 +206,19 @@ public class MacroPlannerResultController {
return
null
;
}
}
private
List
<
SalesDemandResult
>
getSalesDemandsResult
(
String
sceneId
,
String
salesDemandId
)
{
private
List
<
RiskItem
>
getSalesDemandReason
(
String
sceneId
,
List
<
String
>
salesDemandIds
)
{
try
{
FlatParquetUtil
parquetUtil
=
new
FlatParquetUtil
();
ResultWriter
rw
=
new
ResultWriter
();
List
<
FlatParquetUtil
.
FilterCondition
<?>>
filters
=
new
ArrayList
<>();
filters
.
add
(
FlatParquetUtil
.
FilterCondition
.
eq
(
"salesDemandId"
,
salesDemandId
));
List
<
FlatParquetUtil
.
SortCondition
>
sorts
=
Arrays
.
asList
(
FlatParquetUtil
.
SortCondition
.
asc
(
"periodIndex"
)
String
salesDemandReasonPath
=
rw
.
getOptimizationSalesDemandReasons
(
sceneId
);
);
FlatParquetUtil
.
QueryRequest
request
=
new
FlatParquetUtil
.
QueryRequest
(
FlatParquetUtil
.
PageRequest
.
of
(
1
,
500
),
filters
,
sorts
);
FlatParquetUtil
.
PageResult
<
SalesDemandResult
>
result
=
parquetUtil
.
queryPage
(
rw
.
getOptimizationSalesDemand
(
sceneId
),
SalesDemandResult
.
class
,
request
);
List
<
SalesDemandResult
>
pispips
=
result
.
getRecords
();
return
pispips
;
List
<
RiskItem
>
list
=
parquetUtil
.
readAll
(
salesDemandReasonPath
,
RiskItem
.
class
,
oi
->
salesDemandIds
.
contains
(
oi
.
getSalesDemandId
()));
return
list
;
}
catch
(
Exception
e
)
{
return
null
;
}
...
...
@@ -678,25 +683,7 @@ public class MacroPlannerResultController {
}
}
private
void
normalizeUnmetReasons
(
List
<
SalesDemandResult
>
demands
)
{
for
(
SalesDemandResult
demand
:
demands
)
{
List
<
String
>
reasons
=
demand
.
getUnmetReasons
();
if
(
reasons
==
null
||
reasons
.
isEmpty
())
{
continue
;
}
List
<
String
>
normalized
=
new
ArrayList
<>();
for
(
String
reason
:
reasons
)
{
if
(
reason
!=
null
&&
reason
.
startsWith
(
"库存耗尽("
)
&&
reason
.
endsWith
(
")"
))
{
normalized
.
add
(
"库存耗尽"
);
normalized
.
add
(
reason
.
substring
(
"库存耗尽"
.
length
()));
}
else
{
normalized
.
add
(
reason
);
}
}
reasons
.
clear
();
reasons
.
addAll
(
normalized
);
}
}
private
void
enrichPispipProductCodes
(
List
<
PispipResult
>
pispips
)
{
if
(
pispips
==
null
||
pispips
.
isEmpty
())
{
...
...
src/main/java/com/aps/macroplanner/MacroPlannerDataConverterRunner.java
View file @
9e6f7171
...
...
@@ -80,8 +80,8 @@ public class MacroPlannerDataConverterRunner {
optimizer
.
solve
();
ResultWriter
writer
=
new
ResultWriter
(
optimizer
.
getModel
(),
optimizer
.
getData
(),
1
);
OptimizationResult
result
=
writer
.
buildResult
(
"Default"
);
boolean
jsonPath
=
writer
.
saveResultToFile
(
"Default"
,
result
);
OptimizationResult
result
=
writer
.
buildResult
(
sceneId
);
boolean
jsonPath
=
writer
.
saveResultToFile
(
sceneId
,
result
);
System
.
out
.
println
(
"===== MACROPLANNER DATA CONVERTER RUNNER END ====="
);
}
finally
{
...
...
src/main/java/com/aps/macroplanner/output/ResultWriter.java
View file @
9e6f7171
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/macroplanner/output/dto/OptimizationResult.java
View file @
9e6f7171
...
...
@@ -33,6 +33,8 @@ public class OptimizationResult {
private
final
List
<
SalesDemandResult
>
salesDemands
=
new
ArrayList
<>();
private
List
<
SalesDemandResult
>
saleDemandSummaries
=
new
ArrayList
<>();
private
List
<
RiskItem
>
saleDemandReasons
=
new
ArrayList
<>();
private
final
List
<
PispipResult
>
pispips
=
new
ArrayList
<>();
...
...
@@ -76,8 +78,12 @@ public class OptimizationResult {
public
List
<
SalesDemandResult
>
getSaleSummarieDemands
()
{
return
saleDemandSummaries
;
}
public
List
<
RiskItem
>
getSaleDemandReasons
()
{
return
saleDemandReasons
;
}
public
void
setSaleSummarieDemands
(
List
<
SalesDemandResult
>
v
)
{
saleDemandSummaries
=
v
;
}
public
void
setSaleDemandReasons
(
List
<
RiskItem
>
v
)
{
saleDemandReasons
=
v
;
}
public
List
<
PispipResult
>
getPispips
()
{
return
pispips
;
}
...
...
src/main/java/com/aps/macroplanner/output/dto/RiskItem.java
View file @
9e6f7171
...
...
@@ -2,6 +2,7 @@ package com.aps.macroplanner.output.dto;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Data
;
/**
* 作者:佟礼
...
...
@@ -12,16 +13,27 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*
* <p>level 取值: "高" / "低"。</p>
*/
@Data
public
class
RiskItem
{
private
final
String
level
;
private
final
String
description
;
@JsonCreator
public
RiskItem
(
@JsonProperty
(
"level"
)
String
level
,
@JsonProperty
(
"description"
)
String
description
)
{
private
String
salesDemandId
;
private
Integer
periodIndex
;
private
Integer
type
;
private
String
level
;
private
String
title
;
private
String
description
;
public
RiskItem
()
{}
public
RiskItem
(
String
salesDemandId
,
int
periodIndex
,
int
type
,
String
level
,
String
title
,
String
description
)
{
this
.
salesDemandId
=
salesDemandId
;
this
.
periodIndex
=
periodIndex
;
this
.
type
=
type
;
this
.
level
=
level
;
this
.
title
=
title
;
this
.
description
=
description
;
}
public
String
getLevel
()
{
return
level
;
}
public
String
getDescription
()
{
return
description
;
}
}
src/main/java/com/aps/macroplanner/output/dto/SalesDemandResult.java
View file @
9e6f7171
...
...
@@ -39,9 +39,9 @@ public class SalesDemandResult {
private
Long
categoryId
;
/** 未完成原因分析 (仅当 unmetQty > 0 时有内容) */
private
final
List
<
String
>
unmetReasons
=
new
ArrayList
<>();
private
List
<
RiskItem
>
unmetReasons
=
new
ArrayList
<>();
/** 风险分析 (即使满足也可能存在的供应链风险) */
private
final
List
<
RiskItem
>
risks
=
new
ArrayList
<>();
private
List
<
RiskItem
>
risks
=
new
ArrayList
<>();
// ==================== Getters / Setters ====================
...
...
@@ -88,8 +88,10 @@ public class SalesDemandResult {
public
double
getPriority
()
{
return
priority
;
}
public
void
setPriority
(
double
v
)
{
this
.
priority
=
v
;
}
public
List
<
String
>
getUnmetReasons
()
{
return
unmetReasons
;
}
public
List
<
RiskItem
>
getUnmetReasons
()
{
return
unmetReasons
;
}
public
List
<
RiskItem
>
getRisks
()
{
return
risks
;
}
public
void
setUnmetReasons
(
List
<
RiskItem
>
v
)
{
unmetReasons
=
v
;
}
public
void
setRisks
(
List
<
RiskItem
>
v
)
{
risks
=
v
;
}
}
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