Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
d927cd82
Commit
d927cd82
authored
Oct 17, 2024
by
chenzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ziliaoxiazai youhua
parent
2b9dd1c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
25 deletions
+76
-25
CommonController.java
...mos/boot/module/hygf/biz/controller/CommonController.java
+1
-1
CommonServiceImpl.java
.../boot/module/hygf/biz/service/impl/CommonServiceImpl.java
+75
-24
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/controller/CommonController.java
View file @
d927cd82
...
@@ -55,7 +55,7 @@ public class CommonController {
...
@@ -55,7 +55,7 @@ public class CommonController {
commonService
.
downZiliao
(
surveyInformationId
,
peasantHouseholdIds
,
processInstanceId
,
response
);
commonService
.
downZiliao
(
surveyInformationId
,
peasantHouseholdIds
,
processInstanceId
,
response
);
System
.
out
.
println
(
"zip下载成功"
);
}
}
/**
/**
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/service/impl/CommonServiceImpl.java
View file @
d927cd82
...
@@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.activemq.util.MapHelper
;
import
org.apache.activemq.util.MapHelper
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
...
@@ -505,6 +506,35 @@ public class CommonServiceImpl {
...
@@ -505,6 +506,35 @@ public class CommonServiceImpl {
return
jsonArray
;
return
jsonArray
;
}
}
public
static
Path
createUniqueDirectory
(
Path
baseDir
,
String
baseName
)
{
Path
dirPath
=
baseDir
.
resolve
(
baseName
);
// 检查目录是否存在
if
(
Files
.
exists
(
dirPath
))
{
// 如果目录存在,则尝试创建带有数字后缀的目录
int
counter
=
1
;
while
(
true
)
{
String
newName
=
baseName
+
"_"
+
counter
;
dirPath
=
baseDir
.
resolve
(
newName
);
if
(!
Files
.
exists
(
dirPath
))
{
break
;
// 找到了一个新的名称,退出循环
}
counter
++;
}
}
// 创建目录
try
{
Files
.
createDirectories
(
dirPath
);
return
dirPath
;
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Failed to create directory: "
+
dirPath
);
e
.
printStackTrace
();
return
null
;
}
}
public
void
downZiliao
(
String
surveyInformationId
,
List
<
String
>
peasantHouseholdIds
,
String
processInstanceId
,
HttpServletResponse
response
)
throws
IOException
{
public
void
downZiliao
(
String
surveyInformationId
,
List
<
String
>
peasantHouseholdIds
,
String
processInstanceId
,
HttpServletResponse
response
)
throws
IOException
{
String
fileName
=
""
;
String
fileName
=
""
;
String
redisKey
=
""
;
String
redisKey
=
""
;
...
@@ -548,7 +578,14 @@ public class CommonServiceImpl {
...
@@ -548,7 +578,14 @@ public class CommonServiceImpl {
Path
templateDir
=
Paths
.
get
(
TEMPLATE_FILE_PATH
).
getParent
();
Path
templateDir
=
Paths
.
get
(
TEMPLATE_FILE_PATH
).
getParent
();
System
.
out
.
println
(
"模版文件所在目录是: "
+
templateDir
);
System
.
out
.
println
(
"模版文件所在目录是: "
+
templateDir
);
Path
tempDir
=
ziLiaoDir
.
resolve
(
returnDto
.
getSurveyInformation
().
getOwnersName
());
Path
tempDir
=
createUniqueDirectory
(
ziLiaoDir
,
returnDto
.
getSurveyInformation
().
getOwnersName
());
boolean
directoryExists
=
Files
.
exists
(
tempDir
);
if
(
directoryExists
){
}
else
{
}
try
{
try
{
Files
.
createDirectories
(
tempDir
);
// 创建临时目录
Files
.
createDirectories
(
tempDir
);
// 创建临时目录
System
.
out
.
println
(
"Temporary directory created at: "
+
tempDir
);
System
.
out
.
println
(
"Temporary directory created at: "
+
tempDir
);
...
@@ -622,22 +659,29 @@ public class CommonServiceImpl {
...
@@ -622,22 +659,29 @@ public class CommonServiceImpl {
current
=
current
+
15
;
current
=
current
+
15
;
redisUtils
.
set
(
redisKey
,
MapBuilder
.<
String
,
Object
>
create
()
redisUtils
.
set
(
redisKey
,
MapBuilder
.<
String
,
Object
>
create
()
.
put
(
"value"
,
current
).
build
());
.
put
(
"value"
,
current
).
build
());
List
<
HygfRectificationOrder
>
areaOrdersCon
=
Optional
.
ofNullable
(
returnDto
.
getPowerStationConstructionData
().
getAreaOrders
())
List
<
HygfRectificationOrder
>
areaOrdersCon
=
new
ArrayList
<>();
.
orElse
(
new
ArrayList
<>());
if
(
ObjectUtils
.
isNotEmpty
(
returnDto
.
getHygfOnGrid
()))
{
addNonNullList
(
areaOrdersCon
,
returnDto
.
getPowerStationConstructionData
().
getDesignOrders
());
areaOrdersCon
=
Optional
.
ofNullable
(
returnDto
.
getPowerStationConstructionData
().
getAreaOrders
())
addNonNullList
(
areaOrdersCon
,
returnDto
.
getPowerStationConstructionData
().
getEngineeringOrders
());
.
orElse
(
new
ArrayList
<>());
addNonNullList
(
areaOrdersCon
,
returnDto
.
getPowerStationConstructionData
().
getDesignOrders
());
addNonNullList
(
areaOrdersCon
,
returnDto
.
getPowerStationConstructionData
().
getEngineeringOrders
());
}
// 主方法或代码块
// 主方法或代码块
List
<
HygfRectificationOrder
>
areaOrders
=
Optional
.
ofNullable
(
returnDto
.
getHygfOnGrid
().
getAreaOrders
())
List
<
HygfRectificationOrder
>
areaOrders
=
new
ArrayList
<>();
.
orElse
(
new
ArrayList
<>());
if
(
ObjectUtils
.
isNotEmpty
(
returnDto
.
getHygfOnGrid
()))
{
addNonNullList
(
areaOrders
,
returnDto
.
getHygfOnGrid
().
getDesignOrders
());
areaOrders
=
Optional
.
ofNullable
(
returnDto
.
getHygfOnGrid
().
getAreaOrders
())
addNonNullList
(
areaOrders
,
returnDto
.
getHygfOnGrid
().
getEngineeringOrders
());
.
orElse
(
new
ArrayList
<>());
addNonNullList
(
areaOrders
,
returnDto
.
getHygfOnGrid
().
getDesignOrders
());
List
<
HygfRectificationOrder
>
areaOrdersAcc
=
Optional
.
ofNullable
(
returnDto
.
getAcceptanceCheck
().
getAreaOrders
())
addNonNullList
(
areaOrders
,
returnDto
.
getHygfOnGrid
().
getEngineeringOrders
());
.
orElse
(
new
ArrayList
<>());
}
addNonNullList
(
areaOrders
,
returnDto
.
getAcceptanceCheck
().
getLegalOrders
());
List
<
HygfRectificationOrder
>
areaOrdersAcc
=
new
ArrayList
<>();
addNonNullList
(
areaOrders
,
returnDto
.
getAcceptanceCheck
().
getFinanceOrders
());
if
(
ObjectUtils
.
isNotEmpty
(
returnDto
.
getAcceptanceCheck
())){
addNonNullList
(
areaOrders
,
returnDto
.
getAcceptanceCheck
().
getPropertyOrders
());
areaOrdersAcc
=
Optional
.
ofNullable
(
returnDto
.
getAcceptanceCheck
().
getAreaOrders
())
.
orElse
(
new
ArrayList
<>());
addNonNullList
(
areaOrdersAcc
,
returnDto
.
getAcceptanceCheck
().
getLegalOrders
());
addNonNullList
(
areaOrdersAcc
,
returnDto
.
getAcceptanceCheck
().
getFinanceOrders
());
addNonNullList
(
areaOrdersAcc
,
returnDto
.
getAcceptanceCheck
().
getPropertyOrders
());
}
List
<
Future
<?>>
futures
=
new
ArrayList
<>();
List
<
Future
<?>>
futures
=
new
ArrayList
<>();
String
finalRedisKey
=
redisKey
;
String
finalRedisKey
=
redisKey
;
...
@@ -724,9 +768,10 @@ public class CommonServiceImpl {
...
@@ -724,9 +768,10 @@ public class CommonServiceImpl {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}));
}));
futures
.
add
(
executorService
.
submit
(()
->
{
List
<
HygfRectificationOrder
>
finalAreaOrdersCon
=
areaOrdersCon
;
futures
.
add
(
executorService
.
submit
(()
->
{
try
{
try
{
downloadAndZipImages
(
a
reaOrdersCon
,
"施工信息整改单附件"
,
tempDir
,
urlPath
);
downloadAndZipImages
(
finalA
reaOrdersCon
,
"施工信息整改单附件"
,
tempDir
,
urlPath
);
if
(!
finalRedisKey
.
contains
(
","
)){
if
(!
finalRedisKey
.
contains
(
","
)){
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
finalRedisKey
);
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
finalRedisKey
);
Integer
currentNum
=
(
Integer
)
map
.
get
(
"value"
)+
7
;
Integer
currentNum
=
(
Integer
)
map
.
get
(
"value"
)+
7
;
...
@@ -752,9 +797,10 @@ public class CommonServiceImpl {
...
@@ -752,9 +797,10 @@ public class CommonServiceImpl {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}));
}));
futures
.
add
(
executorService
.
submit
(()
->
{
List
<
HygfRectificationOrder
>
finalAreaOrders
=
areaOrders
;
futures
.
add
(
executorService
.
submit
(()
->
{
try
{
try
{
downloadAndZipImages
(
a
reaOrders
,
"并网信息整改单附件"
,
tempDir
,
urlPath
);
downloadAndZipImages
(
finalA
reaOrders
,
"并网信息整改单附件"
,
tempDir
,
urlPath
);
if
(!
finalRedisKey
.
contains
(
","
)){
if
(!
finalRedisKey
.
contains
(
","
)){
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
finalRedisKey
);
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
finalRedisKey
);
Integer
currentNum
=
(
Integer
)
map
.
get
(
"value"
)+
7
;
Integer
currentNum
=
(
Integer
)
map
.
get
(
"value"
)+
7
;
...
@@ -780,9 +826,10 @@ public class CommonServiceImpl {
...
@@ -780,9 +826,10 @@ public class CommonServiceImpl {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}));
}));
futures
.
add
(
executorService
.
submit
(()
->
{
List
<
HygfRectificationOrder
>
finalAreaOrdersAcc
=
areaOrdersAcc
;
futures
.
add
(
executorService
.
submit
(()
->
{
try
{
try
{
downloadAndZipImages
(
a
reaOrdersAcc
,
"验收信息整改单附件"
,
tempDir
,
urlPath
);
downloadAndZipImages
(
finalA
reaOrdersAcc
,
"验收信息整改单附件"
,
tempDir
,
urlPath
);
if
(!
finalRedisKey
.
contains
(
","
)){
if
(!
finalRedisKey
.
contains
(
","
)){
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
finalRedisKey
);
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
finalRedisKey
);
Integer
currentNum
=
(
Integer
)
map
.
get
(
"value"
)+
7
;
Integer
currentNum
=
(
Integer
)
map
.
get
(
"value"
)+
7
;
...
@@ -818,7 +865,6 @@ public class CommonServiceImpl {
...
@@ -818,7 +865,6 @@ public class CommonServiceImpl {
}
}
String
encodedFilename
=
""
;
String
encodedFilename
=
""
;
response
.
setHeader
(
"content-Type"
,
"application/vnd.ms-excel"
);
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
if
(
peasantHouseholdIds
.
size
()
>
1
){
if
(
peasantHouseholdIds
.
size
()
>
1
){
fileName
=
"批量资料"
;
fileName
=
"批量资料"
;
...
@@ -841,7 +887,9 @@ public class CommonServiceImpl {
...
@@ -841,7 +887,9 @@ public class CommonServiceImpl {
private
void
fillSheet
(
Sheet
sheet
,
Object
data
)
{
private
void
fillSheet
(
Sheet
sheet
,
Object
data
)
{
if
(
Objects
.
isNull
(
null
)){
return
;
}
int
startRow
=
1
;
int
startRow
=
1
;
for
(
int
i
=
0
;
i
<
sheet
.
getLastRowNum
()
+
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
sheet
.
getLastRowNum
()
+
1
;
i
++)
{
Row
row
=
sheet
.
getRow
(
i
);
Row
row
=
sheet
.
getRow
(
i
);
...
@@ -1274,6 +1322,9 @@ public class CommonServiceImpl {
...
@@ -1274,6 +1322,9 @@ public class CommonServiceImpl {
}
}
public
static
void
downloadAndZipImages
(
Object
obj
,
String
fileName
,
Path
tempDir
,
String
urlPath
)
throws
IOException
{
public
static
void
downloadAndZipImages
(
Object
obj
,
String
fileName
,
Path
tempDir
,
String
urlPath
)
throws
IOException
{
if
(
ObjectUtils
.
isEmpty
(
obj
)){
return
;
}
Path
baseInfoPath
=
tempDir
.
resolve
(
fileName
);
Path
baseInfoPath
=
tempDir
.
resolve
(
fileName
);
try
{
try
{
Files
.
createDirectories
(
baseInfoPath
);
Files
.
createDirectories
(
baseInfoPath
);
...
...
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