Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 62c03f2d
由
LN
编写于
2021-09-22 11:23:57 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加配置保存功能
1 个父辈
a913fac9
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
134 行增加
和
2 行删除
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
src/main/java/com/neotel/smfcore/common/utils/YmlUpdateUtil.java
src/main/java/com/neotel/smfcore/core/barcode/service/manager/impl/BarcodeManagerImpl.java
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
src/main/java/com/neotel/smfcore/hella/tcp/HellaTcpClient.java
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
查看文件 @
62c03f2
...
@@ -198,7 +198,7 @@ public class DataInitManager {
...
@@ -198,7 +198,7 @@ public class DataInitManager {
//物料管理:元器件管理,条形码管理
//物料管理:元器件管理,条形码管理
Menu
pMenuWl
=
Menu
.
CreatePMenu
(
"物料管理"
,
30
,
"materiel "
,
2
,
"
materiel
"
);
Menu
pMenuWl
=
Menu
.
CreatePMenu
(
"物料管理"
,
30
,
"materiel "
,
2
,
"
BOM
"
);
Menu
menucom
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"component:list"
,
"元器件"
,
1
,
"componentParts"
,
"parts/component/index"
,
""
,
0
,
"server"
);
Menu
menucom
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"component:list"
,
"元器件"
,
1
,
"componentParts"
,
"parts/component/index"
,
""
,
0
,
"server"
);
Menu
menubarcode
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"barcode:list"
,
"条形码"
,
1
,
"barcode"
,
"barcode/barcode/index"
,
""
,
0
,
"chart"
);
Menu
menubarcode
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"barcode:list"
,
"条形码"
,
1
,
"barcode"
,
"barcode/barcode/index"
,
""
,
0
,
"chart"
);
menus
.
addAll
(
createMenus
(
pMenuWl
,
menucom
,
menubarcode
));
menus
.
addAll
(
createMenus
(
pMenuWl
,
menucom
,
menubarcode
));
...
...
src/main/java/com/neotel/smfcore/common/utils/YmlUpdateUtil.java
0 → 100644
查看文件 @
62c03f2
package
com
.
neotel
.
smfcore
.
common
.
utils
;
import
com.neotel.smfcore.SmfCoreApplication
;
import
com.neotel.smfcore.security.rest.UserController
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.util.StringUtil
;
import
org.springframework.util.ClassUtils
;
import
org.yaml.snakeyaml.Yaml
;
import
java.net.URL
;
import
java.io.*
;
import
java.util.HashMap
;
import
java.util.Map
;
@Slf4j
public
class
YmlUpdateUtil
{
public
static
void
updateYamlFile
(
Map
<
String
,
Object
>
updateMap
)
{
try
{
String
src
=
"src/main/resources/application.yml"
;
URL
url
=
ClassUtils
.
getDefaultClassLoader
().
getResource
(
""
);
src
=
url
.
getPath
()
+
"config/application.yml"
;
if
(!
FileUtil
.
exist
(
src
))
{
log
.
info
(
"未找到文件:"
+
src
);
return
;
}
Yaml
yaml
=
new
Yaml
();
FileWriter
fileWriter
=
null
;
//层级map变量 Map<String, Object> springMap, dataSourceMap, resultMap, helperDialect;
Map
<
String
,
Object
>
resultMap
;
try
{
//读取yaml文件,默认返回根目录结构
resultMap
=
(
Map
<
String
,
Object
>)
yaml
.
load
(
new
FileInputStream
(
new
File
(
src
)));
// //get出spring节点数据
// springMap = (Map<String, Object>) resultMap.get("spring");
// //get出数据库节点数据
// dataSourceMap = (Map<String, Object>) springMap.get("datasource");
String
msg
=
""
;
for
(
String
key
:
updateMap
.
keySet
()
)
{
Object
value
=
updateMap
.
get
(
key
);
if
(
StringUtils
.
isEmpty
(
value
.
toString
())){
continue
;
}
key
=
key
.
replace
(
'.'
,
','
);
String
[]
keyarray
=
key
.
split
(
","
);
if
(
keyarray
!=
null
){
Map
<
String
,
Object
>
currMap
=
resultMap
;
int
index
=
0
;
for
(
String
mapKey
:
keyarray
)
{
if
(
index
==(
keyarray
.
length
-
1
)){
currMap
=
updateMapValue
(
mapKey
,
value
,
currMap
);
}
else
{
currMap
=
updateMapMap
(
mapKey
,
currMap
);
}
index
++;
}
}
msg
+=
key
+
"="
+
value
+
","
;
}
//字符输出
fileWriter
=
new
FileWriter
(
new
File
(
src
));
//用yaml方法把map结构格式化为yaml文件结构
String
writeStr
=
yaml
.
dumpAsMap
(
resultMap
);
fileWriter
.
write
(
writeStr
);
//刷新
fileWriter
.
flush
();
//关闭流
fileWriter
.
close
();
log
.
info
(
"更改yml配置:"
+
msg
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"updateYamlFile error :"
+
e
.
toString
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"updateYamlFile error :"
+
e
.
toString
());
}
}
private
static
Map
<
String
,
Object
>
updateMapMap
(
String
key
,
Map
<
String
,
Object
>
map
){
if
(!
map
.
containsKey
(
key
))
{
map
.
put
(
key
,
new
HashMap
<
String
,
Object
>());
}
return
(
Map
<
String
,
Object
>)
map
.
get
(
key
);
}
private
static
Map
<
String
,
Object
>
updateMapValue
(
String
key
,
Object
value
,
Map
<
String
,
Object
>
map
){
if
(
map
.
containsKey
(
key
))
{
map
.
remove
(
key
);
}
map
.
put
(
key
,
value
);
return
map
;
}
}
src/main/java/com/neotel/smfcore/core/barcode/service/manager/impl/BarcodeManagerImpl.java
查看文件 @
62c03f2
...
@@ -48,8 +48,9 @@ public class BarcodeManagerImpl implements IBarcodeManager {
...
@@ -48,8 +48,9 @@ public class BarcodeManagerImpl implements IBarcodeManager {
@Override
@Override
public
PageData
<
Barcode
>
findByPage
(
Query
query
,
Pageable
pageable
)
{
public
PageData
<
Barcode
>
findByPage
(
Query
query
,
Pageable
pageable
)
{
int
totalCount
=
barcodeDao
.
countByQuery
(
query
);
List
<
Barcode
>
barcodes
=
barcodeDao
.
findByQuery
(
query
,
pageable
);
List
<
Barcode
>
barcodes
=
barcodeDao
.
findByQuery
(
query
,
pageable
);
return
new
PageData
(
barcodes
,
barcodes
.
size
()
);
return
new
PageData
(
barcodes
,
totalCount
);
}
}
@Override
@Override
...
...
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
查看文件 @
62c03f2
...
@@ -5,6 +5,8 @@ import com.google.common.collect.Lists;
...
@@ -5,6 +5,8 @@ import com.google.common.collect.Lists;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.common.utils.YmlUpdateUtil
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.storage.bean.InventoryItem
;
import
com.neotel.smfcore.core.storage.bean.InventoryItem
;
...
@@ -103,6 +105,28 @@ public class DataCache {
...
@@ -103,6 +105,28 @@ public class DataCache {
List
<
String
>
ruleList
=(
List
<
String
>)
value
;
List
<
String
>
ruleList
=(
List
<
String
>)
value
;
codeResolve
.
updateBarcodeRuleList
(
ruleList
);
codeResolve
.
updateBarcodeRuleList
(
ruleList
);
}
}
log
.
info
(
"updateCache ["
+
cacheKey
+
"]=["
+
value
+
"]"
);
}
public
String
GetConfigCache
(
String
cacheKey
,
String
configKey
,
String
configValue
)
{
if
(
StringUtils
.
isEmpty
(
configKey
)
||
StringUtils
.
isEmpty
(
cacheKey
))
{
return
configValue
;
}
if
(
StringUtils
.
isEmpty
(
configValue
))
{
String
cacheValue
=
getCache
(
cacheKey
);
if
(
cacheValue
==
null
||
StringUtils
.
isEmpty
(
cacheValue
))
{
return
configValue
;
}
configValue
=
cacheValue
;
Map
<
String
,
Object
>
updateMap
=
new
HashMap
<>();
updateMap
.
put
(
configKey
,
configValue
);
YmlUpdateUtil
.
updateYamlFile
(
updateMap
);
}
else
{
updateCache
(
cacheKey
,
configValue
);
}
return
configValue
;
}
}
/**
/**
...
...
src/main/java/com/neotel/smfcore/hella/tcp/HellaTcpClient.java
查看文件 @
62c03f2
...
@@ -2,9 +2,11 @@ package com.neotel.smfcore.hella.tcp;
...
@@ -2,9 +2,11 @@ package com.neotel.smfcore.hella.tcp;
import
com.google.common.base.Strings
;
import
com.google.common.base.Strings
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.system.service.po.Settings
;
import
com.neotel.smfcore.core.system.service.po.Settings
;
import
com.neotel.smfcore.hella.handler.HellaServiceHandler
;
import
com.neotel.smfcore.hella.handler.HellaServiceHandler
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
...
@@ -52,11 +54,16 @@ public class HellaTcpClient {
...
@@ -52,11 +54,16 @@ public class HellaTcpClient {
@Autowired
@Autowired
private
HellaServiceHandler
hellaServiceHandler
;
private
HellaServiceHandler
hellaServiceHandler
;
@Autowired
private
DataCache
dataCache
;
private
static
IoSession
theSession
;
private
static
IoSession
theSession
;
@PostConstruct
@PostConstruct
public
void
init
(){
public
void
init
(){
host
=
dataCache
.
GetConfigCache
(
"hella.host"
,
"hella.host"
,
host
);
port
=
Integer
.
parseInt
(
dataCache
.
GetConfigCache
(
"hella.port"
,
"hella.port"
,
port
+
""
))
;
updateServerInfo
(
host
,
port
);
updateServerInfo
(
host
,
port
);
start
();
start
();
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论