qingzhangyin 2 years ago
parent
commit
0f3fda1d46

+ 2 - 0
src/main/java/com/palmnest/dao/repair/RepairBillDao.java

@@ -108,4 +108,6 @@ public interface RepairBillDao extends GenericDao<RepairBill, Long> {
 
 	List<Integer> getAutomaticHighPraiseRepairData();
 
+	Page getBillCommentList(Map<String, Object> conditions,int type,int pageNo,int pageSize);
+
 }

+ 60 - 0
src/main/java/com/palmnest/dao/repair/impl/RepairBillDaoImpl.java

@@ -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);
+    }
+
+
 }

+ 2 - 0
src/main/java/com/palmnest/service/repair/RepairBillManager.java

@@ -134,4 +134,6 @@ public interface RepairBillManager extends GenericManager<RepairBill, Long> {
 
 	//获取自动好评工程维修数据
 	List<Integer> getAutomaticHighPraiseRepairData();
+
+	Page getBillCommentList(Map<String, Object> conditions,int type,int pageNo,int pageSize);
 }

+ 3 - 0
src/main/java/com/palmnest/service/repair/RepairBillStatisticsManager.java

@@ -73,4 +73,7 @@ public interface RepairBillStatisticsManager  {
 	Page getPeoplecOrderList(Map<String, Object> conditions,int type,int pageNo,int pageSize);
 
 	WebPageResultDto getPeoplecOrderListExcel(List<Map<String, Object>> list) throws IOException;
+
+
+	Page getBillCommentList(Map<String, Object> conditions,int type,int pageNo,int pageSize);
 }

+ 6 - 0
src/main/java/com/palmnest/service/repair/impl/RepairBillManagerImpl.java

@@ -800,4 +800,10 @@ public class RepairBillManagerImpl extends GenericManagerImpl<RepairBill, Long>
         return repairBillDao.getAutomaticHighPraiseRepairData();
     }
 
+    @Override
+    public Page getBillCommentList(Map<String, Object> conditions, int type,int pageNo, int pageSize) {
+
+        return repairBillDao.getBillCommentList(conditions, type,pageNo, pageSize);
+    }
+
 }

+ 45 - 0
src/main/java/com/palmnest/webapp/controller/backstage/RepairBillStatisticsController.java

@@ -527,4 +527,49 @@ public class RepairBillStatisticsController extends BaseFormController {
 
     }
 
+
+    /**
+     * 工单评价统计
+     * @return
+     */
+    @RequestMapping(value = "/getBillCommentList")
+    @ResponseBody
+    public WebPageResultDto getBillCommentList(@ModelAttribute PeoplecOrderDto repairDto, HttpServletRequest request) {
+
+        LOG.info("工单评价统计-RepairBillStatisticsController.getBillCommentList repairDto:" + JSON.toJSONString(repairDto) + " ");
+        try {
+            int pageSize = Integer.parseInt(request.getParameter("limit"));
+            int pageNo = Integer.parseInt(request.getParameter("page"));
+
+            if (2 == repairDto.getType() && StringUtil.isNotEmpty(repairDto.getDate())) {
+                //当类型为季度时
+                Map<String, String> map = getQuarter(repairDto.getDate());
+                if (map != null) {
+                    repairDto.setDate(map.get("year"));
+                    repairDto.setEndDate(map.get("quarter"));
+                }
+            }
+            if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
+                //当类型为季度时
+                Map<String, String> map = getQuarter(repairDto.getDate());
+                if (map != null) {
+                    repairDto.setDate(map.get("year"));
+                    repairDto.setEndDate(map.get("quarter"));
+                }
+            }
+            String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
+            Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
+            conditions.put("dateString",dateString);
+
+            Page page =  statisticsManager.getBillCommentList(conditions,repairDto.getType().intValue(),pageNo, pageSize);
+            WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
+            dto.setCount(page.getTotalCount());
+            return dto;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "人员工单统计查询失败", LogExceptionStackUtil.LogExceptionStack(e));
+        }
+
+    }
+
 }

+ 1 - 0
super_service.iml

@@ -53,6 +53,7 @@
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.83" level="project" />
     <orderEntry type="library" name="Maven: com.github.fernandospr:javapns-jdk16:2.2.1" level="project" />
     <orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk16:1.46" level="project" />
     <orderEntry type="library" name="Maven: cn.jpush.api:jpush-client:3.3.4" level="project" />