Browse Source

数据统计

wuwen 5 years ago
parent
commit
b4816efe68

+ 4 - 4
src/main/java/com/ssj/dao/sys/analysis/dao/impl/AnalysisQueryDaoImpl.java

@@ -296,8 +296,8 @@ public class AnalysisQueryDaoImpl  implements AnalysisQueryDao {
 		StringBuilder sb = new StringBuilder();
 		List<Object> param = new ArrayList<>();
         sb.append("	SELECT 	");
-      	sb.append("	IFNULL((SELECT COUNT(1) FROM(SELECT COUNT(lib_id) from tb_analysis_count a WHERE a.day_time>=? AND a.day_time<=? GROUP BY a.lib_id) as d),0)  as count_0, " );
-    	sb.append(" IFNULL((SELECT COUNT(1) FROM(SELECT COUNT(lib_id) from tb_analysis_count a WHERE a.day_time>=? AND a.day_time<=? GROUP BY a.lib_id) as d),0)  as count_1 LIMIT 1");
+      	sb.append("	IFNULL((SELECT COUNT(DISTINCT a.lib_id) from tb_analysis_count a WHERE a.day_time>=? AND a.day_time<=? ),0)  as count_0, " );
+    	sb.append(" IFNULL((SELECT COUNT(DISTINCT a.lib_id) from tb_analysis_count a WHERE a.day_time>=? AND a.day_time<=? ),0)  as count_1 LIMIT 1");
       	param.add(params.get("date"));
     	param.add(params.get("date2"));
     	param.add(params.get("date3"));
@@ -329,7 +329,7 @@ public class AnalysisQueryDaoImpl  implements AnalysisQueryDao {
       	sb.append("	SELECT IFNULL(count(1),0) as count from (SELECT t.vip_id,count(t.day_time) as count from tb_analysis t WHERE t.lib_id=? AND t.type=3 AND DATE_FORMAT(t.day_time,'%Y')=DATE_FORMAT(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),'%Y-%m-%d'),'%Y') AND DATE_FORMAT(t.day_time,'%Y')=DATE_FORMAT(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),'%Y-%m-%d'),'%u') GROUP BY t.vip_id HAVING count>=3) as tmp" );
     	param.add(params.get("libId"));
     	List<Map<String, Object>>  list=dao.findMap(sb.toString(),param.toArray());
-        return list!=null && list.size()>0 ? (int)list.get(0).get("count") : 0;
+        return list!=null && list.size()>0 ? Integer.parseInt(list.get(0).get("count").toString()): 0;
 	}
 	
 	
@@ -339,7 +339,7 @@ public class AnalysisQueryDaoImpl  implements AnalysisQueryDao {
       	sb.append("	SELECT COUNT(1) as count from tb_lib_vip t WHERE t.lib_id=? " );
     	param.add(params.get("libId"));
     	List<Map<String, Object>>  list=dao.findMap(sb.toString(),param.toArray());
-        return list!=null && list.size()>0 ? (int)list.get(0).get("count") : 0;
+        return list!=null && list.size()>0 ? Integer.parseInt(list.get(0).get("count").toString()) : 0;
 	}
 
 	@Override

+ 2 - 0
src/main/java/com/ssj/service/sys/analysis/service/impl/AnalysisCountServiceImpl.java

@@ -47,6 +47,7 @@ public class AnalysisCountServiceImpl extends BaseServiceImpl<AnalysisCount, Str
 				analysisCount.setCount(count);
 				this.save(analysisCount);
 			} catch (Exception e) {
+				e.printStackTrace();
 			}
 		}
 	}
@@ -65,6 +66,7 @@ public class AnalysisCountServiceImpl extends BaseServiceImpl<AnalysisCount, Str
 				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 				analysisCount.setDayTime(sdf.parse(dayTime));
 			} catch (ParseException e) {
+				e.printStackTrace();
 			}
 		}
 		return analysisCount;