|
@@ -899,15 +899,16 @@ public class RepairBillDaoImpl extends GenericDaoHibernate<RepairBill, Long> imp
|
|
|
}
|
|
|
sql.append(" com.`name` centerName, ");
|
|
|
sql.append(" orgId,org.`name` orgName, ");
|
|
|
- sql.append(" AVG(c.star) avgStar, ");
|
|
|
- sql.append(" sum(CASE WHEN c.star = 1 THEN 1 ELSE 0 END ) oneStar, ");
|
|
|
- sql.append(" sum(CASE WHEN c.star = 2 THEN 1 ELSE 0 END ) twoStar, ");
|
|
|
- sql.append(" sum(CASE WHEN c.star = 3 THEN 1 ELSE 0 END ) threeStar, ");
|
|
|
- sql.append(" sum(CASE WHEN c.star = 4 THEN 1 ELSE 0 END ) fourStar, ");
|
|
|
- sql.append(" sum(CASE WHEN c.star = 5 THEN 1 ELSE 0 END ) fiveStar ");
|
|
|
+ sql.append(" ROUND(AVG(IF(IFNULL(c.star,0) > IFNULL(rd.star,0),c.star,rd.star)),2) avgStar, ");
|
|
|
+ sql.append(" sum(CASE WHEN IF(IFNULL(c.star,0) > IFNULL(rd.star,0),c.star,rd.star) = 1 THEN 1 ELSE 0 END ) oneStar, ");
|
|
|
+ sql.append(" sum(CASE WHEN IF(IFNULL(c.star,0) > IFNULL(rd.star,0),c.star,rd.star) = 2 THEN 1 ELSE 0 END ) twoStar, ");
|
|
|
+ sql.append(" sum(CASE WHEN IF(IFNULL(c.star,0) > IFNULL(rd.star,0),c.star,rd.star) = 3 THEN 1 ELSE 0 END ) threeStar, ");
|
|
|
+ sql.append(" sum(CASE WHEN IF(IFNULL(c.star,0) > IFNULL(rd.star,0),c.star,rd.star) = 4 THEN 1 ELSE 0 END ) fourStar, ");
|
|
|
+ sql.append(" sum(CASE WHEN IF(IFNULL(c.star,0) > IFNULL(rd.star,0),c.star,rd.star) = 5 THEN 1 ELSE 0 END ) fiveStar ");
|
|
|
sql.append(" FROM ");
|
|
|
sql.append(" tb_repair_bills t ");
|
|
|
sql.append(" LEFT JOIN tb_repair_bill_comments c on c.bill_id = t.id ");
|
|
|
+ sql.append(" LEFT JOIN tb_repair_return_visits rd on rd.bill_id = t.id ");
|
|
|
sql.append(" LEFT JOIN tb_organization org on org.ID=t.orgId ");
|
|
|
sql.append(" LEFT JOIN tr_company_org co ON co.org_id = t.orgId ");
|
|
|
sql.append(" LEFT JOIN tb_company com on com.id = co.company_id ");
|