feat: 优化查询效率
This commit is contained in:
@@ -20,6 +20,7 @@ import org.agt.module.license.controller.admin.license.vo.LicenseCodeImportExcel
|
|||||||
import org.agt.module.license.controller.admin.license.vo.LicenseDetailVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseDetailVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseImportExcelVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseImportExcelVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicensePageReqVO;
|
import org.agt.module.license.controller.admin.license.vo.LicensePageReqVO;
|
||||||
|
import org.agt.module.license.controller.admin.license.vo.LicensePageRespVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseRespVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseRespVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseSaveReqVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseSaveReqVO;
|
||||||
import org.agt.module.license.service.license.LicenseService;
|
import org.agt.module.license.service.license.LicenseService;
|
||||||
@@ -120,8 +121,8 @@ public class LicenseController {
|
|||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得License分页")
|
@Operation(summary = "获得License分页")
|
||||||
@PreAuthorize("@ss.hasPermission('license:license:query')")
|
@PreAuthorize("@ss.hasPermission('license:license:query')")
|
||||||
public CommonResult<PageResult<LicenseRespVO>> getLicensePage(@Valid LicensePageReqVO pageReqVO) {
|
public CommonResult<PageResult<LicensePageRespVO>> getLicensePage(@Valid LicensePageReqVO pageReqVO) {
|
||||||
PageResult<LicenseRespVO> pageResult = licenseService.getLicensePage(pageReqVO);
|
PageResult<LicensePageRespVO> pageResult = licenseService.getLicensePage(pageReqVO);
|
||||||
return success(pageResult);
|
return success(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +145,7 @@ public class LicenseController {
|
|||||||
pageReqVO = BeanUtils.toBean(exportReqVO, LicensePageReqVO.class);
|
pageReqVO = BeanUtils.toBean(exportReqVO, LicensePageReqVO.class);
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
}
|
}
|
||||||
List<LicenseRespVO> voList = licenseService.getLicensePage(pageReqVO).getList();
|
List<LicensePageRespVO> voList = licenseService.getLicensePage(pageReqVO).getList();
|
||||||
|
|
||||||
// List<LicenseRespVO> results = new ArrayList<>();
|
// List<LicenseRespVO> results = new ArrayList<>();
|
||||||
// for (LicenseRespVO license : voList) {
|
// for (LicenseRespVO license : voList) {
|
||||||
@@ -184,7 +185,7 @@ public class LicenseController {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.writeSelected(response, "", pageReqVO.getSheetName(), LicenseRespVO.class,
|
ExcelUtils.writeSelected(response, "", pageReqVO.getSheetName(), LicensePageRespVO.class,
|
||||||
TranslateUtils.translate(voList), pageReqVO.getIncludeFields());
|
TranslateUtils.translate(voList), pageReqVO.getIncludeFields());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
package org.agt.module.license.controller.admin.license.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.fhs.core.trans.vo.VO;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.agt.framework.excel.core.annotations.DictFormat;
|
||||||
|
import org.agt.framework.excel.core.convert.DictConvert;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - License Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class LicensePageRespVO implements VO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25585")
|
||||||
|
// @ExcelProperty("主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "客户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31667")
|
||||||
|
// @Trans(type = TransType.SIMPLE, target = CustomerDO.class, fields = "name", ref = "customerName")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
@Schema(description = "客户名称")
|
||||||
|
@ExcelProperty("客户名称")
|
||||||
|
private String customerName;
|
||||||
|
|
||||||
|
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2496")
|
||||||
|
// @Trans(type = TransType.SIMPLE, target = ProjectDO.class, fields = "name", ref = "projectName")
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
@Schema(description = "项目名称")
|
||||||
|
@ExcelProperty("项目名称")
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
@Schema(description = "sn", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("SN")
|
||||||
|
private String serialNo;
|
||||||
|
|
||||||
|
@Schema(description = "到期时间")
|
||||||
|
private LocalDateTime expiryDate;
|
||||||
|
|
||||||
|
@Schema(description = "到期时间导出")
|
||||||
|
@ExcelProperty("到期时间")
|
||||||
|
private LocalDate expiryDateExt;
|
||||||
|
|
||||||
|
@Schema(description = "网元")
|
||||||
|
@ExcelProperty("网元")
|
||||||
|
private String neListStr;
|
||||||
|
|
||||||
|
@Schema(description = "激活码")
|
||||||
|
@ExcelProperty("激活码")
|
||||||
|
private String activationCode;
|
||||||
|
|
||||||
|
@Schema(description = "网元激活码列表")
|
||||||
|
private List<LicenseDetailVO> neCodeList;
|
||||||
|
|
||||||
|
@Schema(description = "用户数")
|
||||||
|
@ExcelProperty("用户数")
|
||||||
|
private Integer userNumber;
|
||||||
|
|
||||||
|
@Schema(description = "基站数")
|
||||||
|
@ExcelProperty("基站数")
|
||||||
|
private Integer ranNumber;
|
||||||
|
|
||||||
|
@Schema(description = "文件URL")
|
||||||
|
// @ExcelProperty("文件URL")
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
@Schema(description = "申请人ID")
|
||||||
|
// @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "applicantName")
|
||||||
|
private Long applicant;
|
||||||
|
|
||||||
|
@Schema(description = "申请人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("申请人")
|
||||||
|
private String applicantName;
|
||||||
|
|
||||||
|
@Schema(description = "审批人")
|
||||||
|
// @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "approverName")
|
||||||
|
private Long approver;
|
||||||
|
|
||||||
|
@Schema(description = "审批人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("审批人")
|
||||||
|
private String approverName;
|
||||||
|
|
||||||
|
@Schema(description = "状态", example = "1")
|
||||||
|
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||||
|
@DictFormat("lic_license_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
@ExcelProperty("说明")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
// @ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "申请时间")
|
||||||
|
@ExcelProperty("申请时间")
|
||||||
|
private LocalDateTime applicationTime;
|
||||||
|
|
||||||
|
@Schema(description = "license申请次数")
|
||||||
|
@ExcelProperty("申请次数")
|
||||||
|
private Integer applyCount;
|
||||||
|
|
||||||
|
@Schema(description = "数据类型")
|
||||||
|
private Integer dataType;
|
||||||
|
|
||||||
|
private LicensePageRespVO oldLicense;
|
||||||
|
|
||||||
|
private boolean hasHistory;
|
||||||
|
}
|
||||||
@@ -2,15 +2,11 @@ package org.agt.module.license.controller.admin.project.vo;
|
|||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.fhs.core.trans.anno.Trans;
|
|
||||||
import com.fhs.core.trans.constant.TransType;
|
|
||||||
import com.fhs.core.trans.vo.VO;
|
import com.fhs.core.trans.vo.VO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.agt.framework.excel.core.annotations.DictFormat;
|
import org.agt.framework.excel.core.annotations.DictFormat;
|
||||||
import org.agt.framework.excel.core.convert.DictConvert;
|
import org.agt.framework.excel.core.convert.DictConvert;
|
||||||
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
|
|
||||||
import org.agt.module.system.api.user.AdminUserApi;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@@ -24,7 +20,7 @@ public class ProjectRespVO implements VO {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "客户ID")
|
@Schema(description = "客户ID")
|
||||||
@Trans(type = TransType.SIMPLE, target = CustomerDO.class, fields = "name", ref = "customerName")
|
// @Trans(type = TransType.SIMPLE, target = CustomerDO.class, fields = "name", ref = "customerName")
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
@Schema(description = "客户名称")
|
@Schema(description = "客户名称")
|
||||||
@@ -57,19 +53,19 @@ public class ProjectRespVO implements VO {
|
|||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "业务负责人ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "业务负责人ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "businessOwnerName")
|
// @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "businessOwnerName")
|
||||||
private Long businessOwner;
|
private Long businessOwner;
|
||||||
|
|
||||||
@Schema(description = "技术负责人1ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "技术负责人1ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "technicalOwnerAName")
|
// @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "technicalOwnerAName")
|
||||||
private Long technicalOwnerA;
|
private Long technicalOwnerA;
|
||||||
|
|
||||||
@Schema(description = "技术负责人2ID")
|
@Schema(description = "技术负责人2ID")
|
||||||
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "technicalOwnerBName")
|
// @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "technicalOwnerBName")
|
||||||
private Long technicalOwnerB;
|
private Long technicalOwnerB;
|
||||||
|
|
||||||
@Schema(description = "技术负责人3ID")
|
@Schema(description = "技术负责人3ID")
|
||||||
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "technicalOwnerCName")
|
// @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "technicalOwnerCName")
|
||||||
private Long technicalOwnerC;
|
private Long technicalOwnerC;
|
||||||
|
|
||||||
@Schema(description = "业务负责人", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "业务负责人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.agt.module.license.controller.admin.license.vo.LicenseCodeImportExcel
|
|||||||
import org.agt.module.license.controller.admin.license.vo.LicenseDetailVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseDetailVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseImportExcelVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseImportExcelVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicensePageReqVO;
|
import org.agt.module.license.controller.admin.license.vo.LicensePageReqVO;
|
||||||
|
import org.agt.module.license.controller.admin.license.vo.LicensePageRespVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseRespVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseRespVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseSaveReqVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseSaveReqVO;
|
||||||
import org.agt.module.license.dal.dataobject.license.LicenseDetailDO;
|
import org.agt.module.license.dal.dataobject.license.LicenseDetailDO;
|
||||||
@@ -80,7 +81,7 @@ public interface LicenseService {
|
|||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return License分页
|
* @return License分页
|
||||||
*/
|
*/
|
||||||
PageResult<LicenseRespVO> getLicensePage(LicensePageReqVO pageReqVO);
|
PageResult<LicensePageRespVO> getLicensePage(LicensePageReqVO pageReqVO);
|
||||||
|
|
||||||
List<LicenseRespVO> getLicenseByExpiryDate();
|
List<LicenseRespVO> getLicenseByExpiryDate();
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.agt.module.license.controller.admin.license.vo.LicenseCodeImportExcel
|
|||||||
import org.agt.module.license.controller.admin.license.vo.LicenseDetailVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseDetailVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseImportExcelVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseImportExcelVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicensePageReqVO;
|
import org.agt.module.license.controller.admin.license.vo.LicensePageReqVO;
|
||||||
|
import org.agt.module.license.controller.admin.license.vo.LicensePageRespVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseRespVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseRespVO;
|
||||||
import org.agt.module.license.controller.admin.license.vo.LicenseSaveReqVO;
|
import org.agt.module.license.controller.admin.license.vo.LicenseSaveReqVO;
|
||||||
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
|
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
|
||||||
@@ -616,16 +617,16 @@ public class LicenseServiceImpl implements LicenseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<LicenseRespVO> getLicensePage(LicensePageReqVO pageReqVO) {
|
public PageResult<LicensePageRespVO> getLicensePage(LicensePageReqVO pageReqVO) {
|
||||||
if (StrUtil.isNotBlank(pageReqVO.getSortField())) {
|
if (StrUtil.isNotBlank(pageReqVO.getSortField())) {
|
||||||
pageReqVO.setSortField(StrUtil.toUnderlineCase(pageReqVO.getSortField()));
|
pageReqVO.setSortField(StrUtil.toUnderlineCase(pageReqVO.getSortField()));
|
||||||
}
|
}
|
||||||
IPage<LicenseRespVO> page = licenseMapper.queryPage(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
|
IPage<LicenseRespVO> page = licenseMapper.queryPage(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
|
||||||
|
|
||||||
PageResult<LicenseRespVO> voPageResult = BeanUtils.toBean(new PageResult<>(page.getRecords(), page.getTotal()), LicenseRespVO.class);
|
PageResult<LicensePageRespVO> voPageResult = BeanUtils.toBean(new PageResult<>(page.getRecords(), page.getTotal()), LicensePageRespVO.class);
|
||||||
for (LicenseRespVO licenseRespVO : voPageResult.getList()) {
|
// for (LicenseRespVO licenseRespVO : voPageResult.getList()) {
|
||||||
fillLicenseRespVO(licenseRespVO);
|
// fillLicenseRespVO(licenseRespVO);
|
||||||
}
|
// }
|
||||||
return voPageResult;
|
return voPageResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,33 @@
|
|||||||
l.update_time,
|
l.update_time,
|
||||||
l.deleted,
|
l.deleted,
|
||||||
l.tenant_id,
|
l.tenant_id,
|
||||||
|
p.`name` project_name,
|
||||||
|
c.`name` customer_name,
|
||||||
|
al.nickname applicant_name,
|
||||||
|
ar.nickname approver_name,
|
||||||
|
ifnull( lh.apply_count, 1 ) apply_count,
|
||||||
p.customer_id
|
p.customer_id
|
||||||
FROM
|
FROM
|
||||||
crm_license_server l
|
crm_license_server l
|
||||||
LEFT JOIN crm_project p ON l.project_id = p.id
|
LEFT JOIN crm_project p ON l.project_id = p.id
|
||||||
AND p.deleted = 0
|
AND p.deleted = 0
|
||||||
|
LEFT JOIN crm_customer c ON p.customer_id = c.id
|
||||||
|
AND c.deleted = 0
|
||||||
|
LEFT JOIN system_users al ON l.applicant = al.id
|
||||||
|
AND al.deleted = 0
|
||||||
|
LEFT JOIN system_users ar ON l.approver = ar.id
|
||||||
|
AND ar.deleted = 0
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
lh.license_id,
|
||||||
|
count( lh.license_id ) + 1 apply_count
|
||||||
|
FROM
|
||||||
|
crm_license_server_history lh
|
||||||
|
WHERE
|
||||||
|
lh.deleted = 0
|
||||||
|
GROUP BY
|
||||||
|
lh.license_id
|
||||||
|
) lh ON l.id = lh.license_id
|
||||||
WHERE
|
WHERE
|
||||||
l.deleted = 0
|
l.deleted = 0
|
||||||
<if test="query.customerId != null">
|
<if test="query.customerId != null">
|
||||||
|
|||||||
@@ -88,10 +88,22 @@
|
|||||||
SELECT
|
SELECT
|
||||||
p.*,
|
p.*,
|
||||||
l.serial_no,
|
l.serial_no,
|
||||||
|
cu.`name` customer_name,
|
||||||
|
bo.nickname business_owner_name,
|
||||||
|
toa.nickname technical_owner_a_name,
|
||||||
|
tob.nickname technical_owner_b_name,
|
||||||
ifnull( pc.comment_num, 0 ) comment_num,
|
ifnull( pc.comment_num, 0 ) comment_num,
|
||||||
ifnull( pl.apply_count, 0 ) apply_count
|
ifnull( pl.apply_count, 0 ) apply_count
|
||||||
FROM
|
FROM
|
||||||
crm_project p
|
crm_project p
|
||||||
|
LEFT JOIN crm_customer cu ON p.customer_id = cu.id
|
||||||
|
AND cu.deleted = 0
|
||||||
|
LEFT JOIN system_users bo ON p.business_owner = bo.id
|
||||||
|
AND bo.deleted = 0
|
||||||
|
LEFT JOIN system_users toa ON p.technical_owner_a = toa.id
|
||||||
|
AND toa.deleted = 0
|
||||||
|
LEFT JOIN system_users tob ON p.technical_owner_b = tob.id
|
||||||
|
AND tob.deleted = 0
|
||||||
LEFT JOIN ( SELECT project_id, GROUP_CONCAT( serial_no ) serial_no FROM crm_license_server WHERE deleted = 0 GROUP BY project_id ) l ON p.id = l.project_id
|
LEFT JOIN ( SELECT project_id, GROUP_CONCAT( serial_no ) serial_no FROM crm_license_server WHERE deleted = 0 GROUP BY project_id ) l ON p.id = l.project_id
|
||||||
LEFT JOIN ( SELECT c.project_id, count( c.id ) comment_num FROM crm_comment c WHERE c.deleted = 0 GROUP BY c.project_id ) pc ON p.id = pc.project_id
|
LEFT JOIN ( SELECT c.project_id, count( c.id ) comment_num FROM crm_comment c WHERE c.deleted = 0 GROUP BY c.project_id ) pc ON p.id = pc.project_id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
|
|||||||
Reference in New Issue
Block a user