Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataDeclaration
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
dataDeclaration
Commits
e680437a
提交
e680437a
authored
5月 20, 2021
作者:
xc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[设置] 修复了StaticSetting 字段中使用了保留字的BUG
上级
cebe9061
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
48 行增加
和
27 行删除
+48
-27
ExcelController.java
...java/com/tykj/model_layer/controller/ExcelController.java
+6
-0
ExcelData.java
src/main/java/com/tykj/model_layer/excel/ExcelData.java
+25
-10
StatisticsSetting.java
src/main/java/com/tykj/setting/entity/StatisticsSetting.java
+2
-2
StatisticsSettingRepository.java
.../tykj/setting/repository/StatisticsSettingRepository.java
+2
-2
StatisticsSettingService.java
...va/com/tykj/setting/service/StatisticsSettingService.java
+9
-9
application.yml
src/main/resources/application.yml
+4
-4
没有找到文件。
src/main/java/com/tykj/model_layer/controller/ExcelController.java
浏览文件 @
e680437a
...
@@ -70,4 +70,10 @@ public class ExcelController {
...
@@ -70,4 +70,10 @@ public class ExcelController {
return
excelData
.
findPath
();
return
excelData
.
findPath
();
}
}
@ApiOperation
(
"查询进度百分比"
)
@PostMapping
(
"/precent"
)
public
ResponseEntity
findPrecent
(){
return
excelData
.
findPrecen
();
}
}
}
src/main/java/com/tykj/model_layer/excel/ExcelData.java
浏览文件 @
e680437a
...
@@ -50,6 +50,7 @@ public class ExcelData {
...
@@ -50,6 +50,7 @@ public class ExcelData {
@Autowired
@Autowired
private
ExcelConfigDao
excelConfigDao
;
private
ExcelConfigDao
excelConfigDao
;
private
String
path
;
private
String
path
;
private
double
percent
;
private
String
successPath
=
System
.
getProperty
(
"user.dir"
)
+
"/successFile/"
;
private
String
successPath
=
System
.
getProperty
(
"user.dir"
)
+
"/successFile/"
;
private
String
errorPath
=
System
.
getProperty
(
"user.dir"
)
+
"/errorFile/"
;
private
String
errorPath
=
System
.
getProperty
(
"user.dir"
)
+
"/errorFile/"
;
private
String
tmpPath
=
System
.
getProperty
(
"user.dir"
)
+
"/tmp/"
;
private
String
tmpPath
=
System
.
getProperty
(
"user.dir"
)
+
"/tmp/"
;
...
@@ -95,6 +96,7 @@ public class ExcelData {
...
@@ -95,6 +96,7 @@ public class ExcelData {
String
successFileNameList
=
""
;
String
successFileNameList
=
""
;
String
errorFileNameList
=
""
;
String
errorFileNameList
=
""
;
String
errorReason
=
""
;
String
errorReason
=
""
;
int
total
=
dataFiles
.
length
;
for
(
File
dataFile
:
dataFiles
){
for
(
File
dataFile
:
dataFiles
){
List
<
Map
<
String
,
Object
>>
mapList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
mapList
=
new
ArrayList
<>();
//取模板,如果有模板文件传过来就解析模板文件并保存,否则就读本地模板
//取模板,如果有模板文件传过来就解析模板文件并保存,否则就读本地模板
...
@@ -156,16 +158,18 @@ public class ExcelData {
...
@@ -156,16 +158,18 @@ public class ExcelData {
}
}
}
}
int
re
=
modelService
.
putValueByEntityNameList
(
mapList
);
int
re
=
modelService
.
putValueByEntityNameList
(
mapList
);
if
(
re
==
0
){
if
(
re
==
0
){
successFileNameList
=
successFileNameList
+
"["
+
fileName
+
"]"
;
successFileNameList
=
successFileNameList
+
"["
+
fileName
+
"]"
;
dataFile
.
renameTo
(
new
File
(
successPath
+
fileName
));
dataFile
.
renameTo
(
new
File
(
successPath
+
fileName
));
}
else
{
}
else
{
errorFileNameList
=
errorFileNameList
+
"["
+
fileName
+
"]"
;
errorFileNameList
=
errorFileNameList
+
"["
+
fileName
+
"]"
;
errorReason
=
"不是excel文件或保存失败"
;
errorReason
=
"不是excel文件或保存失败"
;
dataFile
.
renameTo
(
new
File
(
errorPath
+
fileName
));
dataFile
.
renameTo
(
new
File
(
errorPath
+
fileName
));
}
}
total
=
total
-
1
;
}
}
percent
=
total
/
dataFiles
.
length
*
1.0
;
if
(!
""
.
equals
(
errorFileNameList
)){
if
(!
""
.
equals
(
errorFileNameList
)){
excelLogService
.
save
(
new
ExcelLog
(
"导入失败"
,
errorReason
,
errorFileNameList
));
excelLogService
.
save
(
new
ExcelLog
(
"导入失败"
,
errorReason
,
errorFileNameList
));
String
s
=
"没有文件"
;
String
s
=
"没有文件"
;
...
@@ -410,7 +414,13 @@ public class ExcelData {
...
@@ -410,7 +414,13 @@ public class ExcelData {
public
ResponseEntity
savePath
(
String
path
){
public
ResponseEntity
savePath
(
String
path
){
try
{
try
{
this
.
path
=
path
;
this
.
path
=
path
;
excelConfigDao
.
saveAndFlush
(
new
ExcelConfig
(
path
));
List
<
ExcelConfig
>
excelConfigs
=
excelConfigDao
.
findAll
();
ExcelConfig
excelConfig
=
new
ExcelConfig
();
if
(
excelConfigs
!=
null
&&
excelConfigs
.
size
()
>
0
){
excelConfig
=
excelConfigs
.
get
(
0
);
}
excelConfig
.
setPath
(
path
);
excelConfigDao
.
saveAndFlush
(
excelConfig
);
return
ResultUtil
.
success
(
""
,
"保存成功"
);
return
ResultUtil
.
success
(
""
,
"保存成功"
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -424,4 +434,9 @@ public class ExcelData {
...
@@ -424,4 +434,9 @@ public class ExcelData {
}
}
return
""
;
return
""
;
}
}
public
ResponseEntity
findPrecen
(){
return
ResultUtil
.
success
(
percent
,
"保存成功"
);
}
}
}
src/main/java/com/tykj/setting/entity/StatisticsSetting.java
浏览文件 @
e680437a
...
@@ -25,10 +25,10 @@ public class StatisticsSetting {
...
@@ -25,10 +25,10 @@ public class StatisticsSetting {
private
Integer
type
;
private
Integer
type
;
@ApiModelProperty
(
"序号"
)
@ApiModelProperty
(
"序号"
)
private
Integer
order
;
private
Integer
order
Pos
;
@ApiModelProperty
(
"参数内容 json格式"
)
@ApiModelProperty
(
"参数内容 json格式"
)
@
Column
(
columnDefinition
=
"text"
)
@
Lob
private
String
params
;
private
String
params
;
}
}
src/main/java/com/tykj/setting/repository/StatisticsSettingRepository.java
浏览文件 @
e680437a
...
@@ -8,8 +8,8 @@ import java.util.List;
...
@@ -8,8 +8,8 @@ import java.util.List;
public
interface
StatisticsSettingRepository
extends
JpaRepository
<
StatisticsSetting
,
Integer
>
{
public
interface
StatisticsSettingRepository
extends
JpaRepository
<
StatisticsSetting
,
Integer
>
{
List
<
StatisticsSetting
>
findAllByOrderGreaterThanEqual
(
Integer
index
);
List
<
StatisticsSetting
>
findAllByOrder
Pos
GreaterThanEqual
(
Integer
index
);
List
<
StatisticsSetting
>
findAllByOrderLessThanEqual
(
Integer
index
);
List
<
StatisticsSetting
>
findAllByOrder
Pos
LessThanEqual
(
Integer
index
);
}
}
src/main/java/com/tykj/setting/service/StatisticsSettingService.java
浏览文件 @
e680437a
...
@@ -43,7 +43,7 @@ public class StatisticsSettingService {
...
@@ -43,7 +43,7 @@ public class StatisticsSettingService {
}
}
public
List
<
StatisticsSettingVo
>
findByLimit
(
Integer
limit
)
{
public
List
<
StatisticsSettingVo
>
findByLimit
(
Integer
limit
)
{
List
<
StatisticsSetting
>
result
=
statisticsSettingRepository
.
findAllByOrderLessThanEqual
(
limit
);
List
<
StatisticsSetting
>
result
=
statisticsSettingRepository
.
findAllByOrder
Pos
LessThanEqual
(
limit
);
return
result
.
stream
()
return
result
.
stream
()
.
map
(
this
::
statisticsSettingVo
)
.
map
(
this
::
statisticsSettingVo
)
.
sorted
(
Comparator
.
comparingInt
(
StatisticsSettingVo:
:
getOrder
))
.
sorted
(
Comparator
.
comparingInt
(
StatisticsSettingVo:
:
getOrder
))
...
@@ -64,27 +64,27 @@ public class StatisticsSettingService {
...
@@ -64,27 +64,27 @@ public class StatisticsSettingService {
public
void
deleteById
(
Integer
id
)
{
public
void
deleteById
(
Integer
id
)
{
StatisticsSetting
statisticsSetting
=
statisticsSettingRepository
.
findById
(
id
).
orElseThrow
(()
->
new
RuntimeException
(
"未找到该id的数据"
));
StatisticsSetting
statisticsSetting
=
statisticsSettingRepository
.
findById
(
id
).
orElseThrow
(()
->
new
RuntimeException
(
"未找到该id的数据"
));
Integer
order
=
statisticsSetting
.
getOrder
();
Integer
order
=
statisticsSetting
.
getOrder
Pos
();
statisticsSettingRepository
.
deleteById
(
id
);
statisticsSettingRepository
.
deleteById
(
id
);
//矫正后排数据的序号
//矫正后排数据的序号
List
<
StatisticsSetting
>
otherStatisticsSettingList
=
statisticsSettingRepository
.
findAllByOrderGreaterThanEqual
(
order
);
List
<
StatisticsSetting
>
otherStatisticsSettingList
=
statisticsSettingRepository
.
findAllByOrder
Pos
GreaterThanEqual
(
order
);
for
(
StatisticsSetting
setting
:
otherStatisticsSettingList
)
{
for
(
StatisticsSetting
setting
:
otherStatisticsSettingList
)
{
setting
.
setOrder
(
setting
.
getOrder
()
-
1
);
setting
.
setOrder
Pos
(
setting
.
getOrderPos
()
-
1
);
statisticsSettingRepository
.
save
(
setting
);
statisticsSettingRepository
.
save
(
setting
);
}
}
}
}
private
void
handleAndSave
(
StatisticsSetting
statisticsSetting
)
{
private
void
handleAndSave
(
StatisticsSetting
statisticsSetting
)
{
Integer
order
=
statisticsSetting
.
getOrder
();
Integer
order
=
statisticsSetting
.
getOrder
Pos
();
long
count
=
statisticsSettingRepository
.
count
();
long
count
=
statisticsSettingRepository
.
count
();
if
(
Objects
.
isNull
(
order
)
||
order
>
count
+
1
||
order
<
0
)
{
if
(
Objects
.
isNull
(
order
)
||
order
>
count
+
1
||
order
<
0
)
{
//如果检查到序号值非法 则强制将序号赋值为末尾序号
//如果检查到序号值非法 则强制将序号赋值为末尾序号
statisticsSetting
.
setOrder
(
Math
.
toIntExact
(
count
+
1
));
statisticsSetting
.
setOrder
Pos
(
Math
.
toIntExact
(
count
+
1
));
}
else
{
}
else
{
//矫正后排数据的序号
//矫正后排数据的序号
List
<
StatisticsSetting
>
otherStatisticsSettingList
=
statisticsSettingRepository
.
findAllByOrder
GreaterThanEqual
(
statisticsSetting
.
getOrder
());
List
<
StatisticsSetting
>
otherStatisticsSettingList
=
statisticsSettingRepository
.
findAllByOrder
PosGreaterThanEqual
(
statisticsSetting
.
getOrderPos
());
for
(
StatisticsSetting
setting
:
otherStatisticsSettingList
)
{
for
(
StatisticsSetting
setting
:
otherStatisticsSettingList
)
{
setting
.
setOrder
(
setting
.
getOrder
()
+
1
);
setting
.
setOrder
Pos
(
setting
.
getOrderPos
()
+
1
);
statisticsSettingRepository
.
save
(
setting
);
statisticsSettingRepository
.
save
(
setting
);
}
}
}
}
...
@@ -120,7 +120,7 @@ public class StatisticsSettingService {
...
@@ -120,7 +120,7 @@ public class StatisticsSettingService {
statisticsSetting
.
getId
(),
statisticsSetting
.
getId
(),
statisticsSetting
.
getName
(),
statisticsSetting
.
getName
(),
statisticsSetting
.
getType
(),
statisticsSetting
.
getType
(),
statisticsSetting
.
getOrder
(),
statisticsSetting
.
getOrder
Pos
(),
params
params
);
);
}
}
...
...
src/main/resources/application.yml
浏览文件 @
e680437a
spring
:
spring
:
datasource
:
datasource
:
username
:
root
username
:
root
password
:
root
password
:
Huang123+
url
:
jdbc:mysql://
localhost:3306/data
?useSSL=false&serverTimezone=GMT%2b8&characterEncoding=utf-8
url
:
jdbc:mysql://
47.106.142.73:3306/dataTest
?useSSL=false&serverTimezone=GMT%2b8&characterEncoding=utf-8
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
jpa
:
jpa
:
show-sql
:
true
show-sql
:
true
hibernate
:
hibernate
:
ddl-auto
:
update
ddl-auto
:
update
server
:
server
:
port
:
8801
port
:
8801
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论