Browse Source

附件/流程

licailing 5 years ago
parent
commit
b8a4beca9f

+ 5 - 1
src/main/java/com/izouma/uwip/domain/Handle.java

@@ -2,14 +2,18 @@ package com.izouma.uwip.domain;
 
 
 import com.izouma.uwip.enums.LogoWorkflow;
 import com.izouma.uwip.enums.LogoWorkflow;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
+import lombok.Builder;
 import lombok.Data;
 import lombok.Data;
 
 
+import java.time.LocalDateTime;
+
 @Data
 @Data
+@Builder
 @ApiModel(value = "处理人")
 @ApiModel(value = "处理人")
 public class Handle {
 public class Handle {
     private Long userId;
     private Long userId;
 
 
-    private Long checkAt;
+    private LocalDateTime checkAt;
 
 
     private LogoWorkflow logoWorkflow;
     private LogoWorkflow logoWorkflow;
 
 

+ 4 - 3
src/main/java/com/izouma/uwip/domain/LogoPatent.java

@@ -2,7 +2,7 @@ package com.izouma.uwip.domain;
 
 
 import com.izouma.uwip.converter.HandleListConverter;
 import com.izouma.uwip.converter.HandleListConverter;
 import com.izouma.uwip.dto.AttachmentDTO;
 import com.izouma.uwip.dto.AttachmentDTO;
-import com.izouma.uwip.enums.LogoApplyStatus;
+import com.izouma.uwip.enums.ApplyStatus;
 import com.izouma.uwip.enums.LogoWorkflow;
 import com.izouma.uwip.enums.LogoWorkflow;
 import com.izouma.uwip.enums.PayRatio;
 import com.izouma.uwip.enums.PayRatio;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
@@ -15,6 +15,7 @@ import org.hibernate.annotations.Where;
 
 
 import javax.persistence.*;
 import javax.persistence.*;
 import java.time.LocalDate;
 import java.time.LocalDate;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 @Data
 @Data
@@ -34,7 +35,7 @@ public class LogoPatent extends BaseEntity {
     private Long clientPartnerId;
     private Long clientPartnerId;
 
 
     @Enumerated(EnumType.STRING)
     @Enumerated(EnumType.STRING)
-    private LogoApplyStatus applyStatus;
+    private ApplyStatus applyStatus;
 
 
     @Enumerated(EnumType.STRING)
     @Enumerated(EnumType.STRING)
     private LogoWorkflow logoWorkflow;
     private LogoWorkflow logoWorkflow;
@@ -90,7 +91,7 @@ public class LogoPatent extends BaseEntity {
 
 
     @Column(columnDefinition = "TEXT")
     @Column(columnDefinition = "TEXT")
     @Convert(converter = HandleListConverter.class)
     @Convert(converter = HandleListConverter.class)
-    private List<Handle> handle;
+    private List<Handle> handle = new ArrayList<>();
 
 
     private int sort;
     private int sort;
 
 

+ 5 - 1
src/main/java/com/izouma/uwip/enums/AuthorityName.java

@@ -3,7 +3,11 @@ package com.izouma.uwip.enums;
 public enum AuthorityName {
 public enum AuthorityName {
     ROLE_USER("普通用户"),
     ROLE_USER("普通用户"),
     ROLE_DEV("开发者"),
     ROLE_DEV("开发者"),
-    ROLE_ADMIN("管理员");
+    ROLE_ADMIN("管理员"),
+    ROLE_ACCOUNT("客户经理"),
+    ROLE_PROJECT("项目经理"),
+    ROLE_TRANSLATE("翻译经理"),
+    ;
     private final String description;
     private final String description;
 
 
     AuthorityName(String description) {
     AuthorityName(String description) {

+ 17 - 8
src/main/java/com/izouma/uwip/enums/LogoWorkflow.java

@@ -2,24 +2,33 @@ package com.izouma.uwip.enums;
 
 
 /*
 /*
 商标申请流程
 商标申请流程
+1 客户经理
+2 项目经理
+3 翻译经理
  */
  */
 public enum LogoWorkflow {
 public enum LogoWorkflow {
-    IS_CONTRACT("是否决定签约"),
-    TO_BE_MAINTAINED("待维护案件"),
-    PENDING("待受理"),
-    PENDING_REVIEW("待审查"),
-    DISMISS("驳回处理"),
-    ANNOUNCEMENTS("公告初审"),
-    HANDLE("证件办理"),
+    IS_CONTRACT("是否决定签约", 1),
+    TO_BE_MAINTAINED("待维护案件", 2),
+    PENDING("待受理", 2),
+    PENDING_REVIEW("待审查", 2),
+    DISMISS("驳回处理", 2),
+    ANNOUNCEMENTS("公告初审", 2),
+    HANDLE("证件办理", 2),
     ;
     ;
 
 
     private final String description;
     private final String description;
+    private final int    authority;
 
 
     public String getDescription() {
     public String getDescription() {
         return description;
         return description;
     }
     }
 
 
-    LogoWorkflow(String description) {
+    public int getAuthority() {
+        return authority;
+    }
+
+    LogoWorkflow(String description, int authority) {
         this.description = description;
         this.description = description;
+        this.authority = authority;
     }
     }
 }
 }

+ 66 - 5
src/main/java/com/izouma/uwip/service/LogoPatentService.java

@@ -1,26 +1,31 @@
 package com.izouma.uwip.service;
 package com.izouma.uwip.service;
 
 
+import cn.hutool.core.util.ObjectUtil;
+import com.izouma.uwip.domain.Handle;
 import com.izouma.uwip.domain.LogoPatent;
 import com.izouma.uwip.domain.LogoPatent;
 import com.izouma.uwip.domain.Partner;
 import com.izouma.uwip.domain.Partner;
 import com.izouma.uwip.dto.PageQuery;
 import com.izouma.uwip.dto.PageQuery;
-import com.izouma.uwip.enums.CaseStage;
-import com.izouma.uwip.enums.CaseType;
+import com.izouma.uwip.enums.*;
 import com.izouma.uwip.exception.BusinessException;
 import com.izouma.uwip.exception.BusinessException;
 import com.izouma.uwip.repo.LogoPatentRepo;
 import com.izouma.uwip.repo.LogoPatentRepo;
 import com.izouma.uwip.repo.PartnerRepo;
 import com.izouma.uwip.repo.PartnerRepo;
 import com.izouma.uwip.utils.JpaUtils;
 import com.izouma.uwip.utils.JpaUtils;
+import com.izouma.uwip.utils.ObjUtils;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.time.LocalDate;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 
 
 @Service
 @Service
 @AllArgsConstructor
 @AllArgsConstructor
 public class LogoPatentService {
 public class LogoPatentService {
 
 
-    private LogoPatentRepo logoPatentRepo;
-    private PartnerRepo    partnerRepo;
+    private LogoPatentRepo    logoPatentRepo;
+    private PartnerRepo       partnerRepo;
+    private AttachmentService attachmentService;
 
 
     public Page<LogoPatent> all(PageQuery pageQuery) {
     public Page<LogoPatent> all(PageQuery pageQuery) {
         return logoPatentRepo.findAll(JpaUtils.toSpecification(pageQuery, LogoPatent.class), JpaUtils.toPageRequest(pageQuery));
         return logoPatentRepo.findAll(JpaUtils.toSpecification(pageQuery, LogoPatent.class), JpaUtils.toPageRequest(pageQuery));
@@ -30,6 +35,62 @@ public class LogoPatentService {
 //        客户编码(由客户经理填写)+年份+案件类型+连接符+案件阶段[+国家]+序列号
 //        客户编码(由客户经理填写)+年份+案件类型+连接符+案件阶段[+国家]+序列号
         Partner partner = partnerRepo.findById(patent.getClientPartnerId()).orElseThrow(new BusinessException("客户不存在"));
         Partner partner = partnerRepo.findById(patent.getClientPartnerId()).orElseThrow(new BusinessException("客户不存在"));
         int y = LocalDate.now().getYear() - 2000;
         int y = LocalDate.now().getYear() - 2000;
-        return partner.getCode() + y + CaseType.LOGO.getValue() + "——" + CaseStage.DOMESTIC.getValue() + String.format("%03d", patent.getSort());
+        return partner.getCode() + y + CaseType.LOGO.getValue() + "——" + CaseStage.DOMESTIC.getValue() + String.format("%03d", patent
+                .getSort());
+    }
+
+    public Handle saveHandle(LogoWorkflow workflow, Long userId) {
+        return Handle.builder()
+                .logoWorkflow(workflow)
+                .userId(userId)
+                .checkAt(LocalDateTime.now())
+                .build();
+    }
+
+    public LogoPatent save(LogoPatent record, Long id) {
+        if (record.getId() != null) {
+            LogoWorkflow workflow = record.getLogoWorkflow();
+            if (ObjectUtil.isNull(workflow)) {
+                throw new BusinessException("流程为空");
+            }
+            LogoPatent orig = logoPatentRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
+            // 保存附件
+            if (CollectionUtils.isNotEmpty(record.getAttachments())) {
+                attachmentService.batchSave(record.getAttachments(), id, record.getId());
+            }
+            ObjUtils.merge(orig, record);
+            orig.getHandle().add(this.saveHandle(workflow, id));
+            orig.setApplyStatus(this.getApplyStatus(workflow));
+            return logoPatentRepo.save(orig);
+        }
+        if (record.getSort() == 0) {
+            record.setSort(logoPatentRepo.findMax());
+        }
+        record.setUwNo(this.getUwNo(record));
+        record = logoPatentRepo.save(record);
+        // 保存附件
+        if (CollectionUtils.isNotEmpty(record.getAttachments())) {
+            attachmentService.batchSave(record.getAttachments(), id, record.getId());
+        }
+        record.setLogoWorkflow(LogoWorkflow.IS_CONTRACT);
+        record.setApplyStatus(ApplyStatus.APPLY_STAGE);
+        return record;
+    }
+
+    public ApplyStatus getApplyStatus(LogoWorkflow logoWorkflow) {
+        switch (logoWorkflow) {
+            case IS_CONTRACT:
+            case TO_BE_MAINTAINED:
+            case PENDING:
+                return ApplyStatus.APPLY_STAGE;
+            case PENDING_REVIEW:
+            case DISMISS:
+            case ANNOUNCEMENTS:
+                return ApplyStatus.REVIEW_STAGE;
+            case HANDLE:
+                return ApplyStatus.GRANT_STAGE;
+            default:
+                return ApplyStatus.COMPLETED;
+        }
     }
     }
 }
 }

+ 2 - 27
src/main/java/com/izouma/uwip/web/LogoPatentController.java

@@ -1,17 +1,13 @@
 package com.izouma.uwip.web;
 package com.izouma.uwip.web;
 
 
 import com.izouma.uwip.domain.LogoPatent;
 import com.izouma.uwip.domain.LogoPatent;
-import com.izouma.uwip.domain.Partner;
-import com.izouma.uwip.service.AttachmentService;
 import com.izouma.uwip.service.LogoPatentService;
 import com.izouma.uwip.service.LogoPatentService;
 import com.izouma.uwip.dto.PageQuery;
 import com.izouma.uwip.dto.PageQuery;
 import com.izouma.uwip.exception.BusinessException;
 import com.izouma.uwip.exception.BusinessException;
 import com.izouma.uwip.repo.LogoPatentRepo;
 import com.izouma.uwip.repo.LogoPatentRepo;
-import com.izouma.uwip.utils.ObjUtils;
 import com.izouma.uwip.utils.SecurityUtils;
 import com.izouma.uwip.utils.SecurityUtils;
 import com.izouma.uwip.utils.excel.ExcelUtils;
 import com.izouma.uwip.utils.excel.ExcelUtils;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
-import org.apache.commons.collections.CollectionUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
@@ -26,33 +22,12 @@ import java.util.List;
 public class LogoPatentController extends BaseController {
 public class LogoPatentController extends BaseController {
     private LogoPatentService logoPatentService;
     private LogoPatentService logoPatentService;
     private LogoPatentRepo    logoPatentRepo;
     private LogoPatentRepo    logoPatentRepo;
-    private AttachmentService attachmentService;
 
 
     //@PreAuthorize("hasRole('ADMIN')")
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     @PostMapping("/save")
     public LogoPatent save(@RequestBody LogoPatent record) {
     public LogoPatent save(@RequestBody LogoPatent record) {
-
-        if (record.getId() != null) {
-            LogoPatent orig = logoPatentRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
-            // 保存附件
-            if (CollectionUtils.isNotEmpty(record.getAttachments())) {
-                attachmentService.batchSave(record.getAttachments(), SecurityUtils.getAuthenticatedUser()
-                        .getId(), record.getId());
-            }
-            ObjUtils.merge(orig, record);
-            return logoPatentRepo.save(orig);
-        }
-        if (record.getSort() == 0) {
-            record.setSort(logoPatentRepo.findMax());
-        }
-        record.setUwNo(logoPatentService.getUwNo(record));
-        record = logoPatentRepo.save(record);
-        // 保存附件
-        if (CollectionUtils.isNotEmpty(record.getAttachments())) {
-            attachmentService.batchSave(record.getAttachments(), SecurityUtils.getAuthenticatedUser()
-                    .getId(), record.getId());
-        }
-        return record;
+        Long id = SecurityUtils.getAuthenticatedUser().getId();
+        return logoPatentService.save(record, id);
     }
     }