Commit 74b8014d zshaohui

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

1 个父辈 04be63de
...@@ -191,4 +191,9 @@ public class Constants { ...@@ -191,4 +191,9 @@ public class Constants {
*/ */
public static final String CACHE_API_XRAY_BYPASSS ="CACHE_API_XRAY_BYPASSS"; public static final String CACHE_API_XRAY_BYPASSS ="CACHE_API_XRAY_BYPASSS";
/**
* 是否启用过期时间验证
*/
public static final String CACHE_EXPIREDATE_VERIFY = "CACHE_EXPIREDATE_VERIFY";
} }
...@@ -393,7 +393,10 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -393,7 +393,10 @@ public class BaseDeviceHandler implements IDeviceHandler {
Date expireDate = barcodeSave.getExpireDate(); Date expireDate = barcodeSave.getExpireDate();
if (expireDate != null) { if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) { if (System.currentTimeMillis() > expireDate.getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库."); boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
} }
} }
......
...@@ -248,7 +248,10 @@ public class NLMShelfHandler extends BaseDeviceHandler { ...@@ -248,7 +248,10 @@ public class NLMShelfHandler extends BaseDeviceHandler {
Barcode barcode = codeBean.getBarcode(); Barcode barcode = codeBean.getBarcode();
Date expireDate = barcode.getExpireDate(); Date expireDate = barcode.getExpireDate();
if (expireDate != null && System.currentTimeMillis() > expireDate.getTime()) { if (expireDate != null && System.currentTimeMillis() > expireDate.getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库."); boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
} }
if (barcode.getPlateSize() <= 1) { if (barcode.getPlateSize() <= 1) {
//长宽为1的需要弹框设置尺寸 //长宽为1的需要弹框设置尺寸
......
...@@ -135,7 +135,10 @@ public class NLPShelfHandler extends BaseDeviceHandler { ...@@ -135,7 +135,10 @@ public class NLPShelfHandler extends BaseDeviceHandler {
Date expireDate = barcode.getExpireDate(); Date expireDate = barcode.getExpireDate();
if (expireDate != null) { if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) { if (System.currentTimeMillis() > expireDate.getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库."); boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
} }
} }
......
...@@ -381,7 +381,10 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -381,7 +381,10 @@ public class NLShelfHandler extends BaseDeviceHandler {
Date expireDate = barcode.getExpireDate(); Date expireDate = barcode.getExpireDate();
if (expireDate != null) { if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) { if (System.currentTimeMillis() > expireDate.getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库."); boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
} }
} }
......
...@@ -410,18 +410,21 @@ public class RobotBoxHandler extends BaseDeviceHandler { ...@@ -410,18 +410,21 @@ public class RobotBoxHandler extends BaseDeviceHandler {
} else { } else {
try { try {
Barcode barcode = codeResolve.resolveOneValideBarcode(code); Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if (barcode.getExpireDate() != null && System.currentTimeMillis() > barcode.getExpireDate().getTime()) { boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
if (barcode.getExpireDate() != null && System.currentTimeMillis() > barcode.getExpireDate().getTime()) {
// throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库."); // throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
//已有入库任务,返回NG,标记原来的入库任务 //已有入库任务,返回NG,标记原来的入库任务
resultMap.put("result", "107"); 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); 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; return resultMap;
}
} }
try { try {
if(ObjectUtil.isNotEmpty(preCid)) { if(ObjectUtil.isNotEmpty(preCid)) {
......
...@@ -121,7 +121,10 @@ public class VirtualBoxHandler extends BaseDeviceHandler{ ...@@ -121,7 +121,10 @@ public class VirtualBoxHandler extends BaseDeviceHandler{
Date expireDate = barcode.getExpireDate(); Date expireDate = barcode.getExpireDate();
if (expireDate != null) { if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) { if (System.currentTimeMillis() > expireDate.getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库."); boolean expiredateVerify = dataCache.getExpiredateVerify();
if (!expiredateVerify) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
} }
} }
......
...@@ -7,6 +7,7 @@ import com.google.common.collect.Lists; ...@@ -7,6 +7,7 @@ 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.core.barcode.service.manager.IComponentManager; 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.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component; import com.neotel.smfcore.core.barcode.service.po.Component;
...@@ -127,7 +128,9 @@ public class DataCache { ...@@ -127,7 +128,9 @@ public class DataCache {
cacheMap = Maps.newConcurrentMap(); cacheMap = Maps.newConcurrentMap();
List<CacheItem> all = cacheItemDao.findAll(); List<CacheItem> all = cacheItemDao.findAll();
for (CacheItem cacheItem : all) { for (CacheItem cacheItem : all) {
cacheMap.put(cacheItem.getCacheKey(), cacheItem.getCacheValue()); if (StringUtils.isNotBlank(cacheItem.getCacheKey()) && cacheItem.getCacheValue() != null) {
cacheMap.put(cacheItem.getCacheKey(), cacheItem.getCacheValue());
}
} }
if (cacheMap.get(Constants.CACHE_StopOut) == null) { if (cacheMap.get(Constants.CACHE_StopOut) == null) {
updateCache(Constants.CACHE_StopOut, false); updateCache(Constants.CACHE_StopOut, false);
...@@ -173,20 +176,22 @@ public class DataCache { ...@@ -173,20 +176,22 @@ public class DataCache {
* 更新缓存信息 * 更新缓存信息
*/ */
public void updateCache(String cacheKey, Object value) { public void updateCache(String cacheKey, Object value) {
cacheItemDao.updateCacheItem(cacheKey, value); if (StringUtils.isNotBlank(cacheKey) && value != null) {
cacheMap.put(cacheKey, value); cacheItemDao.updateCacheItem(cacheKey, value);
if (cacheKey.equals(Constants.CACHE_CodeRule)) { cacheMap.put(cacheKey, value);
List<String> ruleList = (List<String>) value; if (cacheKey.equals(Constants.CACHE_CodeRule)) {
codeResolve.updateBarcodeRuleList(ruleList); List<String> ruleList = (List<String>) value;
} codeResolve.updateBarcodeRuleList(ruleList);
if (cacheKey.equals(Constants.CACHE_ExpiresDay)) { }
codeResolve.updateExpiresDay((Integer) value); 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 + "]"); log.info("updateCache [" + cacheKey + "]=[" + value + "]");
}
} }
/** /**
...@@ -949,4 +954,13 @@ public class DataCache { ...@@ -949,4 +954,13 @@ public class DataCache {
} }
return true; 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 { ...@@ -80,6 +80,13 @@ public class SettingsController {
dataCache.updateCache(Constants.CACHE_API_XRAY_BYPASSS,xrayBypass); 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(); SysSettingsDto dto = new SysSettingsDto();
dto.setStartJob(startJob); dto.setStartJob(startJob);
dto.setStopOut(stopOut); dto.setStopOut(stopOut);
...@@ -90,6 +97,7 @@ public class SettingsController { ...@@ -90,6 +97,7 @@ public class SettingsController {
dto.setSameBarcodeSettings(barcodeSet); dto.setSameBarcodeSettings(barcodeSet);
dto.setApiTest(useAPi); dto.setApiTest(useAPi);
dto.setXrayBypass(xrayBypass); dto.setXrayBypass(xrayBypass);
dto.setExpiredateVerify(expiredateVerify);
return dto; return dto;
} }
...@@ -106,9 +114,11 @@ public class SettingsController { ...@@ -106,9 +114,11 @@ public class SettingsController {
dataCache.updateCache(Constants.CACHE_SAME_BARCODE_SETTINGS, sysSettingsDto.getSameBarcodeSettings()); dataCache.updateCache(Constants.CACHE_SAME_BARCODE_SETTINGS, sysSettingsDto.getSameBarcodeSettings());
dataCache.updateCache(Constants.CACHE_API_TEST, sysSettingsDto.isApiTest()); dataCache.updateCache(Constants.CACHE_API_TEST, sysSettingsDto.isApiTest());
dataCache.updateCache(Constants.CACHE_API_XRAY_BYPASSS, sysSettingsDto.isXrayBypass()); 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() log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob() + ",sluggishDay=" + sysSettingsDto.getSluggishDay()
+ ",expiresDay=" + sysSettingsDto.getExpiresDay() + ",capacityWarn=" + sysSettingsDto.getCapacityWarn() + ",backUpMonth=" + sysSettingsDto.getBackUpMonth() + + ",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(), "保存成功"); String msg = MessageUtils.getText("smfcore.saveOk", servletRequest.getLocale(), "保存成功");
return ResultBean.newOkResult(msg); return ResultBean.newOkResult(msg);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!