Commit 3c091ebf by 阳浪

4.21bug优化

parent 61b3b930
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
<select id="apiListResearch" resultType="com.yizhi.research.application.vo.domain.Research"> <select id="apiListResearch" resultType="com.yizhi.research.application.vo.domain.Research">
<if test="state == 1"> <if test="state == 1">
select * select *
from (select answer.submit_time as submitTime, from (select distinct answer.submit_time as submitTime,
tb.id AS id tb.id AS id
,answer.submit_time as finishTime ,answer.submit_time as finishTime
,tb.research_no AS researchNo ,tb.research_no AS researchNo
...@@ -136,12 +136,11 @@ ...@@ -136,12 +136,11 @@
) )
-- 已完成条件过滤 -- 已完成条件过滤
and <![CDATA[ tb.end_time > #{now} ]]> and answer.id is not null and answer.finish = 1 and <![CDATA[ tb.end_time > #{now} ]]> and answer.id is not null and answer.finish = 1
group by tb.id
)t )t
order by t.create_time desc,t.submitTime desc order by t.create_time desc,t.submitTime desc
</if> </if>
<if test="state == 2"> <if test="state == 2">
select select distinct
answer.submit_time as submitTime, answer.submit_time as submitTime,
tb.id AS id tb.id AS id
,answer.submit_time as finishTime ,answer.submit_time as finishTime
...@@ -174,13 +173,12 @@ ...@@ -174,13 +173,12 @@
-- 进行中条件过滤 -- 进行中条件过滤
and <![CDATA[ tb.end_time > #{now} ]]>and <![CDATA[ tb.start_time < #{now} ]]> and ( answer.id is null or and <![CDATA[ tb.end_time > #{now} ]]>and <![CDATA[ tb.start_time < #{now} ]]> and ( answer.id is null or
answer.finish = 0) answer.finish = 0)
group by tb.id
order by tb.create_time desc,tb.end_time order by tb.create_time desc,tb.end_time
</if> </if>
<if test="state == null"> <if test="state == null">
select * select *
from (select answer.submit_time as submitTime, from (select distinct answer.submit_time as submitTime,
CASE WHEN <![CDATA[ tb.start_time > NOW() ]]> THEN 0 ELSE CASE WHEN <![CDATA[ tb.start_time > NOW() ]]> THEN 0 ELSE
CASE WHEN <![CDATA[ tb.start_time >= NOW() ]]> AND answerf.finish IS NULL THEN 4 ELSE CASE WHEN <![CDATA[ tb.start_time >= NOW() ]]> AND answerf.finish IS NULL THEN 4 ELSE
CASE WHEN answerf.finish=1 THEN 1 ELSE CASE WHEN answerf.finish=1 THEN 1 ELSE
...@@ -209,7 +207,7 @@ ...@@ -209,7 +207,7 @@
tb.create_time tb.create_time
from research tb from research tb
left join tr_research_answer answer on answer.research_id = tb.id and answer.account_id = #{accountId} and answer.finish=1 left join tr_research_answer answer on answer.research_id = tb.id and answer.account_id = #{accountId} and answer.finish=1
left join tr_research_answer answerf on answer.research_id = tb.id and answerf.account_id = #{accountId} and answerf.finish in(0,1) left join tr_research_answer answerf on answer.research_id = tb.id and answerf.account_id = #{accountId} and answerf.finish=0
where where
-- 状态、站点 -- 状态、站点
tb.deleted = 0 and tb.site_id = #{siteId} and tb.state = 1 tb.deleted = 0 and tb.site_id = #{siteId} and tb.state = 1
...@@ -223,7 +221,6 @@ ...@@ -223,7 +221,6 @@
<if test="bizType != null"> <if test="bizType != null">
and tb.biz_type=#{bizType} and tb.biz_type=#{bizType}
</if> </if>
group by tb.id
)t )t
order by t.create_time desc,t.endTime desc,id order by t.create_time desc,t.endTime desc,id
</if> </if>
...@@ -232,7 +229,7 @@ ...@@ -232,7 +229,7 @@
<!-- 查询进行中的我的调研 --> <!-- 查询进行中的我的调研 -->
<select id="apiCountResearch" resultType="Integer"> <select id="apiCountResearch" resultType="Integer">
select count(*) from( select count(*) from(
select select distinct
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from research tb from research tb
left join tr_research_answer answer on answer.research_id = tb.id and answer.account_id = #{accountId} left join tr_research_answer answer on answer.research_id = tb.id and answer.account_id = #{accountId}
...@@ -249,14 +246,13 @@ ...@@ -249,14 +246,13 @@
-- 进行中条件过滤 -- 进行中条件过滤
and <![CDATA[ tb.end_time > #{now} ]]>and <![CDATA[ tb.start_time < #{now} ]]> and( answer.id is null or and <![CDATA[ tb.end_time > #{now} ]]>and <![CDATA[ tb.start_time < #{now} ]]> and( answer.id is null or
answer.finish = 0) answer.finish = 0)
group by tb.id
)r )r
</select> </select>
<!-- 搜索调研 --> <!-- 搜索调研 -->
<select id="apiSearchPage" resultType="com.yizhi.research.application.vo.domain.Research"> <select id="apiSearchPage" resultType="com.yizhi.research.application.vo.domain.Research">
select * from( select * from(
select (case when answer.submit_time>0 then 1 else 0 end) as finishState,tb.id AS id select distinct (case when answer.submit_time>0 then 1 else 0 end) as finishState,tb.id AS id
,answer.submit_time as finishTime,count(answer.id) as realCount ,answer.submit_time as finishTime,count(answer.id) as realCount
,tb.research_no AS researchNo ,tb.research_no AS researchNo
,tb.name AS name ,tb.name AS name
...@@ -283,7 +279,6 @@ ...@@ -283,7 +279,6 @@
(<foreach collection="idsInRange" separator="," item="id">#{id}</foreach>)) (<foreach collection="idsInRange" separator="," item="id">#{id}</foreach>))
</if> </if>
) )
group by tb.id
)t )t
order by t.finishState,t.endTime order by t.finishState,t.endTime
</select> </select>
...@@ -357,7 +352,7 @@ ...@@ -357,7 +352,7 @@
select count(*) from( select count(*) from(
<if test="state == 1"> <if test="state == 1">
select * select *
from (select answer.submit_time as submitTime, from (select distinct answer.submit_time as submitTime,
tb.id AS id tb.id AS id
,answer.submit_time as finishTime ,answer.submit_time as finishTime
,tb.research_no AS researchNo ,tb.research_no AS researchNo
...@@ -386,14 +381,13 @@ ...@@ -386,14 +381,13 @@
) )
-- 已完成条件过滤 -- 已完成条件过滤
and <![CDATA[ tb.end_time > #{now} ]]> and answer.id is not null and answer.finish = 1 and <![CDATA[ tb.end_time > #{now} ]]> and answer.id is not null and answer.finish = 1
group by tb.id
)t )t
order by t.create_time desc order by t.create_time desc
-- order by t.submitTime desc -- order by t.submitTime desc
</if> </if>
<if test="state == 2"> <if test="state == 2">
select select distinct
answer.submit_time as submitTime, answer.submit_time as submitTime,
tb.id AS id tb.id AS id
,answer.submit_time as finishTime ,answer.submit_time as finishTime
...@@ -424,15 +418,41 @@ ...@@ -424,15 +418,41 @@
-- 进行中条件过滤 -- 进行中条件过滤
and <![CDATA[ tb.end_time > #{now} ]]>and <![CDATA[ tb.start_time < #{now} ]]> and ( answer.id is null or and <![CDATA[ tb.end_time > #{now} ]]>and <![CDATA[ tb.start_time < #{now} ]]> and ( answer.id is null or
answer.finish = 0) answer.finish = 0)
group by tb.id
order by tb.create_time desc order by tb.create_time desc
-- order by tb.end_time -- order by tb.end_time
</if> </if>
<if test="state == null"> <if test="state == null">
select select distinct answer.submit_time as submitTime,
tb.id AS id CASE WHEN <![CDATA[ tb.start_time > NOW() ]]> THEN 0 ELSE
CASE WHEN <![CDATA[ tb.start_time >= NOW() ]]> AND answerf.finish IS NULL THEN 4 ELSE
CASE WHEN answerf.finish=1 THEN 1 ELSE
CASE WHEN <![CDATA[ tb.end_time < NOW() ]]> THEN 3 ELSE
2
END
END
END
END AS finishState
,tb.id AS id
,answer.submit_time as finishTime
,tb.research_no AS researchNo
,tb.name AS name
,tb.start_time AS startTime
,tb.end_time AS endTime
,tb.visible_range AS visibleRange
,tb.content AS content
,tb.state AS state
,tb.deleted AS deleted
,tb.company_id AS companyId
,tb.org_id AS orgId
,tb.site_id AS siteId
,tb.image
,tb.biz_type
,tb.page_mode,
tb.create_time
from research tb from research tb
left join tr_research_answer answer on answer.research_id = tb.id and answer.account_id = #{accountId} and answer.finish=1
left join tr_research_answer answerf on answer.research_id = tb.id and answerf.account_id = #{accountId} and answerf.finish=0
where where
-- 状态、站点 -- 状态、站点
tb.deleted = 0 and tb.site_id = #{siteId} and tb.state = 1 tb.deleted = 0 and tb.site_id = #{siteId} and tb.state = 1
...@@ -446,7 +466,6 @@ ...@@ -446,7 +466,6 @@
<if test="bizType != null"> <if test="bizType != null">
and tb.biz_type=#{bizType} and tb.biz_type=#{bizType}
</if> </if>
group by tb.id
order by tb.create_time desc order by tb.create_time desc
</if> </if>
)ttt )ttt
...@@ -598,7 +617,7 @@ ...@@ -598,7 +617,7 @@
</select> </select>
<select id="selectResearchDetails" resultType="com.yizhi.research.application.vo.domain.ResearchVo"> <select id="selectResearchDetails" resultType="com.yizhi.research.application.vo.domain.ResearchVo">
select answer.submit_time as submitTime, select distinct answer.submit_time as submitTime,
CASE WHEN <![CDATA[ tb.start_time > NOW() ]]> THEN 0 ELSE CASE WHEN <![CDATA[ tb.start_time > NOW() ]]> THEN 0 ELSE
CASE WHEN <![CDATA[ tb.start_time >= NOW() ]]> AND answerf.finish IS NULL THEN 4 ELSE CASE WHEN <![CDATA[ tb.start_time >= NOW() ]]> AND answerf.finish IS NULL THEN 4 ELSE
CASE WHEN answerf.finish=1 THEN 1 ELSE CASE WHEN answerf.finish=1 THEN 1 ELSE
...@@ -622,8 +641,7 @@ ...@@ -622,8 +641,7 @@
,tb.biz_type ,tb.biz_type
from research tb from research tb
left join tr_research_answer answer on answer.research_id = tb.id and answer.account_id = #{accountId} and answer.finish=1 left join tr_research_answer answer on answer.research_id = tb.id and answer.account_id = #{accountId} and answer.finish=1
left join tr_research_answer answerf on answer.research_id = tb.id and answerf.account_id = #{accountId} and answerf.finish in(0,1) left join tr_research_answer answerf on answer.research_id = tb.id and answerf.account_id = #{accountId} and answerf.finish=0
where tb.id=#{id} and tb.deleted = 0 and tb.site_id = #{siteId} where tb.id=#{id} and tb.deleted = 0 and tb.site_id = #{siteId}
group by tb.id
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment