|
|
@@ -1,5 +1,6 @@
|
|
|
package com.izouma.uwip.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.izouma.uwip.domain.Handle;
|
|
|
@@ -21,10 +22,7 @@ import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@@ -78,17 +76,23 @@ public class PatentService {
|
|
|
return and;
|
|
|
}
|
|
|
|
|
|
- public void total() {
|
|
|
+ public Map<String, Object> total() {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
List<Patent> patents = patentRepo.findAll();
|
|
|
List<LogoPatent> logoPatents = logoPatentRepo.findAll();
|
|
|
|
|
|
//总数
|
|
|
int total = patents.size() + logoPatents.size();
|
|
|
+ map.put("total", total);
|
|
|
+
|
|
|
//今天
|
|
|
LocalDate now = LocalDate.now();
|
|
|
long pToday = patents.stream().filter(patent -> patent.getCreatedAt().toLocalDate().equals(now)).count();
|
|
|
long lToday = logoPatents.stream().filter(patent -> patent.getCreatedAt().toLocalDate().equals(now)).count();
|
|
|
int today = (int) (pToday + lToday);
|
|
|
+ map.put("today", today);
|
|
|
+
|
|
|
//进行中
|
|
|
List<Patent> pInProgress = patents.stream()
|
|
|
.filter(patent -> !ApplyStatus.COMPLETED.equals(patent.getApplyStatus()))
|
|
|
@@ -96,12 +100,16 @@ public class PatentService {
|
|
|
List<LogoPatent> lInProgress = logoPatents.stream()
|
|
|
.filter(patent -> !ApplyStatus.COMPLETED.equals(patent.getApplyStatus()))
|
|
|
.collect(Collectors.toList());
|
|
|
-
|
|
|
int inProgress = pInProgress.size() + lInProgress.size();
|
|
|
+ map.put("inProgress", inProgress);
|
|
|
+
|
|
|
//已结束
|
|
|
int end = total - inProgress;
|
|
|
+ map.put("end", end);
|
|
|
+
|
|
|
//代办案件列表
|
|
|
List<PatentDTO> lAgent = lInProgress.stream().map(PatentDTO::new).collect(Collectors.toList());
|
|
|
+// List<PatentDTO> pAgent = pInProgress.stream().map(PatentDTO::new).collect(Collectors.toList());
|
|
|
|
|
|
//数据统计
|
|
|
Map<ApplyStatus, List<Patent>> byPStatus = patents.stream()
|
|
|
@@ -109,10 +117,62 @@ public class PatentService {
|
|
|
|
|
|
Map<ApplyStatus, List<LogoPatent>> byLStatus = logoPatents.stream()
|
|
|
.collect(Collectors.groupingBy(LogoPatent::getApplyStatus));
|
|
|
+ List<LogoPatent> applyLPatent = byLStatus.get(ApplyStatus.APPLY_STAGE);
|
|
|
+ List<Patent> applyPatent = byPStatus.get(ApplyStatus.APPLY_STAGE);
|
|
|
+ int apply = CollUtil.isEmpty(applyLPatent) ? 0 : applyLPatent.size() +
|
|
|
+ ((CollUtil.isEmpty(applyPatent)) ? 0 : applyPatent.size());
|
|
|
+
|
|
|
+ List<LogoPatent> grantLPatent = byLStatus.get(ApplyStatus.GRANT_STAGE);
|
|
|
+ List<Patent> grantPatent = byPStatus.get(ApplyStatus.GRANT_STAGE);
|
|
|
+ int grant = CollUtil.isEmpty(grantLPatent) ? 0 : grantLPatent.size() +
|
|
|
+ ((CollUtil.isEmpty(grantPatent)) ? 0 : grantPatent.size());
|
|
|
+
|
|
|
+ List<LogoPatent> reviewLPatent = byLStatus.get(ApplyStatus.REVIEW_STAGE);
|
|
|
+ List<Patent> reviewPatent = byPStatus.get(ApplyStatus.REVIEW_STAGE);
|
|
|
+ int review = CollUtil.isEmpty(reviewLPatent) ? 0 : reviewLPatent.size() +
|
|
|
+ ((CollUtil.isEmpty(reviewPatent)) ? 0 : reviewPatent.size());
|
|
|
+
|
|
|
+ List<LogoPatent> substantiveLPatent = byLStatus.get(ApplyStatus.SUBSTANTIVE_STAGE);
|
|
|
+ List<Patent> substantivePatent = byPStatus.get(ApplyStatus.SUBSTANTIVE_STAGE);
|
|
|
+ int substantive = CollUtil.isEmpty(substantiveLPatent) ? 0 : substantiveLPatent.size() +
|
|
|
+ ((CollUtil.isEmpty(substantivePatent)) ? 0 : substantivePatent.size());
|
|
|
+
|
|
|
+ map.put("apply", apply);
|
|
|
+ map.put("grant", grant);
|
|
|
+ map.put("review", review);
|
|
|
+ map.put("substantive", substantive);
|
|
|
+
|
|
|
|
|
|
//本周数据对比
|
|
|
+ int dayOfWeek = now.getDayOfWeek().getValue() % 7;
|
|
|
+ Map<LocalDate, Integer> weekMap = getData(patents, logoPatents, now, dayOfWeek);
|
|
|
+ map.put("weekMap", weekMap);
|
|
|
|
|
|
+ //本月数据对比
|
|
|
+ int dayOfMonth = now.getDayOfMonth() - 1;
|
|
|
+ Map<LocalDate, Integer> monthMap = getData(patents, logoPatents, now, dayOfMonth);
|
|
|
+ map.put("monthMap", monthMap);
|
|
|
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<LocalDate, Integer> getData(List<Patent> patents, List<LogoPatent> logoPatents,
|
|
|
+ LocalDate now, int day) {
|
|
|
+ Map<LocalDate, Integer> map = new HashMap<>();
|
|
|
+ while (day >= 0) {
|
|
|
+ LocalDate weekStart = now.minusDays(day);
|
|
|
+
|
|
|
+ long pWeek = patents.stream()
|
|
|
+ .filter(patent -> patent.getCreatedAt().toLocalDate().equals(weekStart))
|
|
|
+ .count();
|
|
|
+ long lWeek = logoPatents.stream()
|
|
|
+ .filter(patent -> patent.getCreatedAt().toLocalDate().equals(weekStart))
|
|
|
+ .count();
|
|
|
+ day--;
|
|
|
+
|
|
|
+ map.put(weekStart, (int) (pWeek + lWeek));
|
|
|
+ }
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
|