|
@@ -888,4 +888,64 @@ public class RepairBillDaoImpl extends GenericDaoHibernate<RepairBill, Long> imp
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page getBillCommentList(Map<String, Object> conditions,int type,int pageNo, int pageSize) {
|
|
|
+
|
|
|
+ StringBuilder sql=new StringBuilder("");
|
|
|
+
|
|
|
+ sql.append(" SELECT ");
|
|
|
+ if(conditions.get("dateString") != null && StringUtils.isNotEmpty(conditions.get("dateString").toString())){
|
|
|
+ sql.append(" '"+conditions.get("dateString")+"' dateInfo, ");
|
|
|
+ }
|
|
|
+ sql.append(" com.`name`, ");
|
|
|
+ sql.append(" orgId,org.`name`, ");
|
|
|
+ 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(" 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_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 ");
|
|
|
+ sql.append(" WHERE 1=1 and c.star is not null ");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (conditions.get("centerId") != null && StringUtils.isNotEmpty(conditions.get("centerId").toString())) {
|
|
|
+ sql.append(" and com.id = "+conditions.get("centerId"));
|
|
|
+ }
|
|
|
+ if (conditions.get("orgId") != null && StringUtils.isNotEmpty(conditions.get("orgId").toString())) {
|
|
|
+ sql.append(" and r.orgId = "+conditions.get("orgId"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (1 == type && conditions.get("date") != null && StringUtils.isNotEmpty(conditions.get("date").toString())) {
|
|
|
+ sql.append(" and year(t.create_time) = "+conditions.get("date"));
|
|
|
+ }else if (2 == type && conditions.get("date") != null && StringUtils.isNotEmpty(conditions.get("date").toString())
|
|
|
+ && conditions.get("endDate") != null && StringUtils.isNotEmpty(conditions.get("endDate").toString())) {
|
|
|
+ sql.append(" and year(t.create_time) = "+conditions.get("date"));
|
|
|
+ sql.append(" and QUARTER(t.create_time) = "+conditions.get("endDate"));
|
|
|
+ }else if (3 == type && conditions.get("date") != null && StringUtils.isNotEmpty(conditions.get("date").toString())
|
|
|
+ && conditions.get("endDate") != null && StringUtils.isNotEmpty(conditions.get("endDate").toString())) {
|
|
|
+ sql.append(" and year(t.create_time) = "+conditions.get("date"));
|
|
|
+ sql.append(" and month(t.create_time) = "+conditions.get("endDate"));
|
|
|
+ }else if (4 == type && conditions.get("date") != null && StringUtils.isNotEmpty(conditions.get("date").toString())) {
|
|
|
+ sql.append(" and DATE_FORMAT(t.create_time,'%Y-%m-%d') >= '"+conditions.get("date")+"'");
|
|
|
+ if(conditions.get("endDate") != null && StringUtils.isNotEmpty(conditions.get("endDate").toString())){
|
|
|
+ sql.append(" and DATE_FORMAT(t.create_time,'%Y-%m-%d') <= '"+conditions.get("endDate")+"'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ sql.append(" GROUP BY orgId ");
|
|
|
+
|
|
|
+ log.info(sql.toString());
|
|
|
+ return pagedQueryByJdbcTemplate(sql.toString(), pageNo, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|