Ver código fonte

跟进查询bug

xiewd 5 dias atrás
pai
commit
539a126d72

+ 71 - 12
RuoYi-Vue-fast-master/src/main/resources/mybatis/business/TcFollowMapper.xml

@@ -178,18 +178,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <sql id="test">
-      select * from (
-        SELECT DISTINCT
-        follow_id,
-        business_id,
-        follow_type
-        FROM
-        tc_follow
-        where
-        del_flag = '0'
-        ORDER BY id DESC
-        ) temp
-        Group by business_id,follow_type
+        SELECT main.follow_id
+        FROM (
+        SELECT t1.follow_id,
+        CASE t1.follow_type
+        WHEN '0' THEN
+        t4.lead_no
+        WHEN '1' THEN
+        t5.account_no
+        ELSE t6.project_no
+        END AS business_no,
+        su.nick_name AS follower,
+        CASE t1.follow_type
+        WHEN '0' THEN
+        t4.country_id
+        WHEN '1' THEN
+        t5.country_id
+        ELSE t6.country_id
+        END AS country_id
+        from
+        tc_follow AS t1
+        LEFT JOIN tc_lead AS t4 ON t4.lead_id = t1.business_id AND t1.follow_type = '0'
+        LEFT JOIN tc_account AS t5 ON t5.account_id = t1.business_id AND t1.follow_type = '1'
+        LEFT JOIN tc_project AS t6 ON t6.project_id = t1.business_id AND t1.follow_type = '2'
+        LEFT JOIN sys_user su ON su.user_id = t1.create_by
+        inner join (SELECT p.premession_char FROM (SELECT @premessionStr:= #{permissionChar} p) param ,
+        getpremessionview_chars p
+        ) permission on permission.premession_char = t1.permission_char
+        <where>
+            <if test="loginUserId != null  and loginUserId != ''">
+                and (t1.permission_char &lt;&gt; #{permissionChar} or t1.create_by = #{loginUserId})
+            </if>
+            <if test="followTypeArray != null  and followTypeArray.length != 0">
+                and t1.follow_type in
+                <foreach item="type" collection="followTypeArray" open="(" separator="," close=")">
+                    #{type}
+                </foreach>
+            </if>
+            <if test="followNo != null  and followNo != ''"> and t1.follow_no like CONCAT('%', #{followNo},'%')  escape '/' </if>
+            <if test="beginTime != null and beginTime != ''">
+                and date_format(t1.follow_time,'%Y%m%d') &gt;= date_format(#{beginTime},'%Y%m%d')
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and date_format(t1.follow_time,'%Y%m%d') &lt;= date_format(#{endTime},'%Y%m%d')
+            </if>
+            <if test="followPerson != null  and followPerson != ''"> and t1.follow_person like CONCAT('%', #{followPerson},'%')  escape '/'</if>
+            <if test="followWayArray != null  and followWayArray.length > 0">
+                and t1.follow_way in
+                <foreach item="way" collection="followWayArray" open="(" separator="," close=")">
+                    #{way}
+                </foreach>
+            </if>
+            <if test="contactPerson != null  and contactPerson != ''"> and t1.contact_person like CONCAT('%', #{contactPerson},'%')  escape '/'</if>
+            <if test="contact != null  and contact != ''"> and t1.contact = #{contact}</if>
+            <if test="followDesc != null  and followDesc != ''"> and t1.follow_desc like CONCAT('%', #{followDesc},'%')  escape '/' </if>
+
+        </where>
+        ) main
+        <where>
+        <if test="businessNo != null "> and main.business_no like CONCAT('%', #{businessNo},'%')  escape '/' </if>
+        <if test="follower != null  and follower != ''"> and t1.follower like CONCAT('%', #{follower},'%')  escape '/' </if>
+
+        <if test="countries != null and countries.size() > 0">
+            and t1.country_id in
+            <foreach item="countryId" collection="countries" open="(" separator="," close=")">
+                #{countryId}
+            </foreach>
+        </if>
+        </where>
+        GROUP BY main.business_no
     </sql>
 
     <sql id="test2">
@@ -200,6 +257,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         getpremessionview_chars p
         ) permission on permission.premession_char = t1.permission_char
         <where>
+            t1.del_flag = 0
             <if test="loginUserId != null  and loginUserId != ''">
                 and (t1.permission_char &lt;&gt; #{permissionChar} or t1.create_by = #{loginUserId})
             </if>
@@ -230,6 +288,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         GROUP BY business_id,follow_type
     </sql>
+
     <select id="selectTcFollowList" parameterType="com.ruoyi.project.business.domain.TcFollow" resultMap="TcFollowResultForList">
         <include refid="selectTcFollowVo2"/>