Commit 3adadf98 by jianan

dashboard-17

parent 365d4984
......@@ -234,33 +234,9 @@
) as level,
</otherwise>
</choose>
<choose>
<when test="time.equalsIgnoreCase('D')">
sum(case when to_days(o.underwriting_date)=to_days(now()) then o.order_price else 0 end) fyp,
sum(case when to_days(o.underwriting_date)=to_days(now()) then o.fyc_amount else 0 end) fyc,
sum(case when to_days(o.underwriting_date)=to_days(now()) then 1 else 0 end) pieces
</when>
<when test="time.equalsIgnoreCase('W')">
sum(case when YEARWEEK(date_format(o.underwriting_date, '%Y-%m-%d')) = YEARWEEK(now()) then o.order_price else 0 end) fyp,
sum(case when YEARWEEK(date_format(o.underwriting_date, '%Y-%m-%d')) = YEARWEEK(now()) then o.fyc_amount else 0 end) fyc,
sum(case when YEARWEEK(date_format(o.underwriting_date, '%Y-%m-%d')) = YEARWEEK(now()) then 1 else 0 end) pieces
</when>
<when test="time.equalsIgnoreCase('M')">
sum(case when date_format(o.underwriting_date, '%Y-%m') = date_format(now(), '%Y-%m') then o.order_price else 0 end) fyp,
sum(case when date_format(o.underwriting_date, '%Y-%m') = date_format(now(), '%Y-%m') then o.fyc_amount else 0 end) fyc,
sum(case when date_format(o.underwriting_date, '%Y-%m') = date_format(now(), '%Y-%m') then 1 else 0 end) pieces
</when>
<when test="time.equalsIgnoreCase('Q')">
sum(case when QUARTER(o.underwriting_date) = QUARTER(now()) and year(o.underwriting_date)=year(now()) then o.order_price else 0 end) fyp,
sum(case when QUARTER(o.underwriting_date) = QUARTER(now()) and year(o.underwriting_date)=year(now()) then o.fyc_amount else 0 end) fyc,
sum(case when QUARTER(o.underwriting_date) = QUARTER(now()) and year(o.underwriting_date)=year(now()) then 1 else 0 end) pieces
</when>
<when test="time.equalsIgnoreCase('Y')">
sum(case when YEAR(o.underwriting_date) = YEAR(now()) then o.order_price else 0 end) fyp,
sum(case when YEAR(o.underwriting_date) = YEAR(now()) then o.fyc_amount else 0 end) fyc,
sum(case when YEAR(o.underwriting_date) = YEAR(now()) then 1 else 0 end) pieces
</when>
</choose>
concat(ifnull(sum(o.order_price),0),'') as fyp,
concat(ifnull(sum(o.fyc_amount),0),'') as fyc,
ifnull(count(o.id),0) as pieces
from ag_acl_practitioner p
INNER JOIN ag_acl_life_insurance_practitioner lip ON lip.practitioner_id= p.id
INNER JOIN ag_po_order o ON o.policy_no = lip.policy_no
......@@ -276,6 +252,23 @@
</when>
</choose>
<choose>
<when test="time.equalsIgnoreCase('D')">
and TO_DAYS(o.underwriting_date) = TO_DAYS(now())
</when>
<when test="time.equalsIgnoreCase('W')">
and YEARWEEK(DATE_FORMAT(o.underwriting_date,'%Y-%m-%d')) = YEARWEEK(NOW())
</when>
<when test="time.equalsIgnoreCase('M')">
and DATE_FORMAT(o.underwriting_date, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when test="time.equalsIgnoreCase('Q')">
and QUARTER(o.underwriting_date) = QUARTER(NOW()) AND year(o.underwriting_date)=year(now())
</when>
<otherwise>
and YEAR(o.underwriting_date) = YEAR(now())
</otherwise>
</choose>
<choose>
<when test="type.equalsIgnoreCase('B')">
group by p.insurer_branch_id
</when>
......@@ -300,33 +293,9 @@
where s.id=#{item.id}
) as level,
<choose>
<when test="time.equalsIgnoreCase('D')">
ifnull(sum(case when to_days(o.underwriting_date)=to_days(now()) then o.order_price else 0 end), 0) fyp,
ifnull(sum(case when to_days(o.underwriting_date)=to_days(now()) then o.fyc_amount else 0 end), 0) fyc,
ifnull(sum(case when to_days(o.underwriting_date)=to_days(now()) then 1 else 0 end), 0) pieces
</when>
<when test="time.equalsIgnoreCase('W')">
ifnull(sum(case when YEARWEEK(date_format(o.underwriting_date, '%Y-%m-%d')) = YEARWEEK(now()) then o.order_price else 0 end), 0) fyp,
ifnull(sum(case when YEARWEEK(date_format(o.underwriting_date, '%Y-%m-%d')) = YEARWEEK(now()) then o.fyc_amount else 0 end), 0) fyc,
ifnull(sum(case when YEARWEEK(date_format(o.underwriting_date, '%Y-%m-%d')) = YEARWEEK(now()) then 1 else 0 end), 0) pieces
</when>
<when test="time.equalsIgnoreCase('M')">
ifnull(sum(case when date_format(o.underwriting_date, '%Y-%m') = date_format(now(), '%Y-%m') then o.order_price else 0 end), 0) fyp,
ifnull(sum(case when date_format(o.underwriting_date, '%Y-%m') = date_format(now(), '%Y-%m') then o.fyc_amount else 0 end), 0) fyc,
ifnull(sum(case when date_format(o.underwriting_date, '%Y-%m') = date_format(now(), '%Y-%m') then 1 else 0 end), 0) pieces
</when>
<when test="time.equalsIgnoreCase('Q')">
ifnull(sum(case when QUARTER(o.underwriting_date) = QUARTER(now()) and year(o.underwriting_date)=year(now()) then o.order_price else 0 end), 0) fyp,
ifnull(sum(case when QUARTER(o.underwriting_date) = QUARTER(now()) and year(o.underwriting_date)=year(now()) then o.fyc_amount else 0 end), 0) fyc,
ifnull(sum(case when QUARTER(o.underwriting_date) = QUARTER(now()) and year(o.underwriting_date)=year(now()) then 1 else 0 end), 0) pieces
</when>
<when test="time.equalsIgnoreCase('Y')">
ifnull(sum(case when YEAR(o.underwriting_date) = YEAR(now()) then o.order_price else 0 end), 0) fyp,
ifnull(sum(case when YEAR(o.underwriting_date) = YEAR(now()) then o.fyc_amount else 0 end), 0) fyc,
ifnull(sum(case when YEAR(o.underwriting_date) = YEAR(now()) then 1 else 0 end), 0) pieces
</when>
</choose>
ifnull(sum(o.order_price),0) as fyp,
ifnull(sum(o.fyc_amount),0) as fyc,
ifnull(count(o.id),0) as pieces
from ag_acl_practitioner p
INNER JOIN ag_acl_life_insurance_practitioner lip ON lip.practitioner_id= p.id
INNER JOIN ag_po_order o ON o.policy_no = lip.policy_no
......@@ -342,6 +311,23 @@
and o.product_category_id not in (2,5,8)
</when>
</choose>
<choose>
<when test="time.equalsIgnoreCase('D')">
and TO_DAYS(o.underwriting_date) = TO_DAYS(now())
</when>
<when test="time.equalsIgnoreCase('W')">
and YEARWEEK(DATE_FORMAT(o.underwriting_date,'%Y-%m-%d')) = YEARWEEK(NOW())
</when>
<when test="time.equalsIgnoreCase('M')">
and DATE_FORMAT(o.underwriting_date, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when test="time.equalsIgnoreCase('Q')">
and QUARTER(o.underwriting_date) = QUARTER(NOW()) AND year(o.underwriting_date)=year(now())
</when>
<otherwise>
and YEAR(o.underwriting_date) = YEAR(now())
</otherwise>
</choose>
</if>
</foreach>
order by 4 desc
......
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