Commit e9f6661c zshaohui

1.扫码入库

2.扫码出库
3.呼叫空箱
1 个父辈 20f70078
......@@ -39,10 +39,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* 外仓操作
......@@ -74,7 +73,7 @@ public class WarehouseController {
private DataCache dataCache;
@ApiOperation("选择物料,呼叫空箱")
@ApiOperation("选择物料")
@RequestMapping("/chooseReel")
@AnonymousAccess
public ResultBean chooseReel(@RequestBody Map<String, String> paramMap) {
......@@ -96,6 +95,43 @@ public class WarehouseController {
return ResultBean.newOkResult("");
}
@ApiOperation("呼叫空箱")
@RequestMapping("/callEmptyBox")
@AnonymousAccess
public ResultBean callEmptyBox(@RequestBody Map<String, String> paramMap) {
String size = paramMap.get("size"); //尺寸
String name = paramMap.get("name"); //工位名称
int platsize = getPlatsizeOrHeight(size, 0);
//按料箱的amount数量进行排序
List<Barcode> boxBarcodes = new ArrayList<>();
List<StoragePos> notEmptyStoragePos = storagePosManager.findNotEmpty();
for (StoragePos storagePos : notEmptyStoragePos) {
Barcode boxBarcode = storagePos.getBarcode();
if (platsize == 7) {
if (boxBarcode.getBarcode().startsWith("CS")) {
boxBarcodes.add(boxBarcode);
}
} else if (platsize == 13) {
if (boxBarcode.getBarcode().startsWith("CM")) {
boxBarcodes.add(boxBarcode);
}
} else if (platsize == 15) {
if (boxBarcode.getBarcode().startsWith("CB")) {
boxBarcodes.add(boxBarcode);
}
}
}
if (boxBarcodes.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "未找到可用料箱", new String[]{});
}
boxBarcodes = boxBarcodes.stream().sorted(Comparator.comparing(Barcode::getAmount).reversed()).collect(Collectors.toList());
Barcode boxBarcode = boxBarcodes.get(0);
StoragePos pos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
generateTask(dataCache.getStorageById(pos.getStorageId()), boxBarcode, pos, OP.CHECKOUT, OP_STATUS.WAIT.name(), name);
return ResultBean.newOkResult("");
}
@ApiOperation("获取工位详情")
@RequestMapping("/getStation")
......@@ -104,7 +140,7 @@ public class WarehouseController {
String name = paramMap.get("name");
Station station = StationCacheUtil.getStation(name);
if (station == null) {
return ResultBean.newErrorResult(-1,"","{}工位不存在",new String[]{name});
return ResultBean.newErrorResult(-1, "", "{}工位不存在", new String[]{name});
}
return ResultBean.newOkResult(station);
}
......@@ -141,8 +177,7 @@ public class WarehouseController {
} else if (!currentRfid.startsWith(barcode.getBarcode())) {
throw new ValidateException("", "{}与{}不一致", new String[]{code, currentRfid});
}
String boxCode = barcode.getBarcode();
station.setLastScanBoxCode(boxCode);
station.setLastScanBoxCode(code);
StationCacheUtil.updateStation(station);
barcodeManager.save(barcode);
} else {
......@@ -151,18 +186,22 @@ public class WarehouseController {
if (Strings.isBlank(lastScanBoxCode)) {
//提示要先扫料箱
return ResultBean.newErrorResult(-1, "", "请先扫描料箱,再扫描条码");
} else {
} /*else {
if (StringUtils.isBlank(currentRfid)) {
throw new ValidateException("", "{}不存在", new String[]{currentRfid});
} else if (!currentRfid.startsWith(barcode.getBarcode())) {
throw new ValidateException("", "{}与{}不一致", new String[]{code, currentRfid});
}
return ResultBean.newErrorResult(-1,"", "{}与{}不一致", new String[]{code, currentRfid});
}
}*/
StationCacheUtil.saveReelToBoxCode(station);
finishTask(barcodeManager.findByBarcode(lastScanBoxCode), 1, null, barcode, 1);
String boxBarcode = lastScanBoxCode.substring(0, code.indexOf("-"));
Barcode pidBarcode = barcodeManager.findByBarcode(boxBarcode);
barcode.setHostBarcodeId(pidBarcode.getId());
barcode.setPosName(lastScanBoxCode);
finishTask(pidBarcode, 1, null, barcode, 1);
}
}
return ResultBean.newOkResult("");
return ResultBean.newOkResult(station.getLastScanBoxCode());
}
......@@ -177,7 +216,7 @@ public class WarehouseController {
//校验是否存在
Barcode barcode = barcodeManager.findByBarcode(code);
if (barcode == null) {
throw new ValidateException("", "{}不存在", new String[]{code});
return ResultBean.newErrorResult(-1, "", barcode + "不存在", null);
}
Station station = StationCacheUtil.getStation(name);
if (station == null) {
......@@ -254,18 +293,35 @@ public class WarehouseController {
throw new ValidateException("", "[" + barcode.getBarcode() + "]库位[" + reelLocInfo.getLockPosName() + "]已被锁定,暂停入库", null);
}
}
//开始入库任务
DataLog task = new DataLog(dataCache.getStorageById(pos.getStorageId()), barcode, pos);
task.setType(OP.PUT_IN);
task.setStatus(OP_STATUS.WAIT.name());
taskService.updateQueueTask(task);
//生成任务
generateTask(dataCache.getStorageById(pos.getStorageId()), barcode, pos, OP.PUT_IN, OP_STATUS.WAIT.name(), null);
//同时清空lastScanBoxCode
station.setLastScanBoxCode(null);
StationCacheUtil.updateStation(station);
StationCacheUtil.saveBoxToBoxCode(station);
return ResultBean.newOkResult("");
}
@ApiOperation("扫码出库")
@RequestMapping("/finishBoxOut")
@AnonymousAccess
public ResultBean finishBoxOut(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("barcode");
Barcode barcode = barcodeManager.findByBarcode(code);
int amount = barcode.getAmount();
barcode.setAmount(amount - 1);
Barcode pidBarcode = barcodeManager.get(barcode.getHostBarcodeId());
finishTask(pidBarcode, OP.CHECKOUT, null, barcode, 1);
return ResultBean.newOkResult("");
}
private void generateTask(Storage storage, Barcode barcode, StoragePos pos, int type, String status, String loc) {
//开始入库任务
DataLog task = new DataLog(storage, barcode, pos);
task.setType(type);
task.setStatus(status);
task.setLoc(loc);
taskService.updateQueueTask(task);
}
/**
* 完成出入库任务
......@@ -280,6 +336,14 @@ public class WarehouseController {
//更新barcode缓存
pidBarcode.UpdateSubCode(subBarcode);
//更新pidBarcode的数量
int amount = pidBarcode.getAmount();
if (opType == OP.PUT_IN) {
pidBarcode.setAmount(amount + opQty);
} else {
pidBarcode.setAmount(amount - 1);
}
if (opType == OP.CHECKOUT && subBarcode.getAmount() <= 0) {
//数量为0直接删除
barcodeManager.delete(subBarcode);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!