wangys 6 vuotta sitten
vanhempi
commit
41e12cbc74
20 muutettua tiedostoa jossa 225 lisäystä ja 33 poistoa
  1. 1 1
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/entity/Company.java
  2. 3 3
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/entity/Manage.java
  3. 6 2
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/entity/Product.java
  4. 3 1
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/entity/Project.java
  5. 4 0
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/CompanyService.java
  6. 2 0
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/CostTypeService.java
  7. 2 0
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/ProductService.java
  8. 2 0
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/ProjectService.java
  9. 23 0
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/CompanyServiceImpl.java
  10. 12 1
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/CostTypeServiceImpl.java
  11. 1 1
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/DepartmentServiceImpl.java
  12. 3 3
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/ManageServiceImpl.java
  13. 40 2
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/ProductServiceImpl.java
  14. 28 2
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/ProjectServiceImpl.java
  15. 1 1
      efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/vo/DeptTreeVO.java
  16. 0 15
      efunbox-base/efunbox-base-web/pom.xml
  17. 45 0
      efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/CompanyController.java
  18. 39 0
      efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/CostTypeController.java
  19. 5 1
      efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/ProductController.java
  20. 5 0
      efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/ProjectController.java

+ 1 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/entity/Company.java

@@ -24,7 +24,7 @@ import java.util.Date;
 public class Company implements Serializable {
 
     @Id
-    private String id;
+    private Long id;
 
     @Column(name = "name")
     private String name;

+ 3 - 3
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/entity/Manage.java

@@ -33,13 +33,13 @@ public class Manage implements Serializable {
     private Long deptId;
 
     @Column(name = "product_id")
-    private String productId;
+    private Long productId;
 
     @Column(name = "project_id")
-    private String projectId;
+    private Long projectId;
 
     @Column(name = "company_id")
-    private String companyId;
+    private Long companyId;
 
     @Enumerated(EnumType.ORDINAL)
     private ManageTypeEnum type;

+ 6 - 2
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/entity/Product.java

@@ -23,13 +23,13 @@ import java.util.Date;
 public class Product implements Serializable {
 
     @Id
-    private String id;
+    private Long id;
 
     @Column(name = "dept_id")
     private Long deptId;
 
     @Column(name = "project_id")
-    private String projectId;
+    private Long projectId;
 
     @Column(name = "code")
     private String code;
@@ -48,4 +48,8 @@ public class Product implements Serializable {
 
     @Column(name = "gmt_modified")
     private Date gmtModified;
+
+    private Department department;
+
+    private Project project;
 }

+ 3 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/entity/Project.java

@@ -23,7 +23,7 @@ import java.util.Date;
 public class Project implements Serializable {
 
     @Id
-    private String id;
+    private Long id;
 
     @Column(name = "code")
     private String code;
@@ -49,4 +49,6 @@ public class Project implements Serializable {
     @Column(name = "gmt_modified")
     private Date gmtModified;
 
+    private Department department;
+
 }

+ 4 - 0
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/CompanyService.java

@@ -10,4 +10,8 @@ public interface CompanyService {
     ApiResult save(Company company);
 
     ApiResult update(Company company);
+
+    ApiResult getById(Long companyId);
+
+    ApiResult select();
 }

+ 2 - 0
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/CostTypeService.java

@@ -10,4 +10,6 @@ public interface CostTypeService {
     ApiResult save(CostType costType);
 
     ApiResult update(CostType costType);
+
+    ApiResult select(CostType costType);
 }

+ 2 - 0
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/ProductService.java

@@ -12,4 +12,6 @@ public interface ProductService {
     ApiResult update(Product product);
 
     ApiResult getProductById(String productId);
+
+    ApiResult getSelect();
 }

+ 2 - 0
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/ProjectService.java

@@ -12,4 +12,6 @@ public interface ProjectService {
     ApiResult update(Project project);
 
     ApiResult getProjectById(String projectId);
+
+    ApiResult getSelect();
 }

+ 23 - 0
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/CompanyServiceImpl.java

@@ -35,6 +35,9 @@ public class CompanyServiceImpl implements CompanyService {
 
     @Override
     public ApiResult save(Company company) {
+        if(company == null){
+            return ApiResult.error(ApiCode.PARAMETER_ERROR);
+        }
         company = companyRepository.save(company);
         if(Objects.nonNull(company)){
             return ApiResult.ok(company);
@@ -44,10 +47,30 @@ public class CompanyServiceImpl implements CompanyService {
 
     @Override
     public ApiResult update(Company company) {
+        if(company == null){
+            return ApiResult.error(ApiCode.PARAMETER_ERROR);
+        }
         company = companyRepository.update(company);
         if(Objects.nonNull(company)){
             return ApiResult.ok(company);
         }
         return ApiResult.error(ApiCode.UNKNOWN_ERROR);
     }
+
+    @Override
+    public ApiResult getById(Long companyId) {
+        if(Objects.isNull(companyId)){
+            return ApiResult.error(ApiCode.PARAMETER_ERROR);
+        }
+        Company company = companyRepository.find(companyId);
+        if(Objects.nonNull(company)){
+            return ApiResult.ok(company);
+        }
+        return ApiResult.error(ApiCode.UNKNOWN_ERROR);
+    }
+
+    @Override
+    public ApiResult select() {
+        return ApiResult.ok(companyRepository.findByStatusOrderBySortDesc(BaseStatusEnum.NORMAL));
+    }
 }

+ 12 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/CostTypeServiceImpl.java

@@ -25,7 +25,7 @@ public class CostTypeServiceImpl implements CostTypeService {
 
     @Override
     public ApiResult list(CostType costType) {
-        List<CostType> costTypes = costTypeRepository.findByStatusOrderBySortDesc(BaseStatusEnum.NORMAL);
+        List<CostType> costTypes = costTypeRepository.find(costType);
         if(Objects.nonNull(costTypes)){
             return ApiResult.ok(costTypes);
         }
@@ -34,6 +34,9 @@ public class CostTypeServiceImpl implements CostTypeService {
 
     @Override
     public ApiResult save(CostType costType) {
+        if(costType == null){
+            return ApiResult.error(ApiCode.PARAMETER_ERROR);
+        }
         costType = costTypeRepository.save(costType);
         if(Objects.nonNull(costType)){
             return ApiResult.ok(costType);
@@ -43,10 +46,18 @@ public class CostTypeServiceImpl implements CostTypeService {
 
     @Override
     public ApiResult update(CostType costType) {
+        if(costType == null){
+            return ApiResult.error(ApiCode.PARAMETER_ERROR);
+        }
         costType = costTypeRepository.update(costType);
         if(Objects.nonNull(costType)){
             return ApiResult.ok(costType);
         }
         return ApiResult.error(ApiCode.UNKNOWN_ERROR);
     }
+
+    @Override
+    public ApiResult select(CostType costType) {
+        return ApiResult.ok(costTypeRepository.findByStatusOrderBySortDesc(BaseStatusEnum.NORMAL));
+    }
 }

+ 1 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/DepartmentServiceImpl.java

@@ -89,7 +89,7 @@ public class DepartmentServiceImpl implements DepartmentService {
         Department department = departmentRepository.find(cid);
         DeptTreeVO node = new DeptTreeVO();
         node.setLabel(department.getName());
-        node.setCid(department.getId());
+        node.setId(department.getId());
         List<Department> childTreeNodes = departmentRepository.findByPath(cid);
         for(Department child : childTreeNodes){
             DeptTreeVO n = recursiveTree(child.getId()); //递归

+ 3 - 3
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/ManageServiceImpl.java

@@ -35,13 +35,13 @@ public class ManageServiceImpl implements ManageService {
             public Predicate toPredicate(Root<Manage> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
 
                 List<Predicate> predicates = new ArrayList<>();
-                if(!StringUtils.equals("0", manage.getCompanyId()) && StringUtils.isNotBlank(manage.getCompanyId())){
+                if(0 == manage.getCompanyId() && Objects.nonNull(manage.getCompanyId())){
                     predicates.add(criteriaBuilder.equal(root.get("companyId"), manage.getCompanyId()));
                 }
-                if(!StringUtils.equals("0", manage.getProductId()) && StringUtils.isNotBlank(manage.getProductId())){
+                if(0 == manage.getProductId() && Objects.nonNull(manage.getProductId())){
                     predicates.add(criteriaBuilder.equal(root.get("productId"), manage.getProductId()));
                 }
-                if(!StringUtils.equals("0", manage.getProductId()) && StringUtils.isNotBlank(manage.getProductId())){
+                if(0 == manage.getProductId() && Objects.nonNull(manage.getProductId())){
                     predicates.add(criteriaBuilder.equal(root.get("projectId"), manage.getProductId()));
                 }
                 if(Objects.nonNull(manage.getType())){

+ 40 - 2
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/ProductServiceImpl.java

@@ -1,16 +1,19 @@
 package cn.efunbox.manage.base.service.impl;
 
+import cn.efunbox.manage.base.entity.Department;
 import cn.efunbox.manage.base.entity.Product;
+import cn.efunbox.manage.base.entity.Project;
 import cn.efunbox.manage.base.enums.BaseStatusEnum;
+import cn.efunbox.manage.base.repository.DepartmentRepository;
 import cn.efunbox.manage.base.repository.ProductRepository;
+import cn.efunbox.manage.base.repository.ProjectRepository;
 import cn.efunbox.manage.base.service.ProductService;
 import cn.efunbox.manage.common.result.ApiCode;
 import cn.efunbox.manage.common.result.ApiResult;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * ProductServiceImpl
@@ -22,9 +25,39 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     ProductRepository productRepository;
 
+    @Autowired
+    ProjectRepository projectRepository;
+
+    @Autowired
+    DepartmentRepository departmentRepository;
+
     @Override
     public ApiResult list(Product product) {
         List<Product> products = productRepository.findByStatusOrderBySortDesc(BaseStatusEnum.NORMAL);
+        List<Long> deptIds = new ArrayList<>();
+        List<Long> projectIds = new ArrayList<>();
+        products.stream().forEach(p -> {
+            deptIds.add(p.getDeptId());
+            projectIds.add(p.getProjectId());
+        });
+        List<Project> projects =  projectRepository.findByIds(projectIds);
+        List<Department> departments = departmentRepository.findByIds(deptIds);
+
+        Map<Long, Project> projectMap = new HashMap<>();
+        Map<Long, Department> departmentMap = new HashMap<>();
+
+        projects.stream().forEach(p -> {
+            projectMap.put(p.getId(), p);
+        });
+        departments.stream().forEach(p -> {
+            departmentMap.put(p.getId(), p);
+        });
+
+        products.stream().forEach(p -> {
+            p.setProject(projectMap.get(p.getProjectId()));
+            p.setDepartment(departmentMap.get(p.getDeptId()));
+        });
+
         if(Objects.nonNull(products)){
             return ApiResult.ok(products);
         }
@@ -66,4 +99,9 @@ public class ProductServiceImpl implements ProductService {
         }
         return ApiResult.ok(product);
     }
+
+    @Override
+    public ApiResult getSelect(){
+        return ApiResult.ok(productRepository.findByStatusOrderBySortDesc(BaseStatusEnum.NORMAL));
+    }
 }

+ 28 - 2
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/ProjectServiceImpl.java

@@ -1,7 +1,9 @@
 package cn.efunbox.manage.base.service.impl;
 
+import cn.efunbox.manage.base.entity.Department;
 import cn.efunbox.manage.base.entity.Project;
 import cn.efunbox.manage.base.enums.BaseStatusEnum;
+import cn.efunbox.manage.base.repository.DepartmentRepository;
 import cn.efunbox.manage.base.repository.ProjectRepository;
 import cn.efunbox.manage.base.service.ProjectService;
 import cn.efunbox.manage.common.result.ApiCode;
@@ -9,8 +11,7 @@ import cn.efunbox.manage.common.result.ApiResult;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * ProjectServiceImpl
@@ -22,9 +23,26 @@ public class ProjectServiceImpl implements ProjectService {
     @Autowired
     ProjectRepository projectRepository;
 
+    @Autowired
+    DepartmentRepository departmentRepository;
+
     @Override
     public ApiResult list(Project project) {
         List<Project> projects = projectRepository.find(project);
+        List<Long> deptIds = new ArrayList<>();
+        projects.stream().forEach(p -> {
+            deptIds.add(p.getDeptId());
+        });
+        List<Department> departments = departmentRepository.findByIds(deptIds);
+        Map<Long, Department> departmentMap = new HashMap<>();
+        departments.stream().forEach(department -> {
+            departmentMap.put(department.getId(), department);
+        });
+
+        projects.stream().forEach(p ->{
+            p.setDepartment(departmentMap.get(p.getDeptId()));
+        });
+
         if(Objects.nonNull(projects)){
             return ApiResult.ok(projects);
         }
@@ -60,4 +78,12 @@ public class ProjectServiceImpl implements ProjectService {
         }
         return ApiResult.ok(project);
     }
+
+    @Override
+    public ApiResult getSelect() {
+        List<Project> projects = projectRepository.findByStatusOrderBySortDesc(BaseStatusEnum.NORMAL);
+        return ApiResult.ok(projects);
+    }
+
+
 }

+ 1 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/vo/DeptTreeVO.java

@@ -15,7 +15,7 @@ public class DeptTreeVO {
 
     private String label;
 
-    private Long cid;
+    private Long id;
 
     private List<DeptTreeVO> children = new ArrayList<>();
 

+ 0 - 15
efunbox-base/efunbox-base-web/pom.xml

@@ -109,21 +109,6 @@
                     <outputDirectory>../target</outputDirectory>
                 </configuration>
             </plugin>
-            <!--<plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <version>1.5.7.RELEASE</version>
-                <configuration>
-                    <outputDirectory>../target</outputDirectory>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>-->
         </plugins>
     </build>
 </project>

+ 45 - 0
efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/CompanyController.java

@@ -0,0 +1,45 @@
+package cn.efunbox.manage.base.controller;
+
+import cn.efunbox.manage.base.entity.Company;
+import cn.efunbox.manage.base.service.CompanyService;
+import cn.efunbox.manage.common.result.ApiResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * CompanyController
+ * Created by wangys on 2019/03/13
+ */
+@RestController
+@RequestMapping("/company")
+public class CompanyController {
+
+    @Autowired
+    CompanyService companyService;
+
+    @PostMapping
+    public ApiResult save(Company company){
+        return companyService.save(company);
+    }
+
+    @PutMapping
+    public ApiResult update(Company company){
+        return companyService.update(company);
+    }
+
+    @GetMapping
+    public ApiResult list(Company company){
+        return companyService.list(company);
+    }
+
+    @GetMapping("/{id}")
+    public ApiResult getById(@PathVariable(name ="id") Long companyId){
+        return companyService.getById(companyId);
+    }
+
+    @GetMapping("/select")
+    public ApiResult select(){
+        return companyService.select();
+    }
+
+}

+ 39 - 0
efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/CostTypeController.java

@@ -0,0 +1,39 @@
+package cn.efunbox.manage.base.controller;
+
+import cn.efunbox.manage.base.entity.CostType;
+import cn.efunbox.manage.base.service.CostTypeService;
+import cn.efunbox.manage.common.result.ApiResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * CostTypeController
+ * Created by wangys on 2019/03/13
+ */
+@RestController
+@RequestMapping("/costType")
+public class CostTypeController {
+
+    @Autowired
+    CostTypeService costTypeService;
+
+    @PostMapping
+    public ApiResult save(CostType costType){
+        return costTypeService.save(costType);
+    }
+
+    @PutMapping
+    public ApiResult update(CostType costType){
+        return costTypeService.update(costType);
+    }
+
+    @GetMapping
+    public ApiResult list(CostType costType){
+        return costTypeService.list(costType);
+    }
+
+    @GetMapping("/select")
+    public ApiResult select(CostType costType){
+        return costTypeService.select(costType);
+    }
+}

+ 5 - 1
efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/ProductController.java

@@ -32,10 +32,14 @@ public class ProductController {
         return productService.list(product);
     }
 
-
     @GetMapping("/{id}")
     public ApiResult findById(@PathVariable(name = "id") String productId){
         return productService.getProductById(productId);
     }
 
+    @GetMapping("/select")
+    public ApiResult select(){
+        return productService.getSelect();
+    }
+
 }

+ 5 - 0
efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/ProjectController.java

@@ -37,4 +37,9 @@ public class ProjectController {
     public ApiResult findById(@PathVariable(name = "id") String projectId){
         return projectService.getProjectById(projectId);
     }
+
+    @GetMapping("/select")
+    public ApiResult select(){
+        return projectService.getSelect();
+    }
 }