Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 8d668e69
由
zshaohui
编写于
2023-02-17 15:46:11 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
系统设置-数据备份月数
1 个父辈
9f602532
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
30 行增加
和
17 行删除
src/main/java/com/neotel/smfcore/common/utils/Constants.java
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/SysSettingsDto.java
src/main/java/com/neotel/smfcore/core/system/util/DbBackupService.java
src/main/java/com/neotel/smfcore/common/utils/Constants.java
查看文件 @
8d668e6
...
...
@@ -148,4 +148,14 @@ public class Constants {
*/
public
static
final
String
CACHE_languageType
=
"CACHE_languageType"
;
/**
* 自动存档间隔Key
*/
public
static
final
String
BACKUP_MONTH_KEY
=
"db.backup.month"
;
/**
* 上次自动存档时间
*/
public
static
final
String
LAST_BACKUP_TIME_KEY
=
"db.backup.lastTime"
;
}
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
查看文件 @
8d668e6
...
...
@@ -18,6 +18,7 @@ import com.neotel.smfcore.core.system.rest.bean.dto.SettingsDto;
import
com.neotel.smfcore.core.system.rest.bean.dto.SysSettingsDto
;
import
com.neotel.smfcore.core.system.rest.bean.mapstruct.SettingsMapper
;
import
com.neotel.smfcore.core.system.service.po.Settings
;
import
com.neotel.smfcore.core.system.util.DbBackupService
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.bean.FileProperties
;
import
com.neotel.smfcore.security.rest.bean.dto.MenuDto
;
...
...
@@ -57,6 +58,10 @@ public class SettingsController {
@Autowired
private
final
FileProperties
properties
;
@Autowired
private
DbBackupService
dbBackupService
;
/**
* 当前版本
*/
...
...
@@ -74,26 +79,30 @@ public class SettingsController {
Integer
sluggishDay
=
dataCache
.
getCache
(
Constants
.
CACHE_SluggishDay
);
Integer
expiresDay
=
dataCache
.
getCache
(
Constants
.
CACHE_ExpiresDay
);
Integer
caWarn
=
dataCache
.
getCache
(
Constants
.
CACHE_CapacityWarn
);
Integer
backUpMonth
=
dataCache
.
getCache
(
Constants
.
BACKUP_MONTH_KEY
);
SysSettingsDto
dto
=
new
SysSettingsDto
();
dto
.
setStartJob
(
startJob
);
dto
.
setStopOut
(
stopOut
);
dto
.
setSluggishDay
(
sluggishDay
);
dto
.
setExpiresDay
(
expiresDay
);
dto
.
setCapacityWarn
(
caWarn
);
dto
.
setBackUpMonth
(
backUpMonth
);
return
dto
;
}
@ApiOperation
(
"修改系统设置信息"
)
@PutMapping
(
"/sysSettings"
)
@PreAuthorize
(
"@el.check('sysSetting')"
)
@AnonymousAccess
public
ResultBean
updateSysSettings
(
@Validated
@RequestBody
SysSettingsDto
sysSettingsDto
)
{
dataCache
.
updateCache
(
Constants
.
CACHE_StopOut
,
sysSettingsDto
.
isStopOut
());
dataCache
.
updateCache
(
Constants
.
CACHE_StartJob
,
sysSettingsDto
.
isStartJob
());
dataCache
.
updateCache
(
Constants
.
CACHE_SluggishDay
,
sysSettingsDto
.
getSluggishDay
());
dataCache
.
updateCache
(
Constants
.
CACHE_ExpiresDay
,
sysSettingsDto
.
getExpiresDay
());
dataCache
.
updateCache
(
Constants
.
CACHE_CapacityWarn
,
sysSettingsDto
.
getCapacityWarn
());
dataCache
.
updateCache
(
Constants
.
BACKUP_MONTH_KEY
,
sysSettingsDto
.
getBackUpMonth
());
log
.
info
(
"更改系统设置:stopout="
+
sysSettingsDto
.
isStopOut
()
+
",stopjob="
+
sysSettingsDto
.
isStartJob
()+
",sluggishDay="
+
sysSettingsDto
.
getSluggishDay
()
+
",expiresDay="
+
sysSettingsDto
.
getExpiresDay
()+
",capacityWarn="
+
sysSettingsDto
.
getCapacityWarn
());
+
",expiresDay="
+
sysSettingsDto
.
getExpiresDay
()+
",capacityWarn="
+
sysSettingsDto
.
getCapacityWarn
()
+
",backUpMonth="
+
sysSettingsDto
.
getBackUpMonth
()
);
return
ResultBean
.
newOkResult
(
"保存成功"
);
}
...
...
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/SysSettingsDto.java
查看文件 @
8d668e6
...
...
@@ -24,4 +24,7 @@ public class SysSettingsDto implements Serializable {
@ApiModelProperty
(
"容量预警"
)
private
Integer
capacityWarn
=
0
;
@ApiModelProperty
(
"备份时间"
)
private
Integer
backUpMonth
=
0
;
}
src/main/java/com/neotel/smfcore/core/system/util/DbBackupService.java
查看文件 @
8d668e6
package
com
.
neotel
.
smfcore
.
core
.
system
.
util
;
import
com.google.common.base.Strings
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.DateUtil
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.inList.service.po.InList
;
...
...
@@ -36,15 +37,6 @@ import java.util.concurrent.TimeUnit;
@Service
public
class
DbBackupService
{
/**
* 自动存档间隔Key
*/
private
String
BACKUP_MONTH_KEY
=
"db.backup.month"
;
/**
* 上次自动存档时间
*/
private
String
LAST_BACKUP_TIME_KEY
=
"db.backup.lastTime"
;
@Autowired
DataCache
dataCache
;
...
...
@@ -62,10 +54,10 @@ public class DbBackupService {
log
.
info
(
"开启数据库定时存档任务"
);
while
(
true
){
try
{
Integer
dbBackupMonth
=
dataCache
.
getCache
(
BACKUP_MONTH_KEY
);
dbBackupMonth
=
1
;
Integer
dbBackupMonth
=
dataCache
.
getCache
(
Constants
.
BACKUP_MONTH_KEY
);
//
dbBackupMonth = 1;
if
(
dbBackupMonth
!=
null
&&
dbBackupMonth
>
0
){
Date
lastBackupTime
=
dataCache
.
getCache
(
LAST_BACKUP_TIME_KEY
);
Date
lastBackupTime
=
dataCache
.
getCache
(
Constants
.
LAST_BACKUP_TIME_KEY
);
boolean
needBackup
=
false
;
if
(
lastBackupTime
==
null
){
needBackup
=
true
;
...
...
@@ -99,12 +91,11 @@ public class DbBackupService {
return
false
;
}
processing
=
true
;
Integer
dbBackupMonth
=
dataCache
.
getCache
(
BACKUP_MONTH_KEY
);
Integer
dbBackupMonth
=
dataCache
.
getCache
(
Constants
.
BACKUP_MONTH_KEY
);
if
(
dbBackupMonth
==
null
){
dbBackupMonth
=
12
;
//默认备份12个月前的数据
dataCache
.
updateCache
(
BACKUP_MONTH_KEY
,
dbBackupMonth
);
dataCache
.
updateCache
(
Constants
.
BACKUP_MONTH_KEY
,
dbBackupMonth
);
}
dataCache
.
updateCache
(
LAST_BACKUP_TIME_KEY
,
new
Date
());
backupTable
(
dbBackupMonth
,
DataLog
.
class
,
Humiture
.
class
,
...
...
@@ -115,6 +106,7 @@ public class DbBackupService {
Message
.
class
,
AlarmInfo
.
class
);
dataCache
.
updateCache
(
Constants
.
LAST_BACKUP_TIME_KEY
,
new
Date
());
processing
=
false
;
return
true
;
}
...
...
@@ -151,5 +143,4 @@ public class DbBackupService {
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论