Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ask_data_ai_admin
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
linyangyang
ask_data_ai_admin
Commits
846aed0e
Commit
846aed0e
authored
Jul 31, 2025
by
林洋洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改工具
parent
c254dd2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
28 deletions
+29
-28
ExcelTools.java
...k-data-ai-biz/src/main/java/com/ask/tools/ExcelTools.java
+29
-28
No files found.
ask-data-ai/ask-data-ai-biz/src/main/java/com/ask/tools/ExcelTools.java
View file @
846aed0e
...
@@ -46,7 +46,7 @@ public class ExcelTools {
...
@@ -46,7 +46,7 @@ public class ExcelTools {
@Autowired
@Autowired
private
FileTemplate
fileTemplate
;
private
FileTemplate
fileTemplate
;
private
final
List
<
String
>
placeholders
=
List
.
of
(
private
final
List
<
String
>
placeholders
=
List
.
of
(
"@天津智深数据.iICTS_MoQty"
,
"@天津智深数据.iICTS_MoQty"
,
"@天津智深数据.iICTS_CompletionQty"
,
"@天津智深数据.iICTS_CompletionQty"
,
"@天津智深数据.iICTS_OKRate"
,
"@天津智深数据.iICTS_OKRate"
,
...
@@ -124,25 +124,25 @@ public class ExcelTools {
...
@@ -124,25 +124,25 @@ public class ExcelTools {
return
jsonObject
.
toString
();
return
jsonObject
.
toString
();
}
}
@Tool
(
description
=
"获取天津智深DCS卡件日报"
,
returnDirect
=
true
)
@Tool
(
description
=
"获取天津智深DCS卡件日报"
)
public
String
getDcsFile
(
@ToolParam
(
description
=
"时间(yyyy-M-d)"
)
String
dateStr
)
{
public
String
getDcsFile
(
@ToolParam
(
description
=
"时间(yyyy-M-d)"
)
String
dateStr
)
{
var
ref
=
new
Object
()
{
var
ref
=
new
Object
()
{
String
markDown
=
"| 产线 | 计划产量 | 实际产量 | 成品率 |\n"
+
String
markDown
=
"| --- | --- | --- | --- |\n"
+
"| iICTS | @天津智深数据.iICTS_MoQty | @天津智深数据.iICTS_CompletionQty | @天津智深数据.iICTS_OKRate |\n"
+
"| iAS | @天津智深数据.日iAS计划数量 | @天津智深数据.iAS_CompletionQty | @天津智深数据.iAS_OKRate |\n"
+
"| iSMTS | @天津智深数据.iSMTS_MoQty | @天津智深数据.iSMTS_CompletionQty | @天津智深数据.iSMTS_OKRate |\n"
+
"| iDIPS | @天津智深数据.iDIPS_MoQty | @天津智深数据.iDIPS_CompletionQty | @天津智深数据.iDIPS_OKRate |\n"
+
"| iFCTS | @天津智深数据.iFCTS_MoQty | @天津智深数据.iFCTS_CompletionQty | @天津智深数据.iFCTS_OKRate |\n"
+
"| iCCS | @天津智深数据.iCCS_MoQty | @天津智深数据.iCCS_CompletionQty | @天津智深数据.iDIPS_OKRate |\n"
+
"| iPS | @天津智深数据.iPS_MoQty | @天津智深数据.iPS_CompletionQty | \\- |\n"
+
"| iBS | @天津智深数据.iBS_MoQty | @天津智深数据.iBS_CompletionQty | @天津智深数据.iBS_OKRate |\n"
+
"| **总计** | @天津智深数据.今日_PlanQty | @天津智深数据.今日生产成品 | \\- |\n"
+
"\n"
+
"\n"
+
"<p align=\"center\">\n"
+
"| 产线 | 计划产量 | 实际产量 | 成品率 |\n"
+
" <a href=\"fileUrl\" download>\uD83D\uDCCE 点击下载文件</a>\n"
+
"| --- | --- | --- | --- |\n"
+
"</p>"
;
"| iICTS | @天津智深数据.iICTS_MoQty | @天津智深数据.iICTS_CompletionQty | @天津智深数据.iICTS_OKRate |\n"
+
"| iAS | @天津智深数据.日iAS计划数量 | @天津智深数据.iAS_CompletionQty | @天津智深数据.iAS_OKRate |\n"
+
"| iSMTS | @天津智深数据.iSMTS_MoQty | @天津智深数据.iSMTS_CompletionQty | @天津智深数据.iSMTS_OKRate |\n"
+
"| iDIPS | @天津智深数据.iDIPS_MoQty | @天津智深数据.iDIPS_CompletionQty | @天津智深数据.iDIPS_OKRate |\n"
+
"| iFCTS | @天津智深数据.iFCTS_MoQty | @天津智深数据.iFCTS_CompletionQty | @天津智深数据.iFCTS_OKRate |\n"
+
"| iCCS | @天津智深数据.iCCS_MoQty | @天津智深数据.iCCS_CompletionQty | @天津智深数据.iDIPS_OKRate |\n"
+
"| iPS | @天津智深数据.iPS_MoQty | @天津智深数据.iPS_CompletionQty | \\- |\n"
+
"| iBS | @天津智深数据.iBS_MoQty | @天津智深数据.iBS_CompletionQty | @天津智深数据.iBS_OKRate |\n"
+
"| **总计** | @天津智深数据.今日_PlanQty | @天津智深数据.今日生产成品 | \\- |\n"
+
"\n"
+
"下载连接:[@fileName](@fileUrl)"
;
};
};
log
.
info
(
"getDcsFile{}"
,
dateStr
);
log
.
info
(
"getDcsFile{}"
,
dateStr
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-M-d"
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-M-d"
);
...
@@ -156,17 +156,19 @@ public class ExcelTools {
...
@@ -156,17 +156,19 @@ public class ExcelTools {
String
fileName
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
)
+
".docx"
;
String
fileName
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
)
+
".docx"
;
String
originalName
=
String
.
format
(
"dcs卡件日报(%s).docx"
,
dateFileStr
);
String
originalName
=
String
.
format
(
"dcs卡件日报(%s).docx"
,
dateFileStr
);
String
url
=
baseUrl
+
"/admin/sys-file/"
+
bucketName
+
"/"
+
fileName
+
"/"
+
originalName
;
String
url
=
baseUrl
+
"/admin/sys-file/"
+
bucketName
+
"/"
+
fileName
+
"/"
+
originalName
;
ref
.
markDown
=
ref
.
markDown
.
replace
(
"fileUrl"
,
url
);
ref
.
markDown
=
ref
.
markDown
.
replace
(
"@fileUrl"
,
url
);
Map
<
String
,
Object
>
paramMap
=
generateParamData
(
startTime
,
endTime
,
placeholders
);
ref
.
markDown
=
ref
.
markDown
.
replace
(
"@fileName"
,
originalName
);
Map
<
String
,
Object
>
paramMap
=
generateParamData
(
startTime
,
endTime
,
placeholders
);
log
.
info
(
"入参{}"
,
paramMap
);
log
.
info
(
"入参{}"
,
paramMap
);
paramMap
.
forEach
((
key
,
value
)
->
{
paramMap
.
forEach
((
key
,
value
)
->
{
ref
.
markDown
=
ref
.
markDown
.
replace
(
key
,
String
.
valueOf
(
value
));
ref
.
markDown
=
ref
.
markDown
.
replace
(
key
,
String
.
valueOf
(
value
));
});
});
boolean
result
=
convertUtils
.
fillWordLoop
(
fileName
,
"dcs卡件日报模板.docx"
,
paramMap
,
bucketName
);
boolean
result
=
convertUtils
.
fillWordLoop
(
fileName
,
"dcs卡件日报模板.docx"
,
paramMap
,
bucketName
);
log
.
info
(
"{} {}"
,
result
,
ref
.
markDown
);
log
.
info
(
"{} {}"
,
result
,
ref
.
markDown
);
if
(!
result
)
{
if
(!
result
)
{
return
"dcs卡件日报生成失败"
;
return
"dcs卡件日报生成失败"
;
}
}
...
@@ -174,7 +176,6 @@ public class ExcelTools {
...
@@ -174,7 +176,6 @@ public class ExcelTools {
}
}
public
Map
<
String
,
Object
>
generateReport
(
LocalDateTime
startTime
,
LocalDateTime
endTime
)
{
public
Map
<
String
,
Object
>
generateReport
(
LocalDateTime
startTime
,
LocalDateTime
endTime
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"year"
,
startTime
.
getYear
());
paramMap
.
put
(
"year"
,
startTime
.
getYear
());
...
@@ -238,7 +239,7 @@ public class ExcelTools {
...
@@ -238,7 +239,7 @@ public class ExcelTools {
return
paramMap
;
return
paramMap
;
}
}
public
Map
<
String
,
Object
>
generateParamData
(
LocalDateTime
startTime
,
LocalDateTime
endTime
,
List
<
String
>
params
)
{
public
Map
<
String
,
Object
>
generateParamData
(
LocalDateTime
startTime
,
LocalDateTime
endTime
,
List
<
String
>
params
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"year"
,
startTime
.
getYear
());
paramMap
.
put
(
"year"
,
startTime
.
getYear
());
paramMap
.
put
(
"month"
,
startTime
.
getMonthValue
());
paramMap
.
put
(
"month"
,
startTime
.
getMonthValue
());
...
@@ -257,9 +258,9 @@ public class ExcelTools {
...
@@ -257,9 +258,9 @@ public class ExcelTools {
(
existingValue
,
newValue
)
->
existingValue
// 如果有重复的键,这里决定如何处理。这里选择保留现有的值。
(
existingValue
,
newValue
)
->
existingValue
// 如果有重复的键,这里决定如何处理。这里选择保留现有的值。
));
));
params
.
forEach
(
param
->
{
params
.
forEach
(
param
->
{
paramMap
.
put
(
param
,
""
);
paramMap
.
put
(
param
,
""
);
if
(
result
.
containsKey
(
param
))
{
if
(
result
.
containsKey
(
param
))
{
paramMap
.
put
(
param
,
result
.
get
(
param
));
paramMap
.
put
(
param
,
result
.
get
(
param
));
}
}
});
});
...
...
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