kgdxpr 7 months ago
commit 5ab51fc2da

@ -339,6 +339,10 @@ public class YunXiao {
.set("scheme_id", editionName)
.set("subject_id", subjectCode)
.set("stage_id", key)
//增加学习次数
.set("preview_count", jsonSource.getIntValue("previewCount"))
.set("learning_person_count", jsonSource.getIntValue("learningPersonCount"))
.set("learning_person_times", jsonSource.getIntValue("learningPersonTimes"))
.set("id", UUID.randomUUID().toString());
lessonList.add(record);
int count = resourceCount.incrementAndGet();
@ -431,12 +435,6 @@ public class YunXiao {
}
arp.start();
// 清空表
String[] tables = {"t_crawler_subject", "t_crawler_scheme", "t_crawler_book",
"t_crawler_structure", "t_crawler_lesson"};
for (String table : tables) {
Db.update("truncate table " + table);
}
Map<String, String> map = new HashMap<>();
map.put("1", "学前");
@ -500,6 +498,13 @@ public class YunXiao {
e.printStackTrace();
}
executorService.shutdown();
// 清空表
String[] tables = {"t_crawler_subject", "t_crawler_scheme", "t_crawler_book",
"t_crawler_structure", "t_crawler_lesson"};
for (String table : tables) {
Db.update("truncate table " + table);
}
// 保存数据
print("开始保存数据...");
Db.batchSave("t_crawler_subject", subjectList, batchSize);

Binary file not shown.

@ -3,6 +3,7 @@ package com.dsideal.QingLong.YunXiao.Controller;
import com.dsideal.QingLong.Interceptor.IsLoginInterface;
import com.dsideal.QingLong.Util.CommonUtil;
import com.dsideal.QingLong.YunXiao.Model.YunXiaoModel;
import com.dsideal.QingLong.YunXiao.Util.YunXiaoExportExcelUtil;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
@ -10,7 +11,9 @@ import com.jfinal.ext.interceptor.POST;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.io.File;
import java.util.List;
import java.util.UUID;
public class YunXiaoController extends Controller {
YunXiaoModel ym = new YunXiaoModel();
@ -21,7 +24,7 @@ public class YunXiaoController extends Controller {
// http://10.10.21.20:9000/QingLong/yx/getStandardSchoolList
@Before(GET.class)
public void getStandardSchoolList() {
List<Record> list=ym.getStandardSchoolList();
List<Record> list = ym.getStandardSchoolList();
renderJson(CommonUtil.renderJsonForLayUI(list));
}
@ -98,19 +101,40 @@ public class YunXiaoController extends Controller {
/**
*
*/
// http://10.10.21.20:9000/QingLong/yx/LessonConstructionExportExcel
@Before(GET.class)
public void LessonConstructionExportExcel() {
List<Record> list1 = ym.LessonConstructionInfoByStageSubject();
List<Record> list2 = ym.LessonConstructionInfoByStageSubjectBook();
List<Record> list3 = ym.LessonConstructionInfoByXzqh();
// ExportExcelUtil exporter = new ExportExcelUtil();
// //获取系统临时目录
// String tmpDir = System.getProperty("java.io.tmpdir");
// //使用guid生成一个临时文件名然后拼接到tmpDir后面生成完整的临时文件路径
// String tmpFile = tmpDir + File.separator + UUID.randomUUID().toString() + ".xlsx";
// exporter.exportToExcel(tmpFile, list);
YunXiaoExportExcelUtil exporter = new YunXiaoExportExcelUtil();
//获取系统临时目录
String tmpDir = System.getProperty("java.io.tmpdir");
//使用guid生成一个临时文件名然后拼接到tmpDir后面生成完整的临时文件路径
String tmpFile = tmpDir + File.separator + UUID.randomUUID() + ".xlsx";
exporter.LessonConstructionExportExcel(tmpFile, list1, list2);
//提供下载
//renderFile(new File(tmpFile), gather_regionc + "统计报表.xlsx");
renderFile(new File(tmpFile), "课程建设情况报表.xlsx");
}
/**
*
*/
// http://10.10.21.20:9000/QingLong/yx/LessonConstructionInfoByXzqhSchool
@Before(GET.class)
public void LessonConstructionInfoByXzqhSchool() {
List<Record> list1 = ym.LessonConstructionInfoByXzqh();
List<Record> list2 = ym.LessonConstructionInfoByXzqhStage();
List<Record> list3 = ym.LessonConstructionInfoByXzqhSchool();
List<Record> list4 = ym.LessonConstructionInfo();
YunXiaoExportExcelUtil exporter = new YunXiaoExportExcelUtil();
//获取系统临时目录
String tmpDir = System.getProperty("java.io.tmpdir");
//使用guid生成一个临时文件名然后拼接到tmpDir后面生成完整的临时文件路径
String tmpFile = tmpDir + File.separator + UUID.randomUUID() + ".xlsx";
exporter.LessonConstructionInfoByXzqhSchool(tmpFile, list1, list2, list3,list4);
//提供下载
renderFile(new File(tmpFile), "【区域+学校】课程建设情况报表.xlsx");
}
}

@ -38,7 +38,7 @@ public class YunXiaoModel {
* @param pageSize
* @return
*/
public Page<com.jfinal.plugin.activerecord.Record> matchLessonSchoolName(int pageNum, int pageSize) {
public Page<Record> matchLessonSchoolName(int pageNum, int pageSize) {
SqlPara sqlPara = Db.getSqlPara("YunXiao.matchLessonSchoolName");
return Db.paginate(pageNum, pageSize, sqlPara);
}
@ -124,4 +124,9 @@ public class YunXiaoModel {
SqlPara sqlPara = Db.getSqlPara("YunXiao.LessonConstructionInfoByXzqhSchool");
return Db.find(sqlPara);
}
public List<Record> LessonConstructionInfo() {
SqlPara sqlPara = Db.getSqlPara("YunXiao.LessonConstructionInfo");
return Db.find(sqlPara);
}
}

@ -10,59 +10,235 @@ import java.util.List;
public class YunXiaoExportExcelUtil {
public void exportToExcel(String filePath, List<Record> list) {
/**
*
*
* @param filePath
* @param list1
* @param list2
*/
public void LessonConstructionExportExcel(String filePath, List<Record> list1, List<Record> list2) {
try (XSSFWorkbook workbook = new XSSFWorkbook()) {
XSSFSheet sheet = workbook.createSheet("课程整体");
// 创建样式
CellStyle headerStyle = createHeaderStyle(workbook);
CellStyle dataStyle = createDataStyle(workbook);
//第一个 Sheet
XSSFSheet sheet1 = workbook.createSheet("整体建设情况");
// 设置列宽
sheet.setColumnWidth(0, 4000); // 区域
sheet.setColumnWidth(1, 5000); // 机构编号
sheet.setColumnWidth(2, 8000); // 机构名称
sheet.setColumnWidth(3, 4000); // 办学类型
sheet.setColumnWidth(4, 3000); // 教职工数
sheet.setColumnWidth(5, 3000); // 专任教师数
sheet.setColumnWidth(6, 3000); // 班级数
sheet.setColumnWidth(7, 3000); // 在校生数
sheet1.setColumnWidth(0, 4000); // 学段
sheet1.setColumnWidth(1, 8000); // 科目名称
sheet1.setColumnWidth(2, 5000); // 课程数量
// 创建表头
Row headerRow = sheet1.createRow(0);
headerRow.setHeight((short) (28 * 20));
String[] headers = {
"学段", "科目名称", "课程数量"
};
for (int i = 0; i < headers.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers[i]);
cell.setCellStyle(headerStyle);
}
int rowNum = 1;
// 填充数据
for (Record record : list1) {
Row row = sheet1.createRow(rowNum++);
row.setHeight((short) (28 * 20));
// 学段
createCell(row, 0, record.getStr("stage_name"), dataStyle);
// 科目名称
createCell(row, 1, record.getStr("subject_name"), dataStyle);
// 建设数量
createCell(row, 2, record.getStr("lesson_count"), dataStyle);
}
//第二个 Sheet
XSSFSheet sheet2 = workbook.createSheet("年级课程建设情况");
// 设置列宽
sheet2.setColumnWidth(0, 4000); // 学段
sheet2.setColumnWidth(1, 8000); // 科目名称
sheet2.setColumnWidth(2, 8000); // 册
sheet2.setColumnWidth(3, 5000); // 课程数量
// 创建表头
Row headerRow = sheet.createRow(0);
headerRow = sheet2.createRow(0);
headerRow.setHeight((short) (28 * 20));
String[] headers2 = {
"学段", "科目名称", "册", "课程数量"
};
for (int i = 0; i < headers2.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers2[i]);
cell.setCellStyle(headerStyle);
}
rowNum = 1;
// 填充数据
for (Record record : list2) {
Row row = sheet2.createRow(rowNum++);
row.setHeight((short) (28 * 20));
// 学段
createCell(row, 0, record.getStr("stage_name"), dataStyle);
// 科目名称
createCell(row, 1, record.getStr("subject_name"), dataStyle);
//册
createCell(row, 2, record.getStr("book_name"), dataStyle);
// 建设数量
createCell(row, 3, record.getStr("lesson_count"), dataStyle);
}
// 保存文件
try (FileOutputStream fileOut = new FileOutputStream(filePath)) {
workbook.write(fileOut);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
*
* @param filePath
* @param list1
* @param list2
* @param list3
*/
public void LessonConstructionInfoByXzqhSchool(String filePath, List<Record> list1, List<Record> list2, List<Record> list3, List<Record> list4) {
try (XSSFWorkbook workbook = new XSSFWorkbook()) {
// 创建样式
CellStyle headerStyle = createHeaderStyle(workbook);
CellStyle dataStyle = createDataStyle(workbook);
//第一个 Sheet
XSSFSheet sheet1 = workbook.createSheet("区域建设情况");
// 设置列宽
sheet1.setColumnWidth(0, 7000); // 县区名称
sheet1.setColumnWidth(1, 4000); // 数量
// 创建表头
Row headerRow = sheet1.createRow(0);
headerRow.setHeight((short) (28 * 20));
String[] headers = {
"区域", "机构编号", "机构名称", "办学类型",
"教职工数", "专任教师数", "班级数", "在校生数"
"县区", "课程数量"
};
for (int i = 0; i < headers.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers[i]);
cell.setCellStyle(headerStyle);
}
int rowNum = 1;
// 填充数据
for (Record record : list1) {
Row row = sheet1.createRow(rowNum++);
row.setHeight((short) (28 * 20));
// 县区名称
createCell(row, 0, record.getStr("gather_regionc"), dataStyle);
// 建设数量
createCell(row, 1, record.getStr("c"), dataStyle);
}
//第二个 Sheet
XSSFSheet sheet2 = workbook.createSheet("区域课程建设情况");
// 设置列宽
sheet2.setColumnWidth(0, 5000); // 县区名称
sheet2.setColumnWidth(1, 5000); // 学段
sheet2.setColumnWidth(2, 5000); // 科目名称
sheet2.setColumnWidth(3, 5000); // 课程数量
// 创建表头
headerRow = sheet2.createRow(0);
headerRow.setHeight((short) (28 * 20));
String[] headers2 = {
"县区名称", "学段", "科目名称", "课程数量"
};
for (int i = 0; i < headers2.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers2[i]);
cell.setCellStyle(headerStyle);
}
rowNum = 1;
// 填充数据
for (Record record : list) {
Row row = sheet.createRow(rowNum++);
for (Record record : list2) {
Row row = sheet2.createRow(rowNum++);
row.setHeight((short) (28 * 20));
//县区名称
createCell(row, 0, record.getStr("gather_regionc"), dataStyle);
// 学段
createCell(row, 1, record.getStr("stage_name"), dataStyle);
// 科目名称
createCell(row, 2, record.getStr("subject_name"), dataStyle);
// 建设数量
createCell(row, 3, record.getStr("c"), dataStyle);
}
// 区域
createCell(row, 0, record.getStr("县区"), dataStyle);
// 机构编号
createCell(row, 1, record.getStr("单位号"), dataStyle);
// 机构名称
createCell(row, 2, record.getStr("单位名称"), dataStyle);
// 办学类型
createCell(row, 3, record.getStr("学校类型"), dataStyle);
//教职工数
createCell(row, 4, String.valueOf(record.getInt("教职工数")), dataStyle);
//专任教师数
createCell(row, 5, String.valueOf(record.getInt("专任教师数")), dataStyle);
//班级数
createCell(row, 6, String.valueOf(record.getInt("班级数")), dataStyle);
//在校生数
createCell(row, 7, String.valueOf(record.getInt("在校生数")), dataStyle);
//第三个 Sheet
XSSFSheet sheet3 = workbook.createSheet("学校课程建设情况");
// 设置列宽
sheet3.setColumnWidth(0, 5000); // 县区名称
sheet3.setColumnWidth(1, 8000); // 学校
sheet3.setColumnWidth(2, 5000); // 课程数量
// 创建表头
headerRow = sheet3.createRow(0);
headerRow.setHeight((short) (28 * 20));
String[] headers3 = {
"县区名称", "学校", "课程数量"
};
for (int i = 0; i < headers3.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers3[i]);
cell.setCellStyle(headerStyle);
}
rowNum = 1;
// 填充数据
for (Record record : list3) {
Row row = sheet3.createRow(rowNum++);
row.setHeight((short) (28 * 20));
//县区名称
createCell(row, 0, record.getStr("gather_regionc"), dataStyle);
// 学校
createCell(row, 1, record.getStr("organization_name"), dataStyle);
// 建设数量
createCell(row, 2, record.getStr("c"), dataStyle);
}
//第四个 Sheet
XSSFSheet sheet4 = workbook.createSheet("学校课程建设详情");
// 设置列宽
sheet4.setColumnWidth(0, 8000); // 县区名称
sheet4.setColumnWidth(1, 5000); // 学段
sheet4.setColumnWidth(2, 8000); // 学校
sheet4.setColumnWidth(3, 5000); // 科目
sheet4.setColumnWidth(4, 5000); // 教师
sheet4.setColumnWidth(5, 10000); // 课程名称
// 创建表头
headerRow = sheet4.createRow(0);
headerRow.setHeight((short) (28 * 20));
String[] headers4 = {
"县区名称", "学段", "学校", "科目", "教师", "课程名称"
};
for (int i = 0; i < headers4.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers4[i]);
cell.setCellStyle(headerStyle);
}
rowNum = 1;
// 填充数据
for (Record record : list4) {
Row row = sheet4.createRow(rowNum++);
row.setHeight((short) (28 * 20));
//县区名称
createCell(row, 0, record.getStr("gather_regionc"), dataStyle);
//学段
createCell(row, 1, record.getStr("stage_name"), dataStyle);
// 学校
createCell(row, 2, record.getStr("organization_name"), dataStyle);
//科目
createCell(row, 3, record.getStr("subject_name"), dataStyle);
// 教师
createCell(row, 4, record.getStr("teacher_name"), dataStyle);
// 课程
createCell(row, 5, record.getStr("lesson_name"), dataStyle);
}
// 保存文件
@ -103,23 +279,19 @@ public class YunXiaoExportExcelUtil {
font.setBold(true);
font.setFontHeightInPoints((short) 11);
style.setFont(font);
return style;
}
private CellStyle createDataStyle(XSSFWorkbook workbook) {
CellStyle style = workbook.createCellStyle();
// 设置边框
style.setBorderTop(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
// 设置居中对齐
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
return style;
}
}

@ -47,4 +47,13 @@
inner join t_crawler_lesson as t2 on t1.lesson_id=t2.lesson_id
where t1.match_type=0
#end
-- 课程建设的详细情况
#sql("LessonConstructionInfo")
select t2.gather_regionc,t3.stage_name,t2.organization_name,t4.subject_name,t1.teacher_name,t1.lesson_name from t_crawler_lesson as t1
inner join t_crawler_lesson_school as t2 on t1.lesson_id=t2.lesson_id
inner join t_crawler_stage as t3 on t1.stage_id=t3.stage_id
inner join t_crawler_subject as t4 on t1.subject_id=t4.subject_id
where t2.match_type in (1,2,3) order by t2.gather_regionc,t2.organization_name,t4.subject_name,t1.teacher_name
#end
#end
Loading…
Cancel
Save