From f27c124cc18b9b62e0343af8f8249e51f2ddfc87 Mon Sep 17 00:00:00 2001 From: zhangsiqi <2825463979@qq.com> Date: Wed, 14 Aug 2024 19:50:15 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E6=96=B0=E5=A2=9E=E5=80=9F=E6=96=B9=E7=A7=91=E7=9B=AE?= =?UTF-8?q?=EF=BC=9A=E4=B8=8B=E6=8B=89=E9=80=89=E9=A1=B9=E4=B8=BA0=20?= =?UTF-8?q?=E9=93=B6=E8=A1=8C=E5=AD=98=E6=AC=BE=EF=BC=8C1=20=E4=B8=BA?= =?UTF-8?q?=E7=8E=B0=E9=87=91=E3=80=82=E5=BC=80=E6=88=B7=E9=93=B6=E8=A1=8C?= =?UTF-8?q?=EF=BC=9A0=E8=A1=A8=E7=A4=BA=20=E4=B8=AD=E8=A1=8C=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E6=88=B7=EF=BC=8C1=E8=A1=A8=E7=A4=BA=E5=BB=BA?= =?UTF-8?q?=E8=A1=8C=E4=B8=80=E8=88=AC=E6=88=B7=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=E8=B4=A2=E5=8A=A1=E5=BA=94=E4=BB=98=E6=A1=86=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=94=B6=E6=AC=BE=E5=87=AD=E8=AF=81=EF=BC=88=E9=94=80?= =?UTF-8?q?=E5=94=AE=E8=AE=A2=E5=8D=95=EF=BC=89=EF=BC=8C=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=BC=80=E6=88=B7=E9=93=B6=E8=A1=8C=EF=BC=8C=E4=BB=8E?= =?UTF-8?q?input=E8=BE=93=E5=85=A5=E6=A1=86=E6=94=B9=E4=B8=BA=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E9=80=89=E9=A1=B9=EF=BC=8C=E6=8F=90=E4=BE=9B=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E3=80=82=20=E5=AF=BC=E5=87=BA=E6=98=AF@excel=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=E6=96=B0=E5=A2=9E@Excel(name=20=3D=20"=E5=80=9F?= =?UTF-8?q?=E6=96=B9=E7=A7=91=E7=9B=AE",=20readConverterExp=3D"0=3D?= =?UTF-8?q?=E9=93=B6=E8=A1=8C=E5=AD=98=E6=AC=BE=EF=BC=8C1=3D=E7=8E=B0?= =?UTF-8?q?=E9=87=91")=EF=BC=8C=E4=BF=AE=E6=94=B9mapper.xml=20=E6=8F=92?= =?UTF-8?q?=E5=85=A5SQL=E8=AF=AD=E5=8F=A5=E6=96=B0=E5=A2=9E=E5=AD=97?= =?UTF-8?q?=E6=AE=B5debitaccount=E3=80=82=20=E6=96=B0=E5=A2=9E=EF=BC=9A?= =?UTF-8?q?=E6=94=B6=E6=AC=BE=E5=87=AD=E8=AF=81=E5=AF=BC=E5=87=BA=E6=96=B9?= =?UTF-8?q?=E6=B3=95excelReceivablesVoucher().?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinancialReceivablesController.java | 66 +++++++++++ .../domain/FinancialReceivables.java | 40 ++++++- .../domain/FinancialReceivablesRecords.java | 12 +- .../VO/FinancialReceivablesRecordsVO.java | 2 + .../service/IFinancialReceivablesService.java | 7 ++ .../impl/FinancialReceivablesServiceImpl.java | 14 +++ .../financial/FinancialReceivablesMapper.xml | 60 +++++----- .../receivables/addFinancialReceivables.html | 2 +- .../receivables/addReceivablesVoucher.html | 110 +++++++----------- .../addReceivablesVoucherNoSales.html | 82 ++++++------- 10 files changed, 250 insertions(+), 145 deletions(-) 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 @@
-
+ -
+
+ +
+ +
+
+ -
+