Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zh-baseversion-project
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王浩
zh-baseversion-project
Commits
b356e50f
Commit
b356e50f
authored
Aug 30, 2024
by
wanghao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 燃气用户界面 错误数据导出 再导入功能实现中。
parent
87d1d614
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
164 additions
and
77 deletions
+164
-77
TDetectorUserController.java
...ong/web/controller/supervise/TDetectorUserController.java
+56
-24
燃气用户错误导入数据模版.xlsx
...admin/src/main/resources/importTemplate/燃气用户错误导入数据模版.xlsx
+0
-0
ExcelUtil.java
.../src/main/java/com/zehong/common/utils/poi/ExcelUtil.java
+1
-1
UserManageGasUserExportVo.java
...om/zehong/system/domain/vo/UserManageGasUserExportVo.java
+12
-0
user.js
zh-baseversion-web/src/api/regulation/user.js
+9
-0
index.vue
...eb/src/views/regulation/userManagement/gasUsers/index.vue
+86
-52
No files found.
zh-baseversion-admin/src/main/java/com/zehong/web/controller/supervise/TDetectorUserController.java
View file @
b356e50f
...
@@ -2,8 +2,17 @@ package com.zehong.web.controller.supervise;
...
@@ -2,8 +2,17 @@ package com.zehong.web.controller.supervise;
import
java.io.*
;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
cn.afterturn.easypoi.excel.ExcelExportUtil
;
import
cn.afterturn.easypoi.excel.entity.ExportParams
;
import
cn.afterturn.easypoi.excel.entity.TemplateExportParams
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.zehong.common.core.domain.entity.SysUser
;
import
com.zehong.common.core.domain.entity.SysUser
;
import
com.zehong.common.core.domain.model.LoginUser
;
import
com.zehong.common.core.domain.model.LoginUser
;
import
com.zehong.common.utils.SecurityUtils
;
import
com.zehong.common.utils.SecurityUtils
;
...
@@ -15,6 +24,8 @@ import com.zehong.system.domain.vo.GasUserAndSafetyDeviceVo;
...
@@ -15,6 +24,8 @@ import com.zehong.system.domain.vo.GasUserAndSafetyDeviceVo;
import
com.zehong.system.domain.vo.TDetectorUserInspectVo
;
import
com.zehong.system.domain.vo.TDetectorUserInspectVo
;
import
com.zehong.system.domain.vo.UserManageSafetyDeviceExportVo
;
import
com.zehong.system.domain.vo.UserManageSafetyDeviceExportVo
;
import
com.zehong.system.service.ITDetectorUserErrorService
;
import
com.zehong.system.service.ITDetectorUserErrorService
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.ClassPathResource
;
...
@@ -318,36 +329,57 @@ public class TDetectorUserController extends BaseController
...
@@ -318,36 +329,57 @@ public class TDetectorUserController extends BaseController
file
=
ResourceUtils
.
getFile
(
"/data/java/baseversion/importTemplate/燃气用户错误导入数据模版.xlsx"
);
file
=
ResourceUtils
.
getFile
(
"/data/java/baseversion/importTemplate/燃气用户错误导入数据模版.xlsx"
);
}
}
// 获取文件名
String
filename
=
file
.
getName
();
List
<
TDetectorUser
>
tDetectorUsers
=
tDetectorUserService
.
queryErrorDetectorUserList
();
List
<
TDetectorUser
>
tDetectorUsers
=
tDetectorUserService
.
queryErrorDetectorUserList
();
List
<
UserManageGasUserExportVo
>
userManageGasUserExportVos
=
new
ArrayList
<>();
for
(
TDetectorUser
tDetectorUser
:
tDetectorUsers
)
{
UserManageGasUserExportVo
userManageGasUserExportVo
=
new
UserManageGasUserExportVo
();
BeanUtils
.
copyProperties
(
tDetectorUser
,
userManageGasUserExportVo
);
userManageGasUserExportVos
.
add
(
userManageGasUserExportVo
);
}
ExportParams
exportParams
=
new
ExportParams
(
"数据列表"
,
"数据"
,
file
.
getPath
());
// 获取文件名
Workbook
workbook
=
ExcelExportUtil
.
exportExcel
(
exportParams
,
UserManageGasUserExportVo
.
class
,
userManageGasUserExportVos
);
String
filename
=
file
.
getName
();
// 获取文件后缀名
String
ext
=
filename
.
substring
(
filename
.
lastIndexOf
(
"."
)
+
1
).
toLowerCase
();
// 将文件写入输入流
System
.
out
.
println
(
"file.getPath = "
+
file
.
getPath
());
FileInputStream
fileInputStream
=
new
FileInputStream
(
file
);
System
.
out
.
println
(
"file.getAbsolutePath = "
+
file
.
getAbsolutePath
());
InputStream
fis
=
new
BufferedInputStream
(
fileInputStream
);
byte
[]
buffer
=
new
byte
[
fis
.
available
()];
// 新的文件路径
fis
.
read
(
buffer
);
String
[]
split
=
file
.
getPath
().
split
(
"\\\\"
);
fis
.
close
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
split
.
length
-
1
;
i
++)
{
stringBuilder
.
append
(
split
[
i
]
+
"\\"
);
}
stringBuilder
.
append
(
"错误数据.xlsx"
);
System
.
out
.
println
(
"filepaht = "
+
stringBuilder
);
// 将 Excel 写入文件系统
FileOutputStream
fos
=
new
FileOutputStream
(
stringBuilder
.
toString
());
workbook
.
write
(
fos
);
fos
.
close
();
// // 清空response
// response.reset();
// // 设置response的Header
// response.setCharacterEncoding("UTF-8");
// //Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
// //attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
// // filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
// response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
// // 告知浏览器文件的大小
// response.addHeader("Content-Length", "" + file.length());
// OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
// response.setContentType("application/octet-stream");
// outputStream.write(workbook);
// outputStream.flush();
// 清空response
response
.
reset
();
// 设置response的Header
response
.
setCharacterEncoding
(
"UTF-8"
);
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
filename
,
"UTF-8"
));
// 告知浏览器文件的大小
response
.
addHeader
(
"Content-Length"
,
""
+
file
.
length
());
OutputStream
outputStream
=
new
BufferedOutputStream
(
response
.
getOutputStream
());
response
.
setContentType
(
"application/octet-stream"
);
outputStream
.
write
(
buffer
);
outputStream
.
flush
();
}
catch
(
IOException
ex
)
{
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
...
...
zh-baseversion-admin/src/main/resources/importTemplate/燃气用户错误导入数据模版.xlsx
View file @
b356e50f
No preview for this file type
zh-baseversion-common/src/main/java/com/zehong/common/utils/poi/ExcelUtil.java
View file @
b356e50f
...
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
...
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.InvocationHandler
;
...
@@ -1199,7 +1200,6 @@ public class ExcelUtil<T>
...
@@ -1199,7 +1200,6 @@ public class ExcelUtil<T>
}
}
}
}
/**
/**
* 针对燃气用户的 多sheet导入数据
* 针对燃气用户的 多sheet导入数据
* @param file f
* @param file f
...
...
zh-baseversion-system/src/main/java/com/zehong/system/domain/vo/UserManageGasUserExportVo.java
View file @
b356e50f
...
@@ -58,6 +58,10 @@ public class UserManageGasUserExportVo {
...
@@ -58,6 +58,10 @@ public class UserManageGasUserExportVo {
@Excel
(
name
=
"备注"
,
needMerge
=
true
)
@Excel
(
name
=
"备注"
,
needMerge
=
true
)
private
String
remarks
;
private
String
remarks
;
/** 错误信息 */
@Excel
(
name
=
"错误信息"
,
needMerge
=
true
)
private
String
errorMsg
;
public
String
getUserOwnId
()
{
public
String
getUserOwnId
()
{
return
userOwnId
;
return
userOwnId
;
}
}
...
@@ -154,6 +158,14 @@ public class UserManageGasUserExportVo {
...
@@ -154,6 +158,14 @@ public class UserManageGasUserExportVo {
this
.
userId
=
userId
;
this
.
userId
=
userId
;
}
}
public
String
getErrorMsg
()
{
return
errorMsg
;
}
public
void
setErrorMsg
(
String
errorMsg
)
{
this
.
errorMsg
=
errorMsg
;
}
public
String
getBeyondEnterpriseId
()
{
public
String
getBeyondEnterpriseId
()
{
return
beyondEnterpriseId
;
return
beyondEnterpriseId
;
}
}
...
...
zh-baseversion-web/src/api/regulation/user.js
View file @
b356e50f
...
@@ -166,3 +166,12 @@ export function clearImportError() {
...
@@ -166,3 +166,12 @@ export function clearImportError() {
method
:
'get'
method
:
'get'
})
})
}
}
// 导出从业人员信息- 错误数据
export
function
exportErrorData
()
{
return
request
({
url
:
'/supervise/user/exportErrorData'
,
method
:
'get'
})
}
\ No newline at end of file
zh-baseversion-web/src/views/regulation/userManagement/gasUsers/index.vue
View file @
b356e50f
This diff is collapsed.
Click to expand it.
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