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
b6911640
Commit
b6911640
authored
Aug 29, 2024
by
wanghao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 燃气用户界面 加入 导入功能 ,实现 两个sheet的导入,目前已经能拿到两个sheet的数据, 入库逻辑实现中。
parent
3e469472
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
264 additions
and
60 deletions
+264
-60
TDetectorUserController.java
...ong/web/controller/supervise/TDetectorUserController.java
+24
-9
燃气用户导入模版.xlsx
...ion-admin/src/main/resources/importTemplate/燃气用户导入模版.xlsx
+0
-0
ExcelUtil.java
.../src/main/java/com/zehong/common/utils/poi/ExcelUtil.java
+52
-4
UserManageGasUserExportVo.java
...om/zehong/system/domain/vo/UserManageGasUserExportVo.java
+9
-37
UserManageSafetyDeviceExportVo.java
...hong/system/domain/vo/UserManageSafetyDeviceExportVo.java
+130
-0
ITDetectorUserService.java
...java/com/zehong/system/service/ITDetectorUserService.java
+16
-2
TDetectorUserServiceImpl.java
.../zehong/system/service/impl/TDetectorUserServiceImpl.java
+32
-7
index.vue
...eb/src/views/regulation/userManagement/gasUsers/index.vue
+1
-1
No files found.
zh-baseversion-admin/src/main/java/com/zehong/web/controller/supervise/TDetectorUserController.java
View file @
b6911640
...
...
@@ -2,7 +2,6 @@ package com.zehong.web.controller.supervise;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.util.Arrays
;
import
java.util.List
;
import
com.zehong.common.core.domain.entity.SysUser
;
...
...
@@ -11,9 +10,10 @@ import com.zehong.common.utils.SecurityUtils;
import
com.zehong.common.utils.ServletUtils
;
import
com.zehong.framework.web.service.TokenService
;
import
com.zehong.system.domain.TDetectorUserCount
;
import
com.zehong.system.domain.vo.
GasUserAndSafetyDevice
ExportVo
;
import
com.zehong.system.domain.vo.
UserManageGasUser
ExportVo
;
import
com.zehong.system.domain.vo.GasUserAndSafetyDeviceVo
;
import
com.zehong.system.domain.vo.TDetectorUserInspectVo
;
import
com.zehong.system.domain.vo.UserManageSafetyDeviceExportVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.ClassPathResource
;
...
...
@@ -267,7 +267,7 @@ public class TDetectorUserController extends BaseController
@GetMapping
(
"/importTemplate"
)
public
AjaxResult
importTemplate
()
{
ExcelUtil
<
GasUserAndSafetyDeviceExportVo
>
util
=
new
ExcelUtil
<>(
GasUserAndSafetyDevice
ExportVo
.
class
);
ExcelUtil
<
UserManageGasUserExportVo
>
util
=
new
ExcelUtil
<>(
UserManageGasUser
ExportVo
.
class
);
return
util
.
importTemplateExcel
(
"燃气用户数据"
);
}
...
...
@@ -281,8 +281,8 @@ public class TDetectorUserController extends BaseController
@PostMapping
(
"/importData"
)
public
AjaxResult
importData
(
MultipartFile
file
,
boolean
updateSupport
,
HttpServletResponse
response
)
throws
Exception
{
ExcelUtil
<
GasUserAndSafetyDeviceExportVo
>
util
=
new
ExcelUtil
<>(
GasUserAndSafetyDevice
ExportVo
.
class
);
List
<
GasUserAndSafetyDevice
ExportVo
>
XmbhList
=
util
.
importExcel
(
file
.
getInputStream
());
ExcelUtil
<
UserManageGasUserExportVo
>
util
=
new
ExcelUtil
<>(
UserManageGasUser
ExportVo
.
class
);
List
<
UserManageGasUser
ExportVo
>
XmbhList
=
util
.
importExcel
(
file
.
getInputStream
());
String
operName
=
SecurityUtils
.
getLoginUser
().
getUsername
();
String
message
=
tDetectorUserService
.
importEmployedPeopleInfo
(
XmbhList
,
updateSupport
,
operName
,
response
);
return
AjaxResult
.
success
(
message
);
...
...
@@ -354,12 +354,27 @@ public class TDetectorUserController extends BaseController
*/
@PostMapping
(
"/importCustom"
)
public
AjaxResult
importData
(
MultipartFile
file
,
boolean
updateSupport
)
throws
Exception
{
List
<
GasUserAndSafetyDeviceExportVo
>
dataInfos
=
ExcelUtil
.
importExcel
(
file
,
1
,
2
,
GasUserAndSafetyDevice
ExportVo
.
class
);
for
(
GasUserAndSafetyDeviceExportVo
dataInfo
:
dataInfos
)
{
System
.
out
.
println
(
dataInfo
.
getLinkman
()
);
List
<
UserManageGasUserExportVo
>
dataInfos
=
ExcelUtil
.
importExcel
(
file
,
1
,
2
,
UserManageGasUser
ExportVo
.
class
);
if
(
dataInfos
!=
null
&&
dataInfos
.
size
()
>
0
)
{
tDetectorUserService
.
handleCustomImportData
(
dataInfos
,
updateSupport
);
}
return
AjaxResult
.
success
();
}
/**
* 自定义模版的多sheet导入
* @param file
* @return
* @throws Exception
*/
@PostMapping
(
"/moreSheetImportExcel"
)
public
AjaxResult
moreSheetImportExcel
(
MultipartFile
file
,
boolean
updateSupport
)
throws
Exception
{
List
<
UserManageGasUserExportVo
>
userManageGasUserobjects
=
ExcelUtil
.
moreSheetImportExcel
(
file
,
1
,
2
,
UserManageGasUserExportVo
.
class
,
0
);
List
<
UserManageSafetyDeviceExportVo
>
userManageSafetyobjects
=
ExcelUtil
.
moreSheetImportExcel
(
file
,
1
,
2
,
UserManageSafetyDeviceExportVo
.
class
,
1
);
tDetectorUserService
.
handleCustomMoreSheetImportData
(
userManageGasUserobjects
,
userManageSafetyobjects
,
updateSupport
);
return
AjaxResult
.
success
();
}
}
zh-baseversion-admin/src/main/resources/importTemplate/燃气用户导入模版.xlsx
View file @
b6911640
No preview for this file type
zh-baseversion-common/src/main/java/com/zehong/common/utils/poi/ExcelUtil.java
View file @
b6911640
...
...
@@ -1200,14 +1200,62 @@ public class ExcelUtil<T>
}
/**
* 针对燃气用户的 多sheet导入数据
* @param file f
* @param titleRows 标题在第几行
* @param headerRows 表头在第几行
* @param <T> t
* @return r
*/
public
static
<
T
>
List
<
T
>
moreSheetImportExcel
(
MultipartFile
file
,
Integer
titleRows
,
Integer
headerRows
,
Class
<
T
>
Clazz
,
Integer
sheetIndex
)
{
Map
<
String
,
List
<
T
>>
map
=
new
HashMap
<>();
if
(
file
==
null
)
{
return
null
;
}
ImportParams
params
=
new
ImportParams
();
params
.
setTitleRows
(
titleRows
);
params
.
setHeadRows
(
headerRows
);
params
.
setNeedVerify
(
true
);
ExcelImportResult
<
T
>
result
=
null
;
try
{
ImportParams
param
=
new
ImportParams
();
//标题行数
param
.
setTitleRows
(
titleRows
);
//表头行数
param
.
setHeadRows
(
headerRows
);
//0 是燃气用户数据
param
.
setStartSheetIndex
(
sheetIndex
);
result
=
ExcelImportUtil
.
importExcelMore
(
file
.
getInputStream
(),
Clazz
,
param
);
}
catch
(
NoSuchElementException
e
)
{
// 日志记录错误
log
.
error
(
String
.
format
(
"导入数据为空: %s"
,
ExceptionUtils
.
getStackTrace
(
e
)));
throw
new
RuntimeException
(
"导入数据为空"
);
}
catch
(
Exception
e
)
{
// 日志记录错误
log
.
error
(
String
.
format
(
"导入失败: %s"
,
ExceptionUtils
.
getStackTrace
(
e
)));
throw
new
RuntimeException
(
"导入失败"
);
}
if
(
result
.
isVerifyFail
())
{
// 如有需要,可以根据result.getFailWorkbook();获取到有错误的数据
throw
new
RuntimeException
(
"校验出错"
);
}
return
result
.
getList
();
}
/**
* 导入数据
* @param file
* @param file
f
* @param titleRows 标题在第几行
* @param headerRows 表头在第几行
* @param clazz
* @param <T>
* @return
* @param clazz
c
* @param <T>
t
* @return
r
*/
public
static
<
T
>
List
<
T
>
importExcel
(
MultipartFile
file
,
Integer
titleRows
,
Integer
headerRows
,
Class
<
T
>
clazz
)
{
...
...
zh-baseversion-system/src/main/java/com/zehong/system/domain/vo/
GasUserAndSafetyDevice
ExportVo.java
→
zh-baseversion-system/src/main/java/com/zehong/system/domain/vo/
UserManageGasUser
ExportVo.java
View file @
b6911640
package
com
.
zehong
.
system
.
domain
.
vo
;
import
cn.afterturn.easypoi.excel.annotation.Excel
;
import
cn.afterturn.easypoi.excel.annotation.ExcelCollection
;
import
com.zehong.system.domain.TGasuserSafetyDeviceInfo
;
import
java.util.List
;
public
class
GasUserAndSafetyDeviceExportVo
{
public
class
UserManageGasUserExportVo
{
/** 用户账号 */
@Excel
(
name
=
"用户
账
号"
,
needMerge
=
true
)
private
String
user
name
;
@Excel
(
name
=
"用户
自有编
号"
,
needMerge
=
true
)
private
String
user
OwnId
;
/** 用户名称 */
@Excel
(
name
=
"用户名称"
,
needMerge
=
true
)
private
String
nickName
;
@Excel
(
name
=
"燃气类型"
,
needMerge
=
true
)
@Excel
(
name
=
"燃气类型
(0-天然气;1-液化气)
"
,
needMerge
=
true
)
private
String
gasType
;
/** 用户类型(1居民用户,2商业用户,3工业用户) */
@Excel
(
name
=
"用户类型"
,
needMerge
=
true
)
@Excel
(
name
=
"用户类型
(1-居民用户;2-商业用户;3-工业用户;4-餐饮单位用户)
"
,
needMerge
=
true
)
private
String
userType
;
/**
...
...
@@ -47,24 +43,16 @@ public class GasUserAndSafetyDeviceExportVo {
@Excel
(
name
=
"电话"
,
needMerge
=
true
)
private
String
phone
;
/** 邮箱 */
@Excel
(
name
=
"邮箱"
,
needMerge
=
true
)
private
String
email
;
/** 备注 */
@Excel
(
name
=
"备注"
,
needMerge
=
true
)
private
String
remarks
;
/** 安全装置信息 */
@ExcelCollection
(
name
=
"安全装置信息"
)
private
List
<
TGasuserSafetyDeviceInfo
>
gasuserSafetyDeviceInfoList
;
public
String
getUsername
()
{
return
username
;
public
String
getUserOwnId
()
{
return
userOwnId
;
}
public
void
setUser
name
(
String
username
)
{
this
.
user
name
=
username
;
public
void
setUser
OwnId
(
String
userOwnId
)
{
this
.
user
OwnId
=
userOwnId
;
}
public
String
getNickName
()
{
...
...
@@ -131,14 +119,6 @@ public class GasUserAndSafetyDeviceExportVo {
this
.
phone
=
phone
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getRemarks
()
{
return
remarks
;
}
...
...
@@ -146,12 +126,4 @@ public class GasUserAndSafetyDeviceExportVo {
public
void
setRemarks
(
String
remarks
)
{
this
.
remarks
=
remarks
;
}
public
List
<
TGasuserSafetyDeviceInfo
>
getGasuserSafetyDeviceInfoList
()
{
return
gasuserSafetyDeviceInfoList
;
}
public
void
setGasuserSafetyDeviceInfoList
(
List
<
TGasuserSafetyDeviceInfo
>
gasuserSafetyDeviceInfoList
)
{
this
.
gasuserSafetyDeviceInfoList
=
gasuserSafetyDeviceInfoList
;
}
}
zh-baseversion-system/src/main/java/com/zehong/system/domain/vo/UserManageSafetyDeviceExportVo.java
0 → 100644
View file @
b6911640
package
com
.
zehong
.
system
.
domain
.
vo
;
import
cn.afterturn.easypoi.excel.annotation.Excel
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.util.Date
;
public
class
UserManageSafetyDeviceExportVo
{
/** 用户账号 */
@Excel
(
name
=
"用户自有编号"
)
private
String
userOwnId
;
/** 关联设备类型 */
@Excel
(
name
=
"设备类型"
)
private
String
relationDeviceType
;
/** 设备名称 */
@Excel
(
name
=
"设备名称"
)
private
String
deviceName
;
/** 设备型号 */
@Excel
(
name
=
"设备型号"
)
private
String
deviceModel
;
/** 物联网编号 */
@Excel
(
name
=
"物联网编号"
)
private
String
fIotNo
;
/** 探测介质 */
@Excel
(
name
=
"探测介质"
)
private
String
detectionMedium
;
/** 设备安装时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@Excel
(
name
=
"设备安装时间(yyyy-mm-dd)"
,
width
=
30
,
format
=
"yyyy-MM-dd"
)
private
Date
deviceInstallTime
;
/** 安装位置 */
@Excel
(
name
=
"安装位置"
)
private
String
deviceInstallPosition
;
/** 负责人 */
@Excel
(
name
=
"负责人"
)
private
String
head
;
/** 联系电话 */
@Excel
(
name
=
"联系电话"
)
private
String
phone
;
public
String
getUserOwnId
()
{
return
userOwnId
;
}
public
void
setUserOwnId
(
String
userOwnId
)
{
this
.
userOwnId
=
userOwnId
;
}
public
String
getRelationDeviceType
()
{
return
relationDeviceType
;
}
public
void
setRelationDeviceType
(
String
relationDeviceType
)
{
this
.
relationDeviceType
=
relationDeviceType
;
}
public
String
getDeviceName
()
{
return
deviceName
;
}
public
void
setDeviceName
(
String
deviceName
)
{
this
.
deviceName
=
deviceName
;
}
public
String
getDeviceModel
()
{
return
deviceModel
;
}
public
void
setDeviceModel
(
String
deviceModel
)
{
this
.
deviceModel
=
deviceModel
;
}
public
String
getfIotNo
()
{
return
fIotNo
;
}
public
void
setfIotNo
(
String
fIotNo
)
{
this
.
fIotNo
=
fIotNo
;
}
public
String
getDetectionMedium
()
{
return
detectionMedium
;
}
public
void
setDetectionMedium
(
String
detectionMedium
)
{
this
.
detectionMedium
=
detectionMedium
;
}
public
Date
getDeviceInstallTime
()
{
return
deviceInstallTime
;
}
public
void
setDeviceInstallTime
(
Date
deviceInstallTime
)
{
this
.
deviceInstallTime
=
deviceInstallTime
;
}
public
String
getDeviceInstallPosition
()
{
return
deviceInstallPosition
;
}
public
void
setDeviceInstallPosition
(
String
deviceInstallPosition
)
{
this
.
deviceInstallPosition
=
deviceInstallPosition
;
}
public
String
getHead
()
{
return
head
;
}
public
void
setHead
(
String
head
)
{
this
.
head
=
head
;
}
public
String
getPhone
()
{
return
phone
;
}
public
void
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
}
}
zh-baseversion-system/src/main/java/com/zehong/system/service/ITDetectorUserService.java
View file @
b6911640
...
...
@@ -5,7 +5,6 @@ import java.util.Map;
import
com.zehong.system.domain.TDetectorUser
;
import
com.zehong.system.domain.TDetectorUserCount
;
import
com.zehong.system.domain.TEmployedPeopleInfoError
;
import
com.zehong.system.domain.vo.*
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -171,6 +170,21 @@ public interface ITDetectorUserService
* @param operName 操作用户
* @return 结果
*/
public
String
importEmployedPeopleInfo
(
List
<
GasUserAndSafetyDevice
ExportVo
>
XmbhList
,
Boolean
isUpdateSupport
,
String
operName
,
HttpServletResponse
response
);
public
String
importEmployedPeopleInfo
(
List
<
UserManageGasUser
ExportVo
>
XmbhList
,
Boolean
isUpdateSupport
,
String
operName
,
HttpServletResponse
response
);
/**
* 处理 解析好的 导入的数据
* @param dataInfos d
*/
public
void
handleCustomImportData
(
List
<
UserManageGasUserExportVo
>
dataInfos
,
boolean
updateSupport
)
;
/**
* 处理 解析好的 多sheet 导入的数据
* @param gasUserExportVos g
* @param safetyDeviceExportVos s
*/
public
void
handleCustomMoreSheetImportData
(
List
<
UserManageGasUserExportVo
>
gasUserExportVos
,
List
<
UserManageSafetyDeviceExportVo
>
safetyDeviceExportVos
,
boolean
updateSupport
)
;
}
zh-baseversion-system/src/main/java/com/zehong/system/service/impl/TDetectorUserServiceImpl.java
View file @
b6911640
...
...
@@ -9,10 +9,7 @@ import java.util.stream.Collectors;
import
com.zehong.common.utils.DateUtils
;
import
com.zehong.system.domain.TDetectorUserCount
;
import
com.zehong.system.domain.TGasuserSafetyDeviceInfo
;
import
com.zehong.system.domain.vo.GasUserAndSafetyDeviceExportVo
;
import
com.zehong.system.domain.vo.GasUserAndSafetyDeviceVo
;
import
com.zehong.system.domain.vo.TDetectorUserInspectVo
;
import
com.zehong.system.domain.vo.TDetectorUserVO
;
import
com.zehong.system.domain.vo.*
;
import
com.zehong.system.mapper.TDeviceInfoMapper
;
import
com.zehong.system.mapper.TGasuserSafetyDeviceInfoMapper
;
import
com.zehong.system.mapper.TSiteStationInfoMapper
;
...
...
@@ -411,13 +408,41 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
* @return
*/
@Override
public
String
importEmployedPeopleInfo
(
List
<
GasUserAndSafetyDevice
ExportVo
>
XmbhList
,
Boolean
isUpdateSupport
,
String
operName
,
HttpServletResponse
response
)
{
public
String
importEmployedPeopleInfo
(
List
<
UserManageGasUser
ExportVo
>
XmbhList
,
Boolean
isUpdateSupport
,
String
operName
,
HttpServletResponse
response
)
{
if
(
XmbhList
.
size
()
>
0
)
{
for
(
GasUserAndSafetyDeviceExportVo
gasUserAndSafetyDevice
ExportVo
:
XmbhList
)
{
System
.
out
.
println
(
gasUserAndSafetyDevice
ExportVo
.
getLinkman
());
for
(
UserManageGasUserExportVo
userManageGasUser
ExportVo
:
XmbhList
)
{
System
.
out
.
println
(
userManageGasUser
ExportVo
.
getLinkman
());
}
}
return
null
;
}
/**
* 处理解析好的 自定义模版的导入的数据
* @param dataInfos d
*/
@Override
public
void
handleCustomImportData
(
List
<
UserManageGasUserExportVo
>
dataInfos
,
boolean
updateSupport
)
{
}
/**
* 处理解析好的 自定义模版的导入的数据 多sheet
* @param gasUserExportVos d
* @param safetyDeviceExportVos s
*/
@Override
public
void
handleCustomMoreSheetImportData
(
List
<
UserManageGasUserExportVo
>
gasUserExportVos
,
List
<
UserManageSafetyDeviceExportVo
>
safetyDeviceExportVos
,
boolean
updateSupport
)
{
for
(
UserManageGasUserExportVo
gasUserExportVo
:
gasUserExportVos
)
{
System
.
out
.
println
(
gasUserExportVo
.
getAddress
());
}
for
(
UserManageSafetyDeviceExportVo
safetyDeviceExportVo
:
safetyDeviceExportVos
)
{
System
.
out
.
println
(
safetyDeviceExportVo
.
getDeviceModel
());
}
}
}
zh-baseversion-web/src/views/regulation/userManagement/gasUsers/index.vue
View file @
b6911640
...
...
@@ -538,7 +538,7 @@ export default {
// 设置上传的请求头部
headers
:
{
Authorization
:
"Bearer "
+
getToken
()
},
// 上传的地址
url
:
process
.
env
.
VUE_APP_BASE_API
+
"/supervise/user/
importCustom
"
// todo
url
:
process
.
env
.
VUE_APP_BASE_API
+
"/supervise/user/
moreSheetImportExcel
"
// todo
},
relationImg
:
require
(
'@/assets/project/relation.png'
),
...
...
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