Commit 74b8014d zshaohui

增加物料过期配置 是否可以入库

1 个父辈 04be63de
......@@ -191,4 +191,9 @@ public class Constants {
*/
public static final String CACHE_API_XRAY_BYPASSS ="CACHE_API_XRAY_BYPASSS";
/**
* 是否启用过期时间验证
*/
public static final String CACHE_EXPIREDATE_VERIFY = "CACHE_EXPIREDATE_VERIFY";
}
......@@ -393,9 +393,12 @@ public class BaseDeviceHandler implements IDeviceHandler {
Date expireDate = barcodeSave.getExpireDate();
if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) {
boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
}
int w = barcodeSave.getPlateSize();
int h = barcodeSave.getHeight();
......
......@@ -248,8 +248,11 @@ public class NLMShelfHandler extends BaseDeviceHandler {
Barcode barcode = codeBean.getBarcode();
Date expireDate = barcode.getExpireDate();
if (expireDate != null && System.currentTimeMillis() > expireDate.getTime()) {
boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
if (barcode.getPlateSize() <= 1) {
//长宽为1的需要弹框设置尺寸
return ResultBean.newErrorResult(101,"smfcore.error.barcode.errorSize","条码未设置尺寸");
......
......@@ -135,9 +135,12 @@ public class NLPShelfHandler extends BaseDeviceHandler {
Date expireDate = barcode.getExpireDate();
if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) {
boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
}
String pn = barcode.getPartNumber();
String reelId = barcode.getBarcode();
......
......@@ -381,9 +381,12 @@ public class NLShelfHandler extends BaseDeviceHandler {
Date expireDate = barcode.getExpireDate();
if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) {
boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
}
try {
long now = System.currentTimeMillis();
......
......@@ -410,19 +410,22 @@ public class RobotBoxHandler extends BaseDeviceHandler {
} else {
try {
Barcode barcode = codeResolve.resolveOneValideBarcode(code);
boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
if (barcode.getExpireDate() != null && System.currentTimeMillis() > barcode.getExpireDate().getTime()) {
// throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
//已有入库任务,返回NG,标记原来的入库任务
resultMap.put("result", "107");
errorMsg = "["+barcode.getBarcode()+"]"+MessageUtils.getText("smfcore.error.barcode.expired",new Locale("en","US"),"物料已过期,无法入库");
errorMsg = "[" + barcode.getBarcode() + "]" + MessageUtils.getText("smfcore.error.barcode.expired", new Locale("en", "US"), "物料已过期,无法入库");
resultMap.put("msg", errorMsg);
log.error("物料["+barcode.getBarcode()+"]已过期,无法入库");
log.error("物料[" + barcode.getBarcode() + "]已过期,无法入库");
loadingUtil.AddInListItem(rfid,barcode,"", INITEM_STATUS.API001NG,errorMsg);
loadingUtil.AddInListItem(rfid, barcode, "", INITEM_STATUS.API001NG, errorMsg);
return resultMap;
}
}
try {
if(ObjectUtil.isNotEmpty(preCid)) {
......
......@@ -121,9 +121,12 @@ public class VirtualBoxHandler extends BaseDeviceHandler{
Date expireDate = barcode.getExpireDate();
if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) {
boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
}
try {
//5秒内同一个条码忽略
......
......@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.StringUtils;
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;
......@@ -127,8 +128,10 @@ public class DataCache {
cacheMap = Maps.newConcurrentMap();
List<CacheItem> all = cacheItemDao.findAll();
for (CacheItem cacheItem : all) {
if (StringUtils.isNotBlank(cacheItem.getCacheKey()) && cacheItem.getCacheValue() != null) {
cacheMap.put(cacheItem.getCacheKey(), cacheItem.getCacheValue());
}
}
if (cacheMap.get(Constants.CACHE_StopOut) == null) {
updateCache(Constants.CACHE_StopOut, false);
}
......@@ -173,6 +176,7 @@ public class DataCache {
* 更新缓存信息
*/
public void updateCache(String cacheKey, Object value) {
if (StringUtils.isNotBlank(cacheKey) && value != null) {
cacheItemDao.updateCacheItem(cacheKey, value);
cacheMap.put(cacheKey, value);
if (cacheKey.equals(Constants.CACHE_CodeRule)) {
......@@ -182,12 +186,13 @@ 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);
}
log.info("updateCache [" + cacheKey + "]=[" + value + "]");
}
}
/**
* 获取配置信息同时插入数据库,如果配置值为空,使用数据库配置的值
......@@ -949,4 +954,13 @@ public class DataCache {
}
return true;
}
public boolean getExpiredateVerify(){
Boolean cache = getCache(Constants.CACHE_EXPIREDATE_VERIFY);
if (cache == null){
cache = false;
}
return cache;
}
}
......@@ -80,6 +80,13 @@ public class SettingsController {
dataCache.updateCache(Constants.CACHE_API_XRAY_BYPASSS,xrayBypass);
}
Boolean expiredateVerify = dataCache.getCache(Constants.CACHE_EXPIREDATE_VERIFY);
if (expiredateVerify == null){
expiredateVerify = false;
dataCache.updateCache(Constants.CACHE_EXPIREDATE_VERIFY,expiredateVerify);
}
SysSettingsDto dto = new SysSettingsDto();
dto.setStartJob(startJob);
dto.setStopOut(stopOut);
......@@ -90,6 +97,7 @@ public class SettingsController {
dto.setSameBarcodeSettings(barcodeSet);
dto.setApiTest(useAPi);
dto.setXrayBypass(xrayBypass);
dto.setExpiredateVerify(expiredateVerify);
return dto;
}
......@@ -106,9 +114,11 @@ public class SettingsController {
dataCache.updateCache(Constants.CACHE_SAME_BARCODE_SETTINGS, sysSettingsDto.getSameBarcodeSettings());
dataCache.updateCache(Constants.CACHE_API_TEST, sysSettingsDto.isApiTest());
dataCache.updateCache(Constants.CACHE_API_XRAY_BYPASSS, sysSettingsDto.isXrayBypass());
dataCache.updateCache(Constants.CACHE_EXPIREDATE_VERIFY, sysSettingsDto.isExpiredateVerify());
log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob() + ",sluggishDay=" + sysSettingsDto.getSluggishDay()
+ ",expiresDay=" + sysSettingsDto.getExpiresDay() + ",capacityWarn=" + sysSettingsDto.getCapacityWarn() + ",backUpMonth=" + sysSettingsDto.getBackUpMonth() +
" ,sameBarcodeSettings=" + sysSettingsDto.getSameBarcodeSettings()+", apiTest="+sysSettingsDto.isApiTest()+",xrayBypass="+sysSettingsDto.isXrayBypass());
" ,sameBarcodeSettings=" + sysSettingsDto.getSameBarcodeSettings()+", apiTest="+sysSettingsDto.isApiTest()+",xrayBypass="+sysSettingsDto.isXrayBypass()+
",expiredateVerify=" + sysSettingsDto.isExpiredateVerify());
String msg = MessageUtils.getText("smfcore.saveOk", servletRequest.getLocale(), "保存成功");
return ResultBean.newOkResult(msg);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!