Commit b03d6c8a sunke

流水线根据条码获取物料的任务信息,用于入料口料串冲过头,无法获取料盘尺寸时,从服务器获取(如果有返回尺寸,流水线添加尺寸后正常入库, 如果获取尺寸失败,放上托盘并NG处理,并复位)

1 个父辈 d43b5df5
...@@ -254,6 +254,33 @@ public class DataCache{ ...@@ -254,6 +254,33 @@ public class DataCache{
} }
/** /**
* 从字符串中解析出Barcode
*/
public Barcode getBarcodeFromCodeStr(String codeStr){
if(!Strings.isNullOrEmpty(codeStr)){
//防止规则未初始化
if(barcodeRuleList == null){
getSettings();
}
//双##号分割多个二维码
String[] barcodeItemStrs = codeStr.split("##");
for (String barcodeItemStr : barcodeItemStrs){
if(!barcodeItemStr.isEmpty()){
//每个规则尝试解析一次
for (BarcodeRule codeRule : barcodeRuleList){
CodeBean codeBean = codeRule.toCodeBean(barcodeItemStr);
if(codeBean.isValid()){
return codeBean.getBarcode();
}
}
}
}
}
return null;
}
/**
* 解析条码为单个 Barcode * 解析条码为单个 Barcode
*/ */
public CodeBean resolveSingleCode(String barcodeItemStr){ public CodeBean resolveSingleCode(String barcodeItemStr){
......
...@@ -224,11 +224,13 @@ public class QisdaDeviceController extends BaseController { ...@@ -224,11 +224,13 @@ public class QisdaDeviceController extends BaseController {
} }
if(robotIndex.equals("1")){ if(robotIndex.equals("1")){
//1号位机器人 //1号位机器人
firstRobotTask = task; //firstRobotTask = task;
log.info("将扫码任务["+firstRobotTask.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务"); boolean result = updateRobotTask(robotIndex,task,"");
log.info("将扫码任务["+firstRobotTask.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务,结果:" + result);
}else if(robotIndex.equals("2")){ }else if(robotIndex.equals("2")){
secondRobotTask = task; //secondRobotTask = task;
log.info("将扫码任务["+secondRobotTask.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务"); boolean result = updateRobotTask(robotIndex,task,"");
log.info("将扫码任务["+secondRobotTask.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务:" + result);
} }
}catch(Exception e){ }catch(Exception e){
log.error("料盘到达机器人出错:",e); log.error("料盘到达机器人出错:",e);
...@@ -253,6 +255,7 @@ public class QisdaDeviceController extends BaseController { ...@@ -253,6 +255,7 @@ public class QisdaDeviceController extends BaseController {
try{ try{
Barcode barcode = dataCache.resolveOneValideBarcode(codeStr); Barcode barcode = dataCache.resolveOneValideBarcode(codeStr);
if(robotIndex.equals("1")){ if(robotIndex.equals("1")){
//1号位机器人 //1号位机器人
boolean firstRobtoSame = isSameTask(barcode,firstRobotTask); boolean firstRobtoSame = isSameTask(barcode,firstRobotTask);
...@@ -261,8 +264,9 @@ public class QisdaDeviceController extends BaseController { ...@@ -261,8 +264,9 @@ public class QisdaDeviceController extends BaseController {
log.info("机器人["+robotIndex+"]当前取料任务与条码["+barcode.getBarcode()+"]一致,不再更新位置任务"); log.info("机器人["+robotIndex+"]当前取料任务与条码["+barcode.getBarcode()+"]一致,不再更新位置任务");
return "OK"; return "OK";
} }
firstRobotTask = firstScanTask; //firstRobotTask = firstScanTask;
log.info("将扫码任务["+firstRobotTask.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务"); boolean result = updateRobotTask(robotIndex,firstScanTask,"");
log.info("将扫码任务["+firstScanTask.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务,结果:"+result);
}else if(robotIndex.equals("2")){ }else if(robotIndex.equals("2")){
boolean secondRobtoSame = isSameTask(barcode,secondRobotTask); boolean secondRobtoSame = isSameTask(barcode,secondRobotTask);
if(secondRobtoSame){ if(secondRobtoSame){
...@@ -270,8 +274,9 @@ public class QisdaDeviceController extends BaseController { ...@@ -270,8 +274,9 @@ public class QisdaDeviceController extends BaseController {
log.info("机器人["+robotIndex+"]当前取料任务与条码["+barcode.getBarcode()+"]一致,不再更新位置任务"); log.info("机器人["+robotIndex+"]当前取料任务与条码["+barcode.getBarcode()+"]一致,不再更新位置任务");
return "OK"; return "OK";
} }
secondRobotTask = secondScanTask; //secondRobotTask = secondScanTask;
log.info("将扫码任务["+secondRobotTask.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务"); boolean result = updateRobotTask(robotIndex, secondScanTask, "");
log.info("将扫码任务["+secondRobotTask.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务,结果:" + result);
} }
updateScanTask(robotIndex, null); updateScanTask(robotIndex, null);
}catch(Exception e){ }catch(Exception e){
...@@ -1081,6 +1086,39 @@ public class QisdaDeviceController extends BaseController { ...@@ -1081,6 +1086,39 @@ public class QisdaDeviceController extends BaseController {
return ResultBean.newErrorResult(501,errorMsg); return ResultBean.newErrorResult(501,errorMsg);
} }
private synchronized boolean updateRobotTask(String robotIndex, DataLog task, String barcode){
if(task != null){
if(robotIndex.equals("1")){
//1号位机器人
firstRobotTask = task;
}else if(robotIndex.equals("2")){
secondRobotTask = task;
}
log.info("将条码["+task.getBarcode()+"]设置到机器人["+robotIndex+"]取料任务");
return true;
}else{
//清空
if(robotIndex.equals("1")){
if(firstRobotTask != null){
if(firstRobotTask.getBarcode().equals(barcode)){
firstRobotTask = null;
log.info("清空机器人[1]任务["+barcode+"]成功");
return true;
}
}
}else if(robotIndex.equals("2")){
if(secondRobotTask != null){
if(secondRobotTask.getBarcode().equals(barcode)){
secondRobotTask = null;
log.info("清空机器人[2]任务["+barcode+"]成功");
return true;
}
}
}
}
return false;
}
/** /**
* 放置到料架动作完成,返回当前料架还可放置的数量,用任务总数 * 放置到料架动作完成,返回当前料架还可放置的数量,用任务总数
*/ */
...@@ -1104,17 +1142,19 @@ public class QisdaDeviceController extends BaseController { ...@@ -1104,17 +1142,19 @@ public class QisdaDeviceController extends BaseController {
if(Strings.isNotBlank(robotIndex)){ if(Strings.isNotBlank(robotIndex)){
if(robotIndex.equals("1") && firstRobotTask != null){ if(robotIndex.equals("1") && firstRobotTask != null){
if(firstRobotTask.getBarcode().equals(barcode)){ if(firstRobotTask.getBarcode().equals(barcode)){
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,任务一致,清空机器人任务"); boolean clearResult = updateRobotTask(robotIndex,null, barcode);
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,任务一致,清空机器人任务,结果["+clearResult+"]");
//1号位机器人 //1号位机器人
firstRobotTask = null; //firstRobotTask = null;
}else{ }else{
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,与当前任务["+firstRobotTask.getBarcode()+"]不一致,不清空"); log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,与当前任务["+firstRobotTask.getBarcode()+"]不一致,不清空");
} }
}else if(robotIndex.equals("2") && secondRobotTask != null){ }else if(robotIndex.equals("2") && secondRobotTask != null){
if(secondRobotTask.getBarcode().equals(barcode)){ if(secondRobotTask.getBarcode().equals(barcode)){
//1号位机器人 //2号位机器人
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,任务一致,清空机器人任务"); boolean clearResult = updateRobotTask(robotIndex,null, barcode);
secondRobotTask = null; log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,任务一致,清空机器人任务,结果["+clearResult+"]");
//secondRobotTask = null;
}else{ }else{
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,与当前任务["+secondRobotTask.getBarcode()+"]不一致,不清空"); log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,与当前任务["+secondRobotTask.getBarcode()+"]不一致,不清空");
} }
...@@ -1712,4 +1752,44 @@ public class QisdaDeviceController extends BaseController { ...@@ -1712,4 +1752,44 @@ public class QisdaDeviceController extends BaseController {
} }
} }
/**
* 流水线根据条码获取物料的任务信息,用于入料口料串冲过头,无法获取料盘尺寸时,从服务器获取(如果有返回尺寸,流水线添加尺寸后正常入库, 如果获取尺寸失败,放上托盘并NG处理,并复位)
*/
@RequestMapping(value = "/getReelSize")
@ResponseBody
public ResultBean getReelSize(HttpServletRequest request) {
try{
String barcodeStr = request.getParameter("barcode");
log.info("收到流水线获取["+ barcodeStr +"]的尺寸信息");
Barcode barcode = dataCache.getBarcodeFromCodeStr(barcodeStr);
if(barcode != null){
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("barcode",barcode.getBarcode());
//先查找此料盘之前是否有入过库
Barcode dbBarcode = barcodeManager.findByBarcode(barcode.getBarcode());
if(dbBarcode != null){
dataMap.put("plateW",dbBarcode.getPlateSize());
dataMap.put("plateH",dbBarcode.getHeight());
return ResultBean.newOkResult(dataMap);
}else{
//查找
Component component = componentManager.findProviderPn(barcode.getPartNumber(), barcode.getProvider());
if(component == null){
component = componentManager.findOneByPn(barcode.getPartNumber());
}
if(component != null){
dataMap.put("plateW",component.getPlateSize());
dataMap.put("plateH",component.getHeight());
return ResultBean.newOkResult(dataMap);
}
}
return ResultBean.newErrorResult(405,"未找到条码:"+barcode.getBarcode()+"PN:" + barcode.getPartNumber()+"的尺寸信息");
}
return ResultBean.newErrorResult(404,"未从["+barcodeStr+"]中找到有效条码");
}catch(Exception e){
log.error("流水线获取尺寸信息出错",e);
return ResultBean.newErrorResult(500,e.getMessage());
}
}
} }
...@@ -570,17 +570,17 @@ public class StorageDataController extends BaseController { ...@@ -570,17 +570,17 @@ public class StorageDataController extends BaseController {
Map<String,Object> resultMap = Maps.newHashMap(); Map<String,Object> resultMap = Maps.newHashMap();
//暂停入库时,包装料架例外,包装仓通过AGV不拉VMI线入库料架控制 //暂停入库时,包装料架例外,包装仓通过AGV不拉VMI线入库料架控制
if(!DataCache.isProductionFor(DataCache.CUSTOMER.QISDA4D)){{ // if(!DataCache.isProductionFor(DataCache.CUSTOMER.QISDA4D)){{
//3楼暂停入库功能 // //3楼暂停入库功能
if(dataCache.getSettings().isStopIn()){ // if(dataCache.getSettings().isStopIn()){
if(!StorageConstants.SHEFL_TYPE.isAShelf(rfid)){ // if(!StorageConstants.SHEFL_TYPE.isAShelf(rfid)){
lineMsg = "系统已暂停入库"; // lineMsg = "系统已暂停入库";
resultMap.put("result","100"); // resultMap.put("result","100");
resultMap.put("msg",lineMsg); // resultMap.put("msg",lineMsg);
return resultMap; // return resultMap;
} // }
} // }
}} // }}
String okMsg = ""; String okMsg = "";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!