Commit 92658bfa zshaohui

1.入库连续扫2次码 bug修复

1 个父辈 e4564619
...@@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@Api(tags = "SHELF: NLP感应料架") @Api(tags = "SHELF: NLP感应料架")
@RestController @RestController
...@@ -48,6 +49,8 @@ public class NLPShelfHandler extends BaseDeviceHandler { ...@@ -48,6 +49,8 @@ public class NLPShelfHandler extends BaseDeviceHandler {
@Autowired @Autowired
private IUserManager userManager; private IUserManager userManager;
private Map<String,String> cacheMap = new ConcurrentHashMap<>();
/** /**
* 扫码 * 扫码
*/ */
...@@ -67,14 +70,14 @@ public class NLPShelfHandler extends BaseDeviceHandler { ...@@ -67,14 +70,14 @@ public class NLPShelfHandler extends BaseDeviceHandler {
//获取数量 //获取数量
String newAmountStr = mapValues.get("newAmount"); String newAmountStr = mapValues.get("newAmount");
if (StringUtils.isEmpty(newAmountStr)){ if (StringUtils.isEmpty(newAmountStr)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"amount"}); throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"amount"});
} }
log.info("barcode:[{}],新设置数量为[{}]",code,newAmountStr); log.info("barcode:[{}],新设置数量为[{}]", code, newAmountStr);
Integer newAmount = Integer.valueOf(newAmountStr); Integer newAmount = Integer.valueOf(newAmountStr);
if (newAmount == null || newAmount <= 0){ if (newAmount == null || newAmount <= 0) {
throw new ValidateException("smfcore.error.barcode.wrongQty", "条码[{0}]对应的数量<=0为: {1}", new String[]{code, newAmountStr}); throw new ValidateException("smfcore.error.barcode.wrongQty", "条码[{0}]对应的数量<=0为: {1}", new String[]{code, newAmountStr});
} }
...@@ -95,7 +98,11 @@ public class NLPShelfHandler extends BaseDeviceHandler { ...@@ -95,7 +98,11 @@ public class NLPShelfHandler extends BaseDeviceHandler {
if (groupId != null && groupId.equals("-1")) { if (groupId != null && groupId.equals("-1")) {
groupId = ""; groupId = "";
} }
String value = cacheMap.get(storageId);
if (StringUtils.isEmpty(value)) {
cacheMap.put(storageId, storageId);
}
synchronized (cacheMap.get(storageId)) {
// WebSocketServer.sendMsg("", new SocketMsg("{0}未找到库位:{1}"+code, MsgType.INFO,"smfclient.nlp.cannotFindPos",new String[]{"消息测试","库位号"})); // WebSocketServer.sendMsg("", new SocketMsg("{0}未找到库位:{1}"+code, MsgType.INFO,"smfclient.nlp.cannotFindPos",new String[]{"消息测试","库位号"}));
String loginUser = SecurityUtils.getLoginUsername(); String loginUser = SecurityUtils.getLoginUsername();
Collection<DataLog> queueTasks = taskService.getQueueTasks(); Collection<DataLog> queueTasks = taskService.getQueueTasks();
...@@ -114,7 +121,7 @@ public class NLPShelfHandler extends BaseDeviceHandler { ...@@ -114,7 +121,7 @@ public class NLPShelfHandler extends BaseDeviceHandler {
} }
} }
try{ try {
CodeValidateParam params = new CodeValidateParam(loginUser, groupId, storageId, code, token); CodeValidateParam params = new CodeValidateParam(loginUser, groupId, storageId, code, token);
Barcode barcodeSave = smfApi.canPutInBeforeResolve(params); Barcode barcodeSave = smfApi.canPutInBeforeResolve(params);
...@@ -132,10 +139,10 @@ public class NLPShelfHandler extends BaseDeviceHandler { ...@@ -132,10 +139,10 @@ public class NLPShelfHandler extends BaseDeviceHandler {
//设置新数量 //设置新数量
barcodeSave.setAmount(newAmount); barcodeSave.setAmount(newAmount);
return putIn(loginUser, groupId, storageId, barcodeSave, token); return putIn(loginUser, groupId, storageId, barcodeSave, token);
}catch (ValidateException ve){ } catch (ValidateException ve) {
return ResultBean.newErrorResult(-1,ve.getMsgKey(),ve.getDefaultMsg(),ve.getMsgParam()); return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg(), ve.getMsgParam());
}
} }
} }
protected ResultBean putIn(String loginUser, String groupId, String storageId, Barcode barcode, String token) { protected ResultBean putIn(String loginUser, String groupId, String storageId, Barcode barcode, String token) {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!