From 2fde86022d04bd3f16fc2d210b44f92c3bf441ae Mon Sep 17 00:00:00 2001 From: zhouz <> Date: Fri, 2 Oct 2026 08:09:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/http/ExternalApiLogUtils.java | 60 +++++++++++++++++++ .../nl/module/wms/api/boxinfo/BoxInfoApi.java | 20 +++++++ .../wms/api/boxinfo/dto/BoxInfoEnsureReq.java | 23 +++++++ .../wms/api/boxinfo/BoxInfoApiImpl.java | 24 ++++++++ .../admin/customer/CustomerController.java | 39 ++++++++++++ .../admin/customer/vo/CustomerPageReqVO.java | 14 +++++ .../admin/customer/vo/CustomerRespVO.java | 16 +++++ .../src/api/wms/customer/index.ts | 28 +++++++++ .../src/views/wms/customer/data.ts | 42 +++++++++++++ .../src/views/wms/customer/index.vue | 36 +++++++++++ sql/mysql/wms_box_info_nullable_fields.sql | 8 +++ sql/mysql/wms_box_info_unique_box_no.sql | 3 + sql/mysql/wms_customer_menu.sql | 38 ++++++++++++ sql/mysql/wms_empty_box_truss_dispatch.sql | 15 +++++ 14 files changed, 366 insertions(+) create mode 100644 nl-framework/nl-common/src/main/java/cn/code/nl/framework/common/util/http/ExternalApiLogUtils.java create mode 100644 nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxinfo/BoxInfoApi.java create mode 100644 nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxinfo/dto/BoxInfoEnsureReq.java create mode 100644 nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/api/boxinfo/BoxInfoApiImpl.java create mode 100644 nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/CustomerController.java create mode 100644 nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/vo/CustomerPageReqVO.java create mode 100644 nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/vo/CustomerRespVO.java create mode 100644 nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/customer/index.ts create mode 100644 nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/customer/data.ts create mode 100644 nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/customer/index.vue create mode 100644 sql/mysql/wms_box_info_nullable_fields.sql create mode 100644 sql/mysql/wms_box_info_unique_box_no.sql create mode 100644 sql/mysql/wms_customer_menu.sql create mode 100644 sql/mysql/wms_empty_box_truss_dispatch.sql diff --git a/nl-framework/nl-common/src/main/java/cn/code/nl/framework/common/util/http/ExternalApiLogUtils.java b/nl-framework/nl-common/src/main/java/cn/code/nl/framework/common/util/http/ExternalApiLogUtils.java new file mode 100644 index 00000000..47a59d7d --- /dev/null +++ b/nl-framework/nl-common/src/main/java/cn/code/nl/framework/common/util/http/ExternalApiLogUtils.java @@ -0,0 +1,60 @@ +package cn.code.nl.framework.common.util.http; + +import jakarta.servlet.ServletRequest; +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +/** 外部系统出站调用的访问日志上下文。 */ +public final class ExternalApiLogUtils { + + private static final String ATTRIBUTE_REQUEST_BODY = "external_request_body"; + private static final String ATTRIBUTE_RESPONSE_BODY = "external_response_body"; + private static final String ATTRIBUTE_REQUEST_METHOD = "external_request_method"; + private static final String ATTRIBUTE_REQUEST_URL = "external_request_url"; + + private ExternalApiLogUtils() { + } + + /** 记录当前线程实际发出的外部请求。 */ + public static void setRequest(String method, String url, Object requestBody) { + HttpServletRequest request = getCurrentRequest(); + if (request == null) { + return; + } + request.setAttribute(ATTRIBUTE_REQUEST_METHOD, method); + request.setAttribute(ATTRIBUTE_REQUEST_URL, url); + request.setAttribute(ATTRIBUTE_REQUEST_BODY, requestBody); + } + + /** 记录当前线程收到的外部系统原始响应。 */ + public static void setResponse(Object responseBody) { + HttpServletRequest request = getCurrentRequest(); + if (request != null) { + request.setAttribute(ATTRIBUTE_RESPONSE_BODY, responseBody); + } + } + + public static Object getRequestBody(ServletRequest request) { + return request.getAttribute(ATTRIBUTE_REQUEST_BODY); + } + + public static Object getResponseBody(ServletRequest request) { + return request.getAttribute(ATTRIBUTE_RESPONSE_BODY); + } + + public static String getRequestMethod(ServletRequest request) { + return (String) request.getAttribute(ATTRIBUTE_REQUEST_METHOD); + } + + public static String getRequestUrl(ServletRequest request) { + return (String) request.getAttribute(ATTRIBUTE_REQUEST_URL); + } + + private static HttpServletRequest getCurrentRequest() { + RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); + return attributes instanceof ServletRequestAttributes servletAttributes + ? servletAttributes.getRequest() : null; + } +} diff --git a/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxinfo/BoxInfoApi.java b/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxinfo/BoxInfoApi.java new file mode 100644 index 00000000..fa738a29 --- /dev/null +++ b/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxinfo/BoxInfoApi.java @@ -0,0 +1,20 @@ +package cn.code.nl.module.wms.api.boxinfo; + +import cn.code.nl.framework.common.pojo.CommonResult; +import cn.code.nl.module.wms.api.boxinfo.dto.BoxInfoEnsureReq; +import cn.code.nl.module.wms.enums.ApiConstants; +import jakarta.validation.Valid; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** 木箱信息内部接口。 */ +@FeignClient(name = ApiConstants.NAME) +public interface BoxInfoApi { + + String PREFIX = ApiConstants.PREFIX + "/box-info"; + + /** 木箱规格绑定后,幂等补充木箱实例。 */ + @PostMapping(PREFIX + "/ensure-bound") + CommonResult ensureBoundBox(@Valid @RequestBody BoxInfoEnsureReq req); +} diff --git a/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxinfo/dto/BoxInfoEnsureReq.java b/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxinfo/dto/BoxInfoEnsureReq.java new file mode 100644 index 00000000..2a2691a7 --- /dev/null +++ b/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxinfo/dto/BoxInfoEnsureReq.java @@ -0,0 +1,23 @@ +package cn.code.nl.module.wms.api.boxinfo.dto; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Positive; +import lombok.Data; + +/** 木箱规格绑定后的木箱实例补充请求。 */ +@Data +public class BoxInfoEnsureReq { + @NotBlank(message = "木箱号不能为空") + private String boxNo; + @NotBlank(message = "木箱规格不能为空") + private String boxType; + @NotNull @Positive + private Integer boxLength; + @NotNull @Positive + private Integer boxWidth; + @NotNull @Positive + private Integer boxHigh; + @NotNull @Positive + private Integer quantity; +} diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/api/boxinfo/BoxInfoApiImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/api/boxinfo/BoxInfoApiImpl.java new file mode 100644 index 00000000..e5288d8c --- /dev/null +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/api/boxinfo/BoxInfoApiImpl.java @@ -0,0 +1,24 @@ +package cn.code.nl.module.wms.api.boxinfo; + +import cn.code.nl.framework.common.pojo.CommonResult; +import cn.code.nl.module.wms.api.boxinfo.dto.BoxInfoEnsureReq; +import cn.code.nl.module.wms.service.boxinfo.BoxInfoService; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RestController; + +import static cn.code.nl.framework.common.pojo.CommonResult.success; + +/** 木箱信息内部接口实现。 */ +@RestController +@Validated +public class BoxInfoApiImpl implements BoxInfoApi { + + @Resource + private BoxInfoService boxInfoService; + + @Override + public CommonResult ensureBoundBox(BoxInfoEnsureReq req) { + return success(boxInfoService.ensureBoundBox(req)); + } +} diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/CustomerController.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/CustomerController.java new file mode 100644 index 00000000..c15107e9 --- /dev/null +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/CustomerController.java @@ -0,0 +1,39 @@ +package cn.code.nl.module.wms.controller.admin.customer; + +import cn.code.nl.framework.common.pojo.CommonResult; +import cn.code.nl.framework.common.pojo.PageResult; +import cn.code.nl.framework.common.util.object.BeanUtils; +import cn.code.nl.module.wms.controller.admin.customer.vo.CustomerPageReqVO; +import cn.code.nl.module.wms.controller.admin.customer.vo.CustomerRespVO; +import cn.code.nl.module.wms.dal.dataobject.customer.CustomerDO; +import cn.code.nl.module.wms.dal.mysql.customer.CustomerMapper; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static cn.code.nl.framework.common.pojo.CommonResult.success; + +/** 管理后台 - 客户基础信息只读查询。 */ +@Tag(name = "管理后台 - 客户基础信息") +@RestController +@RequestMapping("/wms/customer") +@Validated +public class CustomerController { + + @Resource + private CustomerMapper customerMapper; + + @GetMapping("/page") + @Operation(summary = "分页查询客户基础信息") + @PreAuthorize("@ss.hasPermission('wms:customer:query')") + public CommonResult> getPage(@Valid CustomerPageReqVO reqVO) { + PageResult page = customerMapper.selectPage(reqVO); + return success(BeanUtils.toBean(page, CustomerRespVO.class)); + } +} diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/vo/CustomerPageReqVO.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/vo/CustomerPageReqVO.java new file mode 100644 index 00000000..2325b0a9 --- /dev/null +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/vo/CustomerPageReqVO.java @@ -0,0 +1,14 @@ +package cn.code.nl.module.wms.controller.admin.customer.vo; + +import cn.code.nl.framework.common.pojo.PageParam; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** 客户基础信息分页查询参数。 */ +@Data +@EqualsAndHashCode(callSuper = true) +public class CustomerPageReqVO extends PageParam { + private String customerCode; + private String customerName; + private String address; +} diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/vo/CustomerRespVO.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/vo/CustomerRespVO.java new file mode 100644 index 00000000..178bcb65 --- /dev/null +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/customer/vo/CustomerRespVO.java @@ -0,0 +1,16 @@ +package cn.code.nl.module.wms.controller.admin.customer.vo; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** 客户基础信息响应。 */ +@Data +public class CustomerRespVO { + private Long id; + private String customerCode; + private String customerName; + private String address; + private LocalDateTime createTime; + private LocalDateTime updateTime; +} diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/customer/index.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/customer/index.ts new file mode 100644 index 00000000..fbd04a9c --- /dev/null +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/customer/index.ts @@ -0,0 +1,28 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace WmsCustomerApi { + export interface Customer { + id: number | string; + customerCode: string; + customerName?: string; + address?: string; + createTime?: number | string; + updateTime?: number | string; + } + + export interface PageParams extends PageParam { + customerCode?: string; + customerName?: string; + address?: string; + } +} + +/** 分页查询客户基础信息。 */ +export function getCustomerPage(params: WmsCustomerApi.PageParams) { + return requestClient.get>( + '/wms/customer/page', + { params }, + ); +} diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/customer/data.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/customer/data.ts new file mode 100644 index 00000000..dfaa5684 --- /dev/null +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/customer/data.ts @@ -0,0 +1,42 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { WmsCustomerApi } from '#/api/wms/customer'; + +/** 客户列表查询条件。 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'customerCode', + label: '客户编码', + component: 'Input', + componentProps: { allowClear: true, placeholder: '请输入客户编码' }, + }, + { + fieldName: 'customerName', + label: '客户名称', + component: 'Input', + componentProps: { allowClear: true, placeholder: '请输入客户名称' }, + }, + { + fieldName: 'address', + label: '客户地址', + component: 'Input', + componentProps: { allowClear: true, placeholder: '请输入客户地址' }, + }, + ]; +} + +/** 客户列表字段。 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { field: 'customerCode', title: '客户编码', minWidth: 180, fixed: 'left' }, + { field: 'customerName', title: '客户名称', minWidth: 220 }, + { field: 'address', title: '客户地址', minWidth: 320 }, + { + field: 'updateTime', + title: '更新时间', + minWidth: 170, + formatter: 'formatDateTime', + }, + ]; +} diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/customer/index.vue b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/customer/index.vue new file mode 100644 index 00000000..7f12a553 --- /dev/null +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/customer/index.vue @@ -0,0 +1,36 @@ + + + diff --git a/sql/mysql/wms_box_info_nullable_fields.sql b/sql/mysql/wms_box_info_nullable_fields.sql new file mode 100644 index 00000000..d737e554 --- /dev/null +++ b/sql/mysql/wms_box_info_nullable_fields.sql @@ -0,0 +1,8 @@ +-- 空木箱创建时,以下属性可能未在木箱类型中维护,允许按 NULL 入库。 +-- 可重复执行。 +ALTER TABLE wmw_boxinfo + MODIFY COLUMN material_name VARCHAR(50) NULL COMMENT '物料名称', + MODIFY COLUMN box_length VARCHAR(10) NULL COMMENT '木箱长度', + MODIFY COLUMN box_width VARCHAR(10) NULL COMMENT '木箱宽度', + MODIFY COLUMN box_high VARCHAR(10) NULL COMMENT '木箱高度', + MODIFY COLUMN lash_num VARCHAR(10) NULL COMMENT '捆绑数量'; diff --git a/sql/mysql/wms_box_info_unique_box_no.sql b/sql/mysql/wms_box_info_unique_box_no.sql new file mode 100644 index 00000000..ff248a3e --- /dev/null +++ b/sql/mysql/wms_box_info_unique_box_no.sql @@ -0,0 +1,3 @@ +-- 木箱号是木箱实例的业务唯一标识,防止规格绑定并发写入重复记录。 +ALTER TABLE wmw_boxinfo + ADD UNIQUE INDEX uk_wmw_boxinfo_box_no (box_no); diff --git a/sql/mysql/wms_customer_menu.sql b/sql/mysql/wms_customer_menu.sql new file mode 100644 index 00000000..58a60166 --- /dev/null +++ b/sql/mysql/wms_customer_menu.sql @@ -0,0 +1,38 @@ +-- WMS管理 / 基础模块:客户基础信息只读查询菜单,可重复执行。 +SET @wms_base_menu_id = ( + SELECT id FROM system_menu + WHERE path = 'wms-base' AND type = 1 AND deleted = b'0' + LIMIT 1 +); + +INSERT INTO system_menu + (id, name, permission, type, sort, parent_id, path, icon, component, + component_name, status, visible, keep_alive, always_show, + creator, create_time, updater, update_time, deleted) +SELECT 2091000000000000115, '客户基础信息', '', 2, 7, @wms_base_menu_id, + 'customer', 'ep:user', 'wms/customer/index', 'WmsCustomer', + 0, b'1', b'1', b'1', '1', NOW(), '1', NOW(), b'0' +WHERE @wms_base_menu_id IS NOT NULL + AND NOT EXISTS ( + SELECT 1 FROM system_menu + WHERE parent_id = @wms_base_menu_id AND path = 'customer' AND deleted = b'0' + ); + +SET @customer_menu_id = ( + SELECT id FROM system_menu + WHERE parent_id = @wms_base_menu_id AND path = 'customer' AND deleted = b'0' + LIMIT 1 +); + +INSERT INTO system_menu + (id, name, permission, type, sort, parent_id, path, icon, component, + component_name, status, visible, keep_alive, always_show, + creator, create_time, updater, update_time, deleted) +SELECT 2091000000000000116, '客户基础信息查询', 'wms:customer:query', 3, 1, + @customer_menu_id, '', '#', NULL, NULL, + 0, b'1', b'1', b'1', '1', NOW(), '1', NOW(), b'0' +WHERE @customer_menu_id IS NOT NULL + AND NOT EXISTS ( + SELECT 1 FROM system_menu + WHERE permission = 'wms:customer:query' AND deleted = b'0' + ); diff --git a/sql/mysql/wms_empty_box_truss_dispatch.sql b/sql/mysql/wms_empty_box_truss_dispatch.sql new file mode 100644 index 00000000..b636ffb5 --- /dev/null +++ b/sql/mysql/wms_empty_box_truss_dispatch.sql @@ -0,0 +1,15 @@ +-- 空木箱桁架入库 ACS 下发参数配置,可重复执行。 + +INSERT INTO infra_config + (category, type, name, config_key, value, visible, remark, creator, updater, deleted) +SELECT 'wms', 2, '空木箱高度等级一级上限', 'wms.empty-box.height-level-one-max', '650', b'1', + '木箱高度小于等于该值时 heightLevel=1', '1', '1', b'0' +WHERE NOT EXISTS (SELECT 1 FROM infra_config + WHERE config_key = 'wms.empty-box.height-level-one-max' AND deleted = b'0'); + +INSERT INTO infra_config + (category, type, name, config_key, value, visible, remark, creator, updater, deleted) +SELECT 'wms', 2, '空木箱高度等级二级上限', 'wms.empty-box.height-level-two-max', '800', b'1', + '木箱高度大于一级上限且小于等于该值时 heightLevel=2,超过时禁止创建任务', '1', '1', b'0' +WHERE NOT EXISTS (SELECT 1 FROM infra_config + WHERE config_key = 'wms.empty-box.height-level-two-max' AND deleted = b'0');