main
黄海 5 months ago
parent 6e2d26f04d
commit e7be7011d3

@ -33,7 +33,7 @@ public class SyncDataEase {
//学校数量
schoolCount();
//学区top5
//areaTop5();
areaTop5();
}
/**
@ -216,13 +216,13 @@ public class SyncDataEase {
* top5
*
* @param areaName
* @param lessonCount
* @param regSchoolCount
* @param lessonSchoolCount
* @param total_cnt
* @param signin_cnt
* @param construct_cnt
*/
public static void updateAreaTop5(String areaName, int lessonCount, int regSchoolCount, int lessonSchoolCount, int sort_id) {
String sql = Db.getSql("DataEase.areaTop5");
Db.use(MYSQL_DB).update(sql, areaName, lessonCount, regSchoolCount, lessonSchoolCount, sort_id);
public static void updateAreaTop5(String areaName, int total_cnt, int signin_cnt, int construct_cnt, int sort_id) {
String sql = Db.getSql("DataEase.updateAreaTop5");
Db.use(MYSQL_DB).update(sql, areaName, total_cnt, signin_cnt, construct_cnt, sort_id);
}
/**
@ -234,12 +234,20 @@ public class SyncDataEase {
int idx = 0;
for (Record record : list) {
String gather_regionc = record.getStr("gather_regionc");
int cnt = record.getInt("cnt");
int regSchoolCount = record.getInt("regSchoolCount");
int lessonSchoolCount = record.getInt("lessonSchoolCount");
int total_cnt = record.getInt("total_cnt");
int signin_cnt = record.getInt("signin_cnt");
int construct_cnt = record.getInt("construct_cnt");
//更新
updateAreaTop5(gather_regionc, cnt, regSchoolCount, lessonSchoolCount, ++idx);
updateAreaTop5(gather_regionc, total_cnt, signin_cnt, construct_cnt, ++idx);
}
print("更新地区top5成功");
}
/**
*
*/
public static void stageYingYingFenBu(){
SqlPara sqlPara = Db.getSqlPara("DataEase.stageYingYingFenBu");
List<Record> list = Db.find(sqlPara);
}
}

@ -144,10 +144,53 @@ ORDER BY
#end
-- 区域建设排名前5
#sql("areaTop5")
SELECT gather_regionc,COUNT(*) as cnt FROM t_crawler_lesson_school WHERE match_type=2 GROUP BY gather_regionc ORDER BY cnt DESC LIMIT 5
WITH base_stats AS (
SELECT
gather_regionc,
COUNT(*) as total_cnt
FROM t_crawler_lesson_school
WHERE match_type = 2
GROUP BY gather_regionc
),
signin_stats AS (
SELECT
gather_regionc,
COUNT(DISTINCT organization_name) as signin_cnt
FROM 1001
WHERE school_running_type_no IN ('211','341','312','345','342','311')
GROUP BY gather_regionc
),
construct_stats AS (
SELECT
gather_regionc,
COUNT(DISTINCT organization_name) as construct_cnt
FROM t_crawler_lesson_school
GROUP BY gather_regionc
)
SELECT
b.gather_regionc,
b.total_cnt,
COALESCE(s.signin_cnt, 0) as signin_cnt,
COALESCE(c.construct_cnt, 0) as construct_cnt
FROM base_stats b
LEFT JOIN signin_stats s ON b.gather_regionc = s.gather_regionc
LEFT JOIN construct_stats c ON b.gather_regionc = c.gather_regionc
ORDER BY b.total_cnt DESC;
#end
-- 更新区域建设排名前5
#sql("updateAreaTop5")
update `excel__a03b1bfada` set ``=?,``=?,``=?,``=? where ``=?
update `excel__a03b1bfada` set ``=?,``=?,``=?,``=? where ``=?
#end
-- 学段应用分布
#sql("stageYingYingFenBu")
-- 小学
SELECT '小学' as stage_name, T2.subject_name,COUNT(DISTINCT lesson_id) as cnt,ROUND(COUNT(DISTINCT lesson_id) * 100.0 / SUM(COUNT(DISTINCT lesson_id)) OVER(),2) as percent FROM t_crawler_lesson T1 INNER JOIN t_crawler_subject T2 ON T1.subject_id=T2.subject_id WHERE T1.stage_id='2' AND T1.node_type=1 AND T1.subject_id IN ('213','241','214','264','215','225','228','224') GROUP BY T2.subject_name
union all
-- 初中
SELECT '初中', T2.subject_name,COUNT(DISTINCT lesson_id) as cnt,ROUND(COUNT(DISTINCT lesson_id) * 100.0 / SUM(COUNT(DISTINCT lesson_id)) OVER(),2) as percent FROM t_crawler_lesson T1 INNER JOIN t_crawler_subject T2 ON T1.subject_id=T2.subject_id WHERE T1.stage_id='3' AND node_type=1 AND T1.subject_id IN ('313','314','341','316','317','318','321','320','364','325','322','324') GROUP BY T2.subject_name
union all
-- 高中
SELECT '高中', T2.subject_name,COUNT(DISTINCT lesson_id) as cnt,ROUND(COUNT(DISTINCT lesson_id) * 100.0 / SUM(COUNT(DISTINCT lesson_id)) OVER(),2) as percent FROM t_crawler_lesson T1 INNER JOIN t_crawler_subject T2 ON T1.subject_id=T2.subject_id WHERE T1.stage_id='4' AND node_type=1 AND T1.subject_id IN ('413','414','416','441','417','418','448','421','420','425','422','424') GROUP BY T2.subject_name
#end
#end
Loading…
Cancel
Save