|
|
@@ -1,11 +1,11 @@
|
|
|
package com.izouma.wenlvju.service.regulation;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.izouma.wenlvju.domain.GradingOrganization;
|
|
|
import com.izouma.wenlvju.domain.Organization;
|
|
|
import com.izouma.wenlvju.domain.Record;
|
|
|
import com.izouma.wenlvju.domain.regulation.Complain;
|
|
|
+import com.izouma.wenlvju.domain.regulation.RecordExpertAudit;
|
|
|
import com.izouma.wenlvju.domain.regulation.Report;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
import com.izouma.wenlvju.dto.ReportDTO;
|
|
|
@@ -14,6 +14,7 @@ import com.izouma.wenlvju.repo.GradingOrganizationRepo;
|
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
|
import com.izouma.wenlvju.repo.RecordRepo;
|
|
|
import com.izouma.wenlvju.repo.regulation.ComplainRepo;
|
|
|
+import com.izouma.wenlvju.repo.regulation.RecordExpertAuditRepo;
|
|
|
import com.izouma.wenlvju.repo.regulation.ReportRepo;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -35,21 +36,17 @@ public class ReportService {
|
|
|
private ComplainRepo complainRepo;
|
|
|
private GradingOrganizationRepo gradingOrganizationRepo;
|
|
|
private OrganizationRepo organizationRepo;
|
|
|
+ private RecordExpertAuditRepo recordExpertAuditRepo;
|
|
|
|
|
|
public Page<Report> all(PageQuery pageQuery) {
|
|
|
return reportRepo.findAll(JpaUtils.toSpecification(pageQuery, Report.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 生成报告
|
|
|
- */
|
|
|
- public List<ReportDTO> generate(Report report) {
|
|
|
-
|
|
|
+ public Map<String, LocalDateTime> getDate(Report report) {
|
|
|
// 开始结束时间
|
|
|
int year = report.getYear();
|
|
|
LocalDateTime start = LocalDateTime.of(year, 1, 1, 0, 0);
|
|
|
LocalDate endDate = LocalDate.of(year, 12, 31);
|
|
|
-
|
|
|
// 名称
|
|
|
String time = year + "年";
|
|
|
|
|
|
@@ -90,8 +87,24 @@ public class ReportService {
|
|
|
}
|
|
|
// 结束日期
|
|
|
LocalDateTime end = LocalDateTime.of(endDate, LocalTime.MAX);
|
|
|
+ report.setTime(time);
|
|
|
+ reportRepo.save(report);
|
|
|
+ Map<String, LocalDateTime> map = new HashMap<>();
|
|
|
+ map.put("start", start);
|
|
|
+ map.put("end", end);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成报告
|
|
|
+ */
|
|
|
+ public List<ReportDTO> generate(Report report) {
|
|
|
+ // 开始结束时间
|
|
|
+ Map<String, LocalDateTime> date = this.getDate(report);
|
|
|
+ LocalDateTime start = date.get("start");
|
|
|
+ LocalDateTime end = date.get("end");
|
|
|
|
|
|
- List<Record> records = recordRepo.findAllByExaminationStartTimeBetween(start.toLocalDate(), endDate);
|
|
|
+ List<Record> records = recordRepo.findAllByExaminationStartTimeBetween(start.toLocalDate(), end.toLocalDate());
|
|
|
List<Complain> complains = complainRepo.findAllByComplainAtBetween(start, end);
|
|
|
|
|
|
List<GradingOrganization> gradingOrganizations = gradingOrganizationRepo.findAll();
|
|
|
@@ -103,16 +116,24 @@ public class ReportService {
|
|
|
Map<String, Organization> organizationMap = organizations
|
|
|
.stream()
|
|
|
.collect(Collectors.toMap(Organization::getUscc, or -> or));
|
|
|
-
|
|
|
+ //备案考级机构
|
|
|
Map<String, List<Record>> examinationAgency = records.stream()
|
|
|
.collect(Collectors.groupingBy(Record::getExaminationAgency));
|
|
|
-
|
|
|
+ //备案承办单位
|
|
|
Map<String, List<Record>> organizer = records.stream()
|
|
|
.collect(Collectors.groupingBy(Record::getUscc));
|
|
|
-
|
|
|
+ //备案监管
|
|
|
+ List<Long> recordIds = records.stream().map(Record::getId).collect(Collectors.toList());
|
|
|
+ List<RecordExpertAudit> recordAudits = recordExpertAuditRepo.findAllByRecordIdIn(recordIds);
|
|
|
+ Map<String, Long> typeCount = recordAudits.stream()
|
|
|
+ .filter(ra -> !ra.isValue())
|
|
|
+ .collect(Collectors.groupingBy(RecordExpertAudit::getType, Collectors.counting()));
|
|
|
+
|
|
|
+ //投诉
|
|
|
Map<Long, List<Complain>> complainsByName = complains.stream()
|
|
|
.collect(Collectors.groupingBy(Complain::getUnitName));
|
|
|
|
|
|
+
|
|
|
// 没有备案但是被投诉
|
|
|
Set<Long> ids = new HashSet<>(complainsByName.keySet());
|
|
|
|
|
|
@@ -126,6 +147,11 @@ public class ReportService {
|
|
|
List<Record> recordList = examinationAgency.get(key);
|
|
|
int examCenterQuantity = recordList.stream().mapToInt(Record::getExamCenterQuantity).sum();
|
|
|
int examQuantity = recordList.stream().mapToInt(Record::getExamQuantity).sum();
|
|
|
+// // 备案检查
|
|
|
+// List<Long> rids = recordList.stream().map(Record::getId).collect(Collectors.toList());
|
|
|
+// Map<String, Long> type = recordAudits.stream()
|
|
|
+// .filter(ra -> ids.contains(ra.getRecordId()) && !ra.isValue())
|
|
|
+// .collect(Collectors.groupingBy(RecordExpertAudit::getType, Collectors.counting()));
|
|
|
|
|
|
reportDTOS.add(ReportDTO.builder()
|
|
|
.unitType(UnitType.GRADING_ORGANIZATION)
|
|
|
@@ -187,9 +213,6 @@ public class ReportService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- report.setTime(time);
|
|
|
- reportRepo.save(report);
|
|
|
-
|
|
|
return reportDTOS;
|
|
|
}
|
|
|
}
|