parent
076604f91c
commit
077946fe06
14 changed files with 237 additions and 57 deletions
@ -0,0 +1,166 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package org.springblade.desk.logistics.controller; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.Parameter; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import lombok.AllArgsConstructor; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import java.math.BigDecimal; |
||||
|
||||
|
||||
/** |
||||
* 输送线 控制器 |
||||
* |
||||
* @author BladeX |
||||
* @since 2026-02-28 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/pipeline") |
||||
@Tag(name = "输送线", description = "输送线接口") |
||||
public class PipelineController extends BladeController { |
||||
|
||||
|
||||
/** |
||||
* 根据物料箱号查询已绑定预估重量 |
||||
*/ |
||||
@GetMapping("/estimated-weight") |
||||
@ApiOperationSupport(order = 1) |
||||
@Operation(summary = "根据物料箱号查询已绑定预估重量", description = "传入箱条码") |
||||
public R estimatedWeight(@RequestParam String boxBarcode) { |
||||
// 1.参数校验
|
||||
if (StringUtils.isEmpty(boxBarcode)) { |
||||
throw new ServiceException("箱条码不能为空"); |
||||
} |
||||
|
||||
// todo 2.查询箱信息
|
||||
// //Box box = boxMapper.selectByBarcode(boxBarcode);
|
||||
// if (box == null) {
|
||||
// throw new ServiceException("箱号不存在: " + boxBarcode);
|
||||
// }
|
||||
//
|
||||
// // 3.检查是否已绑定
|
||||
// if (!box.getBound()) {
|
||||
// throw new ServiceException("该箱号未绑定预估重量");
|
||||
// }
|
||||
BigDecimal estimatedWeight = new BigDecimal(50); |
||||
return R.data(estimatedWeight); |
||||
} |
||||
|
||||
|
||||
@GetMapping("/verifyConveyorBoxWeighing") |
||||
@ApiOperationSupport(order = 2) |
||||
@Operation( |
||||
summary = "验证输送箱实际重量", |
||||
description = "传入箱条码与实际重量,校验是否超重;若超重则解绑物料箱并指令放回输送线" |
||||
) |
||||
public R getBoundEstimatedWeight( |
||||
@Parameter(description = "物料箱条码", required = true) |
||||
@RequestParam String boxBarcode, |
||||
@Parameter(description = "实际称重重量(单位:kg)", required = true) |
||||
@RequestParam BigDecimal actualWeight) { |
||||
|
||||
// 1.参数合法性校验
|
||||
if (boxBarcode == null || boxBarcode.trim().isEmpty()) { |
||||
return R.fail("箱条码不能为空"); |
||||
} |
||||
if (actualWeight == null || actualWeight.compareTo(BigDecimal.ZERO) < 0) { |
||||
return R.fail("实际重量必须为非负数"); |
||||
} |
||||
|
||||
try { |
||||
// 2.根据箱条码查询物料箱基础信息
|
||||
|
||||
// 3.判断是否超重
|
||||
BigDecimal ratedWeight = new BigDecimal(50); |
||||
int weightCompare = actualWeight.compareTo(ratedWeight); |
||||
if (weightCompare > 0) { |
||||
// 4.超重:执行解绑操作 + 指令放回输送线
|
||||
|
||||
// 超重处理完成返回
|
||||
return R.data( |
||||
false,"物料箱[" + boxBarcode + "]超重(实际:" + actualWeight + "kg,额定:" + ratedWeight + "kg),已解绑并放回输送线" |
||||
); |
||||
} else { |
||||
// 5.未超重:正常返回
|
||||
return R.data( |
||||
true,"物料箱[" + boxBarcode + "]重量校验通过(实际:" + actualWeight + "kg,额定:" + ratedWeight + "kg)" |
||||
); |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
return R.fail("物料箱重量校验处理异常:" + e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 接收物料箱到达输送线末尾信息 |
||||
*/ |
||||
@GetMapping("/receiveBoxArriveConveyorEnd") |
||||
@ApiOperationSupport(order = 3) |
||||
@Operation(summary = "接收物料箱", description = "传入箱条码") |
||||
public R receiveBoxArriveConveyorEnd(@RequestParam String boxBarcode) { |
||||
// 1.参数校验
|
||||
if (StringUtils.isEmpty(boxBarcode)) { |
||||
throw new ServiceException("箱条码不能为空"); |
||||
} |
||||
|
||||
return R.data(true); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 接收空物料箱到输送线通知 |
||||
*/ |
||||
@GetMapping("/recordEmptyBoxArriveConveyor") |
||||
@ApiOperationSupport(order = 4) |
||||
@Operation(summary = "接收物料箱", description = "传入箱条码") |
||||
public R recordEmptyBoxArriveConveyor(@RequestParam String boxBarcode) { |
||||
// 1.参数校验
|
||||
if (StringUtils.isEmpty(boxBarcode)) { |
||||
throw new ServiceException("箱条码不能为空"); |
||||
} |
||||
|
||||
return R.data(true); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
Loading…
Reference in new issue