Commit e1872237 LN

增加移库功能

1 个父辈 26f35b58
...@@ -231,6 +231,9 @@ public class StoragePosController { ...@@ -231,6 +231,9 @@ public class StoragePosController {
String opUser = SecurityUtils.getCurrentUsername(); String opUser = SecurityUtils.getCurrentUsername();
log.info(opUser + "清理库位[" + storagePos.getPosName() + "]中的库存" + barcode.getBarcode()); log.info(opUser + "清理库位[" + storagePos.getPosName() + "]中的库存" + barcode.getBarcode());
taskService.addTaskToFinished(storagePos, null, opUser + "-clear"); taskService.addTaskToFinished(storagePos, null, opUser + "-clear");
//清理锁定
ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode());
} }
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -48,14 +48,14 @@ public class SpBoxPutInController { ...@@ -48,14 +48,14 @@ public class SpBoxPutInController {
public ResultBean getStationInfo(Integer type) { public ResultBean getStationInfo(Integer type) {
//默认是s1 工位 //默认是s1 工位
Station station = StationCacheUtil.getStation("s1"); Station station = StationCacheUtil.getStation("s1");
if (station == null){ if (station == null) {
return ResultBean.newErrorResult(-1,"","当前工位没有料箱信息"); return ResultBean.newErrorResult(-1, "", "当前工位没有料箱信息");
} }
String currentRfid = station.getCurrentRfid(); String currentRfid = station.getCurrentRfid();
if(ObjectUtil.isEmpty(currentRfid)){ if (ObjectUtil.isEmpty(currentRfid)) {
if(LuxsanSpApi.Debug){ if (LuxsanSpApi.Debug) {
currentRfid="CS0130"; currentRfid = "CS0130A";
} }
} }
// log.info("getStationInfo工位上"+currentRfid); // log.info("getStationInfo工位上"+currentRfid);
...@@ -138,4 +138,39 @@ public class SpBoxPutInController { ...@@ -138,4 +138,39 @@ public class SpBoxPutInController {
return ResultBean.newOkResult("OK"); return ResultBean.newOkResult("OK");
} }
//以料格为维度,一个料格
@ApiOperation("移库")
@RequestMapping("/moveBoxPos")
@AnonymousAccess
public ResultBean moveBoxPos(@RequestBody Map<String, String> paramMap) throws Exception {
try {
String boxBarcode = paramMap.get("boxBarcode").trim();
String targetPosName = paramMap.get("targetPos").trim();
log.info("moveBoxPos , 参数:箱子号=" + boxBarcode + ", 目标库位号=" + targetPosName);
//解析料箱信息
Barcode barcode = barcodeManager.findByBarcode(boxBarcode);
if (boxBarcode == null) {
throw new Exception("不是有效的料箱条码");
}
StoragePos targetPos = storagePosManager.getByPosName(targetPosName);
if (targetPos == null) {
log.info("moveBoxPos , 参数:箱子号=" + boxBarcode + ", 目标库位号=" + targetPosName + ",未找到目标库位");
throw new Exception("未找到目标库位");
}
String result = SpBoxUtil.movePos(barcode, targetPos);
if (ObjectUtil.isEmpty(result)) {
return ResultBean.newOkResult("OK");
} else {
return ResultBean.newErrorResult(-1, "", result);
}
} catch (Exception exception) {
return ResultBean.newErrorResult(-1, "", exception.getMessage());
}
}
} }
...@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.bean.ReelLockPosInfo; import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import com.neotel.smfcore.common.utils.ReelLockPosUtil; import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
...@@ -292,6 +293,70 @@ public class SpBoxUtil { ...@@ -292,6 +293,70 @@ public class SpBoxUtil {
} }
public static synchronized String movePos(Barcode barcode, StoragePos targetPos) throws Exception {
StoragePos pos = storagePosManager.getByBarcode(barcode.getBarcode());
if (pos != null) {
//如果还在库位中,不能移库
if (barcode.getStatus() == BARCODE_STATUS.IN_STORE) {
log.info("moveBoxPos , 参数:箱子号=" + barcode.getBarcode() + ", 目标库位号=" + targetPos.getPosName() + ",箱子还在库位[" + pos.getPosName() + "]中,无法移库");
throw new Exception("箱子[" + barcode.getBarcode() + "]还在库位[" + pos.getPosName() + "]中,无法移库");
}
}
//清空原来的库位,新库位中增加信息
if (targetPos.getBarcode() != null || targetPos.isUsed()) {
log.info("moveBoxPos , 参数:箱子号=" + barcode.getBarcode() + ", 目标库位号=" + targetPos.getPosName() + ",目标库位不为空");
throw new Exception("目标库位不为空");
}
if (ReelLockPosUtil.posIsLock(targetPos.getPosName())) {
log.info("moveBoxPos , 参数:箱子号=" + barcode.getBarcode() + ", 目标库位号=" + targetPos.getPosName() + ",已被锁定");
throw new Exception("目标库位已被锁定");
}
if(pos!=null){
log.info("料箱[" + barcode.getBarcode() + "]从库位[" + pos.getPosName() + "]中清空信息");
pos.setBarcode(null);
pos.setUsed(false);
storagePosManager.save(pos);
}
//从原有库位清空
log.info("料箱[" + barcode.getBarcode() + "]信息移入库位[" + targetPos.getPosName() + "]中");
targetPos.setBarcode(barcode);
targetPos.setUsed(true);
storagePosManager.save(targetPos);
barcode.setPosName(targetPos.getPosName());
barcode.setStoragePosName(targetPos.getPosName());
List<String> cidList = new ArrayList<>();
List<Storage> storageList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) {
if (!storage.isVirtual()) {
storageList.add(storage);
cidList.add(storage.getCid());
}
}
//3.锁定库位
Storage storage = dataCache.getStorageById(targetPos.getStorageId());
ReelLockPosInfo reelLocInfo = new ReelLockPosInfo();
reelLocInfo.setBarcode(barcode.getBarcode());
reelLocInfo.setCid(storage.getCid());
reelLocInfo.setLockPosName(targetPos.getPosName());
reelLocInfo.setLockPosId(targetPos.getId());
reelLocInfo = ReelLockPosUtil.addReelLockPosInfo(reelLocInfo, cidList);
if (reelLocInfo == null) {
log.info("[" + barcode.getBarcode() + "]库位锁定失败,暂停入库");
return "锁定失败";
}
return "";
}
public static int GetBoxSubCount(String boxStr) { public static int GetBoxSubCount(String boxStr) {
//返回格口数量 //返回格口数量
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!