66 Commit-ok fccca2474d ... ac3bafe66d

Szerző SHA1 Üzenet Dátum
  wangys ac3bafe66d 导出bug 5 éve
  wangys b0282ee310 导出表格去除uid验证 5 éve
  wangys 34d324ce7d 导出表格去除uid验证 5 éve
  wangys 06d70980d0 部门下拉排序 5 éve
  wangys 2ebdc5c6f6 经营数据导出excel 5 éve
  wangys a8542c73ea 经营数据导出excel 5 éve
  wangys 7c2bb72303 经营数据导出excel 5 éve
  wangys df0e9f2617 新增部门类型 5 éve
  wangys a9f16e7b13 新增部门类型 5 éve
  wangys 53479406c3 查询数据bug 5 éve
  wangys eb2c837c36 log输出 5 éve
  wangys f2d225ce3a 计算求和 5 éve
  wangys 75af3e8cbc 查询数据部门多选 5 éve
  wangys c50cb0b3fa 查询数据状态bug 5 éve
  wangys 9c099db772 配置文件 5 éve
  wangys 71fe2f0933 增加经营数据状态 5 éve
  wangys ef2611bcdc 查询多选 5 éve
  xushengqiang 27f78564ea bug fix 5 éve
  xushengqiang 9c0505a455 bug fix 5 éve
  xushengqiang 0b7b73e5bc bug fix 5 éve
  xushengqiang 48d2fccc15 bug fix 5 éve
  xushengqiang 05d3ad00e8 bug fix 5 éve
  xushengqiang 157b150b94 bug fix 5 éve
  xushengqiang ee459aefc2 bug fix 5 éve
  xushengqiang f9059f1420 bug fix 5 éve
  xushengqiang ad949e2d58 bug fix 5 éve
  wangys 1480439c57 bugfix 5 éve
  wangys c3e5b63844 bugfix 5 éve
  wangys a2e10e817f bugfix 5 éve
  wangys 32f1d37f8b bugfix 5 éve
  wangys 29984a1d41 Merge branches 'online' and 'test' of http://gogs.efunbox.cn:/wangys/efunbox-manage into online 5 éve
  wangys 033a4cedd0 uid拦截 5 éve
  wangys 4978689140 Merge branches 'online' and 'test' of http://gogs.efunbox.cn:/wangys/efunbox-manage into online 5 éve
  wangys 67f2935227 properties 5 éve
  wangys 6095a0ec4d bugfix 5 éve
  wangys c9b3de2568 bugfix 5 éve
  wangys a67552103b bugfix 5 éve
  wangys 7a90b75f58 bugfix 5 éve
  wangys da676a65f5 bugfix 5 éve
  wangys 819a071948 bugfix 5 éve
  wangys b122a4dae9 bugfix 5 éve
  wangys 685660e4aa bugfix 5 éve
  wangys b8b36b6a22 bugfix 5 éve
  wangys f091de0102 bugfix 5 éve
  wangys 52a85e6654 bugfix 5 éve
  wangys 130da44ad7 bugfix 5 éve
  wangys 435a8b664b bugfix 5 éve
  wangys fd045eb8bf bugfix 5 éve
  wangys 9febec6ef9 bugfix 5 éve
  wangys 57034ce2dc bugfix 5 éve
  wangys c87d663e2e bugfix 5 éve
  wangys 8376ffd6d4 bugfix 5 éve
  wangys 1afe03da53 bugfix 5 éve
  wangys 31174496b3 bugfix 5 éve
  wangys 92cb1fb547 bugfix 5 éve
  wangys 984a88cd0d bugfix 5 éve
  wangys 460adf85d6 bugfix 5 éve
  wangys 48588da3f6 修改接口传参方式 5 éve
  wangys 86ddf30475 修改接口传参方式 5 éve
  wangys 39a4e58df9 接口开发 5 éve
  wangys 41e12cbc74 接口开发 5 éve
  wangys 43e8418cf3 接口开发 5 éve
  wangys ed54127f97 打包名称 5 éve
  wangys 426c879d16 pom依赖 5 éve
  wangys ef704ab05c 项目结构调整 5 éve
  wangys 8ba92d895a 第一次提交 5 éve

+ 1 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/repository/DepartmentRepository.java

@@ -16,7 +16,7 @@ public interface DepartmentRepository extends BasicRepository<Department> {
 
     List<Department> findByStatusOrderBySortDesc(BaseStatusEnum status);
 
-    @Query(value = "select * from department where status = 0 and type = :type and id not in ('12345','123456','1234567', '12345678') order by path, code", nativeQuery = true)
+    @Query(value = "select * from department where status = 0 and type = :type and id not in ('12345','123456','1234567', '12345678') order by code", nativeQuery = true)
     List<Department> findSelect(@Param("type") Integer type);
 
     Department findByName(String name);

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

@@ -4,10 +4,14 @@ import cn.efunbox.manage.base.entity.Manage;
 import cn.efunbox.manage.base.vo.ManageVO;
 import cn.efunbox.manage.common.result.ApiResult;
 
+import javax.servlet.http.HttpServletResponse;
+
 public interface ManageService {
 
     ApiResult list(ManageVO manageVO);
 
+    void export(ManageVO manageVO, HttpServletResponse response)  throws Exception;
+
     ApiResult save(Manage manage);
 
     ApiResult update(Manage manage);

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

@@ -6,11 +6,15 @@ import cn.efunbox.manage.base.enums.IncomeStatusEnum;
 import cn.efunbox.manage.base.enums.ManageTypeEnum;
 import cn.efunbox.manage.base.repository.*;
 import cn.efunbox.manage.base.service.ManageService;
+import cn.efunbox.manage.base.util.TimeUtil;
 import cn.efunbox.manage.base.vo.ManageVO;
 import cn.efunbox.manage.common.enums.BaseOrderEnum;
 import cn.efunbox.manage.common.helper.SortHelper;
 import cn.efunbox.manage.common.result.ApiCode;
 import cn.efunbox.manage.common.result.ApiResult;
+import org.apache.http.HttpResponse;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
@@ -20,7 +24,14 @@ import org.springframework.stereotype.Service;
 
 import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.Predicate;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
 import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -304,6 +315,373 @@ public class ManageServiceImpl implements ManageService {
     }
 
     @Override
+    public void export(ManageVO manageVO, HttpServletResponse response) throws Exception {
+        if(!manageVO.getIsEntry()){
+            manageVO.setStatus(BaseStatusEnum.NORMAL);
+        }
+        Specification specification = (Specification<Manage>) (root, criteriaQuery, criteriaBuilder) -> {
+
+            List<Predicate> predicates = new ArrayList<>();
+            if(manageVO.getToProjectId() != null && manageVO.getToProjectId().size() > 0){
+                List<Predicate> list = new ArrayList<>();
+                if (manageVO.getToProjectId() != null && manageVO.getToProjectId().size() > 0) {
+                    CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("toProjectId"));
+                    for (Long id : manageVO.getToProjectId()) {
+                        in.value(id);
+                    }
+                    list.add(in);
+                }
+                predicates.addAll(list);
+            }
+            if(manageVO.getToDeptId() != null && manageVO.getToDeptId().size() > 0){
+                List<Predicate> list = new ArrayList<>();
+                if (manageVO.getToDeptId() != null && manageVO.getToDeptId().size() > 0) {
+                    CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("toDeptId"));
+                    for (Long id : manageVO.getToDeptId()) {
+                        in.value(id);
+                    }
+                    list.add(in);
+                }
+                predicates.addAll(list);
+            }
+            if(manageVO.getProductId() != null && manageVO.getProductId().size() > 0){
+                List<Predicate> list = new ArrayList<>();
+                if (manageVO.getProductId() != null && manageVO.getProductId().size() > 0) {
+                    CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("productId"));
+                    for (Long id : manageVO.getProductId()) {
+                        in.value(id);
+                    }
+                    list.add(in);
+                }
+                predicates.addAll(list);
+            }
+            if(manageVO.getProjectId() != null && manageVO.getProjectId().size() > 0){
+                List<Predicate> list = new ArrayList<>();
+                if (manageVO.getProjectId() != null && manageVO.getProjectId().size() > 0) {
+                    CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("projectId"));
+                    for (Long id : manageVO.getProjectId()) {
+                        in.value(id);
+                    }
+                    list.add(in);
+                }
+                predicates.addAll(list);
+            }
+            if(Objects.nonNull(manageVO.getType())){
+                predicates.add(criteriaBuilder.equal(root.get("type"), manageVO.getType()));
+            }
+            if(manageVO.getCostTypeId() != null && manageVO.getCostTypeId().size() > 0){
+                List<Predicate> list = new ArrayList<>();
+                if (manageVO.getCostTypeId() != null && manageVO.getCostTypeId().size() > 0) {
+                    CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("costTypeId"));
+                    for (Long id : manageVO.getCostTypeId()) {
+                        in.value(id);
+                    }
+                    list.add(in);
+                }
+                predicates.addAll(list);
+            }
+            if(manageVO.getIncomeStatus() != null && manageVO.getIncomeStatus().size() > 0){
+                List<Predicate> list = new ArrayList<>();
+                if (manageVO.getIncomeStatus() != null && manageVO.getIncomeStatus().size() > 0) {
+                    CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("incomeStatus"));
+                    for (IncomeStatusEnum incomeStatus : manageVO.getIncomeStatus()) {
+                        in.value(incomeStatus);
+                    }
+                    list.add(in);
+                }
+                predicates.addAll(list);
+            }
+            if(Objects.nonNull(manageVO.getStatus())){
+                predicates.add(criteriaBuilder.equal(root.get("status"), manageVO.getStatus()));
+            }
+            if(Objects.nonNull(manageVO.getStartTime())){
+                predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("happenTime"), manageVO.getStartTime()));
+            }
+            if(Objects.nonNull(manageVO.getEndTime())){
+                predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("happenTime"), manageVO.getEndTime()));
+            }
+            if(Objects.nonNull(manageVO.getMinAmount()) && manageVO.getMinAmount() > 0){
+                predicates.add(criteriaBuilder.ge(root.get("amount"), manageVO.getMinAmount()));
+            }
+            if(Objects.nonNull(manageVO.getMaxAmount()) && manageVO.getMaxAmount() > 0){
+                predicates.add(criteriaBuilder.le(root.get("amount"), manageVO.getMaxAmount()));
+            }
+            if(manageVO.getDeptIds() != null && manageVO.getDeptIds().size() > 0){
+                List<Predicate> list = new ArrayList<>();
+                if (manageVO.getDeptIds() != null && manageVO.getDeptIds().size() > 0) {
+                    CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("deptId"));
+                    for (Long id : manageVO.getDeptIds()) {
+                        in.value(id);
+                    }
+                    list.add(in);
+                }
+                predicates.addAll(list);
+            }
+            return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+        Long count = manageRepository.count(specification);
+        if (count == 0) {
+            return;
+        }
+        List<Manage> totalManages =  manageRepository.findAll(specification);
+        BigDecimal sum = new BigDecimal("0");
+        for (Manage manage: totalManages) {
+            if (Objects.equals(manage.getType(), ManageTypeEnum.COST)){
+                sum = sum.subtract(new BigDecimal(Double.toString(manage.getAmount())));
+            }else {
+                sum = sum.add(new BigDecimal(Double.toString(manage.getAmount())));
+            }
+        }
+        if(Objects.isNull(totalManages)){
+            return;
+
+        }
+        List<Long> deptIds = new ArrayList<>();
+        List<Long> projectIds = new ArrayList<>();
+        List<Long> productIds = new ArrayList<>();
+        List<Long> companyIds = new ArrayList<>();
+        List<Long> costTypeIds = new ArrayList<>();
+        for(Manage m : totalManages){
+            m.setTotalAmount(sum.doubleValue());
+            if(Objects.nonNull(m.getDeptId())){
+                deptIds.add(m.getDeptId());
+            }
+            if(Objects.nonNull(m.getProjectId())){
+                projectIds.add(m.getProjectId());
+            }
+            if(Objects.nonNull(m.getToDeptId())){
+                deptIds.add(m.getToDeptId());
+            }
+            if(Objects.nonNull(m.getProductId())){
+                productIds.add(m.getProductId());
+            }
+            if(Objects.nonNull(m.getCostTypeId())){
+                costTypeIds.add(m.getCostTypeId());
+            }
+            if(Objects.nonNull(m.getToProjectId())){
+                projectIds.add(m.getToProjectId());
+            }
+            if(Objects.nonNull(m.getToDeptId())){
+                deptIds.add(m.getToDeptId());
+            }
+        }
+
+        //部门
+        List<Department> departments = departmentRepository.findByIds(deptIds);
+        Map<Long, Department> departmentMap = new HashMap<>();
+        departments.stream().forEach(department -> {
+            departmentMap.put(department.getId(), department);
+        });
+        //项目
+        List<Project> projects = projectRepository.findByIds(projectIds);
+        Map<Long, Project> projectMap = new HashMap<>();
+        projects.stream().forEach(project -> {
+            projectMap.put(project.getId(), project);
+        });
+        //产品
+        List<Product> products = productRepository.findByIds(productIds);
+        Map<Long, Product> producMap = new HashMap<>();
+        products.stream().forEach(product -> {
+            producMap.put(product.getId(), product);
+        });
+        //支出发起人
+        List<Company> companies = companyRepository.findByIds(companyIds);
+        Map<Long, Company> companyMap = new HashMap<>();
+        companies.stream().forEach(company -> {
+            companyMap.put(company.getId(), company);
+        });
+        //成本类型
+        List<CostType> costTypes = costTypeRepository.findByIds(costTypeIds);
+        Map<Long, CostType> costTypeMap = new HashMap<>();
+        costTypes.stream().forEach(costType -> {
+            costTypeMap.put(costType.getId(), costType);
+        });
+
+        for(Manage m : totalManages){
+            m.setDepartment(departmentMap.get(m.getDeptId()));
+            m.setProject(projectMap.get(m.getProjectId()));
+            m.setProduct(producMap.get(m.getProductId()));
+            m.setToProject(projectMap.get(m.getToProjectId()));
+            if(Objects.nonNull(m.getCostTypeId())){
+                m.setCostType(costTypeMap.get(m.getCostTypeId()));
+            }
+            m.setToDepartment(departmentMap.get(m.getToDeptId()));
+        };
+
+
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        HSSFSheet sheet = workbook.createSheet("经营数据管理平台数据统计表");
+        createTitle(workbook, sheet, manageVO.getType());
+
+        for (int i = 0; i < totalManages.size(); i++){
+            Manage m = totalManages.get(i);
+            HSSFRow r = sheet.createRow(i + 1);
+            HSSFCell cell;
+            cell = r.createCell(0);
+            cell.setCellValue(m.getHappenTime().toString());
+
+            cell = r.createCell(1);
+            cell.setCellValue(m.getAmount());
+            if(Objects.equals(manageVO.getType(), ManageTypeEnum.INCOME)){
+                cell = r.createCell(2);
+                cell.setCellValue(m.getIncomeStatus().toString());
+
+                cell = r.createCell(3);
+                if(Objects.nonNull(m.getProduct())){
+                    cell.setCellValue(m.getProduct().getName());
+                }
+
+                cell = r.createCell(4);
+                if(Objects.nonNull(m.getProject())){
+                    cell.setCellValue(m.getProject().getName());
+                }
+
+                cell = r.createCell(5);
+                if(Objects.nonNull(m.getDepartment())){
+                    cell.setCellValue(m.getDepartment().getName());
+                }
+
+                cell = r.createCell(6);
+                if(Objects.nonNull(m.getToDepartment())){
+                    cell.setCellValue(m.getToDepartment().getName());
+                }
+
+
+                cell = r.createCell(7);
+                cell.setCellValue(m.getRemark());
+
+                cell = r.createCell(8);
+                cell.setCellValue(m.getGmtModified().toString());
+
+
+            }else {
+                cell = r.createCell(2);
+                if(Objects.nonNull(m.getCostType())){
+                    cell.setCellValue(m.getCostType().getName());
+                }
+
+                cell = r.createCell(3);
+                if(Objects.nonNull(m.getDepartment())){
+                    cell.setCellValue(m.getDepartment().getName());
+                }
+
+                cell = r.createCell(4);
+                if(Objects.nonNull(m.getProject())){
+                    cell.setCellValue(m.getProject().getName());
+                }
+
+                cell = r.createCell(5);
+                if(Objects.nonNull(m.getToDepartment())){
+                    cell.setCellValue(m.getToDepartment().getName());
+                }
+
+                cell = r.createCell(6);
+                cell.setCellValue(m.getRemark());
+
+                cell = r.createCell(7);
+                cell.setCellValue(m.getGmtModified().toString());
+            }
+        }
+        //清空response
+        response.reset();
+        //设置response的Header
+        String fileName = "经营数据管理平台数据统计表_" + TimeUtil.getPreDateStr() + ".xls";
+        response.reset();
+        response.setContentType("contentType=application/vnd.ms-excel");
+        response.setHeader("Content-disposition","attachment;filename="+URLEncoder.encode(fileName,"utf-8"));
+        workbook.write(response.getOutputStream());
+        response.flushBuffer();
+    }
+
+    private void createTitle(HSSFWorkbook workbook, HSSFSheet sheet, ManageTypeEnum type) {
+        HSSFRow row0 = sheet.createRow(0);
+
+        int columnNum = 10;
+        for (int i = 0; i < columnNum; i++) {
+            sheet.setColumnWidth(i, 20 * 256);
+        }
+
+        //设置为居中
+        HSSFCellStyle style = workbook.createCellStyle();
+        HSSFFont font = workbook.createFont();
+        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        style.setFont(font);
+        HSSFCell cell;
+
+        if(Objects.equals(type, ManageTypeEnum.INCOME)){
+            cell = row0.createCell(0);
+            cell.setCellValue("发生日期");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(1);
+            cell.setCellValue("金额");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(2);
+            cell.setCellValue("收入状态");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(3);
+            cell.setCellValue("产品");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(4);
+            cell.setCellValue("归属项目");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(5);
+            cell.setCellValue("归属部门");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(6);
+            cell.setCellValue("客户");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(7);
+            cell.setCellValue("备注");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(8);
+            cell.setCellValue("录入日期");
+            cell.setCellStyle(style);
+        }else {
+            cell = row0.createCell(0);
+            cell.setCellValue("发生日期");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(1);
+            cell.setCellValue("金额");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(2);
+            cell.setCellValue("成本类型");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(3);
+            cell.setCellValue("发生部门");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(4);
+            cell.setCellValue("发生项目/人");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(5);
+            cell.setCellValue("供应商");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(6);
+            cell.setCellValue("备注");
+            cell.setCellStyle(style);
+
+            cell = row0.createCell(7);
+            cell.setCellValue("录入日期");
+            cell.setCellStyle(style);
+        }
+
+
+    }
+
+    @Override
     public ApiResult save(Manage manage) {
         if(Objects.isNull(manage)){
             return ApiResult.error(ApiCode.PARAMETER_ERROR);

+ 20 - 0
efunbox-base/efunbox-base-web/src/main/java/cn/efunbox/manage/base/controller/ManageController.java

@@ -7,9 +7,11 @@ import cn.efunbox.manage.base.service.DepartmentService;
 import cn.efunbox.manage.base.service.ManageService;
 import cn.efunbox.manage.base.vo.ManageVO;
 import cn.efunbox.manage.common.result.ApiResult;
+import org.apache.http.HttpResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -46,6 +48,24 @@ public class ManageController {
         return manageService.list(manageVO);
     }
 
+    @GetMapping("/export")
+    public void export(ManageVO manageVO, HttpServletResponse response) throws Exception{
+        List<Long> deptIds = new ArrayList<>();
+        if(null == manageVO.getDeptId() || manageVO.getDeptId().size() ==0){
+            ApiResult<List<Department>> deptResult = departmentService.getDeptChild(12345l, DeptTypeEnum.COMPANY);
+            deptResult.getData().stream().forEach(department -> {
+                deptIds.add(department.getId());
+            });
+        }else {
+            manageVO.getDeptId().stream().forEach(ids -> {
+                deptIds.add(ids);
+            });
+        }
+
+        manageVO.setDeptIds(deptIds);
+        manageService.export(manageVO, response);
+    }
+
     @PostMapping
     public ApiResult save(@RequestBody Manage manage){
         return manageService.save(manage);

+ 1 - 1
efunbox-base/efunbox-base-web/src/main/resources/application.properties

@@ -4,6 +4,6 @@ server.port=8059
 #spring.view.prefix=/templates/
 #spring.view.suffix=.jsp
 # 默认激活哪一个环境的配置文件,时也可以在运行动态指定:java -jar myapp.jar --spring.profiles.active=prd
-spring.profiles.active=prd
+spring.profiles.active=dev
 spring.http.multipart.maxFileSize = 10Mb
 spring.http.multipart.maxRequestSize=100Mb

+ 1 - 0
manage-common/src/main/java/cn/efunbox/manage/common/configuration/FrontConfiguration.java

@@ -61,6 +61,7 @@ public class FrontConfiguration extends WebMvcConfigurerAdapter implements Envir
 		registry.addInterceptor(adminInterceptor)
 				.addPathPatterns("/**")
 				.excludePathPatterns("/user/login")
+				.excludePathPatterns("/manage/export")
 				.excludePathPatterns("/user/logout");
 	}
 

BIN
经营数据管理平台数据统计表_2019-04-16.xls