Browse Source

1: 代码提交

171250443 1 year ago
parent
commit
a0fae6a703

+ 2 - 2
src/main/java/com/cool/bang/api/DataMatch.java

@@ -177,8 +177,8 @@ public class DataMatch {
     /**
      * 托管账户对账
      */
-    @GetMapping("bankAccountChecing")
-    public void bankAccountChecing(){mySQLSecondService.bankAccountChecing();}
+    @GetMapping("bankAccountCheck")
+    public void bankAccountCheck(){mySQLSecondService.bankAccountCheck();}
 
 
     /**

+ 5 - 0
src/main/java/com/cool/bang/modules/mysql/mapper/MySqlMapper.java

@@ -139,4 +139,9 @@ public interface MySqlMapper {
     List<BankBill> selectByBankBill(@Param("bankCode") String bankCode,
                                     @Param("startDate") String startDate,
                                     @Param("endDate") String endDate);
+
+    /**
+     * 根据账户查询交易总余额
+     */
+    List<BankBill> selectAccountBill(String account);
 }

+ 40 - 38
src/main/java/com/cool/bang/modules/mysql/service/MySQLSecondService.java

@@ -259,57 +259,59 @@ public class MySQLSecondService {
     /**
      * 银行账户对账
      */
-    public void bankAccountChecing() {
+    public void bankAccountCheck() {
         List<Account> list = mySqlMapper.selectTgAccountInfo();
-        List<Account> wdzJc = oracleMapper.getWdzJc();
-        List<Account> wdzBf = oracleMapper.getWdzBf();
-        List<String> strs = new ArrayList<>();
-        strs.add("银行名称;银行编号;已计算余额;系统未对账的交存;系统未对账的拨付;其他金额;账户余额;差值");
-        //处理特殊的对账
-        //1、寿光农商银行  缺失的 定金626475.6 (银行流水号 = 041002202216625184199811) 手续费0.44(银行流水号= 041002202216655621675571) (总的楼栋户的合计 比 账户余额少 这两笔 需要加上这两笔 )
-        //2、中国建设银行股份有限公司寿光支行 bankCode:02   手续费 -200(银行流水号= 021002202216625378315471) (总的楼栋户的合计 比对完账的账户余额 多200 总的楼栋户合计需要加上这个-200)
-        //3、中国邮政储蓄银行股份有限公司寿光市支行 利息186893.99 (银行流水号=161002202316730870521161) (总的楼栋户的合计 比账户余额少这一笔  总的楼栋户合计需要加上这个 186893.99)
-        List<String> serialNumbers = new ArrayList<>();
-        serialNumbers.add("041002202216625184199811");
-        serialNumbers.add("041002202216655621675571");
-        serialNumbers.add("021002202216625378315471");
-        serialNumbers.add("161002202316730870521161");
-        List<Account> tsList = mySqlMapper.selectTsDzByserial(serialNumbers);
+        List<Account> payments = oracleMapper.getWdzJc();
+        List<Account> appropriations = oracleMapper.getWdzBf();
+
+        List<String> systemOut = new ArrayList<>();
+        systemOut.add("银行名称;银行编号;交存;支出;未对账交存;未对账支出;计算;账户余额;差值");
         for (Account account : list) {
 
-            //未对账的交存
-            BigDecimal jc = BigDecimal.ZERO;
-            if (wdzJc != null && !wdzJc.isEmpty()) {
-                Account jcAccount = wdzJc.stream().filter(t -> !StringUtils.isEmpty(t.getBankCode()) && t.getBankCode().equals(account.getBankCode())).findFirst().orElse(null);
-                jc = null != jcAccount ? jcAccount.getBalance() : BigDecimal.ZERO;
+            BigDecimal payment = BigDecimal.ZERO;
+            BigDecimal appropriation = BigDecimal.ZERO;
+
+            List<BankBill> bills = mySqlMapper.selectAccountBill(account.getAccount());
+
+            for (BankBill item : bills) {
+                if (item.getType().equals(1)) {
+                    payment = payment.add(item.getAmount());
+                }
+                if (item.getType().equals(2)) {
+                    appropriation = appropriation.add(item.getAmount());
+                }
             }
-            //未对账的拨付
-            BigDecimal bf = BigDecimal.ZERO;
-            if (wdzBf != null && !wdzBf.isEmpty()) {
-                Account bfAccount = wdzBf.stream().filter(t -> !StringUtils.isEmpty(t.getBankCode()) && t.getBankCode().equals(account.getBankCode())).findFirst().orElse(null);
-                bf = null != bfAccount ? bfAccount.getBalance() : BigDecimal.ZERO;
+
+            // 未对账的交存
+            BigDecimal notPayment = BigDecimal.ZERO;
+            for (Account item : payments) {
+                if (item.getBankCode().equals(account.getBankCode())) {
+                    notPayment = notPayment.add(item.getBalance());
+                }
             }
-            //当前托管户 的其他类型的 对账金额
-            BigDecimal otherTypeAmount = BigDecimal.ZERO;
-            Account otherTypeAccount = tsList.stream().filter(t -> !StringUtils.isEmpty(t.getBankCode()) && t.getBankCode().equals(account.getBankCode())).findFirst().orElse(null);
-            if (otherTypeAccount != null) {
-                otherTypeAmount = otherTypeAccount.getBalance();
-                otherTypeAmount = null != otherTypeAmount ? otherTypeAccount.getBalance() : BigDecimal.ZERO;
+
+            //未对账的拨付
+            BigDecimal notAppropriation = BigDecimal.ZERO;
+            for (Account item : appropriations) {
+                if (item.getBankCode().equals(account.getBankCode())) {
+                    notAppropriation = notAppropriation.add(item.getBalance());
+                }
             }
 
             StringBuilder str = new StringBuilder();
             str.append(account.getBankName())
                     .append(";" + account.getBankCode())
-                    .append(";" + account.getBalance())
-                    .append(";" + jc)
-                    .append(";" + bf)
-                    .append(";" + otherTypeAmount)
+                    .append(";" + payment)
+                    .append(";" + appropriation)
+                    .append(";" + notPayment)
+                    .append(";" + notAppropriation)
+                    .append(";" + payment.subtract(appropriation))
                     .append(";" + account.getAccountBalance())
-                    .append(";" + ((account.getBalance().subtract(jc)).add(bf).add(otherTypeAmount)).subtract(account.getAccountBalance()));
-            strs.add(str.toString());
+                    .append(";" + (payment.subtract(appropriation)).subtract(account.getAccountBalance()));
+            systemOut.add(str.toString());
         }
 
-        for (String str : strs) {
+        for (String str : systemOut) {
             System.out.println(str);
         }
     }

+ 2 - 1
src/main/java/com/cool/bang/modules/mysql/service/MySQLService.java

@@ -1350,7 +1350,7 @@ public class MySQLService {
 
     public void bankBill(String bankCode, String startDate, String endDate) {
         List<BankBill> bills = mySqlMapper.selectByBankBill(bankCode, startDate, endDate);
-        List<String> strs = new ArrayList<>();
+        List<String> strs = new ArrayList<>(1844);
         strs.add("编号;账号;收入;支出;时间;类型");
         for (BankBill item : bills) {
             StringBuilder str = new StringBuilder();
@@ -1363,5 +1363,6 @@ public class MySQLService {
             strs.add(str.toString());
         }
         strs.forEach(System.out::println);
+        System.out.println("总计:"+ strs.size());
     }
 }

+ 6 - 1
src/main/resources/mapper/mysql/MySQLMapper.xml

@@ -378,7 +378,7 @@
 
     <select id="selectTgAccountInfo" resultType="com.cool.bang.modules.mysql.domain.Account">
         SELECT
-            t.book_balance, t.income_balance, t2.bank_code AS bankCode , t.bank_name AS bankName,
+            t.account, t.book_balance, t.income_balance, t2.bank_code AS bankCode , t.bank_name AS bankName,
             t.account_balance AS accountBalance, t2.balance AS balance
         FROM
             fc_account t
@@ -429,4 +429,9 @@
     <select id="selectByBankBill" resultType="com.cool.bang.modules.mysql.domain.BankBill">
         select business_number as businessNumber, account, amount, transaction_time as transactionTime, type  from fc_trade where channel_code = #{bankCode} and transaction_time &gt;= #{startDate} and transaction_time &lt;= #{endDate} order by transaction_time
     </select>
+
+    <select id="selectAccountBill" resultType="com.cool.bang.modules.mysql.domain.BankBill">
+        select business_number as businessNumber, account, amount, transaction_time as transactionTime, type from fc_trade where account = #{account}
+    </select>
+
 </mapper>