Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qianhe-ydsj
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangyun
qianhe-ydsj
Commits
6e2070d1
Commit
6e2070d1
authored
Aug 06, 2025
by
wangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2025-08-06 规范建设 V5
parent
77ee1bfe
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
145 additions
and
34 deletions
+145
-34
qianhe-ydsj/src/main/java/com/qianhe/controller/SjZdscController.java
+74
-31
qianhe-ydsj/src/main/java/com/qianhe/domain/SjZdsc.java
+3
-0
qianhe-ydsj/src/main/java/com/qianhe/mapper/GgFjbMapper.java
+1
-0
qianhe-ydsj/src/main/java/com/qianhe/mapper/SjZdscMapper.java
+1
-0
qianhe-ydsj/src/main/java/com/qianhe/service/IGgFjbService.java
+1
-0
qianhe-ydsj/src/main/java/com/qianhe/service/ISjZdscService.java
+2
-0
qianhe-ydsj/src/main/java/com/qianhe/service/impl/GgFjbServiceImpl.java
+4
-0
qianhe-ydsj/src/main/java/com/qianhe/service/impl/SjZdscServiceImpl.java
+32
-1
qianhe-ydsj/src/main/resources/mapper/GgFjbMapper.xml
+5
-1
qianhe-ydsj/src/main/resources/mapper/SjBzxxMapper.xml
+2
-1
qianhe-ydsj/src/main/resources/mapper/SjZdscMapper.xml
+20
-0
No files found.
qianhe-ydsj/src/main/java/com/qianhe/controller/SjZdscController.java
View file @
6e2070d1
...
...
@@ -7,20 +7,20 @@ import java.util.zip.ZipEntry;
import
java.util.zip.ZipOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
com.qianhe.common.config.RuoYiConfig
;
import
com.qianhe.common.constant.Constants
;
import
com.qianhe.common.exception.BusinessException
;
import
com.qianhe.common.utils.StringUtils
;
import
com.qianhe.common.utils.ip.IpUtils
;
import
com.qianhe.domain.GgFjb
;
import
com.qianhe.domain.SjZdsc
;
import
com.qianhe.service.IGgFjbService
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.usermodel.WorkbookFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
com.qianhe.common.annotation.Log
;
import
com.qianhe.common.core.controller.BaseController
;
import
com.qianhe.common.core.domain.AjaxResult
;
import
com.qianhe.common.enums.BusinessType
;
import
com.qianhe.domain.SjZdsc
;
import
com.qianhe.service.ISjZdscService
;
import
com.qianhe.common.utils.poi.ExcelUtil
;
import
com.qianhe.common.core.page.TableDataInfo
;
...
...
@@ -112,13 +112,13 @@ public class SjZdscController extends BaseController
/**
* 批量导出
中原-维修-单台设备审批列表
* 批量导出
* 导出zip
*/
@RequestMapping
(
value
=
"/exportZip"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
void
exportZip
(
HttpServletResponse
response
,
String
ids
)
throws
IOException
public
void
exportZip
(
HttpServletResponse
response
,
@RequestBody
SjZdsc
sjZdsc
)
throws
IOException
{
Long
id
=
Long
.
parseLong
(
ids
);
Long
id
=
Long
.
parseLong
(
sjZdsc
.
getIds
()
);
SjZdsc
en
=
sjZdscService
.
selectSjZdscById
(
id
);
String
zdmc
=
en
.
getZdmc
();
String
bb
=
en
.
getBb
();
...
...
@@ -127,9 +127,10 @@ public class SjZdscController extends BaseController
String
ip
=
IpUtils
.
getIpAddr
();
// 设置响应头
response
.
setContentType
(
"application/zip"
);
// response.setContentType("application/zip");
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
URLEncoder
.
encode
(
zdmc
+
" "
+
bb
+
".zip"
,
"UTF-8"
));
response
.
setCharacterEncoding
(
"UTF-8"
);
// Workbook exl = null;
// OutputStream out = null;
...
...
@@ -137,42 +138,84 @@ public class SjZdscController extends BaseController
// 创建ZIP输出流
try
(
ZipOutputStream
zos
=
new
ZipOutputStream
(
response
.
getOutputStream
()))
{
// 临时变量用于验证是否有有效文件被添加
boolean
hasValidFile
=
false
;
for
(
GgFjb
fj:
fjs
)
{
String
fjlj
=
fj
.
getFJDZ
();
//附件路径
String
fjmc
=
fj
.
getFJMC
();
//附件名称
String
wzfwlj
=
ip
+
fjlj
;
//完整路径
String
localPath
=
RuoYiConfig
.
getProfile
();
String
downloadPath
=
localPath
+
StringUtils
.
substringAfter
(
fjlj
,
Constants
.
RESOURCE_PREFIX
);
// 1. 验证文件存在性和可读性
File
file
=
new
File
(
downloadPath
);
if
(!
file
.
exists
())
{
System
.
out
.
println
(
"文件不存在: {}"
+
downloadPath
);
continue
;
}
if
(!
file
.
canRead
())
{
System
.
out
.
println
(
"文件不可读: {}"
+
downloadPath
);
continue
;
}
if
(
file
.
length
()
==
0
)
{
System
.
out
.
println
(
"文件为空: {}"
+
downloadPath
);
continue
;
}
//
从文件路径读取字节数组
byte
[]
fileBytes
=
null
;
try
(
InputStream
in
=
new
FileInputStream
(
wzfwlj
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
())
{
byte
[]
buffer
=
new
byte
[
1024
];
i
nt
bytesRead
;
while
((
bytesRead
=
in
.
read
(
buffer
))
!=
-
1
)
{
out
.
write
(
buffer
,
0
,
bytesRead
)
;
//
2. 读取文件内容(改进版)
byte
[]
fileBytes
;
try
(
FileInputStream
fis
=
new
FileInputStream
(
file
))
{
fileBytes
=
new
byte
[(
int
)
file
.
length
()];
int
bytesRead
=
fis
.
read
(
fileBytes
);
// 验证读取的字节数是否与文件大小一致
i
f
(
bytesRead
!=
file
.
length
())
{
System
.
out
.
println
(
"文件读取不完整,预期: {},实际: {}"
+
file
.
length
()
+
bytesRead
);
continue
;
}
fileBytes
=
out
.
toByteArray
();
}
catch
(
FileNotFoundException
e
)
{
throw
new
BusinessException
(
"文件不存在: "
+
wzfwlj
);
}
catch
(
IOException
e
)
{
throw
new
BusinessException
(
"读取文件失败: "
+
wzfwlj
);
hasValidFile
=
true
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"读取文件异常: {}"
+
downloadPath
+
e
);
continue
;
}
// 创建ZIP条目
ZipEntry
entry
=
new
ZipEntry
(
fjmc
);
// 3. 处理文件名(避免特殊字符)
String
safeFileName
=
fjmc
.
replaceAll
(
"[\\\\/:*?\"<>|]"
,
"_"
);
ZipEntry
entry
=
new
ZipEntry
(
safeFileName
);
zos
.
putNextEntry
(
entry
);
// 写入PDF文件到ZIP条目
// 4. 写入文件内容(带验证)
zos
.
write
(
fileBytes
);
zos
.
flush
();
// 强制刷新
zos
.
closeEntry
();
}
}
catch
(
Exception
e
){
e
.
getMessage
();
throw
new
BusinessException
(
"导出Excel失败,请联系网站管理员!"
);
}
finally
{
// 5. 确保至少有一个有效文件被添加
if
(!
hasValidFile
)
{
throw
new
BusinessException
(
"没有可导出的有效文件"
);
}
// 6. 完成ZIP文件(关键步骤)
zos
.
finish
();
response
.
flushBuffer
();
// 确保所有数据发送到客户端
}
catch
(
BusinessException
e
)
{
System
.
out
.
println
(
"导出业务异常"
+
e
);
throw
e
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"导出ZIP文件异常"
+
e
);
throw
new
BusinessException
(
"导出文件失败,请联系管理员"
);
}
}
/**
* 批量提交
*/
@PostMapping
(
value
=
"/pltj"
)
public
AjaxResult
pltj
(
@RequestBody
SjZdsc
sjZdsc
)
{
sjZdsc
.
setZt
(
"1"
);
return
success
(
sjZdscService
.
pltj
(
sjZdsc
));
}
}
qianhe-ydsj/src/main/java/com/qianhe/domain/SjZdsc.java
View file @
6e2070d1
...
...
@@ -57,4 +57,7 @@ public class SjZdsc extends BaseEntity
//查询出的结果
private
String
deptName
;
//单位名称
//传入参数
private
String
ids
;
//
}
qianhe-ydsj/src/main/java/com/qianhe/mapper/GgFjbMapper.java
View file @
6e2070d1
...
...
@@ -68,5 +68,6 @@ public interface GgFjbMapper
public
int
deleteFjByYwid
(
GgFjb
ggFjb
);
public
int
insertFj
(
GgFjb
zbZbjcxxfjb
);
List
<
GgFjb
>
selectFj
(
@Param
(
"id"
)
Long
id
,
@Param
(
"mkmc"
)
String
mkmc
);
List
<
GgFjb
>
selectFjByMk
(
@Param
(
"mkmc"
)
String
mkmc
);
}
qianhe-ydsj/src/main/java/com/qianhe/mapper/SjZdscMapper.java
View file @
6e2070d1
...
...
@@ -42,6 +42,7 @@ public interface SjZdscMapper
* @return 结果
*/
public
int
updateSjZdsc
(
SjZdsc
sjZdsc
);
public
int
plxg
(
SjZdsc
sjZdsc
);
/**
* 删除基层三册
...
...
qianhe-ydsj/src/main/java/com/qianhe/service/IGgFjbService.java
View file @
6e2070d1
...
...
@@ -64,6 +64,7 @@ public interface IGgFjbService
public
int
batchSaveFj
(
String
businessId
,
String
fjlx
,
String
mkmc
,
String
fileListStr
);
List
<
GgFjb
>
selectFj
(
Long
id
,
String
mkmc
);
List
<
GgFjb
>
selectFjByMk
(
String
mkmc
);
int
deleteFjByYwid
(
GgFjb
ggFjb
);
}
qianhe-ydsj/src/main/java/com/qianhe/service/ISjZdscService.java
View file @
6e2070d1
package
com
.
qianhe
.
service
;
import
java.util.List
;
import
com.qianhe.domain.SjZdsc
;
/**
...
...
@@ -58,4 +59,5 @@ public interface ISjZdscService
* @return 结果
*/
public
int
deleteSjZdscById
(
Long
id
);
public
int
pltj
(
SjZdsc
sjBzxx
);
}
qianhe-ydsj/src/main/java/com/qianhe/service/impl/GgFjbServiceImpl.java
View file @
6e2070d1
...
...
@@ -135,6 +135,10 @@ public class GgFjbServiceImpl implements IGgFjbService
return
ggFjbMapper
.
selectFj
(
id
,
mkmc
);
}
@Override
public
List
<
GgFjb
>
selectFjByMk
(
String
mkmc
)
{
return
ggFjbMapper
.
selectFjByMk
(
mkmc
);
}
@Override
public
int
deleteFjByYwid
(
GgFjb
fj
)
{
return
ggFjbMapper
.
deleteFjByYwid
(
fj
);
}
...
...
qianhe-ydsj/src/main/java/com/qianhe/service/impl/SjZdscServiceImpl.java
View file @
6e2070d1
...
...
@@ -6,7 +6,9 @@ import java.util.stream.Collectors;
import
com.qianhe.common.annotation.DataScope
;
import
com.qianhe.common.utils.DateUtils
;
import
com.qianhe.common.utils.SecurityUtils
;
import
com.qianhe.domain.GgFjb
;
import
com.qianhe.domain.SjZdsc
;
import
com.qianhe.service.IGgFjbService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -60,7 +62,26 @@ public class SjZdscServiceImpl implements ISjZdscService
@DataScope
(
deptAlias
=
"d"
)
public
List
<
SjZdsc
>
selectSjZdscList
(
SjZdsc
sjZdsc
)
{
return
sjZdscMapper
.
selectSjZdscList
(
sjZdsc
);
List
<
SjZdsc
>
rl
=
sjZdscMapper
.
selectSjZdscList
(
sjZdsc
);
//查询附件
List
<
GgFjb
>
fjlistAll
=
fjbService
.
selectFjByMk
(
"基层三册"
);
for
(
SjZdsc
rt:
rl
){
Long
id
=
rt
.
getId
();
String
ids
=
String
.
valueOf
(
id
);
List
<
GgFjb
>
fjlist
=
fjlistAll
.
stream
().
filter
(
e
->
e
.
getYWID
().
equals
(
ids
)).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
GgFjb
>>
map
=
fjlist
.
stream
().
collect
(
Collectors
.
groupingBy
(
GgFjb:
:
getFJLX
));
if
(
map
.
get
(
"基层三册"
)!=
null
){
List
<
GgFjb
>
fileData
=
map
.
get
(
"基层三册"
).
stream
().
collect
(
Collectors
.
toList
());
rt
.
setFileList1
(
fileData
);
}
}
return
rl
;
}
/**
...
...
@@ -112,4 +133,14 @@ public class SjZdscServiceImpl implements ISjZdscService
{
return
sjZdscMapper
.
deleteSjZdscById
(
id
);
}
@Override
public
int
pltj
(
SjZdsc
sjZdsc
)
{
sjZdsc
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
sjZdsc
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
sjZdscMapper
.
plxg
(
sjZdsc
);
}
}
qianhe-ydsj/src/main/resources/mapper/GgFjbMapper.xml
View file @
6e2070d1
...
...
@@ -120,10 +120,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<delete
id=
"deleteFjByYwid"
parameterType=
"GgFjb"
>
delete from gg_fjb where YWID = #{
SFBM
} AND FJLX =#{FJLX} AND MKMC =#{MKMC}
delete from gg_fjb where YWID = #{
YWID
} AND FJLX =#{FJLX} AND MKMC =#{MKMC}
</delete>
<select
id=
"selectFj"
resultMap=
"GgFjbResult"
>
select * from gg_fjb where YWID = #{id} and MKMC = #{mkmc};
</select>
<select
id=
"selectFjByMk"
resultMap=
"GgFjbResult"
>
select * from gg_fjb where MKMC = #{mkmc};
</select>
</mapper>
\ No newline at end of file
qianhe-ydsj/src/main/resources/mapper/SjBzxxMapper.xml
View file @
6e2070d1
...
...
@@ -126,6 +126,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"remark != null"
>
remark = #{remark},
</if>
</trim>
where find_in_set(id, #{ids})
)
where find_in_set(id, #{ids})
</update>
</mapper>
\ No newline at end of file
qianhe-ydsj/src/main/resources/mapper/SjZdscMapper.xml
View file @
6e2070d1
...
...
@@ -106,4 +106,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<update
id=
"plxg"
parameterType=
"SjBzxx"
>
update sj_zdsc
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"deptId != null"
>
dept_id = #{deptId},
</if>
<if
test=
"lx != null"
>
lx = #{lx},
</if>
<if
test=
"zdmc != null"
>
zdmc = #{zdmc},
</if>
<if
test=
"bb != null"
>
bb = #{bb},
</if>
<if
test=
"fjms != null"
>
fjms = #{fjms},
</if>
<if
test=
"zt != null"
>
zt = #{zt},
</if>
<if
test=
"xzcs != null"
>
xzcs = #{xzcs},
</if>
<if
test=
"createBy != null"
>
create_by = #{createBy},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"remark != null"
>
remark = #{remark},
</if>
</trim>
where find_in_set(id, #{ids})
</update>
</mapper>
\ No newline at end of file
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