no message

main
HUOJIN\92525 2024-08-27 10:26:23 +08:00
parent 11cd78db71
commit 8b33179db6
7 changed files with 64 additions and 57 deletions

View File

@ -18,6 +18,7 @@ package com.youchain.basicdata.service.impl;
import com.youchain.Netty.NettyUtils;
import com.youchain.basicdata.domain.Box;
import com.youchain.exception.BadRequestException;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
import com.youchain.basicdata.repository.BoxRepository;
@ -113,7 +114,7 @@ public class BoxServiceImpl implements BoxService {
for (Box box : boxList) {
sbf.append(box.getLampCode()).append(",").toString();
}
throw new RuntimeException("按钮盒编号" + sbf.deleteCharAt(sbf.length() - 1) + "已绑定!");
throw new BadRequestException("按钮盒编号" + sbf.deleteCharAt(sbf.length() - 1) + "已绑定!");
}
}
Box box = boxRepository.findById(resources.getId()).orElseGet(Box::new);

View File

@ -32,6 +32,7 @@ import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.repository.*;
import com.youchain.businessdata.service.*;
import com.youchain.businessdata.service.dto.TaskDto;
import com.youchain.exception.BadRequestException;
import com.youchain.modules.mnt.websocket.MsgType;
import com.youchain.modules.mnt.websocket.SocketMsg;
import com.youchain.modules.mnt.websocket.WebSocketServer;
@ -226,7 +227,7 @@ public class StockServiceImpl implements StockService {
Stock stock = validateStock(containerCode);//验证容器
Point point = validateSrcPoint(position);//验证点位
if (!isRestrictedArea(point.getType())) {
throw new RuntimeException(point.getCode() + "点位不能入场!");
throw new BadRequestException(point.getCode() + "点位不能入场!");
}
validateAgvContainerIn(UrlApi.containerIn(), containerInJson(containerCode, position));//验证AGV返回信息
@ -313,7 +314,7 @@ public class StockServiceImpl implements StockService {
private void validateBoxNumbers(List<String> boxNumbers) {
if (boxNumbers.isEmpty()) {
throw new RuntimeException("请扫描箱号!");
throw new BadRequestException("请扫描箱号!");
}
}
@ -332,11 +333,11 @@ public class StockServiceImpl implements StockService {
barCodeVo.setOrderQty(parseQuantityString(map.get("Q")));
barCodeVos.add(barCodeVo);
} catch (Exception e) {
throw new RuntimeException("箱号格式错误!", e);
throw new BadRequestException("箱号格式错误!");
}
}
if (barCodeVos.isEmpty()) {
throw new RuntimeException("请扫描箱号!");
throw new BadRequestException("请扫描箱号!");
}
return barCodeVos;
}
@ -345,28 +346,28 @@ public class StockServiceImpl implements StockService {
String firstItemCode = barCodeVos.iterator().next().getItemCode();
boolean allSame = barCodeVos.stream().allMatch(vo -> vo.getItemCode().equals(firstItemCode));
if (!allSame) {
throw new RuntimeException("一个托盘只能放同一种物料!");
throw new BadRequestException("一个托盘只能放同一种物料!");
}
Set<String> barNumbers = barCodeVos.stream().map(BarCodeVo::getBoxNumber).collect(Collectors.toSet());
List<AsnDetail> asnDetails = asnDetailService.existsByboxNumber(barNumbers);
if (!asnDetails.isEmpty()) {
Set<String> newBarNumbers = asnDetails.stream().map(AsnDetail::getOrderNumber).collect(Collectors.toSet());
throw new RuntimeException("箱号已入库,请勿重复入库:" + newBarNumbers);
throw new BadRequestException("箱号已入库,请勿重复入库:" + newBarNumbers);
}
}
private void validateStockType(String stockType) {
if (!"托盘".equals(stockType)) {
throw new RuntimeException(stockType + "容器类型错误!");
throw new BadRequestException(stockType + "容器类型错误!");
}
}
private void validateSrcPointArea(Point srcPoint) {
String srcPointAreaName = srcPoint.getArea().getCode();
if (!isValidMCArea(srcPointAreaName)) {
throw new RuntimeException(srcPoint.getCode() + "为" + srcPointAreaName + "不能入库!");
throw new BadRequestException(srcPoint.getCode() + "为" + srcPointAreaName + "不能入库!");
}
}
@ -468,7 +469,7 @@ public class StockServiceImpl implements StockService {
if (matcher.find()) {
return Integer.parseInt(matcher.group());
} else {
throw new RuntimeException("数量格式错误!");
throw new BadRequestException("数量格式错误!");
}
}
@ -490,7 +491,7 @@ public class StockServiceImpl implements StockService {
public ReturnTaskVo scanStock(String stockCode) {
Task task = taskRepository.findBySrcStockCode(stockCode);
if (task == null) {
throw new RuntimeException("未找到" + stockCode + "托盘的翻包拣货任务!");
throw new BadRequestException("未找到" + stockCode + "托盘的翻包拣货任务!");
}
ReturnTaskVo returnTaskVo = new ReturnTaskVo();
returnTaskVo.setTaskId(task.getId());
@ -521,14 +522,14 @@ public class StockServiceImpl implements StockService {
if (pick.getStock() == null) {
List<Inventory> inventoryList = inventoryRepository.findByStock(dstStock.getId());
if (!inventoryList.isEmpty()) {
throw new RuntimeException(dstStock + "目标托盘已绑定其他出库单,请更换其它的托盘!");
throw new BadRequestException(dstStock + "目标托盘已绑定其他出库单,请更换其它的托盘!");
}
pick.setStock(dstStock);
pickRepository.save(pick);
} else {
Stock oldStock = pick.getStock();
if (!dstStockCode.equals(pick.getStock().getCode())) {
throw new RuntimeException(pick.getGdCode() + "工单只能放入同一个货架!" + "请放入" + oldStock.getCode() + "货架!");
throw new BadRequestException(pick.getGdCode() + "工单只能放入同一个货架!" + "请放入" + oldStock.getCode() + "货架!");
}
}
@ -567,7 +568,7 @@ public class StockServiceImpl implements StockService {
// 如果成品入库缓存区没有空车,则从入库区查询
emptyStockList = stockRepository.findByEnmptyStock(AreaNameDic.CPRKQ);
if (emptyStockList.isEmpty()) {
throw new RuntimeException("成品入库区没有空车,请稍后再试!");
throw new BadRequestException("成品入库区没有空车,请稍后再试!");
}
}
@ -575,7 +576,7 @@ public class StockServiceImpl implements StockService {
Point srcPoint = emptyStock.getPoint();
List<Point> endPointList = pointRepository.findByCode(null, BaseStatus.FREE, BaseStatus.BOX, AreaNameDic.CPXXQ, null, null);
if (endPointList.isEmpty()) {
throw new RuntimeException("成品下线区没有空闲点位,请稍后再试!");
throw new BadRequestException("成品下线区没有空闲点位,请稍后再试!");
}
Point endPoint = endPointList.get(0);
// 创建并下发任务
@ -595,11 +596,11 @@ public class StockServiceImpl implements StockService {
Point srcPoint = validateSrcPoint(transTask.getPointCode());//起点
Stock stock = stockRepository.fingByPointCode(srcPoint.getCode());
if (stock == null) {
throw new RuntimeException(srcPoint.getCode() + "点位没有货架!");
throw new BadRequestException(srcPoint.getCode() + "点位没有货架!");
}
List<Point> endPointList = pointRepository.findByCode(null, BaseStatus.FREE, BaseStatus.BOX, AreaNameDic.CPRKQ, null, null);
if (endPointList.isEmpty()) {
throw new RuntimeException("成品入库区没有空闲点位!");
throw new BadRequestException("成品入库区没有空闲点位!");
}
Point endPoint = endPointList.get(0);
AgvTask agvTask = new AgvTask(BizStatus.Cp_Off_Line, stock.getCode(), srcPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "RACK_MOVE");
@ -615,7 +616,7 @@ public class StockServiceImpl implements StockService {
Point srcPoint = validateSrcPoint(transTask.getPointCode());//起点
List<Point> pointList = pointRepository.findByCode(null, BaseStatus.FREE, BaseStatus.BOX, AreaNameDic.FXSXQ, null, null);
if (pointList.isEmpty()) {
throw new RuntimeException("返修上线区没有空闲点位!");
throw new BadRequestException("返修上线区没有空闲点位!");
}
Point endPoint = pointList.get(0);
AgvTask agvTask = new AgvTask(BizStatus.Fx_Off_Line, null, srcPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "ROLLER_MOVE");
@ -636,10 +637,10 @@ public class StockServiceImpl implements StockService {
@Transactional(rollbackFor = Exception.class)
public void callJlTask(Pick pick) {
if (pick.getStock() == null) {
throw new RuntimeException(pick.getGdCode() + "请翻包拣货!");
throw new BadRequestException(pick.getGdCode() + "请翻包拣货!");
}
if (pick.getCallPoint() == null) {
throw new RuntimeException(pick.getGdCode() + "工单没有叫料请求!");
throw new BadRequestException(pick.getGdCode() + "工单没有叫料请求!");
}
Point srcPoint = pick.getStock().getPoint();
Point endPoint = pick.getCallPoint();
@ -674,11 +675,11 @@ public class StockServiceImpl implements StockService {
private Task validateTask(Long taskId, String orderNumber) {
TaskDto taskDto = taskService.findById(taskId);
if (taskDto == null) {
throw new RuntimeException("未找到相应任务记录!");
throw new BadRequestException("未找到相应任务记录!");
}
Task task = taskService.toEntity(taskDto);//Dto转实体
if (!orderNumber.equals(task.getItemKey().getOrderNumber())) {
throw new RuntimeException("扫描的箱号与分配的箱号不一致!");
throw new BadRequestException("扫描的箱号与分配的箱号不一致!");
}
return task;
@ -692,17 +693,17 @@ public class StockServiceImpl implements StockService {
*/
private Stock validatedstStock(String dstStockCode) {
if (StringUtils.isEmpty(dstStockCode)) {
throw new RuntimeException("请扫描目标托盘号!");
throw new BadRequestException("请扫描目标托盘号!");
}
Stock dstStock = stockRepository.findByCode(dstStockCode, null);
if (dstStock == null) {
throw new RuntimeException(dstStockCode + "目标托盘不存在,请扫描正确的托盘号!");
throw new BadRequestException(dstStockCode + "目标托盘不存在,请扫描正确的托盘号!");
}
if (BaseStatus.USED.equals(dstStock.getStatus())) {
throw new RuntimeException(dstStockCode + "目标托盘已使用,请更换新的托盘!");
throw new BadRequestException(dstStockCode + "目标托盘已使用,请更换新的托盘!");
}
if (dstStock.getPoint() == null) {
throw new RuntimeException(dstStockCode + "目标托盘没有关联点位!");
throw new BadRequestException(dstStockCode + "目标托盘没有关联点位!");
}
return dstStock;
}
@ -770,7 +771,7 @@ public class StockServiceImpl implements StockService {
List<Point> endPointList = pointRepository.findByCode(null, BaseStatus.FREE, BaseStatus.STORAGE, areaCode, null, null);
if (endPointList.isEmpty()) {
throw new RuntimeException(areaCode + "没有空闲点位!");
throw new BadRequestException(areaCode + "没有空闲点位!");
}
Point endPoint = endPointList.get(0);
@ -784,7 +785,7 @@ public class StockServiceImpl implements StockService {
private Item validateItem(String itemCode) {
Item item = itemService.existItem(itemCode);
if (item == null) {
throw new RuntimeException("请扫描正确的物料!");
throw new BadRequestException("请扫描正确的物料!");
}
return item;
}
@ -792,21 +793,21 @@ public class StockServiceImpl implements StockService {
private Stock validateStock(String stockCode) {
Stock stock = findByCode(stockCode, null);
if (stock == null) {
throw new RuntimeException("请扫描正确的容器!");
throw new BadRequestException("请扫描正确的容器!");
}
return stock;
}
private void validateStockStatus(Stock stock) {
if (BaseStatus.USED.equals(stock.getStatus())) {
throw new RuntimeException("容器已使用,请更换新的容器!");
throw new BadRequestException("容器已使用,请更换新的容器!");
}
}
private Point validateSrcPoint(String pointCode) {
List<Point> pointList = pointRepository.findByCode(pointCode, null, null, null, null, null);
if (pointList.isEmpty()) {
throw new RuntimeException("请扫描正确的点位!");
throw new BadRequestException("请扫描正确的点位!");
}
return pointList.get(0);
}
@ -815,14 +816,14 @@ public class StockServiceImpl implements StockService {
List<Point> endPointList = pointRepository.findByCode(null, BaseStatus.FREE, BaseStatus.STORAGE, areaCode, null, null);
if (endPointList.isEmpty()) {
Area area = areaRepository.findByCode(areaCode);
throw new RuntimeException(area.getName() + "没有空闲点位!");
throw new BadRequestException(area.getName() + "没有空闲点位!");
}
return endPointList.get(0);
}
private void checkPointStatus(Point srcPoint) {
if (BaseStatus.USED.equals(srcPoint.getStatus())) {
throw new RuntimeException(srcPoint.getCode() + "点位已有任务,请勿重复操作!");
throw new BadRequestException(srcPoint.getCode() + "点位已有任务,请勿重复操作!");
}
}
@ -848,32 +849,32 @@ public class StockServiceImpl implements StockService {
private void validateAgvContainerIn(String url, String jsonObject) {
String resultJson = HttpPostUtil.sendPostReq(url, jsonObject);
if (StringUtils.isEmpty(resultJson)) {
throw new RuntimeException("AGV返回信息:容器入场接口调用失败!");
throw new BadRequestException("AGV返回信息:容器入场接口调用失败!");
}
JSONObject resultObject = JSON.parseObject(resultJson);
if (resultObject == null) {
throw new RuntimeException("AGV返回信息:容器入场接口数据返回为空!");
throw new BadRequestException("AGV返回信息:容器入场接口数据返回为空!");
}
String code = resultObject.getString("code");
String message = resultObject.getString("message");
if (!"0".equals(code)) {
throw new RuntimeException("AGV返回信息:容器入场接口调用失败!" + message);
throw new BadRequestException("AGV返回信息:容器入场接口调用失败!" + message);
}
}
private void validateAgvContainerOut(String url, String jsonObject) {
String resultJson = HttpPostUtil.sendPostReq(url, jsonObject);
if (StringUtils.isEmpty(resultJson)) {
throw new RuntimeException("AGV返回信息:容器出场接口调用失败!");
throw new BadRequestException("AGV返回信息:容器出场接口调用失败!");
}
JSONObject resultObject = JSON.parseObject(resultJson);
if (resultObject == null) {
throw new RuntimeException("AGV返回信息:容器出场接口数据返回为空!");
throw new BadRequestException("AGV返回信息:容器出场接口数据返回为空!");
}
String code = resultObject.getString("code");
String message = resultObject.getString("message");
if (!"0".equals(code)) {
throw new RuntimeException("AGV返回信息:容器出场接口调用失败!" + message);
throw new BadRequestException("AGV返回信息:容器出场接口调用失败!" + message);
}
}

View File

@ -27,6 +27,7 @@ import com.youchain.businessdata.repository.InventoryRepository;
import com.youchain.businessdata.repository.PickRepository;
import com.youchain.businessdata.repository.TaskRepository;
import com.youchain.businessdata.service.*;
import com.youchain.exception.BadRequestException;
import com.youchain.modules.quartz.utils.TimeNumberUtils;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
@ -356,17 +357,17 @@ public class AgvTaskServiceImpl implements AgvTaskService {
private void sendAgvTask(AgvTask agvTask, String json) {
String resultJson = HttpPostUtil.sendPostReq(UrlApi.submitMission(), json);
if (StringUtils.isEmpty(resultJson)) {
throw new RuntimeException("AGV返回信息:下发任务接口调用失败!");
throw new BadRequestException("AGV返回信息:下发任务接口调用失败!");
}
JSONObject resulObject = JSON.parseObject(resultJson);
if (resulObject == null) {
throw new RuntimeException("AGV返回信息:下发任务接口返回为空!");
throw new BadRequestException("AGV返回信息:下发任务接口返回为空!");
}
String code = resulObject.getString("code");
String message = resulObject.getString("message");
if (!"0".equals(code)) {
throw new RuntimeException("AGV返回信息:" + message);
throw new BadRequestException("AGV返回信息:" + message);
} else {
agvTask.setJobForce(agvTask.getId().toString());//任务组
agvTask.setJobForceAsc((1));
@ -429,7 +430,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
String endAreaName = endPoint.getArea().getCode();
Stock stock = stockRepository.findByCode(containerCode, null);
if (stock == null) {
throw new RuntimeException(containerCode + "容器不存在! 请维护");
throw new BadRequestException(containerCode + "容器不存在! 请维护");
}
List<Task> taskList = taskService.getAgvTaskList(agvTask.getId());
switch (endAreaName) {
@ -458,7 +459,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
String endAreaName = endPoint.getArea().getCode();
Stock stock = stockRepository.findByCode(containerCode, null);
if (stock == null) {
throw new RuntimeException(containerCode + "容器不存在! 请维护");
throw new BadRequestException(containerCode + "容器不存在! 请维护");
}
List<Task> taskList = taskService.getAgvTaskList(agvTask.getId());
switch (endAreaName) {
@ -477,7 +478,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
private synchronized void handleResendTask(AgvTask agvTask) {
List<AgvTask> repeatList = agvTaskRepository.findRepeat(agvTask.getStockCode());
if (!repeatList.isEmpty()) {
throw new RuntimeException("任务已重新生成,请勿重复操作! ");
throw new BadRequestException("任务已重新生成,请勿重复操作! ");
}
AgvTask newAgvTask = new AgvTask();
newAgvTask.setStockCode(agvTask.getStockCode());
@ -510,7 +511,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
sendAgvTaskGTImpl(newAgvTask);
break;
default:
throw new RuntimeException("任务类型不支持: " + agvTask.getJobType());
throw new BadRequestException("任务类型不支持: " + agvTask.getJobType());
}
@ -639,7 +640,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
String endAreaName = endPoint.getArea().getCode();
Stock stock = stockRepository.findByCode(containerCode, null);
if (stock == null) {
throw new RuntimeException(containerCode + "容器不存在! 请维护");
throw new BadRequestException(containerCode + "容器不存在! 请维护");
}
switch (endAreaName) {
case AreaNameDic.XJQ:

View File

@ -28,6 +28,7 @@ import com.youchain.businessdata.repository.PickDetailRepository;
import com.youchain.businessdata.repository.TaskRepository;
import com.youchain.businessdata.service.AgvTaskService;
import com.youchain.config.thread.ThreadPoolExecutorUtil;
import com.youchain.exception.BadRequestException;
import com.youchain.modules.system.service.DeptService;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
@ -221,13 +222,13 @@ public class PickServiceImpl implements PickService {
try {
batchCreateOrUpdate.batchInsert(createPicks);
} catch (Exception e) {
throw new RuntimeException("出库单创建失败!", e);
throw new BadRequestException("出库单创建失败!"+e);
}
try {
batchCreateOrUpdate.batchInsert(createPickDetails);
} catch (Exception e) {
throw new RuntimeException("出库单明细创建失败!", e);
throw new BadRequestException("出库单明细创建失败!"+e);
}

View File

@ -21,6 +21,7 @@ import com.youchain.basicdata.repository.StockRepository;
import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.repository.*;
import com.youchain.businessdata.service.InventoryLogService;
import com.youchain.exception.BadRequestException;
import com.youchain.modules.system.domain.Dept;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
@ -182,12 +183,12 @@ public class TaskServiceImpl implements TaskService {
pickDetailRepository.save(pickDetail);
} else {
throw new RuntimeException("未找到库存相应记录!");
throw new BadRequestException("未找到库存相应记录!");
}
}
} else {
throw new RuntimeException("参数错误或为空");
throw new BadRequestException("参数错误或为空");
}
}
@ -221,11 +222,11 @@ public class TaskServiceImpl implements TaskService {
}
pickDetailRepository.save(pickDetail);
} else {
throw new RuntimeException("未找到库存相应记录!");
throw new BadRequestException("未找到库存相应记录!");
}
} else {
throw new RuntimeException("参数错误或为空");
throw new BadRequestException("参数错误或为空");
}
}

View File

@ -5,6 +5,7 @@ import com.youchain.businessdata.domain.Pick;
import com.youchain.businessdata.repository.PickRepository;
import com.youchain.businessdata.service.PickDetailService;
import com.youchain.businessdata.service.PickService;
import com.youchain.exception.BadRequestException;
import com.youchain.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -39,7 +40,7 @@ public class pickTask {
List<String> statuses = Arrays.asList(BizStatus.OPEN, BizStatus.ASSIGN);
List<Pick> pickList = pickRepository.findByPickStatus(statuses,false);
if (pickList.isEmpty()) {
throw new RuntimeException("无待分配的出库单,分配失败!");
throw new BadRequestException("无待分配的出库单,分配失败!");
} else {
for (Pick pick : pickList) {
pickDetailService.allocatePick(pick);
@ -55,7 +56,7 @@ public class pickTask {
List<String> statuses = Arrays.asList(BizStatus.ALLOCATE);
List<Pick> pickList = pickRepository.findByPickStatus(statuses,false);
if (pickList.isEmpty()) {
throw new RuntimeException("无已分配的出库单,下发任务失败!");
throw new BadRequestException("无已分配的出库单,下发任务失败!");
} else {
for (Pick pick : pickList) {
pickService.materialPick(pick);
@ -68,7 +69,7 @@ public class pickTask {
List<String> statuses = Arrays.asList(BizStatus.PICK_ALL);
List<Pick> pickList = pickRepository.findByPickStatus(statuses,true);
if (pickList.isEmpty()) {
throw new RuntimeException("无拣货完成的出库单或出库单为未叫料,呼叫货架失败!");
throw new BadRequestException("无拣货完成的出库单或出库单为未叫料,呼叫货架失败!");
} else {
for (Pick pick : pickList) {
stockService.callJlTask(pick);

View File

@ -3,6 +3,7 @@ package com.youchain;
import com.youchain.basicdata.domain.BigItem;
import com.youchain.basicdata.vo.BarCodeVo;
import com.youchain.businessdata.domain.PickDetail;
import com.youchain.exception.BadRequestException;
import com.youchain.utils.BaseStatus;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@ -167,7 +168,7 @@ public class EladminSystemApplicationTests {
lastTaskTime = System.currentTimeMillis();
}
} catch (Exception e) {
throw new RuntimeException(e);
throw new BadRequestException(e.getMessage());
}
System.out.println(id);
}