From 5cb45125e405011b80d74e14513ed1b6a01887d8 Mon Sep 17 00:00:00 2001 From: yf001217 <834502597@qq.com> Date: Fri, 5 Jun 2026 15:19:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=8B=E5=8A=A8=E5=8F=91?= =?UTF-8?q?=E8=B5=B7=E5=BA=93=E5=AD=98=E6=A3=80=E6=B5=8B=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...comingInspectionTaskControllerService.java | 13 ------ .../admin/controller/InventoryController.java | 15 +++++++ .../nflg/wms/admin/service/QmsService.java | 42 ++++++++++++++++++- .../pojo/qo/InventoryDetectionApplyQO.java | 26 ++++++++++++ 4 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/InventoryDetectionApplyQO.java diff --git a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/IncomingInspectionTaskControllerService.java b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/IncomingInspectionTaskControllerService.java index 0cd84a2e..e79629a2 100644 --- a/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/IncomingInspectionTaskControllerService.java +++ b/nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/IncomingInspectionTaskControllerService.java @@ -113,9 +113,6 @@ public class IncomingInspectionTaskControllerService { @Resource private List sendMessageServices; - @Resource - private IWmsInventoryService inventoryService; - /** * 来料检验申请(对外接口) * 业务规则: @@ -384,16 +381,6 @@ public class IncomingInspectionTaskControllerService { .eq(QmsIncomingInspectionTask::getId, task.getId()) .update(); - boolean inventoryUpdated = inventoryService.lambdaUpdate() - .set(WmsInventory::getDetectionStatus, (short) 1) - .set(WmsInventory::getDetectionResults, null) - .eq(WmsInventory::getMaterialNo, request.getMaterialNo()) - .eq(WmsInventory::getFactoryNo, request.getFactory()) - .eq(WmsInventory::getWarehouseNo, request.getWarehouse()) - .eq(WmsInventory::getBinLocation, request.getStorageLocation()) - .update(); - VUtil.trueThrowBusinessError(!inventoryUpdated).throwMessage("未找到对应库存,无法更新检测状态"); - QmsTodoItem qmsTodoItem = new QmsTodoItem() .setTitle("新的IQC库存检测任务" + task.getTaskNo()) .setCode(basdeSerialNumberControllerService.generateSerialNumber(32)) diff --git a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/InventoryController.java b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/InventoryController.java index 11ad743a..c22654a2 100644 --- a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/InventoryController.java +++ b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/controller/InventoryController.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import com.nflg.wms.admin.repository.InventoryCheckTaskScanRecordResitory; +import com.nflg.wms.admin.service.QmsService; import com.nflg.wms.common.constant.STATE; import com.nflg.wms.common.pojo.ApiResult; import com.nflg.wms.common.pojo.PageData; @@ -59,6 +60,9 @@ public class InventoryController extends BaseController { @Resource private IWmsQrCodeMasterService qrCodeMasterService; + @Resource + private QmsService qmsService; + /** * 库存查看 * @@ -69,6 +73,17 @@ public class InventoryController extends BaseController { return ApiResult.success(inventoryService.search(request)); } + /** + * 发起库存检测任务 + * + * @param request 库存检测申请参数 + */ + @PostMapping("detection/apply") + public ApiResult applyInventoryDetection(@Valid @RequestBody InventoryDetectionApplyQO request) { + qmsService.pushInventoryInspection(request); + return ApiResult.success(); + } + /** * 保存库存盘点任务 * diff --git a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/QmsService.java b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/QmsService.java index fdf2ba3e..1272afcb 100644 --- a/nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/QmsService.java +++ b/nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/QmsService.java @@ -3,7 +3,11 @@ package com.nflg.wms.admin.service; import cn.hutool.json.JSONUtil; import com.nflg.wms.common.pojo.ApiResult; import com.nflg.wms.common.pojo.qo.ExternalIncomingInspectionApplyQO; +import com.nflg.wms.common.pojo.qo.ExternalInventoryInspectionApplyQO; +import com.nflg.wms.common.pojo.qo.InventoryDetectionApplyQO; import com.nflg.wms.common.util.VUtil; +import com.nflg.wms.repository.entity.WmsInventory; +import com.nflg.wms.repository.service.IWmsInventoryService; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -26,6 +30,9 @@ public class QmsService { @Resource private RestTemplate restTemplate; + @Resource + private IWmsInventoryService inventoryService; + @Value("${qms.inspection.url:}") private String qmsUrl; @@ -49,4 +56,37 @@ public class QmsService { Objects.isNull(response.getBody()) || response.getBody().getCode() != 200 ).throwMessage("推送来料检验申请到QMS失败:" + response.getBody().getMessage()); } -} \ No newline at end of file + + public void pushInventoryInspection(InventoryDetectionApplyQO request) { + ExternalInventoryInspectionApplyQO apply = request.getApply(); + log.info("推送库存检测申请到QMS:申请参数={},二维码={}", + JSONUtil.toJsonStr(apply), JSONUtil.toJsonStr(request.getQrCodes())); + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity requestEntity = new HttpEntity<>(apply, headers); + + ResponseEntity> response = restTemplate.exchange( + qmsUrl + "/external/incoming-inspection-task/inventory-apply", + HttpMethod.POST, + requestEntity, + new ParameterizedTypeReference>() {} + ); + + ApiResult body = response.getBody(); + log.info("推送库存检测申请到QMS结果:{},{}", + response.getStatusCode().value(), JSONUtil.toJsonStr(body)); + VUtil.trueThrowBusinessError(Objects.isNull(body) || body.getCode() != 200) + .throwMessage("推送库存检测申请到QMS失败:" + (Objects.isNull(body) ? "无响应内容" : body.getMessage())); + + boolean inventoryUpdated = inventoryService.lambdaUpdate() + .set(WmsInventory::getDetectionStatus, (short) 1) + .set(WmsInventory::getDetectionResults, null) + .eq(WmsInventory::getMaterialNo, apply.getMaterialNo()) + .eq(WmsInventory::getFactoryNo, apply.getFactory()) + .eq(WmsInventory::getWarehouseNo, apply.getWarehouse()) + .eq(WmsInventory::getBinLocation, apply.getStorageLocation()) + .update(); + VUtil.trueThrowBusinessError(!inventoryUpdated).throwMessage("未找到对应库存,无法更新检测状态"); + } +} diff --git a/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/InventoryDetectionApplyQO.java b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/InventoryDetectionApplyQO.java new file mode 100644 index 00000000..05d47cf9 --- /dev/null +++ b/nflg-wms-common/src/main/java/com/nflg/wms/common/pojo/qo/InventoryDetectionApplyQO.java @@ -0,0 +1,26 @@ +package com.nflg.wms.common.pojo.qo; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +/** + * WMS发起库存检测申请 + */ +@Data +public class InventoryDetectionApplyQO { + + /** + * 库存检测申请参数 + */ + @Valid + @NotNull(message = "库存检测申请参数不能为空") + private ExternalInventoryInspectionApplyQO apply; + + /** + * 物料二维码列表,允许为空;后续落库使用,本次仅预留 + */ + private List qrCodes; +}