diff --git a/ruoyi-admin/src/main/java/com/ruoyi/financial/controller/FinancialReceivablesController.java b/ruoyi-admin/src/main/java/com/ruoyi/financial/controller/FinancialReceivablesController.java index 3b98ed89..301745be 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/financial/controller/FinancialReceivablesController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/financial/controller/FinancialReceivablesController.java @@ -1,11 +1,24 @@ package com.ruoyi.financial.controller; +import java.io.*; +import java.net.URLEncoder; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.builder.ExcelWriterBuilder; +import com.alibaba.excel.write.metadata.WriteSheet; import com.ruoyi.financial.domain.FinancialReceivablesRecords; import com.ruoyi.financial.service.IFinancialReceivablesRecordsService; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; @@ -17,6 +30,12 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; +import javax.servlet.http.HttpServletResponse; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.write.builder.ExcelWriterBuilder; +import com.alibaba.excel.write.metadata.WriteSheet; + /** * 财务应收账款Controller @@ -28,6 +47,7 @@ import com.ruoyi.common.core.page.TableDataInfo; @RequestMapping("/financial/receivables") public class FinancialReceivablesController extends BaseController { + private static final String CHARSET_UTF8 = "utf-8"; private String prefix = "financial/receivables"; @Autowired @@ -127,6 +147,49 @@ public class FinancialReceivablesController extends BaseController } return prefix + "/addReceivablesVoucher"; } + /**导出收款凭证*/ + @RequiresPermissions("financial:receivables:export") + @Log(title = "财务应收账款凭证", businessType = BusinessType.EXPORT) + @GetMapping("/excelReceivablesVoucher/{financialReceivablesId}") + public void excelReceivablesVoucher(@PathVariable("financialReceivablesId") Long financialReceivablesId,HttpServletResponse response) throws IOException { + FinancialReceivables financialReceivables = financialReceivablesService.selectFinancialReceivablesById(financialReceivablesId); + + + // 模版位置 + String name = "FinancialReceiptVoucherTemplate.xlsx"; + + // 设置响应头,指定文件名和文件类型 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("FinancialReceiptVoucher.xlsx", "UTF-8")); + response.setContentType("application/octet-stream"); + + InputStream inputStream = null; + try { + // 获取模板文件的输入流 + inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); + + if (inputStream == null) { + throw new FileNotFoundException("模板文件未找到:" + name); + } + + // 创建一个ExcelWriterBuilder对象,并指定输出流和输入流 + ExcelWriterBuilder writerBuilder = EasyExcel.write(response.getOutputStream()); + + // 创建一个WriteSheet对象,并指定模板中的Sheet编号 + WriteSheet writeSheet = EasyExcel.writerSheet(0).build(); + + // 将数据写入Excel文件 + writerBuilder.withTemplate(inputStream).sheet("sheet1").doFill(financialReceivables); + + } finally { + // 关闭输入流 + if (inputStream != null) { + inputStream.close(); + } + } + + // 刷新输出流 + response.flushBuffer(); + } /** * 新增保存销售订单创建收款凭证 @@ -241,4 +304,7 @@ public class FinancialReceivablesController extends BaseController return getDataTable(financialReceivablesRecords); } + + + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialReceivables.java b/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialReceivables.java index 5282706e..dbb648b2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialReceivables.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialReceivables.java @@ -6,10 +6,12 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.financial.domain.VO.FinancialReceivablesRecordsVO; +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import org.springframework.context.annotation.EnableAspectJAutoProxy; /** * 财务应收账款对象 financial_receivables @@ -17,6 +19,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * @author 刘晓旭 * @date 2024-05-08 */ +@Data public class FinancialReceivables extends BaseEntity { private static final long serialVersionUID = 1L; @@ -35,6 +38,9 @@ public class FinancialReceivables extends BaseEntity /** 关联销售订单号 */ @Excel(name = "关联销售订单号") private String salesOrderCode; + /*借方科目*/ + @Excel(name = "借方科目", readConverterExp="0=银行存款,1=现金") + private String debitAccount; /** 贷方科目 */ @Excel(name = "贷方科目") @@ -45,7 +51,7 @@ public class FinancialReceivables extends BaseEntity private String creditDetail; /** 开户银行 */ - @Excel(name = "开户银行") + @Excel(name = "开户银行",readConverterExp="0=中行基本户,建行一般户") private String openBank; /** 开户账号 */ @@ -113,10 +119,41 @@ public class FinancialReceivables extends BaseEntity @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd") private Date operatingTime; + /*年*/ + private String year; + /*月*/ + private String month; + /*日*/ + private String day; + /** 收款备注 */ @Excel(name = "收款备注") private String receivablesRemark; + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + + public String getDay() { + return day; + } + + public void setDay(String day) { + this.day = day; + } + /** 收款记录集合 */ List receivablesRecordsList; @@ -354,7 +391,6 @@ public class FinancialReceivables extends BaseEntity public void setReceivablesRecordsVOList(List receivablesRecordsVOList) { this.receivablesRecordsVOList = receivablesRecordsVOList; } - @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialReceivablesRecords.java b/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialReceivablesRecords.java index 8c61c23d..82fb4c20 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialReceivablesRecords.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialReceivablesRecords.java @@ -51,8 +51,18 @@ public class FinancialReceivablesRecords extends BaseEntity /** 收款备注 */ @Excel(name = "收款备注") private String receivablesRemark; + /*获取当前登录的账号*/ + private String operatingPerson; - public void setReceivablesRecordsId(Long receivablesRecordsId) + public String getOperatingPerson() { + return operatingPerson; + } + + public void setOperatingPerson(String operatingPerson) { + this.operatingPerson = operatingPerson; + } + + public void setReceivablesRecordsId(Long receivablesRecordsId) { this.receivablesRecordsId = receivablesRecordsId; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/VO/FinancialReceivablesRecordsVO.java b/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/VO/FinancialReceivablesRecordsVO.java index b2c600ce..a210c343 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/VO/FinancialReceivablesRecordsVO.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/financial/domain/VO/FinancialReceivablesRecordsVO.java @@ -47,3 +47,5 @@ public class FinancialReceivablesRecordsVO extends BaseEntity { @Excel(name = "收款备注") private String receivablesRemark; } + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/financial/service/IFinancialReceivablesService.java b/ruoyi-admin/src/main/java/com/ruoyi/financial/service/IFinancialReceivablesService.java index 1e0a6295..e7a6051e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/financial/service/IFinancialReceivablesService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/financial/service/IFinancialReceivablesService.java @@ -1,6 +1,8 @@ package com.ruoyi.financial.service; import java.util.List; +import java.util.Map; + import com.ruoyi.financial.domain.FinancialReceivables; /** @@ -87,4 +89,9 @@ public interface IFinancialReceivablesService * 销售订单审批完成后根据销售单号生成财务应收账款 * */ int generateReceivablesBySalesOrderCode(String salesOrderCode); + + /** + * 查询导出收款凭证 + */ + Map exportReceivables(FinancialReceivables financialReceivables); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinancialReceivablesServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinancialReceivablesServiceImpl.java index f3e75552..575d3a4e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinancialReceivablesServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinancialReceivablesServiceImpl.java @@ -4,7 +4,9 @@ import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; @@ -198,6 +200,18 @@ public class FinancialReceivablesServiceImpl implements IFinancialReceivablesSer } + @Override + public Map exportReceivables(FinancialReceivables financialReceivables) { + //获取应收账款列表 + FinancialReceivables financialReceivablesList = financialReceivablesMapper.selectFinancialReceivablesById(financialReceivables.getFinancialReceivablesId()); + FinancialReceivablesRecords financialReceivablesRecords = new FinancialReceivablesRecords(); + financialReceivablesRecords.setFinancialReceivablesCode(financialReceivablesList.getFinancialReceivablesCode()); + //再获取对应应收账款的收款凭证列表 + List financialReceivablesRecordsList = receivablesRecordsMapper.selectFinancialReceivablesRecordsList(financialReceivablesRecords); + Map map = new HashMap<>(); + return map; + } + /** * 删除财务应收账款对象 diff --git a/ruoyi-admin/src/main/resources/mapper/financial/FinancialReceivablesMapper.xml b/ruoyi-admin/src/main/resources/mapper/financial/FinancialReceivablesMapper.xml index a2aaeda8..fd713ec9 100644 --- a/ruoyi-admin/src/main/resources/mapper/financial/FinancialReceivablesMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/financial/FinancialReceivablesMapper.xml @@ -5,34 +5,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -70,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" financial_receivables_code, receivables_closing_status, sales_order_code, + debit_account, credit_account, credit_detail, open_bank, @@ -99,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{financialReceivablesCode}, #{receivablesClosingStatus}, #{salesOrderCode}, + #{debitAccount}, #{creditAccount}, #{creditDetail}, #{openBank}, @@ -132,6 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" financial_receivables_code = #{financialReceivablesCode}, receivables_closing_status = #{receivablesClosingStatus}, sales_order_code = #{salesOrderCode}, + debit_account = #{debitAccount}, credit_account = #{creditAccount}, credit_detail = #{creditDetail}, open_bank = #{openBank}, diff --git a/ruoyi-admin/src/main/resources/templates/financial/receivables/addFinancialReceivables.html b/ruoyi-admin/src/main/resources/templates/financial/receivables/addFinancialReceivables.html index 4d0e9620..6cbb45dd 100644 --- a/ruoyi-admin/src/main/resources/templates/financial/receivables/addFinancialReceivables.html +++ b/ruoyi-admin/src/main/resources/templates/financial/receivables/addFinancialReceivables.html @@ -31,7 +31,7 @@ -
+
+
+ +
+ +
+
@@ -44,7 +53,11 @@
- + +
@@ -53,13 +66,13 @@
-
+ -
+
+ +
+ +
+
+ -
+