Commit d5b8a08d zshaohui

1.查询库位是否有料或物料是否在库位中

2.获取库位时,已经锁定了库位,返回ng
3.修改锁定库位工具类
1 个父辈 ec308d19
......@@ -37,6 +37,18 @@ public class ReelLockPosUtil {
}
}
private static ReelLockPosInfo getFromMap(String barcode){
return reelLocKPosMap.get(barcode.replace(".","-"));
}
private static void removeFromMap(String barcode){
reelLocKPosMap.remove(barcode.replace(".","-"));
}
private static void putToMap(String barcode,ReelLockPosInfo reelLockPosInfo){
reelLocKPosMap.put(barcode.replace(".","-"),reelLockPosInfo);
}
/**
* 添加条码锁定库位信息
*
......@@ -44,7 +56,8 @@ public class ReelLockPosUtil {
*/
public static synchronized ReelLockPosInfo addReelLockPosInfo(ReelLockPosInfo reelLockPosInfo , List<String> cidList) {
log.info("为[" + reelLockPosInfo.getBarcode() + "]锁定库位[" + reelLockPosInfo.getLockPosName() + "]");
ReelLockPosInfo oldLocInfo = reelLocKPosMap.get(reelLockPosInfo.getBarcode());
//ReelLockPosInfo oldLocInfo = reelLocKPosMap.get(reelLockPosInfo.getBarcode());
ReelLockPosInfo oldLocInfo = getFromMap(reelLockPosInfo.getBarcode());
if (oldLocInfo != null && oldLocInfo.getLockPosName() != null) {
if(cidList.contains(oldLocInfo.getCid())){
log.info("[" + oldLocInfo.getBarcode() + "]已有锁定库位[" + oldLocInfo.getLockPosName() + "],返回之前锁定的库位");
......@@ -52,7 +65,8 @@ public class ReelLockPosUtil {
}else{
//锁定库位不在cid列表中
log.info("[" + oldLocInfo.getBarcode() + "]已有锁定库位[" + oldLocInfo.getLockPosName() + "],Cid["+oldLocInfo.getCid()+"]不在["+String.join(",",cidList)+"]中,清理原有锁定库位");
reelLocKPosMap.remove(reelLockPosInfo.getBarcode());
//reelLocKPosMap.remove(reelLockPosInfo.getBarcode());
removeFromMap(reelLockPosInfo.getBarcode());
}
}
for (ReelLockPosInfo locInfo : reelLocKPosMap.values()) {
......@@ -61,7 +75,8 @@ public class ReelLockPosUtil {
return null;
}
}
reelLocKPosMap.put(reelLockPosInfo.getBarcode(), reelLockPosInfo);
//reelLocKPosMap.put(reelLockPosInfo.getBarcode(), reelLockPosInfo);
putToMap(reelLockPosInfo.getBarcode(), reelLockPosInfo);
dataCache.updateCache(REEL_LOCK_POS_MAP_KEY, reelLocKPosMap);
return reelLockPosInfo;
}
......@@ -69,6 +84,7 @@ public class ReelLockPosUtil {
public static ReelLockPosInfo getLockPosInfoByCode(String barcode) {
if (org.apache.logging.log4j.util.Strings.isNotBlank(barcode)) {
barcode = barcode.replace(".","-");
for (ReelLockPosInfo reelLockPosInfo : reelLocKPosMap.values()) {
String lockBarcode = reelLockPosInfo.getBarcode();
......@@ -88,7 +104,8 @@ public class ReelLockPosUtil {
* 清理条码锁定库位信息
*/
public static void removeReelLockPosInfo(String barcode) {
reelLocKPosMap.remove(barcode);
//reelLocKPosMap.remove(barcode);
removeFromMap(barcode);
dataCache.updateCache(REEL_LOCK_POS_MAP_KEY, reelLocKPosMap);
}
......@@ -99,7 +116,8 @@ public class ReelLockPosUtil {
* @return
*/
public static String getReelLockPosId(String barcode) {
ReelLockPosInfo lockPosInfo = reelLocKPosMap.get(barcode);
//ReelLockPosInfo lockPosInfo = reelLocKPosMap.get(barcode);
ReelLockPosInfo lockPosInfo = getFromMap(barcode);
if (lockPosInfo != null) {
return lockPosInfo.getLockPosId();
}
......
......@@ -518,4 +518,42 @@ public class DeviceController {
return outTaskCount;
}
@ApiOperation("查询库位是否有料或物料是否在库位中")
@RequestMapping(value = "/service/store/posQuery")
@ResponseBody
@AnonymousAccess
public ResultBean queryPos(HttpServletRequest request) {
String posName = request.getParameter("posName");
String barcode = request.getParameter("barcode");
//参数:发送posName 或 barcode
//返回code=0,有料或在库位中,data中返回 posName,barcode,plateW,plateH
//返回code=101: 未找到库位号
//返回code=102:条码未找到库位
//返回code=100:库位中无料
StoragePos pos = null;
if (ObjectUtil.isNotEmpty(posName)) {
//查询库位中是否有料
pos = storagePosManager.getByPosName(posName);
if (pos == null) {
return ResultBean.newErrorResult(101, "smfcore.queryPos.cannotFind", "cannot find posName ["+posName+"]", new String[]{posName});
} else if (pos.getBarcode() == null) {
return ResultBean.newErrorResult(100, "smfcore.queryPos.posIsEmpty", "["+posName+"] is empty", new String[]{posName});
}
} else if (ObjectUtil.isNotEmpty(barcode)) {
pos = storagePosManager.getByBarcode(barcode);
if (pos == null) {
return ResultBean.newErrorResult(102, "smfcore.queryPos.cannotFindBarcode", "cannot find barcode ["+barcode+"] In storage", new String[]{barcode});
}
}else{
return ResultBean.newErrorResult(101, "smfcore.queryPos.cannotFind", "cannot find posName ["+posName+"]", new String[]{posName});
}
Map<String, String> data = new HashMap<>();
data.put("posName", pos.getPosName());
data.put("barcode", pos.getBarcode().getBarcode());
data.put("plateW", pos.getBarcode().getPlateSize() + "");
data.put("plateH", pos.getBarcode().getHeight() + "");
return ResultBean.newOkResult(data);
}
}
......@@ -624,6 +624,7 @@ public class TaskService {
Barcode posBarcode = pos.getBarcode();
if (posBarcode == null) {
log.info("条码[" + barcode.getBarcode() + "]已锁定库位[" + pos.getPosName() + "],返回锁定中的库位");
throw new ValidateException("smfcore.error.barcode.locked", "库位[{0}]已被锁定",new String[]{pos.getPosName()});
} else {
log.info("条码[" + barcode.getBarcode() + "]已锁定库位[" + pos.getPosName() + "]中已有物料[" + posBarcode.getBarcode() + "],重新查找库位");
pos = null;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!