From f8663453d2ddd1982d21a4f182b2d4b95b440d26 Mon Sep 17 00:00:00 2001 From: my_ong <429426262@qq.com> Date: Sun, 23 Mar 2025 10:26:18 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20=E7=94=B3=E8=AF=B7=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../material/ApplyFormController.java | 12 +++++------ .../tech/riemann/ims/enums/ApplyTypeEnum.java | 10 ++++----- .../ims/mapper/material/ApplyFormMapper.java | 4 +++- .../service/material/IApplyFormService.java | 8 +++---- .../material/impl/ApplyFormServiceImpl.java | 6 ++++-- src/main/resources/mapper/ApplyFormMapper.xml | 21 ++++++++++++------- 6 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/main/java/tech/riemann/ims/controller/platform/material/ApplyFormController.java b/src/main/java/tech/riemann/ims/controller/platform/material/ApplyFormController.java index 656e014..7b1dfa3 100644 --- a/src/main/java/tech/riemann/ims/controller/platform/material/ApplyFormController.java +++ b/src/main/java/tech/riemann/ims/controller/platform/material/ApplyFormController.java @@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; import org.apache.poi.util.StringUtil; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -57,9 +58,9 @@ public class ApplyFormController { @Parameter(description = "页面大小") @RequestParam(name = "size", required = false, defaultValue = "10") int size, @Parameter(description = "申请类型(1入库 3出库 4盘点)") @RequestParam(name = "applyType") Integer applyType, @Parameter(description = "物料类型") @RequestParam(name = "type", required = false) String type, - @Parameter(description = "物料编码") @RequestParam(name = "code", required = false) String code, - @Parameter(description = "物料名称") @RequestParam(name = "name", required = false) String name) { - IPage result = applyFormService.search(page, size, applyType, type, code, name); + @Parameter(description = "编码/名称") @RequestParam(name = "key", required = false) String key) { + String[] types = StringUtils.isNotBlank(type) ? type.split(",") : new String[0]; + IPage result = applyFormService.search(page, size, applyType, List.of(types), key); result.getRecords().forEach(item -> item.setTypeName(typeService.getTypeName(item.getType()))); return result; } @@ -68,10 +69,9 @@ public class ApplyFormController { @Operation(summary = "导出申请单列表") public void downloadExcel(@Parameter(description = "申请类型(1入库 3出库 4盘点)") @RequestParam(name = "applyType") Integer applyType, @Parameter(description = "物料类型") @RequestParam(name = "type", required = false) String type, - @Parameter(description = "物料编码") @RequestParam(name = "code", required = false) String code, - @Parameter(description = "物料名称") @RequestParam(name = "name", required = false) String name, + @Parameter(description = "编码/名称") @RequestParam(name = "code", required = false) String key, HttpServletResponse response) { - IPage applyDTOIPage = searchPage(1, 10000, applyType, type, code, name); + IPage applyDTOIPage = searchPage(1, 10000, applyType, type, key); List applyDTOList = applyDTOIPage.getRecords(); // 导出excel String sheetName = "申请单列表"; diff --git a/src/main/java/tech/riemann/ims/enums/ApplyTypeEnum.java b/src/main/java/tech/riemann/ims/enums/ApplyTypeEnum.java index 1a129e7..3ba3b95 100644 --- a/src/main/java/tech/riemann/ims/enums/ApplyTypeEnum.java +++ b/src/main/java/tech/riemann/ims/enums/ApplyTypeEnum.java @@ -13,11 +13,11 @@ import lombok.Getter; @AllArgsConstructor public enum ApplyTypeEnum implements ICodeBook { - PURCHASE_RECEIPT("1", "采购入库申请"), - RETURN_RECEIPT("2", "归还入库申请"), - LOAN_OUT("3", "外借出库申请"), - AUDIT("4", "盘点申请"), - SCRAP_OUT("5", "报废出库申请"), + PURCHASE_RECEIPT("1", "采购入库"), + RETURN_RECEIPT("2", "归还入库"), + LOAN_OUT("3", "外借出库"), + AUDIT("4", "盘点"), + SCRAP_OUT("5", "报废出库"), ; @EnumValue diff --git a/src/main/java/tech/riemann/ims/mapper/material/ApplyFormMapper.java b/src/main/java/tech/riemann/ims/mapper/material/ApplyFormMapper.java index 1867d60..e861e5e 100644 --- a/src/main/java/tech/riemann/ims/mapper/material/ApplyFormMapper.java +++ b/src/main/java/tech/riemann/ims/mapper/material/ApplyFormMapper.java @@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import tech.riemann.ims.dto.response.ApplyDTO; import tech.riemann.ims.entity.material.ApplyForm; +import java.util.List; + /** * @author mayong * @since 2024/11/28 15:38 */ public interface ApplyFormMapper extends BaseMapper { - IPage searchPage(IPage page, Integer applyType, String type, String code, String name); + IPage searchPage(IPage page, Integer applyType, List types, String key); } diff --git a/src/main/java/tech/riemann/ims/service/material/IApplyFormService.java b/src/main/java/tech/riemann/ims/service/material/IApplyFormService.java index 267956b..c73ae6d 100644 --- a/src/main/java/tech/riemann/ims/service/material/IApplyFormService.java +++ b/src/main/java/tech/riemann/ims/service/material/IApplyFormService.java @@ -6,6 +6,8 @@ import org.nutz.spring.boot.service.interfaces.IdNameEntityService; import tech.riemann.ims.dto.response.ApplyDTO; import tech.riemann.ims.entity.material.ApplyForm; +import java.util.List; + /** * @author mayong * @since 2024/11/28 15:35 @@ -17,10 +19,8 @@ public interface IApplyFormService extends IService, IdNameEntityServ * @param page 页码 * @param size 每页数量 * @param applyType 申请类型 - * @param type 申请材料类型 - * @param code 申请材料编码 - * @param name 申请材料名称 + * @param key 编码或名称关键字 * @return IPage */ - IPage search(int page, int size, Integer applyType, String type, String code, String name); + IPage search(int page, int size, Integer applyType, List types, String key); } diff --git a/src/main/java/tech/riemann/ims/service/material/impl/ApplyFormServiceImpl.java b/src/main/java/tech/riemann/ims/service/material/impl/ApplyFormServiceImpl.java index 77c92a6..83ff6bb 100644 --- a/src/main/java/tech/riemann/ims/service/material/impl/ApplyFormServiceImpl.java +++ b/src/main/java/tech/riemann/ims/service/material/impl/ApplyFormServiceImpl.java @@ -11,6 +11,8 @@ import tech.riemann.ims.entity.material.ApplyForm; import tech.riemann.ims.mapper.material.ApplyFormMapper; import tech.riemann.ims.service.material.IApplyFormService; +import java.util.List; + /** * @author mayong * @since 2024/11/28 15:36 @@ -28,7 +30,7 @@ public class ApplyFormServiceImpl extends ServiceImpl search(int page, int size, Integer applyType, String type, String code, String name) { - return applyFormMapper.searchPage(Page.of(page, size), applyType, type, code, name); + public IPage search(int page, int size, Integer applyType, List types, String key) { + return applyFormMapper.searchPage(Page.of(page, size), applyType, types, key); } } diff --git a/src/main/resources/mapper/ApplyFormMapper.xml b/src/main/resources/mapper/ApplyFormMapper.xml index 3f4a905..0745b80 100644 --- a/src/main/resources/mapper/ApplyFormMapper.xml +++ b/src/main/resources/mapper/ApplyFormMapper.xml @@ -54,15 +54,20 @@ - - and( m.m_type LIKE CONCAT('%', #{type}, '%') or m.m_code LIKE CONCAT('%', #{code}, '%') or m.m_name LIKE CONCAT('%', #{name}, '%') ) + + and ( + + ( m_type like concat(#{item},'%') ) + + ) + + + + and ( + m_code like concat('%',#{key},'%') + or m_name like concat('%',#{key},'%') + ) - - - - - - ORDER BY f.af_apply_date DESC