Sfoglia il codice sorgente

报告数据导出功能

user5 2 anni fa
parent
commit
269749f269

+ 49 - 13
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/controller/CwProjectReportController.java

@@ -1,30 +1,22 @@
 package com.jeeplus.test.cw.projectReport.controller;
 
 import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.TypeReference;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.common.collect.Maps;
 import com.jeeplus.aop.logging.annotation.ApiLog;
 import com.jeeplus.common.redis.RedisUtils;
 import com.jeeplus.common.utils.ResponseUtil;
-import com.jeeplus.flowable.model.Flow;
+import com.jeeplus.core.excel.ExcelOptions;
+import com.jeeplus.core.excel.ExportMode;
+import com.jeeplus.core.excel.utils.EasyPoiUtil;
 import com.jeeplus.flowable.service.FlowTaskService;
 import com.jeeplus.sys.constant.enums.LogTypeEnum;
+import com.jeeplus.sys.utils.DictUtils;
 import com.jeeplus.sys.utils.UserUtils;
-import com.jeeplus.test.cw.common.flowable.dto.CommitParamDTO;
-import com.jeeplus.test.cw.projectRecords.domain.CwProjectRecords;
-import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
-import com.jeeplus.test.cw.projectReport.domain.CwProjectReport;
 import com.jeeplus.test.cw.projectReport.domain.CwProjectReportData;
 import com.jeeplus.test.cw.projectReport.domain.CwProjectReportSignature;
-import com.jeeplus.test.cw.projectReport.mapper.CwProjectReportSignatureMapper;
 import com.jeeplus.test.cw.projectReport.mapper.ProjectReportWorkAttachmentMapper;
 import com.jeeplus.test.cw.projectReport.service.CwProjectReportService;
-import com.jeeplus.test.cw.projectReport.service.dto.CwProjectReportDTO;
 import com.jeeplus.test.cw.projectReport.service.dto.CwProjectReportSignatureDTO;
 import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
 import com.jeeplus.test.oss.domain.WorkAttachment;
@@ -33,17 +25,18 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.flowable.engine.TaskService;
-import org.flowable.task.api.Task;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 /**
  * @author: 王强
@@ -249,4 +242,47 @@ public class CwProjectReportController {
         String s = "projectReportService.updateSignatureStatusById(data);";
         return ResponseEntity.ok(s);
     }
+
+
+
+    /**
+     * 导出分所报销数据
+     * @param cwProjectReportData
+     * @param page
+     * @param response
+     * @throws Exception
+     */
+    @ApiLog("导出报告数据信息")
+    @GetMapping("export")
+    @ApiOperation(value = "导出报告数据信息excel")
+    public void exportFile(CwProjectReportData cwProjectReportData, Page <CwProjectReportData> page, ExcelOptions options, HttpServletResponse response) throws Exception {
+        String fileName = options.getFilename ( );
+
+        List<CwProjectReportData> result;
+        if ( ExportMode.current.equals ( options.getMode ( ) ) ) {
+            result = projectReportService.findList ( page, cwProjectReportData ).getRecords();
+        } else if ( ExportMode.selected.equals ( options.getMode ( ) ) ) {
+            result = projectReportService.findList ( page, cwProjectReportData ).getRecords().stream ( ).filter ( info ->
+                    options.getSelectIds ( ).contains ( info.getId ( ) )
+            ).collect ( Collectors.toList ( ) );
+        } else {
+            page.setSize ( -1 );
+            page.setCurrent ( 0 );
+            result = projectReportService.findList ( page, cwProjectReportData ).getRecords();
+        }
+        if(result.size()>0){
+            for (CwProjectReportData info : result) {
+                if(StringUtils.isNotBlank(info.getStatus())){
+                    info.setStatus(DictUtils.getDictLabel(info.getStatus(), "cw_status", ""));
+                }
+                if(StringUtils.isNotBlank(info.getStatus1())){
+                    info.setStatus1(DictUtils.getDictLabel(info.getStatus1(), "cw_status", ""));
+                }
+                if(StringUtils.isNotBlank(info.getStatus2())){
+                    info.setStatus1(DictUtils.getDictLabel(info.getStatus2(), "cw_project_report_sign_status", ""));
+                }
+            }
+        }
+        EasyPoiUtil.exportExcel ( result, "报告信息",  options.getSheetName ( ), CwProjectReportData.class, fileName, response );
+    }
 }

+ 26 - 5
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/domain/CwProjectReportData.java

@@ -1,11 +1,13 @@
 package com.jeeplus.test.cw.projectReport.domain;
 
+import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.jeeplus.core.query.Query;
 import com.jeeplus.core.service.dto.BaseDTO;
 import com.jeeplus.test.cw.common.flowable.dto.CommitParamDTO;
 import lombok.Data;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -33,16 +35,19 @@ public class CwProjectReportData extends BaseDTO {
     /**
      * 单据编号
      */
+    @Excel(name = "单据编号",width = 20)
     private String documentNo;
     /**
      * 项目名称
      */
     @Query(tableColumn = "b.project_name")
+    @Excel(name = "项目名称",width = 40)
     private String projectName;
     /**
      * 项目编号
      */
     @Query(tableColumn = "b.project_number")
+    @Excel(name = "项目编号",width = 20)
     private String projectNumber;
     /**
      * 项目id
@@ -52,10 +57,16 @@ public class CwProjectReportData extends BaseDTO {
      * 报告所属部门
      */
     private String officeId;
+
+
+    @TableField(exist = false)
+    @Excel(name = "报告所属部门",width = 20)
+    private String departmentName; //部门名称
     /**
      * 项目经理
      */
     @Query(tableColumn = "e.name")
+    @Excel(name = "项目经理",width = 12)
     private String projectMasterName;
     /**
      * 签字注师1
@@ -78,19 +89,28 @@ public class CwProjectReportData extends BaseDTO {
     private String processDefinitionId;
 
     /**
+     * 创建人
+     */
+    @TableField(exist = false)
+    @Excel(name = "创建人",width = 12)
+    private String userName; //用户名
+
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", exportFormat="yyyy-MM-dd",width = 16)
+    private Date createDate;
+
+    /**
      * 状态
      */
+    @Excel(name = "状态",width = 12)
     private String status;
 
     //新建行数据
     @TableField(exist = false)
     List<CwProjectInfoData> cwProjectInfoList;
 
-    @TableField(exist = false)
-    private String departmentName; //部门名称
-
-    @TableField(exist = false)
-    private String userName; //用户名
 
     @TableField(exist = false)
     private String[] contractDates;
@@ -123,6 +143,7 @@ public class CwProjectReportData extends BaseDTO {
     /**
      * 公章流程status
      */
+    @Excel(name = "签章状态",width = 12)
     private String status1;
 
     /**

+ 2 - 2
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReportArchive/controller/CwProjectReportArchiveDetailController.java

@@ -58,9 +58,9 @@ public class CwProjectReportArchiveDetailController {
      * @param response
      * @throws Exception
      */
-    @ApiLog("导出分所报销数据")
+    @ApiLog("导出归档数据信息")
     @GetMapping("export")
-    @ApiOperation(value = "导出分所报销数据excel")
+    @ApiOperation(value = "导出归档数据信息excel")
     public void exportFile(CwProjectReportArchiveDetailDTO cwProjectReportArchiveDetailDTO, Page <CwProjectReportArchiveDetailDTO> page, ExcelOptions options, HttpServletResponse response) throws Exception {
         String fileName = options.getFilename ( );
 

+ 9 - 5
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/controller/UserController.java

@@ -201,7 +201,7 @@ public class UserController {
         if ( StrUtil.isNotBlank ( userDTO.getNewPassword ( ) ) ) {
             userDTO.setPassword ( SecurityUtils.encryptPassword ( userDTO.getNewPassword ( ) ) );
         }
-        if ( isCheckLoginName ( userDTO.getOldLoginName ( ), userDTO.getLoginName ( ) ) ) {
+        if ( isCheckLoginName ( userDTO.getOldLoginName ( ),userDTO.getId(), userDTO.getLoginName ( ) ) ) {
             return ResponseEntity.badRequest ( ).body ( "保存用户'" + userDTO.getLoginName ( ) + "'失败,登录名已存在!" );
         }
         // 保存用户信息
@@ -409,17 +409,21 @@ public class UserController {
     }
 
 
-    private boolean isCheckLoginName(String oldLoginName, String loginName) {
+    private boolean isCheckLoginName(String oldLoginName,String oldLoginId, String loginName) {
         if (StringUtils.isNotBlank(loginName)) {
             List<User> userList = userService.list(new QueryWrapper<User>().lambda().eq(User::getLoginName,loginName));
             if (CollectionUtil.isNotEmpty(userList)) {
-                return true;
+                for (User info: userList) {
+                    if(!info.getId().equals(oldLoginId)){
+                        return true;
+                    }
+                }
             }
-            if (StringUtils.isNotBlank(oldLoginName)){
+            /*if (StringUtils.isNotBlank(oldLoginName)){
                 if ( loginName.equals ( oldLoginName ) ) {
                     return true;
                 }
-            }
+            }*/
         }
         return false;
     }