|
@@ -8,8 +8,10 @@ import com.izouma.uwip.domain.LogoPatent;
|
|
|
import com.izouma.uwip.domain.Patent;
|
|
import com.izouma.uwip.domain.Patent;
|
|
|
import com.izouma.uwip.dto.PageQuery;
|
|
import com.izouma.uwip.dto.PageQuery;
|
|
|
import com.izouma.uwip.dto.PatentDTO;
|
|
import com.izouma.uwip.dto.PatentDTO;
|
|
|
|
|
+import com.izouma.uwip.dto.TrendDTO;
|
|
|
import com.izouma.uwip.enums.ApplyStatus;
|
|
import com.izouma.uwip.enums.ApplyStatus;
|
|
|
-import com.izouma.uwip.repo.*;
|
|
|
|
|
|
|
+import com.izouma.uwip.repo.LogoPatentRepo;
|
|
|
|
|
+import com.izouma.uwip.repo.PatentRepo;
|
|
|
import com.izouma.uwip.utils.JpaUtils;
|
|
import com.izouma.uwip.utils.JpaUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
@@ -28,11 +30,8 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class PatentService {
|
|
public class PatentService {
|
|
|
|
|
|
|
|
- private final PatentRepo patentRepo;
|
|
|
|
|
- private final LogoPatentRepo logoPatentRepo;
|
|
|
|
|
- private final DomesticPatentRepo domesticPatentRepo;
|
|
|
|
|
- private final InternationalPatentRepo internationalPatentRepo;
|
|
|
|
|
- private final CountryPatentRepo countryPatentRepo;
|
|
|
|
|
|
|
+ private final PatentRepo patentRepo;
|
|
|
|
|
+ private final LogoPatentRepo logoPatentRepo;
|
|
|
|
|
|
|
|
public Page<Patent> all(PageQuery pageQuery) {
|
|
public Page<Patent> all(PageQuery pageQuery) {
|
|
|
return patentRepo.findAll(JpaUtils.toSpecification(pageQuery, Patent.class), JpaUtils.toPageRequest(pageQuery));
|
|
return patentRepo.findAll(JpaUtils.toSpecification(pageQuery, Patent.class), JpaUtils.toPageRequest(pageQuery));
|
|
@@ -84,17 +83,16 @@ public class PatentService {
|
|
|
List<Patent> patents = patentRepo.findAll();
|
|
List<Patent> patents = patentRepo.findAll();
|
|
|
List<LogoPatent> logoPatents = logoPatentRepo.findAll();
|
|
List<LogoPatent> logoPatents = logoPatentRepo.findAll();
|
|
|
|
|
|
|
|
|
|
+ Map<String, Integer> card = new HashMap<>();
|
|
|
//总数
|
|
//总数
|
|
|
int total = patents.size() + logoPatents.size();
|
|
int total = patents.size() + logoPatents.size();
|
|
|
- map.put("total", total);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ card.put("total", total);
|
|
|
//今天
|
|
//今天
|
|
|
LocalDate now = LocalDate.now();
|
|
LocalDate now = LocalDate.now();
|
|
|
long pToday = patents.stream().filter(patent -> patent.getCreatedAt().toLocalDate().equals(now)).count();
|
|
long pToday = patents.stream().filter(patent -> patent.getCreatedAt().toLocalDate().equals(now)).count();
|
|
|
long lToday = logoPatents.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);
|
|
int today = (int) (pToday + lToday);
|
|
|
- map.put("today", today);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ card.put("today", today);
|
|
|
//进行中
|
|
//进行中
|
|
|
List<Patent> pInProgress = patents.stream()
|
|
List<Patent> pInProgress = patents.stream()
|
|
|
.filter(patent -> !ApplyStatus.COMPLETED.equals(patent.getApplyStatus()))
|
|
.filter(patent -> !ApplyStatus.COMPLETED.equals(patent.getApplyStatus()))
|
|
@@ -103,80 +101,68 @@ public class PatentService {
|
|
|
.filter(patent -> !ApplyStatus.COMPLETED.equals(patent.getApplyStatus()))
|
|
.filter(patent -> !ApplyStatus.COMPLETED.equals(patent.getApplyStatus()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
int inProgress = pInProgress.size() + lInProgress.size();
|
|
int inProgress = pInProgress.size() + lInProgress.size();
|
|
|
- map.put("inProgress", inProgress);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ card.put("inProgress", inProgress);
|
|
|
//已结束
|
|
//已结束
|
|
|
int end = total - inProgress;
|
|
int end = total - inProgress;
|
|
|
- map.put("end", end);
|
|
|
|
|
|
|
+ card.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());
|
|
|
|
|
-
|
|
|
|
|
- pInProgress.forEach(patent -> {
|
|
|
|
|
- PatentDTO dto = new PatentDTO(patent);
|
|
|
|
|
- List<Handle> handle = patent.getHandle();
|
|
|
|
|
- int size = handle.size();
|
|
|
|
|
- if (size > 0) {
|
|
|
|
|
- String workflow = handle.get(size - 1).getWorkflow();
|
|
|
|
|
-
|
|
|
|
|
- if ("TRANSLATION_DOCUMENTS".equals(workflow)) {
|
|
|
|
|
- //TRANSLATION_DOCUMENTS 待申请翻译文稿
|
|
|
|
|
- } else if ("SUPPLIER_MATERIALS".equals(workflow)) {
|
|
|
|
|
- //SUPPLIER_MATERIALS 待添加供应商
|
|
|
|
|
- dto.setDate(patent.getSupplierSubmitPeriod());
|
|
|
|
|
- } else if ("DETERMINED_REPLY".equals(workflow)) {
|
|
|
|
|
- //DETERMINED_REPLY 待上传答复通知
|
|
|
|
|
- dto.setDate(patent.getSubmitPeriod());
|
|
|
|
|
- } else if("AUTHORIZE_REGISTER".equals(workflow)){
|
|
|
|
|
- //授权办登通知日
|
|
|
|
|
- } else if("PENDING_REVIEW".equals(workflow)){
|
|
|
|
|
|
|
+ map.put("card", card);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ //代办案件列表
|
|
|
|
|
+ List<PatentDTO> lAgent = lInProgress.stream()
|
|
|
|
|
+ .map(PatentDTO::new)
|
|
|
|
|
+ .filter(agent -> ObjectUtil.isNotNull(agent.getDate()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ List<PatentDTO> pAgent = pInProgress.stream()
|
|
|
|
|
+ .map(PatentDTO::new)
|
|
|
|
|
+ .filter(agent -> ObjectUtil.isNotNull(agent.getDate()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ lAgent.addAll(pAgent);
|
|
|
|
|
+ List<PatentDTO> agents = lAgent.stream()
|
|
|
|
|
+ .sorted(Comparator.comparing(PatentDTO::getDate))
|
|
|
|
|
+ .limit(5)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ map.put("agent", agents);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- });
|
|
|
|
|
//数据统计
|
|
//数据统计
|
|
|
- Map<ApplyStatus, List<Patent>> byPStatus = patents.stream()
|
|
|
|
|
- .collect(Collectors.groupingBy(Patent::getApplyStatus));
|
|
|
|
|
|
|
+ Map<ApplyStatus, Long> byPStatus = patents.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(Patent::getApplyStatus, Collectors.counting()));
|
|
|
|
|
|
|
|
- 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());
|
|
|
|
|
|
|
+ Map<ApplyStatus, Long> byLStatus = logoPatents.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(LogoPatent::getApplyStatus, Collectors.counting()));
|
|
|
|
|
|
|
|
- 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());
|
|
|
|
|
|
|
+ long apply = ObjectUtil.isNull(byPStatus.get(ApplyStatus.APPLY_STAGE)) ? 0 : byPStatus.get(ApplyStatus.APPLY_STAGE) +
|
|
|
|
|
+ ((ObjectUtil.isNull(byLStatus.get(ApplyStatus.APPLY_STAGE))) ? 0 : byLStatus.get(ApplyStatus.APPLY_STAGE));
|
|
|
|
|
|
|
|
- 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());
|
|
|
|
|
|
|
+ long grant = ObjectUtil.isNull(byPStatus.get(ApplyStatus.GRANT_STAGE)) ? 0 : byPStatus.get(ApplyStatus.GRANT_STAGE) +
|
|
|
|
|
+ ((ObjectUtil.isNull(byLStatus.get(ApplyStatus.GRANT_STAGE))) ? 0 : byLStatus.get(ApplyStatus.GRANT_STAGE));
|
|
|
|
|
|
|
|
- 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());
|
|
|
|
|
|
|
+ long review = ObjectUtil.isNull(byPStatus.get(ApplyStatus.REVIEW_STAGE)) ? 0 : byPStatus.get(ApplyStatus.REVIEW_STAGE) +
|
|
|
|
|
+ ((ObjectUtil.isNull(byLStatus.get(ApplyStatus.REVIEW_STAGE))) ? 0 : byLStatus.get(ApplyStatus.REVIEW_STAGE));
|
|
|
|
|
|
|
|
- map.put("apply", apply);
|
|
|
|
|
- map.put("grant", grant);
|
|
|
|
|
- map.put("review", review);
|
|
|
|
|
- map.put("substantive", substantive);
|
|
|
|
|
|
|
+ long substantive = ObjectUtil.isNull(byPStatus.get(ApplyStatus.SUBSTANTIVE_STAGE)) ? 0 : byPStatus.get(ApplyStatus.SUBSTANTIVE_STAGE) +
|
|
|
|
|
+ ((ObjectUtil.isNull(byLStatus.get(ApplyStatus.SUBSTANTIVE_STAGE))) ? 0 : byLStatus.get(ApplyStatus.SUBSTANTIVE_STAGE));
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Long> pie = new HashMap<>();
|
|
|
|
|
+ pie.put("apply", apply);
|
|
|
|
|
+ pie.put("grant", grant);
|
|
|
|
|
+ pie.put("review", review);
|
|
|
|
|
+ pie.put("substantive", substantive);
|
|
|
|
|
+
|
|
|
|
|
+ map.put("pie", pie);
|
|
|
|
|
|
|
|
|
|
|
|
|
//本周数据对比
|
|
//本周数据对比
|
|
|
- int dayOfWeek = now.getDayOfWeek().getValue() % 7;
|
|
|
|
|
|
|
+ int dayOfWeek = now.getDayOfWeek().getValue();
|
|
|
Map<LocalDate, Integer> weekMap = getData(patents, logoPatents, now, dayOfWeek);
|
|
Map<LocalDate, Integer> weekMap = getData(patents, logoPatents, now, dayOfWeek);
|
|
|
map.put("weekMap", weekMap);
|
|
map.put("weekMap", weekMap);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
//本月数据对比
|
|
//本月数据对比
|
|
|
- int dayOfMonth = now.getDayOfMonth() - 1;
|
|
|
|
|
|
|
+ int dayOfMonth = now.getDayOfMonth();
|
|
|
Map<LocalDate, Integer> monthMap = getData(patents, logoPatents, now, dayOfMonth);
|
|
Map<LocalDate, Integer> monthMap = getData(patents, logoPatents, now, dayOfMonth);
|
|
|
map.put("monthMap", monthMap);
|
|
map.put("monthMap", monthMap);
|
|
|
|
|
|
|
@@ -189,23 +175,88 @@ public class PatentService {
|
|
|
2 月
|
|
2 月
|
|
|
3 年
|
|
3 年
|
|
|
*/
|
|
*/
|
|
|
- public Map<Integer, Integer> getTrend(int type) {
|
|
|
|
|
- Map<Integer, Integer> map = new HashMap<>();
|
|
|
|
|
- switch (type) {
|
|
|
|
|
|
|
+ public List<TrendDTO> getTrend(int type) {
|
|
|
|
|
|
|
|
|
|
+ List<TrendDTO> dtos = new ArrayList<>();
|
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
|
+ List<Patent> patents = patentRepo.findAll();
|
|
|
|
|
+ List<LogoPatent> logoPatents = logoPatentRepo.findAll();
|
|
|
|
|
+ switch (type) {
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ int dayOfWeek = now.getDayOfWeek().getValue();
|
|
|
|
|
+ getEveryDay(patents, logoPatents, dtos, now, dayOfWeek);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ int dayOfMonth = now.getDayOfMonth();
|
|
|
|
|
+ getEveryDay(patents, logoPatents, dtos, now, dayOfMonth);
|
|
|
|
|
+ break;
|
|
|
case 3:
|
|
case 3:
|
|
|
|
|
+ int month = now.getMonthValue();
|
|
|
|
|
+ while (month > 0) {
|
|
|
|
|
+ int dp = 0;
|
|
|
|
|
+ int ip = 0;
|
|
|
|
|
+ int cp = 0;
|
|
|
|
|
+ int finalMonth = month;
|
|
|
|
|
+ List<Patent> monthPatents = patents.stream()
|
|
|
|
|
+ .filter(patent -> patent.getCreatedAt().getMonthValue() == finalMonth)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ for (Patent mp : monthPatents) {
|
|
|
|
|
+ if (0 == mp.getCategory()) {
|
|
|
|
|
+ dp++;
|
|
|
|
|
+ } else if (1 == mp.getCategory()) {
|
|
|
|
|
+ ip++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ cp++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ int lp = (int) logoPatents.stream()
|
|
|
|
|
+ .filter(patent -> patent.getCreatedAt().getMonthValue() == finalMonth)
|
|
|
|
|
+ .count();
|
|
|
|
|
+
|
|
|
|
|
+ dtos.add(new TrendDTO(dp, ip, cp, lp, month));
|
|
|
|
|
+ month--;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ return dtos;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return map;
|
|
|
|
|
|
|
+ public void getEveryDay(List<Patent> patents, List<LogoPatent> lPatents, List<TrendDTO> dtos, LocalDate now, int day) {
|
|
|
|
|
+ while (day > 0) {
|
|
|
|
|
+ int dp = 0;
|
|
|
|
|
+ int ip = 0;
|
|
|
|
|
+ int cp = 0;
|
|
|
|
|
+ LocalDate weekStart = now.minusDays(day - 1);
|
|
|
|
|
+ List<Patent> monthPatents = patents.stream()
|
|
|
|
|
+ .filter(patent -> patent.getCreatedAt().toLocalDate().equals(weekStart))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ for (Patent mp : monthPatents) {
|
|
|
|
|
+ if (0 == mp.getCategory()) {
|
|
|
|
|
+ dp++;
|
|
|
|
|
+ } else if (1 == mp.getCategory()) {
|
|
|
|
|
+ ip++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ cp++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ int lp = (int) lPatents.stream()
|
|
|
|
|
+ .filter(patent -> patent.getCreatedAt().toLocalDate().equals(weekStart))
|
|
|
|
|
+ .count();
|
|
|
|
|
+
|
|
|
|
|
+ dtos.add(new TrendDTO(dp, ip, cp, lp, day));
|
|
|
|
|
+ day--;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Map<LocalDate, Integer> getData(List<Patent> patents, List<LogoPatent> logoPatents,
|
|
|
|
|
- LocalDate now, int day) {
|
|
|
|
|
|
|
+ public Map<LocalDate, Integer> getData(List<Patent> patents, List<LogoPatent> logoPatents,
|
|
|
|
|
+ LocalDate now, int day) {
|
|
|
Map<LocalDate, Integer> map = new HashMap<>();
|
|
Map<LocalDate, Integer> map = new HashMap<>();
|
|
|
- while (day >= 0) {
|
|
|
|
|
- LocalDate weekStart = now.minusDays(day);
|
|
|
|
|
|
|
+ while (day > 0) {
|
|
|
|
|
+ LocalDate weekStart = now.minusDays(day - 1);
|
|
|
|
|
|
|
|
long pWeek = patents.stream()
|
|
long pWeek = patents.stream()
|
|
|
.filter(patent -> patent.getCreatedAt().toLocalDate().equals(weekStart))
|
|
.filter(patent -> patent.getCreatedAt().toLocalDate().equals(weekStart))
|