yewc пре 1 година
родитељ
комит
75fabd553d

+ 12 - 0
client/src/views/OaSystem/financialManagement/loan/loan.vue

@@ -39,6 +39,10 @@
             <img src="@/assets/imgs/OA/search.png" class="mr-8px" alt="" />
             查询</el-button
           >
+          <el-button type="primary" @click="exportData">
+            <img src="@/assets/imgs/OA/open.png" class="mr-8px" alt="" />
+            导出</el-button
+          >
         </div>
       </div>
     </div>
@@ -131,6 +135,7 @@ import UserForm from './UserForm.vue'
 import * as DeptApi from '@/api/system/dept'
 import { defaultProps, handleTree } from '@/utils/tree'
 import UserOrgTree from '@/views/OaSystem/components/UserOrgTree/index.vue'
+import download from '@/utils/download'
 
 defineOptions({ name: 'Loan' })
 const verifyMap: any = { null: '未核销', 1: '已核销', 0: '未核销' }
@@ -267,4 +272,11 @@ const formRef = ref()
 const openForm = (row: object) => {
   formRef.value.open(row)
 }
+const exportData = async () => {
+  const sendData = {
+    ...queryParams
+  }
+  const data = await request.downloadPost({ url: '/loan/exportData', sendData }, '/business')
+  download.excel(data, '借款数据导出记录.xlsx')
+}
 </script>

+ 4 - 0
zjugis-business/src/main/java/com/zjugis/business/bean/entity/Loan.java

@@ -68,6 +68,8 @@ public class Loan extends BaseEntity {
      * 借款总金额
      */
     private BigDecimal loanAmount;
+    @TableField(exist = false)
+    private BigDecimal loanBalance;
 
 /**
      * 借款说明
@@ -83,6 +85,8 @@ public class Loan extends BaseEntity {
      * 是否已核销
      */
     private Integer isVerify;
+    @TableField(exist = false)
+    private String isVerifyName;
 
 /**
      * 流程状态 1 已完成

+ 58 - 0
zjugis-business/src/main/java/com/zjugis/business/bean/response/LoanExcelResponse.java

@@ -0,0 +1,58 @@
+package com.zjugis.business.bean.response;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+import static com.zjugis.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+/**
+ * @author ljy
+ * @version 1.0
+ * @date 2023/11/23 14:37
+ */
+@Data
+@ExcelIgnoreUnannotated
+public class LoanExcelResponse {
+
+
+
+    @ExcelProperty(value = "借款单号")
+    private String loanNumber;
+
+    @ExcelProperty("申请时间")
+    private LocalDate applyDate;
+
+    @ExcelProperty("借款人部门")
+    private String workerDept;
+
+    @ExcelProperty("借款人")
+    private String worker;
+
+    @ExcelProperty("借款总金额")
+    private BigDecimal loanAmount;
+
+    @ExcelProperty("已核销金额")
+    private BigDecimal verifyAmount;
+
+    @ExcelProperty("借款余额")
+    private BigDecimal loanBalance;
+
+    @ExcelProperty("约定付款期限")
+    private LocalDate agreedPayTime;
+
+    @ExcelProperty("核销时间")
+    private LocalDate verifyDate;
+
+    @ExcelProperty("借款说明")
+    private String description;
+
+    @ExcelProperty("核销状态")
+    private String isVerifyName;
+
+}

+ 25 - 0
zjugis-business/src/main/java/com/zjugis/business/controller/LoanController.java

@@ -3,12 +3,20 @@ package com.zjugis.business.controller;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.business.bean.dto.LoanDto;
 import com.zjugis.business.bean.entity.Loan;
+import com.zjugis.business.bean.response.LoanExcelResponse;
 import com.zjugis.business.bean.response.LoanRespense;
 import com.zjugis.business.service.LoanService;
 import com.zjugis.framework.common.pojo.CommonResult;
+import com.zjugis.framework.excel.core.util.ExcelUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -83,5 +91,22 @@ public class LoanController {
     public CommonResult<Integer> getCount(LoanDto loan) {
         return CommonResult.success(loanService.getCount(loan));
     }
+
+    @PostMapping("/loan/exportData")
+    public void export(LoanDto pageReqVO, HttpServletResponse response) throws IOException {
+        List<Loan> projects = loanService.getExportData(pageReqVO);
+
+        List<LoanExcelResponse> excelList = new ArrayList<>(projects.size());
+        projects.forEach(project -> {
+            LoanExcelResponse projectExcelResponse = new LoanExcelResponse();
+            BeanUtils.copyProperties(project,projectExcelResponse);
+            excelList.add(projectExcelResponse);
+        });
+        response.setContentType("multipart/form-data");
+        response.setCharacterEncoding(String.valueOf(StandardCharsets.UTF_8));
+        response.setHeader("Content-Disposition",
+                "attachment;filename*=utf-8'zh-cn'" + URLEncoder.encode("借款查询列表.xlsx", String.valueOf(StandardCharsets.UTF_8)));
+        ExcelUtils.write(response, "借款查询列表.xlsx", "借款查询列表", LoanExcelResponse.class, excelList);
+    }
 }
 

+ 3 - 0
zjugis-business/src/main/java/com/zjugis/business/mapper/LoanMapper.java

@@ -8,6 +8,7 @@ import com.zjugis.business.bean.response.LoanRespense;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,5 +26,7 @@ public interface LoanMapper extends BaseMapper<Loan> {
     Integer getCount(@Param("params")LoanDto loan);
 
     LoanRespense overview(@Param("params")LoanDto loan);
+
+    List<Loan> page(@Param("params") LoanDto loan);
 }
 

+ 2 - 0
zjugis-business/src/main/java/com/zjugis/business/service/LoanService.java

@@ -55,5 +55,7 @@ public interface LoanService {
     Integer getCount(LoanDto loan);
 
     LoanRespense overview(LoanDto loan);
+
+    List<Loan> getExportData(LoanDto pageReqVO);
 }
 

+ 25 - 0
zjugis-business/src/main/java/com/zjugis/business/service/impl/LoanServiceImpl.java

@@ -124,5 +124,30 @@ public class LoanServiceImpl implements LoanService {
         }
         return loanMapper.overview(loan);
     }
+
+    @Override
+    public List<Loan> getExportData(LoanDto loan) {
+        if(loan.getDeptId()!=null){
+            Set<String> dept=commonService.getDeptCondition(loan.getDeptId());
+            loan.setUserDeptList(dept);
+            List<Project> projects = projectService.selectByDeptId(loan.getDeptId());
+            loan.setProjectIds(convertList(projects, Project::getId));
+            loan.setDeptId(null);
+        }
+        List<Loan> list= loanMapper.page(loan);
+        for(Loan entity:list){
+            if("1".equals(entity.getIsVerify())){
+                entity.setIsVerifyName("已核销");
+            }else{
+                entity.setIsVerifyName("未核销");
+            }
+            if(entity.getVerifyAmount()!=null){
+                entity.setLoanBalance(entity.getLoanAmount().subtract(entity.getVerifyAmount()));
+            }else{
+                entity.setLoanBalance(entity.getLoanAmount());
+            }
+        }
+        return list;
+    }
 }