Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
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
zengtianlai3
ioc_sixiang_license
Commits
323e93a9
Commit
323e93a9
authored
Jun 16, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改excel的格式和错误信息提示
parent
b101cb1f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
16 deletions
+26
-16
ResourceManager.java
...in/java/iot/sixiang/license/resource/ResourceManager.java
+23
-13
ApplyServiceImpl.java
...va/iot/sixiang/license/service/impl/ApplyServiceImpl.java
+1
-1
DeviceBlackServiceImpl.java
.../sixiang/license/service/impl/DeviceBlackServiceImpl.java
+1
-1
UserServiceImpl.java
...ava/iot/sixiang/license/service/impl/UserServiceImpl.java
+1
-1
No files found.
license/src/main/java/iot/sixiang/license/resource/ResourceManager.java
View file @
323e93a9
...
...
@@ -5,6 +5,7 @@ import iot.sixiang.license.model.vo.ResourceVo;
import
iot.sixiang.license.service.ResourceService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -39,11 +40,21 @@ public class ResourceManager {
//第二步创建sheet
HSSFSheet
sheet
=
wb
.
createSheet
();
wb
.
setSheetName
(
0
,
sheetName
);
sheet
.
setDefaultColumnWidth
(
20
);
//设置表格格式
// sheet.setDefaultColumnWidth(20);
//设置首行格式
HSSFCellStyle
styleRow
=
wb
.
createCellStyle
();
HSSFFont
font1
=
wb
.
createFont
();
font1
.
setFontName
(
"宋体"
);
font1
.
setBold
(
true
);
//粗体显示
styleRow
.
setFont
(
font1
);
//选择须要用到的字体格式
styleRow
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
//居中
//设置单元格格式
HSSFCellStyle
style
=
wb
.
createCellStyle
();
style
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
//居中
Font
font
=
wb
.
createFont
();
font
.
setFontName
(
"宋体"
);
style
.
setFont
(
font
);
//第三步创建行row:添加表头0行
HSSFRow
row
=
sheet
.
createRow
((
short
)
0
);
...
...
@@ -51,23 +62,23 @@ public class ResourceManager {
//第四步创建单元格
HSSFCell
cell
=
row
.
createCell
((
short
)
0
);
//第一个单元格
cell
.
setCellValue
(
"公司名称"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
cell
=
row
.
createCell
((
short
)
1
);
//第二个单元格
cell
.
setCellValue
(
"应用名称"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
cell
=
row
.
createCell
((
short
)
2
);
//第三个单元格
cell
.
setCellValue
(
"app_id"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
cell
=
row
.
createCell
((
short
)
3
);
//第四个单元格
cell
.
setCellValue
(
"app_key"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
cell
=
row
.
createCell
((
short
)
4
);
//第五个单元格
cell
.
setCellValue
(
"sn"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
//第五步插入数据
List
<
ResourceVo
>
resourceList
=
resourceService
.
getResource
(
userId
);
for
(
int
i
=
0
;
i
<
resourceList
.
size
();
i
++)
{
...
...
@@ -96,11 +107,10 @@ public class ResourceManager {
cell
.
setCellValue
(
resourceVo
.
getSn
());
cell
.
setCellStyle
(
style
);
}
sheet
.
autoSizeColumn
((
short
)
0
);
//调整第一列宽度
sheet
.
autoSizeColumn
((
short
)
1
);
//调整第二列宽度
sheet
.
autoSizeColumn
((
short
)
2
);
//调整第三列宽度
sheet
.
autoSizeColumn
((
short
)
3
);
//调整第四列宽度
sheet
.
autoSizeColumn
((
short
)
4
);
//调整第五列宽度
//在填完所有值以后,对每一列设置自适应宽度
for
(
int
n
=
0
;
n
<
5
;
n
++)
{
sheet
.
autoSizeColumn
(
n
);
}
wb
.
write
(
os
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
license/src/main/java/iot/sixiang/license/service/impl/ApplyServiceImpl.java
View file @
323e93a9
...
...
@@ -41,7 +41,7 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
}
Apply
res
=
applyMapper
.
getApplyByAppName
(
appName
);
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
()
);
throw
new
IotLicenseException
(
403
,
"应用名已存在"
);
}
String
appId
=
CommonUtil
.
genRandomNum
(
18
).
toLowerCase
();
boolean
re
=
applyMapper
.
addApply
(
appId
,
appName
,
appKey
,
userId
);
...
...
license/src/main/java/iot/sixiang/license/service/impl/DeviceBlackServiceImpl.java
View file @
323e93a9
...
...
@@ -56,7 +56,7 @@ public class DeviceBlackServiceImpl extends ServiceImpl<DeviceBlackMapper, Devic
}
}
if
(!
flag
)
{
throw
new
IotLicenseException
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
()
);
throw
new
IotLicenseException
(
403
,
"设备不存在"
);
}
boolean
res
=
deviceBlackMapper
.
addDeviceBlack
(
deviceId
);
if
(
res
)
{
...
...
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
323e93a9
...
...
@@ -66,7 +66,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
}
User
res
=
userMapper
.
getUserByUserName
(
userName
);
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
()
);
throw
new
IotLicenseException
(
403
,
"用户名已存在"
);
}
return
userMapper
.
addUser
(
userName
,
company
,
password
);
}
...
...
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