🆕 申请分页改造
All checks were successful
Release / Release (push) Successful in 43s

This commit is contained in:
my_ong 2025-03-23 10:26:18 +08:00
parent 6d13c8a996
commit f8663453d2
6 changed files with 35 additions and 26 deletions

View File

@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; 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 = "页面大小") @RequestParam(name = "size", required = false, defaultValue = "10") int size,
@Parameter(description = "申请类型(1入库 3出库 4盘点)") @RequestParam(name = "applyType") Integer applyType, @Parameter(description = "申请类型(1入库 3出库 4盘点)") @RequestParam(name = "applyType") Integer applyType,
@Parameter(description = "物料类型") @RequestParam(name = "type", required = false) String type, @Parameter(description = "物料类型") @RequestParam(name = "type", required = false) String type,
@Parameter(description = "物料编码") @RequestParam(name = "code", required = false) String code, @Parameter(description = "编码/名称") @RequestParam(name = "key", required = false) String key) {
@Parameter(description = "物料名称") @RequestParam(name = "name", required = false) String name) { String[] types = StringUtils.isNotBlank(type) ? type.split(",") : new String[0];
IPage<ApplyDTO> result = applyFormService.search(page, size, applyType, type, code, name); IPage<ApplyDTO> result = applyFormService.search(page, size, applyType, List.of(types), key);
result.getRecords().forEach(item -> item.setTypeName(typeService.getTypeName(item.getType()))); result.getRecords().forEach(item -> item.setTypeName(typeService.getTypeName(item.getType())));
return result; return result;
} }
@ -68,10 +69,9 @@ public class ApplyFormController {
@Operation(summary = "导出申请单列表") @Operation(summary = "导出申请单列表")
public void downloadExcel(@Parameter(description = "申请类型(1入库 3出库 4盘点)") @RequestParam(name = "applyType") Integer applyType, 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 = "type", required = false) String type,
@Parameter(description = "物料编码") @RequestParam(name = "code", required = false) String code, @Parameter(description = "编码/名称") @RequestParam(name = "code", required = false) String key,
@Parameter(description = "物料名称") @RequestParam(name = "name", required = false) String name,
HttpServletResponse response) { HttpServletResponse response) {
IPage<ApplyDTO> applyDTOIPage = searchPage(1, 10000, applyType, type, code, name); IPage<ApplyDTO> applyDTOIPage = searchPage(1, 10000, applyType, type, key);
List<ApplyDTO> applyDTOList = applyDTOIPage.getRecords(); List<ApplyDTO> applyDTOList = applyDTOIPage.getRecords();
// 导出excel // 导出excel
String sheetName = "申请单列表"; String sheetName = "申请单列表";

View File

@ -13,11 +13,11 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
public enum ApplyTypeEnum implements ICodeBook { public enum ApplyTypeEnum implements ICodeBook {
PURCHASE_RECEIPT("1", "采购入库申请"), PURCHASE_RECEIPT("1", "采购入库"),
RETURN_RECEIPT("2", "归还入库申请"), RETURN_RECEIPT("2", "归还入库"),
LOAN_OUT("3", "外借出库申请"), LOAN_OUT("3", "外借出库"),
AUDIT("4", "盘点申请"), AUDIT("4", "盘点"),
SCRAP_OUT("5", "报废出库申请"), SCRAP_OUT("5", "报废出库"),
; ;
@EnumValue @EnumValue

View File

@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import tech.riemann.ims.dto.response.ApplyDTO; import tech.riemann.ims.dto.response.ApplyDTO;
import tech.riemann.ims.entity.material.ApplyForm; import tech.riemann.ims.entity.material.ApplyForm;
import java.util.List;
/** /**
* @author mayong * @author mayong
* @since 2024/11/28 15:38 * @since 2024/11/28 15:38
*/ */
public interface ApplyFormMapper extends BaseMapper<ApplyForm> { public interface ApplyFormMapper extends BaseMapper<ApplyForm> {
IPage<ApplyDTO> searchPage(IPage<ApplyDTO> page, Integer applyType, String type, String code, String name); IPage<ApplyDTO> searchPage(IPage<ApplyDTO> page, Integer applyType, List<String> types, String key);
} }

View File

@ -6,6 +6,8 @@ import org.nutz.spring.boot.service.interfaces.IdNameEntityService;
import tech.riemann.ims.dto.response.ApplyDTO; import tech.riemann.ims.dto.response.ApplyDTO;
import tech.riemann.ims.entity.material.ApplyForm; import tech.riemann.ims.entity.material.ApplyForm;
import java.util.List;
/** /**
* @author mayong * @author mayong
* @since 2024/11/28 15:35 * @since 2024/11/28 15:35
@ -17,10 +19,8 @@ public interface IApplyFormService extends IService<ApplyForm>, IdNameEntityServ
* @param page 页码 * @param page 页码
* @param size 每页数量 * @param size 每页数量
* @param applyType 申请类型 * @param applyType 申请类型
* @param type 申请材料类型 * @param key 编码或名称关键字
* @param code 申请材料编码
* @param name 申请材料名称
* @return IPage<ApplyDTO> * @return IPage<ApplyDTO>
*/ */
IPage<ApplyDTO> search(int page, int size, Integer applyType, String type, String code, String name); IPage<ApplyDTO> search(int page, int size, Integer applyType, List<String> types, String key);
} }

View File

@ -11,6 +11,8 @@ import tech.riemann.ims.entity.material.ApplyForm;
import tech.riemann.ims.mapper.material.ApplyFormMapper; import tech.riemann.ims.mapper.material.ApplyFormMapper;
import tech.riemann.ims.service.material.IApplyFormService; import tech.riemann.ims.service.material.IApplyFormService;
import java.util.List;
/** /**
* @author mayong * @author mayong
* @since 2024/11/28 15:36 * @since 2024/11/28 15:36
@ -28,7 +30,7 @@ public class ApplyFormServiceImpl extends ServiceImpl<ApplyFormMapper, ApplyForm
} }
@Override @Override
public IPage<ApplyDTO> search(int page, int size, Integer applyType, String type, String code, String name) { public IPage<ApplyDTO> search(int page, int size, Integer applyType, List<String> types, String key) {
return applyFormMapper.searchPage(Page.of(page, size), applyType, type, code, name); return applyFormMapper.searchPage(Page.of(page, size), applyType, types, key);
} }
} }

View File

@ -54,15 +54,20 @@
</otherwise> </otherwise>
</choose> </choose>
</if> </if>
<if test="type!= null and type!= ''"> <if test="types != null and types.size() > 0">
and( m.m_type LIKE CONCAT('%', #{type}, '%') or m.m_code LIKE CONCAT('%', #{code}, '%') or m.m_name LIKE CONCAT('%', #{name}, '%') ) and (
<foreach collection="types" item="item" separator="or">
( m_type like concat(#{item},'%') )
</foreach>
)
</if>
<if test="key != null and key.trim().length() > 0">
and (
m_code like concat('%',#{key},'%')
or m_name like concat('%',#{key},'%')
)
</if> </if>
<!-- <if test="code!= null and code!= ''">-->
<!-- AND m.m_code LIKE CONCAT('%', #{code}, '%')-->
<!-- </if>-->
<!-- <if test="name!= null and name!= ''">-->
<!-- AND m.m_name LIKE CONCAT('%', #{name}, '%')-->
<!-- </if>-->
ORDER BY f.af_apply_date DESC ORDER BY f.af_apply_date DESC
</select> </select>