Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ba505a4a
由
LN
编写于
2021-12-20 16:06:37 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
系统设置中:暂停自动任务改为开启自动任务。
1 个父辈
b3f39fa3
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
473 行增加
和
397 行删除
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
src/main/java/com/neotel/smfcore/common/utils/Constants.java
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
src/main/java/com/neotel/smfcore/core/language/rest/LanguageMsgController.java
src/main/java/com/neotel/smfcore/core/language/util/MessageService.java
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
src/main/java/com/neotel/smfcore/core/order/LiteOrderCache.java
src/main/java/com/neotel/smfcore/core/storage/service/manager/impl/StoragePosManagerImpl.java
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/SysSettingsDto.java
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
查看文件 @
ba505a4
...
...
@@ -232,14 +232,15 @@ public class DataInitManager {
Menu
sysSetting
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"barcode"
,
"条码设置"
,
1
,
"barcodeSetting"
,
"system/barcodeSetting/index"
,
""
,
0
,
"database"
);
Menu
outSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"outSetting"
,
"出库策略"
,
1
,
"outSetting"
,
"system/outSetting/index"
,
""
,
0
,
"outSet"
);
Menu
sysSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"sysSetting"
,
"系统设置"
,
1
,
"sysSetting"
,
"system/sysSetting/index"
,
""
,
0
,
"sysSet"
);
Menu
translationSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"translation"
,
"资源翻译"
,
1
,
"translation"
,
"system/translation/index"
,
""
,
0
,
"sysSet"
);
Menu
translationSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"translation"
,
"资源翻译"
,
1
,
"translation"
,
"system/translation/index"
,
""
,
0
,
"translation"
);
Menu
orderSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"orderSetting"
,
"工单设置"
,
1
,
"orderSetting"
,
"system/orderSetting/index"
,
""
,
0
,
"sysSet"
);
menuMenu
.
setHidden
(
true
);
outSet
.
setHidden
(
true
);
sysSet
.
setHidden
(
true
);
// menuMenu.setHidden(true);
// sysSetting.setHidden(true);
menus
.
addAll
(
createMenus
(
poutSet
,
menuStorage
,
menuStoragePos
,
menuMenu
,
sysSetting
,
outSet
,
sysSet
,
translationSet
));
menus
.
addAll
(
createMenus
(
poutSet
,
menuStorage
,
menuStoragePos
,
menuMenu
,
sysSetting
,
outSet
,
sysSet
,
translationSet
,
orderSet
));
//用户管理:用户管理,角色管理
...
...
src/main/java/com/neotel/smfcore/common/utils/Constants.java
查看文件 @
ba505a4
...
...
@@ -94,10 +94,16 @@ public class Constants {
* 准备进行更新,不允许需求单出库
*/
public
static
final
String
CACHE_StopOut
=
"stopOut"
;
/**
*
停止定时器
任务
*
开启自动
任务
*/
public
static
final
String
CACHE_StopJob
=
"stopJob"
;
public
static
final
String
CACHE_StartJob
=
"startJob"
;
//
// /**
// * 停止定时器任务
// */
// public static final String CACHE_StopJob="stopJob";
/**
*出库策略配置: 出库方式类型
...
...
@@ -110,6 +116,11 @@ public class Constants {
public
static
final
String
CACHE_msdSetting
=
"msdSetting"
;
/**
*工单设置
*/
public
static
final
String
CACHE_OrderSetting
=
"orderSetting"
;
/**
* 客户端自定义配置
*/
public
static
final
String
CACHE_clientSetting
=
"clientSetting"
;
...
...
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
查看文件 @
ba505a4
...
...
@@ -86,8 +86,8 @@ public class DataCache {
if
(
cacheMap
.
get
(
Constants
.
CACHE_StopOut
)
==
null
)
{
updateCache
(
Constants
.
CACHE_StopOut
,
false
);
}
if
(
cacheMap
.
get
(
Constants
.
CACHE_St
op
Job
)
==
null
)
{
updateCache
(
Constants
.
CACHE_St
op
Job
,
false
);
if
(
cacheMap
.
get
(
Constants
.
CACHE_St
art
Job
)
==
null
)
{
updateCache
(
Constants
.
CACHE_St
art
Job
,
false
);
}
}
...
...
src/main/java/com/neotel/smfcore/core/language/rest/LanguageMsgController.java
查看文件 @
ba505a4
...
...
@@ -12,9 +12,9 @@ import com.neotel.smfcore.core.language.rest.bean.dto.LanguageResourceDto;
import
com.neotel.smfcore.core.language.rest.bean.mapstruct.LanguageMsgMapper
;
import
com.neotel.smfcore.core.language.rest.bean.query.LanguageMsgCriteria
;
import
com.neotel.smfcore.core.language.service.bean.Content
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager
;
import
com.neotel.smfcore.core.language.service.po.LanguageMsg
;
import
com.neotel.smfcore.core.language.util.MessageService
;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.bean.FileProperties
;
...
...
@@ -48,23 +48,16 @@ public class LanguageMsgController {
@Autowired
LanguageMsgMapper
languageMsgMapper
;
@Autowired
MessageService
messageService
;
@Autowired
private
final
FileProperties
properties
;
@Autowired
DataCache
dataCache
;
public
List
<
String
>
getAllLanList
()
{
List
<
LanguageInfo
>
lanList
=
dataCache
.
getLanguageList
();
List
<
String
>
list
=
new
ArrayList
<>();
for
(
LanguageInfo
lan
:
lanList
)
{
list
.
add
(
lan
.
getLanCode
());
}
return
list
;
}
@ApiOperation
(
"导入资源文件"
)
@PostMapping
(
value
=
"/upload"
)
...
...
@@ -88,15 +81,15 @@ public class LanguageMsgController {
String
lanType
=
getLanTypeByFileName
(
uploadFile
.
getOriginalFilename
());
if
(
smfclientType
.
contains
(
fileType
))
{
//客户端js文件处理
Map
<
String
,
String
>
proMap
=
MessageUtils
.
readJsFile
(
file
);
resultMsg
=
R
esourceUpload
(
uploadFile
.
getOriginalFilename
(),
proMap
,
lanType
,
"smfclient"
);
Map
<
String
,
String
>
proMap
=
messageService
.
readJsFile
(
file
);
resultMsg
=
messageService
.
r
esourceUpload
(
uploadFile
.
getOriginalFilename
(),
proMap
,
lanType
,
"smfclient"
);
}
else
if
(
smfcoreType
.
contains
(
fileType
))
{
Map
<
String
,
String
>
proMap
=
MessageUtils
.
readPropertiesFile
(
file
);
resultMsg
=
R
esourceUpload
(
uploadFile
.
getOriginalFilename
(),
proMap
,
lanType
,
""
);
Map
<
String
,
String
>
proMap
=
messageService
.
readPropertiesFile
(
file
);
resultMsg
=
messageService
.
r
esourceUpload
(
uploadFile
.
getOriginalFilename
(),
proMap
,
lanType
,
""
);
}
if
(
csvType
.
equals
(
fileType
)){
List
<
LanguageMsg
>
list
=
MessageUtils
.
readCsvFile
(
file
.
getAbsolutePath
(),
dataCache
.
getLanguageList
());
m
sgListUpload
(
list
);
List
<
LanguageMsg
>
list
=
messageService
.
readCsvFile
(
file
.
getAbsolutePath
(),
dataCache
.
getLanguageList
());
m
essageService
.
msgListUpload
(
file
.
getName
(),
list
);
}
return
ResultBean
.
newOkResult
(
resultMsg
);
}
...
...
@@ -106,7 +99,7 @@ public class LanguageMsgController {
@GetMapping
(
value
=
"/download"
)
public
void
download
(
HttpServletResponse
response
,
LanguageMsgCriteria
criteria
)
throws
Exception
{
Query
query
=
QueryHelp
.
getQuery
(
criteria
);
int
languageSize
=
getAllLanList
().
size
();
int
languageSize
=
messageService
.
getAllLanList
().
size
();
if
(
criteria
.
getTranslationState
()
!=
null
)
{
if
(
criteria
.
getTranslationState
()
==
1
)
{
// db.getCollection('languageMsg').find({contentList:{$elemMatch:{lanCode:"en-US"}}})
...
...
@@ -133,7 +126,7 @@ public class LanguageMsgController {
List
<
String
>
typeList
=
languageMsgManager
.
findTypeList
();
int
languageSize
=
getAllLanList
().
size
();
int
languageSize
=
messageService
.
getAllLanList
().
size
();
Query
query
=
QueryHelp
.
getQuery
(
criteria
);
if
(
criteria
.
getTranslationState
()
!=
null
)
{
if
(
criteria
.
getTranslationState
()
==
1
)
{
...
...
@@ -190,7 +183,7 @@ public class LanguageMsgController {
lanCode
=
lanCode
.
replace
(
"_"
,
"-"
);
List
<
LanguageMsg
>
msgList
=
MessageUtils
.
getLanMsgByType
(
type
);
Map
<
String
,
Map
<
String
,
String
>>
resourceMap
=
new
HashMap
<>();
List
<
String
>
allLantypeList
=
getAllLanList
();
List
<
String
>
allLantypeList
=
messageService
.
getAllLanList
();
for
(
LanguageMsg
msg
:
msgList
)
{
for
(
Content
con
:
...
...
@@ -235,7 +228,7 @@ public class LanguageMsgController {
String
type
=
paramsMap
.
get
(
"type"
).
toString
();
List
<
String
>
lanList
=
getAllLanList
();
List
<
String
>
lanList
=
messageService
.
getAllLanList
();
for
(
String
key
:
paramsMap
.
keySet
())
{
if
(
key
.
toString
().
equals
(
"type"
))
{
...
...
@@ -262,7 +255,7 @@ public class LanguageMsgController {
lanResourceMap
.
put
(
resKey
,
resValue
.
toString
());
}
}
R
esourceUpload
(
"接口上传"
,
lanResourceMap
,
lanType
,
type
);
messageService
.
r
esourceUpload
(
"接口上传"
,
lanResourceMap
,
lanType
,
type
);
}
return
ResultBean
.
newOkResult
(
"ok"
);
}
...
...
@@ -294,7 +287,7 @@ public class LanguageMsgController {
private
String
getLanTypeByFileName
(
String
orgFilename
)
{
String
tname
=
orgFilename
.
replace
(
'_'
,
'-'
);
for
(
String
lanType
:
getAllLanList
())
{
messageService
.
getAllLanList
())
{
if
(
tname
.
contains
(
lanType
)){
return
lanType
;
}
...
...
@@ -303,126 +296,5 @@ public class LanguageMsgController {
return
""
;
}
private
String
ResourceUpload
(
String
orgFileName
,
Map
<
String
,
String
>
proMap
,
String
lanCode
,
String
type
)
{
List
<
LanguageMsg
>
newLanguageList
=
new
ArrayList
<>();
List
<
LanguageMsg
>
updateLanguageList
=
new
ArrayList
<>();
if
(
proMap
!=
null
&&
proMap
.
size
()
>
0
)
{
for
(
String
key
:
proMap
.
keySet
())
{
String
msgStr
=
proMap
.
get
(
key
);
LanguageMsg
msg
=
MessageUtils
.
getMsg
(
type
,
key
);
//导入时只能新增不能修改
if
(
msg
==
null
)
{
msg
=
new
LanguageMsg
(
key
,
msgStr
,
type
);
msg
.
setContent
(
lanCode
,
msgStr
);
newLanguageList
.
add
(
msg
);
}
else
{
String
oldMsg
=
msg
.
getContent
(
lanCode
);
// if (!oldMsg.equals(msgStr)) {
if
(
ObjectUtil
.
isEmpty
(
oldMsg
)){
msg
.
setContent
(
lanCode
,
msgStr
);
//内容默认更改为中文
if
(
lanCode
.
equals
(
MessageUtils
.
ZH_CN
)){
if
(!
msg
.
getMsg
().
equals
(
msgStr
)){
msg
.
setMsg
(
msgStr
);
}
}
updateLanguageList
.
add
(
msg
);
languageMsgManager
.
save
(
msg
);
MessageUtils
.
updateMsg
(
msg
);
}
}
}
}
if
(
newLanguageList
.
size
()
>
0
)
{
languageMsgManager
.
insertAll
(
newLanguageList
);
for
(
LanguageMsg
msg
:
newLanguageList
)
{
MessageUtils
.
updateMsg
(
msg
);
}
}
log
.
info
(
"导入资源["
+
orgFileName
+
"]["
+
type
+
"]["
+
lanCode
+
"],共["
+
proMap
.
size
()+
"]条数据,共更新["
+
updateLanguageList
.
size
()
+
"]条资源,新增["
+
newLanguageList
.
size
()
+
"]条资源"
);
return
"ok"
;
}
private
void
msgListUpload
(
List
<
LanguageMsg
>
msgList
)
{
List
<
LanguageMsg
>
newLanguageList
=
new
ArrayList
<>();
List
<
LanguageMsg
>
updateLanguageList
=
new
ArrayList
<>();
for
(
LanguageMsg
msg
:
msgList
)
{
if
(
ObjectUtil
.
isEmpty
(
msg
.
getCode
()))
{
//code不能为空
continue
;
}
if
(
ObjectUtil
.
isEmpty
(
msg
.
getMsg
())){
//内容不能为空
continue
;
}
if
(
ObjectUtil
.
isEmpty
(
msg
.
getType
())){
//内容不能为空
continue
;
}
List
<
Content
>
contentList
=
new
ArrayList
<>();
for
(
Content
con
:
msg
.
getContentList
())
{
if
(
ObjectUtil
.
isEmpty
(
con
.
getLanCode
())
||
ObjectUtil
.
isEmpty
(
con
.
getMsg
()))
{
continue
;
}
contentList
.
add
(
con
);
}
//判断是否是新增
LanguageMsg
oldMsg
=
MessageUtils
.
getMsg
(
msg
.
getType
(),
msg
.
getCode
());
if
(
oldMsg
==
null
){
newLanguageList
.
add
(
msg
);
}
else
{
boolean
isUpdate
=
false
;
//只新增不修改
List
<
String
>
allLanList
=
getAllLanList
();
for
(
String
lanType
:
allLanList
)
{
String
oldValue
=
oldMsg
.
getContent
(
lanType
);
if
(
ObjectUtil
.
isEmpty
(
oldValue
)){
oldMsg
.
setContent
(
lanType
,
msg
.
getContent
(
lanType
));
isUpdate
=
true
;
//内容默认更改为中文
if
(
lanType
.
equals
(
MessageUtils
.
ZH_CN
)){
if
(!
oldMsg
.
getMsg
().
equals
(
oldValue
)){
oldMsg
.
setMsg
(
oldValue
);
}
}
}
}
if
(
isUpdate
){
updateLanguageList
.
add
(
oldMsg
);
languageMsgManager
.
save
(
oldMsg
);
MessageUtils
.
updateMsg
(
oldMsg
);
}
}
}
if
(
newLanguageList
.
size
()
>
0
)
{
languageMsgManager
.
insertAll
(
newLanguageList
);
for
(
LanguageMsg
msg
:
newLanguageList
)
{
MessageUtils
.
updateMsg
(
msg
);
}
}
log
.
info
(
"导入csv资源,共["
+
msgList
.
size
()+
"]条数据,共更新["
+
updateLanguageList
.
size
()
+
"]条资源,新增["
+
newLanguageList
.
size
()
+
"]条资源"
);
}
}
src/main/java/com/neotel/smfcore/core/language/util/MessageService.java
0 → 100644
查看文件 @
ba505a4
package
com
.
neotel
.
smfcore
.
core
.
language
.
util
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.csv.CsvReader
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.language.service.bean.Content
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager
;
import
com.neotel.smfcore.core.language.service.po.LanguageMsg
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Service
public
class
MessageService
{
@Autowired
ILanguageMsgManager
languageMsgManager
;
@Autowired
DataCache
dataCache
;
public
Map
<
String
,
Map
<
String
,
LanguageMsg
>>
loadMsgMap
()
{
Map
<
String
,
Map
<
String
,
LanguageMsg
>>
resourceMap
=
new
HashMap
<>();
List
<
LanguageMsg
>
msgs
=
languageMsgManager
.
findByQuery
(
new
Query
());
for
(
LanguageMsg
msg
:
msgs
)
{
if
(
msg
.
getCode
().
startsWith
(
"smfcode."
)||
msg
.
getType
().
equals
(
"smfcode"
)){
String
newCode
=
msg
.
getCode
().
replace
(
"smfcode."
,
"smfcore."
);
msg
.
setCode
(
newCode
);
msg
.
setType
(
"smfcore"
);
languageMsgManager
.
save
(
msg
);
}
Map
<
String
,
LanguageMsg
>
typeMap
=
resourceMap
.
get
(
msg
.
getType
());
if
(
typeMap
==
null
){
typeMap
=
new
HashMap
<>();
}
typeMap
.
put
(
msg
.
getCode
(),
msg
);
resourceMap
.
put
(
msg
.
getType
(),
typeMap
);
}
log
.
info
(
"loadMsgMap 共加载到"
+
msgs
.
size
()
+
"条Msg"
);
return
resourceMap
;
}
public
void
autoImportCsvFile
(){
String
fielPath
=
"D:\\resources\\"
;
File
file
=
new
File
(
fielPath
);
//需要获取的文件的路径
List
<
LanguageInfo
>
languageInfoList
=
dataCache
.
getLanguageList
();
if
(
file
.
exists
()
&&
file
.
isDirectory
())
{
String
[]
fileNameLists
=
file
.
list
();
//存储文件名的String数组
File
[]
filePathLists
=
file
.
listFiles
();
//存储文件路径的String数组
for
(
int
i
=
0
;
i
<
filePathLists
.
length
;
i
++)
{
//只读取后缀名为csv的
if
(
filePathLists
[
i
].
isFile
())
{
String
fileName
=
filePathLists
[
i
].
getName
();
if
(
fileName
.
endsWith
(
".csv"
))
{
try
{
List
<
LanguageMsg
>
msgList
=
readCsvFile
(
filePathLists
[
i
].
getAbsolutePath
(),
languageInfoList
);
if
(
msgList
.
size
()>
0
){
msgListUpload
(
fileName
,
msgList
);
}
}
catch
(
Exception
ex
){
log
.
info
(
"autoImportCsvFile 读取文件"
+
fileName
+
"错误:"
+
ex
.
toString
());
}
}
}
}
}
}
public
void
autoImportProperties
()
{
String
fielPath
=
"D:\\resources"
;
File
file
=
new
File
(
fielPath
);
//需要获取的文件的路径
if
(
file
.
exists
()
&&
file
.
isDirectory
())
{
String
[]
fileNameLists
=
file
.
list
();
//存储文件名的String数组
File
[]
filePathLists
=
file
.
listFiles
();
//存储文件路径的String数组
Map
<
String
,
String
>
defaultLanMap
=
new
HashMap
<>();
Map
<
String
,
Map
<
String
,
String
>>
lanMsgMap
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
filePathLists
.
length
;
i
++)
{
if
(
filePathLists
[
i
].
isFile
())
{
String
fileName
=
filePathLists
[
i
].
getName
();
if
(
fileName
.
endsWith
(
".properties"
))
{
String
lanType
=
fileName
.
replace
(
"messages"
,
""
).
replace
(
".properties"
,
""
);
if
(
ObjectUtil
.
isEmpty
(
lanType
))
{
defaultLanMap
=
readPropertiesFile
(
filePathLists
[
i
]);
log
.
info
(
"MessageCache 从文件["
+
fileName
+
"]中导入["
+
defaultLanMap
.
size
()
+
"]条默认资源"
);
}
else
{
String
lan
=
lanType
.
substring
(
1
);
lan
=
lan
.
replace
(
'_'
,
'-'
);
Map
<
String
,
String
>
map
=
readPropertiesFile
(
filePathLists
[
i
]);
lanMsgMap
.
put
(
lan
,
map
);
log
.
info
(
"MessageCache 从文件["
+
fileName
+
"]中导入["
+
defaultLanMap
.
size
()
+
"]条["
+
lan
+
"]资源"
);
}
}
}
}
List
<
LanguageMsg
>
languageMsgs
=
new
ArrayList
<>();
for
(
String
code
:
defaultLanMap
.
keySet
())
{
String
defMsg
=
defaultLanMap
.
get
(
code
);
LanguageMsg
msg
=
new
LanguageMsg
(
code
,
defMsg
,
""
);
for
(
String
lan
:
lanMsgMap
.
keySet
())
{
if
(
lanMsgMap
.
get
(
lan
).
containsKey
(
code
))
{
String
lanMsg
=
lanMsgMap
.
get
(
lan
).
get
(
code
);
msg
.
setContent
(
lan
,
lanMsg
);
}
}
languageMsgs
.
add
(
msg
);
}
languageMsgManager
.
insertAll
(
languageMsgs
);
}
}
public
List
<
String
>
getAllLanList
()
{
List
<
LanguageInfo
>
lanList
=
dataCache
.
getLanguageList
();
List
<
String
>
list
=
new
ArrayList
<>();
for
(
LanguageInfo
lan
:
lanList
)
{
list
.
add
(
lan
.
getLanCode
());
}
return
list
;
}
public
String
resourceUpload
(
String
orgFileName
,
Map
<
String
,
String
>
proMap
,
String
lanCode
,
String
type
)
{
List
<
LanguageMsg
>
newLanguageList
=
new
ArrayList
<>();
List
<
LanguageMsg
>
updateLanguageList
=
new
ArrayList
<>();
if
(
proMap
!=
null
&&
proMap
.
size
()
>
0
)
{
for
(
String
key
:
proMap
.
keySet
())
{
String
msgStr
=
proMap
.
get
(
key
);
LanguageMsg
msg
=
MessageUtils
.
getMsg
(
type
,
key
);
//导入时只能新增不能修改
if
(
msg
==
null
)
{
msg
=
new
LanguageMsg
(
key
,
msgStr
,
type
);
msg
.
setContent
(
lanCode
,
msgStr
);
newLanguageList
.
add
(
msg
);
}
else
{
String
oldMsg
=
msg
.
getContent
(
lanCode
);
// if (!oldMsg.equals(msgStr)) {
if
(
ObjectUtil
.
isEmpty
(
oldMsg
)){
msg
.
setContent
(
lanCode
,
msgStr
);
//内容默认更改为中文
if
(
lanCode
.
equals
(
MessageUtils
.
ZH_CN
)){
if
(!
msg
.
getMsg
().
equals
(
msgStr
)){
msg
.
setMsg
(
msgStr
);
}
}
updateLanguageList
.
add
(
msg
);
languageMsgManager
.
save
(
msg
);
MessageUtils
.
updateMsg
(
msg
);
}
}
}
}
if
(
newLanguageList
.
size
()
>
0
)
{
languageMsgManager
.
insertAll
(
newLanguageList
);
for
(
LanguageMsg
msg
:
newLanguageList
)
{
MessageUtils
.
updateMsg
(
msg
);
}
}
log
.
info
(
"导入资源["
+
orgFileName
+
"]["
+
type
+
"]["
+
lanCode
+
"],共["
+
proMap
.
size
()+
"]条数据,共更新["
+
updateLanguageList
.
size
()
+
"]条资源,新增["
+
newLanguageList
.
size
()
+
"]条资源"
);
return
"ok"
;
}
public
void
msgListUpload
(
String
fileName
,
List
<
LanguageMsg
>
msgList
)
{
List
<
LanguageMsg
>
newLanguageList
=
new
ArrayList
<>();
List
<
LanguageMsg
>
updateLanguageList
=
new
ArrayList
<>();
for
(
LanguageMsg
msg
:
msgList
)
{
if
(
ObjectUtil
.
isEmpty
(
msg
.
getCode
()))
{
//code不能为空
continue
;
}
if
(
ObjectUtil
.
isEmpty
(
msg
.
getMsg
())){
//内容不能为空
continue
;
}
if
(
ObjectUtil
.
isEmpty
(
msg
.
getType
())){
//内容不能为空
continue
;
}
List
<
Content
>
contentList
=
new
ArrayList
<>();
for
(
Content
con
:
msg
.
getContentList
())
{
if
(
ObjectUtil
.
isEmpty
(
con
.
getLanCode
())
||
ObjectUtil
.
isEmpty
(
con
.
getMsg
()))
{
continue
;
}
contentList
.
add
(
con
);
}
//判断是否是新增
LanguageMsg
oldMsg
=
MessageUtils
.
getMsg
(
msg
.
getType
(),
msg
.
getCode
());
if
(
oldMsg
==
null
){
newLanguageList
.
add
(
msg
);
}
else
{
boolean
isUpdate
=
false
;
//只新增不修改
List
<
String
>
allLanList
=
getAllLanList
();
for
(
String
lanType
:
allLanList
)
{
String
oldValue
=
oldMsg
.
getContent
(
lanType
);
if
(
ObjectUtil
.
isEmpty
(
oldValue
)){
oldMsg
.
setContent
(
lanType
,
msg
.
getContent
(
lanType
));
isUpdate
=
true
;
//内容默认更改为中文
if
(
lanType
.
equals
(
MessageUtils
.
ZH_CN
)){
if
(!
oldMsg
.
getMsg
().
equals
(
oldValue
)){
oldMsg
.
setMsg
(
oldValue
);
}
}
}
}
if
(
isUpdate
){
updateLanguageList
.
add
(
oldMsg
);
languageMsgManager
.
save
(
oldMsg
);
MessageUtils
.
updateMsg
(
oldMsg
);
}
}
}
if
(
newLanguageList
.
size
()
>
0
)
{
languageMsgManager
.
insertAll
(
newLanguageList
);
for
(
LanguageMsg
msg
:
newLanguageList
)
{
MessageUtils
.
updateMsg
(
msg
);
}
}
log
.
info
(
"导入csv["
+
fileName
+
"]资源,共["
+
msgList
.
size
()+
"]条数据,共更新["
+
updateLanguageList
.
size
()
+
"]条资源,新增["
+
newLanguageList
.
size
()
+
"]条资源"
);
}
public
Map
<
String
,
String
>
readPropertiesFile
(
File
file
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
try
(
FileInputStream
fis
=
new
FileInputStream
(
file
.
getPath
());
InputStreamReader
isr
=
new
InputStreamReader
(
fis
,
"UTF-8"
);
BufferedReader
br
=
new
BufferedReader
(
isr
)
)
{
String
line
;
//网友推荐更加简洁的写法
while
((
line
=
br
.
readLine
())
!=
null
)
{
// 一次读入一行数据
// System.out.println(line);
String
[]
array
=
line
.
split
(
"="
);
if
(
array
.
length
==
2
)
{
map
.
put
(
array
[
0
].
trim
(),
array
[
1
].
trim
());
}
}
}
catch
(
IOException
e
)
{
log
.
error
(
"ReadPropertiesFile 出错:"
+
e
.
toString
());
e
.
printStackTrace
();
}
return
map
;
}
public
List
<
LanguageMsg
>
readCsvFile
(
String
fileURL
,
List
<
LanguageInfo
>
languageInfos
)
throws
Exception
{
CsvReader
csvRead
=
CsvReader
.
newReader
(
fileURL
,
"编号"
,
"code"
);
int
codeIndex
=
csvRead
.
getCsvIndex
(
"编号"
,
"code"
);
int
typeIndex
=
csvRead
.
getCsvIndex
(
"类型"
,
"type"
);
int
msgIndex
=
csvRead
.
getCsvIndex
(
"内容"
,
"msg"
);
Map
<
String
,
Integer
>
lanCodeIndex
=
new
HashMap
<>()
;
// List<LanguageInfo> languageInfos=dataCache.getLanguageList();
for
(
LanguageInfo
lan:
languageInfos
)
{
int
lanIndex
=
csvRead
.
getCsvIndex
(
lan
.
getLanCode
(),
lan
.
getLanName
());
if
(
lanIndex
>=
0
){
lanCodeIndex
.
put
(
lan
.
getLanCode
(),
lanIndex
);
}
}
int
row
=
1
;
int
newRowCount
=
0
;
int
updateRowCount
=
0
;
String
msg
=
""
;
List
<
LanguageMsg
>
list
=
new
ArrayList
<>();
while
(
csvRead
.
readRecord
())
{
row
++;
String
[]
lineValues
=
csvRead
.
getValues
();
LanguageMsg
languageMsg
=
new
LanguageMsg
();
String
code
=
lineValues
[
codeIndex
];
String
type
=
lineValues
[
typeIndex
];
String
msgStr
=
lineValues
[
msgIndex
];
if
(
code
.
isEmpty
()
||
type
.
isEmpty
()
||
msgStr
.
isEmpty
())
{
log
.
warn
(
"第"
+
row
+
"行中有空白内容,此行忽略"
);
continue
;
}
languageMsg
.
setMsg
(
msgStr
);
languageMsg
.
setCode
(
code
);
languageMsg
.
setType
(
type
);
for
(
String
lan
:
lanCodeIndex
.
keySet
())
{
int
lanIndex
=
lanCodeIndex
.
get
(
lan
);
String
lanMsg
=
lineValues
[
lanIndex
];
if
(!
lanMsg
.
isEmpty
()){
languageMsg
.
setContent
(
lan
,
lanMsg
);
}
}
list
.
add
(
languageMsg
);
}
return
list
;
}
public
Map
<
String
,
String
>
readJsFile
(
File
file
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
try
(
FileInputStream
fis
=
new
FileInputStream
(
file
.
getPath
());
InputStreamReader
isr
=
new
InputStreamReader
(
fis
,
"UTF-8"
);
BufferedReader
br
=
new
BufferedReader
(
isr
)
)
{
String
line
;
//网友推荐更加简洁的写法
int
lineIndex
=-
1
;
String
currNodeName
=
""
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
lineIndex
++;
// if(lineIndex==0){
// continue;
// }
if
(
ObjectUtil
.
isEmpty
(
line
)){
continue
;
}
if
(
line
.
contains
(
"{"
)){
if
(
line
.
contains
(
"="
)){
currNodeName
=
""
;
}
else
{
int
dendIndex
=
line
.
indexOf
(
':'
);
String
lineNode
=
line
.
substring
(
0
,
dendIndex
).
trim
();
if
(
ObjectUtil
.
isEmpty
(
currNodeName
)){
currNodeName
=
lineNode
;
}
else
{
//节点名称+
currNodeName
=
currNodeName
+
"."
+
lineNode
;
}
}
}
else
if
(
line
.
contains
(
"}"
)){
//节点名称-
if
(
currNodeName
.
contains
(
"."
)){
int
endIndex
=
currNodeName
.
lastIndexOf
(
"."
);
currNodeName
=
currNodeName
.
substring
(
0
,
endIndex
);
}
else
{
currNodeName
=
""
;
}
}
else
if
(
line
.
contains
(
":"
)){
if
(
line
.
endsWith
(
","
)){
line
=
line
.
substring
(
0
,
line
.
length
()-
1
);
}
String
[]
array
=
line
.
replace
(
"'"
,
""
).
replace
(
"\""
,
""
).
split
(
":"
);
if
(
array
.
length
==
2
){
String
linekey
=
array
[
0
].
trim
();
String
lineValue
=
array
[
1
].
trim
();
map
.
put
(
currNodeName
+
"."
+
linekey
,
lineValue
);
}
}
}
}
catch
(
IOException
e
)
{
log
.
error
(
"readJsFile 出错:"
+
e
.
toString
());
e
.
printStackTrace
();
}
return
map
;
}
}
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
查看文件 @
ba505a4
...
...
@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.language.util;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.csv.CsvReader
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.language.service.bean.Content
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager
;
...
...
@@ -65,7 +66,11 @@ public class MessageUtils {
@Autowired
ILanguageMsgManager
languageMsgManager
;
@Autowired
DataCache
dataCache
;
@Autowired
MessageService
messageService
;
public
static
final
String
ZH_CN
=
"zh-CN"
;
public
static
final
String
ZH_TW
=
"zh-TW"
;
...
...
@@ -82,6 +87,20 @@ public class MessageUtils {
}
private
void
initLanguageMsgList
()
{
msgMap
=
messageService
.
loadMsgMap
();
if
(
msgMap
.
size
()
>
0
)
{
return
;
}
//自动导入CSV内容
messageService
.
autoImportCsvFile
();
messageService
.
autoImportProperties
();
msgMap
=
messageService
.
loadMsgMap
();
}
//-----------------以下为从缓存读取资源-------------------------------------
public
static
Locale
getDefaultLocal
(){
return
new
Locale
(
"zh-CH"
);
...
...
@@ -160,36 +179,8 @@ public class MessageUtils {
if
(
typeMap
!=
null
){
msgList
=
new
ArrayList
<>(
typeMap
.
values
());
}
// for (LanguageMsg msg :
// msgMap.values()) {
// if(msg.getType().equals(type)){
// msgList.add(msg);
// }
// }
return
msgList
;
}
private
Map
<
String
,
Map
<
String
,
LanguageMsg
>>
loadMsgMap
()
{
Map
<
String
,
Map
<
String
,
LanguageMsg
>>
resourceMap
=
new
HashMap
<>();
List
<
LanguageMsg
>
msgs
=
languageMsgManager
.
findByQuery
(
new
Query
());
for
(
LanguageMsg
msg
:
msgs
)
{
if
(
msg
.
getCode
().
startsWith
(
"smfcode."
)||
msg
.
getType
().
equals
(
"smfcode"
)){
String
newCode
=
msg
.
getCode
().
replace
(
"smfcode."
,
"smfcore."
);
msg
.
setCode
(
newCode
);
msg
.
setType
(
"smfcore"
);
languageMsgManager
.
save
(
msg
);
}
Map
<
String
,
LanguageMsg
>
typeMap
=
resourceMap
.
get
(
msg
.
getType
());
if
(
typeMap
==
null
){
typeMap
=
new
HashMap
<>();
}
typeMap
.
put
(
msg
.
getCode
(),
msg
);
resourceMap
.
put
(
msg
.
getType
(),
typeMap
);
}
log
.
info
(
"MessageCache共加载到"
+
msgs
.
size
()
+
"条Msg"
);
return
resourceMap
;
}
public
static
List
<
LanguageInfo
>
getDefaultLanList
()
{
List
<
LanguageInfo
>
lanList
=
new
ArrayList
<>();
...
...
@@ -205,217 +196,4 @@ public class MessageUtils {
private
void
initLanguageMsgList
()
{
msgMap
=
loadMsgMap
();
if
(
msgMap
.
size
()
>
0
)
{
return
;
}
//自动导入CSV内容
autoImportCsvFile
();
autoImportProperties
();
msgMap
=
loadMsgMap
();
}
private
void
autoImportCsvFile
(){
}
private
void
autoImportProperties
()
{
String
fielPath
=
"D:\\resources"
;
File
file
=
new
File
(
fielPath
);
//需要获取的文件的路径
if
(
file
.
exists
()
&&
file
.
isDirectory
())
{
String
[]
fileNameLists
=
file
.
list
();
//存储文件名的String数组
File
[]
filePathLists
=
file
.
listFiles
();
//存储文件路径的String数组
Map
<
String
,
String
>
defaultLanMap
=
new
HashMap
<>();
Map
<
String
,
Map
<
String
,
String
>>
lanMsgMap
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
filePathLists
.
length
;
i
++)
{
if
(
filePathLists
[
i
].
isFile
())
{
String
fileName
=
filePathLists
[
i
].
getName
();
if
(
fileName
.
endsWith
(
".properties"
))
{
String
lanType
=
fileName
.
replace
(
"messages"
,
""
).
replace
(
".properties"
,
""
);
if
(
ObjectUtil
.
isEmpty
(
lanType
))
{
defaultLanMap
=
readPropertiesFile
(
filePathLists
[
i
]);
log
.
info
(
"MessageCache 从文件["
+
fileName
+
"]中导入["
+
defaultLanMap
.
size
()
+
"]条默认资源"
);
}
else
{
String
lan
=
lanType
.
substring
(
1
);
lan
=
lan
.
replace
(
'_'
,
'-'
);
Map
<
String
,
String
>
map
=
readPropertiesFile
(
filePathLists
[
i
]);
lanMsgMap
.
put
(
lan
,
map
);
log
.
info
(
"MessageCache 从文件["
+
fileName
+
"]中导入["
+
defaultLanMap
.
size
()
+
"]条["
+
lan
+
"]资源"
);
}
}
}
}
List
<
LanguageMsg
>
languageMsgs
=
new
ArrayList
<>();
for
(
String
code
:
defaultLanMap
.
keySet
())
{
String
defMsg
=
defaultLanMap
.
get
(
code
);
LanguageMsg
msg
=
new
LanguageMsg
(
code
,
defMsg
,
""
);
for
(
String
lan
:
lanMsgMap
.
keySet
())
{
if
(
lanMsgMap
.
get
(
lan
).
containsKey
(
code
))
{
String
lanMsg
=
lanMsgMap
.
get
(
lan
).
get
(
code
);
msg
.
setContent
(
lan
,
lanMsg
);
}
}
languageMsgs
.
add
(
msg
);
}
languageMsgManager
.
insertAll
(
languageMsgs
);
}
}
public
static
Map
<
String
,
String
>
readPropertiesFile
(
File
file
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
try
(
FileInputStream
fis
=
new
FileInputStream
(
file
.
getPath
());
InputStreamReader
isr
=
new
InputStreamReader
(
fis
,
"UTF-8"
);
BufferedReader
br
=
new
BufferedReader
(
isr
)
)
{
String
line
;
//网友推荐更加简洁的写法
while
((
line
=
br
.
readLine
())
!=
null
)
{
// 一次读入一行数据
// System.out.println(line);
String
[]
array
=
line
.
split
(
"="
);
if
(
array
.
length
==
2
)
{
map
.
put
(
array
[
0
].
trim
(),
array
[
1
].
trim
());
}
}
}
catch
(
IOException
e
)
{
log
.
error
(
"ReadPropertiesFile 出错:"
+
e
.
toString
());
e
.
printStackTrace
();
}
return
map
;
}
public
static
List
<
LanguageMsg
>
readCsvFile
(
String
fileURL
,
List
<
LanguageInfo
>
languageInfos
)
throws
Exception
{
CsvReader
csvRead
=
CsvReader
.
newReader
(
fileURL
,
"编号"
,
"code"
);
int
codeIndex
=
csvRead
.
getCsvIndex
(
"编号"
,
"code"
);
int
typeIndex
=
csvRead
.
getCsvIndex
(
"类型"
,
"type"
);
int
msgIndex
=
csvRead
.
getCsvIndex
(
"内容"
,
"msg"
);
Map
<
String
,
Integer
>
lanCodeIndex
=
new
HashMap
<>()
;
// List<LanguageInfo> languageInfos=dataCache.getLanguageList();
for
(
LanguageInfo
lan:
languageInfos
)
{
int
lanIndex
=
csvRead
.
getCsvIndex
(
lan
.
getLanCode
(),
lan
.
getLanName
());
if
(
lanIndex
>=
0
){
lanCodeIndex
.
put
(
lan
.
getLanCode
(),
lanIndex
);
}
}
int
row
=
1
;
int
newRowCount
=
0
;
int
updateRowCount
=
0
;
String
msg
=
""
;
List
<
LanguageMsg
>
list
=
new
ArrayList
<>();
while
(
csvRead
.
readRecord
())
{
row
++;
String
[]
lineValues
=
csvRead
.
getValues
();
LanguageMsg
languageMsg
=
new
LanguageMsg
();
String
code
=
lineValues
[
codeIndex
];
String
type
=
lineValues
[
typeIndex
];
String
msgStr
=
lineValues
[
msgIndex
];
if
(
code
.
isEmpty
()
||
type
.
isEmpty
()
||
msgStr
.
isEmpty
())
{
log
.
warn
(
"第"
+
row
+
"行中有空白内容,此行忽略"
);
continue
;
}
languageMsg
.
setMsg
(
msgStr
);
languageMsg
.
setCode
(
code
);
languageMsg
.
setType
(
type
);
for
(
String
lan
:
lanCodeIndex
.
keySet
())
{
int
lanIndex
=
lanCodeIndex
.
get
(
lan
);
String
lanMsg
=
lineValues
[
lanIndex
];
if
(!
lanMsg
.
isEmpty
()){
languageMsg
.
setContent
(
lan
,
lanMsg
);
}
}
list
.
add
(
languageMsg
);
}
return
list
;
}
public
static
Map
<
String
,
String
>
readJsFile
(
File
file
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
try
(
FileInputStream
fis
=
new
FileInputStream
(
file
.
getPath
());
InputStreamReader
isr
=
new
InputStreamReader
(
fis
,
"UTF-8"
);
BufferedReader
br
=
new
BufferedReader
(
isr
)
)
{
String
line
;
//网友推荐更加简洁的写法
int
lineIndex
=-
1
;
String
currNodeName
=
""
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
lineIndex
++;
// if(lineIndex==0){
// continue;
// }
if
(
ObjectUtil
.
isEmpty
(
line
)){
continue
;
}
if
(
line
.
contains
(
"{"
)){
if
(
line
.
contains
(
"="
)){
currNodeName
=
""
;
}
else
{
int
dendIndex
=
line
.
indexOf
(
':'
);
String
lineNode
=
line
.
substring
(
0
,
dendIndex
).
trim
();
if
(
ObjectUtil
.
isEmpty
(
currNodeName
)){
currNodeName
=
lineNode
;
}
else
{
//节点名称+
currNodeName
=
currNodeName
+
"."
+
lineNode
;
}
}
}
else
if
(
line
.
contains
(
"}"
)){
//节点名称-
if
(
currNodeName
.
contains
(
"."
)){
int
endIndex
=
currNodeName
.
lastIndexOf
(
"."
);
currNodeName
=
currNodeName
.
substring
(
0
,
endIndex
);
}
else
{
currNodeName
=
""
;
}
}
else
if
(
line
.
contains
(
":"
)){
if
(
line
.
endsWith
(
","
)){
line
=
line
.
substring
(
0
,
line
.
length
()-
1
);
}
String
[]
array
=
line
.
replace
(
"'"
,
""
).
replace
(
"\""
,
""
).
split
(
":"
);
if
(
array
.
length
==
2
){
String
linekey
=
array
[
0
].
trim
();
String
lineValue
=
array
[
1
].
trim
();
map
.
put
(
currNodeName
+
"."
+
linekey
,
lineValue
);
}
}
}
}
catch
(
IOException
e
)
{
log
.
error
(
"readJsFile 出错:"
+
e
.
toString
());
e
.
printStackTrace
();
}
return
map
;
}
}
src/main/java/com/neotel/smfcore/core/order/LiteOrderCache.java
查看文件 @
ba505a4
...
...
@@ -97,9 +97,9 @@ public class LiteOrderCache implements ITaskListener {
if
(!
isProcessTimer
){
isProcessTimer
=
true
;
try
{
boolean
st
opJob
=
dataCache
.
getCache
(
Constants
.
CACHE_Stop
Job
);
boolean
st
artJob
=
dataCache
.
getCache
(
Constants
.
CACHE_Start
Job
);
if
(
!
stop
Job
){
if
(
start
Job
){
//定时执行工单任务
executeOrderTask
();
}
...
...
src/main/java/com/neotel/smfcore/core/storage/service/manager/impl/StoragePosManagerImpl.java
查看文件 @
ba505a4
...
...
@@ -180,7 +180,7 @@ public class StoragePosManagerImpl implements IStoragePosManager {
@Override
public
void
delete
(
StoragePos
object
)
throws
ValidateException
{
storagePosDao
.
removeOneById
(
object
.
getId
());
}
@Override
...
...
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/SysSettingsDto.java
查看文件 @
ba505a4
...
...
@@ -13,6 +13,6 @@ public class SysSettingsDto implements Serializable {
@ApiModelProperty
(
"准备进行更新,不允许需求单出库"
)
private
boolean
stopOut
=
false
;
@ApiModelProperty
(
"
停止定时器
任务"
)
private
boolean
st
op
Job
=
false
;
@ApiModelProperty
(
"
开启自动
任务"
)
private
boolean
st
art
Job
=
false
;
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论