对账单增加记录号
diff --git a/payapi-common/src/main/java/com/supwisdom/dlpay/api/agent/Constant.java b/payapi-common/src/main/java/com/supwisdom/dlpay/api/agent/Constant.java
index c135d58..7f572da 100644
--- a/payapi-common/src/main/java/com/supwisdom/dlpay/api/agent/Constant.java
+++ b/payapi-common/src/main/java/com/supwisdom/dlpay/api/agent/Constant.java
@@ -19,4 +19,5 @@
   public static final String COL_AGENT_DATE = "agentdate";
   public static final String COL_STATUS = "status";
   public static final String COL_FLAG = "flag";
+  public static final String COL_RECORDNO = "recordno"; //记录号
 }
diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/bean/YnrccChkfileBean.java b/payapi/src/main/java/com/supwisdom/dlpay/api/bean/YnrccChkfileBean.java
index bdfc228..125c4bb 100644
--- a/payapi/src/main/java/com/supwisdom/dlpay/api/bean/YnrccChkfileBean.java
+++ b/payapi/src/main/java/com/supwisdom/dlpay/api/bean/YnrccChkfileBean.java
@@ -3,13 +3,14 @@
 public class YnrccChkfileBean {
   private String refno; //本地流水号
   private String agentrefno; //银行流水号
-  private String agentdate; //yin
+  private String agentdate; //银行记账日期
   private Integer amount;
   private String payerid;
   private String payeeid;
   private String summary;
   private String status;
   private String flag;
+  private Integer recordno; //记录号
 
   public String getRefno() {
     return refno;
@@ -82,4 +83,12 @@
   public void setFlag(String flag) {
     this.flag = flag;
   }
+
+  public Integer getRecordno() {
+    return recordno;
+  }
+
+  public void setRecordno(Integer recordno) {
+    this.recordno = recordno;
+  }
 }
diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/TransactionChkdtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/TransactionChkdtlDao.java
index 88a6f56..1896786 100644
--- a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/TransactionChkdtlDao.java
+++ b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/TransactionChkdtlDao.java
@@ -11,8 +11,8 @@
 public interface TransactionChkdtlDao extends JpaRepository<TTransactionChkdtl, String> {
 
   @Modifying
-  @Query("delete from TTransactionChkdtl t where t.accdate=?1 and t.sourcetype=?2 ")
-  void deleteByAccdateAndSorucetype(String accdate, String sourcetype);
+  @Query("delete from TTransactionChkdtl t where t.chkfileId=?1 ")
+  void deleteByChkfileid(String chkfileId);
 
   @Query("select count(t.id) as totalcnt,sum(t.amount) as totalamt from TTransactionChkdtl t where t.accdate=?1 and t.sourcetype=?2 ")
   CountAmountBean getTransactionSumInfo(String accdate, String sourcetype);
diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkdtl.java b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkdtl.java
index bc8d7ea..422d766 100644
--- a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkdtl.java
+++ b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkdtl.java
@@ -7,7 +7,7 @@
 
 @Entity
 @Table(name = "TB_TRANSACTION_CHKDTL",
-    indexes = {@Index(name = "UK_TRANSACTION_CHKDTL", unique = true, columnList = "ACCDATE,SOURCETYPE,THIRD_REFNO,LOCAL_REFNO")})
+    indexes = {@Index(name = "UK_TRANSACTION_CHKDTL", unique = true, columnList = "ACCDATE,SOURCETYPE,OTHER_REFNO,LOCAL_REFNO")})
 public class TTransactionChkdtl {
   @Id
   @GenericGenerator(name = "idGenerator", strategy = "uuid")
@@ -15,29 +15,35 @@
   @Column(name = "ID", nullable = false, length = 32)
   private String id;
 
+  @Column(name = "CHKFILE_ID", nullable = false, length = 32)
+  private String chkfileId;
+
   @Column(name = "ACCDATE", nullable = false, length = 8)
   private String accdate;
 
   @Column(name = "SOURCETYPE", nullable = false, length = 20)
   private String sourcetype;
 
+  @Column(name = "RECORDNO", precision = 9)
+  private Integer recordno;
+
   @Column(name = "AMOUNT", nullable = false, precision = 9, scale = 2)
   private Double amount;
 
-  @Column(name = "THIRD_REFNO", nullable = false, length = 32)
-  private String thirdRefno; //第三方流水号
+  @Column(name = "OTHER_REFNO", nullable = false, length = 32)
+  private String otherRefno; //第三方流水号
 
   @Column(name = "LOCAL_REFNO", nullable = false, length = 32)
   private String localRefno; //本地流水号
 
-  @Column(name = "THIRD_ACCDATE", nullable = false, length = 8)
-  private String thirdAccdate; //第三方记账日期
+  @Column(name = "OTHER_ACCDATE", nullable = false, length = 8)
+  private String otherAccdate; //第三方记账日期
 
   @Column(name = "TRANSTYPE", length = 20)
   private String transtype; // pay-支付|refund-退款|cancel-撤销
 
-  @Column(name = "THIRD_STATUS", length = 20)
-  private String thirdStatus; //第三方流水状态
+  @Column(name = "OTHER_STATUS", length = 20)
+  private String otherStatus; //第三方流水状态
 
   @Column(name = "REMARK", length = 200)
   private String remark;
@@ -65,6 +71,14 @@
     this.id = id;
   }
 
+  public String getChkfileId() {
+    return chkfileId;
+  }
+
+  public void setChkfileId(String chkfileId) {
+    this.chkfileId = chkfileId;
+  }
+
   public String getAccdate() {
     return accdate;
   }
@@ -81,6 +95,14 @@
     this.sourcetype = sourcetype;
   }
 
+  public Integer getRecordno() {
+    return recordno;
+  }
+
+  public void setRecordno(Integer recordno) {
+    this.recordno = recordno;
+  }
+
   public Double getAmount() {
     return amount;
   }
@@ -89,12 +111,12 @@
     this.amount = amount;
   }
 
-  public String getThirdRefno() {
-    return thirdRefno;
+  public String getOtherRefno() {
+    return otherRefno;
   }
 
-  public void setThirdRefno(String thirdRefno) {
-    this.thirdRefno = thirdRefno;
+  public void setOtherRefno(String otherRefno) {
+    this.otherRefno = otherRefno;
   }
 
   public String getLocalRefno() {
@@ -105,12 +127,12 @@
     this.localRefno = localRefno;
   }
 
-  public String getThirdAccdate() {
-    return thirdAccdate;
+  public String getOtherAccdate() {
+    return otherAccdate;
   }
 
-  public void setThirdAccdate(String thirdAccdate) {
-    this.thirdAccdate = thirdAccdate;
+  public void setOtherAccdate(String otherAccdate) {
+    this.otherAccdate = otherAccdate;
   }
 
   public String getTranstype() {
@@ -121,12 +143,12 @@
     this.transtype = transtype;
   }
 
-  public String getThirdStatus() {
-    return thirdStatus;
+  public String getOtherStatus() {
+    return otherStatus;
   }
 
-  public void setThirdStatus(String thirdStatus) {
-    this.thirdStatus = thirdStatus;
+  public void setOtherStatus(String otherStatus) {
+    this.otherStatus = otherStatus;
   }
 
   public String getRemark() {
diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkfile.java b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkfile.java
index 6517f21..f6f3df6 100644
--- a/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkfile.java
+++ b/payapi/src/main/java/com/supwisdom/dlpay/api/domain/TTransactionChkfile.java
@@ -30,11 +30,11 @@
   @Column(name = "REMARK", length = 600)
   private String remark;
 
-  @Column(name = "THIRDCNT", nullable = false, precision = 9)
-  private Integer thirdcnt;
+  @Column(name = "OTHERCNT", nullable = false, precision = 9)
+  private Integer othercnt;
 
-  @Column(name = "THIRDAMT", nullable = false, precision = 15, scale = 2)
-  private Double thirdamt;
+  @Column(name = "OTHERAMT", nullable = false, precision = 15, scale = 2)
+  private Double otheramt;
 
   @Column(name = "LOCALCNT", nullable = false, precision = 9)
   private Integer localcnt;
@@ -97,20 +97,20 @@
     this.remark = remark;
   }
 
-  public Integer getThirdcnt() {
-    return thirdcnt;
+  public Integer getOthercnt() {
+    return othercnt;
   }
 
-  public void setThirdcnt(Integer thirdcnt) {
-    this.thirdcnt = thirdcnt;
+  public void setOthercnt(Integer othercnt) {
+    this.othercnt = othercnt;
   }
 
-  public Double getThirdamt() {
-    return thirdamt;
+  public Double getOtheramt() {
+    return otheramt;
   }
 
-  public void setThirdamt(Double thirdamt) {
-    this.thirdamt = thirdamt;
+  public void setOtheramt(Double otheramt) {
+    this.otheramt = otheramt;
   }
 
   public Integer getLocalcnt() {
diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/scheduler_ynrccchk_task.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/scheduler_ynrccchk_task.kt
index e2fbcda..067f1ef 100644
--- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/scheduler_ynrccchk_task.kt
+++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/scheduler_ynrccchk_task.kt
@@ -70,7 +70,7 @@
                     val agentConfig = sourceTypeService.getChargePaytypeConfig(TradeDict.PAYTYPE_CITIZEN_CARD, true)
                     val agentUrl = agentConfig[YnrccUtil.YNRCC_ANGENT_URL] + "/download?filename=" + resp.filename
                     //根据filename 取文件数据
-                    downloadYnrccBills(billDate, agentUrl, chkfile)
+                    downloadYnrccBills(chkfile, agentUrl)
 
                 } else if (YnrccUtil.NO_RECORDS_TODAY == resp.code) {
                     //当日无交易明细,也创建空记录
@@ -91,7 +91,7 @@
         }
     }
 
-    private fun downloadYnrccBills(accdate: String, agentUrl: String, chkfile: TTransactionChkfile) {
+    private fun downloadYnrccBills(chkfile: TTransactionChkfile, agentUrl: String) {
         val client = Client.create()
         client.setConnectTimeout(30000)
         val respClient = client.resource(agentUrl).type(MediaType.APPLICATION_OCTET_STREAM_TYPE).get(ClientResponse::class.java)
@@ -101,7 +101,6 @@
                 val header = reader.readLine()
                 val fields = header.split(",").mapNotNull { if (it.isNotEmpty()) it else null }
                 val batchSize = 10000 //每次保存的数目
-                var totalcnt = 0
                 var failcnt = 0
 
                 val datalist = ArrayList<YnrccChkfileBean>()
@@ -112,26 +111,22 @@
                     val bean = YnrccChkfileBean()
                     StringUtil.transforToBean(fields, columns, bean)
                     datalist.add(bean)
-                    totalcnt++
                     if (datalist.size >= batchSize) {
-                        val fcnt = doBatchSaveYnrccCheckDetails(accdate, datalist) //保存
+                        val fcnt = doBatchSaveYnrccCheckDetails(chkfile, datalist) //保存
                         failcnt += fcnt
                         datalist.clear()
-                        if (failcnt > 0) break
                     }
-
                 }
                 //保存最后的不足batchSize的记录
                 if (datalist.size > 0) {
-                    val fcnt = doBatchSaveYnrccCheckDetails(accdate, datalist) //保存
+                    val fcnt = doBatchSaveYnrccCheckDetails(chkfile, datalist) //保存
                     failcnt += fcnt
                 }
 
                 if (failcnt > 0) {
                     //该天对账单保存错误
-                    transactionReconciliationService.deleteTransactionChkDtlByAccdateAndSourcetype(accdate, TradeDict.PAYTYPE_CITIZEN_CARD) //删除已存明细
                     chkfile.status = ConstantUtil.CHKFILE_STATUS_ERROR
-                    chkfile.remark = "对账单数据入库失败,请下载的检查数据"
+                    chkfile.remark = "对账单数据存在保存失败记录,请手动核对对账单数据"
                     transactionReconciliationService.saveOrUpdateTransactionChkfile(chkfile)
                     return
                 }
@@ -141,16 +136,16 @@
 
             }
         } else {
-            logger.error("请求前置download[$accdate]对账单返回失败:httpStatus=[${respClient.status}]。获取对账文件数据失败")
+            logger.error("请求前置download[${chkfile.accdate}]对账单返回失败:httpStatus=[${respClient.status}]。获取对账文件数据失败")
             chkfile.status = ConstantUtil.CHKFILE_STATUS_ERROR
             chkfile.remark = "请求前置获取对账单数据失败,download返回:httpStatus=${respClient.status}"
             transactionReconciliationService.saveOrUpdateTransactionChkfile(chkfile)
         }
     }
 
-    private fun doBatchSaveYnrccCheckDetails(accdate: String, list: ArrayList<YnrccChkfileBean>): Int {
+    private fun doBatchSaveYnrccCheckDetails(chkfile: TTransactionChkfile, list: ArrayList<YnrccChkfileBean>): Int {
         try {
-            transactionReconciliationService.doBatchSaveYnrccTransactionChkDtl(TradeDict.PAYTYPE_CITIZEN_CARD, accdate, list)
+            transactionReconciliationService.doBatchSaveYnrccTransactionChkDtl(chkfile, list)
             return 0  //批量保存成功,无失败
         } catch (e1: Exception) {
         }
@@ -159,7 +154,7 @@
         var failcnt = 0
         for (bean in list) {
             try {
-                transactionReconciliationService.saveYnrccTransactionChkDtl(TradeDict.PAYTYPE_CITIZEN_CARD, accdate, bean)
+                transactionReconciliationService.saveYnrccTransactionChkDtl(chkfile, bean)
             } catch (e2: Exception) {
                 failcnt++
                 e2.printStackTrace()
diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_reconciliation_service_impl.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_reconciliation_service_impl.kt
index d43e051..d900687 100644
--- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_reconciliation_service_impl.kt
+++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_reconciliation_service_impl.kt
@@ -44,8 +44,8 @@
                     this.status = ConstantUtil.CHKFILE_STATUS_INIT
                     this.result = ConstantUtil.CHKFILE_RESULT_NONE
                     this.remark = null
-                    this.thirdcnt = 0
-                    this.thirdamt = 0.00
+                    this.othercnt = 0
+                    this.otheramt = 0.00
                     this.localcnt = 0
                     this.localamt = 0.00
                     this.lastsaved = systemUtilService.sysdatetime.sysdate
@@ -59,16 +59,18 @@
         transactionChkfileDao.save(chkfile)
     }
 
-    override fun saveYnrccTransactionChkDtl(sourcetype: String, accdate: String, bean: YnrccChkfileBean): TTransactionChkdtl {
+    override fun saveYnrccTransactionChkDtl(chkfile: TTransactionChkfile, bean: YnrccChkfileBean): TTransactionChkdtl {
         return transactionChkdtlDao.save(TTransactionChkdtl().apply {
-            this.accdate = accdate
-            this.sourcetype = sourcetype
+            this.chkfileId = chkfile.id
+            this.accdate = chkfile.accdate
+            this.sourcetype = chkfile.sourcetype
+            this.recordno = bean.recordno
             this.amount = bean.amount / 100.0
-            this.thirdRefno = bean.agentrefno
+            this.otherRefno = bean.agentrefno
             this.localRefno = bean.refno
-            this.thirdAccdate = bean.agentdate
+            this.otherAccdate = bean.agentdate
             this.transtype = bean.flag
-            this.thirdStatus = bean.status
+            this.otherStatus = bean.status
             this.remark = null
             this.extdata = bean.summary
             this.chkresult = ConstantUtil.CHKDTL_CHKRESULT_UNCHECK
@@ -78,23 +80,19 @@
         })
     }
 
-    override fun doBatchSaveYnrccTransactionChkDtl(sourcetype: String, accdate: String, list: ArrayList<YnrccChkfileBean>): Boolean {
+    override fun doBatchSaveYnrccTransactionChkDtl(chkfile: TTransactionChkfile, list: ArrayList<YnrccChkfileBean>): Boolean {
         for (bean in list) {
-            saveYnrccTransactionChkDtl(sourcetype, accdate, bean)
+            saveYnrccTransactionChkDtl(chkfile, bean)
         }
         return true
     }
 
-    override fun deleteTransactionChkDtlByAccdateAndSourcetype(accdate: String, sourcetype: String) {
-        transactionChkdtlDao.deleteByAccdateAndSorucetype(accdate, sourcetype)
-    }
-
     override fun doSuccessTransactionChkfile(chkfile: TTransactionChkfile, remark: String) {
         val suminfo = transactionChkdtlDao.getTransactionSumInfo(chkfile.accdate, chkfile.sourcetype)
         chkfile.status = ConstantUtil.CHKFILE_STATUS_UNCHECK
         chkfile.remark = remark
-        chkfile.thirdcnt = suminfo.totalcnt ?: 0
-        chkfile.thirdamt = suminfo.totalamt ?: 0.0
+        chkfile.othercnt = suminfo.totalcnt ?: 0
+        chkfile.otheramt = suminfo.totalamt ?: 0.0
         transactionChkfileDao.save(chkfile)
         businessparaDao.updateBusinessparaValue(YnrccUtil.YNRCC_BILLS_DOWNLOAD_LASTDATE, chkfile.accdate) //更新下载对账单日期
     }
diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_reconciliation_service.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_reconciliation_service.kt
index 2326df3..173d15a 100644
--- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_reconciliation_service.kt
+++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_reconciliation_service.kt
@@ -16,16 +16,12 @@
     fun saveOrUpdateTransactionChkfile(chkfile: TTransactionChkfile)
 
     @Transactional(rollbackFor = [Exception::class])
-    fun saveYnrccTransactionChkDtl(sourcetype: String, accdate: String, bean: YnrccChkfileBean): TTransactionChkdtl
+    fun saveYnrccTransactionChkDtl(chkfile: TTransactionChkfile, bean: YnrccChkfileBean): TTransactionChkdtl
 
     @Transactional(rollbackFor = [Exception::class])
-    fun doBatchSaveYnrccTransactionChkDtl(sourcetype: String, accdate: String, list: ArrayList<YnrccChkfileBean>): Boolean
-
-    @Transactional(rollbackFor = [Exception::class])
-    fun deleteTransactionChkDtlByAccdateAndSourcetype(accdate: String, sourcetype: String)
+    fun doBatchSaveYnrccTransactionChkDtl(chkfile: TTransactionChkfile, list: ArrayList<YnrccChkfileBean>): Boolean
 
     @Transactional(rollbackFor = [Exception::class])
     fun doSuccessTransactionChkfile(chkfile: TTransactionChkfile, reamrk:String)
 
-
 }
\ No newline at end of file
diff --git a/ynrcc-agent/src/main/java/com/supwisdom/agent/api/controller/YnrccApiController.java b/ynrcc-agent/src/main/java/com/supwisdom/agent/api/controller/YnrccApiController.java
index 30fbcca..5053954 100644
--- a/ynrcc-agent/src/main/java/com/supwisdom/agent/api/controller/YnrccApiController.java
+++ b/ynrcc-agent/src/main/java/com/supwisdom/agent/api/controller/YnrccApiController.java
@@ -457,7 +457,7 @@
       writeLine(output, Constant.COL_REFNO, Constant.COL_AGENT_REFNO,
           Constant.COL_AGENT_DATE, Constant.COL_FLAG, Constant.COL_PAYERID,
           Constant.COL_PAYEEID, Constant.COL_STATUS,
-          Constant.COL_AMOUNT, Constant.COL_SUMMARY);
+          Constant.COL_AMOUNT, Constant.COL_SUMMARY, Constant.COL_RECORDNO);
       while (true) {
         String line = reader.readLine();
         if (line == null) {
@@ -485,7 +485,7 @@
         fileHeader.setTotalAmount(fileHeader.getTotalAmount() - record.getAmount());
         writeLine(output, record.getRefno(), record.getAgentrefno(), record.getAgentdate(),
             flag, record.getPayerid(), record.getPayeeid(), Constant.STATUS_SUCCESS,
-            amount, record.getSummary());
+            amount, record.getSummary(), lineno - 1);
       }
       if (!fileHeader.isZero()) {
         throw new IllegalArgumentException("对账文件总金额与笔数与明细不符");