Commit fae12414 LN

增加获取空料架接口

1 个父辈 cef4b71c
......@@ -62,6 +62,16 @@ public class ShelfInfo {
*/
private int maxLocCount = 0;
/**
* 是否所有位置都已扫码亮灯
*/
private boolean lightEnd=false;
/**
* 线体,目标位置
*/
private String line;
public static ShelfInfo newFShelf() {
return new ShelfInfo(SHELF_TYPE.F, 31);
}
......@@ -297,4 +307,6 @@ public class ShelfInfo {
// result.add(bigEmpty);
// return result;
// }
}
......@@ -54,6 +54,11 @@ public class ShelfLoc {
private String shelfLocation=null;
/**
* 是否已经扫码亮灯,料架所有料都扫码亮灯后,料架可离开
*/
private boolean codeLight=false;
/**
* 判断该架位锁定的条码是否与给定的条码一样
*
* @param barcode
......
......@@ -13,12 +13,13 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
......@@ -51,6 +52,11 @@ public class AgvShelfController {
liteOrderCache.addOrderToMap(order);
}
String line=order.getLine();
if(!shelfInfo.getLine().equals(line)){
shelfInfo.setLine(line);
TaskShelfUtil.updateShelfInfo(shelfInfo);
}
log.info("getShelfTargetLoc 料架 ,rfid=[" + rfid + "],目标位置:[" + line + "]");
return ResultBean.newOkResult(line);
}
......@@ -78,7 +84,10 @@ public class AgvShelfController {
//更新记录
TaskShelfUtil.updateShelfLoc(rfid, loc);
log.info("updateShelfLoc 更新料架【" + rfid + "】位置=【" + loc + "】");
if(!shelfInfo.getLine().equals(loc)){
shelfInfo.setLine(loc);
TaskShelfUtil.updateShelfInfo(shelfInfo);
}
String orderNo=shelfInfo.getOrderNo();
LiteOrder order = liteOrderCache.getLiteOrder(orderNo);
if (order != null) {
......@@ -90,4 +99,79 @@ public class AgvShelfController {
return ResultBean.newOkResult("ok");
}
@ApiOperation("获取产线可以拉回的空料架")
@PostMapping(value = "/emptyShelfList")
@ResponseBody
@AnonymousAccess
public ResultBean emptyShelfList(HttpServletRequest request) {
List<Map<String,String>> result=new ArrayList<>();
Map<String, Map<String, ShelfInfo>> taskShelfMap= TaskShelfUtil.taskShelfMap;
for (Map<String, ShelfInfo> map:taskShelfMap.values()
) {
for (ShelfInfo shelf :
map.values()) {
if (shelf.isLightEnd()) {
Map<String, String> shelfMap = new HashMap<>();
shelfMap.put("realRfid", shelf.getRealRfid());
shelfMap.put("orderNo", shelf.getOrderNo());
shelfMap.put("rfidIndex", shelf.getRfidIndex() + "");
shelfMap.put("line", shelf.getLine());
result.add(shelfMap);
}
}
}
// if(result.size()<=0) {
// Map<String, String> shelfMap = new HashMap<>();
// shelfMap.put("realRfid", "rfid1");
// shelfMap.put("orderNo", "orderNo1");
// shelfMap.put("rfidIndex", "001");
// shelfMap.put("line", "L1");
//
// result.add(shelfMap);
//
// shelfMap = new HashMap<>();
// shelfMap.put("realRfid", "rfid2");
// shelfMap.put("orderNo", "orderNo2");
// shelfMap.put("rfidIndex", "002");
// shelfMap.put("line", "L2");
//
// result.add(shelfMap);
// }
ResultBean resultBean= ResultBean.newOkResult("ok" );
resultBean.setData(result);
return resultBean;
}
@ApiOperation("根据rfid清空料架信息")
@PostMapping(value = "/clearRfid")
@ResponseBody
@AnonymousAccess
public ResultBean clearRfid(HttpServletRequest request ) {
String rfid = request.getParameter("rfid");
log.info("收到清空料架:/agv/clearRfid ,rfid=[" + rfid + "]");
if (ObjectUtil.isNotEmpty(rfid)) {
ShelfInfo shelfInfo = TaskShelfUtil.findShelfByRealRfid(rfid);
if (shelfInfo == null) {
log.info("clearRfid rfid[" + rfid + "]");
return ResultBean.newErrorResult(99, "smfcore.taskShelf.notExist", "未找到rfid[" + rfid + "]", new String[]{rfid});
}
boolean result = TaskShelfUtil.clearShelf(shelfInfo.getOrderNo(), rfid);
if (result) {
log.info("clearRfid orderNo[" + shelfInfo.getOrderNo() + "],rfid[" + rfid + "] OK");
}
return ResultBean.newOkResult("ok");
} else {
return ResultBean.newOkResult("未找到可清除的料架");
}
}
}
......@@ -98,7 +98,11 @@ public class TaskShelfUtil {
if (orderNo != null) {
Map<String, ShelfInfo> shelfMap = taskShelfMap.get(orderNo);
if (shelfMap != null) {
log.info("清理[" + orderNo + "]使用过的料架 成功");
for (ShelfInfo shelf :
shelfMap.values()) {
updateShelfLoc(shelf.getRealRfid(),"");
log.info("清理[" + orderNo + "]使用过的料架["+shelf.getRealRfid()+"] 成功");
}
taskShelfMap.remove(orderNo);
saveShelfMap(taskShelfMap,true);
return true;
......@@ -118,6 +122,7 @@ public class TaskShelfUtil {
String tempRfid = shelfInfo.tempRfid();
shelfMap.remove(tempRfid);
taskShelfMap.put(orderNo, shelfMap);
updateShelfLoc(shelfInfo.getRealRfid(),"");
log.info("清理[" + orderNo + "]使用的过料架[" + rfid + "]成功");
clearResult = true;
saveShelfMap(taskShelfMap,true);
......@@ -134,7 +139,7 @@ public class TaskShelfUtil {
/**
* 更新料架缓存信息
*/
private static void updateShelfInfo(ShelfInfo shelfInfo) {
public static void updateShelfInfo(ShelfInfo shelfInfo) {
String orderNo = shelfInfo.getOrderNo();
Map<String, ShelfInfo> shelfMap = taskShelfMap.getOrDefault(orderNo, new ConcurrentHashMap<>());
shelfMap.put(shelfInfo.tempRfid(), shelfInfo);
......@@ -486,7 +491,12 @@ public class TaskShelfUtil {
public static void updateShelfLoc(String rfid,String loc){
lineShelfLocMap.put(rfid,loc);
if(ObjectUtil.isEmpty(loc)){
lineShelfMap.remove(rfid);
}else {
lineShelfLocMap.put(rfid, loc);
}
saveLineShelfLocMap(lineShelfLocMap);
}
......@@ -500,20 +510,44 @@ public class TaskShelfUtil {
}
public static ShelfLoc getLastLoc(String barcode){
/**
* 扫码亮灯,获取库位号
* @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.setCodeLight(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.isCodeLight()){
lightEnd=false;
break;
}
}
}
shelf.setLightEnd(lightEnd);
ShelfLoc shelfLoc=shelf.getBarcodeLoc(barcode);
if(shelfLoc!=null&&(!shelfLoc.isEmpty())){
//获取料架位置
String line=getShelfLoc(shelfLoc.getRealRfid());
shelfLoc.setShelfLocation(line);
return shelfLoc;
updateShelfInfo(shelf);
log.info("标记料架[" + shelf.getRealRfid() + "]位置[" + shelfLoc.getLoc() + "]条码[" + shelfLoc.getBarcode() + "]为已扫码亮灯,料架是否亮灯完成["+lightEnd+"]");
return shelfLoc;
}
}
}
}
......
package com.neotel.smfcore.custom.gree20242;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.util.DataCache;
......@@ -14,20 +10,16 @@ import com.neotel.smfcore.core.shelf.util.TaskShelfUtil;
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.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.awt.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@Slf4j
......@@ -60,7 +52,7 @@ public class CodeLightController {
log.info("codeLed 未找到有效条码[" + code + "]");
return ResultBean.newErrorResult(99, "smfcore.error.barcode.invalid", "未找到有效条码");
}
ShelfLoc loc = TaskShelfUtil.getLastLoc(barcode.getBarcode());
ShelfLoc loc = TaskShelfUtil.codeLightGetLoc(barcode.getBarcode());
if (loc == null) {
return ResultBean.newErrorResult(99, "smfcore.light.error.noloc", "未找到亮灯位置");
}
......@@ -119,7 +111,7 @@ public class CodeLightController {
log.info("codeLed 未找到有效条码[" + code + "]");
return ResultBean.newErrorResult(99, "smfcore.error.barcode.invalid", "未找到有效条码");
}
ShelfLoc loc = TaskShelfUtil.getLastLoc(barcode.getBarcode());
ShelfLoc loc = TaskShelfUtil.codeLightGetLoc(barcode.getBarcode());
if (loc == null) {
return ResultBean.newErrorResult(99, "smfcore.light.error.noloc", "未找到亮灯位置");
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!