Commit 211a0cdc sunke

1 亮灯灭灯慢的问题

2 第一盘料没感应到又扫了第二盘物料时,取消第一盘料的入库任务
1 个父辈 c7bd53b4
......@@ -141,240 +141,244 @@ public class NLPShelfHandler extends BaseDeviceHandler{
if(storage == null){
return ResultBean.newErrorResult(-1,"smfcore.shelfNotExist", "{0}对应的料架不存在",new String[]{cid} );
}
String groupId = storage.getGroupId();
if(groupId.equals("")){
groupId="-1";
}
String[] hasReelPosList = request.getParameterValues("hasReelPosList");
String[] noReelPosList = request.getParameterValues("noReelPosList");
String[] hasReelPosErrorList = request.getParameterValues("hasReelPosErrorList");//实际信号有料,数据库无信息
String[] noReelPosErrorList = request.getParameterValues("noReelPosErrorList");//实际信号无料,数据库有信息
if(hasReelPosErrorList==null){
hasReelPosErrorList=new String[]{};
}
if(noReelPosErrorList==null) {
noReelPosErrorList = new String[]{};
}
List<String> ngToOk=new ArrayList<>();
//数据库有信息,实际无料
if(noReelPosErrorList.length>0){
//log.info("开始检测noReelPosErrorList");
Query query=new Query(Criteria.where("posName").in(noReelPosErrorList));
List<StoragePos> posList= storagePosManager.findByQuery(query);
for (StoragePos pos:posList) {
if(!pos.isUsed()){
ngToOk.add(pos.getPosName());
log.info("sensorChange 客户端上传 noReelPosErrorList 库位["+pos.getPosName()+"]数据库无信息,放入ngToOk");
}
synchronized(storage){
//实际信号有料,数据库无信息
String[] hasReelPosErrorList = request.getParameterValues("hasReelPosErrorList");
//实际信号无料,数据库有信息
String[] noReelPosErrorList = request.getParameterValues("noReelPosErrorList");
if(hasReelPosErrorList==null){
hasReelPosErrorList=new String[]{};
}
if(noReelPosErrorList==null) {
noReelPosErrorList = new String[]{};
}
}
List<List<String>> data=new ArrayList<>();
data.add(Arrays.asList(hasReelPosErrorList) );
data.add(Arrays.asList(noReelPosErrorList));
DevicesStatusUtil.updateDeviceData(cid,data);
List<String> inOkList = new ArrayList<>();
List<String> inNgList = new ArrayList<>();
List<String> outOkList = new ArrayList<>();
List<String> outNgList = new ArrayList<>();
if(hasReelPosList != null){
log.info("开始检测hasReelPosList");
List<String> newList=new ArrayList<>();
for (String posName : hasReelPosList) {
StoragePos pos = storagePosManager.getByPosName(posName);
if(pos==null) {
log.info("sensorChange 未找到库位 hasReelPosList [" + posName + "]");
continue;
}
if(!pos.isEnabled()){
continue;
List<String> usedPosNameList = dataCache.getUsedPosNameList(storage.getCid());
List<String> ngToOk=new ArrayList<>();
//数据库有信息,实际无料
if(noReelPosErrorList.length>0){
//log.info("开始检测noReelPosErrorList");
for (String noReelPosName : noReelPosErrorList) {
if(usedPosNameList.contains(noReelPosName)){
ngToOk.add(noReelPosName);
log.info("sensorChange 客户端上传 noReelPosErrorList 库位["+noReelPosName+"]数据库无物料,放入ngToOk");
}
}
newList.add(posName);
}
hasReelPosList=newList.toArray(new String[newList.size()]);
List<List<String>> data=new ArrayList<>();
data.add(Arrays.asList(hasReelPosErrorList) );
data.add(Arrays.asList(noReelPosErrorList));
DevicesStatusUtil.updateDeviceData(cid,data);
List<String> inOkList = new ArrayList<>();
List<String> inNgList = new ArrayList<>();
List<String> outOkList = new ArrayList<>();
List<String> outNgList = new ArrayList<>();
String[] hasReelPosList = request.getParameterValues("hasReelPosList");
if(hasReelPosList != null){
log.info("开始检测hasReelPosList");
Set<String> disabledPosNameSet = dataCache.getDisabledPosNameSet();
List<String> newList=new ArrayList<>();
for (String posName : hasReelPosList) {
if(disabledPosNameSet.contains(posName)){
log.info("sensorChange hasReelPosList [" + posName + "]库位被禁用,忽略");
continue;
}
newList.add(posName);
}
//入库的库位列表
if(hasReelPosList.length > 1){
String msg = "不可同时放入多盘物料:"+ String.join(",",hasReelPosList);
log.error(msg);
List<String> notifyUsers = userManager.findByDeviceGroupId(storage.getGroupId());
SocketMsg socketMsg = new SocketMsg(notifyUsers, msg, MsgType.ERROR,"smfclient.nlp.onlyOneTray",new String[]{String.join(",",hasReelPosList)});
hasReelPosList=newList.toArray(new String[newList.size()]);
WebSocketServer.sendMsg("",socketMsg);
for (String posStr : hasReelPosList) {
inNgList.add(posStr);
}
}else if (hasReelPosList.length==1){
log.info("开始检测执行入库");
StoragePos pos = storagePosManager.getByPosName(hasReelPosList[0]);
if(pos == null){
String msg = "未找到库位:"+String.join(",",hasReelPosList) ;
//入库的库位列表
if(hasReelPosList.length > 1){
String msg = "不可同时放入多盘物料:"+ String.join(",",hasReelPosList);
log.error(msg);
List<String> notifyUsers = userManager.findByDeviceGroupId(storage.getGroupId());
WebSocketServer.sendMsg("",new SocketMsg(notifyUsers,msg, MsgType.ERROR,"smfclient.nlp.cannotFindPos",new String[]{"",String.join(",",hasReelPosList)}));
for (String posStr : hasReelPosList) {
inNgList.add(posStr);
}
}else if (hasReelPosList.length==1){
log.info("开始检测执行入库");
StoragePos pos = storagePosManager.getByPosName(hasReelPosList[0]);
if(pos == null){
String msg = "未找到库位:"+String.join(",",hasReelPosList) ;
log.error(msg);
}
else if(!pos.getStorageId().equals(storage.getId())){
String msg = "["+storage.getName()+"]未找到库位:"+String.join(",",hasReelPosList) ;
log.error(msg);
}
//如果库位有料,直接结束
else if(pos.getBarcode()!=null) {
log.info("料架[" + cid + "]入库库位[" + pos.getPosName() + "]已有料: [" + pos.getBarcode().getBarcode() + "]");
}
else{
boolean posInResult = handlePosIn(storage,pos);
if(posInResult){
inOkList.add(pos.getPosName());
}else{
inNgList.add(pos.getPosName());
}
}
}
else if(!pos.getStorageId().equals(storage.getId())){
String msg = "["+storage.getName()+"]未找到库位:"+String.join(",",hasReelPosList) ;
log.error(msg);
}
List<String> notifyUsers = userManager.findByDeviceGroupId(storage.getGroupId());
WebSocketServer.sendMsg("",new SocketMsg(notifyUsers, msg, MsgType.ERROR,"smfclient.nlp.cannotFindPos",new String[]{storage.getName(),String.join(",",hasReelPosList)}));
}
//如果库位有料,直接结束
else if(pos.getBarcode()!=null) {
log.info("料架[" + cid + "]入库库位[" + pos.getPosName() + "]已有料: [" + pos.getBarcode().getBarcode() + "]");
String[] noReelPosList = request.getParameterValues("noReelPosList");
if(noReelPosList != null){
//出库
log.info("出库检测noReelPosList");
for (String noReelPosName : noReelPosList) {
boolean handleNoReelPosResult = handleNoReelPos(storage,usedPosNameList,noReelPosName);
if(handleNoReelPosResult){
outOkList.add(noReelPosName);
}else{
outNgList.add(noReelPosName);
}
}
else{
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
boolean isPutInTask=false;
if(ObjectUtil.isNotEmpty(queueTask.getStorageId()) ){
if(queueTask.isPutInTask()&&queueTask.getStorageId().equals(storage.getId())){
isPutInTask=true;
}
}
else if(queueTask.isPutInTask() && queueTask.getGroupId().equals(groupId)) {
isPutInTask = true;
}
if(isPutInTask) {
queueTask.setCid(cid);
queueTask.setPosId(pos.getId());
queueTask.setPosName(pos.getPosName());
queueTask.setStorageId(storage.getId());
queueTask.setStorageName(storage.getName());
try {
//入库完成,发送入库完成请求
log.info("入库完成,发送入库完成请求");
super.finishedPutIn(cid, pos.getPosName());
inOkList.add(hasReelPosList[0]);
String msg = queueTask.getBarcode() + "入库到" + pos.getPosName() + "成功";
log.info(msg);
}
List<String> notifyUsers = userManager.findByDeviceGroupId(storage.getGroupId());
WebSocketServer.sendMsg("",new SocketMsg(notifyUsers, msg, MsgType.INFO,"smfclient.nlp.inputOk",new String[]{queueTask.getBarcode(),pos.getPosName()}));
Map<String,List<String>> dataMap = new HashMap<>();
dataMap.put("inOkList",inOkList);
dataMap.put("inNgList",inNgList);
dataMap.put("outOkList",outOkList);
dataMap.put("outNgList",outNgList);
dataMap.put("ngToOk",ngToOk);
return ResultBean.newOkResult(dataMap);
}
try {
//判断是否是入库单入库
if (queueTask.getInType() == 5) {
log.info("入库单入库");
Barcode barcode = barcodeManager.findByBarcode(queueTask.getBarcode());
InListItem item = inListCache.UpdateInList(queueTask.getSourceName(), pos, barcode);
if (item != null) {
InList inList = inListCache.getInList(queueTask.getSourceName());
//入库完成,调用 7.2转储单入库过账接口
TransferOrderInInfo inInfo = new TransferOrderInInfo(inList.getName(), inList.getDocType(), queueTask.getBarcode(), item.getBaseCode(), item.getInLgort(), queueTask.getNum());
boolean result = HikApi.transferOrderInApi(queueTask.getOperator(), inInfo);
}
}
} else {
/**
* 处理库位入库
* @param storage
* @param pos
* @return
*/
private boolean handlePosIn(Storage storage, StoragePos pos){
String groupId = storage.getGroupId();
if(groupId.equals("")){
groupId="-1";
}
log.info("调用 7.5入库上架过账接口");
//入库完成,调用 7.5入库上架过账接口
boolean result = HikApi.putInApi(queueTask.getOperator(), InOutApiInfo.inputInfo(queueTask.getInType(), queueTask.getBarcode(), queueTask.getNum()));
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
boolean isPutInTask=false;
if(ObjectUtil.isNotEmpty(queueTask.getStorageId()) ){
if(queueTask.isPutInTask()&&queueTask.getStorageId().equals(storage.getId())){
isPutInTask=true;
}
}
else if(queueTask.isPutInTask() && queueTask.getGroupId().equals(groupId)) {
isPutInTask = true;
}
boolean inResult = false;
if(isPutInTask) {
queueTask.setCid(storage.getCid());
queueTask.setPosId(pos.getId());
queueTask.setPosName(pos.getPosName());
queueTask.setStorageId(storage.getId());
queueTask.setStorageName(storage.getName());
try {
//入库完成,发送入库完成请求
log.info("入库完成,发送入库完成请求");
super.finishedPutIn(storage.getCid(), pos.getPosName());
String msg = queueTask.getBarcode() + "入库到" + pos.getPosName() + "成功";
log.info(msg);
inResult = true;
try {
//判断是否是入库单入库
if (queueTask.getInType() == 5) {
log.info("入库单入库");
Barcode barcode = barcodeManager.findByBarcode(queueTask.getBarcode());
InListItem item = inListCache.UpdateInList(queueTask.getSourceName(), pos, barcode);
if (item != null) {
InList inList = inListCache.getInList(queueTask.getSourceName());
//入库完成,调用 7.2转储单入库过账接口
TransferOrderInInfo inInfo = new TransferOrderInInfo(inList.getName(), inList.getDocType(), queueTask.getBarcode(), item.getBaseCode(), item.getInLgort(), queueTask.getNum());
HikApi.transferOrderInApi(queueTask.getOperator(), inInfo);
}
}
} catch (Exception e) {
log.error("入库完成接口处理报错:", e);
return ResultBean.newErrorResult(-1, "smfcore.inputError", "入库出错:{0}", new String[]{e.getMessage()});
}
} else {
log.info("调用 7.5入库上架过账接口");
//入库完成,调用 7.5入库上架过账接口
HikApi.putInApi(queueTask.getOperator(), InOutApiInfo.inputInfo(queueTask.getInType(), queueTask.getBarcode(), queueTask.getNum()));
break;
} catch (Exception e) {
log.error("入库完成处理出错:", e);
return ResultBean.newErrorResult(-1, "smfcore.inputError", "入库出错:{0}", new String[]{e.getMessage()});
}
}
} catch (Exception e) {
log.error("入库完成接口处理报错:", e);
}
if(inOkList.size() == 0){
inNgList.add(hasReelPosList[0]);
log.error("未找到["+pos.getPosName()+"]的入库任务");
}
} catch (Exception e) {
log.error("入库完成处理出错:", e);
}
return inResult;
}
}
if(noReelPosList != null){
//出库
log.info("出库检测noReelPosList");
for (String posName : noReelPosList) {
StoragePos pos = storagePosManager.getByPosName(posName);
if(pos==null){
log.info("sensorChange 未找到库位 noReelPosList ["+posName+"]");
continue;
}
if(!pos.isEnabled()){
continue;
}
if(pos == null){
String msg = "未找到库位:"+String.join(",",hasReelPosList) ;
log.error(msg);
log.error("未找到["+pos.getPosName()+"]的入库任务");
return false;
}
List<String> notifyUsers = userManager.findByDeviceGroupId(storage.getGroupId());
WebSocketServer.sendMsg("",new SocketMsg(notifyUsers, msg, MsgType.ERROR,"smfclient.nlp.cannotFindPos",new String[]{"",String.join(",",hasReelPosList)}));
}
else if(!pos.getStorageId().equals(storage.getId())){
String msg = "["+storage.getName()+"]未找到库位:"+String.join(",",hasReelPosList) ;
/**
* 处理客户端发上来的无料库位
* @param storage
* @param usedPosNameList
* @param noReelPosName
* @return
*/
private boolean handleNoReelPos(Storage storage, List<String> usedPosNameList, String noReelPosName){
boolean handleResult = false;
if(!usedPosNameList.contains(noReelPosName)){
log.info("库位: "+noReelPosName+" 中数据库中已无物料信息,加入outOkList");
handleResult = true;
}else{
StoragePos pos = storagePosManager.getByPosName(noReelPosName);
if(pos==null){
log.error("sensorChange 未找到库位 noReelPosList ["+noReelPosName+"],加入outOkList");
handleResult = true;
}else{
if(!pos.isEnabled()){
log.error("sensorChange noReelPosList ["+noReelPosName+"]已禁用,加入outOkList");
handleResult = true;
}else if(!pos.getStorageId().equals(storage.getId())){
String msg = "["+storage.getName()+"]未找到库位:"+ noReelPosName+",加入outOkList";
log.error(msg);
List<String> notifyUsers = userManager.findByDeviceGroupId(storage.getGroupId());
WebSocketServer.sendMsg("",new SocketMsg(notifyUsers, msg, MsgType.ERROR,"smfclient.nlp.cannotFindPos",new String[]{storage.getName(),String.join(",",hasReelPosList)}));
handleResult = true;
}else if(pos.getBarcode()==null){
log.info("料架[" + cid + "]出库库位[" + pos.getPosName() + "]已为空 ");
log.info("库位: "+noReelPosName+" 数据库中已无物料信息,加入outOkList");
handleResult = true;
}else{
String outResult = "";
Collection<DataLog> queueTasks = taskService.getQueueTasks();
String outResult = "";
for (DataLog queueTask : queueTasks) {
if(queueTask.isCheckOutTask() && queueTask.getPosName().equals(posName)){
if(queueTask.isCheckOutTask() && queueTask.getPosName().equals(noReelPosName)){
//出库完成
try {
outResult = posName;
super.finishedOutPos(cid,posName);
String msg = queueTask.getBarcode()+ "从"+ posName+"出库成功,颜色["+queueTask.getLightColor()+"]";
outResult = noReelPosName;
super.finishedOutPos(storage.getCid(),noReelPosName);
String msg = queueTask.getBarcode()+ "从"+ noReelPosName+"出库成功";
log.info(msg);
List<String> notifyUsers = userManager.findByDeviceGroupId(storage.getGroupId());
WebSocketServer.sendMsg("",new SocketMsg(notifyUsers, msg, MsgType.INFO,"smfclient.nlp.outputOk",new String[]{queueTask.getBarcode(),posName}));
break;
} catch (Exception e) {
log.error("出库出错",e);
return ResultBean.newErrorResult(-1,"smfcore.checkoutError","出库出错:{0}" ,new String[]{ e.getMessage()});
log.error("库位:" + noReelPosName+"出库出错",e);
break;
}
}
}
if(outResult.isEmpty()){
outNgList.add(posName);
String msg = "未找到["+posName+"]的出库任务";
handleResult = false;
String msg = "未找到["+noReelPosName+"]的出库任务";
log.error(msg);
//WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.ERROR,"smfclient.nlp.noOutTask",new String[]{posName,storage.getName()}));
}else{
outOkList.add(outResult);
handleResult = true;
}
}
}
}
Map<String,List<String>> dataMap = new HashMap<>();
dataMap.put("inOkList",inOkList);
dataMap.put("inNgList",inNgList);
dataMap.put("outOkList",outOkList);
dataMap.put("outNgList",outNgList);
dataMap.put("ngToOk",ngToOk);
return ResultBean.newOkResult(dataMap);
return handleResult;
}
/**
* 获取料架的库位占用及出库任务
*/
......
......@@ -394,6 +394,7 @@ public class DeviceController {
}
pos.setEnabled(false);
storagePosManager.save(pos);
dataCache.updateDisablePos(pos);
log.info("屏蔽库位:库位号[" + pos.getId() + "][" + pos.getPosName() + "]barcode[" + barcode + "]");
DeviceMessageUtil.addEnabledPosMessage(pos,"");
......
......@@ -64,6 +64,11 @@ public class DataCache {
* 库位占用Map, key为cid,value为已使用的库位列表
*/
private static Map<String, List<String>> usedPosNameMap = new ConcurrentHashMap<>();
/**
* 禁用库位名称列表
*/
private static Set<String> disabledPosNameSet;
/**
* 所有的料仓 key 为 cid, value 为 Storage
*/
......@@ -470,6 +475,39 @@ public class DataCache {
return storageInventory;
}
/**
* 获取禁用库位缓存
*/
public Set<String> getDisabledPosNameSet(){
initDisabledPosNameSet();
return disabledPosNameSet;
}
/**
* 初始化禁用库位缓存
*/
private synchronized void initDisabledPosNameSet(){
if(disabledPosNameSet == null){
disabledPosNameSet = new HashSet<>();
List<StoragePos> disabledPosList = storagePosManager.findDisabled();
for (StoragePos disabledPos : disabledPosList) {
disabledPosNameSet.add(disabledPos.getPosName());
}
log.info("加载禁用库位缓存,共" + disabledPosNameSet.size() + "个");
}
}
/**
* 更新禁用库位缓存
*/
public void updateDisablePos(StoragePos pos){
initDisabledPosNameSet();
if(pos.isEnabled()){
disabledPosNameSet.remove(pos.getPosName());
}else{
disabledPosNameSet.add(pos.getPosName());
}
}
/**
* 出库时清除使用库位列表
......@@ -492,9 +530,9 @@ public class DataCache {
/**
* 获取设备所有占用的库位名称列表
*/
public List<String> getUsedPosNameList(String cid) {
if(cid == null){
cid = "";
public synchronized List<String> getUsedPosNameList(String cid) {
if(cid == null || cid.isEmpty()){
return new ArrayList<>();
}
List<String> posNameList = usedPosNameMap.get(cid);
if (posNameList == null) {
......
......@@ -183,161 +183,155 @@ public class SingleInController {
if (ObjectUtils.isEmpty(code)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
}
Storage storage = storageManager.get(storageId);
Storage storage = dataCache.getStorageById(storageId);
if (storage == null) {
return ResultBean.newErrorResult(-1, "smfcore.shelfNotExist", "{0}对应的料架不存在", new String[]{storageId});
}
// log.info("codeInProcess , code["+code+"],storageId["+storageId+"]开始验证是否有未结束的任务");
// WebSocketServer.sendMsg("", new SocketMsg("{0}未找到库位:{1}"+code, MsgType.INFO,"smfclient.nlp.cannotFindPos",new String[]{"消息测试","库位号"}));
String loginUser = SecurityUtils.getLoginUsername();
Collection<DataLog> queueTasks = taskService.getQueueTasks();
ResultBean resultBean = null;
for (DataLog queueTask : queueTasks) {
synchronized (storage){
// log.info("codeInProcess , code["+code+"],storageId["+storageId+"]开始验证是否有未结束的任务");
// WebSocketServer.sendMsg("", new SocketMsg("{0}未找到库位:{1}"+code, MsgType.INFO,"smfclient.nlp.cannotFindPos",new String[]{"消息测试","库位号"}));
String loginUser = SecurityUtils.getLoginUsername();
Collection<DataLog> queueTasks = taskService.getQueueTasks();
ResultBean resultBean = null;
for (DataLog queueTask : queueTasks) {
// log.info("------codeInProcess queueTask="+ JsonUtil.toJsonStr(queueTask));
if (queueTask.isPutInTask() &&(queueTask.isWait()||queueTask.isExecuting()) ) {
if (!Strings.isNullOrEmpty(storageId) && queueTask.getStorageId().equals(storageId)) {
log.info("codeIn [" + code + "][" + storageId + "]入库失败:条码[" + queueTask.getBarcode() + "]的任务还未结束 ");
throw new ValidateException("smfcore.unfinished", "the task of [{0}] is unfinished", new String[]{queueTask.getBarcode()});
if (queueTask.isPutInTask() &&(queueTask.isWait()||queueTask.isExecuting()) ) {
if (!Strings.isNullOrEmpty(storageId) && queueTask.getStorageId().equals(storageId)) {
log.warn("扫描条码["+code+"]时取消物料["+queueTask.getBarcode()+"]未完成的入库任务");
taskService.cancelTask(queueTask.getId());
// log.info("codeIn [" + code + "][" + storageId + "]入库失败:条码[" + queueTask.getBarcode() + "]的任务还未结束 ");
// throw new ValidateException("smfcore.unfinished", "the task of [{0}] is unfinished", new String[]{queueTask.getBarcode()});
}
}
}
}
Barcode barcode = resolveBarcode(code);
Barcode barcode = resolveBarcode(code);
StoragePos pos = storagePosManager.getByBarcode(barcode.getBarcode());
if (pos != null) {
throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()});
}
for (DataLog queueTask : queueTasks) {
if (queueTask.getBarcode()!=null&&queueTask.getBarcode().equals(barcode.getBarcode())) {
log.info("codeIn [" + code + "][" + storageId + "]入库失败:条码[" + queueTask.getBarcode() + "]在料仓["+queueTask.getStorageName()+"]已有入库任务 ");
throw new ValidateException("smfcore.barcode.unfinished", "条码["+queueTask.getBarcode()+"]在料仓["+queueTask.getStorageName()+"]已有入库任务",
new String[]{queueTask.getBarcode(),queueTask.getStorageName()});
StoragePos pos = storagePosManager.getByBarcode(barcode.getBarcode());
if (pos != null) {
throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()});
}
}
//判断料架是否有空位
for (UsageItem item : storage.getUsageMap().values()) {
if (item.getH() == barcode.getHeight() && item.getW() == barcode.getPlateSize()) {
int emptyCount = item.getTotalCount() - item.getUsedCount();
if(emptyCount<=0){
log.info("codeIn [" + code + "][" + storageId + "]入库失败:"+barcode.getPlateSize()+"X"+barcode.getHeight()+"未找到可用库位 ");
throw new ValidateException("smfcore.noValidPos", "未找到可用仓位");
for (DataLog queueTask : queueTasks) {
if (queueTask.getBarcode()!=null&&queueTask.getBarcode().equals(barcode.getBarcode())) {
log.warn("扫描条码["+code+"]时取消["+queueTask.getBarcode()+"]未完成的入库任务");
taskService.cancelTask(queueTask.getId());
}
}
}
//线边间转储入库和退料入库需要获取数量
boolean needGetQty = false;
//01 退料 02 线边仓间入库
String businessType = "";
String businessNo = "";
//线边间转储入库和退料入库需要获取数量
boolean needGetQty = false;
//01 退料 02 线边仓间入库
String businessType = "";
String businessNo = "";
//存储入库需要先验证入库单
if(inType.equals(5)) {
if(ObjectUtil.isEmpty(docName)){
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"docName"});
}
InList inList = inListCache.getInList(docName);
if(inList != null){
if(inList.getDocType() == 4){
//线边仓间入库
businessType = "02";
businessNo = docName;
//存储入库需要先验证入库单
if(inType.equals(5)) {
if(ObjectUtil.isEmpty(docName)){
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"docName"});
}
InList inList = inListCache.getInList(docName);
if(inList != null){
if(inList.getDocType() == 4){
//线边仓间入库
businessType = "02";
businessNo = docName;
}
}
}
if(inType.equals(4)){
//退料入库
businessType = "01";
}
}
if(inType.equals(4)){
//退料入库
businessType = "01";
}
//判断如果是退料入库,需要获取数量
if (!businessType.isEmpty()) {
int num = HikApi.returnMaterialApi(SecurityUtils.getCurrentUsername(), barcode.getBarcode(),businessType,businessNo);
if (num > 0) {
barcode.setAmount(num);
barcodeManager.saveBarcode(barcode);
log.info("入库二维码 " + barcode.getBarcode() + " 从接口获得新数量:" + num + ",并更新");
} else {
throw new ValidateException("smfcore.returnMaterialApi.error", "入库:[" + barcode.getBarcode() + "]获取数量失败");
}
if(inType.equals(5)) {
//入库单验证
resultBean = inListCache.inListValidate(docName, barcode.getPartNumber(),barcode.getAmount());
if (!resultBean.isOkResult()) {
return resultBean;
}
}
//判断如果是退料入库,需要获取数量
if (!businessType.isEmpty()) {
int num = HikApi.returnMaterialApi(SecurityUtils.getCurrentUsername(), barcode.getBarcode(),businessType,businessNo);
if (num > 0) {
barcode.setAmount(num);
barcodeManager.saveBarcode(barcode);
log.info("入库二维码 " + barcode.getBarcode() + " 从接口获得新数量:" + num + ",并更新");
} else {
throw new ValidateException("smfcore.returnMaterialApi.error", "入库:[" + barcode.getBarcode() + "]获取数量失败");
}
if(inType.equals(5)) {
//入库单验证
resultBean = inListCache.inListValidate(docName, barcode.getPartNumber(),barcode.getAmount());
if (!resultBean.isOkResult()) {
return resultBean;
//唯一码校验接口
ResponseParam param = HikApi.riCheckApi(SecurityUtils.getCurrentUsername(), barcode.getBarcode(), "", "");
if (ObjectUtil.isNotEmpty(param)) {
if (param.getCode().equals(HikApi.CODE_OK)) {
//唯一码验证成功
log.info("唯一码[" + barcode.getBarcode() + "]验证成功");
} else {
log.info("唯一码[" + barcode.getBarcode() + "]验证失败:" + param.getCode() + "=" + param.getMessage());
throw new ValidateException("smfcore.riCheckApi.error", "唯一码[" + barcode.getBarcode() + "]验证失败:" + param.getCode() + "=" + param.getMessage() + ""
, new String[]{param.getCode().toString(), param.getMessage()});
}
}
}
} else {
//唯一码校验接口
ResponseParam param = HikApi.riCheckApi(SecurityUtils.getCurrentUsername(), barcode.getBarcode(), "", "");
if (ObjectUtil.isNotEmpty(param)) {
if (param.getCode().equals(HikApi.CODE_OK)) {
//唯一码验证成功
log.info("唯一码[" + barcode.getBarcode() + "]验证成功");
} else {
log.info("唯一码[" + barcode.getBarcode() + "]验证失败:" + param.getCode() + "=" + param.getMessage());
throw new ValidateException("smfcore.riCheckApi.error", "唯一码[" + barcode.getBarcode() + "]验证失败:" + param.getCode() + "=" + param.getMessage() + ""
, new String[]{param.getCode().toString(), param.getMessage()});
String pn = barcode.getPartNumber();
String reelId = barcode.getBarcode();
String num = barcode.getAmount() + "";
Integer qty = barcode.getAmount();
String msl = barcode.getMsl();
try {
//创建入库任务,暂不指定库位
DataLog dataLog = new DataLog();
dataLog.setBarcode(reelId);
dataLog.setPartNumber(pn);
dataLog.setType(OP.PUT_IN);
dataLog.setInType(inType);
dataLog.setProvider(barcode.getProvider());
dataLog.setBatchInfo(barcode.getBatch());
if(inType.equals(5)){
InList inList=inListCache.getInList(docName);
dataLog.setSourceName(docName);
dataLog.setSubSourceInfo(inList.getDocNo());
}
}
}
String pn = barcode.getPartNumber();
String reelId = barcode.getBarcode();
String num = barcode.getAmount() + "";
Integer qty = barcode.getAmount();
String msl = barcode.getMsl();
try {
//创建入库任务,暂不指定库位
DataLog dataLog = new DataLog();
dataLog.setBarcode(reelId);
dataLog.setPartNumber(pn);
dataLog.setType(OP.PUT_IN);
dataLog.setInType(inType);
dataLog.setProvider(barcode.getProvider());
dataLog.setBatchInfo(barcode.getBatch());
if(inType.equals(5)){
InList inList=inListCache.getInList(docName);
dataLog.setSourceName(docName);
dataLog.setSubSourceInfo(inList.getDocNo());
}
barcode.setPutInTime(System.currentTimeMillis());
barcode.updateSluggishTime(dataCache.getPNsluggishDay(barcode.getPartNumber()));
barcodeManager.saveBarcode(barcode);
barcode.setPutInTime(System.currentTimeMillis());
barcode.updateSluggishTime(dataCache.getPNsluggishDay(barcode.getPartNumber()));
barcodeManager.saveBarcode(barcode);
dataLog.setNum(barcode.getAmount());
dataLog.setStatus(OP_STATUS.WAIT.name());
dataLog.setGroupId(storage.getGroupId());
dataLog.setStorageId(storageId);
dataLog.setMemo(barcode.getMemo());
dataLog.setOperator(loginUser);
if (ObjectUtil.isNotEmpty(storageId)) {
if (storage != null) {
dataLog.setCid(storage.getCid());
dataLog.setStorageName(storage.getName());
dataLog.setNum(barcode.getAmount());
dataLog.setStatus(OP_STATUS.WAIT.name());
dataLog.setGroupId(storage.getGroupId());
dataLog.setStorageId(storageId);
dataLog.setMemo(barcode.getMemo());
dataLog.setOperator(loginUser);
if (ObjectUtil.isNotEmpty(storageId)) {
if (storage != null) {
dataLog.setCid(storage.getCid());
dataLog.setStorageName(storage.getName());
}
}
log.info("用户[" + loginUser + "]创建料架[" + storage.getName() + "]的入库任务:barcode[" + barcode.getBarcode() + "],cid[" + storage.getCid() + "],inType[" + inType + "]");
try {
taskService.addTaskToExecute(dataLog);
} catch (Exception e) {
return ResultBean.newErrorResult(-1,"smfclient.nlp.error","入库失败:"+e.getMessage(),new String[]{e.getMessage()});
}
}
log.info("用户[" + loginUser + "]创建料架[" + storage.getName() + "]的入库任务:barcode[" + barcode.getBarcode() + "],cid[" + storage.getCid() + "],inType[" + inType + "]");
try {
taskService.addTaskToExecute(dataLog);
} catch (Exception e) {
return ResultBean.newErrorResult(-1,"smfclient.nlp.error","入库失败:"+e.getMessage(),new String[]{e.getMessage()});
}
} catch (ValidateException e) {
log.error(e.toString());
return ResultBean.newErrorResult(1, e.getMsgKey(), e.getDefaultMsg());
} catch (ValidateException e) {
log.error(e.toString());
return ResultBean.newErrorResult(1, e.getMsgKey(), e.getDefaultMsg());
}
return ResultBean.newOkResult("");
}
return ResultBean.newOkResult("");
}
......
......@@ -215,6 +215,7 @@ public class StoragePosController {
}
pos.setEnabled(enabledDto.isEnabled());
storagePosManager.save(pos);
dataCache.updateDisablePos(pos);
log.info("启用禁用库位:库位号[" + pos.getId() + "][" + pos.getPosName() + "]=" + enabledDto.isEnabled());
DeviceMessageUtil.addEnabledPosMessage(pos,SecurityUtils.getCurrentUsername());
......@@ -244,6 +245,7 @@ public class StoragePosController {
String enabledStr="";
if(pos.isEnabled()!= saveDto.isEnabled()){
pos.setEnabled(saveDto.isEnabled());
dataCache.updateDisablePos(pos);
enabledStr=saveDto.isEnabled()?",启用库位":",禁用库位";
DeviceMessageUtil.addEnabledPosMessage(pos,SecurityUtils.getCurrentUsername());
}
......
......@@ -43,6 +43,8 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
List<StoragePos> findNotEmpty();
List<StoragePos> findDisabled();
List<StoragePos> findByStorage(String storageId);
void insertAll(List<StoragePos> posList);
......
......@@ -7,10 +7,8 @@ import com.google.common.collect.Maps;
import com.neotel.smfcore.common.base.IExcelDownLoad;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.PointUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.bean.PlateSizeBean;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.language.util.MessageUtils;
......@@ -21,7 +19,6 @@ import com.neotel.smfcore.core.storage.service.dao.IStoragePosDao;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.security.service.po.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
......@@ -415,6 +412,13 @@ public class StoragePosManagerImpl implements IStoragePosManager {
}
@Override
public List<StoragePos> findDisabled(){
Criteria c = Criteria.where("enabled").is(false);//不可用;
Query query = new Query(c);
return storagePosDao.findByQuery(query);
}
@Override
public List<StoragePos> findByStorage(String storageId) {
return storagePosDao.findListByCondition(new String[]{"storageId" }, new String[]{storageId });
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!