|
@@ -7,9 +7,7 @@ import com.izouma.wenlvju.domain.GradingOrganization;
|
|
|
import com.izouma.wenlvju.domain.Organization;
|
|
import com.izouma.wenlvju.domain.Organization;
|
|
|
import com.izouma.wenlvju.domain.Record;
|
|
import com.izouma.wenlvju.domain.Record;
|
|
|
import com.izouma.wenlvju.domain.RecordSpecialty;
|
|
import com.izouma.wenlvju.domain.RecordSpecialty;
|
|
|
-import com.izouma.wenlvju.domain.regulation.Complain;
|
|
|
|
|
-import com.izouma.wenlvju.domain.regulation.NumOfReport;
|
|
|
|
|
-import com.izouma.wenlvju.domain.regulation.Report;
|
|
|
|
|
|
|
+import com.izouma.wenlvju.domain.regulation.*;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
import com.izouma.wenlvju.dto.ReportDTO;
|
|
import com.izouma.wenlvju.dto.ReportDTO;
|
|
|
import com.izouma.wenlvju.enums.ReportType;
|
|
import com.izouma.wenlvju.enums.ReportType;
|
|
@@ -22,6 +20,7 @@ import com.izouma.wenlvju.repo.RecordSpecialtyRepo;
|
|
|
import com.izouma.wenlvju.repo.regulation.ComplainRepo;
|
|
import com.izouma.wenlvju.repo.regulation.ComplainRepo;
|
|
|
import com.izouma.wenlvju.repo.regulation.RecordExpertAuditRepo;
|
|
import com.izouma.wenlvju.repo.regulation.RecordExpertAuditRepo;
|
|
|
import com.izouma.wenlvju.repo.regulation.ReportRepo;
|
|
import com.izouma.wenlvju.repo.regulation.ReportRepo;
|
|
|
|
|
+import com.izouma.wenlvju.repo.regulation.ReportStatisticRepo;
|
|
|
import com.izouma.wenlvju.service.storage.StorageService;
|
|
import com.izouma.wenlvju.service.storage.StorageService;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
import freemarker.template.Configuration;
|
|
import freemarker.template.Configuration;
|
|
@@ -58,6 +57,7 @@ public class ReportService {
|
|
|
private RecordExpertAuditRepo recordExpertAuditRepo;
|
|
private RecordExpertAuditRepo recordExpertAuditRepo;
|
|
|
private RecordSpecialtyRepo recordSpecialtyRepo;
|
|
private RecordSpecialtyRepo recordSpecialtyRepo;
|
|
|
private StorageService storageService;
|
|
private StorageService storageService;
|
|
|
|
|
+ private ReportStatisticRepo reportStatisticRepo;
|
|
|
|
|
|
|
|
public Page<Report> all(PageQuery pageQuery) {
|
|
public Page<Report> all(PageQuery pageQuery) {
|
|
|
return reportRepo.findAll(JpaUtils.toSpecification(pageQuery, Report.class), JpaUtils.toPageRequest(pageQuery));
|
|
return reportRepo.findAll(JpaUtils.toSpecification(pageQuery, Report.class), JpaUtils.toPageRequest(pageQuery));
|
|
@@ -132,7 +132,7 @@ public class ReportService {
|
|
|
/**
|
|
/**
|
|
|
* 生成报告
|
|
* 生成报告
|
|
|
*/
|
|
*/
|
|
|
- public List<ReportDTO> generate(List<Record> records, List<Long> recordIds, List<Complain> complains) {
|
|
|
|
|
|
|
+ public List<ReportStatistic> generate(List<Record> records, List<Complain> complains) {
|
|
|
List<GradingOrganization> gradingOrganizations = gradingOrganizationRepo.findAll();
|
|
List<GradingOrganization> gradingOrganizations = gradingOrganizationRepo.findAll();
|
|
|
Map<String, GradingOrganization> gradingOrganizationMap = gradingOrganizations
|
|
Map<String, GradingOrganization> gradingOrganizationMap = gradingOrganizations
|
|
|
.stream()
|
|
.stream()
|
|
@@ -162,7 +162,7 @@ public class ReportService {
|
|
|
// 没有备案但是被投诉
|
|
// 没有备案但是被投诉
|
|
|
Set<Long> ids = new HashSet<>(complainsByName.keySet());
|
|
Set<Long> ids = new HashSet<>(complainsByName.keySet());
|
|
|
|
|
|
|
|
- List<ReportDTO> reportDTOS = new ArrayList<>();
|
|
|
|
|
|
|
+ List<ReportStatistic> reportDTOS = new ArrayList<>();
|
|
|
examinationAgency.forEach((key, value) -> {
|
|
examinationAgency.forEach((key, value) -> {
|
|
|
GradingOrganization go = gradingOrganizationMap.get(key.trim());
|
|
GradingOrganization go = gradingOrganizationMap.get(key.trim());
|
|
|
|
|
|
|
@@ -187,7 +187,7 @@ public class ReportService {
|
|
|
// .filter(ra -> ids.contains(ra.getRecordId()) && !ra.isValue())
|
|
// .filter(ra -> ids.contains(ra.getRecordId()) && !ra.isValue())
|
|
|
// .collect(Collectors.groupingBy(RecordExpertAudit::getType, Collectors.counting()));
|
|
// .collect(Collectors.groupingBy(RecordExpertAudit::getType, Collectors.counting()));
|
|
|
|
|
|
|
|
- reportDTOS.add(ReportDTO.builder()
|
|
|
|
|
|
|
+ reportDTOS.add(ReportStatistic.builder()
|
|
|
.unitType(UnitType.GRADING_ORGANIZATION)
|
|
.unitType(UnitType.GRADING_ORGANIZATION)
|
|
|
.name(key)
|
|
.name(key)
|
|
|
.complain(size)
|
|
.complain(size)
|
|
@@ -220,7 +220,7 @@ public class ReportService {
|
|
|
int examQuantity = value.stream().mapToInt(Record::getExamQuantity).sum();
|
|
int examQuantity = value.stream().mapToInt(Record::getExamQuantity).sum();
|
|
|
|
|
|
|
|
|
|
|
|
|
- reportDTOS.add(ReportDTO.builder()
|
|
|
|
|
|
|
+ reportDTOS.add(ReportStatistic.builder()
|
|
|
.unitType(UnitType.ORGANIZATION)
|
|
.unitType(UnitType.ORGANIZATION)
|
|
|
.name(name)
|
|
.name(name)
|
|
|
.complain(size)
|
|
.complain(size)
|
|
@@ -247,7 +247,7 @@ public class ReportService {
|
|
|
} else if (UnitType.ORGANIZATION.equals(unitType)) {
|
|
} else if (UnitType.ORGANIZATION.equals(unitType)) {
|
|
|
name = orMap.get(id).getName();
|
|
name = orMap.get(id).getName();
|
|
|
}
|
|
}
|
|
|
- reportDTOS.add(ReportDTO.builder()
|
|
|
|
|
|
|
+ reportDTOS.add(ReportStatistic.builder()
|
|
|
.unitType(unitType)
|
|
.unitType(unitType)
|
|
|
.name(name)
|
|
.name(name)
|
|
|
.complain(complainList.size())
|
|
.complain(complainList.size())
|
|
@@ -264,64 +264,55 @@ public class ReportService {
|
|
|
/*
|
|
/*
|
|
|
总统计图
|
|
总统计图
|
|
|
*/
|
|
*/
|
|
|
- public List<NumOfReport> getTotal(List<Record> records, List<Complain> complains) {
|
|
|
|
|
|
|
+ public List<NumOfReport> getTotal(List<Record> records, List<Complain> complains, List<RecordExpertAudit> recordAudits) {
|
|
|
List<NumOfReport> total = new ArrayList<>(3);
|
|
List<NumOfReport> total = new ArrayList<>(3);
|
|
|
//备案条数
|
|
//备案条数
|
|
|
- total.add(NumOfReport.builder()
|
|
|
|
|
- .name("record")
|
|
|
|
|
- .num(records.size())
|
|
|
|
|
- .build());
|
|
|
|
|
|
|
+ total.add(new NumOfReport("record", records.size()));
|
|
|
//报考人数
|
|
//报考人数
|
|
|
int examQuantity = records.stream().mapToInt(Record::getExamQuantity).sum();
|
|
int examQuantity = records.stream().mapToInt(Record::getExamQuantity).sum();
|
|
|
- total.add(NumOfReport.builder()
|
|
|
|
|
- .name("examQuantity")
|
|
|
|
|
- .num(examQuantity)
|
|
|
|
|
- .build());
|
|
|
|
|
|
|
+ total.add(new NumOfReport("totalExamQuantity", examQuantity));
|
|
|
//投诉条数
|
|
//投诉条数
|
|
|
- total.add(NumOfReport.builder()
|
|
|
|
|
- .name("complain")
|
|
|
|
|
- .num(complains.size())
|
|
|
|
|
- .build());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ total.add(new NumOfReport("totalComplain", complains.size()));
|
|
|
|
|
+ //检查数量
|
|
|
|
|
+ Map<Long, List<RecordExpertAudit>> auditMap = recordAudits.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(RecordExpertAudit::getRecordId));
|
|
|
|
|
+ total.add(new NumOfReport("totalAudit", auditMap.size()));
|
|
|
return total;
|
|
return total;
|
|
|
-// Map<String, Integer> map = new HashMap<>();
|
|
|
|
|
-// //备案条数
|
|
|
|
|
-// map.put("record", records.size());
|
|
|
|
|
-// //报考人数
|
|
|
|
|
-// map.put("examQuantity", examQuantity);
|
|
|
|
|
-// //投诉数量
|
|
|
|
|
-// map.put("complain", complains.size());
|
|
|
|
|
-// return map;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
各专业考场数量-饼图
|
|
各专业考场数量-饼图
|
|
|
*/
|
|
*/
|
|
|
- public Map<String, Long> getSpecialty(List<RecordSpecialty> recordSpecialties) {
|
|
|
|
|
- Map<String, Long> specialtyCount = recordSpecialties.stream().filter(rs -> StrUtil.isNotEmpty(rs.getCode()))
|
|
|
|
|
- .collect(Collectors.groupingBy(RecordSpecialty::getCode, Collectors.counting()));
|
|
|
|
|
- Map<String, Long> result = new HashMap<>(5);
|
|
|
|
|
- result.put("01", 0L);
|
|
|
|
|
- result.put("02", 0L);
|
|
|
|
|
- result.put("03", 0L);
|
|
|
|
|
- result.put("04", 0L);
|
|
|
|
|
- result.put("05", 0L);
|
|
|
|
|
-
|
|
|
|
|
- specialtyCount.forEach((key, value) -> {
|
|
|
|
|
- String name = "01";
|
|
|
|
|
- if (key.startsWith("02")) {
|
|
|
|
|
- name = "02";
|
|
|
|
|
- } else if (key.startsWith("03")) {
|
|
|
|
|
- name = "03";
|
|
|
|
|
- } else if (key.startsWith("04")) {
|
|
|
|
|
- name = "04";
|
|
|
|
|
- } else if (key.startsWith("05")) {
|
|
|
|
|
- name = "05";
|
|
|
|
|
|
|
+ public List<NumOfReport> getSpecialty(List<RecordSpecialty> recordSpecialties) {
|
|
|
|
|
+ int sum01 = 0;
|
|
|
|
|
+ int sum02 = 0;
|
|
|
|
|
+ int sum03 = 0;
|
|
|
|
|
+ int sum04 = 0;
|
|
|
|
|
+ int sum05 = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (RecordSpecialty specialty : recordSpecialties) {
|
|
|
|
|
+ if (StrUtil.isEmpty(specialty.getCode())) {
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
- Long count = result.get(name) + value;
|
|
|
|
|
- result.put(name, count);
|
|
|
|
|
- });
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ if (specialty.getCode().startsWith("01")) {
|
|
|
|
|
+ sum01 += specialty.getNumOfExam();
|
|
|
|
|
+ } else if (specialty.getCode().startsWith("02")) {
|
|
|
|
|
+ sum02 += specialty.getNumOfExam();
|
|
|
|
|
+ } else if (specialty.getCode().startsWith("03")) {
|
|
|
|
|
+ sum03 += specialty.getNumOfExam();
|
|
|
|
|
+ } else if (specialty.getCode().startsWith("04")) {
|
|
|
|
|
+ sum04 += specialty.getNumOfExam();
|
|
|
|
|
+ } else if (specialty.getCode().startsWith("05")) {
|
|
|
|
|
+ sum05 += specialty.getNumOfExam();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ List<NumOfReport> reports = new ArrayList<>();
|
|
|
|
|
+ reports.add(new NumOfReport("music", sum01));
|
|
|
|
|
+ reports.add(new NumOfReport("dance", sum02));
|
|
|
|
|
+ reports.add(new NumOfReport("fineArt", sum03));
|
|
|
|
|
+ reports.add(new NumOfReport("operaDrama", sum04));
|
|
|
|
|
+ reports.add(new NumOfReport("folkArt", sum05));
|
|
|
|
|
+ return reports;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -356,11 +347,13 @@ public class ReportService {
|
|
|
//备案专业
|
|
//备案专业
|
|
|
List<Long> recordIds = records.stream().map(Record::getId).collect(Collectors.toList());
|
|
List<Long> recordIds = records.stream().map(Record::getId).collect(Collectors.toList());
|
|
|
List<RecordSpecialty> recordSpecialties = recordSpecialtyRepo.findAllByRecordIdIn(recordIds);
|
|
List<RecordSpecialty> recordSpecialties = recordSpecialtyRepo.findAllByRecordIdIn(recordIds);
|
|
|
|
|
+ //备案检查
|
|
|
|
|
+ List<RecordExpertAudit> recordAudits = recordExpertAuditRepo.findAllByRecordIdIn(recordIds);
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
|
|
|
|
//标题
|
|
//标题
|
|
|
- dataMap.put("year", report.getYear());
|
|
|
|
|
|
|
+ dataMap.put("year", String.valueOf(report.getYear()));
|
|
|
if (ReportType.QUARTERLY.equals(report.getType())) {
|
|
if (ReportType.QUARTERLY.equals(report.getType())) {
|
|
|
String[] arr = {"一季度", "二季度", "三季度", "四季度"};
|
|
String[] arr = {"一季度", "二季度", "三季度", "四季度"};
|
|
|
dataMap.put("quarterly", arr[report.getQuarterly() - 1]);
|
|
dataMap.put("quarterly", arr[report.getQuarterly() - 1]);
|
|
@@ -374,26 +367,19 @@ public class ReportService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//总统计
|
|
//总统计
|
|
|
- List<NumOfReport> total = this.getTotal(records, complains);
|
|
|
|
|
|
|
+ List<NumOfReport> total = this.getTotal(records, complains, recordAudits);
|
|
|
total.forEach(num -> dataMap.put(num.getName(), num.getNum()));
|
|
total.forEach(num -> dataMap.put(num.getName(), num.getNum()));
|
|
|
-// dataMap.put("record", total.get("record"));
|
|
|
|
|
-// dataMap.put("totalExamQuantity", total.get("examQuantity"));
|
|
|
|
|
-// dataMap.put("totalComplain", total.get("complain"));
|
|
|
|
|
|
|
|
|
|
//各专业统计
|
|
//各专业统计
|
|
|
- Map<String, Long> specialty = this.getSpecialty(recordSpecialties);
|
|
|
|
|
- dataMap.put("music", specialty.get("01"));
|
|
|
|
|
- dataMap.put("dance", specialty.get("02"));
|
|
|
|
|
- dataMap.put("fineArt", specialty.get("03"));
|
|
|
|
|
- dataMap.put("operaDrama", specialty.get("04"));
|
|
|
|
|
- dataMap.put("folkArt", specialty.get("05"));
|
|
|
|
|
|
|
+ List<NumOfReport> specialty = this.getSpecialty(recordSpecialties);
|
|
|
|
|
+ specialty.forEach(num -> dataMap.put(num.getName(), num.getNum()));
|
|
|
|
|
|
|
|
//考级机构/承办单位统计
|
|
//考级机构/承办单位统计
|
|
|
- List<ReportDTO> reportDTOS = this.generate(records, recordIds, complains);
|
|
|
|
|
- Map<UnitType, List<ReportDTO>> unitTypeListMap = reportDTOS.stream()
|
|
|
|
|
- .collect(Collectors.groupingBy(ReportDTO::getUnitType));
|
|
|
|
|
|
|
+ List<ReportStatistic> reportDTOS = this.generate(records, complains);
|
|
|
|
|
+ Map<UnitType, List<ReportStatistic>> unitTypeListMap = reportDTOS.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(ReportStatistic::getUnitType));
|
|
|
//考级机构
|
|
//考级机构
|
|
|
- List<ReportDTO> reportsGo = unitTypeListMap.get(UnitType.GRADING_ORGANIZATION);
|
|
|
|
|
|
|
+ List<ReportStatistic> reportsGo = unitTypeListMap.get(UnitType.GRADING_ORGANIZATION);
|
|
|
List<Map<String, Object>> listMapGo = new ArrayList<>();
|
|
List<Map<String, Object>> listMapGo = new ArrayList<>();
|
|
|
reportsGo.forEach(dto -> {
|
|
reportsGo.forEach(dto -> {
|
|
|
Map<String, Object> goMap = new HashMap<>();
|
|
Map<String, Object> goMap = new HashMap<>();
|
|
@@ -407,9 +393,9 @@ public class ReportService {
|
|
|
dataMap.put("list", listMapGo);
|
|
dataMap.put("list", listMapGo);
|
|
|
|
|
|
|
|
//承办单位
|
|
//承办单位
|
|
|
- List<ReportDTO> reports = unitTypeListMap.get(UnitType.ORGANIZATION);
|
|
|
|
|
|
|
+ List<ReportStatistic> reportStatistics = unitTypeListMap.get(UnitType.ORGANIZATION);
|
|
|
List<Map<String, Object>> listMap = new ArrayList<>();
|
|
List<Map<String, Object>> listMap = new ArrayList<>();
|
|
|
- reports.forEach(dto -> {
|
|
|
|
|
|
|
+ reportStatistics.forEach(dto -> {
|
|
|
Map<String, Object> orMap = new HashMap<>();
|
|
Map<String, Object> orMap = new HashMap<>();
|
|
|
orMap.put("name", dto.getName());
|
|
orMap.put("name", dto.getName());
|
|
|
orMap.put("examCenterQuantity", dto.getExamCenterQuantity());
|
|
orMap.put("examCenterQuantity", dto.getExamCenterQuantity());
|
|
@@ -433,11 +419,15 @@ public class ReportService {
|
|
|
String url = storageService.uploadFromInputStream(is, "word" + "/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date())
|
|
String url = storageService.uploadFromInputStream(is, "word" + "/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date())
|
|
|
+ RandomStringUtils.randomAlphabetic(8) + ".docx");
|
|
+ RandomStringUtils.randomAlphabetic(8) + ".docx");
|
|
|
|
|
|
|
|
|
|
+ report.setSpecialty(specialty);
|
|
|
report.setTotal(total);
|
|
report.setTotal(total);
|
|
|
report.setFile(url);
|
|
report.setFile(url);
|
|
|
report.setTime(String.valueOf(date.get("time")));
|
|
report.setTime(String.valueOf(date.get("time")));
|
|
|
report.setTitle("南京市社会艺术水平考级监管报告");
|
|
report.setTitle("南京市社会艺术水平考级监管报告");
|
|
|
- reportRepo.save(report);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Long id = reportRepo.save(report).getId();
|
|
|
|
|
+ List<ReportStatistic> statistics = reportStatistics.stream()
|
|
|
|
|
+ .peek(statistic -> statistic.setReportId(id))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ reportStatisticRepo.saveAll(statistics);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|