结算调整
diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/DebitCreditDtlDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/DebitCreditDtlDao.java
index 80e22f2..0b5e733 100644
--- a/src/main/java/com/supwisdom/dlpay/api/dao/DebitCreditDtlDao.java
+++ b/src/main/java/com/supwisdom/dlpay/api/dao/DebitCreditDtlDao.java
@@ -13,10 +13,11 @@
 @Repository
 public interface DebitCreditDtlDao extends JpaRepository<TDebitCreditDtl, TDebitCreditDtlPK> {
 
-  @Query(value = "select a.drsubjno,a.crsubjno,a.summary,count(distinct a.refno) as transcnt,sum(a.amount) as transamt " +
-      "from TB_USERDTL_DEBITCREDIT a left join TB_USERDTL b on a.refno=b.refno " +
+  @Query(value = "select a.drsubjno,case when a.drsubjno='220201' then '220201' else a.draccno end as draccno, a.crsubjno,case when a.crsubjno='220201' then '220201' else a.craccno end as craccno," +
+      "a.summary,count(distinct a.refno) as transcnt,sum(a.amount) as transamt " +
+      "from TB_USERDTL_DEBITCREDIT a left join TB_TRANSACTIONMAIN b on a.refno=b.refno " +
       "where b.status='success' and b.accdate=:settledate " +
-      "group by a.drsubjno,a.crsubjno,a.summary ", nativeQuery = true)
+      "group by a.drsubjno,case when a.drsubjno='220201' then '220201' else a.draccno end,a.crsubjno,case when a.crsubjno='220201' then '220201' else a.craccno end,a.summary ", nativeQuery = true)
   List<VoucherTemp> getVoucherData(@Param("settledate") String settledate);
 
   List<TDebitCreditDtl> findByRefno(String refno);
diff --git a/src/main/java/com/supwisdom/dlpay/framework/core/DayendSettleTask.java b/src/main/java/com/supwisdom/dlpay/framework/core/DayendSettleTask.java
index 46ca41f..785ef41 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/core/DayendSettleTask.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/core/DayendSettleTask.java
@@ -8,7 +8,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
 
+@Component
 public class DayendSettleTask {
   @Autowired
   private SystemUtilService systemUtilService;
@@ -19,7 +22,8 @@
 
   private static final Logger logger = LoggerFactory.getLogger(DayendSettleTask.class);
 
-
+//  @Scheduled(cron="0 3/30 2-3 * * ? ")
+  @Scheduled(cron="0 0/2 * * * ? ")
   public void doSettleTask() {
     if (logger.isDebugEnabled()) logger.debug("进入日结算任务!");
 
@@ -37,7 +41,7 @@
 
       settleLog = dayendSettleService.doCreateSettleLog(); //记录日志
 
-      //step1: 账户校验
+      //step1: 账户校验(fixme: 清算任务?)
       long t1 = System.currentTimeMillis();
       if (!checkAccounts()) {
         logger.error("账户余额校验出错,退出结算!");
@@ -46,7 +50,7 @@
       long t2 = System.currentTimeMillis();
       logger.info("===== step1: 日终结算【账户校验】耗时 " + (t2 - t1) + " ms");
 
-      //step2: 对账判断
+      //step2: 对账判断(fixme: 清算任务?)
       long t3 = System.currentTimeMillis();
       if (!checkChkfiles()) {
         logger.error("对账未完成,退出结算!");
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java
index f6d4c02..ec8fadc 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java
@@ -3,6 +3,7 @@
 import com.supwisdom.dlpay.framework.domain.TSettlectl;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Lock;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
@@ -18,6 +19,7 @@
   @Query(value = "from TSettlectl where booksetno=:booksetno ")
   TSettlectl findByBooksetnoWithLock(@Param("booksetno") Integer booksetno);
 
+  @Modifying(clearAutomatically = true)
   @Query(value = "update TB_SETTLECTL set PERIODYEAR=:peridyear,PERIODMONTH=:peridmonth where BOOKSETNO=1 ", nativeQuery = true)
   void updateSettlePeriod(@Param("peridyear") int peridyear, @Param("peridmonth") int peridmonth);
 
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java
index fa2ab12..303a3b0 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java
@@ -1,6 +1,5 @@
 package com.supwisdom.dlpay.framework.dao;
 
-import com.supwisdom.dlpay.framework.data.ExistBean;
 import com.supwisdom.dlpay.framework.domain.TShopacc;
 import org.springframework.data.jpa.repository.*;
 import org.springframework.data.repository.query.Param;
@@ -10,17 +9,14 @@
 import javax.persistence.LockModeType;
 
 import javax.persistence.QueryHint;
-import java.math.BigDecimal;
 import java.util.List;
 
 @Repository
 public interface ShopaccDao extends JpaRepository<TShopacc, String> {
 
-  @Query(value = "select t.SHOPACCNO as accno from TB_SHOPACC t left join TB_SHOPACCBAL a on t.SHOPACCNO=a.SHOPACCNO where a.SHOPACCNO is null ", nativeQuery = true)
-  List<String> getNewShopacc();
+  @Query(value = "select t.SHOPACCNO from TB_SHOPACC t left join TB_SHOPACCDAY a on t.SHOPACCNO=a.SHOPACCNO and a.accdate=:lastsettday where a.SHOPACCNO is null ", nativeQuery = true)
+  List<String> getNewShopacc(@Param("lastsettday") String lastsettday);
 
-  @Query(value = "select count(t.shopaccno) as existed from TB_SHOPACC t left join TB_SHOPACCBAL a on t.SHOPACCNO=a.SHOPACCNO where a.SHOPACCNO is null and t.STATUS='normal' ", nativeQuery = true)
-  ExistBean checkSettleShopacc();
 
   @Query(value = "select shopname from TShopacc where shopaccno=:shopaccno ")
   String getShopname(@Param("shopaccno") String shopaccno);
@@ -42,7 +38,7 @@
   TShopacc getByShopaccno(String shopaccno);
 
   @Transactional
-  @Modifying
+  @Modifying(clearAutomatically = true)
   @Query("update TShopacc set shopname=?1 where shopaccno=?2")
   void updateShopnameByShopaccno(String shopname, String shopaccno);
 
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccbalDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccbalDao.java
deleted file mode 100644
index 1a769bb..0000000
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccbalDao.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.supwisdom.dlpay.framework.dao;
-
-import com.supwisdom.dlpay.framework.domain.TShopaccbal;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Lock;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.query.Param;
-import org.springframework.stereotype.Repository;
-
-import javax.persistence.LockModeType;
-import java.util.List;
-
-@Repository
-public interface ShopaccbalDao extends JpaRepository<TShopaccbal, String> {
-
-  @Query(value = "select t.* from TB_SHOPACCBAL t left join (select shopaccno from TB_SHOPACCDAY where accdate=:lastsettday ) a on t.shopaccno=a.shopaccno where a.shopaccno is null ", nativeQuery = true)
-  List<TShopaccbal> getUnsettleShopacc(@Param("lastsettday") String lastsettday);
-
-  @Lock(LockModeType.PESSIMISTIC_WRITE)
-  @Query(value = "from TShopaccbal where shopaccno=:shopaccno ")
-  TShopaccbal getTShopaccbalByIdWithLock(@Param("shopaccno")String shopaccno);
-
-}
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccdayDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccdayDao.java
index b7acdb3..ddc0265 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccdayDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccdayDao.java
@@ -3,6 +3,7 @@
 import com.supwisdom.dlpay.framework.domain.TShopaccday;
 import com.supwisdom.dlpay.framework.domain.TShopaccdayPK;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
@@ -18,7 +19,8 @@
   @Query(value = "from TShopaccday t where t.accdate=:accdate and t.shopaccno=:shopaccno ")
   TShopaccday getTShopaccdayById(@Param("accdate") String accdate, @Param("shopaccno") String shopaccno);
 
-  @Query(value = "update TShopaccday set balance=beginbal-dramt+cramt,updtime=:updtime where accdate=:accdate ")
+  @Modifying(clearAutomatically = true)
+  @Query(value = "update TB_SHOPACCDAY set balance=beginbal-dramt+cramt,updtime=:updtime where accdate=:accdate ", nativeQuery = true)
   void updateShopaccdayBalance(@Param("accdate") String accdate,@Param("updtime")String updtime);
 
   @Query(value = "select sum(balance) as amount from TShopaccday where accdate=:accdate ")
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectDao.java
index 328a01a..2c0fae9 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectDao.java
@@ -12,7 +12,7 @@
 @Repository
 public interface SubjectDao extends JpaRepository<TSubject, String> {
 
-  @Query(value = "select t.SUBJNO as accno from TB_SUBJECT t left join TB_SUBJECTBAL a on t.SUBJNO=a.SUBJNO where t.ENDFLAG=1 and a.SUBJNO is null ", nativeQuery = true)
+  @Query(value = "select t.SUBJNO from TB_SUBJECT t left join TB_SUBJECTBAL a on t.SUBJNO=a.SUBJNO where t.ENDFLAG=1 and a.SUBJNO is null ", nativeQuery = true)
   List<String> getNewSubject();
 
   @Query(value = "select count(t.subjno) as existed from TB_SUBJECT t left join TB_SUBJECTBAL a on t.SUBJNO=a.SUBJNO where t.ENDFLAG=1 and a.SUBJNO is null ", nativeQuery = true)
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java
index cb618f9..e839c01 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java
@@ -5,17 +5,19 @@
 import com.supwisdom.dlpay.framework.domain.TVoucher;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Lock;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 
 import javax.persistence.LockModeType;
 import java.util.List;
 
-public interface VoucherDao extends JpaRepository<TVoucher, String> {
+public interface VoucherDao extends JpaRepository<TVoucher, Integer> {
 
-  @Query(value = "select count(t.voucherid) as existed from TB_VOUCHER t where t.POSTFLAG=0 and t.SOURCETYPE!='auto' ", nativeQuery = true)
+  @Query(value = "select count(t.voucherid) as existed from TB_VOUCHER t where t.POSTFLAG=0 ", nativeQuery = true)
   ExistBean checkExistUnpostVouhcer();
 
+  @Modifying
   @Query(value="delete from TB_VOUCHER where POSTFLAG=0 ",nativeQuery = true)
   void deleteUnpostVoucher();
 
@@ -34,5 +36,5 @@
 
   @Lock(LockModeType.PESSIMISTIC_WRITE)
   @Query(value = "from TVoucher where voucherid=:voucherid ")
-  TVoucher findByVoucheridWithLock(@Param("voucherid") String voucherid);
+  TVoucher findByVoucheridWithLock(@Param("voucherid") Integer voucherid);
 }
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherEntryDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherEntryDao.java
index ba4ba73..cfb8cfd 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherEntryDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherEntryDao.java
@@ -4,6 +4,7 @@
 import com.supwisdom.dlpay.framework.domain.TVoucherEntryPK;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Lock;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
@@ -12,6 +13,7 @@
 
 @Repository
 public interface VoucherEntryDao extends JpaRepository<TVoucherEntry,TVoucherEntryPK> {
+  @Modifying
   @Query(value = "delete from TB_VOUCHERENTRY where VOUCHERID in (select VOUCHERID from TB_VOUCHER where POSTFLAG=0)", nativeQuery = true)
   void deleteUnpostVoucherentry();
 
@@ -20,5 +22,5 @@
 
   @Lock(LockModeType.PESSIMISTIC_WRITE)
   @Query(value = "from TVoucherEntry t where t.voucherid=:voucherid ")
-  List<TVoucherEntry> getVoucherEntryByVoucherid(@Param("voucherid")String voucherid);
+  List<TVoucherEntry> getVoucherEntryByVoucherid(@Param("voucherid")Integer voucherid);
 }
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/VouchernoCtlDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/VouchernoCtlDao.java
index fe3744d..7f81bf9 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/VouchernoCtlDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/VouchernoCtlDao.java
@@ -3,6 +3,7 @@
 import com.supwisdom.dlpay.framework.domain.TVouchernoCtl;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Lock;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
@@ -11,6 +12,7 @@
 
 @Repository
 public interface VouchernoCtlDao extends JpaRepository<TVouchernoCtl, Integer> {
+  @Modifying(clearAutomatically = true)
   @Query(value = "update TB_VOUCHERNOCTL set PERIODMONTH=:peridmonth,VOUCHERNO=:voucherno where VOUCHERTYPE=1 ", nativeQuery = true)
   void updateVoucherno(@Param("peridmonth") int peridmonth, @Param("voucherno") int voucherno);
 
diff --git a/src/main/java/com/supwisdom/dlpay/framework/data/VoucherTemp.java b/src/main/java/com/supwisdom/dlpay/framework/data/VoucherTemp.java
index 8a38e41..ee4e4d4 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/data/VoucherTemp.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/data/VoucherTemp.java
@@ -3,11 +3,11 @@
 public interface VoucherTemp {
   String getDrsubjno();
 
-//  String getDraccno();
+  String getDraccno();
 
   String getCrsubjno();
 
-//  String getCraccno();
+  String getCraccno();
 
   String getSummary();
 
diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TShopaccbal.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TShopaccbal.java
deleted file mode 100644
index d64608e..0000000
--- a/src/main/java/com/supwisdom/dlpay/framework/domain/TShopaccbal.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package com.supwisdom.dlpay.framework.domain;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "TB_SHOPACCBAL")
-public class TShopaccbal {
-  @Id
-  @Column(name="SHOPACCNO", length = 10)
-  private String shopaccno;
-
-  @Column(name="ACCUMDRAMT", precision = 15, scale = 2)
-  private Double accumdramt;
-
-  @Column(name="ACCUMCRAMT", precision = 15, scale = 2)
-  private Double accumcramt;
-
-  @Column(name="BEGINBAL", precision = 15, scale = 2)
-  private Double beginbal;
-
-  @Column(name="DRAMT", precision = 15, scale = 2)
-  private Double dramt;
-
-  @Column(name="CRAMT", precision = 15, scale = 2)
-  private Double cramt;
-
-  @Column(name="BALANCE", precision = 15, scale = 2)
-  private Double balance;
-
-  @Column(name="UPDTIME", precision = 15, scale = 2)
-  private String updtime;
-
-  @Column(name="LASTSETTLEDAY", length = 8)
-  private String lastsettleday;
-
-  @Column(name="SETTLETOTALAMT", precision = 15, scale = 2)
-  private Double settletotalamt;
-
-  public TShopaccbal() {
-  }
-
-  public TShopaccbal(String shopaccno) {
-    this.shopaccno = shopaccno;
-    this.accumdramt = 0D;
-    this.accumcramt = 0D;
-    this.beginbal = 0D;
-    this.dramt = 0D;
-    this.cramt = 0D;
-    this.balance = 0D;
-  }
-
-  public TShopaccbal(String shopaccno, Double accumdramt, Double accumcramt, Double beginbal, Double dramt, Double cramt, Double balance, String updtime, String lastsettleday, Double settletotalamt) {
-    this.shopaccno = shopaccno;
-    this.accumdramt = accumdramt;
-    this.accumcramt = accumcramt;
-    this.beginbal = beginbal;
-    this.dramt = dramt;
-    this.cramt = cramt;
-    this.balance = balance;
-    this.updtime = updtime;
-    this.lastsettleday = lastsettleday;
-    this.settletotalamt = settletotalamt;
-  }
-
-  public String getShopaccno() {
-    return shopaccno;
-  }
-
-  public void setShopaccno(String shopaccno) {
-    this.shopaccno = shopaccno;
-  }
-
-  public Double getAccumdramt() {
-    return accumdramt;
-  }
-
-  public void setAccumdramt(Double accumdramt) {
-    this.accumdramt = accumdramt;
-  }
-
-  public Double getAccumcramt() {
-    return accumcramt;
-  }
-
-  public void setAccumcramt(Double accumcramt) {
-    this.accumcramt = accumcramt;
-  }
-
-  public Double getBeginbal() {
-    return beginbal;
-  }
-
-  public void setBeginbal(Double beginbal) {
-    this.beginbal = beginbal;
-  }
-
-  public Double getDramt() {
-    return dramt;
-  }
-
-  public void setDramt(Double dramt) {
-    this.dramt = dramt;
-  }
-
-  public Double getCramt() {
-    return cramt;
-  }
-
-  public void setCramt(Double cramt) {
-    this.cramt = cramt;
-  }
-
-  public Double getBalance() {
-    return balance;
-  }
-
-  public void setBalance(Double balance) {
-    this.balance = balance;
-  }
-
-  public String getUpdtime() {
-    return updtime;
-  }
-
-  public void setUpdtime(String updtime) {
-    this.updtime = updtime;
-  }
-
-  public String getLastsettleday() {
-    return lastsettleday;
-  }
-
-  public void setLastsettleday(String lastsettleday) {
-    this.lastsettleday = lastsettleday;
-  }
-
-  public Double getSettletotalamt() {
-    return settletotalamt;
-  }
-
-  public void setSettletotalamt(Double settletotalamt) {
-    this.settletotalamt = settletotalamt;
-  }
-}
diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java
index 7f42c1f..cd13743 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java
@@ -1,17 +1,15 @@
 package com.supwisdom.dlpay.framework.domain;
 
-import org.hibernate.annotations.GenericGenerator;
-
 import javax.persistence.*;
 
 @Entity
 @Table(name = "TB_VOUCHER")
 public class TVoucher {
   @Id
-  @GenericGenerator(name = "idGenerator", strategy = "uuid")
-  @GeneratedValue(generator = "idGenerator")
-  @Column(name="VOUCHERID", nullable = false, length = 32)
-  private String voucherid;
+  @SequenceGenerator(name = "voucherid", sequenceName = "SEQ_VOUCHERID", allocationSize = 1)
+  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "voucherid")
+  @Column(name="VOUCHERID", nullable = false, precision = 9)
+  private Integer voucherid;
 
   @Column(name="PERIODYEAR", precision = 8)
   private Integer periodYear;
@@ -120,11 +118,11 @@
     this.createdate = createdate;
   }
 
-  public String getVoucherid() {
+  public Integer getVoucherid() {
     return voucherid;
   }
 
-  public void setVoucherid(String voucherid) {
+  public void setVoucherid(Integer voucherid) {
     this.voucherid = voucherid;
   }
 
diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntry.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntry.java
index a0d08c7..4a8e005 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntry.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntry.java
@@ -7,8 +7,8 @@
 @IdClass(TVoucherEntryPK.class)
 public class TVoucherEntry {
   @Id
-  @Column(name = "VOUCHERID",nullable = false, length = 32)
-  private String voucherid;
+  @Column(name = "VOUCHERID",nullable = false, precision = 9)
+  private Integer voucherid;
 
   @Id
   @Column(name = "ENTRYID", precision = 2)
@@ -47,7 +47,7 @@
   public TVoucherEntry() {
   }
 
-  public TVoucherEntry(String voucherid, Integer entryid, String subjno, String accno, Double dramt, Double cramt, String summary, String oppsubjno, String oppaccno) {
+  public TVoucherEntry(Integer voucherid, Integer entryid, String subjno, String accno, Double dramt, Double cramt, String summary, String oppsubjno, String oppaccno) {
     this.voucherid = voucherid;
     this.entryid = entryid;
     this.subjno = subjno;
@@ -59,7 +59,7 @@
     this.oppaccno = oppaccno;
   }
 
-  public TVoucherEntry(String voucherid, Integer entryid, String subjno, String accno, Double dramt, Double cramt, Double balance, Integer balflag, String summary, String oppsubjno, String oppaccno, String oppname) {
+  public TVoucherEntry(Integer voucherid, Integer entryid, String subjno, String accno, Double dramt, Double cramt, Double balance, Integer balflag, String summary, String oppsubjno, String oppaccno, String oppname) {
     this.voucherid = voucherid;
     this.entryid = entryid;
     this.subjno = subjno;
@@ -74,11 +74,11 @@
     this.oppname = oppname;
   }
 
-  public String getVoucherid() {
+  public Integer getVoucherid() {
     return voucherid;
   }
 
-  public void setVoucherid(String voucherid) {
+  public void setVoucherid(Integer voucherid) {
     this.voucherid = voucherid;
   }
 
diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntryPK.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntryPK.java
index 751af0f..9fa5279 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntryPK.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntryPK.java
@@ -6,18 +6,18 @@
 
 public class TVoucherEntryPK implements Serializable {
   @Id
-  @Column(name = "VOUCHERID", nullable = false, length = 32)
-  private String voucherid;
+  @Column(name = "VOUCHERID", nullable = false, precision = 9)
+  private Integer voucherid;
 
   @Id
   @Column(name = "ENTRYID", precision = 2)
   private Integer entryid;
 
-  public String getVoucherid() {
+  public Integer getVoucherid() {
     return voucherid;
   }
 
-  public void setVoucherid(String voucherid) {
+  public void setVoucherid(Integer voucherid) {
     this.voucherid = voucherid;
   }
 
diff --git a/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java b/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java
index 59c85cf..2f4959b 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java
@@ -37,8 +37,6 @@
   @Autowired
   private ShopaccDao shopaccDao;
   @Autowired
-  private ShopaccbalDao shopaccbalDao;
-  @Autowired
   private SubjectDao subjectDao;
   @Autowired
   private SubjectbalDao subjectbalDao;
@@ -125,11 +123,11 @@
     TVoucherEntry entry1;
     TVoucherEntry entry2;
     if (voucherTemp.getTransamt() >= 0) {
-      entry1 = new TVoucherEntry(voucher.getVoucherid(), 1, voucherTemp.getDrsubjno(), null, Math.abs(voucherTemp.getTransamt()), 0D, voucherTemp.getSummary(), voucherTemp.getCrsubjno(), null);
-      entry2 = new TVoucherEntry(voucher.getVoucherid(), 2, voucherTemp.getCrsubjno(), null, 0D, Math.abs(voucherTemp.getTransamt()), voucherTemp.getSummary(), voucherTemp.getDrsubjno(), null);
+      entry1 = new TVoucherEntry(voucher.getVoucherid(), 1, voucherTemp.getDrsubjno(), voucherTemp.getDraccno(), Math.abs(voucherTemp.getTransamt()), 0D, voucherTemp.getSummary(), voucherTemp.getCrsubjno(), voucherTemp.getCraccno());
+      entry2 = new TVoucherEntry(voucher.getVoucherid(), 2, voucherTemp.getCrsubjno(), voucherTemp.getCraccno(), 0D, Math.abs(voucherTemp.getTransamt()), voucherTemp.getSummary(), voucherTemp.getDrsubjno(), voucherTemp.getDraccno());
     } else {
-      entry1 = new TVoucherEntry(voucher.getVoucherid(), 1, voucherTemp.getCrsubjno(), null, 0D, Math.abs(voucherTemp.getTransamt()), voucherTemp.getSummary(), voucherTemp.getDrsubjno(), null);
-      entry2 = new TVoucherEntry(voucher.getVoucherid(), 2, voucherTemp.getDrsubjno(), null, Math.abs(voucherTemp.getTransamt()), 0D, voucherTemp.getSummary(), voucherTemp.getCrsubjno(), null);
+      entry1 = new TVoucherEntry(voucher.getVoucherid(), 1, voucherTemp.getDrsubjno(), voucherTemp.getDraccno(), 0D, Math.abs(voucherTemp.getTransamt()), voucherTemp.getSummary(), voucherTemp.getCrsubjno(), voucherTemp.getCraccno());
+      entry2 = new TVoucherEntry(voucher.getVoucherid(), 2, voucherTemp.getCrsubjno(), voucherTemp.getCraccno(), Math.abs(voucherTemp.getTransamt()), 0D, voucherTemp.getSummary(), voucherTemp.getDrsubjno(), voucherTemp.getDraccno());
     }
     voucherEntryDao.save(entry1);
     voucherEntryDao.save(entry2);
@@ -163,18 +161,6 @@
       }
     }
 
-//    //新增商户插入商户余额表
-//    List<String> newShopaccList = shopaccDao.getNewShopacc();
-//    if (!StringUtil.isEmpty(newShopaccList)) {
-//      for (String accno : newShopaccList) {
-//        TShopaccbal shopaccbal = new TShopaccbal(accno);
-//        shopaccbalDao.save(shopaccbal);
-//      }
-//    }
-//    if (shopaccDao.checkSettleShopacc().getExisted() > 0) {
-//      throw new Exception("初始化数据错误:商户余额表数据没有包含所有有效的商户账户余额");
-//    }
-
     //新增科目插入科目余额表(末级科目)
     List<String> newEndsubjectList = subjectDao.getNewSubject();
     if (!StringUtil.isEmpty(newEndsubjectList)) {
@@ -223,37 +209,38 @@
       vouchernoCtlDao.save(vouchernoCtl);
     }
 
-//    Map<String, Double> v_merchbaldict = new HashMap<String, Double>(0);
-//    //根据商户昨天日结表生成当天日结表(交易前余额), 新增商户添加记录(交易前余额为商户余额)
-//    List<TShopaccday> lastShopaccdays = shopaccdayDao.getShopaccdayByAccdate(String.valueOf(lastsettday));
-//    if (!StringUtil.isEmpty(lastShopaccdays)) {
-//      for (TShopaccday lastday : lastShopaccdays) {
-//        TShopaccday today = new TShopaccday(String.valueOf(settledate), lastday.getShopaccno(), periodYear, periodMonth, lastday.getBalance(), 0D, 0D, 0D);
-//        shopaccdayDao.save(today);
-//        v_merchbaldict.put(lastday.getShopaccno(), lastday.getBalance());
-//      }
-//    }
-//    List<TShopaccbal> newShopbals = shopaccbalDao.getUnsettleShopacc(String.valueOf(lastsettday));
-//    if (!StringUtil.isEmpty(newShopbals)) {
-//      for (TShopaccbal newShopbal : newShopbals) {
-//        TShopaccday today = new TShopaccday(String.valueOf(settledate), newShopbal.getShopaccno(), periodYear, periodMonth, newShopbal.getBeginbal(), 0D, 0D, 0D);
-//        shopaccdayDao.save(today);
-//        v_merchbaldict.put(newShopbal.getShopaccno(), newShopbal.getBeginbal());
-//      }
-//    }
-//    List<MerchBean> merchBeanList = voucherDao.getShopVoucherByAccdate(settledate);
-//    if (!StringUtil.isEmpty(merchBeanList)) {
-//      for (MerchBean merch : merchBeanList) {
-//        TShopaccday merchday = shopaccdayDao.getTShopaccdayById(String.valueOf(settledate), merch.getShopaccno());
-//        if (null == merchday) {
-//          throw new Exception("商户余额表无此商户账号[" + merch.getShopaccno() + "]");
-//        }
-//        merchday.setDramt(merch.getDramt() == null ? 0D : merch.getDramt());
-//        merchday.setCramt(merch.getCramt() == null ? 0D : merch.getCramt());
-//        shopaccdayDao.save(merchday);
-//      }
-//    }
-//    shopaccdayDao.updateShopaccdayBalance(String.valueOf(settledate), systemUtilService.getSysdatetime().getHostdatetime()); //批量更新余额,商户日结表生成
+    Map<String, Double> v_merchbaldict = new HashMap<String, Double>(0);
+    //根据商户昨天日结表生成当天日结表(交易前余额), 新增商户添加记录
+    List<TShopaccday> lastShopaccdays = shopaccdayDao.getShopaccdayByAccdate(String.valueOf(lastsettday));
+    if (!StringUtil.isEmpty(lastShopaccdays)) {
+      for (TShopaccday lastday : lastShopaccdays) {
+        TShopaccday today = new TShopaccday(String.valueOf(settledate), lastday.getShopaccno(), periodYear, periodMonth, lastday.getBalance(), 0D, 0D, 0D);
+        shopaccdayDao.save(today);
+        v_merchbaldict.put(lastday.getShopaccno(), lastday.getBalance());
+      }
+    }
+    List<String> newShopaccs = shopaccDao.getNewShopacc(String.valueOf(lastsettday)); //新增商户
+    if(!StringUtil.isEmpty(newShopaccs)){
+      for(String accno:newShopaccs){
+        TShopaccday today = new TShopaccday(String.valueOf(settledate), accno, periodYear, periodMonth, 0D, 0D, 0D, 0D);
+        shopaccdayDao.save(today);
+        v_merchbaldict.put(accno, 0D);
+      }
+    }
+
+    List<MerchBean> merchBeanList = voucherDao.getShopVoucherByAccdate(settledate);
+    if (!StringUtil.isEmpty(merchBeanList)) {
+      for (MerchBean merch : merchBeanList) {
+        TShopaccday merchday = shopaccdayDao.getTShopaccdayById(String.valueOf(settledate), merch.getShopaccno());
+        if (null == merchday) {
+          throw new Exception("商户余额表无此商户账号[" + merch.getShopaccno() + "]");
+        }
+        merchday.setDramt(merch.getDramt() == null ? 0D : merch.getDramt());
+        merchday.setCramt(merch.getCramt() == null ? 0D : merch.getCramt());
+        shopaccdayDao.save(merchday);
+      }
+    }
+    shopaccdayDao.updateShopaccdayBalance(String.valueOf(settledate), systemUtilService.getSysdatetime().getHostdatetime()); //批量更新余额,商户日结表生成
 
     //根据科目昨天日结表生成当天日结表(交易前借贷方余额),新增末级科目插入记录(交易前余额为科目贷方余额)
     List<TSubjectday> lastSubjectDays = subjectdayDao.getAllByAccdate(String.valueOf(lastsettday));
@@ -334,23 +321,23 @@
     List<TVoucherEntry> entryList = voucherEntryDao.getVoucherEntryByVoucherdate(settledate);
     if (!StringUtil.isEmpty(entryList)) {
       for (TVoucherEntry vce : entryList) {
-//        if (TradeDict.SUBJNO_SHOP.equals(vce.getSubjno())) {
-//          //商户科目
-//          Double befbal = v_merchbaldict.get(vce.getAccno());
-//          if (null == befbal) throw new Exception("商户表商户账号[" + vce.getAccno() + "]不存在");
-//          v_merchbaldict.put(vce.getAccno(), MoneyUtil.formatYuan(befbal + vce.getCramt() - vce.getDramt())); //更新余额
-//          vce.setBalflag(2);
-//          vce.setBalance(v_merchbaldict.get(vce.getAccno()));
-//          if (!StringUtil.isEmpty(vce.getOppaccno())) {
-//            vce.setOppname(shopaccDao.getShopname(vce.getOppaccno()).getAccname());
-//          } else {
-//            vce.setOppname(subjectDao.getSubjectname(vce.getOppsubjno()).getAccname());
-//          }
-//          voucherEntryDao.save(vce);
-//          Double befMerchbal = v_subjbaldict.get(vce.getSubjno());
-//          if (null == befMerchbal) throw new Exception("商户科目号[" + vce.getSubjno() + "]不存在");
-//          v_subjbaldict.put(vce.getSubjno(), MoneyUtil.formatYuan(befMerchbal - vce.getDramt() + vce.getCramt())); //商户科目总余额更新
-//        } else {
+        if (Subject.SUBJNO_MACHANT_INCOME.equals(vce.getSubjno())) {
+          //商户科目
+          Double befbal = v_merchbaldict.get(vce.getAccno());
+          if (null == befbal) throw new Exception("商户表商户账号[" + vce.getAccno() + "]不存在");
+          v_merchbaldict.put(vce.getAccno(), MoneyUtil.formatYuan(befbal + vce.getCramt() - vce.getDramt())); //更新余额
+          vce.setBalflag(2);
+          vce.setBalance(v_merchbaldict.get(vce.getAccno()));
+          if (Subject.SUBJNO_MACHANT_INCOME.equals(vce.getOppsubjno())) {
+            vce.setOppname(shopaccDao.getShopname(vce.getOppaccno()));
+          } else {
+            vce.setOppname(subjectDao.getSubjectname(vce.getOppsubjno()));
+          }
+          voucherEntryDao.save(vce);
+          Double befMerchbal = v_subjbaldict.get(vce.getSubjno());
+          if (null == befMerchbal) throw new Exception("商户科目号[" + vce.getSubjno() + "]不存在");
+          v_subjbaldict.put(vce.getSubjno(), MoneyUtil.formatYuan(befMerchbal - vce.getDramt() + vce.getCramt())); //商户科目总余额更新
+        } else {
           //其他科目
           Integer balflag = v_subjbalflagdict.get(vce.getSubjno());
           Double befbal = v_subjbaldict.get(vce.getSubjno());
@@ -362,28 +349,28 @@
           }
           vce.setBalflag(balflag);
           vce.setBalance(v_subjbaldict.get(vce.getSubjno()));
-//          if (!StringUtil.isEmpty(vce.getOppaccno())) {
-//            vce.setOppname(shopaccDao.getShopname(vce.getOppaccno()).getAccname());
-//          } else {
+          if (Subject.SUBJNO_MACHANT_INCOME.equals(vce.getOppsubjno())) {
+            vce.setOppname(shopaccDao.getShopname(vce.getOppaccno()));
+          } else {
             vce.setOppname(subjectDao.getSubjectname(vce.getOppsubjno()));
-//          }
+          }
           voucherEntryDao.save(vce);
-//        }
+        }
       }
     }
 
     //开始校验
     //核算商户日结表商户余额 和凭证明细余额是否一致 TODO(新商户收入校验逻辑)
-//    for (String shopaccno : v_merchbaldict.keySet()) {
-//      TShopaccday tShopaccday = shopaccdayDao.getTShopaccdayById(String.valueOf(settledate), shopaccno);
-//      if (!MoneyUtil.moneyEqual(v_merchbaldict.get(shopaccno), tShopaccday.getBalance())) {
-//        throw new Exception("结算后检查失败:商户余额不等,商户余额[" + tShopaccday.getBalance() + "]凭证商户余额[" + v_merchbaldict.get(shopaccno) + "]");
-//      }
+    for (String shopaccno : v_merchbaldict.keySet()) {
+      TShopaccday tShopaccday = shopaccdayDao.getTShopaccdayById(String.valueOf(settledate), shopaccno);
+      if (!MoneyUtil.moneyEqual(v_merchbaldict.get(shopaccno), tShopaccday.getBalance())) {
+        throw new Exception("结算后检查失败:商户["+shopaccno+"]余额不等,商户日结余额[" + tShopaccday.getBalance() + "]凭证商户余额[" + v_merchbaldict.get(shopaccno) + "]");
+      }
 //      TShopaccbal tShopaccbal = shopaccbalDao.getOne(shopaccno);
 //      tShopaccbal.setBalance(tShopaccday.getBalance());
 //      tShopaccbal.setUpdtime(systemUtilService.getSysdatetime().getHostdatetime());
-//      shopaccbalDao.save(tShopaccbal);
-//    }
+//      shopaccbalDao.save(tShopaccbal); //商户期末余额
+    }
 
     //核算科目日结表科目余额和凭证明细余额是否一致
     for (String subjno : v_subjbaldict.keySet()) {
@@ -403,13 +390,13 @@
     }
 
     //核对商户日结表余额表和科目日结表商户余额是否一致
-//    TSubjectday shopSubjectday = subjectdayDao.getSubjectDayById(String.valueOf(settledate), TradeDict.SUBJNO_SHOP);
-//    AmountBean merchbal = shopaccdayDao.getSumBalance(String.valueOf(settledate));
-//    double shopSubbal = (shopSubjectday == null ? 0 : shopSubjectday.getCrbal());
-//    double shopMerchbal = ((null == merchbal || null == merchbal.getAmount()) ? 0 : merchbal.getAmount());
-//    if (!MoneyUtil.moneyEqual(shopSubbal, shopMerchbal)) {
-//      throw new Exception("结算后检查失败:商户日结表和科目日结表期末余额不平衡,商户[" + shopMerchbal + "] 科目[" + shopSubbal + "]");
-//    }
+    TSubjectday shopSubjectday = subjectdayDao.getSubjectDayById(String.valueOf(settledate), Subject.SUBJNO_MACHANT_INCOME);
+    Double merchbal = shopaccdayDao.getSumBalance(String.valueOf(settledate));
+    double shopSubbal = (shopSubjectday == null ? 0 : shopSubjectday.getCrbal());
+    double shopMerchbal = (merchbal == null ? 0 : merchbal);
+    if (!MoneyUtil.moneyEqual(shopSubbal, shopMerchbal)) {
+      throw new Exception("结算后检查失败:商户日结表和科目日结表期末余额不平衡,商户[" + shopMerchbal + "] 科目[" + shopSubbal + "]");
+    }
 
     //核算一级科目余额是否平衡
     FSubjectInfoBean allParentSubjbal = subjectdayDao.getAllParentSubjectSumInfo(String.valueOf(settledate));
@@ -433,8 +420,11 @@
 
     //日切
     tSettlectl.setStatus(0); //清标记
+    tSettlectl.setPeriodYear(periodYear);
+    tSettlectl.setPeriodMonth(periodMonth);
     tSettlectl.setSettledate(Integer.valueOf(DateUtil.getNewDay(String.valueOf(settledate), 1)));
     tSettlectl.setUpdtime(systemUtilService.getSysdatetime().getHostdatetime());
+    settleCtlDao.save(tSettlectl);
     return true;
   }
 
@@ -450,100 +440,100 @@
 //    int hostDate = Integer.valueOf(systemUtilService.getSysdatetime().getHostdatetime());
 //    int prdyear = settlectl.getPeriodYear();
 //    int prdmonth = settlectl.getPeriodMonth();
-    int settday = settlectl.getSettledate();
-
-    List<String> newShopList = shopaccDao.getNewAddShopacc(String.valueOf(settday));
-    if (!StringUtil.isEmpty(newShopList)) {
-      for (String accno : newShopList) {
-        TShopaccbal shopBal = new TShopaccbal(accno);
-        shopaccbalDao.save(shopBal);
-      }
-    }
-    if (shopaccDao.checkSettleShopacc().getExisted() > 0) {
-      throw new Exception("初始化数据错误:商户余额表数据没有包含所有有效的商户账户余额");
-    }
-
-    //新增科目插入科目余额表(末级科目)
-    List<String> newEndsubjectList = subjectDao.getNewSubject();
-    if (!StringUtil.isEmpty(newEndsubjectList)) {
-      for (String subjno : newEndsubjectList) {
-        TSubjectbal subjectbal = new TSubjectbal(subjno);
-        subjectbalDao.save(subjectbal);
-      }
-    }
-    if (subjectDao.checkSettleSubject().getExisted() > 0) {
-      throw new Exception("初始化数据错误:科目余额表数据没有包含所有的科目余额");
-    }
-
-    TVoucher voucher = voucherDao.findByVoucheridWithLock(voucherid);
-    List<TVoucherEntry> entryList = voucherEntryDao.getVoucherEntryByVoucherid(voucherid);
-    if (null == voucher) {
-      throw new Exception("凭证查询无记录");
-    } else if ("auto".equals(voucher.getSourcetype())) {
-      throw new Exception("该凭证不是手工录入凭证");
-    } else if (voucher.getCheckflag() != 1) {
-      throw new Exception("该凭证未审核");
-    } else if (StringUtil.isEmpty(voucher.getSummary())) {
-      throw new Exception("摘要不能为空");
-    } else if (voucher.getPostflag() == 1) {
-      throw new Exception("凭证已入账");
-    }
-
-    if (StringUtil.isEmpty(entryList)) {
-      throw new Exception("凭证无借贷明细!");
-    }
-
-    //凭证号
-    TVouchernoCtl vouchernoCtl = vouchernoCtlDao.getVoucherno();
-    if (null == vouchernoCtl) {
-      vouchernoCtl = new TVouchernoCtl(1, periodMonth, 0);
-      vouchernoCtlDao.save(vouchernoCtl);
-    }
-    int voucherno = vouchernoCtl.getVoucherno() + 1;
-    vouchernoCtl.setVoucherno(voucherno);
-    vouchernoCtlDao.save(vouchernoCtl);
-
-    voucher.setVoucherno(voucherno);
-    voucher.setPostflag(1);
-    voucherDao.save(voucher); //修改凭证表凭证号、入账标志
-
-    //明细
-    for (TVoucherEntry entry : entryList) {
-      if (Subject.SUBJNO_MACHANT_INCOME.equals(entry.getSubjno())) {
-        TShopaccbal tShopaccbal = shopaccbalDao.getTShopaccbalByIdWithLock(entry.getAccno());
-        if (null == tShopaccbal) {
-          throw new Exception("商户表商户账号[" + entry.getAccno() + "]不存在");
-        }
-        tShopaccbal.setBalance(tShopaccbal.getBeginbal() + entry.getCramt() - entry.getDramt());
-        shopaccbalDao.save(tShopaccbal);
-        entry.setBalflag(2);
-        entry.setBalance(tShopaccbal.getBalance());
-      } else {
-        TSubjectbal tSubjectbal = subjectbalDao.getTSubjectbalBySubjnoWithLock(entry.getSubjno());
-        TSubject subject = subjectDao.getOne(entry.getSubjno());
-        if (null == tSubjectbal || null == subject) {
-          throw new Exception("科目表科目号[" + entry.getSubjno() + "]不存在");
-        } else if (subject.getEndflag() != 1) {
-          throw new Exception("科目[" + entry.getSubjno() + "]非末级科目");
-        }
-        entry.setBalflag(subject.getBalflag());
-        if (subject.getBalflag() == 1) {
-          tSubjectbal.setDrbal(tSubjectbal.getDrbal() + entry.getDramt() - entry.getCramt());
-          entry.setBalance(tSubjectbal.getDrbal());
-        } else {
-          tSubjectbal.setCrbal(tSubjectbal.getCrbal() - entry.getDramt() + entry.getCramt());
-          entry.setBalance(tSubjectbal.getCrbal());
-        }
-        subjectbalDao.save(tSubjectbal);
-      }
-
-      if (!StringUtil.isEmpty(entry.getOppaccno())) {
-        entry.setOppname(shopaccDao.getShopname(entry.getOppaccno()));
-      } else {
-        entry.setOppname(subjectDao.getSubjectname(entry.getOppsubjno()));
-      }
-      voucherEntryDao.save(entry);
-    }
+//    int settday = settlectl.getSettledate();
+//
+//    List<String> newShopList = shopaccDao.getNewAddShopacc(String.valueOf(settday));
+//    if (!StringUtil.isEmpty(newShopList)) {
+//      for (String accno : newShopList) {
+//        TShopaccbal shopBal = new TShopaccbal(accno);
+//        shopaccbalDao.save(shopBal);
+//      }
+//    }
+//    if (shopaccDao.checkSettleShopacc().getExisted() > 0) {
+//      throw new Exception("初始化数据错误:商户余额表数据没有包含所有有效的商户账户余额");
+//    }
+//
+//    //新增科目插入科目余额表(末级科目)
+//    List<String> newEndsubjectList = subjectDao.getNewSubject();
+//    if (!StringUtil.isEmpty(newEndsubjectList)) {
+//      for (String subjno : newEndsubjectList) {
+//        TSubjectbal subjectbal = new TSubjectbal(subjno);
+//        subjectbalDao.save(subjectbal);
+//      }
+//    }
+//    if (subjectDao.checkSettleSubject().getExisted() > 0) {
+//      throw new Exception("初始化数据错误:科目余额表数据没有包含所有的科目余额");
+//    }
+//
+//    TVoucher voucher = voucherDao.findByVoucheridWithLock(voucherid);
+//    List<TVoucherEntry> entryList = voucherEntryDao.getVoucherEntryByVoucherid(voucherid);
+//    if (null == voucher) {
+//      throw new Exception("凭证查询无记录");
+//    } else if ("auto".equals(voucher.getSourcetype())) {
+//      throw new Exception("该凭证不是手工录入凭证");
+//    } else if (voucher.getCheckflag() != 1) {
+//      throw new Exception("该凭证未审核");
+//    } else if (StringUtil.isEmpty(voucher.getSummary())) {
+//      throw new Exception("摘要不能为空");
+//    } else if (voucher.getPostflag() == 1) {
+//      throw new Exception("凭证已入账");
+//    }
+//
+//    if (StringUtil.isEmpty(entryList)) {
+//      throw new Exception("凭证无借贷明细!");
+//    }
+//
+//    //凭证号
+//    TVouchernoCtl vouchernoCtl = vouchernoCtlDao.getVoucherno();
+//    if (null == vouchernoCtl) {
+//      vouchernoCtl = new TVouchernoCtl(1, periodMonth, 0);
+//      vouchernoCtlDao.save(vouchernoCtl);
+//    }
+//    int voucherno = vouchernoCtl.getVoucherno() + 1;
+//    vouchernoCtl.setVoucherno(voucherno);
+//    vouchernoCtlDao.save(vouchernoCtl);
+//
+//    voucher.setVoucherno(voucherno);
+//    voucher.setPostflag(1);
+//    voucherDao.save(voucher); //修改凭证表凭证号、入账标志
+//
+//    //明细
+//    for (TVoucherEntry entry : entryList) {
+//      if (Subject.SUBJNO_MACHANT_INCOME.equals(entry.getSubjno())) {
+//        TShopaccbal tShopaccbal = shopaccbalDao.getTShopaccbalByIdWithLock(entry.getAccno());
+//        if (null == tShopaccbal) {
+//          throw new Exception("商户表商户账号[" + entry.getAccno() + "]不存在");
+//        }
+//        tShopaccbal.setBalance(tShopaccbal.getBeginbal() + entry.getCramt() - entry.getDramt());
+//        shopaccbalDao.save(tShopaccbal);
+//        entry.setBalflag(2);
+//        entry.setBalance(tShopaccbal.getBalance());
+//      } else {
+//        TSubjectbal tSubjectbal = subjectbalDao.getTSubjectbalBySubjnoWithLock(entry.getSubjno());
+//        TSubject subject = subjectDao.getOne(entry.getSubjno());
+//        if (null == tSubjectbal || null == subject) {
+//          throw new Exception("科目表科目号[" + entry.getSubjno() + "]不存在");
+//        } else if (subject.getEndflag() != 1) {
+//          throw new Exception("科目[" + entry.getSubjno() + "]非末级科目");
+//        }
+//        entry.setBalflag(subject.getBalflag());
+//        if (subject.getBalflag() == 1) {
+//          tSubjectbal.setDrbal(tSubjectbal.getDrbal() + entry.getDramt() - entry.getCramt());
+//          entry.setBalance(tSubjectbal.getDrbal());
+//        } else {
+//          tSubjectbal.setCrbal(tSubjectbal.getCrbal() - entry.getDramt() + entry.getCramt());
+//          entry.setBalance(tSubjectbal.getCrbal());
+//        }
+//        subjectbalDao.save(tSubjectbal);
+//      }
+//
+//      if (!StringUtil.isEmpty(entry.getOppaccno())) {
+//        entry.setOppname(shopaccDao.getShopname(entry.getOppaccno()));
+//      } else {
+//        entry.setOppname(subjectDao.getSubjectname(entry.getOppsubjno()));
+//      }
+//      voucherEntryDao.save(entry);
+//    }
 
     return true;
   }
diff --git a/src/main/kotlin/com/supwisdom/dlpay/PayApiApplication.kt b/src/main/kotlin/com/supwisdom/dlpay/PayApiApplication.kt
index 9d334d7..6810f89 100644
--- a/src/main/kotlin/com/supwisdom/dlpay/PayApiApplication.kt
+++ b/src/main/kotlin/com/supwisdom/dlpay/PayApiApplication.kt
@@ -16,6 +16,7 @@
 import org.springframework.data.redis.repository.configuration.EnableRedisRepositories
 import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
 import org.springframework.data.redis.serializer.StringRedisSerializer
+import org.springframework.scheduling.annotation.EnableScheduling
 
 
 @Configuration
@@ -66,6 +67,7 @@
 
 
 @SpringBootApplication
+@EnableScheduling
 class PayApiApplication
 
 fun main(args: Array<String>) {
diff --git a/src/main/resources/static/libs/zTree/css/zTreeStyle/zTreeStyle.css b/src/main/resources/static/libs/zTree/css/zTreeStyle/zTreeStyle.css
index 77c2794..3b7190b 100755
--- a/src/main/resources/static/libs/zTree/css/zTreeStyle/zTreeStyle.css
+++ b/src/main/resources/static/libs/zTree/css/zTreeStyle/zTreeStyle.css
@@ -8,7 +8,7 @@
 
 -------------------------------------*/
 
-.ztree * {padding:0; margin:0; font-size:12px; font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif}
+.ztree * {padding:0; margin:0; font-size:14px; font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif}
 .ztree {margin:0; padding:5px; color:#333}
 .ztree li{padding:0; margin:0; list-style:none; line-height:14px; text-align:left; white-space:nowrap; outline:0}
 .ztree li ul{ margin:0; padding:0 0 0 18px}