Browse Source

2023年1月10 18:15

wangzhuo 2 years ago
parent
commit
98fa0f1e3c

+ 51 - 0
blade-service-api/trade-finance-api/src/main/java/org/springblade/finance/excel/ChargeExcel.java

@@ -0,0 +1,51 @@
+package org.springblade.finance.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ *  应收账款余额导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class ChargeExcel {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 客户
+	 */
+	@ExcelProperty(value = "客户")
+	private String corpName;
+
+	/**
+	 * 本期应收
+	 */
+	@ExcelProperty(value = "本期应收")
+	private BigDecimal amount;
+
+	/**
+	 * 本期已收
+	 */
+	@ExcelProperty(value = "本期已收")
+	private BigDecimal settlementAmount;
+
+	/**
+	 * 余额(总)
+	 */
+	@ExcelProperty(value = "余额(总)")
+	private BigDecimal balance;
+
+	/**
+	 * 溢付款余额
+	 */
+	@ExcelProperty(value = "溢付款余额")
+	private BigDecimal inOverpayment;
+}

+ 93 - 0
blade-service-api/trade-finance-api/src/main/java/org/springblade/finance/excel/ChargeItemExcel.java

@@ -0,0 +1,93 @@
+package org.springblade.finance.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ *  应收账款余额明细导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class ChargeItemExcel {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 销售单号
+	 */
+	@ExcelProperty(value = "销售单号")
+	private String accSysNo;
+
+	/**
+	 * 数量
+	 */
+	@ExcelProperty(value = "数量")
+	private BigDecimal quantity;
+
+	/**
+	 * 应收金额
+	 */
+	@ExcelProperty(value = "应收金额")
+	private BigDecimal amount;
+
+	/**
+	 * 已收金额
+	 */
+	@ExcelProperty(value = "已收金额")
+	private BigDecimal settlementAmount;
+
+	/**
+	 * 余额
+	 */
+	@ExcelProperty(value = "余额")
+	private BigDecimal balance;
+
+	/**
+	 * 科目代码
+	 */
+	@ExcelProperty(value = "科目代码")
+	private String subjectNumber;
+
+	/**
+	 * 开户银行
+	 */
+	@ExcelProperty(value = "开户银行")
+	private String accountBank;
+
+	/**
+	 * 银行户头
+	 */
+	@ExcelProperty(value = "银行户头")
+	private String accountName;
+
+	/**
+	 * 银行账号
+	 */
+	@ExcelProperty(value = "银行账号")
+	private String accountNo;
+
+	/**
+	 * 溢付款
+	 */
+	@ExcelProperty(value = "溢付款")
+	private String overPayment;
+
+	/**
+	 * 使用返利
+	 */
+	@ExcelProperty(value = "使用返利")
+	private String usedProfit;
+
+	/**
+	 * 使用溢付款
+	 */
+	@ExcelProperty(value = "使用溢付款")
+	private String caseOverPayment;
+}

+ 51 - 0
blade-service-api/trade-finance-api/src/main/java/org/springblade/finance/excel/PayExcel.java

@@ -0,0 +1,51 @@
+package org.springblade.finance.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ *  应付账款余额导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class PayExcel {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 客户
+	 */
+	@ExcelProperty(value = "客户")
+	private String corpName;
+
+	/**
+	 * 本期应付
+	 */
+	@ExcelProperty(value = "本期应收")
+	private BigDecimal amount;
+
+	/**
+	 * 本期已付
+	 */
+	@ExcelProperty(value = "本期已收")
+	private BigDecimal settlementAmount;
+
+	/**
+	 * 余额(总)
+	 */
+	@ExcelProperty(value = "余额(总)")
+	private BigDecimal balance;
+
+	/**
+	 * 溢付款余额
+	 */
+	@ExcelProperty(value = "溢付款余额")
+	private BigDecimal inOverpayment;
+}

+ 81 - 0
blade-service-api/trade-finance-api/src/main/java/org/springblade/finance/excel/PayItemExcel.java

@@ -0,0 +1,81 @@
+package org.springblade.finance.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ *  应付账款余额明细导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class PayItemExcel {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 采购单号
+	 */
+	@ExcelProperty(value = "采购单号")
+	private String accSysNo;
+
+	/**
+	 * 数量
+	 */
+	@ExcelProperty(value = "数量")
+	private BigDecimal quantity;
+
+	/**
+	 * 应收金额
+	 */
+	@ExcelProperty(value = "应收金额")
+	private BigDecimal amount;
+
+	/**
+	 * 已收金额
+	 */
+	@ExcelProperty(value = "已收金额")
+	private BigDecimal settlementAmount;
+
+	/**
+	 * 余额
+	 */
+	@ExcelProperty(value = "余额")
+	private BigDecimal balance;
+
+	/**
+	 * 科目代码
+	 */
+	@ExcelProperty(value = "科目代码")
+	private String subjectNumber;
+
+	/**
+	 * 开户银行
+	 */
+	@ExcelProperty(value = "开户银行")
+	private String accountBank;
+
+	/**
+	 * 银行户头
+	 */
+	@ExcelProperty(value = "银行户头")
+	private String accountName;
+
+	/**
+	 * 银行账号
+	 */
+	@ExcelProperty(value = "银行账号")
+	private String accountNo;
+
+	/**
+	 * 使用溢付款
+	 */
+	@ExcelProperty(value = "使用溢付款")
+	private String caseOverPayment;
+}

+ 49 - 3
blade-service/trade-finance/src/main/java/org/springblade/finance/controller/AccController.java

@@ -42,13 +42,13 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
-import org.springblade.finance.excel.FeeStatisticsExcel;
-import org.springblade.finance.excel.FeeStatisticsExcelJTMC;
+import org.springblade.finance.excel.*;
 import org.springblade.finance.service.IAccService;
 import org.springblade.finance.vo.AccVO;
 import org.springblade.finance.vojo.Acc;
 import org.springblade.finance.vojo.ExportAccDWTOut;
 import org.springblade.finance.vojo.ExportAccOut;
+import org.springblade.purchase.sales.vo.SalesDetailsVo;
 import org.springblade.system.entity.Tenant;
 import org.springblade.system.feign.ITenantClient;
 import org.springblade.system.user.feign.IUserClient;
@@ -608,7 +608,7 @@ public class AccController extends BladeController {
 	}
 
 	/**
-	 * 应收账款余额
+	 * 应收账款余额
 	 */
 	@GetMapping("/selBillBalance")
 	@ApiOperation(value = "收付款余额", notes = "传入acc")
@@ -619,6 +619,52 @@ public class AccController extends BladeController {
 	}
 
 	/**
+	 * 应收付账款余额导出
+	 */
+	@GetMapping("/selBillBalanceExport")
+	@ApiOperation(value = "应收付账款余额导出", notes = "应收付账款余额导出")
+	public void selBillBalanceExport(Acc acc, HttpServletResponse response) {
+		acc.setTenantId(AuthUtil.getTenantId());
+		List<Acc> list = accService.selBillBalanceExport(acc);
+		if ("收费".equals(acc.getBillType())){
+			List<ChargeExcel> chargeExcelList = BeanUtil.copy(list, ChargeExcel.class);
+			ExcelUtil.export(response, "应收账款余额", "应收账款余额", chargeExcelList, ChargeExcel.class);
+		}else if ("申请".equals(acc.getBillType())){
+			List<PayExcel> payExcelList = BeanUtil.copy(list, PayExcel.class);
+			ExcelUtil.export(response, "应付账款余额", "应付账款余额", payExcelList, PayExcel.class);
+		}
+
+	}
+
+	/**
+	 * 应收付款明细
+	 */
+	@GetMapping("/SelAccItem")
+	@ApiOperation(value = "应收付款明细", notes = "应收付款明细")
+	public R<IPage<Acc>> SelAccItem(Acc acc, Query query){
+		acc.setTenantId(AuthUtil.getTenantId());
+		IPage<Acc> page = accService.SelAccItem(Condition.getPage(query), acc);
+		return R.data(page);
+	}
+
+	/**
+	 * 应收付款明细导出
+	 */
+	@GetMapping("/SelAccItemExport")
+	@ApiOperation(value = "应收付款明细导出", notes = "应收付款明细导出")
+	public void SelAccItemExport(Acc acc, HttpServletResponse response){
+		acc.setTenantId(AuthUtil.getTenantId());
+		List<Acc> list = accService.SelAccItemExport(acc);
+		if ("收费".equals(acc.getBillType())){
+			List<ChargeItemExcel> chargeItemList = BeanUtil.copy(list, ChargeItemExcel.class);
+			ExcelUtil.export(response, "应收账款明细", "应收账款明细", chargeItemList, ChargeItemExcel.class);
+		}else if ("申请".equals(acc.getBillType())){
+			List<PayItemExcel> payItemList = BeanUtil.copy(list, PayItemExcel.class);
+			ExcelUtil.export(response, "应付账款明细", "应付账款明细", payItemList, PayItemExcel.class);
+		}
+	}
+
+	/**
 	 * 获得应收应付总额
 	 */
 	@GetMapping("/SumBillBalance")

+ 2 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/mapper/AccMapper.java

@@ -88,5 +88,7 @@ public interface AccMapper extends BaseMapper<Acc> {
 
 	List<Acc> selBillBalance(IPage<Acc> page, @Param("acc") Acc acc);
 
+	List<Acc> SelAccItem(IPage<Acc> page, @Param("acc") Acc acc);
+
 	Map<String, Object> SumBillBalance(@Param("acc") Acc acc);
 }

+ 61 - 9
blade-service/trade-finance/src/main/java/org/springblade/finance/mapper/AccMapper.xml

@@ -58,10 +58,11 @@
 
     <select id="selBillBalance" resultType="org.springblade.finance.vojo.Acc">
         SELECT
+            FC.Corpid AS corpId,
             BCD.cname AS corpName,
             IFNULL( BC.amount, 0 ) AS amount,
-            IFNULL( BC.settlementAmount, 0 ) AS settlementAmount,
-            IFNULL( (SUM( FC.Amount ) - SUM( FC.Settlement_Amount )), 0 )AS balance,
+            IFNULL( FS.settlementAmount, 0 ) AS settlementAmount,
+            IFNULL( IFNULL( BC.amount, 0 ) - IFNULL( FS.settlementAmount, 0 ), 0 ) AS balance,
             IFNULL( BO.in_overpayment, 0 ) AS inOverpayment
         FROM finance_acc FC
         LEFT JOIN basic_corps_desc BCD ON BCD.id = FC.Corpid
@@ -82,16 +83,35 @@
                 <if test='acc.createDateList != null and acc.createDateList[1] != null and acc.createDateList[1]!= ""'>
                     and FC.create_time &lt;= #{acc.createDateList[1]}
                 </if>
-                <if test='acc.createStartDate != null and acc.createStartDate != ""'>
-                    and FC.create_time &gt;= #{acc.createStartDate}
-                </if>
-                <if test='acc.createEndDate != null and acc.createEndDate != ""'>
-                    and FC.create_time &lt;= #{acc.createEndDate}
-                </if>
             </where>
             GROUP BY
             FC.Corpid
         ) BC ON BC.corpId = FC.Corpid
+        LEFT JOIN (
+            SELECT
+                FS.Corp_id AS corpId,
+                sum( FS.Amount ) AS settlementAmount
+            FROM  finance_settlement FS
+            <where>
+                FS.tenant_id = #{acc.tenantId}
+                AND FS.is_deleted = 0
+                AND FS.finance_status = '结算完成'
+                <if test='acc.billType != null and acc.billType != "" and acc.billType == "申请"'>
+                    AND FS.bill_type = '付费'
+                </if>
+                <if test='acc.billType != null and acc.billType != "" and acc.billType == "收费"'>
+                    AND FS.bill_type = #{acc.billType}
+                </if>
+                <if test='acc.createDateList != null and acc.createDateList[0] != null and acc.createDateList[0]!= ""'>
+                    and FS.completion_time &gt;= #{acc.createDateList[0]}
+                </if>
+                <if test='acc.createDateList != null and acc.createDateList[1] != null and acc.createDateList[1]!= ""'>
+                    and FS.completion_time &lt;= #{acc.createDateList[1]}
+                </if>
+            </where>
+            GROUP BY
+            FS.Corp_id
+        ) FS ON FS.corpId = FC.Corpid
         <where>
             FC.tenant_id = #{acc.tenantId}
             and FC.is_deleted = 0
@@ -101,7 +121,39 @@
             </if>
         </where>
         GROUP BY FC.Corpid
-        HAVING SUM(FC.Amount-FC.Settlement_Amount) >= 100
+        HAVING SUM(IFNULL( IFNULL( BC.amount, 0 ) - IFNULL( FS.settlementAmount, 0 ), 0 )) >= 100
+    </select>
+
+    <select id="SelAccItem" resultType="org.springblade.finance.vojo.Acc">
+        SELECT DISTINCT
+            FA.AccSysNo AS accSysNo,
+            FA.quantity AS quantity,
+            FA.Amount AS amount,
+            FA.Settlement_Amount AS settlementAmount,
+            IFNULL( IFNULL( FA.Amount, 0 ) - IFNULL( FA.Settlement_Amount, 0 ), 0 ) AS balance,
+            FS.subject_number as subjectNumber,
+            FS.ACCOUNT_bank AS accountBank,
+            FS.ACCOUNT_NAME AS accountName,
+            FS.ACCOUNT_no AS accountNo,
+            FS.over_payment AS overPayment,
+            0 as usedProfit,
+            FS.case_over_payment AS caseOverPayment
+        FROM finance_acc FA
+                 LEFT JOIN finance_settlement FS ON FS.Src_OrderNo = FA.AccSysNo
+        <where>
+            FA.tenant_id = #{acc.tenantId}
+            AND FA.is_deleted = 0
+            and FC.bill_type = #{acc.billType}
+            <if test="acc.corpId != null and acc.corpId != ''">
+                and FC.Corpid = #{acc.corpId}
+            </if>
+            <if test="acc.accSysNo != null and acc.accSysNo != ''">
+                and FA.AccSysNo like concat('%', #{acc.accSysNo}, '%')
+            </if>
+            <if test="acc.amount != null and acc.amount != ''">
+                and FA.Amount like concat('%', #{acc.amount}, '%')
+            </if>
+        </where>
     </select>
 
     <select id="SumBillBalance" resultType="java.util.Map">

+ 6 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/service/IAccService.java

@@ -104,5 +104,11 @@ public interface IAccService extends IService<Acc> {
 
 	IPage<Acc> selBillBalance(IPage<Acc> page, Acc acc);
 
+	List<Acc> selBillBalanceExport(Acc acc);
+
+	IPage<Acc> SelAccItem(IPage<Acc> page, Acc acc);
+
+	List<Acc> SelAccItemExport(Acc acc);
+
 	Map<String, Object> SumBillBalance(Acc acc);
 }

+ 15 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/service/impl/AccServiceImpl.java

@@ -451,6 +451,21 @@ public class AccServiceImpl extends ServiceImpl<AccMapper, Acc> implements IAccS
 	}
 
 	@Override
+	public List<Acc> selBillBalanceExport(Acc acc){
+		return baseMapper.selBillBalance(null, acc);
+	}
+
+	@Override
+	public IPage<Acc> SelAccItem(IPage<Acc> iPage, Acc acc){
+		return iPage.setRecords(baseMapper.SelAccItem(iPage, acc));
+	}
+
+	@Override
+	public List<Acc> SelAccItemExport(Acc acc){
+		return baseMapper.SelAccItem(null, acc);
+	}
+
+	@Override
 	public Map<String, Object> SumBillBalance(Acc acc){
 		return baseMapper.SumBillBalance(acc);
 	}