Просмотр исходного кода

新增结算归档记录表,增加定时任务进行归档数据记录

xucaiqin 2 лет назад
Родитель
Сommit
c119e61408
21 измененных файлов с 891 добавлено и 14 удалено
  1. 18 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java
  2. 26 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  3. 3 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java
  4. 20 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementRecordMapper.java
  5. 4 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java
  6. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/job/AsyncPool.java
  7. 93 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementRecord.java
  8. 134 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/LedgerLogistics.java
  9. 129 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/LedgerSell.java
  10. 42 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/FinanceCount.java
  11. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java
  12. 26 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementRecordService.java
  13. 3 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  14. 23 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WorkbenchService.java
  15. 3 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java
  16. 68 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/task/FinanceTask.java
  17. 122 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  18. 71 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  19. 25 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml
  20. 52 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementRecordMapper.xml
  21. 25 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

+ 18 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java

@@ -6,6 +6,7 @@ import com.sckw.payment.model.dto.LedgerCarrierDto;
 import com.sckw.payment.model.dto.LedgerLogisticsDto;
 import com.sckw.payment.model.dto.LedgerShipperDto;
 import com.sckw.payment.model.dto.LedgerSize;
+import com.sckw.payment.model.vo.LedgerLogistics;
 import com.sckw.payment.model.vo.req.LogisticsReq;
 import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -31,6 +32,14 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      */
     List<LedgerShipperDto> shipperSelect(@Param("logisticsReq") LogisticsReq logisticsReq);
 
+    /**
+     * 运营端
+     *
+     * @param logisticsReq
+     * @return
+     */
+    List<LedgerLogistics> list(@Param("logisticsReq") LogisticsReq logisticsReq);
+
     /**
      * 承运方 对账发起方,客户公司是托运方
      *
@@ -47,10 +56,19 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      */
     Map<String, Long> countOrder(@Param("logisticsReq") LogisticsReq logisticsReq);
 
+    /**
+     * 运营端统计
+     *
+     * @param logisticsReq
+     * @return
+     */
+    Map<String, Long> countOrder2(@Param("logisticsReq") LogisticsReq logisticsReq);
+
     LedgerLogisticsDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
 
     List<LedgerShipperDto> selectShipperIds(@Param("ids") List<Long> ids);
+    List<LedgerLogistics> selectIds(@Param("ids") List<Long> ids);
 
     /**
      * 承运方

+ 26 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java

@@ -6,6 +6,7 @@ import com.sckw.payment.model.dto.LedgerPurchaseDto;
 import com.sckw.payment.model.dto.LedgerSellDto;
 import com.sckw.payment.model.dto.LedgerSize;
 import com.sckw.payment.model.dto.LedgerTradeDto;
+import com.sckw.payment.model.vo.LedgerSell;
 import com.sckw.payment.model.vo.req.TradeReq;
 import com.sckw.payment.model.vo.res.LedgerCountSumVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -25,6 +26,14 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
 
     List<LedgerSellDto> sellList(@Param("tradeReq") TradeReq tradeReq);
 
+    /**
+     * 运营端 对账列表数据
+     *
+     * @param tradeReq
+     * @return
+     */
+    List<LedgerSell> list(@Param("tradeReq") TradeReq tradeReq);
+
     /**
      * 采购方数据需要过滤已保存、已撤回状态的数据
      *
@@ -34,8 +43,22 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
 
     List<LedgerPurchaseDto> purchaseList(@Param("tradeReq") TradeReq tradeReq);
 
+    /**
+     * 统计对账单数量
+     *
+     * @param tradeReq
+     * @return
+     */
     Map<String, Long> countOrder(@Param("tradeReq") TradeReq tradeReq);
 
+    /**
+     * 运营端统计对账单数量
+     *
+     * @param tradeReq
+     * @return
+     */
+    Map<String, Long> countOrder2(@Param("tradeReq") TradeReq tradeReq);
+
     LedgerTradeDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 
     List<LedgerSellDto> selectSellIds(@Param("ids") List<Long> ids);
@@ -47,12 +70,11 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
     void updatePrice(@Param("id") Long id, @Param("totalPrice") BigDecimal totalPrice);
 
     /**
-     *
-     * @param entId 采购单位
+     * @param entId     采购单位
      * @param entTarget 销售单位
      * @return
      */
-    List<String> selectJoin(@Param("entId")Long entId, @Param("entTarget")Long entTarget);
+    List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);
 
-    LedgerSize countSize(@Param("entId")Long entId);
+    LedgerSize countSize(@Param("entId") Long entId);
 }

+ 3 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java

@@ -2,6 +2,7 @@ package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
+import com.sckw.payment.model.KwpSettlementRecord;
 import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.MoneyType;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
@@ -77,4 +78,6 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
      * @param unitType 企业类型
      */
     List<MoneyType> sumMoneyType(@Param("entId") Long entId, @Param("cur") List<LocalDateTime> cur, @Param("pre") List<LocalDateTime> pre, @Param("unitType") Integer unitType);
+
+    List<KwpSettlementRecord> queryRecord();
 }

+ 20 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementRecordMapper.java

@@ -0,0 +1,20 @@
+package com.sckw.payment.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.payment.model.KwpSettlementRecord;
+import com.sckw.payment.model.vo.req.FinanceCount;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+* @date 2023-09-13 18:48:30
+* @author xucaiqin
+*/
+@Mapper
+public interface KwpSettlementRecordMapper extends BaseMapper<KwpSettlementRecord> {
+    void insertBatch(@Param("list") List<KwpSettlementRecord> list);
+
+    void countByDay(FinanceCount financeCount);
+}

+ 4 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.payment.model.KwpSettlementRecord;
 import com.sckw.payment.model.KwpSettlementTrade;
 import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.MoneyType;
@@ -51,4 +52,7 @@ public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade>
      * @param unitType 企业类型
      */
     List<MoneyType> sumMoneyType(@Param("entId") Long entId, @Param("cur") List<LocalDateTime> cur, @Param("pre") List<LocalDateTime> pre, @Param("unitType") Integer unitType);
+
+    List<KwpSettlementRecord> queryRecord();
+
 }

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/job/AsyncPool.java

@@ -23,8 +23,8 @@ public class AsyncPool {
     }
 
     private static class ThreadPool {
-        public static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,
-                1,
+        public static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,
+                2,
                 1,
                 TimeUnit.MINUTES,
                 new LinkedBlockingQueue<>(12));

+ 93 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementRecord.java

@@ -0,0 +1,93 @@
+package com.sckw.payment.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+* @date 2023-09-13 18:48:30
+* @author xucaiqin
+*/
+/**
+    * 结算归档表
+    */
+@Data
+@TableName(value = "kwp_settlement_record")
+public class KwpSettlementRecord {
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.INPUT)
+    private Long id;
+
+    /**
+     * 企业id
+     */
+    @TableField(value = "ent_id")
+    private Long entId;
+
+    /**
+     * 总应收金额
+     */
+    @TableField(value = "total_receive_money")
+    private BigDecimal totalReceiveMoney;
+
+    /**
+     * 待收金额
+     */
+    @TableField(value = "exact_money")
+    private BigDecimal exactMoney;
+
+    /**
+     * 已收金额(累加金额)
+     */
+    @TableField(value = "received_money")
+    private BigDecimal receivedMoney;
+
+    /**
+     * 逾期待收金额
+     */
+    @TableField(value = "overdue_exact_money")
+    private BigDecimal overdueExactMoney;
+
+    /**
+     * 总应付金额
+     */
+    @TableField(value = "total_pay_money")
+    private BigDecimal totalPayMoney;
+
+    /**
+     * 待付金额
+     */
+    @TableField(value = "unpaid_money")
+    private BigDecimal unpaidMoney;
+
+    /**
+     * 已付金额(累加金额)
+     */
+    @TableField(value = "paid_money")
+    private BigDecimal paidMoney;
+
+    /**
+     * 逾期待付金额
+     */
+    @TableField(value = "overdue_paid_money")
+    private BigDecimal overduePaidMoney;
+
+    /**
+     * 创建日期
+     */
+    @TableField(value = "create_time")
+    private LocalDate createTime;
+
+    /**
+     * 1-物流 2-贸易
+     */
+    @TableField(value = "order_type")
+    private Integer orderType;
+}

+ 134 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/LedgerLogistics.java

@@ -0,0 +1,134 @@
+package com.sckw.payment.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.payment.model.dto.ILedger;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 对账-物流订单
+ *
+ * @author xucaiqin
+ * @date 2023-07-10 18:11:24
+ */
+@Getter
+@Setter
+public class LedgerLogistics implements ILedger {
+    /**
+     * 主键
+     */
+    private Long id;
+    /**
+     * 物流对账单编号
+     */
+    private String lLedgerNo;
+
+    /**
+     * 对账单名称
+     */
+    private String name;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 托运单位
+     */
+    private String shipperFirmName;
+
+    /**
+     * 承运单位
+     */
+    private String carrierFirmName;
+
+
+
+    /**
+     * 发票税率(%)
+     */
+    private String taxRateLabel;
+    private Integer taxRate;
+
+    /**
+     * 交易方式(预付款、货到付款)
+     */
+    private String trading;
+    private String tradingLabel;
+    /**
+     * 对账托运方财务联系人电话
+     */
+    private String auditPhone;
+
+    /**
+     * 对账托运方财务联系人名称
+     */
+    private String auditUser;
+    /**
+     * 对账承运方财务联系人名称
+     */
+    private String successUser;
+    /**
+     * 对账承运方财务联系人电话
+     */
+    private String successPhone;
+
+    /**
+     * 总应收/元
+     */
+    private BigDecimal totalPrice;
+    /**
+     * 不含税金额
+     */
+    private BigDecimal exTaxPrice;
+
+    /**
+     * 实际结算金额
+     */
+    private BigDecimal settlePrice;
+
+    /**
+     * 已收款/元
+     */
+    private BigDecimal actualPrice;
+
+    /**
+     * 对账清单凭证
+     */
+    private String url;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime generateTime;
+    /**
+     * 预计收款时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDateTime receiptTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态状态(1-已保存、2-待对账、3-已对账、4-已完成、5-已退回)
+     */
+    private Integer status;
+    private String statusLabel;
+    /**
+     * 创建人
+     */
+    private Long createBy;
+    private String createByName;
+
+    /**
+     * 订单数量
+     */
+    private Integer orderCount;
+}

+ 129 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/LedgerSell.java

@@ -0,0 +1,129 @@
+package com.sckw.payment.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.sckw.payment.model.dto.ILedger;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 对账-贸易订单 销售方
+ *
+ * @author xucaiqin
+ * @date 2023-07-10 18:11:24
+ */
+@Getter
+@Setter
+public class LedgerSell implements ILedger {
+    /**
+     * 主键
+     */
+    private Long id;
+    /**
+     * 贸易对账单编号
+     */
+    @JsonProperty("tLedgerNo")
+    private String tLedgerNo;
+
+    /**
+     * 对账单名称
+     */
+    private String name;
+
+
+    /**
+     * 开始日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime startTime;
+
+    /**
+     * 结束日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime endTime;
+
+    /**
+     * 发票税率(%)
+     */
+    private Integer taxRate;
+    private String taxRateLabel;
+
+    /**
+     * 交易方式(预付款、货到付款)
+     */
+    private String trading;
+    private String tradingLabel;
+
+
+    /**
+     * 总应收/元
+     */
+    private BigDecimal totalPrice;
+    /**
+     * 不含税金额
+     */
+    private BigDecimal exTaxPrice;
+
+    /**
+     * 实际结算金额
+     */
+    private BigDecimal settlePrice;
+
+    /**
+     * 已收款/元
+     */
+    private BigDecimal actualPrice;
+
+    /**
+     * 对账审核人电话
+     */
+    private String auditPhone;
+
+    /**
+     * 对账审核人名称
+     */
+    private String auditUser;
+
+    /**
+     * 对账清单凭证
+     */
+    private String url;
+    /**
+     * 生成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime generateTime;
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDateTime receiptTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态(1-已保存、2-待对账、3-已对账、4-已完成、5-已退回)
+     */
+    private Integer status;
+    private String statusLabel;
+    private String contacts;
+    private String phone;
+    private String firmName;
+    /**
+     * 创建人
+     */
+    private Long createBy;
+    private String createByName;
+
+    /**
+     * 订单数量
+     */
+    private Integer orderCount;
+}

+ 42 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/FinanceCount.java

@@ -0,0 +1,42 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * 财务统计
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class FinanceCount {
+    /**
+     * 周期维度 日、月
+     */
+    @NotBlank(message = "周期维度不能为空")
+    private Integer circle;
+    /**
+     * 开始时间
+     */
+//    @NotBlank(message = "周期维度不能为空")
+    private String startTime;
+    /**
+     * 结束时间
+     */
+//    @NotBlank(message = "周期维度不能为空")
+    private String endTime;
+    /**
+     * 统计因子
+     */
+    @Size(message = "统计因子不能为空", min = 1)
+    @NotNull(message = "统计因子不能为空")
+    private List<Integer> factor;
+
+}

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java

@@ -61,7 +61,7 @@ public class KwpSettlementOfflineService {
     private final KwpSettlementTradeService settlementTradeService;
     private final KwpLedgerTradeOrderService tradeOrderService;
     private final KwpSettlementTradeTrackService settlementTradeTrackService;
-    private final KwpLedgerTradeService ledgerTradeService;
+    private final KwpLedgerTradeService kwpLedgerTradeService;
     private final MessageSender messageSender;
     private final KwpLedgerTradeUnitService tradeUnitService;
     @DubboReference(version = "1.0.0", group = "design", check = false)
@@ -388,7 +388,7 @@ public class KwpSettlementOfflineService {
 
                 settlementOfflineMapper.insert(kwpSettlementOffline);
                 //预付款-更新对账单已付金额
-                ledgerTradeService.updateActualPrice(byId.gettLedgerId(), payReq.getPayPrice());
+                kwpLedgerTradeService.updateActualPrice(byId.gettLedgerId(), payReq.getPayPrice());
 
                 //记录表记录数据
                 settlementTradeTrackService.save(KwpSettlementTradeTrack.build(byId.getId(), SettlementTrackEnum.OFFLINE_PAY.getStatus()));

+ 26 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementRecordService.java

@@ -0,0 +1,26 @@
+package com.sckw.payment.service;
+
+import com.sckw.payment.dao.KwpSettlementRecordMapper;
+import com.sckw.payment.model.vo.req.FinanceCount;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 归档记录
+ *
+ * @author xucaiqin
+ * @date 2023-08-28 15:38:53
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class KwpSettlementRecordService {
+    private final KwpSettlementRecordMapper kwpSettlementRecordMapper;
+
+
+    public String financeCount(FinanceCount financeCount) {
+        kwpSettlementRecordMapper.countByDay(financeCount);
+        return null;
+    }
+}

+ 3 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java

@@ -85,7 +85,7 @@ public class KwpSettlementWalletService {
     private TransportDubboService transportDubboService;
     private final KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
     @Resource
-    private KwpLedgerTradeService ledgerTradeService;
+    private KwpLedgerTradeService kwpLedgerTradeService;
 
 
     /**
@@ -386,7 +386,7 @@ public class KwpSettlementWalletService {
                 kwpSettlementWallet.setDelFlag(Global.UN_DELETED);
                 settlementWalletMapper.insert(kwpSettlementWallet);
                 //货到付款-更新对账单已付金额
-                ledgerTradeService.updateActualPrice(byId.getLedgerId(), price);
+                kwpLedgerTradeService.updateActualPrice(byId.getLedgerId(), price);
                 //更新交易结算单状态和金额
                 KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
                 kwpSettlementTrade.setId(byId.getId());
@@ -561,7 +561,7 @@ public class KwpSettlementWalletService {
                 kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
                 kwpSettlementTradeService.updateById(kwpSettlementTrade);
                 //预付款-更新对账单已付金额
-                ledgerTradeService.updateActualPrice(byId.gettLedgerId(), byId.getTotalPrice());
+                kwpLedgerTradeService.updateActualPrice(byId.gettLedgerId(), byId.getTotalPrice());
                 //新增电子钱包结算记录
                 KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
                 kwpSettlementWallet.setId(new IdWorker(1).nextId());

+ 23 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WorkbenchService.java

@@ -0,0 +1,23 @@
+package com.sckw.payment.service;
+
+import com.sckw.payment.model.vo.req.FinanceCount;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 工作台
+ *
+ * @author xucaiqin
+ * @date 2023-08-28 15:38:53
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class WorkbenchService {
+
+
+    public String financeCount(FinanceCount financeCount) {
+        return null;
+    }
+}

+ 3 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java

@@ -35,7 +35,7 @@ import java.util.*;
 @Slf4j
 public class PaymentDubboServiceImpl implements PaymentDubboService {
     private final KwpLedgerLogisticsService ledgerLogisticsService;
-    private final KwpLedgerTradeService ledgerTradeService;
+    private final KwpLedgerTradeService kwpLedgerTradeService;
     private final KwpSettlementLogisticsService settlementLogisticsService;
     private final KwpSettlementTradeService settlementTradeService;
 
@@ -62,7 +62,7 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
             throw new BusinessException("企业id不能为空");
         }
         List<String> logistics = ledgerLogisticsService.checkOrder(entId, entTarget);
-        List<String> trade = ledgerTradeService.checkOrder(entId, entTarget);
+        List<String> trade = kwpLedgerTradeService.checkOrder(entId, entTarget);
         Map<OrderEnum, List<String>> res = new HashMap<>(2);
         res.put(OrderEnum.LOGISTICS, logistics);
         res.put(OrderEnum.TRADE, trade);
@@ -85,7 +85,7 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
     @Override
     public LedgerCount countLedger(Long entId) {
         LedgerSize count = ledgerLogisticsService.count(entId);
-        LedgerSize ledgerSize = ledgerTradeService.count(entId);
+        LedgerSize ledgerSize = kwpLedgerTradeService.count(entId);
         return new LedgerCount(ledgerSize.send(), ledgerSize.receive(), count.send(), count.receive());
     }
 

+ 68 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/task/FinanceTask.java

@@ -0,0 +1,68 @@
+package com.sckw.payment.task;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
+import com.sckw.payment.dao.KwpSettlementRecordMapper;
+import com.sckw.payment.dao.KwpSettlementTradeMapper;
+import com.sckw.payment.model.KwpSettlementRecord;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * 财务定时任务
+ *
+ * @author xucaiqin
+ * @date 2023-09-05 19:37:00
+ */
+@Slf4j
+@Component
+@EnableScheduling
+public class FinanceTask {
+    @Resource
+    private KwpSettlementTradeMapper kwpSettlementTradeMapper;
+    @Resource
+    private KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
+    @Resource
+    private KwpSettlementRecordMapper kwpSettlementRecordMapper;
+
+    @Scheduled(cron = "0 0 0 ? * *")
+//    @Scheduled(cron = "0 0/1 * * * ?")
+    public void task() {
+        LocalDate now = LocalDate.now().minusDays(1);
+        log.info("结算记录归档:{}", now);
+        List<KwpSettlementRecord> moneyArchivedDto = kwpSettlementTradeMapper.queryRecord();
+        List<KwpSettlementRecord> kwpSettlementRecords = kwpSettlementLogisticsMapper.queryRecord();
+
+        try {
+            if (!CollectionUtils.isEmpty(moneyArchivedDto)) {
+                for (KwpSettlementRecord kwpSettlementRecord : moneyArchivedDto) {
+                    kwpSettlementRecord.setId(new IdWorker(NumberConstant.ONE).nextId());
+                    kwpSettlementRecord.setOrderType(2);
+                    kwpSettlementRecord.setCreateTime(now);
+                }
+                kwpSettlementRecordMapper.insertBatch(moneyArchivedDto);
+                log.info("贸易归档:{}", JSONObject.toJSONString(moneyArchivedDto));
+            }
+            if (!CollectionUtils.isEmpty(kwpSettlementRecords)) {
+                for (KwpSettlementRecord kwpSettlementRecord : kwpSettlementRecords) {
+                    kwpSettlementRecord.setId(new IdWorker(NumberConstant.ONE).nextId());
+                    kwpSettlementRecord.setOrderType(1);
+                    kwpSettlementRecord.setCreateTime(now);
+                }
+                kwpSettlementRecordMapper.insertBatch(kwpSettlementRecords);
+                log.info("物流归档:{}", JSONObject.toJSONString(kwpSettlementRecords));
+            }
+        } catch (Exception ex) {
+            log.error("结算记录归档异常:{}", ex, ex);
+        }
+    }
+}

+ 122 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -150,6 +150,95 @@
         </where>
         order by kll.generate_time desc
     </select>
+    <select id="list" resultType="com.sckw.payment.model.vo.LedgerLogistics">
+        SELECT kll.id,
+               MAX(kll.l_ledger_no)                                                 AS lLedgerNo,
+               MAX(kll.name)                                                        AS name,
+               MAX(kll.start_time)                                                  AS startTime,
+               MAX(kll.end_time)                                                    AS endTime,
+               MAX(kll.tax_rate)                                                    AS taxRate,
+               MAX(kll.trading)                                                     AS trading,
+               MAX(kll.total_price)                                                 AS totalPrice,
+               MAX(kll.ex_tax_price)                                                AS exTaxPrice,
+               MAX(kll.settle_price)                                                AS settlePrice,
+               MAX(kll.actual_price)                                                AS actualPrice,
+               MAX(kll.success_phone)                                               AS successPhone,
+               MAX(kll.success_user)                                                AS successUser,
+               MAX(kll.url)                                                         AS url,
+               MAX(kll.generate_time)                                               AS generateTime,
+               MAX(kll.receipt_time)                                                AS receiptTime,
+               MAX(kll.remark)                                                      AS remark,
+               MAX(kll.status)                                                      AS status,
+               MAX(kll.order_count)                                                 AS orderCount,
+               MAX(kll.create_by)                                                   AS createBy,
+               MAX(CASE WHEN kllu.unit_type = 1 THEN kllu.top_ent_id ELSE NULL END) AS shipperEntId,
+               MAX(CASE WHEN kllu.unit_type = 1 THEN kllu.firm_name ELSE NULL END)  AS shipperFirmName,
+               MAX(CASE WHEN kllu.unit_type = 2 THEN kllu.top_ent_id ELSE NULL END) AS carrierEntId,
+               MAX(CASE WHEN kllu.unit_type = 2 THEN kllu.firm_name ELSE NULL END)  AS carrierFirmName
+        FROM kwp_ledger_logistics kll
+                 INNER JOIN kwp_ledger_logistics_unit kllu
+                            ON kll.id = kllu.l_ledger_id AND kllu.del_flag = 0
+        <where>
+            kll.del_flag = 0
+            <if test="logisticsReq.status != null">
+                and kll.status = #{logisticsReq.status}
+            </if>
+            <if test="logisticsReq.trading != null">
+                and kll.trading = #{logisticsReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="logisticsReq.startCreateTime != null and logisticsReq.startCreateTime != '' and logisticsReq.endCreateTime != null and logisticsReq.endCreateTime != ''">
+                and kll.generate_time between #{logisticsReq.startCreateTime,jdbcType=TIMESTAMP}
+                    and #{logisticsReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="logisticsReq.keywords != null and logisticsReq.keywords != ''">
+                and (
+                            kll.l_ledger_no like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kllu.firm_name like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                    )
+            </if>
+        </where>
+        GROUP BY kll.id
+        order by generateTime desc
+    </select>
+    <select id="selectIds" resultType="com.sckw.payment.model.vo.LedgerLogistics">
+        SELECT kll.id,
+               MAX(kll.l_ledger_no)                                                 AS lLedgerNo,
+               MAX(kll.name)                                                        AS name,
+               MAX(kll.start_time)                                                  AS startTime,
+               MAX(kll.end_time)                                                    AS endTime,
+               MAX(kll.tax_rate)                                                    AS taxRate,
+               MAX(kll.trading)                                                     AS trading,
+               MAX(kll.total_price)                                                 AS totalPrice,
+               MAX(kll.ex_tax_price)                                                AS exTaxPrice,
+               MAX(kll.settle_price)                                                AS settlePrice,
+               MAX(kll.actual_price)                                                AS actualPrice,
+               MAX(kll.success_phone)                                               AS successPhone,
+               MAX(kll.success_user)                                                AS successUser,
+               MAX(kll.url)                                                         AS url,
+               MAX(kll.generate_time)                                               AS generateTime,
+               MAX(kll.receipt_time)                                                AS receiptTime,
+               MAX(kll.remark)                                                      AS remark,
+               MAX(kll.status)                                                      AS status,
+               MAX(kll.order_count)                                                 AS orderCount,
+               MAX(kll.create_by)                                                   AS createBy,
+               MAX(CASE WHEN kllu.unit_type = 1 THEN kllu.top_ent_id ELSE NULL END) AS shipperEntId,
+               MAX(CASE WHEN kllu.unit_type = 1 THEN kllu.firm_name ELSE NULL END)  AS shipperFirmName,
+               MAX(CASE WHEN kllu.unit_type = 2 THEN kllu.top_ent_id ELSE NULL END) AS carrierEntId,
+               MAX(CASE WHEN kllu.unit_type = 2 THEN kllu.firm_name ELSE NULL END)  AS carrierFirmName
+        FROM kwp_ledger_logistics kll
+                 INNER JOIN kwp_ledger_logistics_unit kllu
+                            ON kll.id = kllu.l_ledger_id AND kllu.del_flag = 0
+        <where>
+            kll.del_flag = 0
+              and kll.id in
+            <foreach collection="ids" item="id" close=")" open="(" separator=",">
+                #{id,jdbcType=BIGINT}
+            </foreach>
+        </where>
+        GROUP BY kll.id
+        order by generateTime desc
+    </select>
     <select id="countSum" resultType="com.sckw.payment.model.vo.res.LedgerCountSumVo">
         select IFNULL(count(1), 0)  "ledgerCount",
                sum(kll.total_price) "totalPrice"
@@ -255,6 +344,39 @@
         </where>
     </select>
 
+    <select id="countOrder2" resultType="java.util.Map">
+        SELECT count(1)                                    "0",
+               count(IF(kll_distinct.status = 1, 1, NULL)) "1",
+               count(IF(kll_distinct.status = 2, 1, NULL)) "2",
+               count(IF(kll_distinct.status = 3, 1, NULL)) "3",
+               count(IF(kll_distinct.status = 4, 1, NULL)) "4",
+               count(IF(kll_distinct.status = 5, 1, NULL)) "5",
+               count(IF(kll_distinct.status = 6, 1, NULL)) "6"
+        FROM (
+        SELECT DISTINCT kll.id, kll.status
+        FROM kwp_ledger_logistics kll
+                 INNER JOIN kwp_ledger_logistics_unit kllu
+                            ON kll.id = kllu.l_ledger_id AND kllu.del_flag = 0
+        <where>
+            kll.del_flag = 0
+            <if test="logisticsReq.trading != null">
+                AND kll.trading = #{logisticsReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="logisticsReq.startCreateTime != null and logisticsReq.startCreateTime != '' and logisticsReq.endCreateTime != null and logisticsReq.endCreateTime != ''">
+                AND kll.generate_time BETWEEN #{logisticsReq.startCreateTime,jdbcType=TIMESTAMP}
+                    AND #{logisticsReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="logisticsReq.keywords != null and logisticsReq.keywords != ''">
+                AND (
+                            kll.l_ledger_no LIKE CONCAT('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        OR kllu.firm_name LIKE CONCAT('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        OR kllu.contacts LIKE CONCAT('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                    )
+            </if>
+        </where>
+        ) kll_distinct
+    </select>
+
     <select id="selectCarrierIds" resultType="com.sckw.payment.model.dto.LedgerCarrierDto">
         select
         <include refid="list_col"/>

+ 71 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

@@ -152,6 +152,45 @@
         </where>
         order by klt.generate_time desc
     </select>
+    <select id="list" resultType="com.sckw.payment.model.vo.LedgerSell">
+        select
+        <include refid="sell_col"/>
+        from kwp_ledger_trade klt
+        inner join kwp_ledger_trade_unit kltu
+        on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
+        kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
+        inner join kwp_ledger_trade_unit kltu2
+        on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and kltu2.unit_type =
+        #{tradeReq.unitTypeTwo,jdbcType=INTEGER}
+        <where>
+            klt.del_flag = 0
+            and kltu2.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
+            <if test="tradeReq.status != null">
+                and klt.status = #{tradeReq.status}
+            </if>
+            <if test="tradeReq.trading != null">
+                and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
+                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
+                and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
+                and (
+                klt.t_ledger_no like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                or kltu.firm_name like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                or kltu.contacts like concat('%'
+                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                , '%')
+                )
+            </if>
+        </where>
+        order by klt.generate_time desc
+    </select>
     <select id="purchaseList" resultType="com.sckw.payment.model.dto.LedgerPurchaseDto">
         select
         <include refid="purchase_col"/>
@@ -277,6 +316,38 @@
             </if>
         </where>
     </select>
+    <select id="countOrder2" resultType="java.util.Map">
+        SELECT count(1)                                    "0",
+               count(IF(kll_distinct.status = 1, 1, NULL)) "1",
+               count(IF(kll_distinct.status = 2, 1, NULL)) "2",
+               count(IF(kll_distinct.status = 3, 1, NULL)) "3",
+               count(IF(kll_distinct.status = 4, 1, NULL)) "4",
+               count(IF(kll_distinct.status = 5, 1, NULL)) "5",
+               count(IF(kll_distinct.status = 6, 1, NULL)) "6"
+        FROM (
+        SELECT distinct klt.id, klt.status
+        from kwp_ledger_trade klt
+                 inner join kwp_ledger_trade_unit kltu
+                            on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <where>
+            klt.del_flag = 0
+            <if test="tradeReq.trading != null">
+                and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
+                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
+                    and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
+                and (
+                            klt.t_ledger_no like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kltu.firm_name like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kltu.contacts like concat('%', #{tradeReq.keywords,jdbcType=VARCHAR}, '%')
+                    )
+            </if>
+        </where>
+        ) kll_distinct
+    </select>
 
     <select id="selectSellIds" resultType="com.sckw.payment.model.dto.LedgerSellDto">
         select klt.id,

+ 25 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

@@ -286,4 +286,29 @@
             </foreach>
         </where>
     </select>
+
+    <select id="queryRecord" resultType="com.sckw.payment.model.KwpSettlementRecord">
+        SELECT kllu.top_ent_id                                                      entId,
+               sum(IF(kllu.unit_type = 2, ksl.total_price, 0.0))                    totalReceiveMoney,
+               sum(IF(kllu.unit_type = 1, ksl.total_price, 0.0))                    totalPayMoney,
+               sum(IF(kllu.unit_type = 2, ksl.actual_price, 0.0))                   receivedMoney,
+               sum(IF(kllu.unit_type = 1, ksl.actual_price, 0.0))                   paidMoney,
+               sum(IF(kllu.unit_type = 2, ksl.total_price - ksl.actual_price, 0.0)) exactMoney,
+               sum(IF(kllu.unit_type = 1, ksl.total_price - ksl.actual_price, 0.0)) unpaidMoney,
+               sum(
+                       IF
+                           (ksl.receipt_time &lt; now() &amp;&amp; kllu.unit_type = 2,
+                            ksl.total_price - ksl.actual_price, 0.0)
+                   )                                                                overdueExactMoney,
+               sum(
+                       IF
+                           (ksl.receipt_time &lt; now() &amp;&amp; kllu.unit_type = 2,
+                            ksl.total_price - ksl.actual_price, 0.0)
+                   )                                                                overduePaidMoney
+        FROM kwp_settlement_logistics ksl
+                 LEFT JOIN kwp_ledger_logistics_unit kllu ON ksl.l_ledger_id = kllu.l_ledger_id
+            AND kllu.del_flag = 0
+        WHERE ksl.del_flag = 0
+        GROUP BY kllu.top_ent_id
+    </select>
 </mapper>

+ 52 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementRecordMapper.xml

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sckw.payment.dao.KwpSettlementRecordMapper">
+  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementRecord">
+    <!--@mbg.generated-->
+    <!--@Table kwp_settlement_record-->
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="ent_id" jdbcType="BIGINT" property="entId" />
+    <result column="total_receive_money" jdbcType="DECIMAL" property="totalReceiveMoney" />
+    <result column="exact_money" jdbcType="DECIMAL" property="exactMoney" />
+    <result column="received_money" jdbcType="DECIMAL" property="receivedMoney" />
+    <result column="overdue_exact_money" jdbcType="DECIMAL" property="overdueExactMoney" />
+    <result column="total_pay_money" jdbcType="DECIMAL" property="totalPayMoney" />
+    <result column="unpaid_money" jdbcType="DECIMAL" property="unpaidMoney" />
+    <result column="paid_money" jdbcType="DECIMAL" property="paidMoney" />
+    <result column="overdue_paid_money" jdbcType="DECIMAL" property="overduePaidMoney" />
+    <result column="create_time" jdbcType="DATE" property="createTime" />
+    <result column="order_type" jdbcType="INTEGER" property="orderType" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, ent_id, total_receive_money, exact_money, received_money, overdue_exact_money, 
+    total_pay_money, unpaid_money, paid_money, overdue_paid_money, create_time, order_type
+  </sql>
+
+  <insert id="insertBatch">
+      insert into kwp_settlement_record
+      <trim prefix="(" suffix=")" suffixOverrides=",">
+          id, ent_id, total_receive_money, exact_money, received_money, overdue_exact_money,
+          total_pay_money, unpaid_money, paid_money, overdue_paid_money, create_time, order_type
+      </trim>
+      values
+      <foreach collection="list" item="item" separator=",">
+          <trim prefix="(" suffix=")" suffixOverrides=",">
+              #{item.id,jdbcType=BIGINT},
+              #{item.entId,jdbcType=BIGINT},
+              #{item.totalReceiveMoney,jdbcType=DECIMAL},
+              #{item.exactMoney,jdbcType=DECIMAL},
+              #{item.receivedMoney,jdbcType=DECIMAL},
+              #{item.overdueExactMoney,jdbcType=DECIMAL},
+              #{item.totalPayMoney,jdbcType=DECIMAL},
+              #{item.unpaidMoney,jdbcType=DECIMAL},
+              #{item.paidMoney,jdbcType=DECIMAL},
+              #{item.overduePaidMoney,jdbcType=DECIMAL},
+              #{item.createTime,jdbcType=TIMESTAMP},
+              #{item.orderType,jdbcType=INTEGER}
+          </trim>
+      </foreach>
+  </insert>
+    <select id="countByDay">
+    </select>
+</mapper>

+ 25 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -349,4 +349,29 @@
             </foreach>
         </where>
     </select>
+
+    <select id="queryRecord" resultType="com.sckw.payment.model.KwpSettlementRecord">
+        SELECT kltu.top_ent_id                                                      entId,
+               sum(IF(kltu.unit_type = 2, kst.total_price, 0.0))                    totalReceiveMoney,
+               sum(IF(kltu.unit_type = 1, kst.total_price, 0.0))                    totalPayMoney,
+               sum(IF(kltu.unit_type = 2, kst.actual_price, 0.0))                   receivedMoney,
+               sum(IF(kltu.unit_type = 1, kst.actual_price, 0.0))                   paidMoney,
+               sum(IF(kltu.unit_type = 2, kst.total_price - kst.actual_price, 0.0)) exactMoney,
+               sum(IF(kltu.unit_type = 1, kst.total_price - kst.actual_price, 0.0)) unpaidMoney,
+               sum(
+                       IF
+                           (kst.receipt_time &lt; now() &amp;&amp; kltu.unit_type = 2,
+                            kst.total_price - kst.actual_price, 0.0)
+                   )                                                                overdueExactMoney,
+               sum(
+                       IF
+                           (kst.receipt_time &lt; now() &amp;&amp; kltu.unit_type = 2,
+                            kst.total_price - kst.actual_price, 0.0)
+                   )                                                                overduePaidMoney
+        FROM `kwp_settlement_trade` kst
+                 LEFT JOIN kwp_ledger_trade_unit kltu ON kst.t_ledger_id = kltu.t_ledger_id
+            AND kltu.del_flag = 0
+        WHERE kst.del_flag = 0
+        GROUP BY kltu.top_ent_id
+    </select>
 </mapper>