1.修改分页逻辑,增加SQL性能分析插件

master
x_z 3 years ago
parent 065577e40b
commit f501525bdf

@ -105,6 +105,14 @@
<version>${mybatis-plus.version}</version>
</dependency>
<!--SQL性能分析插件-->
<dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>3.9.1</version>
</dependency>
<!--自动生成 GET SET-->
<dependency>
<groupId>org.projectlombok</groupId>

@ -3,7 +3,6 @@ package com.glxp.udi.admin.controller.info;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
import com.glxp.udi.admin.common.res.BaseResponse;
import com.glxp.udi.admin.entity.info.PlatformEntity;
@ -123,7 +122,7 @@ public class PlatformController {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
Page<PlatformLinkResponse> page = platformService.getLinkPlatformList(platformLinkRequest);
IPage<PlatformLinkResponse> page = platformService.getLinkPlatformList(platformLinkRequest);
PageSimpleResponse<PlatformLinkResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(page.getRecords());

@ -1,6 +1,7 @@
package com.glxp.udi.admin.controller.inout;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
import com.glxp.udi.admin.common.res.BaseResponse;
@ -306,7 +307,7 @@ public class StockQRCodeTextController {
SystemPDFTemplateRelevanceRequest systemPDFTemplateRelevanceRequest = new SystemPDFTemplateRelevanceRequest();
systemPDFTemplateRelevanceRequest.setLocalAction(orderMdEntity.getAction());
systemPDFTemplateRelevanceRequest.setModuleId(inspectionPDFTemplateRequest.getModuleId());
Page<SystemPDFTemplateRelevanceResponse> page = systemPDFTemplateRelevanceService.filterList(systemPDFTemplateRelevanceRequest);
IPage<SystemPDFTemplateRelevanceResponse> page = systemPDFTemplateRelevanceService.filterList(systemPDFTemplateRelevanceRequest);
if (page.getTotal() == 0) {
return ResultVOUtils.error(ResultEnum.DATA_NOT, "未找到模板文件");
} else {
@ -335,7 +336,7 @@ public class StockQRCodeTextController {
SystemPDFTemplateRelevanceRequest systemPDFTemplateRelevanceRequest = new SystemPDFTemplateRelevanceRequest();
systemPDFTemplateRelevanceRequest.setModuleId(systemPDFModuleEntity.getId());
systemPDFTemplateRelevanceRequest.setLocalAction(list.get(0).getBillType());
Page<SystemPDFTemplateRelevanceResponse> page = systemPDFTemplateRelevanceService.filterList(systemPDFTemplateRelevanceRequest);
IPage<SystemPDFTemplateRelevanceResponse> page = systemPDFTemplateRelevanceService.filterList(systemPDFTemplateRelevanceRequest);
if (page.getTotal() == 0) {
return;
}

@ -97,7 +97,7 @@ public class SystemPDFModuleController {
systemPDFTemplateRelevanceService.insert(systemPDFTemplateRelevanceEntity);
}
Page<SystemPDFTemplateRelevanceResponse> systemPDFTemplateRelevanceResponsePage = systemPDFTemplateRelevanceService.filterList(systemPDFModuleRequest);
IPage<SystemPDFTemplateRelevanceResponse> systemPDFTemplateRelevanceResponsePage = systemPDFTemplateRelevanceService.filterList(systemPDFModuleRequest);
pageSimpleResponse.setList(systemPDFTemplateRelevanceResponsePage.getRecords());
pageSimpleResponse.setTotal(systemPDFTemplateRelevanceResponsePage.getTotal());
}

@ -1,9 +1,9 @@
package com.glxp.udi.admin.dao.info;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.entity.info.PlatformEntity;
import com.glxp.udi.admin.req.info.PlatformLinkRequest;
import com.glxp.udi.admin.res.info.PlatformLinkResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -34,7 +34,7 @@ public interface PlatformDao extends BaseMapper<PlatformEntity> {
* @param platformLinkRequest
* @return
*/
Page<PlatformLinkResponse> getLinkPlatformList(Page<PlatformLinkResponse> page, @Param("platformLinkRequest") PlatformLinkRequest platformLinkRequest);
IPage<PlatformLinkResponse> getLinkPlatformList(IPage<PlatformLinkResponse> page, String customerId, String key);
/**
*

@ -14,8 +14,6 @@ public interface SystemPDFModuleDao extends BaseMapper<SystemPDFModuleEntity> {
Page<SystemPDFModuleEntity> listPDFModules(Page<SystemPDFModuleEntity> page);
SystemPDFModuleEntity findSystemPDFModule(SystemPDFModuleRequest systemPDFModuleRequest);
SystemPDFModuleEntity selectById(String id);
boolean updateById(SystemPDFModuleSaveRequest systemPDFModuleSaveRequest);

@ -1,7 +1,7 @@
package com.glxp.udi.admin.dao.param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.glxp.udi.admin.entity.param.SystemPDFTemplateRelevanceEntity;
import com.glxp.udi.admin.req.itextpdf.SystemPDFTemplateRelevanceRequest;
import com.glxp.udi.admin.res.param.SystemPDFTemplateRelevanceResponse;
@ -14,8 +14,6 @@ import java.util.List;
public interface SystemPDFTemplateRelevanceDao extends BaseMapper<SystemPDFTemplateRelevanceEntity> {
Page<SystemPDFTemplateRelevanceResponse> filterList(Page<SystemPDFTemplateRelevanceResponse> page, SystemPDFTemplateRelevanceRequest systemPDFModuleRequest);
/**
* customerId
*
@ -59,4 +57,9 @@ public interface SystemPDFTemplateRelevanceDao extends BaseMapper<SystemPDFTempl
boolean deleteById(Integer id);
boolean udpateRl(SystemPDFTemplateRelevanceEntity systemPDFTemplateRelevanceEntity);
IPage<SystemPDFTemplateRelevanceResponse> filterList(IPage<SystemPDFTemplateRelevanceResponse> page, Integer moduleId, String localAction, String customerId);
List<SystemPDFTemplateRelevanceResponse> filterAll(SystemPDFTemplateRelevanceRequest systemPDFTemplateRelevanceRequest);
}

@ -1,5 +1,6 @@
package com.glxp.udi.admin.entity.param;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -29,10 +30,13 @@ public class SystemPDFModuleEntity {
private Integer templateType;
@TableField(exist = false)
private String remark1;
@TableField(exist = false)
private String remark2;
@TableField(exist = false)
private String remark3;
}

@ -14,7 +14,7 @@ public class SystemPDFModuleRequest extends ListPageRequest {
private String name;
private String param;
private String fieldExplain;
private int templateId;
private Integer templateId;
private String remark;
private Date create_time;
private Date update_time;

@ -103,13 +103,13 @@ public class PlatformService {
* @param customerId
* @return
*/
public Page<PlatformLinkResponse> getLinkPlatformList(PlatformLinkRequest platformLinkRequest) {
public IPage<PlatformLinkResponse> getLinkPlatformList(PlatformLinkRequest platformLinkRequest) {
if (null == platformLinkRequest) {
return new Page<>();
}
Page<PlatformLinkResponse> page = new Page<>(platformLinkRequest.getPage(), platformLinkRequest.getLimit());
return platformDao.getLinkPlatformList(page, platformLinkRequest);
IPage<PlatformLinkResponse> page = new Page<>(platformLinkRequest.getPage(), platformLinkRequest.getLimit());
return platformDao.getLinkPlatformList(page, platformLinkRequest.getCustomerId(), platformLinkRequest.getKey());
}
/**

@ -1,5 +1,7 @@
package com.glxp.udi.admin.service.param;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.dao.param.SystemPDFModuleDao;
import com.glxp.udi.admin.entity.param.SystemPDFModuleEntity;
@ -21,7 +23,10 @@ public class SystemPDFModuleService {
public Page<SystemPDFModuleEntity> queryPage(SystemPDFModuleRequest systemPDFModuleRequest) {
Page<SystemPDFModuleEntity> page = new Page<>(systemPDFModuleRequest.getPage(), systemPDFModuleRequest.getLimit());
return systemPDFModuleDao.queryPage(page, systemPDFModuleRequest);
QueryWrapper<SystemPDFModuleEntity> wrapper = new QueryWrapper<>();
wrapper.like(null != systemPDFModuleRequest.getTemplateId(), "templateId", systemPDFModuleRequest.getTemplateId())
.like(StrUtil.isNotBlank(systemPDFModuleRequest.getName()), "name", systemPDFModuleRequest.getName());
return systemPDFModuleDao.selectPage(page, wrapper);
}
public Page<SystemPDFModuleEntity> listPDFModules(Integer page, Integer limit) {
@ -37,7 +42,6 @@ public class SystemPDFModuleService {
}
public boolean updateById(SystemPDFModuleSaveRequest systemPDFModuleSaveRequest) {
return systemPDFModuleDao.updateById(systemPDFModuleSaveRequest);
}

@ -1,5 +1,6 @@
package com.glxp.udi.admin.service.param;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.dao.param.SystemPDFTemplateRelevanceDao;
import com.glxp.udi.admin.entity.param.SystemPDFTemplateRelevanceEntity;
@ -21,15 +22,21 @@ public class SystemPDFTemplateRelevanceService {
@Resource
private SystemPDFTemplateRelevanceDao systemPDFTemplateRelevanceDao;
public Page<SystemPDFTemplateRelevanceResponse> filterList(SystemPDFTemplateRelevanceRequest systemPDFModuleRequest) {
public IPage<SystemPDFTemplateRelevanceResponse> filterList(SystemPDFTemplateRelevanceRequest systemPDFModuleRequest) {
if (null == systemPDFModuleRequest) {
return new Page<>();
}
Page<SystemPDFTemplateRelevanceResponse> page = new Page<>(-1, -1);
if (null != systemPDFModuleRequest.getPage() && null != systemPDFModuleRequest.getLimit()) {
page = new Page<>(systemPDFModuleRequest.getPage(), systemPDFModuleRequest.getLimit());
IPage<SystemPDFTemplateRelevanceResponse> page = new Page<>(systemPDFModuleRequest.getPage(), systemPDFModuleRequest.getLimit());
return systemPDFTemplateRelevanceDao.filterList(page, systemPDFModuleRequest.getModuleId(), systemPDFModuleRequest.getLocalAction(), systemPDFModuleRequest.getCustomerId());
} else {
List<SystemPDFTemplateRelevanceResponse> responses = systemPDFTemplateRelevanceDao.filterAll(systemPDFModuleRequest);
IPage<SystemPDFTemplateRelevanceResponse> page = new Page<>();
page.setTotal(responses.size());
page.setRecords(responses);
return page;
}
return systemPDFTemplateRelevanceDao.filterList(page, systemPDFModuleRequest);
}
/**

@ -6,6 +6,7 @@ spring:
url: jdbc:mysql://192.168.235.137:3306/udims?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
data:
mongodb:
uri: mongodb://192.168.0.66:27017/udiwms

@ -1,5 +1,6 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/udims?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: mysql@2020

@ -3,9 +3,11 @@ spring:
pathmatch:
matching-strategy: ant_path_matcher
datasource:
url: jdbc:mysql://192.168.0.66:3360/udims?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
url: jdbc:p6spy:mysql://192.168.0.66:3360/udims?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
data:
mongodb:
uri: mongodb://192.168.0.66:27017/udiwms

@ -4,8 +4,7 @@ server:
spring:
profiles:
active: test
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis-plus:
mapperPackage: com.glxp.udi.admin.dao.*

@ -85,12 +85,12 @@
from io_unit_maintain u
left join auth_platform p on u.platformId = p.id
<where>
customerId = #{platformLinkRequest.customerId}
customerId = #{customerId}
and platformId is not null
<if test="param1.key != null and param1.key != ''">
AND (u.unitId like concat('%', #{param1.key}, '%')
or u.name like concat('%', #{param1.key}, '%')
or u.pinyinCode like concat('%', #{param1.key}, '%')
<if test="key != null and key != ''">
AND (u.unitId like concat('%', #{key}, '%')
or u.name like concat('%', #{key}, '%')
or u.pinyinCode like concat('%', #{key}, '%')
)
</if>
</where>

@ -16,11 +16,6 @@
</where>
</select>
<select id="findSystemPDFModule" parameterType="com.glxp.udi.admin.req.param.SystemPDFModuleRequest"
resultType="com.glxp.udi.admin.entity.param.SystemPDFModuleEntity">
SELECT * FROM system_pdf_module WHERE id=#{id}
</select>
<select id="selectById" parameterType="java.lang.String"
resultType="com.glxp.udi.admin.entity.param.SystemPDFModuleEntity">
select * FROM system_pdf_module WHERE id = #{id}

@ -23,7 +23,7 @@
on system_pdf_template_relevance.templateId = system_pdf_template.id
<where>
<if test="moduleId != null">
AND `moduleId` = #{moduleId}
AND system_pdf_template_relevance.`moduleId` = #{moduleId}
</if>
<if test="localAction != null">
AND system_pdf_template_relevance.`localAction` = #{localAction}
@ -34,6 +34,31 @@
</where>
</select>
<select id="filterAll" parameterType="com.glxp.udi.admin.req.itextpdf.SystemPDFTemplateRelevanceRequest"
resultType="com.glxp.udi.admin.res.param.SystemPDFTemplateRelevanceResponse">
select basic_bussiness_type.`name` localActionName,system_pdf_template_relevance.id,
basic_bussiness_type.action localAction,
templateId,
moduleId,
system_pdf_template_relevance.remark1, system_pdf_template_relevance.remark2,system_pdf_template_relevance.remark3,
system_pdf_template.name templateName
from basic_bussiness_type
LEFT JOIN system_pdf_template_relevance
on basic_bussiness_type.action = system_pdf_template_relevance.localAction
LEFT JOIN system_pdf_template
on system_pdf_template_relevance.templateId = system_pdf_template.id
<where>
<if test="moduleId != null">
AND system_pdf_template_relevance.`moduleId` = #{moduleId}
</if>
<if test="localAction != null">
AND system_pdf_template_relevance.`localAction` = #{localAction}
</if>
<if test="customerId != null and customerId != ''">
AND basic_bussiness_type.customerId = #{customerId}
</if>
</where>
</select>
<select id="listByCustomerIdIn" resultType="com.glxp.udi.admin.entity.param.SystemPDFTemplateRelevanceEntity">
SELECT *

@ -0,0 +1,24 @@
#3.2.1以上使用
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
#3.2.1以下使用或者不配置
#modulelist=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
# 自定义日志打印
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
#日志输出到控制台
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
# 使用日志系统记录 sql
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
# 设置 p6spy driver 代理
deregisterdrivers=true
# 取消JDBC URL前缀
useprefix=true
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
excludecategories=info,debug,result,commit,resultset
# 日期格式
dateformat=yyyy-MM-dd HH:mm:ss
# 实际驱动可多个
#driverlist=org.h2.Driver
# 是否开启慢SQL记录
outagedetection=true
# 慢SQL记录标准 2 秒
outagedetectioninterval=2
Loading…
Cancel
Save