Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 657398a6
由
LN
编写于
2021-12-17 13:26:21 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
锡膏管理图标修改。资源不同type的code可以重复。
1 个父辈
4b7908d5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
201 行增加
和
173 行删除
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
src/main/java/com/neotel/smfcore/core/language/rest/LanguageMsgController.java
src/main/java/com/neotel/smfcore/core/language/service/nanager/impl/LanguageMsgManagerImpl.java
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
src/main/java/com/neotel/smfcore/core/system/util/DevicesStatusUtil.java
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
查看文件 @
657398a
...
...
@@ -205,11 +205,11 @@ public class DataInitManager {
menus
.
addAll
(
createMenus
(
msd
,
msdManage
,
msdData
,
msdSetting
));
Menu
solderPaste
=
Menu
.
CreatePMenu
(
"锡膏管理"
,
20
,
"solderPaste"
,
2
,
"
MSD
"
);
Menu
solderPasteKanban
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"solderPasteKanban"
,
"设备概览"
,
1
,
"solderPasteKanban"
,
"neolight/solderPasteKanban/index"
,
""
,
0
,
"
MSDManager
"
);
Menu
solderPasteManage
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"solderPasteManage"
,
"库存"
,
1
,
"solderPasteManage"
,
"neolight/solderPasteManage/index"
,
""
,
0
,
"
MSDManag
er"
);
Menu
solderPasteData
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"solderPasteData"
,
"追溯性"
,
1
,
"solderPasteData"
,
"neolight/solderPasteData/index"
,
""
,
0
,
"
MSD
Data"
);
Menu
solderPasteSetting
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"solderPasteSetting"
,
"设置"
,
1
,
"solderPasteSetting"
,
"neolight/solderPasteSetting/index"
,
""
,
0
,
"
MSDSet
"
);
Menu
solderPaste
=
Menu
.
CreatePMenu
(
"锡膏管理"
,
20
,
"solderPaste"
,
2
,
"
sMana
"
);
Menu
solderPasteKanban
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"solderPasteKanban"
,
"设备概览"
,
1
,
"solderPasteKanban"
,
"neolight/solderPasteKanban/index"
,
""
,
0
,
"
sKanban
"
);
Menu
solderPasteManage
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"solderPasteManage"
,
"库存"
,
1
,
"solderPasteManage"
,
"neolight/solderPasteManage/index"
,
""
,
0
,
"
sold
er"
);
Menu
solderPasteData
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"solderPasteData"
,
"追溯性"
,
1
,
"solderPasteData"
,
"neolight/solderPasteData/index"
,
""
,
0
,
"
s
Data"
);
Menu
solderPasteSetting
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"solderPasteSetting"
,
"设置"
,
1
,
"solderPasteSetting"
,
"neolight/solderPasteSetting/index"
,
""
,
0
,
"
system
"
);
menus
.
addAll
(
createMenus
(
solderPaste
,
solderPasteKanban
,
solderPasteManage
,
solderPasteData
,
solderPasteSetting
));
//物料管理:元器件管理,条形码管理
...
...
src/main/java/com/neotel/smfcore/core/language/rest/LanguageMsgController.java
查看文件 @
657398a
...
...
@@ -3,11 +3,8 @@ package com.neotel.smfcore.core.language.rest;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.bean.PageData
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.csv.CsvReader
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.FileUtil
;
import
com.neotel.smfcore.common.utils.Md5Utls
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.language.rest.bean.dto.LanguageMsgDto
;
...
...
@@ -21,12 +18,10 @@ import com.neotel.smfcore.core.language.service.po.LanguageMsg;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.bean.FileProperties
;
import
com.neotel.smfcore.security.service.po.User
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.mapstruct.ap.shaded.freemarker.ext.beans.HashAdapter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.mongodb.core.query.Criteria
;
...
...
@@ -93,14 +88,14 @@ public class LanguageMsgController {
String
lanType
=
getLanTypeByFileName
(
uploadFile
.
getOriginalFilename
());
if
(
smfclientType
.
contains
(
fileType
))
{
//客户端js文件处理
Map
<
String
,
String
>
proMap
=
readJsFile
(
file
);
Map
<
String
,
String
>
proMap
=
MessageUtils
.
readJsFile
(
file
);
resultMsg
=
ResourceUpload
(
uploadFile
.
getOriginalFilename
(),
proMap
,
lanType
,
"smfclient"
);
}
else
if
(
smfcoreType
.
contains
(
fileType
))
{
Map
<
String
,
String
>
proMap
=
MessageUtils
.
R
eadPropertiesFile
(
file
);
Map
<
String
,
String
>
proMap
=
MessageUtils
.
r
eadPropertiesFile
(
file
);
resultMsg
=
ResourceUpload
(
uploadFile
.
getOriginalFilename
(),
proMap
,
lanType
,
""
);
}
if
(
csvType
.
equals
(
fileType
)){
List
<
LanguageMsg
>
list
=
CsvFileRead
(
file
.
getAbsolutePath
());
List
<
LanguageMsg
>
list
=
MessageUtils
.
readCsvFile
(
file
.
getAbsolutePath
(),
dataCache
.
getLanguageList
());
msgListUpload
(
list
);
}
return
ResultBean
.
newOkResult
(
resultMsg
);
...
...
@@ -232,6 +227,7 @@ public class LanguageMsgController {
return
list
;
}
@ApiOperation
(
"客户端提交资源列表:只增加不修改"
)
@PostMapping
(
value
=
"/resource"
)
@AnonymousAccess
...
...
@@ -317,7 +313,7 @@ public class LanguageMsgController {
proMap
.
keySet
())
{
String
msgStr
=
proMap
.
get
(
key
);
LanguageMsg
msg
=
MessageUtils
.
getMsg
(
key
);
LanguageMsg
msg
=
MessageUtils
.
getMsg
(
type
,
key
);
//导入时只能新增不能修改
if
(
msg
==
null
)
{
msg
=
new
LanguageMsg
(
key
,
msgStr
,
type
);
...
...
@@ -353,124 +349,6 @@ public class LanguageMsgController {
return
"ok"
;
}
private
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
;
}
private
List
<
LanguageMsg
>
CsvFileRead
(
String
fileURL
)
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
;
}
private
void
msgListUpload
(
List
<
LanguageMsg
>
msgList
)
{
List
<
LanguageMsg
>
newLanguageList
=
new
ArrayList
<>();
...
...
@@ -501,7 +379,7 @@ public class LanguageMsgController {
//判断是否是新增
LanguageMsg
oldMsg
=
MessageUtils
.
getMsg
(
msg
.
getCode
());
LanguageMsg
oldMsg
=
MessageUtils
.
getMsg
(
msg
.
get
Type
(),
msg
.
get
Code
());
if
(
oldMsg
==
null
){
newLanguageList
.
add
(
msg
);
}
...
...
src/main/java/com/neotel/smfcore/core/language/service/nanager/impl/LanguageMsgManagerImpl.java
查看文件 @
657398a
...
...
@@ -89,19 +89,19 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager {
@Override
public
LanguageMsg
saveMsg
(
LanguageMsg
resources
)
{
if
(
resources
.
getCode
()
==
null
)
{
if
(
ObjectUtil
.
isEmpty
(
resources
.
getCode
()
)
)
{
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"code"
});
}
if
(
resources
.
getMsg
()
==
null
)
{
if
(
ObjectUtil
.
isEmpty
(
resources
.
getMsg
()
)
)
{
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"msg"
});
}
if
(
resources
.
getType
()
==
null
)
{
if
(
ObjectUtil
.
isEmpty
(
resources
.
getType
()
)
)
{
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"type"
});
}
if
(
resources
.
getContentList
()
==
null
)
{
if
(
ObjectUtil
.
isEmpty
(
resources
.
getContentList
()
)
)
{
resources
.
setContentList
(
new
ArrayList
<>());
}
Criteria
c
=
Criteria
.
where
(
"code"
).
is
(
resources
.
getCode
());
Criteria
c
=
Criteria
.
where
(
"code"
).
is
(
resources
.
getCode
())
.
and
(
"type"
).
is
(
resources
.
getType
())
;
String
logName
=
"新增资源:"
;
if
(
resources
.
getId
()
!=
null
)
{
logName
=
"修改资源:"
;
...
...
@@ -109,7 +109,7 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager {
}
//code不能重复
LanguageMsg
result
=
languageMsgDao
.
findOne
(
new
Query
(
c
));
if
(
result
!=
null
)
{
throw
new
ValidateException
(
"smfcore.resourcesExist"
,
"资源[
"
+
resources
.
getCode
()
+
"]已存在"
);
throw
new
ValidateException
(
"smfcore.resourcesExist"
,
"资源[
{0}][{1}]已存在"
,
new
String
[]{
resources
.
getType
(),
resources
.
getCode
()}
);
}
Query
query
=
new
Query
(
c
);
...
...
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
查看文件 @
657398a
package
com
.
neotel
.
smfcore
.
core
.
language
.
util
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.common.csv.CsvReader
;
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.context.MessageSource
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
...
...
@@ -62,7 +60,7 @@ public class MessageUtils {
/**
* 资源集合,key=code
*/
private
static
Map
<
String
,
LanguageMsg
>
msgMap
=
new
HashMap
<>();
private
static
Map
<
String
,
Map
<
String
,
LanguageMsg
>
>
msgMap
=
new
HashMap
<>();
@Autowired
...
...
@@ -74,15 +72,21 @@ public class MessageUtils {
public
static
final
String
EN_US
=
"en-US"
;
public
static
final
String
JA_JP
=
"ja-JP"
;
//服务器type
public
static
final
String
smfcore
=
"smfcore"
;
@PostConstruct
public
void
initialize
()
{
initLanguageMsgList
();
}
//-----------------以下为从缓存读取资源-------------------------------------
public
static
Locale
getDefaultLocal
(){
return
new
Locale
(
"zh-CH"
);
}
public
static
String
getText
(
String
msgKey
,
Locale
locale
,
String
defaultMsg
)
{
return
getText
(
msgKey
,
null
,
locale
,
defaultMsg
);
}
...
...
@@ -105,8 +109,8 @@ public class MessageUtils {
}
private
static
String
getMessage
(
String
msgKey
,
String
lanType
,
String
defaultMsg
)
{
if
(
msgMap
!=
null
)
{
LanguageMsg
msg
=
msgMap
.
get
(
msgKey
);
if
(
msgMap
!=
null
&&
msgMap
.
containsKey
(
smfcore
)
)
{
LanguageMsg
msg
=
msgMap
.
get
(
smfcore
).
get
(
msgKey
);
if
(
msg
!=
null
)
{
for
(
Content
con
:
msg
.
getContentList
())
{
...
...
@@ -116,38 +120,57 @@ public class MessageUtils {
return
con
.
getMsg
();
}
}
log
.
info
(
"获取资源["
+
msgKey
+
"]["
+
defaultMsg
+
"]["
+
lanType
+
"]失败:未找到code["
+
msgKey
+
"]对应语言["
+
lanType
+
"]"
);
//
log.info("获取资源[" + msgKey + "][" + defaultMsg + "][" + lanType + "]失败:未找到code[" + msgKey + "]对应语言[" + lanType + "]");
return
msg
.
getMsg
();
}
log
.
info
(
"获取资源["
+
msgKey
+
"]["
+
defaultMsg
+
"]["
+
lanType
+
"]失败:未找到code["
+
msgKey
+
"]"
);
}
return
defaultMsg
;
}
//-------------------------------------------------------------------------------
public
static
void
updateMsg
(
LanguageMsg
msg
)
{
msgMap
.
put
(
msg
.
getCode
(),
msg
);
Map
<
String
,
LanguageMsg
>
typeMap
=
msgMap
.
get
(
msg
.
getType
());
if
(
typeMap
==
null
){
typeMap
=
new
HashMap
<>();
}
typeMap
.
put
(
msg
.
getCode
(),
msg
);
msgMap
.
put
(
msg
.
getType
(),
typeMap
);
}
public
static
void
removeMsg
(
LanguageMsg
msg
)
{
msgMap
.
remove
(
msg
.
getCode
());
if
(
msgMap
.
containsKey
(
msg
.
getType
()))
{
msgMap
.
get
(
msg
.
getType
()).
remove
(
msg
.
getCode
());
}
}
public
static
LanguageMsg
getMsg
(
String
code
)
{
return
msgMap
.
get
(
code
);
public
static
LanguageMsg
getMsg
(
String
type
,
String
code
)
{
Map
<
String
,
LanguageMsg
>
typeMap
=
msgMap
.
get
(
type
);
if
(
typeMap
!=
null
){
return
typeMap
.
get
(
code
);
}
return
null
;
}
public
static
List
<
LanguageMsg
>
getLanMsgByType
(
String
type
)
{
List
<
LanguageMsg
>
msgList
=
new
ArrayList
<>();
for
(
LanguageMsg
msg
:
msgMap
.
values
())
{
if
(
msg
.
getType
().
equals
(
type
)){
msgList
.
add
(
msg
);
}
Map
<
String
,
LanguageMsg
>
typeMap
=
msgMap
.
get
(
type
);
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
,
LanguageMsg
>
loadMsgMap
()
{
Map
<
String
,
LanguageMsg
>
msgMap
=
new
HashMap
<>();
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
)
{
...
...
@@ -157,10 +180,15 @@ public class MessageUtils {
msg
.
setType
(
"smfcore"
);
languageMsgManager
.
save
(
msg
);
}
msgMap
.
put
(
msg
.
getCode
(),
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共加载到"
+
msg
Map
.
size
()
+
"条Msg"
);
return
msg
Map
;
log
.
info
(
"MessageCache共加载到"
+
msg
s
.
size
()
+
"条Msg"
);
return
resource
Map
;
}
public
static
List
<
LanguageInfo
>
getDefaultLanList
()
{
...
...
@@ -182,6 +210,19 @@ public class MessageUtils {
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
);
//需要获取的文件的路径
...
...
@@ -201,12 +242,12 @@ public class MessageUtils {
String
lanType
=
fileName
.
replace
(
"messages"
,
""
).
replace
(
".properties"
,
""
);
if
(
ObjectUtil
.
isEmpty
(
lanType
))
{
defaultLanMap
=
R
eadPropertiesFile
(
filePathLists
[
i
]);
defaultLanMap
=
r
eadPropertiesFile
(
filePathLists
[
i
]);
log
.
info
(
"MessageCache 从文件["
+
fileName
+
"]中导入["
+
defaultLanMap
.
size
()
+
"]条默认资源"
);
}
else
{
String
lan
=
lanType
.
substring
(
1
);
lan
=
lan
.
replace
(
'_'
,
'-'
);
Map
<
String
,
String
>
map
=
R
eadPropertiesFile
(
filePathLists
[
i
]);
Map
<
String
,
String
>
map
=
r
eadPropertiesFile
(
filePathLists
[
i
]);
lanMsgMap
.
put
(
lan
,
map
);
log
.
info
(
"MessageCache 从文件["
+
fileName
+
"]中导入["
+
defaultLanMap
.
size
()
+
"]条["
+
lan
+
"]资源"
);
}
...
...
@@ -219,14 +260,6 @@ public class MessageUtils {
for
(
String
code
:
defaultLanMap
.
keySet
())
{
String
defMsg
=
defaultLanMap
.
get
(
code
);
// int index = code.indexOf('.');
// String type = code.substring(0, index);
// LanguageMsg msg = new LanguageMsg();
// msg.setUpdateDate(msg.getCreateDate());
// msg.setCode(code);
// msg.setType(type);
// msg.setMsg(defMsg);
LanguageMsg
msg
=
new
LanguageMsg
(
code
,
defMsg
,
""
);
for
(
String
lan
:
lanMsgMap
.
keySet
())
{
...
...
@@ -239,10 +272,10 @@ public class MessageUtils {
}
languageMsgManager
.
insertAll
(
languageMsgs
);
}
msgMap
=
loadMsgMap
();
}
public
static
Map
<
String
,
String
>
ReadPropertiesFile
(
File
file
)
{
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"
);
...
...
@@ -267,7 +300,122 @@ public class MessageUtils {
}
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/system/util/DevicesStatusUtil.java
查看文件 @
657398a
...
...
@@ -116,7 +116,9 @@ public class DevicesStatusUtil {
public
static
Map
<
String
,
String
>
getAndRemoveOp
(
String
cid
){
Map
<
String
,
String
>
opMap
=
storageOpMap
.
get
(
cid
);
opMap
.
remove
(
cid
);
if
(
opMap
!=
null
){
opMap
.
remove
(
cid
);
}
return
opMap
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论