Commit 1f4d9263 zshaohui

1.上架和下架的时候,如果料架有异常料架,提示不能操作

1 个父辈 fe89450a
...@@ -25,6 +25,8 @@ import com.neotel.smfcore.hikvision_mobile.bean.response.ApiResponse; ...@@ -25,6 +25,8 @@ import com.neotel.smfcore.hikvision_mobile.bean.response.ApiResponse;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
...@@ -101,6 +103,11 @@ public class HikVisionController { ...@@ -101,6 +103,11 @@ public class HikVisionController {
return ApiResponse.apiResponse(reqCode, ResponseCode.REQUEST_ERROR.getCode(), "", "smfcore.shelfNotExist", new String[]{shelfCode}, "{0}对应的料架不存在"); return ApiResponse.apiResponse(reqCode, ResponseCode.REQUEST_ERROR.getCode(), "", "smfcore.shelfNotExist", new String[]{shelfCode}, "{0}对应的料架不存在");
} }
boolean hasErrorPos = hasErrorPos(storage.getCid());
if (hasErrorPos){
return ApiResponse.apiResponse(reqCode,ResponseCode.REQUEST_ERROR.getCode(),"","",new String[]{},"当前货架状态异常,无法发起上架任务");
}
//判断是否正在执行 //判断是否正在执行
Collection<DataLog> queueTasks = taskService.getQueueTasks(); Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) { for (DataLog queueTask : queueTasks) {
...@@ -207,17 +214,24 @@ public class HikVisionController { ...@@ -207,17 +214,24 @@ public class HikVisionController {
} }
} }
//判断料架是否存在
Storage storage = dataCache.getStorageByName(info.getShelfCode());
if (storage == null) {
return ApiResponse.apiResponse(reqCode, ResponseCode.REQUEST_ERROR.getCode(), "", "smfcore.shelfNotExist", new String[]{info.getShelfCode()}, "{0}对应的料架不存在");
}
boolean hasErrorPos = hasErrorPos(storage.getCid());
if (hasErrorPos){
return ApiResponse.apiResponse(reqCode,ResponseCode.REQUEST_ERROR.getCode(),"","",new String[]{},"当前物料唯一码货位异常,无法发起下架任务");
}
//判断是否已经生成任务 //判断是否已经生成任务
int count = dataLogManager.countByReqCode(reqCode); int count = dataLogManager.countByReqCode(reqCode);
if (count > 0) { if (count > 0) {
return ApiResponse.apiResponse(reqCode, ResponseCode.PROCESSED.getCode(), "", "smfcore.valueAlreadyExist", new String[]{"请求号", reqCode}, "{0}[{1}]已存在"); return ApiResponse.apiResponse(reqCode, ResponseCode.PROCESSED.getCode(), "", "smfcore.valueAlreadyExist", new String[]{"请求号", reqCode}, "{0}[{1}]已存在");
} }
//判断料架是否存在
Storage storage = dataCache.getStorageByName(info.getShelfCode());
if (storage == null) {
return ApiResponse.apiResponse(reqCode, ResponseCode.REQUEST_ERROR.getCode(), "", "smfcore.shelfNotExist", new String[]{info.getShelfCode()}, "{0}对应的料架不存在");
}
//判断库位中信息是否存在料盘 //判断库位中信息是否存在料盘
StoragePos pos = storagePosManager.getByBarcode(info.getUniqueCode()); StoragePos pos = storagePosManager.getByBarcode(info.getUniqueCode());
if (pos == null) { if (pos == null) {
...@@ -231,7 +245,7 @@ public class HikVisionController { ...@@ -231,7 +245,7 @@ public class HikVisionController {
if (barcode == null) { if (barcode == null) {
return ApiResponse.apiResponse(reqCode, ResponseCode.REQUEST_ERROR.getCode(), "", "smfcore.error.barcode.invalid", new String[]{info.getUniqueCode()}, "{0}不是有效的条码"); return ApiResponse.apiResponse(reqCode, ResponseCode.REQUEST_ERROR.getCode(), "", "smfcore.error.barcode.invalid", new String[]{info.getUniqueCode()}, "{0}不是有效的条码");
} }
/*
//判断是否有正在下架的任务 //判断是否有正在下架的任务
for (DataLog dataLog : taskService.getAllTasks()) { for (DataLog dataLog : taskService.getAllTasks()) {
if (!dataLog.isFinished()){ if (!dataLog.isFinished()){
...@@ -239,7 +253,7 @@ public class HikVisionController { ...@@ -239,7 +253,7 @@ public class HikVisionController {
return ApiResponse.apiResponse(reqCode, ResponseCode.REQUEST_ERROR.getCode(), "", "", new String[]{info.getShelfCode()}, info.getShelfCode() + "有正在执行中的下架任务,不可发起新的下架任务"); return ApiResponse.apiResponse(reqCode, ResponseCode.REQUEST_ERROR.getCode(), "", "", new String[]{info.getShelfCode()}, info.getShelfCode() + "有正在执行中的下架任务,不可发起新的下架任务");
} }
} }
} }*/
DataLog dataLog = new DataLog(storage, barcode, pos); DataLog dataLog = new DataLog(storage, barcode, pos);
...@@ -497,21 +511,39 @@ public class HikVisionController { ...@@ -497,21 +511,39 @@ public class HikVisionController {
} }
@GetMapping("/test") private boolean hasErrorPos(String cid) {
@AnonymousAccess List<List<String>> deviceData = DevicesStatusUtil.getDeviceData(cid);
public void test(String id){ if (deviceData != null && deviceData.size() == 2) {
Collection<DataLog> queueTasks = taskService.getQueueTasks(); List<String> hasReelPosErrorList = deviceData.get(0);
DataLog task = null; if (hasReelPosErrorList != null && !hasReelPosErrorList.isEmpty()) {
for (DataLog queueTask : queueTasks) { Query query = new Query(Criteria.where("posName").in(hasReelPosErrorList.toArray()));
if (id.equals(queueTask.getId())){ List<StoragePos> posList = storagePosManager.findByQuery(query);
task = queueTask; for (StoragePos pos : posList) {
break; if (!pos.isEnabled()) {
continue;
}
if (pos.isUsed()) {
continue;
}
return true;
}
}
List<String> noReelPosErrorList = deviceData.get(1);
if (noReelPosErrorList != null && !noReelPosErrorList.isEmpty()) {
Query query = new Query(Criteria.where("posName").in(hasReelPosErrorList.toArray()));
List<StoragePos> posList = storagePosManager.findByQuery(query);
for (StoragePos pos : posList) {
if (!pos.isEnabled()) {
continue;
}
if (!pos.isUsed()) {
continue;
}
return true;
}
} }
} }
if (task != null){ return false;
task.setStatus(OP_STATUS.FINISHED.name());
taskService.moveTaskToFinished(task);
taskService.updateFinishedTask(task);
}
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!