Commit 92658bfa zshaohui

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

1 个父辈 e4564619
......@@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@Api(tags = "SHELF: NLP感应料架")
@RestController
......@@ -48,6 +49,8 @@ public class NLPShelfHandler extends BaseDeviceHandler {
@Autowired
private IUserManager userManager;
private Map<String,String> cacheMap = new ConcurrentHashMap<>();
/**
* 扫码
*/
......@@ -67,14 +70,14 @@ public class NLPShelfHandler extends BaseDeviceHandler {
//获取数量
String newAmountStr = mapValues.get("newAmount");
if (StringUtils.isEmpty(newAmountStr)){
if (StringUtils.isEmpty(newAmountStr)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"amount"});
}
log.info("barcode:[{}],新设置数量为[{}]",code,newAmountStr);
log.info("barcode:[{}],新设置数量为[{}]", code, 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});
}
......@@ -95,47 +98,51 @@ public class NLPShelfHandler extends BaseDeviceHandler {
if (groupId != null && groupId.equals("-1")) {
groupId = "";
}
// WebSocketServer.sendMsg("", new SocketMsg("{0}未找到库位:{1}"+code, MsgType.INFO,"smfclient.nlp.cannotFindPos",new String[]{"消息测试","库位号"}));
String loginUser = SecurityUtils.getLoginUsername();
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (queueTask.isPutInTask() && (queueTask.isWait() || queueTask.isExecuting())) {
if (!Strings.isNullOrEmpty(groupId) && queueTask.getGroupId().equals(groupId)) {
log.info("codeIn [" + code + "][" + groupId + "]入库时取消条码[" + queueTask.getBarcode() + "]的未完成入库任务");
//return ResultBean.newErrorResult(-1,"smfcore.unfinished","the task of [{0}] is unfinished",new String[]{queueTask.getBarcode()});
taskService.cancelTask(queueTask.getId());
}
if (!Strings.isNullOrEmpty(storageId) && queueTask.getStorageId().equals(storageId)) {
log.info("codeIn [" + code + "][" + storageId + "]入库时取消料架[" + queueTask.getStorageId() + "]的未完成入库任务");
//return ResultBean.newErrorResult(-1,"smfcore.unfinished","the task of [{0}] is unfinished",new String[]{queueTask.getStorageName()});
taskService.cancelTask(queueTask.getId());
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[]{"消息测试","库位号"}));
String loginUser = SecurityUtils.getLoginUsername();
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (queueTask.isPutInTask() && (queueTask.isWait() || queueTask.isExecuting())) {
if (!Strings.isNullOrEmpty(groupId) && queueTask.getGroupId().equals(groupId)) {
log.info("codeIn [" + code + "][" + groupId + "]入库时取消条码[" + queueTask.getBarcode() + "]的未完成入库任务");
//return ResultBean.newErrorResult(-1,"smfcore.unfinished","the task of [{0}] is unfinished",new String[]{queueTask.getBarcode()});
taskService.cancelTask(queueTask.getId());
}
if (!Strings.isNullOrEmpty(storageId) && queueTask.getStorageId().equals(storageId)) {
log.info("codeIn [" + code + "][" + storageId + "]入库时取消料架[" + queueTask.getStorageId() + "]的未完成入库任务");
//return ResultBean.newErrorResult(-1,"smfcore.unfinished","the task of [{0}] is unfinished",new String[]{queueTask.getStorageName()});
taskService.cancelTask(queueTask.getId());
}
}
}
}
try{
CodeValidateParam params = new CodeValidateParam(loginUser, groupId, storageId, code, token);
Barcode barcodeSave = smfApi.canPutInBeforeResolve(params);
try {
CodeValidateParam params = new CodeValidateParam(loginUser, groupId, storageId, code, token);
Barcode barcodeSave = smfApi.canPutInBeforeResolve(params);
if (barcodeSave == null) {
barcodeSave = codeResolve.resolveOneValideBarcode("=1x1=" + code);
}
if (barcodeSave == null) {
barcodeSave = codeResolve.resolveOneValideBarcode("=1x1=" + code);
}
//从API验证
Barcode verResult = smfApi.canPutInAfterResolve(params, barcodeSave);
//从API验证
Barcode verResult = smfApi.canPutInAfterResolve(params, barcodeSave);
if (verResult != null) {
barcodeSave = verResult;
}
if (verResult != null) {
barcodeSave = verResult;
}
//设置新数量
barcodeSave.setAmount(newAmount);
return putIn(loginUser, groupId, storageId, barcodeSave, token);
}catch (ValidateException ve){
return ResultBean.newErrorResult(-1,ve.getMsgKey(),ve.getDefaultMsg(),ve.getMsgParam());
//设置新数量
barcodeSave.setAmount(newAmount);
return putIn(loginUser, groupId, storageId, barcodeSave, token);
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg(), ve.getMsgParam());
}
}
}
protected ResultBean putIn(String loginUser, String groupId, String storageId, Barcode barcode, String token) {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!