浏览代码

优化查询效率

hxl13994548489 1 年之前
父节点
当前提交
77e8594d1e

+ 17 - 1
src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java

@@ -1536,7 +1536,23 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
     @Override
     public BasePageResult<InsOrders> queryPageOrderByLinkType(OrderQueryVo orderQueryVo, int type) {
         //添加收回按钮的操作
-
+        //优化查询效率   add by hxl  2025-01-25
+        if(StringUtils.isNotBlank(orderQueryVo.getQuoteStartDateStr()) && StringUtils.isNotBlank(orderQueryVo.getQuoteEndDateStr())){
+            if(orderQueryVo.getQuoteStartDateStr().length()==10){
+                orderQueryVo.setQuoteStartDateStr(orderQueryVo.getQuoteStartDateStr()+" 00:00:00");
+            }
+            if(orderQueryVo.getQuoteEndDateStr().length()==10){
+                orderQueryVo.setQuoteEndDateStr(orderQueryVo.getQuoteEndDateStr()+" 23:59:59");
+            }
+        }
+        if(StringUtils.isNotBlank(orderQueryVo.getSignStartDateStr()) && StringUtils.isNotBlank(orderQueryVo.getSignEndDateStr())){
+            if(orderQueryVo.getSignStartDateStr().length()==10){
+                orderQueryVo.setSignStartDateStr(orderQueryVo.getSignStartDateStr()+" 00:00:00");
+            }
+            if(orderQueryVo.getSignEndDateStr().length()==10){
+                orderQueryVo.setSignEndDateStr(orderQueryVo.getSignEndDateStr()+" 23:59:59");
+            }
+        }
         Boolean flag = false;
         Page<InsOrders> page = new Page<>(orderQueryVo.getPageNum(), orderQueryVo.getPageSize());
         page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询

+ 4 - 4
src/main/resources/mapper/modules/order/InsOrdersMapper.xml

@@ -1034,7 +1034,7 @@
                 and REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') = #{orderQueryVo.insuredName}
             </if>
             <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
-                and  DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{orderQueryVo.quoteStartDateStr} AND #{orderQueryVo.quoteEndDateStr}
+                and  iac.createtime >= #{orderQueryVo.quoteStartDateStr} AND  iac.createtime <![CDATA[ <= ]]> #{orderQueryVo.quoteEndDateStr}
             </if>
             <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
                 and iac.company_id = #{orderQueryVo.companyId}
@@ -1097,7 +1097,7 @@
                 </when>
             </choose>
             <if test="orderQueryVo.signStartDateStr != null and orderQueryVo.signEndDateStr != null">
-                and  DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{orderQueryVo.signStartDateStr} AND #{orderQueryVo.signEndDateStr}
+                and  iac.signing_time >= #{orderQueryVo.signStartDateStr} AND  iac.signing_time <![CDATA[ <= ]]> #{orderQueryVo.signEndDateStr}
             </if>
             <if test="orderQueryVo.entryStatus != null and orderQueryVo.entryStatus != ''">
                 and io.entry_status = #{orderQueryVo.entryStatus }
@@ -1197,7 +1197,7 @@
                 and REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') = #{orderQueryVo.insuredName}
             </if>
             <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
-                and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{orderQueryVo.quoteStartDateStr} AND #{orderQueryVo.quoteEndDateStr}
+                and iac.createtime >= #{orderQueryVo.quoteStartDateStr} AND iac.createtime  <![CDATA[ <= ]]> #{orderQueryVo.quoteEndDateStr}
             </if>
             <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
                 and iac.company_id = #{orderQueryVo.companyId}
@@ -1260,7 +1260,7 @@
                 </when>
             </choose>
             <if test="orderQueryVo.signStartDateStr != null and orderQueryVo.signEndDateStr != null">
-                and  DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{orderQueryVo.signStartDateStr} AND #{orderQueryVo.signEndDateStr}
+                and  iac.signing_time >= #{orderQueryVo.signStartDateStr} AND   iac.signing_time <![CDATA[ <= ]]> #{orderQueryVo.signEndDateStr}
             </if>
             <if test="orderQueryVo.entryStatus != null and orderQueryVo.entryStatus != ''">
                 and io.entry_status = #{orderQueryVo.entryStatus }