Quellcode durchsuchen

feature SQL优化

xiahan vor 9 Monaten
Ursprung
Commit
5593d954c4

+ 10 - 6
cx-aps/cx-aps-common/src/main/resources/mybatis/ApsProcessOperationProcessEquDao.xml

@@ -178,7 +178,7 @@
         DATE(a3.PROMISEDATESTART) AS PROMISEDATESTART,
         DATE(a3.PROMISEDATEEND) AS PROMISEDATEEND,
         DATE(a3.DELIVERYDATE) AS DELIVERYDATE,
-        (SELECT GROUP_CONCAT( a4.PRODUCTNAME )  FROM aps_process_output_product a4 WHERE a4.DELETED = '0' and  a3.ID = a4.BLANKID GROUP BY a4.BLANKID) PRODUCTNAME ,
+        a3.PRODUCTNAME ,
         a6.ID AS productionorderid,
         a6.ORDERNO,
         a6.CUSTOMNAME,
@@ -192,14 +192,13 @@
         a3.PLANHAVEMATERIALDATE as planhavematerialdate,
         a2.SINGLEROLLWEIGHT,
         a2.SINGLEROLLWEIGHT * a1.PLANPROCESSRALL as totalRollWeight
-
         FROM
         (SELECT
         a3.*,
         GROUP_CONCAT( a4.PRODUCTNAME ) as PRODUCTNAME
         FROM
         aps_blank_order a3
-        LEFT JOIN aps_process_output_product a4 FORCE INDEX(aps_process_output_product_idx)  on a3.ID=a4.BLANKID
+        LEFT JOIN aps_process_output_product a4 FORCE INDEX(aps_process_output_product_idx) on a3.ID=a4.BLANKID
         WHERE
         a4.DELETED = '0'
         GROUP BY
@@ -207,8 +206,13 @@
         LEFT JOIN aps_production_order a6 ON a3.PRODUCTIONORDERID = a6.ID
         LEFT JOIN aps_customer_management a7 ON a6.CUSTOMID = a7.ID
         LEFT JOIN aps_process_operation a2 ON a3.ID= a2.BLANKID
-        LEFT JOIN aps_process_operation_process_equ a1 FORCE INDEX (aps_process_operation_process_equ_idx2) ON a1.PROCESSID = a2.ID
+        LEFT JOIN aps_process_operation_process_equ a1 FORCE INDEX (aps_process_operation_process_equ_idx2) ON
+        a1.PROCESSID = a2.ID
         <where>
+            <if test="factoryId != null and factoryId != '' and factoryId != 'ALL'">
+                and a1.TENANTID = #{factoryId}
+                and a3.TENANTID= #{factoryId}
+            </if>
             a3.SCHEDULINGSTATUS != '10'
             and a1.DELETED ='0'
             AND a2.DELETED = '0'
@@ -244,7 +248,7 @@
                 <bind name="pattern" value="'%' + equName + '%'"/>
                 and a1.PROCESSDEVICE like #{pattern}
             </if>
-            <if test="factoryId != null and factoryId != '' and factoryId != 'ALL'">and a1.TENANTID = #{factoryId}</if>
+
             <if test="startTime != null and endTime != null ">
                 and not (a1.PLANSTARTDATE &gt; #{endTime} or a1.PLANENDDATE &lt; #{startTime})
             </if>
@@ -254,7 +258,7 @@
                 and a3.BLANKNUMBER like #{blankNumberPattern}
             </if>
         </where>
-#         order by a1.PROCESSWORKSHOP,a1.PROCESSDEVICE,a1.PLANSTARTDATE asc,a1.PLANENDDATE desc
+        # order by a1.PROCESSWORKSHOP,a1.PROCESSDEVICE,a1.PLANSTARTDATE asc,a1.PLANENDDATE desc
     </select>
     <select id="selectNeedUpdate" resultType="com.rongwei.bsentity.vo.CommonUpdateProductionStatusReq">
         SELECT