瀏覽代碼

费用管理导出和导出包含明细

wangzhuo 2 年之前
父節點
當前提交
fde06543f5

+ 27 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/cost/TCostManagementController.java

@@ -3,6 +3,8 @@ package com.ruoyi.web.controller.cost;
 import java.util.List;
 import java.util.Map;
 
+import com.ruoyi.anpin.domain.CostManagementDetailExcel;
+import com.ruoyi.anpin.domain.CostManagementExcel;
 import com.ruoyi.anpin.domain.TCostManagement;
 import com.ruoyi.anpin.service.ITCostManagementService;
 import com.ruoyi.common.annotation.RepeatSubmit;
@@ -59,6 +61,31 @@ public class TCostManagementController extends BaseController
         return util.exportExcel(list, "费用管理");
     }
 
+
+    /**
+     * 导出费用管理列表与详情
+     */
+    @PreAuthorize("@ss.hasPermi('anpin:management:exportdetail')")
+    @Log(title = "费用管理", businessType = BusinessType.EXPORT)
+    @GetMapping("/export/detail")
+    public AjaxResult exportDetail(TCostManagement tCostManagement) {
+        List<CostManagementDetailExcel> list = tCostManagementService.getTCostManagementExportDetail(tCostManagement);
+        ExcelUtil<CostManagementDetailExcel> util = new ExcelUtil<>(CostManagementDetailExcel.class);
+        return util.exportExcel(list, "费用管理包含明细");
+    }
+
+    /**
+     * 导出费用管理列表与详情
+     */
+    @PreAuthorize("@ss.hasPermi('anpin:management:exportall')")
+    @Log(title = "费用管理", businessType = BusinessType.EXPORT)
+    @GetMapping("/exportAll")
+    public AjaxResult exportAll(TCostManagement tCostManagement) {
+        List<CostManagementExcel> list = tCostManagementService.getTCostManagementExportAll(tCostManagement);
+        ExcelUtil<CostManagementExcel> util = new ExcelUtil<>(CostManagementExcel.class);
+        return util.exportExcel(list, "费用管理");
+    }
+
     /**
      * 获取费用管理详细信息
      */

+ 4 - 4
ruoyi-admin/src/main/resources/application-druid.yml

@@ -10,12 +10,12 @@ spring:
  #       url: jdbc:mysql://115.29.151.39:3306/sys?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
         #url: jdbc:mysql://124.70.179.5:3306/AnPingTest?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
 #        正式环境
-        url: jdbc:mysql://123.60.138.20:3306/AnPinJingYuan?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+#        url: jdbc:mysql://123.60.138.20:3306/AnPinJingYuan?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
 #        本地测试
-#        url: jdbc:mysql://localhost:3306/an_pin_test?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+        url: jdbc:mysql://localhost:3306/an_pin_test?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
         username: root
-        password: daasan7ujm^YHN
-#        password: root
+#        password: daasan7ujm^YHN
+        password: root
 
       # 从库数据源
       slave:

+ 86 - 0
ruoyi-anpin/src/main/java/com/ruoyi/anpin/domain/CostManagementDetailExcel.java

@@ -0,0 +1,86 @@
+package com.ruoyi.anpin.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class CostManagementDetailExcel {
+
+    @Excel(name = "编号")
+    private String fNo;
+
+//    @Excel(name = "部门")
+//    private String deptName;
+
+//    @Excel(name = "制单人")
+//    private String createBy;
+
+//    @Excel(name = "制单部门")
+//    private String createDeptName;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "业务日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date businessTime;
+
+//    @JsonFormat(pattern = "yyyy-MM-dd")
+//    @Excel(name = "制单日期", width = 30, dateFormat = "yyyy-MM-dd")
+//    private Date createTime;
+
+    @Excel(name = "金额合计")
+    private BigDecimal totalAmount;
+
+//    @Excel(name = "业务类型", dictType = "expense_business_type")
+//    private String businessType;
+
+    @Excel(name = "报销方式", dictType = "reimbursement_method")
+    private String expenseType;
+
+//    @Excel(name = "备注")
+//    private String remark;
+
+    @Excel(name = "申请人")
+    private String applicantName;
+
+//    @Excel(name = "状态")
+//    private String fStatusName;
+//
+//    @Excel(name = "打印次数")
+//    private Integer printTime;
+//
+//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @Excel(name = "打印时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+//    private Date printDate;
+//
+//    @JsonFormat(pattern = "yyyy-MM-dd")
+//    @Excel(name = "审核日期", width = 30, dateFormat = "yyyy-MM-dd")
+//    private Date fReviewDate;
+//
+    @Excel(name = "====")
+    private String detail = "==>";
+
+    @Excel(name = "费用名称")
+    private String expenseName;
+
+    @Excel(name = "金额")
+    private BigDecimal amount;
+
+    @Excel(name = "项目名称")
+    private String belongsProjectName;
+
+    @Excel(name = "所属人员名称")
+    private String personnelName;
+
+    @Excel(name = "所属部门名称")
+    private String departmentName;
+
+    @Excel(name = "物料名称")
+    private String matterName;
+
+    @Excel(name = "详情备注")
+    private String remarkDetail;
+
+}

+ 62 - 0
ruoyi-anpin/src/main/java/com/ruoyi/anpin/domain/CostManagementExcel.java

@@ -0,0 +1,62 @@
+package com.ruoyi.anpin.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class CostManagementExcel {
+
+    @Excel(name = "编号")
+    private String fNo;
+
+    @Excel(name = "部门")
+    private String deptName;
+
+    @Excel(name = "制单人")
+    private String createBy;
+
+    @Excel(name = "制单部门")
+    private String createDeptName;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "业务日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date businessTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "制单日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date createTime;
+
+    @Excel(name = "金额合计")
+    private BigDecimal totalAmount;
+
+    @Excel(name = "业务类型", dictType = "expense_business_type")
+    private String businessType;
+
+    @Excel(name = "报销方式", dictType = "reimbursement_method")
+    private String expenseType;
+
+    @Excel(name = "备注")
+    private String remark;
+
+    @Excel(name = "申请人")
+    private String applicantName;
+
+    @Excel(name = "状态")
+    private String fStatusName;
+
+    @Excel(name = "打印次数")
+    private Integer printTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "打印时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date printDate;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "审核日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date fReviewDate;
+
+}

+ 11 - 0
ruoyi-anpin/src/main/java/com/ruoyi/anpin/mapper/TCostManagementMapper.java

@@ -1,5 +1,7 @@
 package com.ruoyi.anpin.mapper;
 
+import com.ruoyi.anpin.domain.CostManagementDetailExcel;
+import com.ruoyi.anpin.domain.CostManagementExcel;
 import com.ruoyi.anpin.domain.TCostManagement;
 import org.apache.ibatis.annotations.Param;
 
@@ -100,4 +102,13 @@ public interface TCostManagementMapper
      * @return
      */
     int setPrintTimes(@Param("fId") Long fId, @Param("printDate") String printDate);
+
+    /**
+     * left join详情表查询数据
+     * @param tCostManagement
+     * @return
+     */
+    List<CostManagementDetailExcel> getTCostManagementExportDetail(TCostManagement tCostManagement);
+
+    List<CostManagementExcel> getTCostManagementExportAll(TCostManagement tCostManagement);
 }

+ 16 - 0
ruoyi-anpin/src/main/java/com/ruoyi/anpin/service/ITCostManagementService.java

@@ -1,5 +1,7 @@
 package com.ruoyi.anpin.service;
 
+import com.ruoyi.anpin.domain.CostManagementDetailExcel;
+import com.ruoyi.anpin.domain.CostManagementExcel;
 import com.ruoyi.anpin.domain.TCostManagement;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.model.LoginUser;
@@ -99,4 +101,18 @@ public interface ITCostManagementService
      * @return
      */
     int setPrintTimes(Long fId, String printDate);
+
+    /**
+     * 根据条件导出包括详情的excel
+     * @param tCostManagement 查询条件
+     * @return 数据
+     */
+    List<CostManagementDetailExcel> getTCostManagementExportDetail(TCostManagement tCostManagement);
+
+    /**
+     * 根据条件导出excel
+     * @param tCostManagement
+     * @return
+     */
+    List<CostManagementExcel> getTCostManagementExportAll(TCostManagement tCostManagement);
 }

+ 13 - 0
ruoyi-anpin/src/main/java/com/ruoyi/anpin/service/impl/TCostManagementServiceImpl.java

@@ -5,6 +5,8 @@ import java.util.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.ruoyi.anpin.domain.CostManagementDetailExcel;
+import com.ruoyi.anpin.domain.CostManagementExcel;
 import com.ruoyi.anpin.domain.TCostManagement;
 import com.ruoyi.anpin.domain.TCostManagementItem;
 import com.ruoyi.anpin.mapper.TCostManagementItemMapper;
@@ -629,4 +631,15 @@ public class TCostManagementServiceImpl implements ITCostManagementService
         return tCostManagementMapper.setPrintTimes(fId, printDate);
     }
 
+    @Override
+    public List<CostManagementDetailExcel> getTCostManagementExportDetail(TCostManagement tCostManagement) {
+        return tCostManagementMapper.getTCostManagementExportDetail(tCostManagement);
+    }
+
+    @Override
+    public List<CostManagementExcel> getTCostManagementExportAll(TCostManagement tCostManagement) {
+        return tCostManagementMapper.getTCostManagementExportAll(tCostManagement);
+
+    }
+
 }

+ 136 - 1
ruoyi-anpin/src/main/resources/mapper/anpin/TCostManagementMapper.xml

@@ -1677,5 +1677,140 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
         </where>
     </select>
-    
+    <select id="getTCostManagementExportDetail" resultType="com.ruoyi.anpin.domain.CostManagementDetailExcel">
+        SELECT DISTINCT
+        TCM.f_no AS fNo,
+        TCM.print_time AS printTime,
+        TCM.print_date AS printDate,
+        CASE
+        WHEN TCM.f_status = '0' THEN
+        '录入'
+        WHEN TCM.f_status = '1' THEN
+        '请核'
+        WHEN TCM.f_status = '2' THEN
+        '审批中'
+        WHEN TCM.f_status = '3' THEN
+        '审批通过'
+        WHEN TCM.f_status = '4' THEN
+        '完成'
+        END AS fStatusName,
+        TCM.dept_name AS deptName,
+        TCM.create_by AS createBy,
+        TCM.create_dept_name AS createDeptName,
+        TCM.business_time AS businessTime,
+        TCM.create_time AS createTime,
+        TCM.total_amount AS totalAmount,
+        TCM.remark,
+        TCM.applicant_name AS applicantName,
+        TCM.f_review_date AS fReviewDate,
+        TCM.business_type AS businessType,
+        TCM.expense_type AS expenseType,
+        TCMI.expense_name AS expenseName,
+        TCMI.amount,
+        TCMI.belongs_project_name AS belongsProjectName,
+        TCMI.personnel_name AS personnelName,
+        TCMI.department_name AS departmentName,
+        TCMI.matter_name AS matterName,
+        TCMI.remark AS remarkDetail
+        FROM
+        t_cost_management TCM
+        LEFT JOIN t_cost_management_item TCMI ON TCMI.f_pid = TCM.f_id
+        <where>
+            TCM.del_flag = 0
+            <if test="deptId != null and deptId != ''">and TCM.dept_id = #{deptId}</if>
+            <if test="deptName != null  and deptName != ''">and TCM.dept_name like concat('%', #{deptName}, '%')</if>
+            <if test='businessTimeList != null and businessTimeList[0] != null and businessTimeList[0]!= ""'>
+                and TCM.business_time &gt;= #{businessTimeList[0]}
+            </if>
+            <if test='businessTimeList != null and businessTimeList[1] != null and businessTimeList[1]!= ""'>
+                and TCM.business_time &lt;= #{businessTimeList[1]}
+            </if>
+
+            <if test="businessType != null  and businessType != ''">and TCM.business_type = #{businessType}</if>
+            <if test="expenseType != null  and expenseType != ''">and TCM.expense_type = #{expenseType}</if>
+
+            <if test="createDept != null  and createDept != ''">and TCM.create_dept = #{createDept}</if>
+            <if test="createDeptName != null  and createDeptName != ''">and TCM.create_dept_name like concat('%',
+                #{createDeptName}, '%')
+            </if>
+            <if test="createById != null  and createById != ''">and TCM.create_by_id = #{createById}</if>
+            <if test="createBy != null  and createBy != ''">and TCM.create_by like concat('%', #{createBy}, '%')</if>
+            <if test="itemExpenseId != null  and itemExpenseId != ''">and TCMI.expense_id = #{itemExpenseId}</if>
+            <if test="itemBelongsProjectId != null  and itemBelongsProjectId != ''">and TCMI.belongs_project_id =
+                #{itemBelongsProjectId}
+            </if>
+            <if test="itemDepartment != null  and itemDepartment != ''">and TCMI.department_id = #{itemDepartment}</if>
+            <if test="itemPersonnel != null  and itemPersonnel != ''">and TCMI.personnel_id = #{itemPersonnel}</if>
+            <if test="itemMatterName != null  and itemMatterName != ''">and TCMI.matter_name like concat('%',
+                #{itemMatterName}, '%')
+            </if>
+            <if test="remark != null  and remark != ''">and TCM.remark like concat('%', #{remark}, '%')</if>
+        </where>
+        order by TCM.create_time desc
+    </select>
+    <select id="getTCostManagementExportAll" resultType="com.ruoyi.anpin.domain.CostManagementExcel">
+        SELECT DISTINCT
+        TCM.f_no AS fNo,
+        TCM.print_time AS printTime,
+        TCM.print_date AS printDate,
+        CASE
+        WHEN TCM.f_status = '0' THEN
+        '录入'
+        WHEN TCM.f_status = '1' THEN
+        '请核'
+        WHEN TCM.f_status = '2' THEN
+        '审批中'
+        WHEN TCM.f_status = '3' THEN
+        '审批通过'
+        WHEN TCM.f_status = '4' THEN
+        '完成'
+        END AS fStatusName,
+        TCM.dept_name AS deptName,
+        TCM.create_by AS createBy,
+        TCM.create_dept_name AS createDeptName,
+        TCM.business_time AS businessTime,
+        TCM.create_time AS createTime,
+        TCM.total_amount AS totalAmount,
+        TCM.remark,
+        TCM.applicant_name AS applicantName,
+        TCM.f_review_date AS fReviewDate,
+        TCM.business_type AS businessType,
+        TCM.expense_type AS expenseType
+        FROM
+        t_cost_management TCM
+        LEFT JOIN t_cost_management_item TCMI ON TCMI.f_pid = TCM.f_id
+        <where>
+            TCM.del_flag = 0
+            <if test="deptId != null and deptId != ''">and TCM.dept_id = #{deptId}</if>
+            <if test="deptName != null  and deptName != ''">and TCM.dept_name like concat('%', #{deptName}, '%')</if>
+            <if test='businessTimeList != null and businessTimeList[0] != null and businessTimeList[0]!= ""'>
+                and TCM.business_time &gt;= #{businessTimeList[0]}
+            </if>
+            <if test='businessTimeList != null and businessTimeList[1] != null and businessTimeList[1]!= ""'>
+                and TCM.business_time &lt;= #{businessTimeList[1]}
+            </if>
+
+            <if test="businessType != null  and businessType != ''">and TCM.business_type = #{businessType}</if>
+            <if test="expenseType != null  and expenseType != ''">and TCM.expense_type = #{expenseType}</if>
+
+            <if test="createDept != null  and createDept != ''">and TCM.create_dept = #{createDept}</if>
+            <if test="createDeptName != null  and createDeptName != ''">and TCM.create_dept_name like concat('%',
+                #{createDeptName}, '%')
+            </if>
+            <if test="createById != null  and createById != ''">and TCM.create_by_id = #{createById}</if>
+            <if test="createBy != null  and createBy != ''">and TCM.create_by like concat('%', #{createBy}, '%')</if>
+            <if test="itemExpenseId != null  and itemExpenseId != ''">and TCMI.expense_id = #{itemExpenseId}</if>
+            <if test="itemBelongsProjectId != null  and itemBelongsProjectId != ''">and TCMI.belongs_project_id =
+                #{itemBelongsProjectId}
+            </if>
+            <if test="itemDepartment != null  and itemDepartment != ''">and TCMI.department_id = #{itemDepartment}</if>
+            <if test="itemPersonnel != null  and itemPersonnel != ''">and TCMI.personnel_id = #{itemPersonnel}</if>
+            <if test="itemMatterName != null  and itemMatterName != ''">and TCMI.matter_name like concat('%',
+                #{itemMatterName}, '%')
+            </if>
+            <if test="remark != null  and remark != ''">and TCM.remark like concat('%', #{remark}, '%')</if>
+        </where>
+        order by TCM.create_time desc
+    </select>
+
 </mapper>