Commit bc2cc4c3 hc

fix:手动GR完成装箱并入库手动指定库位

1 个父辈 a64f9515
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller.manual;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
......@@ -28,7 +30,6 @@ import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BinCacheUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -199,15 +200,23 @@ public class ManualGrPutInController {
@ApiOperation("完成装箱并入库")
@RequestMapping("/boxToPos")
@AnonymousAccess
public synchronized ResultBean boxToPos(String boxStr) {
public synchronized ResultBean boxToPos(String boxStr, String posName) {
if (StringUtils.isEmpty(boxStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料箱信息"});
}
if (StringUtils.isEmpty(posName)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"库位信息"});
}
//1.判断有没有正在执行的任务
List<DataLog> taskList = taskService.getAllTasks();
for (DataLog dataLog : taskList) {
if (posName.equals(dataLog.getPosName())) {
if (!dataLog.isFinished() && !dataLog.isCancel()) {
return ResultBean.newErrorResult(-3, "", "当前库位有任务正在执行");
}
}
if (boxStr.startsWith(dataLog.getBarcode())) {
if (!dataLog.isFinished() && !dataLog.isCancel()) {
if (dataLog.isPutInTask()) {
......@@ -220,19 +229,36 @@ public class ManualGrPutInController {
}
}
}
//2.获取空库位
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
StoragePos pos = BoxHandleUtil.locOnePos(boxBarcode);
if (pos == null) {
return ResultBean.newErrorResult(-1, "", boxStr + "未找到可用库位");
//2.判断库位是否存在
StoragePos newPos = storagePosManager.getByPosName(posName);
if (newPos == null) {
return ResultBean.newErrorResult(-2, "smfcore.error.pos.notExist", "[{0}]库位不存在", new String[]{posName});
}
//3.库位是否存了料箱
if (ObjectUtil.isNotNull(newPos.getBarcode())
&& !newPos.getBarcode().getBarcode().equals(boxStr)) {
return ResultBean.newErrorResult(-4, "smfcore.error.pos.hasReel", "库位[{0}]中已有物料,无法入库", new String[]{posName});
}
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
//4.生成入库任务
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog dataLog = taskService.addPutInTaskToExecute(storage, boxBarcode, pos, TaskCurrentLoc.Manual_DischargeHole);
taskService.addTaskToFinished(newPos, boxBarcode, SecurityUtils.getLoginUsername());
return ResultBean.newOkResult("库位为:"+dataLog.getPosName());
//将料箱原来的库位置空
String oldPosName = boxBarcode.getPosName();
StoragePos oldPos = null;
if (oldPosName != null) {
oldPos = storagePosManager.getByPosName(oldPosName);
}
if (oldPos != null) {
// 原先已被存储在oldPos
oldPos.setBarcode(null);
oldPos.setUsed(false);
storagePosManager.save(oldPos);
}
return ResultBean.newOkResult("ok");
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!