Commit 57192da0 by jianan

PEP得分查询bug修复及优化

parent 0f652e37
package com.yd.api.practitioner.vo.sechedule;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.practitioner.PersonalPEPScore;
import lombok.Data;
import java.util.List;
......@@ -8,7 +9,7 @@ import java.util.Map;
@Data
public class QueryPEPScoreResponseVO {
private Map<String, String> average;
private List<Map<String, Object>> personalList;
private Map<String, Object> average;
private List<PersonalPEPScore> personalList;
private CommonResult commonResult;
}
package com.yd.dal.entity.practitioner;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PersonalPEPScore {
private Long practitionerId;
private String name;
private Long dayScore;
private Long weekScore;
private Long monthScore;
private BigDecimal FYC;
private Double rate;
}
package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.practitioner.PersonalPEPScore;
import com.yd.dal.entity.practitioner.PersonalSchedule;
import com.yd.dal.entity.practitioner.ScheduleTrack;
import org.apache.ibatis.annotations.Param;
......@@ -17,8 +18,8 @@ public interface ScheduleTrackMapper {
int checkTimePeriodConflict(@Param("taskTimeFrom")String taskTimeFrom, @Param("taskTimeEnd")String taskTimeEnd,
@Param("practitionerId")Long practitionerId);
List<Map<String, Object>> querySaleRecuitScoreFYC(@Param("practitionerId")Long practitionerId, @Param("firstDay")Date firstDay,
@Param("lastDay")Date lastDay);
List<PersonalPEPScore> querySaleRecuitScoreFYC(@Param("practitionerId")Long practitionerId, @Param("firstDay")Date firstDay,
@Param("lastDay")Date lastDay);
List<Map<String, Object>> queryOtherScore(@Param("practitionerId")Long practitionerId);
......
......@@ -87,23 +87,23 @@
</select>
<select id="querySaleRecuitScoreFYC" resultType="hashmap">
SELECT practitioner_id, dayScore, weekScore, monthScore, COALESCE(fyc,0) FYC
<select id="querySaleRecuitScoreFYC" resultType="com.yd.dal.entity.practitioner.PersonalPEPScore">
SELECT practitionerId, name, dayScore, weekScore, monthScore, COALESCE(fyc,0) FYC
FROM
(select practitioner_id,
sum(case when to_days(created_at) = to_days(now()) then COALESCE(track_score,0) else 0 end) dayScore,
sum(case when YEARWEEK(date_format(created_at,'%Y-%m-%d'),1) = YEARWEEK(now(),1) then COALESCE(track_score,0) else 0 end) weekScore,
sum(case when date_format(created_at,'%Y-%m')=date_format(now(),'%Y-%m') then COALESCE(track_score,0) else 0 end) monthScore
from ag_mkt_schedule_task_tracking
where is_active = 1
and practitioner_id in (SELECT id from ag_acl_practitioner
where subordinate_system_id =
(select subordinate_system_id from ag_acl_practitioner where id = #{practitionerId,jdbcType=BIGINT})
)
and md_drop_option_id not in (223,224,225,226,227)
and created_at between #{firstDay,jdbcType=TIMESTAMP}
and #{lastDay,jdbcType=TIMESTAMP}
group by practitioner_id
(select p.id practitionerId,
p.name,
sum(case when to_days(t.created_at) = to_days(now()) then COALESCE(t.track_score,0) else 0 end) dayScore,
sum(case when YEARWEEK(date_format(t.created_at,'%Y-%m-%d'),1) = YEARWEEK(now(),1) then COALESCE(t.track_score,0) else 0 end) weekScore,
sum(case when date_format(t.created_at,'%Y-%m')=date_format(now(),'%Y-%m') then COALESCE(t.track_score,0) else 0 end) monthScore
from ag_acl_practitioner p
left join (select practitioner_id, created_at, track_score
from ag_mkt_schedule_task_tracking where md_drop_option_id not in (223,224,225,226,227)
) t on p.id = t.practitioner_id
left join ag_acl_practitioner_subordinate_system s on s.id = p.subordinate_system_id
where s.owner_practitioner_id = #{practitionerId,jdbcType=BIGINT}
and s.is_active=1
and p.is_active=1
group by p.id
) s
LEFT JOIN
(select t.customer_id, sum(t.fyc_amount) fyc
......@@ -116,7 +116,8 @@
and #{lastDay,jdbcType=TIMESTAMP}
group by t.customer_id
) fyc
ON s.practitioner_id = fyc.customer_id
ON s.practitionerId = fyc.customer_id
ORDER BY dayScore desc, weekScore desc, monthScore desc
</select>
<select id="queryTeamAllPractitionerId" resultType="Long">
......
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