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
f159dae6
Commit
f159dae6
authored
Jun 16, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'm33' into 'master'
修改excel的格式和错误信息提示 See merge request
!37
parents
b101cb1f
323e93a9
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 @
f159dae6
...
@@ -5,6 +5,7 @@ import iot.sixiang.license.model.vo.ResourceVo;
...
@@ -5,6 +5,7 @@ import iot.sixiang.license.model.vo.ResourceVo;
import
iot.sixiang.license.service.ResourceService
;
import
iot.sixiang.license.service.ResourceService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -39,11 +40,21 @@ public class ResourceManager {
...
@@ -39,11 +40,21 @@ public class ResourceManager {
//第二步创建sheet
//第二步创建sheet
HSSFSheet
sheet
=
wb
.
createSheet
();
HSSFSheet
sheet
=
wb
.
createSheet
();
wb
.
setSheetName
(
0
,
sheetName
);
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
();
HSSFCellStyle
style
=
wb
.
createCellStyle
();
style
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
//居中
style
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
//居中
Font
font
=
wb
.
createFont
();
font
.
setFontName
(
"宋体"
);
style
.
setFont
(
font
);
//第三步创建行row:添加表头0行
//第三步创建行row:添加表头0行
HSSFRow
row
=
sheet
.
createRow
((
short
)
0
);
HSSFRow
row
=
sheet
.
createRow
((
short
)
0
);
...
@@ -51,23 +62,23 @@ public class ResourceManager {
...
@@ -51,23 +62,23 @@ public class ResourceManager {
//第四步创建单元格
//第四步创建单元格
HSSFCell
cell
=
row
.
createCell
((
short
)
0
);
//第一个单元格
HSSFCell
cell
=
row
.
createCell
((
short
)
0
);
//第一个单元格
cell
.
setCellValue
(
"公司名称"
);
cell
.
setCellValue
(
"公司名称"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
cell
=
row
.
createCell
((
short
)
1
);
//第二个单元格
cell
=
row
.
createCell
((
short
)
1
);
//第二个单元格
cell
.
setCellValue
(
"应用名称"
);
cell
.
setCellValue
(
"应用名称"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
cell
=
row
.
createCell
((
short
)
2
);
//第三个单元格
cell
=
row
.
createCell
((
short
)
2
);
//第三个单元格
cell
.
setCellValue
(
"app_id"
);
cell
.
setCellValue
(
"app_id"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
cell
=
row
.
createCell
((
short
)
3
);
//第四个单元格
cell
=
row
.
createCell
((
short
)
3
);
//第四个单元格
cell
.
setCellValue
(
"app_key"
);
cell
.
setCellValue
(
"app_key"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
cell
=
row
.
createCell
((
short
)
4
);
//第五个单元格
cell
=
row
.
createCell
((
short
)
4
);
//第五个单元格
cell
.
setCellValue
(
"sn"
);
cell
.
setCellValue
(
"sn"
);
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
Row
);
//第五步插入数据
//第五步插入数据
List
<
ResourceVo
>
resourceList
=
resourceService
.
getResource
(
userId
);
List
<
ResourceVo
>
resourceList
=
resourceService
.
getResource
(
userId
);
for
(
int
i
=
0
;
i
<
resourceList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
resourceList
.
size
();
i
++)
{
...
@@ -96,11 +107,10 @@ public class ResourceManager {
...
@@ -96,11 +107,10 @@ public class ResourceManager {
cell
.
setCellValue
(
resourceVo
.
getSn
());
cell
.
setCellValue
(
resourceVo
.
getSn
());
cell
.
setCellStyle
(
style
);
cell
.
setCellStyle
(
style
);
}
}
sheet
.
autoSizeColumn
((
short
)
0
);
//调整第一列宽度
//在填完所有值以后,对每一列设置自适应宽度
sheet
.
autoSizeColumn
((
short
)
1
);
//调整第二列宽度
for
(
int
n
=
0
;
n
<
5
;
n
++)
{
sheet
.
autoSizeColumn
((
short
)
2
);
//调整第三列宽度
sheet
.
autoSizeColumn
(
n
);
sheet
.
autoSizeColumn
((
short
)
3
);
//调整第四列宽度
}
sheet
.
autoSizeColumn
((
short
)
4
);
//调整第五列宽度
wb
.
write
(
os
);
wb
.
write
(
os
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
license/src/main/java/iot/sixiang/license/service/impl/ApplyServiceImpl.java
View file @
f159dae6
...
@@ -41,7 +41,7 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
...
@@ -41,7 +41,7 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
}
}
Apply
res
=
applyMapper
.
getApplyByAppName
(
appName
);
Apply
res
=
applyMapper
.
getApplyByAppName
(
appName
);
if
(
res
!=
null
)
{
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
()
);
throw
new
IotLicenseException
(
403
,
"应用名已存在"
);
}
}
String
appId
=
CommonUtil
.
genRandomNum
(
18
).
toLowerCase
();
String
appId
=
CommonUtil
.
genRandomNum
(
18
).
toLowerCase
();
boolean
re
=
applyMapper
.
addApply
(
appId
,
appName
,
appKey
,
userId
);
boolean
re
=
applyMapper
.
addApply
(
appId
,
appName
,
appKey
,
userId
);
...
...
license/src/main/java/iot/sixiang/license/service/impl/DeviceBlackServiceImpl.java
View file @
f159dae6
...
@@ -56,7 +56,7 @@ public class DeviceBlackServiceImpl extends ServiceImpl<DeviceBlackMapper, Devic
...
@@ -56,7 +56,7 @@ public class DeviceBlackServiceImpl extends ServiceImpl<DeviceBlackMapper, Devic
}
}
}
}
if
(!
flag
)
{
if
(!
flag
)
{
throw
new
IotLicenseException
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
()
);
throw
new
IotLicenseException
(
403
,
"设备不存在"
);
}
}
boolean
res
=
deviceBlackMapper
.
addDeviceBlack
(
deviceId
);
boolean
res
=
deviceBlackMapper
.
addDeviceBlack
(
deviceId
);
if
(
res
)
{
if
(
res
)
{
...
...
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
f159dae6
...
@@ -66,7 +66,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -66,7 +66,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
}
}
User
res
=
userMapper
.
getUserByUserName
(
userName
);
User
res
=
userMapper
.
getUserByUserName
(
userName
);
if
(
res
!=
null
)
{
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
()
);
throw
new
IotLicenseException
(
403
,
"用户名已存在"
);
}
}
return
userMapper
.
addUser
(
userName
,
company
,
password
);
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