Jelajahi Sumber

会计合同添加导出功能

user5 2 tahun lalu
induk
melakukan
88bdba7bdb

+ 39 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/contractRegistration/controller/ContractInfoController.java

@@ -3,12 +3,20 @@ package com.jeeplus.test.cw.contractRegistration.controller;
 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.jeeplus.aop.logging.annotation.ApiLog;
 import com.jeeplus.common.utils.ResponseUtil;
+import com.jeeplus.core.excel.ExcelOptions;
+import com.jeeplus.core.excel.ExportMode;
+import com.jeeplus.core.excel.utils.EasyPoiUtil;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.flowable.service.FlowTaskService;
+import com.jeeplus.sys.constant.enums.LogTypeEnum;
 import com.jeeplus.sys.utils.StringUtils;
 import com.jeeplus.test.cw.contractRegistration.domain.ContractInfo;
 import com.jeeplus.test.cw.contractRegistration.service.ContractInfoService;
+import com.jeeplus.test.cw.reimbursementApproval.approvalInfo.service.dto.QueryListDto;
+import com.jeeplus.test.materialManagement.contract.service.dto.ContractInfoDto;
+import com.jeeplus.test.zs.zsReimbursement.approvalInfo.service.dto.ZsRetureListDto;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,7 +25,10 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author: 王强
@@ -142,4 +153,32 @@ public class ContractInfoController {
         List<ContractInfo> list = service.getByClientId(contractId,contractInfo);
         return ResponseEntity.ok(list);
     }
+
+
+    @ApiLog(value = "兴光会计合同数据导出", type = LogTypeEnum.EXPORT)
+    @GetMapping("exportFile")
+    @ApiOperation(value = "兴光会计合同数据导出")
+    public void exportFile(ContractInfo info, Page <ContractInfo> page, ExcelOptions options, HttpServletResponse response) throws Exception {
+        QueryWrapper<ContractInfo> wrapper = QueryWrapperGenerator.buildQueryCondition(info, ContractInfo.class);
+        String fileName = options.getFilename();
+        String sheetName = options.getSheetName();
+        List<ContractInfo> result = new ArrayList<>();
+        if ( ExportMode.current.equals ( options.getMode() ) ) {
+            result = service.list (page,info,wrapper).getRecords();
+        } else if (ExportMode.selected.equals ( options.getMode() )) {
+            result = service.list (page,info,wrapper).getRecords().stream ( ).filter ( item ->
+                    options.getSelectIds ( ).contains ( item.getId ( ) )
+            ).collect ( Collectors.toList ( ) );
+        } else {
+            page.setSize (-1);
+            page.setCurrent (0);
+            result = service.list (page,info,wrapper).getRecords();
+        }
+        try {
+            EasyPoiUtil.exportExcel ( result, sheetName,  sheetName, ContractInfo.class, fileName, response );
+        }catch (Exception e){
+            System.out.println(e);
+        }
+
+    }
 }

+ 55 - 41
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/contractRegistration/domain/ContractInfo.java

@@ -1,5 +1,6 @@
 package com.jeeplus.test.cw.contractRegistration.domain;
 
+import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -39,17 +40,67 @@ public class ContractInfo extends BaseEntity {
     //合同 特字流水号
     public static final String SERIAL_NUMBER6 = "22";
 
-    @Query(tableColumn = "a.contract_no")
-    private String contractNo;              //合同编号
     @Query(tableColumn = "a.contract_name")
+    @Excel(name = "合同名称", width = 30)
     private String contractName;            //合同名称
+    @Query(tableColumn = "a.contract_no")
+    @Excel(name = "合同编号", width = 30)
+    private String contractNo;              //合同编号
 
-    private String payerSubject;            //付款主体
-    private String paymentMethod;           //付款方式
+    /**
+     * 委托方联系人名称
+     */
+    @TableField(exist = false)
+    @Excel(name = "委托方", width = 30)
+    private String clientContactsName;
+
+    /**
+     * 案卷号
+     */
+    @TableField(exist = false)
+    @Excel(name = "案卷号", width = 16)
+    private String filedNo;
     @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "签约日期", width = 16,exportFormat="yyyy-MM-dd")
     private Date signingDate;             //签约日期
     @Query(tableColumn = "a.contract_amount")
+    @Excel(name = "合同金额(元)", width = 16, type = 10)
     private Double contractAmount;          //合同金额(元)
+
+    @TableField(exist = false)
+    @Excel(name = "所属部门", width = 16)
+    private String departmentName;
+
+    /**
+     * 创建人
+     */
+    @TableField(exist = false)
+    @Excel(name = "创建人", width = 12)
+    private String createName;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "创建时间", width = 16,exportFormat="yyyy-MM-dd")
+    private Date createDate;
+    @Excel(name = "状态", width = 10,dict = "cw_status")
+    private String status;                  //状态
+
+    /**
+     * 纸质归档状态
+     */
+    @Excel(name = "纸质归档状态", width = 16,dict = "filed_type")
+    private String filedPaperType;
+
+    /**
+     * 借用状态
+     */
+    @Excel(name = "借用状态", width = 12,dict = "borrow_type")
+    private String borrowType;
+
+    private String payerSubject;            //付款主体
+    private String paymentMethod;           //付款方式
     private Double predictAmount;          //预计金额(元)
     private Double actualContractAmount;    //合同实际金额
     private String contractNum;             //合同份数
@@ -63,7 +114,6 @@ public class ContractInfo extends BaseEntity {
     private String contractApprovalType;    //合同归档审批类型
     private String procInsId;               //流程id
     private String processDefinitionId;     //
-    private String status;                  //状态
 
     @TableField(fill = FieldFill.INSERT)
     private String createBy;                //创建人名称
@@ -90,11 +140,6 @@ public class ContractInfo extends BaseEntity {
     @Query(tableColumn = "a.filed_type")
     private String filedType;
 
-    /**
-     * 纸质归档状态
-     */
-    private String filedPaperType;
-
     @TableField(exist = false)
     private String[] contractAmounts;
 
@@ -113,9 +158,6 @@ public class ContractInfo extends BaseEntity {
     @TableField(exist = false)
     private List<CwWorkClientBaseDTO> cwWorkClientContactDTOList;
 
-    @TableField(exist = false)
-    private String departmentName;
-
     /**
      * 归档附件信息
      */
@@ -138,23 +180,12 @@ public class ContractInfo extends BaseEntity {
     private String contractFee;
 
     private String fees;
-
-    /**
-     * 案卷号
-     */
-    @TableField(exist = false)
-    private String filedNo;
     /**
      * 确认案卷号
      */
     @TableField(exist = false)
     private String confirmFiledNo;
 
-    /**
-     * 借用状态
-     */
-    private String borrowType;
-
     @TableField(exist = false)
     private String taskBorrowId;
 
@@ -183,23 +214,6 @@ public class ContractInfo extends BaseEntity {
     private String address;
 
     /**
-     * 委托方联系人名称
-     */
-    @TableField(exist = false)
-    private String clientContactsName;
-
-    /**
-     * 创建人
-     */
-    @TableField(exist = false)
-    private String createName;
-
-    /**
-     * 创建时间
-     */
-    private Date createDate;
-
-    /**
      * 付款描述
      */
     private String paymentDescribe;