Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit cc485925
由
LN
编写于
2024-01-05 09:12:14 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
过期时间增加供应商配置
1 个父辈
0e1f94f9
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
219 行增加
和
57 行删除
src/main/java/com/neotel/smfcore/common/utils/Constants.java
src/main/java/com/neotel/smfcore/core/barcode/utils/CodeResolve.java
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
src/main/java/com/neotel/smfcore/custom/micron1053/bean/ExpConfig.java
src/main/java/com/neotel/smfcore/custom/micron1053/controller/MicronGroupController.java
src/main/java/com/neotel/smfcore/common/utils/Constants.java
查看文件 @
cc48592
...
...
@@ -169,7 +169,6 @@ public class Constants {
public
static
final
String
CACHE_SAME_BARCODE_SETTINGS
=
"CACHE_sameBarcode_settings"
;
public
static
final
String
CHCHE_ExpirationDateConfig
=
"micron_expiration_config"
;
/**
* 当前入库信息:
*/
...
...
@@ -201,4 +200,9 @@ public class Constants {
* 入库检测配置
*/
public
static
final
String
CACHE_INPUT_CHECK
=
"CACHE_INPUT_CHECK"
;
public
static
final
String
CHCHE_ExpirationDateConfig
=
"micron_expiration_config"
;
// public static final String ExpirationDateConfig = "micron_expiration_config";
public
static
final
String
CACHE_ExpirationDateConfig_N
=
"micron_expiration_config_new"
;
}
src/main/java/com/neotel/smfcore/core/barcode/utils/CodeResolve.java
查看文件 @
cc48592
...
...
@@ -12,6 +12,7 @@ import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import
com.neotel.smfcore.core.barcode.service.manager.IComponentManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Component
;
import
com.neotel.smfcore.custom.micron1053.bean.ExpConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -35,7 +36,9 @@ public class CodeResolve {
private
List
<
BarcodeRule
>
barcodeRuleList
;
private
Integer
defaultExpiresDay
=
0
;
Map
<
String
,
Integer
>
configMap
=
new
HashMap
<>();
private
List
<
ExpConfig
>
configList
=
new
ArrayList
<>();
// Map<String, Integer> configMap =new HashMap<>();
public
void
updateBarcodeRuleList
(
List
<
String
>
ruleList
){
barcodeRuleList
=
Lists
.
newArrayList
();
...
...
@@ -49,17 +52,19 @@ public class CodeResolve {
defaultExpiresDay
=
expiresDay
;
}
public
void
updateConfigMap
(
Map
<
String
,
Integer
>
map
){
this
.
configMap
=
map
;
// public void updateConfigMap(Map<String,Integer> map){
// this.configMap=map;
// }
public
void
updateConfigMap
(
List
<
ExpConfig
>
configs
){
this
.
configList
=
configs
;
}
public
CodeBean
resolveSingleCode
(
String
barcodeItemStr
){
return
resolveSingleCode
(
barcodeItemStr
,
COMPONENT_TYPE
.
COMPONENT
);
}
public
int
getTargetValid
(
String
pn
,
int
validDay
)
{
public
int
getTargetValid
(
String
pn
,
String
manufacture
,
int
validDay
)
{
try
{
if
(
validDay
>
0
)
{
...
...
@@ -67,14 +72,38 @@ public class CodeResolve {
}
int
year
=
0
;
if
(
configMap
!=
null
)
for
(
String
key
:
configMap
.
keySet
())
{
if
(
pn
.
startsWith
(
key
))
{
year
=
configMap
.
get
(
key
);
// if (configMap != null)
// for (String key :
// configMap.keySet()) {
// if (pn.startsWith(key)) {
// year = configMap.get(key);
// break;
// }
// }
if
(
manufacture
==
null
){
manufacture
=
""
;
}
if
(
configList
!=
null
){
for
(
ExpConfig
conf
:
configList
)
{
if
(
pn
.
startsWith
(
conf
.
getKey
())
&&
conf
.
getManufacture
().
equals
(
manufacture
))
{
year
=
conf
.
getValue
();
break
;
}
}
if
(
year
<=
0
){
for
(
ExpConfig
conf
:
configList
)
{
if
(
pn
.
startsWith
(
conf
.
getKey
())
&&
ObjectUtil
.
isEmpty
(
conf
.
getManufacture
()))
{
year
=
conf
.
getValue
();
break
;
}
}
}
}
if
(
year
>
0
)
{
return
year
*
365
;
}
...
...
@@ -229,7 +258,7 @@ public class CodeResolve {
// if(validDay<=0&& defaultExpiresDay!=null&&defaultExpiresDay>0){
// validDay=defaultExpiresDay;
// }
validDay
=
getTargetValid
(
barcode
.
getPartNumber
(),
validDay
);
validDay
=
getTargetValid
(
barcode
.
getPartNumber
(),
barcode
.
getProvider
(),
validDay
);
if
((!
setSize
)&&
codeBeanFromRule
.
hasReelSizeInfo
()){
//如果客户端传入的有尺寸,但尺寸不一致,使用上传上来的尺寸
if
(
barcode
.
getHeight
()
!=
codeBeanFromRule
.
getReelHeight
()
||
barcode
.
getPlateSize
()
!=
codeBeanFromRule
.
getReelWidth
()){
...
...
@@ -367,7 +396,7 @@ public class CodeResolve {
Date
produceDate
=
barcodeFromRule
.
getProduceDate
();
int
validDay
=
component
.
getValidDay
();
validDay
=
getTargetValid
(
component
.
getPartNumber
(),
validDay
);
validDay
=
getTargetValid
(
component
.
getPartNumber
(),
component
.
getProvider
(),
validDay
);
if
(
validDay
>
0
&&
(
produceDate
!=
null
))
{
log
.
info
(
"设置"
+
barcodeFromRule
.
getBarcode
()
+
"的过期时间"
);
Date
expireDate
=
DateUtil
.
addDays
(
produceDate
,
validDay
);
...
...
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
查看文件 @
cc48592
...
...
@@ -16,7 +16,6 @@ import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import
com.neotel.smfcore.core.device.bean.StatusBean
;
import
com.neotel.smfcore.core.inList.util.InListCache
;
import
com.neotel.smfcore.core.inout.service.manager.IInOutDataManager
;
import
com.neotel.smfcore.core.inout.service.po.InOutData
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
com.neotel.smfcore.core.storage.bean.InventoryItem
;
...
...
@@ -34,7 +33,7 @@ import com.neotel.smfcore.core.system.service.po.CacheItem;
import
com.neotel.smfcore.core.system.service.po.Settings
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.custom.micron1053.
loading.util.LoadingUtil
;
import
com.neotel.smfcore.custom.micron1053.
bean.ExpConfig
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -120,8 +119,29 @@ public class DataCache {
Integer
expireDay
=
getCache
(
Constants
.
CACHE_ExpiresDay
);
codeResolve
.
updateExpiresDay
(
expireDay
);
Map
<
String
,
Integer
>
conMap
=
getCache
(
Constants
.
CHCHE_ExpirationDateConfig
);
codeResolve
.
updateConfigMap
(
conMap
);
// Map<String, Integer> conMap=getCache(Constants.CHCHE_ExpirationDateConfig);
// codeResolve.updateConfigMap(conMap);
//转存过期配置数据
Map
<
String
,
Integer
>
oldconfigMap
=
getCache
(
Constants
.
CHCHE_ExpirationDateConfig
);
List
<
ExpConfig
>
configs
=
getCache
(
Constants
.
CACHE_ExpirationDateConfig_N
);
if
(
oldconfigMap
!=
null
&&
configs
==
null
)
{
configs
=
new
ArrayList
<>();
for
(
String
key
:
oldconfigMap
.
keySet
())
{
ExpConfig
config
=
new
ExpConfig
(
key
,
""
,
oldconfigMap
.
get
(
key
));
configs
.
add
(
config
);
}
updateCache
(
Constants
.
CACHE_ExpirationDateConfig_N
,
configs
);
}
codeResolve
.
updateConfigMap
(
configs
);
// if (oldconfigMap == null) {
// oldconfigMap = new HashMap<>();
// oldconfigMap.put(key, value);
// }
}
private
void
initCacheItem
()
{
...
...
@@ -186,8 +206,11 @@ public class DataCache {
if
(
cacheKey
.
equals
(
Constants
.
CACHE_ExpiresDay
))
{
codeResolve
.
updateExpiresDay
((
Integer
)
value
);
}
if
(
cacheKey
.
equals
(
Constants
.
CHCHE_ExpirationDateConfig
))
{
codeResolve
.
updateConfigMap
((
Map
<
String
,
Integer
>)
value
);
// if (cacheKey.equals(Constants.CHCHE_ExpirationDateConfig)) {
// codeResolve.updateConfigMap((Map<String, Integer>) value);
// }
if
(
cacheKey
.
equals
(
Constants
.
CACHE_ExpirationDateConfig_N
))
{
codeResolve
.
updateConfigMap
((
List
<
ExpConfig
>)
value
);
}
log
.
info
(
"updateCache ["
+
cacheKey
+
"]=["
+
value
+
"]"
);
...
...
src/main/java/com/neotel/smfcore/custom/micron1053/bean/ExpConfig.java
0 → 100644
查看文件 @
cc48592
package
com
.
neotel
.
smfcore
.
custom
.
micron1053
.
bean
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.Serializable
;
@Data
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public
class
ExpConfig
implements
Serializable
{
private
String
key
;
private
String
manufacture
;
private
Integer
value
;
}
src/main/java/com/neotel/smfcore/custom/micron1053/controller/MicronGroupController.java
查看文件 @
cc48592
package
com
.
neotel
.
smfcore
.
custom
.
micron1053
.
controller
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.custom.micron1053.bean.ExpConfig
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -11,8 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.
HashMap
;
import
java.util.
Map
;
import
java.util.
ArrayList
;
import
java.util.
List
;
@Slf4j
@RestController
...
...
@@ -20,57 +23,124 @@ import java.util.Map;
@RequestMapping
(
"/rest/micron/group"
)
public
class
MicronGroupController
{
public
static
final
String
ExpirationDateConfig
=
"micron_expiration_config"
;
@Autowired
private
DataCache
dataCache
;
private
List
<
ExpConfig
>
getConfigList
(){
List
<
ExpConfig
>
configList
=
dataCache
.
getCache
((
Constants
.
CACHE_ExpirationDateConfig_N
));
if
(
configList
==
null
)
{
configList
=
new
ArrayList
<>();
}
return
configList
;
}
@ApiOperation
(
"增加过期设置"
)
@RequestMapping
(
"/addExpirationDateConfig"
)
@AnonymousAccess
public
ResultBean
addExpirationDateConfig
(
String
key
,
int
value
)
{
Map
<
String
,
Integer
>
configMap
=
dataCache
.
getCache
(
ExpirationDateConfig
);
if
(
configMap
==
null
)
{
configMap
=
new
HashMap
<>();
configMap
.
put
(
key
,
value
);
}
else
{
if
(
configMap
.
get
(
key
)
!=
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.expiration.ameExists"
,
"过期配置[{0}]已存在"
,
new
String
[]{
key
});
public
ResultBean
addExpirationDateConfig
(
String
key
,
String
manufacture
,
int
value
)
{
if
(
ObjectUtil
.
isEmpty
(
manufacture
)){
manufacture
=
""
;
}
ExpConfig
config
=
new
ExpConfig
(
key
,
manufacture
,
value
);
List
<
ExpConfig
>
configList
=
dataCache
.
getCache
((
Constants
.
CACHE_ExpirationDateConfig_N
));
if
(
configList
==
null
){
configList
=
new
ArrayList
<>();
configList
.
add
(
config
);
}
else
{
//查找是否已存在
boolean
has
=
false
;
for
(
ExpConfig
cc
:
configList
)
{
if
(
cc
.
getKey
().
equals
(
config
.
getKey
())&&
cc
.
getManufacture
().
equals
(
config
.
getManufacture
())){
has
=
true
;
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.expiration.ameExists"
,
"过期配置[{0}]已存在"
,
new
String
[]{
key
+
"-"
+
manufacture
});
}
}
config
Map
.
put
(
key
,
value
);
config
List
.
add
(
config
);
}
dataCache
.
updateCache
(
ExpirationDateConfig
,
configMap
);
dataCache
.
updateCache
(
Constants
.
CACHE_ExpirationDateConfig_N
,
configList
);
return
ResultBean
.
newOkResult
(
""
);
// Map<String, Integer> configMap = dataCache.getCache(ExpirationDateConfig);
// if (configMap == null) {
// configMap = new HashMap<>();
// configMap.put(key, value);
// } else {
// if (configMap.get(key) != null) {
// return ResultBean.newErrorResult(-1, "smfcore.expiration.ameExists", "过期配置[{0}]已存在", new String[]{key});
// }
// configMap.put(key, value);
// }
// dataCache.updateCache(ExpirationDateConfig, configMap);
// return ResultBean.newOkResult("");
}
@ApiOperation
(
"删除过期设置"
)
@RequestMapping
(
"/deleteExpirationDateConfig"
)
@AnonymousAccess
public
ResultBean
deleteExpirationDateConfig
(
String
key
)
{
Map
<
String
,
Integer
>
configMap
=
dataCache
.
getCache
(
ExpirationDateConfig
);
if
(
configMap
==
null
)
{
configMap
=
new
HashMap
<>();
public
ResultBean
deleteExpirationDateConfig
(
String
key
,
String
manufacture
)
{
if
(
ObjectUtil
.
isEmpty
(
manufacture
)){
manufacture
=
""
;
}
List
<
ExpConfig
>
configList
=
getConfigList
();
int
index
=-
1
;
for
(
int
i
=
0
;
i
<
configList
.
size
();
i
++)
{
if
(
configList
.
get
(
i
).
getKey
().
equals
(
key
)&&
configList
.
get
(
i
).
getManufacture
().
equals
(
manufacture
)
){
index
=
i
;
break
;
}
}
if
(
index
>=
0
){
configList
.
remove
(
index
);
}
configMap
.
remove
(
key
);
dataCache
.
updateCache
(
ExpirationDateConfig
,
configMap
);
dataCache
.
updateCache
(
Constants
.
CACHE_ExpirationDateConfig_N
,
configList
);
return
ResultBean
.
newOkResult
(
""
);
// Map<String, Integer> configMap = dataCache.getCache(ExpirationDateConfig);
// if (configMap == null) {
// configMap = new HashMap<>();
// }
// configMap.remove(key);
// dataCache.updateCache(ExpirationDateConfig, configMap);
// return ResultBean.newOkResult("");
}
@ApiOperation
(
"修改过期设置"
)
@RequestMapping
(
"/updateExpirationDateConfig"
)
@AnonymousAccess
public
ResultBean
updateExpirationDateConfig
(
String
key
,
int
value
)
{
Map
<
String
,
Integer
>
configMap
=
dataCache
.
getCache
(
ExpirationDateConfig
);
if
(
configMap
==
null
)
{
configMap
=
new
HashMap
<>();
public
ResultBean
updateExpirationDateConfig
(
String
key
,
String
manufacture
,
int
value
)
{
if
(
ObjectUtil
.
isEmpty
(
manufacture
)){
manufacture
=
""
;
}
List
<
ExpConfig
>
configList
=
getConfigList
();
int
index
=-
1
;
for
(
int
i
=
0
;
i
<
configList
.
size
();
i
++)
{
if
(
configList
.
get
(
i
).
getKey
().
equals
(
key
)&&
configList
.
get
(
i
).
getManufacture
().
equals
(
manufacture
)
){
index
=
i
;
break
;
}
}
Integer
config
=
configMap
.
get
(
key
);
if
(
config
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.expiration.notExist"
,
"过期配置[{0}]不存在 "
,
new
String
[]{
key
});
ExpConfig
con
=
new
ExpConfig
(
key
,
manufacture
,
value
);
if
(
index
>=
0
){
configList
.
set
(
index
,
con
);
}
else
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.expiration.notExist"
,
"过期配置[{0}]不存在 "
,
new
String
[]{
key
+
"-"
+
manufacture
});
}
configMap
.
put
(
key
,
value
);
dataCache
.
updateCache
(
ExpirationDateConfig
,
configMap
);
dataCache
.
updateCache
(
Constants
.
CACHE_ExpirationDateConfig_N
,
configList
);
return
ResultBean
.
newOkResult
(
""
);
// Map<String, Integer> configMap = dataCache.getCache(ExpirationDateConfig);
// if (configMap == null) {
// configMap = new HashMap<>();
// }
// Integer config = configMap.get(key);
// if (config == null) {
// return ResultBean.newErrorResult(-1, "smfcore.expiration.notExist", "过期配置[{0}]不存在 ", new String[]{key});
// }
// configMap.put(key, value);
// dataCache.updateCache(ExpirationDateConfig, configMap);
// return ResultBean.newOkResult("");
}
...
...
@@ -78,18 +148,33 @@ public class MicronGroupController {
@RequestMapping
(
"/getExpirationDateConfig"
)
@AnonymousAccess
public
ResultBean
getExpirationDateConfig
(
String
key
)
{
Map
<
String
,
Integer
>
configMap
=
dataCache
.
getCache
(
ExpirationDateConfig
);
if
(
configMap
==
null
)
{
configMap
=
new
HashMap
<>();
}
else
{
if
(
StringUtils
.
isNotBlank
(
key
))
{
HashMap
<
String
,
Integer
>
resultMap
=
new
HashMap
<>();
if
(
c
onfigMap
.
get
(
key
)
!=
null
)
{
result
Map
.
put
(
key
,
configMap
.
get
(
key
)
);
List
<
ExpConfig
>
configList
=
getConfigList
();
if
(
StringUtils
.
isNotBlank
(
key
))
{
List
<
ExpConfig
>
result
=
new
ArrayList
<>();
for
(
ExpConfig
cc
:
configList
)
{
if
(
c
c
.
getKey
().
equals
(
key
)
)
{
result
.
add
(
cc
);
}
return
ResultBean
.
newOkResult
(
resultMap
);
}
return
ResultBean
.
newOkResult
(
result
);
}
return
ResultBean
.
newOkResult
(
configMap
);
return
ResultBean
.
newOkResult
(
configList
);
// Map<String, Integer> configMap = dataCache.getCache(ExpirationDateConfig);
// if (configMap == null) {
// configMap = new HashMap<>();
// } else {
// if (StringUtils.isNotBlank(key)) {
// HashMap<String, Integer> resultMap = new HashMap<>();
// if (configMap.get(key) != null) {
// resultMap.put(key, configMap.get(key));
// }
// return ResultBean.newOkResult(resultMap);
// }
// }
// return ResultBean.newOkResult(configMap);
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论