فهرست منبع

开心灵工订单列表查询接口(不分页)-sql调整,优化查询

ZhangWenQiang 5 سال پیش
والد
کامیت
e7c7dec7ac

+ 4 - 12
happy-cloud-wisdom/happy-cloud-wisdom-biz/src/main/java/org/jeecg/modules/hlworder/mapper/xml/HlwOrderMapper.xml

@@ -85,19 +85,13 @@
 
     <select id="queryOrderListNoPage" resultType="org.jeecg.modules.hlworder.entity.HlwOrder">
         SELECT
-        t.*,
-        case when count(usId) = (SELECT count(su.id) from hlw_subcontractor su ) then 1 ELSE 0 end as "contractStatus"
-        FROM
-        (
-        SELECT
-        a.*, us.id as "usId"
+        a.order_code, case when count(us.id) = (SELECT count(su.id) from hlw_subcontractor su ) then 1 ELSE 0 end as "contractStatus"
         FROM hlw_order a
         LEFT JOIN hlw_requirement r ON r.id = a.requirement_id
         LEFT JOIN hlw_company com ON com.id = r.company_id
         left join hlw_user_subcontractor us on us.order_code = a.order_code
         <where>
-            1=1
-            and r.application_id = #{applicationId}
+            r.application_id = #{applicationId}
             <if test="companyCodeList != null and companyCodeList.size() != 0">
                 and com.company_code in
                 <foreach collection="companyCodeList" index="index" item="code" open="(" separator="," close=")">
@@ -123,13 +117,11 @@
                 and a.create_time between #{hlwOrder.createTime_begin} and #{hlwOrder.createTime_end}
             </if>
         </where>
-        ORDER BY a.update_time DESC, a.id ASC
-        ) t
-        GROUP BY t.id
+        GROUP BY a.id
         <if test="hlwOrder.contractStatus != null ">
             HAVING contractStatus = #{hlwOrder.contractStatus}
         </if>
-        ORDER BY t.update_time DESC, t.id ASC
+        ORDER BY a.update_time DESC, a.id ASC
     </select>