|  |  | @ -428,10 +428,10 @@ | 
			
		
	
		
			
				
					|  |  |  |         ) agency ON grid.PID = agency.ID | 
			
		
	
		
			
				
					|  |  |  |        WHERE | 
			
		
	
		
			
				
					|  |  |  |            grid.del_flag = 0 | 
			
		
	
		
			
				
					|  |  |  |        AND | 
			
		
	
		
			
				
					|  |  |  |            grid.area_code LIKE CONCAT(#{areaCode},'%') | 
			
		
	
		
			
				
					|  |  |  |        AND | 
			
		
	
		
			
				
					|  |  |  |            grid.customer_id = #{customerId} | 
			
		
	
		
			
				
					|  |  |  |             <if test='areaCode != "" and areaCode != null'> | 
			
		
	
		
			
				
					|  |  |  |                AND grid.area_code LIKE CONCAT(#{areaCode},'%') | 
			
		
	
		
			
				
					|  |  |  |             </if> | 
			
		
	
		
			
				
					|  |  |  |             AND grid.customer_id = #{customerId} | 
			
		
	
		
			
				
					|  |  |  |        ORDER BY | 
			
		
	
		
			
				
					|  |  |  |            grid.customer_id, | 
			
		
	
		
			
				
					|  |  |  |            CONVERT ( gridName USING gbk ) ASC | 
			
		
	
	
		
			
				
					|  |  | @ -443,7 +443,6 @@ | 
			
		
	
		
			
				
					|  |  |  |         SELECT | 
			
		
	
		
			
				
					|  |  |  |             c.* | 
			
		
	
		
			
				
					|  |  |  |         FROM | 
			
		
	
		
			
				
					|  |  |  |         ( | 
			
		
	
		
			
				
					|  |  |  |             ( | 
			
		
	
		
			
				
					|  |  |  |                 SELECT | 
			
		
	
		
			
				
					|  |  |  |                     a.id AS grid_id, | 
			
		
	
	
		
			
				
					|  |  | @ -468,45 +467,9 @@ | 
			
		
	
		
			
				
					|  |  |  |                 ) agency ON a.PID = agency.ID | 
			
		
	
		
			
				
					|  |  |  |                 WHERE | 
			
		
	
		
			
				
					|  |  |  |                     a.del_flag = 0 | 
			
		
	
		
			
				
					|  |  |  |                 AND a.area_code = #{areaCode} | 
			
		
	
		
			
				
					|  |  |  |                 AND a.customer_id = #{customerId} | 
			
		
	
		
			
				
					|  |  |  |                 ORDER BY | 
			
		
	
		
			
				
					|  |  |  |                   CONVERT ( gridName USING gbk ) ASC | 
			
		
	
		
			
				
					|  |  |  |                 LIMIT 0,999999999999 | 
			
		
	
		
			
				
					|  |  |  |             ) | 
			
		
	
		
			
				
					|  |  |  |             UNION | 
			
		
	
		
			
				
					|  |  |  |             ( | 
			
		
	
		
			
				
					|  |  |  |                 SELECT | 
			
		
	
		
			
				
					|  |  |  |                 b.id AS grid_id, | 
			
		
	
		
			
				
					|  |  |  |                 b.customer_id, | 
			
		
	
		
			
				
					|  |  |  |                 concat(agency.fullname , '-' ,b.grid_name) as gridName | 
			
		
	
		
			
				
					|  |  |  |                 FROM | 
			
		
	
		
			
				
					|  |  |  |                 CUSTOMER_GRID b | 
			
		
	
		
			
				
					|  |  |  |                 LEFT JOIN ( | 
			
		
	
		
			
				
					|  |  |  |                     SELECT | 
			
		
	
		
			
				
					|  |  |  |                         a1.id, | 
			
		
	
		
			
				
					|  |  |  |                         CASE | 
			
		
	
		
			
				
					|  |  |  |                         WHEN a2.ORGANIZATION_NAME IS NULL THEN | 
			
		
	
		
			
				
					|  |  |  |                         a1.ORGANIZATION_NAME ELSE concat( a2.ORGANIZATION_NAME, '-', a1.ORGANIZATION_NAME ) | 
			
		
	
		
			
				
					|  |  |  |                         END AS fullname | 
			
		
	
		
			
				
					|  |  |  |                     FROM | 
			
		
	
		
			
				
					|  |  |  |                         customer_agency a1 | 
			
		
	
		
			
				
					|  |  |  |                     LEFT JOIN customer_agency a2 ON a1.PID = a2.ID | 
			
		
	
		
			
				
					|  |  |  |                         AND a1.del_flag = '0' | 
			
		
	
		
			
				
					|  |  |  |                     WHERE | 
			
		
	
		
			
				
					|  |  |  |                         a1.del_flag = '0' | 
			
		
	
		
			
				
					|  |  |  |                     AND a1.customer_id = #{customerId} | 
			
		
	
		
			
				
					|  |  |  |                 ) agency ON b.PID = agency.ID | 
			
		
	
		
			
				
					|  |  |  |                 WHERE | 
			
		
	
		
			
				
					|  |  |  |                     b.del_flag = 0 | 
			
		
	
		
			
				
					|  |  |  |                 AND b.customer_id = #{customerId} | 
			
		
	
		
			
				
					|  |  |  |                 AND b.area_code LIKE CONCAT(#{cityCode},'%') | 
			
		
	
		
			
				
					|  |  |  |                 AND  <![CDATA[ b.area_code <> #{areaCode}]]> | 
			
		
	
		
			
				
					|  |  |  |                 ORDER BY | 
			
		
	
		
			
				
					|  |  |  |                     b.area_code DESC ,CONVERT ( gridName USING gbk ) ASC | 
			
		
	
		
			
				
					|  |  |  |                 LIMIT 0,999999999999 | 
			
		
	
		
			
				
					|  |  |  |             ) | 
			
		
	
		
			
				
					|  |  |  |         ) AS c | 
			
		
	
		
			
				
					|  |  |  |                     AND a.customer_id = #{customerId} | 
			
		
	
		
			
				
					|  |  |  |             ) AS c | 
			
		
	
		
			
				
					|  |  |  |          ORDER BY  CONVERT ( gridName USING gbk ) ASC | 
			
		
	
		
			
				
					|  |  |  |         LIMIT #{pageNo}, #{pageSize} | 
			
		
	
		
			
				
					|  |  |  |     </select> | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 |