Commit b7df5340 LN

扫码亮灯修改

1 个父辈 b8d58d48
...@@ -25,6 +25,7 @@ import java.util.*; ...@@ -25,6 +25,7 @@ import java.util.*;
@Component @Component
public class DataInitManager { public class DataInitManager {
public static boolean Debug=false;
public static Date startRunTime=new Date(); public static Date startRunTime=new Date();
public static Set<String> allPermissionSet; public static Set<String> allPermissionSet;
......
...@@ -63,18 +63,44 @@ public class ShelfInfo { ...@@ -63,18 +63,44 @@ public class ShelfInfo {
private int maxLocCount = 0; private int maxLocCount = 0;
/** /**
* 如果已绑定任务都放完成,可以离开
*/
private boolean needLeave=false;
/**
* 是否所有位置都已扫码亮灯
*/
private boolean lightEnd=false;
/**
* 线体,目标位置 * 线体,目标位置
*/ */
private String line; private String line;
/**
* 料架状态。0=等待放料。
* 1=绑定任务已完成,离开
* 2.已到达line
* 3=所有料盘已扫码灭灯,agv可以拉空料架离开
*/
private int shelfState=0;
public void NeedLeave(){ shelfState=1;
log.info("RFID["+realRfid+"] 设置shelfState= "+shelfState);
}
public void ArriveLine(String line) {
shelfState = 2;
this.line = line;
log.info("RFID[" + realRfid + "] 设置shelfState= " + shelfState + ", line=" + line);
}
public void NeedLeaveLine() {
shelfState = 3;
log.info("RFID[" + realRfid + "] 设置shelfState= " + shelfState);
}
// /**
// * 如果已绑定任务都放完成,可以离开
// */
// private boolean needLeave=false;
//
// /**
// * 是否所有位置都已扫码亮灯
// */
// private boolean lightEnd=false;
// /**
// * 线体,目标位置
// */
// private boolean inLine =false;
public static ShelfInfo newFShelf() { public static ShelfInfo newFShelf() {
return new ShelfInfo(SHELF_TYPE.F, 31); return new ShelfInfo(SHELF_TYPE.F, 31);
...@@ -106,6 +132,10 @@ public class ShelfInfo { ...@@ -106,6 +132,10 @@ public class ShelfInfo {
return false; return false;
} }
public List<ShelfLoc> getLocList(){
List<ShelfLoc> list=new ArrayList<>(locMap.values());
return list;
}
/** /**
* 根据条码获取库位信息 * 根据条码获取库位信息
*/ */
...@@ -247,11 +277,11 @@ public class ShelfInfo { ...@@ -247,11 +277,11 @@ public class ShelfInfo {
} }
} }
if (lCount == 0) { if (lCount == 0) {
needLeave = true; NeedLeave();
} }
// } // }
log.info("料盘[" + barcode + "]放入位置" + rfid + "[" + loc + "]成功,料架是否需要离开="+needLeave); log.info("料盘[" + barcode + "]放入位置" + rfid + "[" + loc + "]成功,料架是否需要离开="+(shelfState==1));
return putInResult; return putInResult;
} else { } else {
log.error("料盘[" + barcode + "]放入位置" + rfid + "[" + loc + "]失败,此位置料盘已放入"); log.error("料盘[" + barcode + "]放入位置" + rfid + "[" + loc + "]失败,此位置料盘已放入");
......
...@@ -51,12 +51,12 @@ public class ShelfLoc { ...@@ -51,12 +51,12 @@ public class ShelfLoc {
*/ */
private boolean isLock = false; private boolean isLock = false;
private String shelfLocation=null; // private String shelfLocation=null;
/** /**
* 是否已经扫码亮灯,料架所有料都扫码亮灯后,料架可离开 * 料盘是否已拿走
*/ */
private boolean codeLight=false; private boolean reelLeave =false;
/** /**
* 判断该架位锁定的条码是否与给定的条码一样 * 判断该架位锁定的条码是否与给定的条码一样
...@@ -94,4 +94,16 @@ public class ShelfLoc { ...@@ -94,4 +94,16 @@ public class ShelfLoc {
public boolean isBigLoc() { public boolean isBigLoc() {
return reelType == REEL_TYPE.BIG; return reelType == REEL_TYPE.BIG;
} }
public String getPosName(String lineLoc) {
String reLoc = lineLoc + "-B1-" + loc;
if (loc <= 13) {
reLoc = lineLoc + "-A1-" + loc;
} else if (loc <= 26) {
reLoc = lineLoc + "-A2-" + (loc - 13);
} else {
reLoc = lineLoc + "-B1-" + (loc - 26);
}
return reLoc;
}
} }
...@@ -82,11 +82,13 @@ public class AgvShelfController { ...@@ -82,11 +82,13 @@ public class AgvShelfController {
//更新记录 //更新记录
TaskShelfUtil.updateShelfLoc(rfid, loc); TaskShelfUtil.updateShelfLoc(rfid, loc);
log.info("updateShelfLoc 更新料架【" + rfid + "】位置=【" + loc + "】"); TaskShelfUtil.OpenShelfLed(shelfInfo);
if(!shelfInfo.getLine().equals(loc)){ log.info("updateShelfLoc 更新料架【" + rfid + "】位置=【" + loc + "】,并所有库位亮灯");
shelfInfo.setLine(loc); // if(!shelfInfo.getLine().equals(loc)){
// shelfInfo.setLine(loc);
shelfInfo.ArriveLine(loc);
TaskShelfUtil.updateShelfInfo(shelfInfo); TaskShelfUtil.updateShelfInfo(shelfInfo);
} // }
String orderNo=shelfInfo.getOrderNo(); String orderNo=shelfInfo.getOrderNo();
LiteOrder order = liteOrderCache.getLiteOrder(orderNo); LiteOrder order = liteOrderCache.getLiteOrder(orderNo);
if (order != null) { if (order != null) {
...@@ -112,20 +114,30 @@ public class AgvShelfController { ...@@ -112,20 +114,30 @@ public class AgvShelfController {
) { ) {
for (ShelfInfo shelf : for (ShelfInfo shelf :
map.values()) { map.values()) {
if (shelf.isLightEnd()) { if (shelf.getShelfState()==3) {
Map<String, String> shelfMap = new HashMap<>(); Map<String, String> shelfMap = new HashMap<>();
shelfMap.put("realRfid", shelf.getRealRfid()); shelfMap.put("realRfid", shelf.getRealRfid());
shelfMap.put("orderNo", shelf.getOrderNo()); shelfMap.put("orderNo", shelf.getOrderNo());
shelfMap.put("rfidIndex", shelf.getRfidIndex() + ""); shelfMap.put("rfidIndex", shelf.getRfidIndex() + "");
shelfMap.put("line", shelf.getLine()); String loc=TaskShelfUtil.getShelfLoc(shelf.getRealRfid());
shelfMap.put("line", loc);
result.add(shelfMap); result.add(shelfMap);
} }
} }
} }
ResultBean resultBean= ResultBean.newOkResult("ok" ); ResultBean resultBean= ResultBean.newOkResult("ok" );
// if(result.size()<=0){
// for (int i=1;i<=2;i++){
// Map<String, String> shelfMap = new HashMap<>();
// shelfMap.put("realRfid","F001"+i);
// shelfMap.put("orderNo", "OrderNo"+i);
// shelfMap.put("rfidIndex","index"+i);
// shelfMap.put("line", "L1-00"+i);
//
// result.add(shelfMap);
// }
// }
resultBean.setData(result); resultBean.setData(result);
return resultBean; return resultBean;
} }
......
...@@ -95,7 +95,8 @@ public class TaskShelfController { ...@@ -95,7 +95,8 @@ public class TaskShelfController {
ShelfLoc loc = TaskShelfUtil.lockShelfLoc(opTask, rfid); ShelfLoc loc = TaskShelfUtil.lockShelfLoc(opTask, rfid);
if (loc == null) { if (loc == null) {
return ResultBean.newErrorResult(304, "smfcore.taskLoc.lockLoc.fail", "{0}获取位置{1}失败", new String[]{opTask.getBarcode(), rfid}, resultMap); return ResultBean.newErrorResult(304, "smfcore.taskLoc.lockLoc.fail", "{0}获取位置{1}失败",
new String[]{opTask.getBarcode()+"-"+opTask.getTempRfid()+"-"+opTask.getRfidLoc(), rfid}, resultMap);
} }
String rfidSave = loc.getRealRfid(); String rfidSave = loc.getRealRfid();
if (ObjectUtil.isEmpty(rfidSave)) { if (ObjectUtil.isEmpty(rfidSave)) {
...@@ -405,7 +406,7 @@ public class TaskShelfController { ...@@ -405,7 +406,7 @@ public class TaskShelfController {
for (String tempRfid : for (String tempRfid :
map2.keySet()) { map2.keySet()) {
ShelfInfo shelfInfo=map2.get(tempRfid); ShelfInfo shelfInfo=map2.get(tempRfid);
msg+="hSerial="+hSerial+",tempRfid="+tempRfid+",realRfid="+shelfInfo.getRealRfid()+",needLeave="+shelfInfo.isNeedLeave()+"\r\n"; msg+="hSerial="+hSerial+",tempRfid="+tempRfid+",realRfid="+shelfInfo.getRealRfid()+",ShelfState="+shelfInfo.getShelfState()+"\r\n";
} }
} }
} }
......
...@@ -6,11 +6,15 @@ import com.neotel.smfcore.core.device.util.DataCache; ...@@ -6,11 +6,15 @@ import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.shelf.bean.ShelfInfo; import com.neotel.smfcore.core.shelf.bean.ShelfInfo;
import com.neotel.smfcore.core.shelf.bean.ShelfLoc; import com.neotel.smfcore.core.shelf.bean.ShelfLoc;
import com.neotel.smfcore.core.shelf.enums.SHELF_TYPE; import com.neotel.smfcore.core.shelf.enums.SHELF_TYPE;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.awt.*;
import java.util.*; import java.util.*;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Slf4j @Slf4j
public class TaskShelfUtil { public class TaskShelfUtil {
...@@ -49,12 +53,28 @@ public class TaskShelfUtil { ...@@ -49,12 +53,28 @@ public class TaskShelfUtil {
initShelfLocMap(); initShelfLocMap();
} }
public static String getCid(String loc){
return loc;
}
private static void initShelfLocMap() { private static void initShelfLocMap() {
if (lineShelfLocMap == null) { if (lineShelfLocMap == null) {
lineShelfLocMap = dataCache.getCache(LINE_SHELF_LOC_MAP_KEY); lineShelfLocMap = dataCache.getCache(LINE_SHELF_LOC_MAP_KEY);
if(lineShelfLocMap ==null){ if(lineShelfLocMap ==null){
lineShelfLocMap =new ConcurrentHashMap<>(); lineShelfLocMap =new ConcurrentHashMap<>();
}else {
for (String rfid :
lineShelfLocMap.keySet()) {
ShelfInfo shelfInfo = TaskShelfUtil.findShelfByRealRfid(rfid);
if (shelfInfo != null) {
String loc = lineShelfLocMap.get(rfid);
log.info("initShelfLocMap 料架 rfid=[" + rfid + "] loc[" + loc + "] 库位亮灯");
OpenShelfLed(shelfInfo);
} else {
log.info("initShelfLocMap 未找到料架 ,rfid=[" + rfid + "]");
}
}
} }
} }
...@@ -68,10 +88,10 @@ public class TaskShelfUtil { ...@@ -68,10 +88,10 @@ public class TaskShelfUtil {
private static void saveLineShelfMap(Map<String, ShelfInfo> map) { private static void saveLineShelfMap(Map<String, ShelfInfo> map) {
dataCache.updateCache(LINE_SHELF_MAP_KEY, map); dataCache.updateCache(LINE_SHELF_MAP_KEY, map);
} }
private static void AddShelfToLineMap(ShelfInfo shelfInfo){ // private static void AddShelfToLineMap(ShelfInfo shelfInfo){
lineShelfMap.put(shelfInfo.getRealRfid(),shelfInfo); // lineShelfMap.put(shelfInfo.getRealRfid(),shelfInfo);
saveLineShelfMap(lineShelfMap); // saveLineShelfMap(lineShelfMap);
} // }
private static void saveLineShelfLocMap(Map<String, String> map) { private static void saveLineShelfLocMap(Map<String, String> map) {
dataCache.updateCache(LINE_SHELF_LOC_MAP_KEY, map); dataCache.updateCache(LINE_SHELF_LOC_MAP_KEY, map);
} }
...@@ -172,12 +192,13 @@ public class TaskShelfUtil { ...@@ -172,12 +192,13 @@ public class TaskShelfUtil {
int maxIndex = 0; int maxIndex = 0;
if (shelfMap != null) { if (shelfMap != null) {
for (ShelfInfo shelfInfo : shelfMap.values()) { for (ShelfInfo shelfInfo : shelfMap.values()) {
if(shelfInfo.isNeedLeave()){
continue;
}
if (shelfInfo.getRfidIndex() > maxIndex) { if (shelfInfo.getRfidIndex() > maxIndex) {
maxIndex = shelfInfo.getRfidIndex(); maxIndex = shelfInfo.getRfidIndex();
} }
if(shelfInfo.getShelfState()>=1){
continue;
}
targetLoc = shelfInfo.addUnLimitLoc(task); targetLoc = shelfInfo.addUnLimitLoc(task);
if (targetLoc != -1) { if (targetLoc != -1) {
//添加成功 //添加成功
...@@ -328,7 +349,7 @@ public class TaskShelfUtil { ...@@ -328,7 +349,7 @@ public class TaskShelfUtil {
}); });
ShelfInfo minIndexShelf = null; ShelfInfo minIndexShelf = null;
for (ShelfInfo shelf : shelfList) { for (ShelfInfo shelf : shelfList) {
if (shelf.isFull()||shelf.isNeedLeave()) { if (shelf.isFull()||shelf.getShelfState()>=1) {
//已经放满,查找下一个 //已经放满,查找下一个
continue; continue;
} }
...@@ -513,7 +534,7 @@ public class TaskShelfUtil { ...@@ -513,7 +534,7 @@ public class TaskShelfUtil {
public static void updateShelfLoc(String rfid,String loc){ public static void updateShelfLoc(String rfid,String loc){
if(ObjectUtil.isEmpty(loc)){ if(ObjectUtil.isEmpty(loc)){
lineShelfMap.remove(rfid); lineShelfLocMap.remove(rfid);
}else { }else {
lineShelfLocMap.put(rfid, loc); lineShelfLocMap.put(rfid, loc);
...@@ -530,23 +551,98 @@ public class TaskShelfUtil { ...@@ -530,23 +551,98 @@ public class TaskShelfUtil {
return line; return line;
} }
//
// /**
// * 扫码亮灯,获取库位号
// * @param barcode
// * @return
// */
// public static ShelfLoc codeLightGetLoc(String barcode) {
// for (Map<String, ShelfInfo> shelfInfoMap : taskShelfMap.values()) {
// for (ShelfInfo shelf : shelfInfoMap.values()) {
//
// ShelfLoc shelfLoc = shelf.getBarcodeLoc(barcode);
// if (shelfLoc != null && (!shelfLoc.isEmpty())) {
// //获取料架位置
// String line = getShelfLoc(shelfLoc.getRealRfid());
// shelfLoc.setShelfLocation(line);
//
// shelfLoc.setReelLeave(true);
// //TODO 标记此料已扫码
// Map<Integer, ShelfLoc> locMap = shelf.getLocMap();
// locMap.put(shelfLoc.getLoc(), shelfLoc);
// shelf.setLocMap(locMap);
//
// boolean lightEnd=true;
// for (ShelfLoc loc : locMap.values()){
// if(!loc.isEmpty()){
// if(!loc.isReelLeave()){
// lightEnd=false;
// break;
// }
// }
// }
//
// shelf.setLightEnd(lightEnd);
//
// updateShelfInfo(shelf);
// log.info("标记料架[" + shelf.getRealRfid() + "]位置[" + shelfLoc.getLoc() + "]条码[" + shelfLoc.getBarcode() + "]为已扫码亮灯,料架是否亮灯完成["+lightEnd+"]");
// return shelfLoc;
//
// }
//
// }
// }
// return null;
// }
public static boolean OpenShelfLed(ShelfInfo shelfInfo) {
List<ShelfLoc> locs = shelfInfo.getLocList();
String shelfLoc = getShelfLoc(shelfInfo.getRealRfid());
String cid=getCid(shelfLoc);
Storage storage = dataCache.getStorage(cid);
if (storage == null) {
log.error("OpenShelfLed 料架" + shelfInfo.getRealRfid() + " , 位置:" + shelfLoc + ",cid "+cid+" 未找到对应的亮灯料架");
return false;
}
for (ShelfLoc loc : locs
) {
String posname = loc.getPosName(shelfLoc);
if (loc.isEmpty() || ObjectUtil.isEmpty(loc.getBarcode())) {
continue;
}
if (loc.isReelLeave()) {
continue;
} else {
DevicesStatusUtil.appendOp(storage.getCid(), "open", posname + "=" + Color.GREEN.toString());
log.info("亮灯料架CID:" + storage.getCid() + ",料架RFID:" + shelfInfo.getRealRfid() + " ,库位: " + posname + " 亮灯 :" + Color.GREEN.toString());
}
}
return true;
}
/** /**
* 扫码亮灯,获取库位号 * 扫码亮灯,获取库位号
* @param barcode * @param barcode
* @return * @return
*/ */
public static ShelfLoc codeLightGetLoc(String barcode) { public static List<Object> ReelLeave(String barcode) {
List<Object> list=new ArrayList<>();
for (Map<String, ShelfInfo> shelfInfoMap : taskShelfMap.values()) { for (Map<String, ShelfInfo> shelfInfoMap : taskShelfMap.values()) {
for (ShelfInfo shelf : shelfInfoMap.values()) { for (ShelfInfo shelf : shelfInfoMap.values()) {
if(!(shelf.getShelfState()==2)){
return null;
}
ShelfLoc shelfLoc = shelf.getBarcodeLoc(barcode); ShelfLoc shelfLoc = shelf.getBarcodeLoc(barcode);
if (shelfLoc != null && (!shelfLoc.isEmpty())) { if (shelfLoc != null && (!shelfLoc.isEmpty())) {
//获取料架位置 //获取料架位置
String line = getShelfLoc(shelfLoc.getRealRfid()); // String line = getShelfLoc(shelfLoc.getRealRfid());
shelfLoc.setShelfLocation(line); // shelfLoc.setShelfLocation(line);
shelfLoc.setCodeLight(true); shelfLoc.setReelLeave(true);
//TODO 标记此料已扫码 //TODO 标记此料已扫码
Map<Integer, ShelfLoc> locMap = shelf.getLocMap(); Map<Integer, ShelfLoc> locMap = shelf.getLocMap();
locMap.put(shelfLoc.getLoc(), shelfLoc); locMap.put(shelfLoc.getLoc(), shelfLoc);
...@@ -555,18 +651,20 @@ public class TaskShelfUtil { ...@@ -555,18 +651,20 @@ public class TaskShelfUtil {
boolean lightEnd=true; boolean lightEnd=true;
for (ShelfLoc loc : locMap.values()){ for (ShelfLoc loc : locMap.values()){
if(!loc.isEmpty()){ if(!loc.isEmpty()){
if(!loc.isCodeLight()){ if(!loc.isReelLeave()){
lightEnd=false; lightEnd=false;
break; break;
} }
} }
} }
shelf.setLightEnd(lightEnd); shelf.NeedLeaveLine();
updateShelfInfo(shelf); updateShelfInfo(shelf);
log.info("标记料架[" + shelf.getRealRfid() + "]位置[" + shelfLoc.getLoc() + "]条码[" + shelfLoc.getBarcode() + "]为已扫码亮灯,料架是否亮灯完成["+lightEnd+"]"); log.info("标记料架[" + shelf.getRealRfid() + "]位置[" + shelfLoc.getLoc() + "]条码[" + shelfLoc.getBarcode() + "]已扫码灭灯,料盘已离开,料架是否亮灯完成["+lightEnd+"]");
return shelfLoc; list.add(shelf);
list.add(shelfLoc);
// return shelfLoc;
} }
......
package com.neotel.smfcore.custom.gree20242.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ShelfDto {
@ApiModelProperty("料架rfid")
private String rfid ;
@ApiModelProperty("位置")
private String loc ;
@ApiModelProperty("工单信息")
private String orderNo ;
@ApiModelProperty("物料列表")
private List<ShelfReelDto> reelList;
}
package com.neotel.smfcore.custom.gree20242.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ShelfReelDto implements Serializable {
@ApiModelProperty("PN")
private String pn;
@ApiModelProperty("RI")
private String ri;
@ApiModelProperty("库位号")
private String posName;
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!