Browse Source

监管报告

licailing 4 years ago
parent
commit
e9e981431b

+ 2 - 0
src/main/java/com/izouma/wenlvju/domain/regulation/Report.java

@@ -21,6 +21,8 @@ import javax.persistence.Enumerated;
 public class Report extends BaseEntity {
     private String title;
 
+    private String time;
+
     @Enumerated(EnumType.STRING)
     private ReportType type;
 

+ 35 - 0
src/main/java/com/izouma/wenlvju/domain/regulation/ReportStatistic.java

@@ -0,0 +1,35 @@
+package com.izouma.wenlvju.domain.regulation;
+
+import com.izouma.wenlvju.domain.BaseEntity;
+import com.izouma.wenlvju.enums.UnitType;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+
+@Data
+@Builder
+@NoArgsConstructor
+public class ReportStatistic extends BaseEntity {
+    @Enumerated(EnumType.STRING)
+    @ApiModelProperty(value = "单位类型")
+    private UnitType unitType;
+
+    @ApiModelProperty(value = "名称")
+    private String name;
+
+    @ApiModelProperty(value = "投诉条数")
+    private int complain;
+
+    @ApiModelProperty(value = "投诉内容")
+    private String complainContent;
+
+    @ApiModelProperty(value = "考级数量")
+    private int examCenterQuantity;
+
+    @ApiModelProperty(value = "报考人数")
+    private int examQuantity;
+}

+ 48 - 11
src/main/java/com/izouma/wenlvju/service/regulation/ReportService.java

@@ -1,6 +1,8 @@
 package com.izouma.wenlvju.service.regulation;
 
+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.Report;
@@ -40,30 +42,62 @@ public class ReportService {
     /**
      * 生成报告
      */
-    public void generate(Report report) {
-        List<Record> records = new ArrayList<>();
-        List<Complain> complains = new ArrayList<>();
+    public List<ReportDTO> generate(Report report) {
+        List<Record> records;
+        List<Complain> complains;
+
+        // 开始结束时间
+        int year = Integer.parseInt(report.getYear());
+        LocalDateTime start = LocalDateTime.of(year, 1, 1, 0, 0);
+        LocalDateTime end = LocalDateTime.of(year, 12, 31, 23, 59, 59, 59);
+
+        //  名称
+
+
         switch (report.getType()) {
             case ANNUAL:
-                int year = Integer.parseInt(report.getYear());
-                LocalDateTime start = LocalDateTime.of(year, 1, 1, 0, 0);
-                LocalDateTime end = LocalDateTime.of(year, 12, 31, 23, 59, 59, 59);
-                records = recordRepo.findAllByExaminationStartTimeBetween(start.toLocalDate(), end.toLocalDate());
-                complains = complainRepo.findAllByComplainAtBetween(start, end);
+
                 break;
             case QUARTERLY:
+                int quarterly = Integer.parseInt(report.getQuarterly());
+                switch (quarterly) {
+                    case 1:
+                        end = LocalDateTime.of(year, 3, 31, 23, 59, 59, 59);
+                        break;
+                    case 2:
+                        start = LocalDateTime.of(year, 4, 1, 0, 0);
+                        end = LocalDateTime.of(year, 6, 30, 23, 59, 59, 59);
+                        break;
+                    case 3:
+                        start = LocalDateTime.of(year, 7, 1, 0, 0);
+                        end = LocalDateTime.of(year, 9, 30, 23, 59, 59, 59);
+                        break;
+                    case 4:
+                        start = LocalDateTime.of(year, 10, 1, 0, 0, 0);
+                        break;
+                }
+
                 break;
             case MONTHLY:
                 break;
         }
+        records = recordRepo.findAllByExaminationStartTimeBetween(start.toLocalDate(), end.toLocalDate());
+        complains = complainRepo.findAllByComplainAtBetween(start, end);
+
         Map<String, GradingOrganization> gradingOrganizationMap = gradingOrganizationRepo.findAll()
                 .stream()
                 .collect(Collectors.toMap(GradingOrganization::getName, go -> go));
+
+        Map<String, Organization> organizationMap = organizationRepo.findAll()
+                .stream()
+                .filter(or -> ObjectUtil.isNotNull(or.getUscc()))
+                .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::getOrganizer));
+                .collect(Collectors.groupingBy(Record::getUscc));
 
         Map<Long, List<Complain>> complainsByName = complains.stream()
                 .collect(Collectors.groupingBy(Complain::getUnitName));
@@ -90,9 +124,9 @@ public class ReportService {
         });
 
         organizer.forEach((key, value) -> {
-            GradingOrganization go = gradingOrganizationMap.get(key);
+            Organization or = organizationMap.get(key);
             // 投诉
-            List<Complain> complainList = complainsByName.get(go.getId());
+            List<Complain> complainList = complainsByName.get(or.getId());
             String complainContent = complainList.stream().map(Complain::getTitle).collect(Collectors.joining(","));
             // 备案
             List<Record> recordList = examinationAgency.get(key);
@@ -108,5 +142,8 @@ public class ReportService {
                     .examQuantity(examQuantity)
                     .build());
         });
+
+
+        return reportDTOS;
     }
 }

+ 0 - 1
src/main/java/com/izouma/wenlvju/utils/JpaUtils.java

@@ -1,6 +1,5 @@
 package com.izouma.wenlvju.utils;
 
-import cn.hutool.core.convert.Convert;
 import com.izouma.wenlvju.annotations.Searchable;
 import com.izouma.wenlvju.annotations.SearchableOne;
 import com.izouma.wenlvju.dto.PageQuery;

+ 12 - 2
src/main/vue/src/views/ReportList.vue

@@ -30,7 +30,12 @@
                 </el-form-item>
                 <el-form-item label="季度" v-if="form.type != 'ANNUAL'">
                     <el-select v-model="form.quarterly" clearable style="width: 110px">
-                        <el-option v-for="item in quarterlys" :key="item" :value="item" :label="item"></el-option>
+                        <el-option
+                            v-for="item in quarterlys"
+                            :key="item.value"
+                            :value="item.value"
+                            :label="item.label"
+                        ></el-option>
                     </el-select>
                 </el-form-item>
                 <el-form-item label="月份" v-if="form.type != 'ANNUAL' && form.type != 'QUARTERLY'">
@@ -110,7 +115,12 @@ export default {
             ],
             form: {},
             years: ['2021', '2022', '2023', '2024'],
-            quarterlys: ['一季度', '二季度', '三季度', '四季度'],
+            quarterlys: [
+                { label: '一季度', value: 1 },
+                { label: '二季度', value: 2 },
+                { label: '三季度', value: 3 },
+                { label: '四季度', value: 4 }
+            ],
             months: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
         };
     },

+ 23 - 0
src/test/java/com/izouma/wenlvju/service/regulation/ReportServiceTest.java

@@ -0,0 +1,23 @@
+package com.izouma.wenlvju.service.regulation;
+
+
+import com.izouma.wenlvju.ApplicationTests;
+import com.izouma.wenlvju.domain.regulation.Report;
+import com.izouma.wenlvju.enums.ReportType;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ReportServiceTest extends ApplicationTests {
+    @Autowired
+    private ReportService reportService;
+
+    @Test
+    public void test() {
+        Report report = Report.builder()
+                .year("2021")
+                .type(ReportType.ANNUAL)
+                .build();
+        reportService.generate(report);
+    }
+
+}