From 509c0a8dac51324e67ea396373607d8cc675c528 Mon Sep 17 00:00:00 2001 From: Xia Kaixiang Date: Mon, 12 Aug 2019 18:16:45 +0800 Subject: [PATCH] =?utf8?q?=E7=BB=93=E7=AE=97=E6=95=B4=E7=90=86=E5=92=8C?= =?utf8?q?=E7=BB=93=E7=AE=97=E6=97=A5=E5=BF=97=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- config/application-devel-pg-xkx.properties | 3 +- .../dlpay/api/dao/DebitCreditDtlDao.java | 4 +- .../dlpay/api/service/SourceTypeService.java | 6 +- .../framework/core/DayendSettleTask.java | 8 +- .../dlpay/framework/dao/PeriodDao.java | 11 +- .../dlpay/framework/dao/SettleCtlDao.java | 8 + .../dlpay/framework/dao/SettleLogDao.java | 3 +- .../dlpay/framework/dao/ShopaccDao.java | 4 +- .../dlpay/framework/dao/ShopaccdayDao.java | 12 +- .../dlpay/framework/dao/SubjectDao.java | 18 +-- .../dlpay/framework/dao/SubjectbalDao.java | 21 +-- .../dlpay/framework/dao/SubjectdayDao.java | 24 +-- .../dlpay/framework/dao/TranscodeDao.java | 1 + .../dlpay/framework/dao/VoucherDao.java | 20 +-- .../dlpay/framework/dao/VoucherEntryDao.java | 8 +- .../dlpay/framework/dao/VouchernoCtlDao.java | 8 + .../dlpay/framework/domain/TPeriod.java | 22 ++- .../dlpay/framework/domain/TPeriodPK.java | 52 ------ .../dlpay/framework/domain/TResource.java | 2 +- .../dlpay/framework/domain/TSettlectl.java | 2 +- .../dlpay/framework/domain/TSubjectbal.java | 14 +- .../dlpay/framework/domain/TSubjectday.java | 14 +- .../dlpay/framework/domain/TSubjectdayPK.java | 6 +- .../dlpay/framework/domain/TVoucherEntry.java | 6 +- .../dlpay/framework/domain/TVouchernoCtl.java | 11 +- .../service/impl/DayendSettleServiceImpl.java | 109 +++++++------ .../service/impl/SystemUtilServiceImpl.java | 2 +- .../system/bean/SettleLogSearchBean.java | 40 +++++ .../controller/SettlementLogController.java | 56 +++++++ .../system/service/SettlementLogService.java | 11 ++ .../impl/SettlementLogServiceImpl.java | 56 +++++++ payapi/src/main/resources/data-postgresql.sql | 4 +- payapi/src/main/resources/data.sql | 13 +- .../templates/system/settlelog/index.html | 152 ++++++++++++++++++ 34 files changed, 530 insertions(+), 201 deletions(-) delete mode 100644 payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPeriodPK.java create mode 100644 payapi/src/main/java/com/supwisdom/dlpay/system/bean/SettleLogSearchBean.java create mode 100644 payapi/src/main/java/com/supwisdom/dlpay/system/controller/SettlementLogController.java create mode 100644 payapi/src/main/java/com/supwisdom/dlpay/system/service/SettlementLogService.java create mode 100644 payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettlementLogServiceImpl.java create mode 100644 payapi/src/main/resources/templates/system/settlelog/index.html diff --git a/config/application-devel-pg-xkx.properties b/config/application-devel-pg-xkx.properties index 85ffa709..727f38f1 100644 --- a/config/application-devel-pg-xkx.properties +++ b/config/application-devel-pg-xkx.properties @@ -28,7 +28,8 @@ security.request.sign=false ## quartz task scheduler shopbalance.updater.cron=- #download.ynrcc.chkfile.cron =3 0/2 * * * ? -query.third.transdtl.result.cron=7 0/1 * * * ? +#query.third.transdtl.result.cron=7 0/1 * * * ? +dayend.settletask.cron=0 0/2 * * * ? ############################################# spring.cloud.consul.enabled=false spring.cloud.consul.host=172.28.201.70 diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/DebitCreditDtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/DebitCreditDtlDao.java index 0b5e7336..b55c02ce 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/DebitCreditDtlDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/DebitCreditDtlDao.java @@ -16,9 +16,9 @@ public interface DebitCreditDtlDao extends JpaRepository getVoucherData(@Param("settledate") String settledate); + List getVoucherData(@Param("settledate") String settledate, @Param("tenantid") String tenantid); List findByRefno(String refno); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java b/payapi/src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java index c0d78b76..8e4048b6 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java @@ -25,9 +25,6 @@ public interface SourceTypeService { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) boolean checkShopSourceType(String shopaccno, String sourceType, boolean anonymousflag) throws Exception; - @Transactional - List getAllEnabledSourcetype(); - /** * 获取支付能力充值参数全局配置 */ @@ -46,6 +43,9 @@ public interface SourceTypeService { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) boolean checkShopCanReverse(String sourcetype, String shopaccno) throws Exception; + @Transactional(rollbackFor = Exception.class, readOnly = true) + List getAllEnabledSourcetype(); + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) TSourceTypeCheckStatus getSourceTypeCheckStatus(String sourceType); diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/core/DayendSettleTask.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/core/DayendSettleTask.java index 86fb351f..f0cc66c6 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/core/DayendSettleTask.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/core/DayendSettleTask.java @@ -1,5 +1,6 @@ package com.supwisdom.dlpay.framework.core; +import com.supwisdom.dlpay.exception.TransactionException; import com.supwisdom.dlpay.framework.domain.TSettleLog; import com.supwisdom.dlpay.framework.service.DayendSettleService; import com.supwisdom.dlpay.framework.tenant.TenantContext; @@ -25,10 +26,10 @@ public class DayendSettleTask { @SchedulerLock(name = "DayendSettleTask", lockAtMostForString = "PT30M") public void doSettleTask() { if (logger.isDebugEnabled()) logger.debug("进入日结算任务!"); + if (null == TenantContext.getTenantSchema()) TenantContext.setTenantSchema(Constants.DEFAULT_TENANTID); + settleLog = dayendSettleService.doCreateSettleLog(); //记录日志 try { - if (null == TenantContext.getTenantSchema()) TenantContext.setTenantSchema(Constants.DEFAULT_TENANTID); - //step1: 账户校验(fixme: 清算任务?) long t1 = System.currentTimeMillis(); if (!checkAccounts()) { @@ -80,6 +81,9 @@ public class DayendSettleTask { dayendSettleService.doUpdateSettleLog(settleLog.update("0", "成功结算")); } return ret; + } catch (TransactionException ex) { + dayendSettleService.doUpdateSettleLog(settleLog.update("" + ex.code(), ex.getMessage())); + return false; } catch (Exception e) { if (!StringUtil.isEmpty(e.getMessage())) { dayendSettleService.doUpdateSettleLog(settleLog.update("-9", e.getMessage())); diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PeriodDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PeriodDao.java index aa05bd78..bd32b18f 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PeriodDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PeriodDao.java @@ -1,7 +1,6 @@ package com.supwisdom.dlpay.framework.dao; import com.supwisdom.dlpay.framework.domain.TPeriod; -import com.supwisdom.dlpay.framework.domain.TPeriodPK; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Lock; import org.springframework.data.jpa.repository.Query; @@ -11,11 +10,11 @@ import org.springframework.stereotype.Repository; import javax.persistence.LockModeType; @Repository -public interface PeriodDao extends JpaRepository { - @Query(value = "from TPeriod t where t.periodYear=:periodyear and t.periodMonth=:periodmonth ") - TPeriod getPeriod(@Param("periodyear") Integer periodyear, @Param("periodmonth") Integer periodmonth); +public interface PeriodDao extends JpaRepository { + @Query(value = "from TPeriod t where t.periodYear=:periodyear and t.periodMonth=:periodmonth and t.tenantId=:tenantid ") + TPeriod getPeriod(@Param("periodyear") Integer periodyear, @Param("periodmonth") Integer periodmonth, @Param("tenantid") String tenantid); @Lock(LockModeType.PESSIMISTIC_WRITE) - @Query(value = "from TPeriod t where t.periodYear=:periodyear and t.periodMonth=:periodmonth ") - TPeriod getTPeriodWithLock(@Param("periodyear") Integer periodyear, @Param("periodmonth") Integer periodmonth); + @Query(value = "from TPeriod t where t.periodYear=:periodyear and t.periodMonth=:periodmonth and t.tenantId=:tenantid ") + TPeriod getTPeriodWithLock(@Param("periodyear") Integer periodyear, @Param("periodmonth") Integer periodmonth, @Param("tenantid") String tenantid); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java index ec8fadc4..88e3eb2f 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleCtlDao.java @@ -19,8 +19,16 @@ public interface SettleCtlDao extends JpaRepository { @Query(value = "from TSettlectl where booksetno=:booksetno ") TSettlectl findByBooksetnoWithLock(@Param("booksetno") Integer booksetno); + @Lock(value = LockModeType.PESSIMISTIC_WRITE) + @Query(value = "from TSettlectl where tenantId=:tenantid ") + TSettlectl findByTenantIdWithLock(@Param("tenantid") String tenantid); + @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); + @Modifying(clearAutomatically = true) + @Query(value = "update TB_SETTLECTL set PERIODYEAR=:peridyear,PERIODMONTH=:peridmonth where TENANTID=:tenantid ", nativeQuery = true) + void updateSettlePeriodByTenantid(@Param("peridyear") int peridyear, @Param("peridmonth") int peridmonth, @Param("tenantid") String tenantid); + } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleLogDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleLogDao.java index 30de1aef..75b907ac 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleLogDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SettleLogDao.java @@ -2,8 +2,9 @@ package com.supwisdom.dlpay.framework.dao; import com.supwisdom.dlpay.framework.domain.TSettleLog; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.stereotype.Repository; @Repository -public interface SettleLogDao extends JpaRepository { +public interface SettleLogDao extends JpaRepository, JpaSpecificationExecutor { } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java index f76cffa7..db210cd1 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java @@ -14,8 +14,8 @@ import java.util.List; @Repository public interface ShopaccDao extends JpaRepository { - @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 getNewShopacc(@Param("lastsettday") String lastsettday); + @Query(value = "select t.SHOPACCNO from TB_SHOPACC t left join TB_SHOPACCDAY a on t.SHOPACCNO=a.SHOPACCNO and a.accdate=:lastsettday where t.TENANTID=:tenantid and a.SHOPACCNO is null ", nativeQuery = true) + List getNewShopacc(@Param("lastsettday") String lastsettday, @Param("tenantid") String tenantid); @Query(value = "select shopname from TShopacc where shopaccno=:shopaccno ") diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccdayDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccdayDao.java index ddc02652..bf0d37b5 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccdayDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccdayDao.java @@ -13,17 +13,17 @@ import java.util.List; @Repository public interface ShopaccdayDao extends JpaRepository { - @Query(value = "from TShopaccday t where t.accdate=:accdate ") - List getShopaccdayByAccdate(@Param("accdate") String accdate); + @Query(value = "from TShopaccday t where t.accdate=:accdate and t.tenantId=:tenantid ") + List getShopaccdayByAccdate(@Param("accdate") String accdate, @Param("tenantid") String tenantid); @Query(value = "from TShopaccday t where t.accdate=:accdate and t.shopaccno=:shopaccno ") TShopaccday getTShopaccdayById(@Param("accdate") String accdate, @Param("shopaccno") String shopaccno); @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 = "update TB_SHOPACCDAY set balance=beginbal-dramt+cramt,updtime=:updtime where accdate=:accdate and TENANTID=:tenantid ", nativeQuery = true) + void updateShopaccdayBalance(@Param("accdate") String accdate,@Param("updtime")String updtime, @Param("tenantid") String tenantid); - @Query(value = "select sum(balance) as amount from TShopaccday where accdate=:accdate ") - Double getSumBalance(@Param("accdate") String accdate); + @Query(value = "select sum(balance) as amount from TShopaccday where accdate=:accdate and tenantId=:tenantid ") + Double getSumBalance(@Param("accdate") String accdate, @Param("tenantid") String tenantid); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectDao.java index 78ecb030..c1fb3e8e 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectDao.java @@ -10,19 +10,19 @@ import org.springframework.stereotype.Repository; import java.util.List; @Repository -public interface SubjectDao extends JpaRepository { +public interface SubjectDao extends JpaRepository { - @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 getNewSubject(); + @Query(value = "select t.* from TB_SUBJECT t left join TB_SUBJECTBAL a on t.SUBJNO=a.SUBJNO and t.TENANTID=a.TENANTID where t.ENDFLAG=1 and a.SUBJNO is null and t.TENANTID=:tenantid ", nativeQuery = true) + List getNewSubjectByTenantid(@Param("tenantid") String tenantid); - @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) - ExistBean checkSettleSubject(); + @Query(value = "select count(t.subjno) as existed from TB_SUBJECT t left join TB_SUBJECTBAL a on t.SUBJNO=a.SUBJNO and t.TENANTID=a.TENANTID where t.ENDFLAG=1 and a.SUBJNO is null and t.TENANTID=:tenantid ", nativeQuery = true) + ExistBean checkSettleSubjectByTenantid(@Param("tenantid") String tenantid); - @Query(value = "select a.subjno as accno from TB_SUBJECT a left join (select subjno from TB_SUBJECTDAY where accdate =:accdate ) b on a.subjno=b.subjno where a.subjlevel=1 and b.subjno is null ", nativeQuery = true) - List getNewSubjnos(@Param("accdate") String accdate); + @Query(value = "select a.* from TB_SUBJECT a left join (select subjno from TB_SUBJECTDAY where accdate =:accdate and TENANTID=:tenantid ) b on a.subjno=b.subjno where a.subjlevel=1 and a.TENANTID=:tenantid and b.subjno is null ", nativeQuery = true) + List getNewSubjnos(@Param("accdate") String accdate, @Param("tenantid") String tenantid); - @Query(value = "select subjname from TSubject where subjno=:subjno ") - String getSubjectname(@Param("subjno") String subjno); + @Query(value = "select subjname from TSubject where subjno=:subjno and tenantId=:tenantid ") + String getSubjectname(@Param("subjno") String subjno, @Param("tenantid") String tenantid); TSubject findBySubjno(String subjno); diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectbalDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectbalDao.java index 73b01cf9..3f5737ea 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectbalDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectbalDao.java @@ -13,21 +13,24 @@ import javax.persistence.LockModeType; import java.util.List; @Repository -public interface SubjectbalDao extends JpaRepository { +public interface SubjectbalDao extends JpaRepository { - @Query(value = "select t.* from TB_SUBJECTBAL t left join ( select subjno from TB_SUBJECTDAY where accdate =:lastsettday) a on t.subjno=a.subjno where a.subjno is null ", nativeQuery = true) - List getUnsettleSubjectbal(@Param("lastsettday") String lastsettday); + @Query(value = "select t.* from TB_SUBJECTBAL t left join ( select subjno from TB_SUBJECTDAY where accdate =:lastsettday and TENANTID=:tenantid) a on t.subjno=a.subjno where t.TENANTID=:tenantid and a.subjno is null ", nativeQuery = true) + List getUnsettleSubjectbal(@Param("lastsettday") String lastsettday, @Param("tenantid") String tenantid); - @Query(value = "select sum(BEGINDRBAL) as dramt,sum(BEGINCRBAL) as cramt from TB_SUBJECTBAL where SUBJNO in (select SUBJNO from TB_SUBJECT where fsubjno=:fsubjno) ", nativeQuery = true) - MerchBean getSubjectInfo(@Param("fsubjno") String fsubjno); + @Query(value = "select sum(BEGINDRBAL) as dramt,sum(BEGINCRBAL) as cramt from TB_SUBJECTBAL where TENANTID=:tenantid and SUBJNO in (select SUBJNO from TB_SUBJECT where fsubjno=:fsubjno and TENANTID=:tenantid) ", nativeQuery = true) + MerchBean getSubjectInfo(@Param("fsubjno") String fsubjno, @Param("tenantid") String tenantid); - @Query(value = "select sa.subjno,sa.drbal,crbal,sb.subjtype,sb.balflag from TB_SUBJECTBAL sa,TB_SUBJECT sb where sa.subjno=sb.subjno and sb.endflag=1 order by sa.subjno ", nativeQuery = true) - List getSubjectbalAndFlag(); + @Query(value = "select sa.subjno,sa.drbal,crbal,sb.subjtype,sb.balflag from TB_SUBJECTBAL sa,TB_SUBJECT sb where sa.tenantid=sb.tenantid and sa.subjno=sb.subjno and sb.endflag=1 and sa.tenantid=:tenantid order by sa.subjno ", nativeQuery = true) + List getSubjectbalAndFlag(@Param("tenantid") String tenantid); - @Query(value = "select case when :balflag=1 then sum(drbal) else sum(crbal) end as amount from tb_subjectbal where subjno in (select subjno from tb_subject where endflag=1 and balflag=:balflag )",nativeQuery = true) - Double getSumEndsubjectBalByEndflag(@Param("balflag")Integer balflag); + @Query(value = "select case when :balflag=1 then sum(drbal) else sum(crbal) end as amount from tb_subjectbal where tenantid=:tenantid and subjno in (select subjno from tb_subject where endflag=1 and balflag=:balflag and tenantid=:tenantid )",nativeQuery = true) + Double getSumEndsubjectBalByEndflag(@Param("balflag")Integer balflag, @Param("tenantid") String tenantid); @Lock(LockModeType.PESSIMISTIC_WRITE) @Query("from TSubjectbal where subjno=:subjno ") TSubjectbal getTSubjectbalBySubjnoWithLock(@Param("subjno")String subjno); + + @Query("from TSubjectbal where subjno=:subjno and tenantId=:tenantid ") + TSubjectbal getBySubjnoAndTenantId(@Param("subjno")String subjno, @Param("tenantid") String tenantid); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectdayDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectdayDao.java index 9a6a92c6..fb65662f 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectdayDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/SubjectdayDao.java @@ -15,26 +15,26 @@ import java.util.List; @Repository public interface SubjectdayDao extends JpaRepository { - @Query(value = "from TSubjectday where accdate=:accdate ") - List getAllByAccdate(@Param("accdate") String accdate); + @Query(value = "from TSubjectday where accdate=:accdate and tenantId=:tenantid ") + List getAllByAccdate(@Param("accdate") String accdate, @Param("tenantid") String tenantid); - @Query(value = "select a.subjno as shopaccno,a.begindrbal as dramt,a.begincrbal as cramt from TB_SUBJECTDAY a left join (select subjno from TB_SUBJECT where endflag=1) b on a.subjno=b.subjno where a.accdate=:accdate and b.subjno is not null ", nativeQuery = true) - List getEndSubjectbalInfos(@Param("accdate") String accdate); + @Query(value = "select a.subjno as shopaccno,a.begindrbal as dramt,a.begincrbal as cramt from TB_SUBJECTDAY a left join (select subjno from TB_SUBJECT where endflag=1 and TENANTID=:tenantid) b on a.subjno=b.subjno where a.TENANTID=:tenantid and a.accdate=:accdate and b.subjno is not null ", nativeQuery = true) + List getEndSubjectbalInfos(@Param("accdate") String accdate, @Param("tenantid") String tenantid); - @Query(value = "from TSubjectday where accdate=:accdate and subjno=:subjno") - TSubjectday getSubjectDayById(@Param("accdate") String accdate, @Param("subjno") String subjno); + @Query(value = "from TSubjectday where accdate=:accdate and subjno=:subjno and tenantId=:tenantid ") + TSubjectday getSubjectDayById(@Param("accdate") String accdate, @Param("subjno") String subjno, @Param("tenantid") String tenantid); - @Query(value = "from TSubjectday t where t.accdate=:accdate and t.subjno in (select subjno from TSubject where subjlevel=1 and endflag=0 ) ") - List getParentSubjectday(@Param("accdate") String accdate); + @Query(value = "from TSubjectday t where t.tenantId=:tenantid and t.accdate=:accdate and t.subjno in (select subjno from TSubject where subjlevel=1 and endflag=0 and tenantId=:tenantid) ") + List getParentSubjectday(@Param("accdate") String accdate, @Param("tenantid") String tenantid); @Query(value = "select sum(sb.begindrbal) as begindrbal,sum(sb.begincrbal) as begincrbal,sum(sb.dramt) as dramt,sum(sb.cramt) as cramt,sum(sb.drbal) as drbal,sum(sb.crbal) as crbal " + "from TB_SUBJECTDAY sb, TB_SUBJECT s " + - "where sb.accdate =:accdate and sb.subjno=s.subjno and s.subjlevel=2 and s.fsubjno=:fsubjno ", nativeQuery = true) - FSubjectInfoBean getParentSumInfo(@Param("accdate") String accdate, @Param("fsubjno") String fsubjno); + "where sb.tenantid=s.tenantid and sb.tenantid=:tenantid and sb.accdate =:accdate and sb.subjno=s.subjno and s.subjlevel=2 and s.fsubjno=:fsubjno ", nativeQuery = true) + FSubjectInfoBean getParentSumInfo(@Param("accdate") String accdate, @Param("fsubjno") String fsubjno, @Param("tenantid") String tenantid); @Query(value = "select sum(begindrbal) as begindrbal,sum(begincrbal) as begincrbal,sum(dramt) as dramt,sum(cramt) as cramt,sum(drbal) as drbal,sum(crbal) as crbal " + - "from tb_subjectday where accdate=:accdate and subjno in (select subjno from tb_subject where subjlevel=1) ", nativeQuery = true) - FSubjectInfoBean getAllParentSubjectSumInfo(@Param("accdate") String accdate); + "from tb_subjectday where accdate=:accdate and tenantid=:tenantid and subjno in (select subjno from tb_subject where subjlevel=1 and tenantid=:tenantid) ", nativeQuery = true) + FSubjectInfoBean getAllParentSubjectSumInfo(@Param("accdate") String accdate, @Param("tenantid") String tenantid); @Query(value = "SELECT t.subjno AS subjno, t.subjname AS subjname,t.fsubjno AS fsubjno,t.subjlevel AS subjlevel,t.displayflag, " + "a.begindrbal AS lastdaydrbal,a.begincrbal AS lastdaycrbal, " + diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/TranscodeDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/TranscodeDao.java index d40f2666..516ff2cd 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/TranscodeDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/TranscodeDao.java @@ -6,4 +6,5 @@ import org.springframework.stereotype.Repository; @Repository public interface TranscodeDao extends JpaRepository { + TTranscode getByTranscode(Integer transcode); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java index 02f5bada..c6bcf4cf 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java @@ -20,25 +20,25 @@ import java.util.List; @Repository public interface VoucherDao extends JpaRepository { - @Query(value = "select count(t.voucherid) as existed from TB_VOUCHER t where t.POSTFLAG=0 ", nativeQuery = true) - ExistBean checkExistUnpostVouhcer(); + @Query(value = "select count(t.voucherid) as existed from TB_VOUCHER t where t.POSTFLAG=0 and t.TENANTID=:tenantid ", nativeQuery = true) + ExistBean checkExistUnpostVouhcer(@Param("tenantid") String tenantid); @Modifying - @Query(value="delete from TB_VOUCHER where POSTFLAG=0 ",nativeQuery = true) - void deleteUnpostVoucher(); + @Query(value = "delete from TB_VOUCHER where POSTFLAG=0 and TENANTID=:tenantid ", nativeQuery = true) + void deleteUnpostVoucher(@Param("tenantid") String tenantid); @Lock(LockModeType.PESSIMISTIC_WRITE) - @Query(value = "from TVoucher where postflag=0 order by voucherid ") - List getSettleVouchers(); + @Query(value = "from TVoucher where postflag=0 and tenantId=:tenantid order by voucherid ") + List getSettleVouchers(@Param("tenantid") String tenantid); @Query(value="select va.accno as shopaccno,sum(va.dramt) as dramt,sum(va.cramt) as cramt " + "from tb_voucherentry va,tb_voucher vb " + - "where va.voucherid=vb.voucherid and vb.voucherdate=:settledate and va.subjno='2004' and va.accno is not null " + + "where va.voucherid=vb.voucherid and vb.voucherdate=:settledate and va.subjno='2004' and va.accno is not null and va.TENANTID=vb.TENANTID and va.TENANTID=:tenantid " + "group by va.accno order by va.accno ", nativeQuery = true) - List getShopVoucherByAccdate(@Param("settledate")Integer settledate); + List getShopVoucherByAccdate(@Param("settledate")Integer settledate, @Param("tenantid") String tenantid); - @Query(value = "select sum(va.dramt) as dramt, sum(va.cramt) as cramt from TB_VOUCHERENTRY va,TB_VOUCHER vb where va.voucherid=vb.voucherid and vb.voucherdate=:voucherdate and va.subjno=:subjno ", nativeQuery = true) - MerchBean getSettleSuminfo(@Param("voucherdate") Integer voucherdate, @Param("subjno") String subjno); + @Query(value = "select sum(va.dramt) as dramt, sum(va.cramt) as cramt from TB_VOUCHERENTRY va,TB_VOUCHER vb where va.tenantid=vb.tenantid and va.voucherid=vb.voucherid and va.tenantid=:tenantid and vb.voucherdate=:voucherdate and va.subjno=:subjno ", nativeQuery = true) + MerchBean getSettleSuminfo(@Param("voucherdate") Integer voucherdate, @Param("subjno") String subjno, @Param("tenantid") String tenantid); @Lock(LockModeType.PESSIMISTIC_WRITE) @Query(value = "from TVoucher where voucherid=:voucherid ") diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherEntryDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherEntryDao.java index cfb8cfd4..0d3b3cd4 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherEntryDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherEntryDao.java @@ -14,11 +14,11 @@ import java.util.List; @Repository public interface VoucherEntryDao extends JpaRepository { @Modifying - @Query(value = "delete from TB_VOUCHERENTRY where VOUCHERID in (select VOUCHERID from TB_VOUCHER where POSTFLAG=0)", nativeQuery = true) - void deleteUnpostVoucherentry(); + @Query(value = "delete from TB_VOUCHERENTRY where TENANTID=:tenantid and VOUCHERID in (select VOUCHERID from TB_VOUCHER where POSTFLAG=0 and t.TENANTID=:tenantid)", nativeQuery = true) + void deleteUnpostVoucherentry(@Param("tenantid") String tenantid); - @Query(value = "from TVoucherEntry where voucherid in (select voucherid from TVoucher where voucherdate=:voucherdate) order by subjno,accno,voucherid ") - List getVoucherEntryByVoucherdate(@Param("voucherdate") Integer voucherdate); + @Query(value = "from TVoucherEntry where tenantId=:tenantid and voucherid in (select voucherid from TVoucher where voucherdate=:voucherdate and tenantId=:tenantid) order by subjno,accno,voucherid ") + List getVoucherEntryByVoucherdate(@Param("voucherdate") Integer voucherdate, @Param("tenantid") String tenantid); @Lock(LockModeType.PESSIMISTIC_WRITE) @Query(value = "from TVoucherEntry t where t.voucherid=:voucherid ") diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VouchernoCtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VouchernoCtlDao.java index 7f81bf91..fcf8b7db 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VouchernoCtlDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/VouchernoCtlDao.java @@ -16,7 +16,15 @@ public interface VouchernoCtlDao extends JpaRepository { @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); + @Modifying(clearAutomatically = true) + @Query(value = "update TB_VOUCHERNOCTL set PERIODMONTH=:peridmonth,VOUCHERNO=:voucherno where TENANTID=:tenantid ", nativeQuery = true) + void updateVouchernoByTenantid(@Param("peridmonth") int peridmonth, @Param("voucherno") int voucherno, @Param("tenantid") String tenantid); + @Lock(LockModeType.PESSIMISTIC_WRITE) @Query(value = "from TVouchernoCtl where vouchertype=1 ") TVouchernoCtl getVoucherno(); + + @Lock(LockModeType.PESSIMISTIC_WRITE) + @Query(value = "from TVouchernoCtl where tenantId=:tenantid ") + TVouchernoCtl getVouchernoByTenantid(@Param("tenantid") String tenantid); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPeriod.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPeriod.java index 5d542685..6df7005d 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPeriod.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPeriod.java @@ -1,17 +1,23 @@ package com.supwisdom.dlpay.framework.domain; +import org.hibernate.annotations.GenericGenerator; + import javax.persistence.*; import javax.validation.constraints.NotNull; @Entity -@Table(name = "TB_PERIOD") -@IdClass(TPeriodPK.class) +@Table(name = "TB_PERIOD", + indexes = {@Index(name = "TB_PERIOD_UK", columnList = "PERIOD_YEAR, PERIOD_MONTH, TENANTID", unique = true)}) public class TPeriod { @Id + @GenericGenerator(name = "idGenerator", strategy = "uuid") + @GeneratedValue(generator = "idGenerator") + @Column(name = "ID", nullable = false, length = 32) + private String id; + @Column(name = "PERIOD_YEAR", nullable = false, precision = 4) private Integer periodYear; - @Id @Column(name = "PERIOD_MONTH", nullable = false, precision = 2) private Integer periodMonth; @@ -27,10 +33,18 @@ public class TPeriod { @NotNull private Integer settleflag = 0; - @Column(name = "tenantid", length = 20) + @Column(name = "TENANTID", length = 20) @NotNull private String tenantId; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public Integer getPeriodYear() { return periodYear; } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPeriodPK.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPeriodPK.java deleted file mode 100644 index e307db31..00000000 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPeriodPK.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.supwisdom.dlpay.framework.domain; - -import javax.persistence.Column; -import javax.persistence.Id; -import java.io.Serializable; - -public class TPeriodPK implements Serializable { - - @Id - @Column(name="PERIOD_YEAR", nullable = false, precision = 4) - private Integer periodYear; - - @Id - @Column(name="PERIOD_MONTH", nullable = false, precision = 2) - private Integer periodMonth; - - public Integer getPeriodYear() { - return periodYear; - } - - public void setPeriodYear(Integer periodYear) { - this.periodYear = periodYear; - } - - public Integer getPeriodMonth() { - return periodMonth; - } - - public void setPeriodMonth(Integer periodMonth) { - this.periodMonth = periodMonth; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TPeriodPK tPeriodPK = (TPeriodPK) o; - if (periodYear != null ? !periodYear.equals(tPeriodPK.getPeriodYear()) : periodYear != null) - return false; - if (periodMonth != null ? !periodMonth.equals(tPeriodPK.getPeriodMonth()) : periodMonth != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = periodYear != null ? periodYear.hashCode() : 0; - result = 31 * result + (periodMonth != null ? periodMonth.hashCode() : 0); - return result; - } -} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TResource.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TResource.java index 13be663f..fe2ce3f7 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TResource.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TResource.java @@ -5,7 +5,7 @@ import javax.validation.constraints.NotNull; @Entity @Table(name = "TB_RESOURCE") -@SequenceGenerator(name = "SEQ_RES", sequenceName = "SEQ_RES", allocationSize = 1000) +@SequenceGenerator(name = "SEQ_RES", sequenceName = "SEQ_RES", allocationSize = 1, initialValue = 1000) public class TResource { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_RES") diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSettlectl.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSettlectl.java index aa0a5158..5f6f2146 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSettlectl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSettlectl.java @@ -31,7 +31,7 @@ public class TSettlectl { @Column(name="UPDTIME", length = 14) private String updtime; - @Column(name = "tenantid", length = 20) + @Column(name = "TENANTID", length = 20) @NotNull private String tenantId; diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectbal.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectbal.java index 93a64e16..47b7ddd4 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectbal.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectbal.java @@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull; public class TSubjectbal { @Id @Column(name = "subjid", nullable = false, length = 32) - private String subjid; + private Integer subjid; @Column(name = "SUBJNO", length = 10) @NotNull @@ -55,7 +55,8 @@ public class TSubjectbal { public TSubjectbal() { } - public TSubjectbal(String subjno) { + public TSubjectbal(Integer subjid, String subjno, String tenantId) { + this.subjid = subjid; this.subjno = subjno; this.accumdramt = 0D; this.accumcramt = 0D; @@ -65,9 +66,11 @@ public class TSubjectbal { this.cramt = 0D; this.drbal = 0D; this.crbal = 0D; + this.tenantId = tenantId; } - public TSubjectbal(String subjno, Double accumdramt, Double accumcramt, Double begindrbal, Double begincrbal, Double dramt, Double cramt, Double drbal, Double crbal, String updtime, Integer lastsettleday, Double accumsettleamt) { + public TSubjectbal(Integer subjid, @NotNull String subjno, Double accumdramt, Double accumcramt, Double begindrbal, Double begincrbal, Double dramt, Double cramt, Double drbal, Double crbal, String updtime, Integer lastsettleday, Double accumsettleamt, @NotNull String tenantId) { + this.subjid = subjid; this.subjno = subjno; this.accumdramt = accumdramt; this.accumcramt = accumcramt; @@ -80,6 +83,7 @@ public class TSubjectbal { this.updtime = updtime; this.lastsettleday = lastsettleday; this.accumsettleamt = accumsettleamt; + this.tenantId = tenantId; } public String getSubjno() { @@ -186,11 +190,11 @@ public class TSubjectbal { this.tenantId = tenantId; } - public String getSubjid() { + public Integer getSubjid() { return subjid; } - public void setSubjid(String subjid) { + public void setSubjid(Integer subjid) { this.subjid = subjid; } } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectday.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectday.java index d200c62b..db73aeb0 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectday.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectday.java @@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull; public class TSubjectday { @Id @Column(name = "subjid", nullable = false, length = 32) - private String subjid; + private Integer subjid; @Id @Column(name = "ACCDATE", nullable = false, length = 8) @@ -54,7 +54,8 @@ public class TSubjectday { public TSubjectday() { } - public TSubjectday(String accdate, String subjno, Integer periodYear, Integer periodMonth, Double begindrbal, Double begincrbal, Double dramt, Double cramt, Double drbal, Double crbal) { + public TSubjectday(Integer subjid, String accdate, String subjno, Integer periodYear, Integer periodMonth, Double begindrbal, Double begincrbal, Double dramt, Double cramt, Double drbal, Double crbal, String tenantId) { + this.subjid = subjid; this.accdate = accdate; this.subjno = subjno; this.periodYear = periodYear; @@ -65,9 +66,11 @@ public class TSubjectday { this.cramt = cramt; this.drbal = drbal; this.crbal = crbal; + this.tenantId = tenantId; } - public TSubjectday(String accdate, String subjno, Integer periodYear, Integer periodMonth, Double begindrbal, Double begincrbal, Double dramt, Double cramt, Double drbal, Double crbal, String updtime) { + public TSubjectday(Integer subjid, String accdate, String subjno, Integer periodYear, Integer periodMonth, Double begindrbal, Double begincrbal, Double dramt, Double cramt, Double drbal, Double crbal, String updtime, String tenantId) { + this.subjid = subjid; this.accdate = accdate; this.subjno = subjno; this.periodYear = periodYear; @@ -79,6 +82,7 @@ public class TSubjectday { this.drbal = drbal; this.crbal = crbal; this.updtime = updtime; + this.tenantId = tenantId; } public String getAccdate() { @@ -177,11 +181,11 @@ public class TSubjectday { this.tenantId = tenantId; } - public String getSubjid() { + public Integer getSubjid() { return subjid; } - public void setSubjid(String subjid) { + public void setSubjid(Integer subjid) { this.subjid = subjid; } } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectdayPK.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectdayPK.java index ac70e2f9..e887b0c1 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectdayPK.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TSubjectdayPK.java @@ -11,7 +11,7 @@ public class TSubjectdayPK implements Serializable { @Id @Column(name = "SUBJID", nullable = false, length = 32) - private String subjid; + private Integer subjid; public String getAccdate() { return accdate; @@ -21,11 +21,11 @@ public class TSubjectdayPK implements Serializable { this.accdate = accdate; } - public String getSubjid() { + public Integer getSubjid() { return subjid; } - public void setSubjid(String subjid) { + public void setSubjid(Integer subjid) { this.subjid = subjid; } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntry.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntry.java index b3006d81..d2419583 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntry.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucherEntry.java @@ -52,7 +52,7 @@ public class TVoucherEntry { public TVoucherEntry() { } - public TVoucherEntry(Integer 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, String tenantId) { this.voucherid = voucherid; this.entryid = entryid; this.subjno = subjno; @@ -62,9 +62,10 @@ public class TVoucherEntry { this.summary = summary; this.oppsubjno = oppsubjno; this.oppaccno = oppaccno; + this.tenantId = tenantId; } - 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) { + 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, String tenantId) { this.voucherid = voucherid; this.entryid = entryid; this.subjno = subjno; @@ -77,6 +78,7 @@ public class TVoucherEntry { this.oppsubjno = oppsubjno; this.oppaccno = oppaccno; this.oppname = oppname; + this.tenantId = tenantId; } public Integer getVoucherid() { diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TVouchernoCtl.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TVouchernoCtl.java index f7ff6494..e2b9e3d4 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TVouchernoCtl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TVouchernoCtl.java @@ -1,15 +1,14 @@ package com.supwisdom.dlpay.framework.domain; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; import javax.validation.constraints.NotNull; @Entity @Table(name = "TB_VOUCHERNOCTL") public class TVouchernoCtl { @Id + @SequenceGenerator(name = "vouchertype", sequenceName = "SEQ_vouchertype", allocationSize = 1, initialValue = 100) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "vouchertype") @Column(name = "VOUCHERTYPE", nullable = false, precision = 2) private Integer vouchertype; @@ -28,10 +27,10 @@ public class TVouchernoCtl { public TVouchernoCtl() { } - public TVouchernoCtl(Integer vouchertype, Integer periodMonth, Integer voucherno) { - this.vouchertype = vouchertype; + public TVouchernoCtl(Integer periodMonth, Integer voucherno, String tenantId) { this.periodMonth = periodMonth; this.voucherno = voucherno; + this.tenantId = tenantId; } public Integer getVouchertype() { diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java index 8310435b..d1ff06dd 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/DayendSettleServiceImpl.java @@ -1,6 +1,7 @@ package com.supwisdom.dlpay.framework.service.impl; import com.supwisdom.dlpay.api.dao.DebitCreditDtlDao; +import com.supwisdom.dlpay.exception.TransactionException; import com.supwisdom.dlpay.framework.dao.*; import com.supwisdom.dlpay.framework.data.FSubjectInfoBean; import com.supwisdom.dlpay.framework.data.MerchBean; @@ -9,6 +10,7 @@ import com.supwisdom.dlpay.framework.data.VoucherTemp; import com.supwisdom.dlpay.framework.domain.*; import com.supwisdom.dlpay.framework.service.DayendSettleService; import com.supwisdom.dlpay.framework.service.SystemUtilService; +import com.supwisdom.dlpay.framework.tenant.TenantContext; import com.supwisdom.dlpay.framework.util.DateUtil; import com.supwisdom.dlpay.framework.util.MoneyUtil; import com.supwisdom.dlpay.framework.util.StringUtil; @@ -65,6 +67,7 @@ public class DayendSettleServiceImpl implements DayendSettleService { public TSettleLog doCreateSettleLog() { TSettleLog log = new TSettleLog(); log.setStarttime(systemUtilService.getSysdatetime().getHostdatetime()); + log.setTenantId(TenantContext.getTenantSchema()); return settleLogDao.save(log); } @@ -76,7 +79,7 @@ public class DayendSettleServiceImpl implements DayendSettleService { } private boolean doSwitchPeriod() throws Exception { - TPeriod period = periodDao.getTPeriodWithLock(periodYear, periodMonth); + TPeriod period = periodDao.getTPeriodWithLock(periodYear, periodMonth, TenantContext.getTenantSchema()); if (period.getSettleflag() == 1) { throw new Exception("月末结转已完成"); } @@ -90,7 +93,7 @@ public class DayendSettleServiceImpl implements DayendSettleService { periodMonth = periodMonth + 1; //year不变 } - TPeriod nextPerid = periodDao.getPeriod(periodYear, periodMonth); + TPeriod nextPerid = periodDao.getPeriod(periodYear, periodMonth, TenantContext.getTenantSchema()); if (null != nextPerid) { if (settledate != Integer.valueOf(nextPerid.getStartdate())) { throw new Exception("下一个会计期间的开始日期不正确"); @@ -109,25 +112,27 @@ public class DayendSettleServiceImpl implements DayendSettleService { nextPerid.setStartdate(startdate.toString()); nextPerid.setEnddate(enddate.toString()); nextPerid.setSettleflag(0); + nextPerid.setTenantId(TenantContext.getTenantSchema()); periodDao.save(nextPerid); //保存下个会计期间 } - settleCtlDao.updateSettlePeriod(periodYear, periodMonth); - vouchernoCtlDao.updateVoucherno(periodMonth, 0); + settleCtlDao.updateSettlePeriodByTenantid(periodYear, periodMonth, TenantContext.getTenantSchema()); + vouchernoCtlDao.updateVouchernoByTenantid(periodMonth, 0, TenantContext.getTenantSchema()); return true; } private void saveVoucher(VoucherTemp voucherTemp) { TVoucher voucher = new TVoucher(periodYear, periodMonth, 0, settledate, settledate, voucherTemp.getTranscnt(), Math.abs(voucherTemp.getTransamt()), voucherTemp.getSummary(), "auto", hostdate); + voucher.setTenantId(TenantContext.getTenantSchema()); voucher = voucherDao.save(voucher); TVoucherEntry entry1; TVoucherEntry entry2; if (voucherTemp.getTransamt() >= 0) { - 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()); + entry1 = new TVoucherEntry(voucher.getVoucherid(), 1, voucherTemp.getDrsubjno(), voucherTemp.getDraccno(), Math.abs(voucherTemp.getTransamt()), 0D, voucherTemp.getSummary(), voucherTemp.getCrsubjno(), voucherTemp.getCraccno(), TenantContext.getTenantSchema()); + entry2 = new TVoucherEntry(voucher.getVoucherid(), 2, voucherTemp.getCrsubjno(), voucherTemp.getCraccno(), 0D, Math.abs(voucherTemp.getTransamt()), voucherTemp.getSummary(), voucherTemp.getDrsubjno(), voucherTemp.getDraccno(), TenantContext.getTenantSchema()); } else { - 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()); + entry1 = new TVoucherEntry(voucher.getVoucherid(), 1, voucherTemp.getDrsubjno(), voucherTemp.getDraccno(), 0D, Math.abs(voucherTemp.getTransamt()), voucherTemp.getSummary(), voucherTemp.getCrsubjno(), voucherTemp.getCraccno(), TenantContext.getTenantSchema()); + entry2 = new TVoucherEntry(voucher.getVoucherid(), 2, voucherTemp.getCrsubjno(), voucherTemp.getCraccno(), Math.abs(voucherTemp.getTransamt()), 0D, voucherTemp.getSummary(), voucherTemp.getDrsubjno(), voucherTemp.getDraccno(), TenantContext.getTenantSchema()); } voucherEntryDao.save(entry1); voucherEntryDao.save(entry2); @@ -135,7 +140,7 @@ public class DayendSettleServiceImpl implements DayendSettleService { @Override public boolean doDayendSettle() throws Exception { - TSettlectl tSettlectl = settleCtlDao.findByBooksetnoWithLock(1); + TSettlectl tSettlectl = settleCtlDao.findByTenantIdWithLock(TenantContext.getTenantSchema()); if (null == tSettlectl || null == tSettlectl.getBooksetno()) { throw new Exception("初始化错误,T_SETTLECTL 无初始化数据"); } @@ -149,38 +154,38 @@ public class DayendSettleServiceImpl implements DayendSettleService { lastsettday = Integer.valueOf(DateUtil.getNewDay(tSettlectl.getSettledate().toString(), -1)); if (settledate >= hostdate) { - throw new Exception("日终结算已完成"); + throw new TransactionException(-99, "日终结算已完成"); } - TPeriod period = periodDao.getPeriod(periodYear, periodMonth); + TPeriod period = periodDao.getPeriod(periodYear, periodMonth, TenantContext.getTenantSchema()); if (null == period) throw new Exception("year=[" + periodYear + "],month=[" + periodMonth + "] t_period not find "); if (settledate > Integer.valueOf(period.getEnddate())) { //月切 if (!doSwitchPeriod()) { - throw new Exception("月切失败"); + throw new TransactionException(-3, "月切失败"); } } //新增科目插入科目余额表(末级科目) - List newEndsubjectList = subjectDao.getNewSubject(); + List newEndsubjectList = subjectDao.getNewSubjectByTenantid(TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(newEndsubjectList)) { - for (String subjno : newEndsubjectList) { - TSubjectbal subjectbal = new TSubjectbal(subjno); + for (TSubject subject : newEndsubjectList) { + TSubjectbal subjectbal = new TSubjectbal(subject.getId(),subject.getSubjno(), subject.getTenantId()); subjectbalDao.save(subjectbal); } } - if (subjectDao.checkSettleSubject().getExisted() > 0) { + if (subjectDao.checkSettleSubjectByTenantid(TenantContext.getTenantSchema()).getExisted() > 0) { throw new Exception("初始化数据错误:科目余额表数据没有包含所有的科目余额"); } //删除未入账凭证 - if (voucherDao.checkExistUnpostVouhcer().getExisted() > 0) { - voucherEntryDao.deleteUnpostVoucherentry(); - voucherDao.deleteUnpostVoucher(); + if (voucherDao.checkExistUnpostVouhcer(TenantContext.getTenantSchema()).getExisted() > 0) { + voucherEntryDao.deleteUnpostVoucherentry(TenantContext.getTenantSchema()); + voucherDao.deleteUnpostVoucher(TenantContext.getTenantSchema()); } //用户交易凭证 - List userList = debitCreditDtlDao.getVoucherData(String.valueOf(settledate)); + List userList = debitCreditDtlDao.getVoucherData(String.valueOf(settledate), TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(userList)) { for (VoucherTemp temp : userList) { saveVoucher(temp); @@ -188,16 +193,16 @@ public class DayendSettleServiceImpl implements DayendSettleService { } //凭证号 - TVouchernoCtl vouchernoCtl = vouchernoCtlDao.getVoucherno(); + TVouchernoCtl vouchernoCtl = vouchernoCtlDao.getVouchernoByTenantid(TenantContext.getTenantSchema()); if (null == vouchernoCtl) { vouchernoCtl = new TVouchernoCtl(); - vouchernoCtl.setVouchertype(1); vouchernoCtl.setPeriodMonth(periodMonth); vouchernoCtl.setVoucherno(0); + vouchernoCtl.setTenantId(TenantContext.getTenantSchema()); vouchernoCtlDao.save(vouchernoCtl); } int voucherno = vouchernoCtl.getVoucherno(); - List voucherList = voucherDao.getSettleVouchers(); + List voucherList = voucherDao.getSettleVouchers(TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(voucherList)) { for (TVoucher voucher : voucherList) { voucherno++; @@ -211,24 +216,26 @@ public class DayendSettleServiceImpl implements DayendSettleService { Map v_merchbaldict = new HashMap(0); //根据商户昨天日结表生成当天日结表(交易前余额), 新增商户添加记录 - List lastShopaccdays = shopaccdayDao.getShopaccdayByAccdate(String.valueOf(lastsettday)); + List lastShopaccdays = shopaccdayDao.getShopaccdayByAccdate(String.valueOf(lastsettday), TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(lastShopaccdays)) { for (TShopaccday lastday : lastShopaccdays) { TShopaccday today = new TShopaccday(String.valueOf(settledate), lastday.getShopaccno(), periodYear, periodMonth, lastday.getBalance(), 0D, 0D, 0D); + today.setTenantId(lastday.getTenantId()); shopaccdayDao.save(today); v_merchbaldict.put(lastday.getShopaccno(), lastday.getBalance()); } } - List newShopaccs = shopaccDao.getNewShopacc(String.valueOf(lastsettday)); //新增商户 + List newShopaccs = shopaccDao.getNewShopacc(String.valueOf(lastsettday), TenantContext.getTenantSchema()); //新增商户 if(!StringUtil.isEmpty(newShopaccs)){ for(String accno:newShopaccs){ TShopaccday today = new TShopaccday(String.valueOf(settledate), accno, periodYear, periodMonth, 0D, 0D, 0D, 0D); + today.setTenantId(TenantContext.getTenantSchema()); shopaccdayDao.save(today); v_merchbaldict.put(accno, 0D); } } - List merchBeanList = voucherDao.getShopVoucherByAccdate(settledate); + List merchBeanList = voucherDao.getShopVoucherByAccdate(settledate, TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(merchBeanList)) { for (MerchBean merch : merchBeanList) { TShopaccday merchday = shopaccdayDao.getTShopaccdayById(String.valueOf(settledate), merch.getShopaccno()); @@ -240,34 +247,34 @@ public class DayendSettleServiceImpl implements DayendSettleService { shopaccdayDao.save(merchday); } } - shopaccdayDao.updateShopaccdayBalance(String.valueOf(settledate), systemUtilService.getSysdatetime().getHostdatetime()); //批量更新余额,商户日结表生成 + shopaccdayDao.updateShopaccdayBalance(String.valueOf(settledate), systemUtilService.getSysdatetime().getHostdatetime(), TenantContext.getTenantSchema()); //批量更新余额,商户日结表生成 //根据科目昨天日结表生成当天日结表(交易前借贷方余额),新增末级科目插入记录(交易前余额为科目贷方余额) - List lastSubjectDays = subjectdayDao.getAllByAccdate(String.valueOf(lastsettday)); + List lastSubjectDays = subjectdayDao.getAllByAccdate(String.valueOf(lastsettday), TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(lastSubjectDays)) { for (TSubjectday lastday : lastSubjectDays) { - TSubjectday today = new TSubjectday(String.valueOf(settledate), lastday.getSubjno(), periodYear, periodMonth, lastday.getDrbal(), lastday.getCrbal(), 0D, 0D, 0D, 0D); + TSubjectday today = new TSubjectday(lastday.getSubjid(),String.valueOf(settledate), lastday.getSubjno(), periodYear, periodMonth, lastday.getDrbal(), lastday.getCrbal(), 0D, 0D, 0D, 0D, lastday.getTenantId()); subjectdayDao.save(today); } } - List newSubjectBals = subjectbalDao.getUnsettleSubjectbal(String.valueOf(lastsettday)); + List newSubjectBals = subjectbalDao.getUnsettleSubjectbal(String.valueOf(lastsettday), TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(newSubjectBals)) { for (TSubjectbal newSubject : newSubjectBals) { - TSubjectday today = new TSubjectday(String.valueOf(settledate), newSubject.getSubjno(), periodYear, periodMonth, newSubject.getBegindrbal(), newSubject.getBegincrbal(), 0D, 0D, 0D, 0D); + TSubjectday today = new TSubjectday(newSubject.getSubjid(),String.valueOf(settledate), newSubject.getSubjno(), periodYear, periodMonth, newSubject.getBegindrbal(), newSubject.getBegincrbal(), 0D, 0D, 0D, 0D, newSubject.getTenantId()); subjectdayDao.save(today); } } - List newFSubjnos = subjectDao.getNewSubjnos(String.valueOf(settledate)); //新增非末级科目 + List newFSubjnos = subjectDao.getNewSubjnos(String.valueOf(settledate), TenantContext.getTenantSchema()); //新增非末级科目 if (!StringUtil.isEmpty(newFSubjnos)) { - for (String subjno : newFSubjnos) { + for (TSubject subj : newFSubjnos) { double beginDrbal = 0; double beginCrbal = 0; - MerchBean balInfo = subjectbalDao.getSubjectInfo(subjno); //统计下级所有科目的交易前余额 + MerchBean balInfo = subjectbalDao.getSubjectInfo(subj.getSubjno(), subj.getTenantId()); //统计下级所有科目的交易前余额 if (null != balInfo) { beginDrbal = (balInfo.getDramt() == null ? 0 : balInfo.getDramt().doubleValue()); beginCrbal = (balInfo.getCramt() == null ? 0 : balInfo.getCramt().doubleValue()); } - TSubjectday today = new TSubjectday(String.valueOf(settledate), subjno, periodYear, periodMonth, beginDrbal, beginCrbal, 0D, 0D, 0D, 0D); + TSubjectday today = new TSubjectday(subj.getId(),String.valueOf(settledate), subj.getSubjno(), periodYear, periodMonth, beginDrbal, beginCrbal, 0D, 0D, 0D, 0D, subj.getTenantId()); subjectdayDao.save(today); } } @@ -275,22 +282,22 @@ public class DayendSettleServiceImpl implements DayendSettleService { //初始化末级科目期初余额(包含商户科目) Map v_subjbaldict = new HashMap(0); Map v_subjbalflagdict = new HashMap(0); - List subjectList = subjectdayDao.getEndSubjectbalInfos(String.valueOf(settledate)); + List subjectList = subjectdayDao.getEndSubjectbalInfos(String.valueOf(settledate), TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(subjectList)) { for (MerchBean bean : subjectList) { v_subjbaldict.put(bean.getShopaccno(), MoneyUtil.formatYuan(bean.getDramt() + bean.getCramt())); } } - List subjInfoList = subjectbalDao.getSubjectbalAndFlag(); + List subjInfoList = subjectbalDao.getSubjectbalAndFlag(TenantContext.getTenantSchema()); for (SubjectInfoBean subj : subjInfoList) { - TSubjectday tSubjectday = subjectdayDao.getSubjectDayById(String.valueOf(settledate), subj.getSubjno()); + TSubjectday tSubjectday = subjectdayDao.getSubjectDayById(String.valueOf(settledate), subj.getSubjno(), TenantContext.getTenantSchema()); if (null == tSubjectday) { throw new Exception("科目日结表无此科目记录[" + subj.getSubjno() + "]"); } v_subjbalflagdict.put(subj.getSubjno(), subj.getBalflag()); - MerchBean suminfo = voucherDao.getSettleSuminfo(settledate, subj.getSubjno()); + MerchBean suminfo = voucherDao.getSettleSuminfo(settledate, subj.getSubjno(), TenantContext.getTenantSchema()); double sumDramt = ((null == suminfo || null == suminfo.getDramt()) ? 0 : suminfo.getDramt().doubleValue()); double sumCramt = ((null == suminfo || null == suminfo.getCramt()) ? 0 : suminfo.getCramt().doubleValue()); tSubjectday.setDramt(sumDramt); @@ -304,9 +311,9 @@ public class DayendSettleServiceImpl implements DayendSettleService { subjectdayDao.save(tSubjectday); } //根据二级更新一级科目日结 - List parentSubject = subjectdayDao.getParentSubjectday(String.valueOf(settledate)); + List parentSubject = subjectdayDao.getParentSubjectday(String.valueOf(settledate), TenantContext.getTenantSchema()); for (TSubjectday fsub : parentSubject) { - FSubjectInfoBean sumInfo = subjectdayDao.getParentSumInfo(String.valueOf(settledate), fsub.getSubjno()); + FSubjectInfoBean sumInfo = subjectdayDao.getParentSumInfo(String.valueOf(settledate), fsub.getSubjno(), fsub.getTenantId()); fsub.setBegindrbal((null == sumInfo || null == sumInfo.getBegindrbal()) ? 0D : sumInfo.getBegindrbal()); fsub.setBegincrbal((null == sumInfo || null == sumInfo.getBegincrbal()) ? 0D : sumInfo.getBegincrbal()); fsub.setDramt((null == sumInfo || null == sumInfo.getDramt()) ? 0D : sumInfo.getDramt()); @@ -318,7 +325,7 @@ public class DayendSettleServiceImpl implements DayendSettleService { } //批量更新凭证明细中商户或科目账户的余额 - List entryList = voucherEntryDao.getVoucherEntryByVoucherdate(settledate); + List entryList = voucherEntryDao.getVoucherEntryByVoucherdate(settledate, TenantContext.getTenantSchema()); if (!StringUtil.isEmpty(entryList)) { for (TVoucherEntry vce : entryList) { if (Subject.SUBJNO_MACHANT_INCOME.equals(vce.getSubjno())) { @@ -331,7 +338,7 @@ public class DayendSettleServiceImpl implements DayendSettleService { if (Subject.SUBJNO_MACHANT_INCOME.equals(vce.getOppsubjno())) { vce.setOppname(shopaccDao.getShopname(vce.getOppaccno())); } else { - vce.setOppname(subjectDao.getSubjectname(vce.getOppsubjno())); + vce.setOppname(subjectDao.getSubjectname(vce.getOppsubjno(), vce.getTenantId())); } voucherEntryDao.save(vce); Double befMerchbal = v_subjbaldict.get(vce.getSubjno()); @@ -352,7 +359,7 @@ public class DayendSettleServiceImpl implements DayendSettleService { if (Subject.SUBJNO_MACHANT_INCOME.equals(vce.getOppsubjno())) { vce.setOppname(shopaccDao.getShopname(vce.getOppaccno())); } else { - vce.setOppname(subjectDao.getSubjectname(vce.getOppsubjno())); + vce.setOppname(subjectDao.getSubjectname(vce.getOppsubjno(), vce.getTenantId())); } voucherEntryDao.save(vce); } @@ -374,11 +381,11 @@ public class DayendSettleServiceImpl implements DayendSettleService { //核算科目日结表科目余额和凭证明细余额是否一致 for (String subjno : v_subjbaldict.keySet()) { - TSubjectday tSubjectday = subjectdayDao.getSubjectDayById(String.valueOf(settledate), subjno); + TSubjectday tSubjectday = subjectdayDao.getSubjectDayById(String.valueOf(settledate), subjno, TenantContext.getTenantSchema()); if (!MoneyUtil.moneyEqual(v_subjbaldict.get(subjno), tSubjectday.getDrbal() + tSubjectday.getCrbal())) { throw new Exception("结算后检查失败:科目日结表期末余额不等,科目号[" + subjno + "],科目余额[" + (tSubjectday.getDrbal() + tSubjectday.getCrbal()) + "],凭证科目余额[" + v_subjbaldict.get(subjno) + "]"); } - TSubjectbal tSubjectbal = subjectbalDao.getOne(subjno); + TSubjectbal tSubjectbal = subjectbalDao.getBySubjnoAndTenantId(subjno, tSubjectday.getTenantId()); tSubjectbal.setBegindrbal(tSubjectday.getBegindrbal()); tSubjectbal.setBegincrbal(tSubjectday.getBegincrbal()); tSubjectbal.setDramt(tSubjectday.getDramt()); @@ -390,8 +397,8 @@ public class DayendSettleServiceImpl implements DayendSettleService { } //核对商户日结表余额表和科目日结表商户余额是否一致 - TSubjectday shopSubjectday = subjectdayDao.getSubjectDayById(String.valueOf(settledate), Subject.SUBJNO_MACHANT_INCOME); - Double merchbal = shopaccdayDao.getSumBalance(String.valueOf(settledate)); + TSubjectday shopSubjectday = subjectdayDao.getSubjectDayById(String.valueOf(settledate), Subject.SUBJNO_MACHANT_INCOME, TenantContext.getTenantSchema()); + Double merchbal = shopaccdayDao.getSumBalance(String.valueOf(settledate), TenantContext.getTenantSchema()); // double shopSubbal = (shopSubjectday == null ? 0 : shopSubjectday.getCrbal()); double shopMerchbal = (merchbal == null ? 0 : merchbal); if (!MoneyUtil.moneyEqual(shopSubbal, shopMerchbal)) { @@ -399,7 +406,7 @@ public class DayendSettleServiceImpl implements DayendSettleService { } //核算一级科目余额是否平衡 - FSubjectInfoBean allParentSubjbal = subjectdayDao.getAllParentSubjectSumInfo(String.valueOf(settledate)); + FSubjectInfoBean allParentSubjbal = subjectdayDao.getAllParentSubjectSumInfo(String.valueOf(settledate), TenantContext.getTenantSchema()); if (!MoneyUtil.moneyEqual(allParentSubjbal.getBegindrbal(), allParentSubjbal.getBegincrbal())) { throw new Exception("结算后检查失败:一级科目余额表期初余额不平衡,借方[" + allParentSubjbal.getBegindrbal() + "],贷方[" + allParentSubjbal.getBegincrbal() + "]"); } @@ -410,8 +417,8 @@ public class DayendSettleServiceImpl implements DayendSettleService { throw new Exception("结算后检查失败:一级科目余额表期末额不平衡,借方[" + allParentSubjbal.getDrbal() + "]贷方[" + allParentSubjbal.getCrbal() + "]"); } //校验科目余额表的balflag=1的总期末余额和balflag=2的总期末余额是否一致 - Double balflag_1_sumbal = subjectbalDao.getSumEndsubjectBalByEndflag(1); - Double balflag_2_sumbal = subjectbalDao.getSumEndsubjectBalByEndflag(2); + Double balflag_1_sumbal = subjectbalDao.getSumEndsubjectBalByEndflag(1, TenantContext.getTenantSchema()); + Double balflag_2_sumbal = subjectbalDao.getSumEndsubjectBalByEndflag(2, TenantContext.getTenantSchema()); if (null == balflag_1_sumbal || null == balflag_1_sumbal) throw new Exception("结算后检查失败:科目余额表无数据"); if (!MoneyUtil.moneyEqual(balflag_1_sumbal, balflag_2_sumbal)) { throw new Exception("结算后检查失败:科目余额表期末余额不平衡,借方[" + balflag_1_sumbal + "],贷方[" + balflag_2_sumbal + "]"); diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/SystemUtilServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/SystemUtilServiceImpl.java index baf8449d..d67a64dc 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/SystemUtilServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/service/impl/SystemUtilServiceImpl.java @@ -84,7 +84,7 @@ public class SystemUtilServiceImpl implements SystemUtilService { @Override public String getTranscodeName(int transocde, String defaultValue) { - TTranscode tTranscode = transcodeDao.getOne(transocde); + TTranscode tTranscode = transcodeDao.getByTranscode(transocde); if (null != tTranscode && !StringUtil.isEmpty(tTranscode.getTransname())) { return tTranscode.getTransname(); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/bean/SettleLogSearchBean.java b/payapi/src/main/java/com/supwisdom/dlpay/system/bean/SettleLogSearchBean.java new file mode 100644 index 00000000..082c2ead --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/bean/SettleLogSearchBean.java @@ -0,0 +1,40 @@ +package com.supwisdom.dlpay.system.bean; + +public class SettleLogSearchBean { + private Integer page; + private Integer limit; + private String accdate; + private String status; + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public String getAccdate() { + return accdate; + } + + public void setAccdate(String accdate) { + this.accdate = accdate; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/controller/SettlementLogController.java b/payapi/src/main/java/com/supwisdom/dlpay/system/controller/SettlementLogController.java new file mode 100644 index 00000000..296af29c --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/controller/SettlementLogController.java @@ -0,0 +1,56 @@ +package com.supwisdom.dlpay.system.controller; + +import com.supwisdom.dlpay.api.bean.JsonResult; +import com.supwisdom.dlpay.framework.domain.TSettleLog; +import com.supwisdom.dlpay.framework.domain.TSyspara; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.framework.util.WebConstant; +import com.supwisdom.dlpay.system.bean.SettleLogSearchBean; +import com.supwisdom.dlpay.system.service.SettlementLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +/** + * 结算日志 + * */ +@Controller +public class SettlementLogController { + @Autowired + private SettlementLogService settlementLogService; + + @GetMapping("/settlelog/index") + public String userdtlView() { + return "system/settlelog/index"; + } + + @GetMapping("/settlelog/datalist") + @PreAuthorize("hasPermission('/settlelog/index','')") + @ResponseBody + public PageResult searchUserdtlPage(@ModelAttribute SettleLogSearchBean searchBean) { + try { + Integer pageNo = searchBean.getPage(); + Integer pageSize = searchBean.getLimit(); + if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; + if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; + return settlementLogService.getSettleLogPage(searchBean,pageNo,pageSize); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); + } + } + + @PostMapping("/settlelog/dosettle") + @PreAuthorize("hasPermission('/settlelog/dosettle','')") + @ResponseBody + public JsonResult doSettlement() { + try { + return JsonResult.error("暂不支持调用结算执行逻辑"); + } catch (Exception e) { + e.printStackTrace(); + return JsonResult.error("系统处理异常").put("exception", e); + } + } + +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/SettlementLogService.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/SettlementLogService.java new file mode 100644 index 00000000..0dfb0315 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/SettlementLogService.java @@ -0,0 +1,11 @@ +package com.supwisdom.dlpay.system.service; + +import com.supwisdom.dlpay.framework.domain.TSettleLog; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.system.bean.SettleLogSearchBean; +import org.springframework.transaction.annotation.Transactional; + +public interface SettlementLogService { + @Transactional(rollbackFor = Exception.class, readOnly = true) + PageResult getSettleLogPage(SettleLogSearchBean searchBean, int pageNo, int pageSize); +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettlementLogServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettlementLogServiceImpl.java new file mode 100644 index 00000000..f5cd51f9 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettlementLogServiceImpl.java @@ -0,0 +1,56 @@ +package com.supwisdom.dlpay.system.service.impl; + +import com.supwisdom.dlpay.framework.dao.SettleLogDao; +import com.supwisdom.dlpay.framework.domain.TSettleLog; +import com.supwisdom.dlpay.framework.util.DateUtil; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.framework.util.StringUtil; +import com.supwisdom.dlpay.system.bean.SettleLogSearchBean; +import com.supwisdom.dlpay.system.service.SettlementLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.util.ArrayList; +import java.util.List; + +@Service +public class SettlementLogServiceImpl implements SettlementLogService { + @Autowired + private SettleLogDao settleLogDao; + + + @Override + public PageResult getSettleLogPage(SettleLogSearchBean searchBean, int pageNo, int pageSize) { + Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by(Sort.Direction.DESC, "starttime")); + Page page = settleLogDao.findAll(new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + if (!StringUtil.isEmpty(searchBean.getAccdate())) { + predicates.add(criteriaBuilder.ge(root.get("starttime").as(Long.class), Long.valueOf(DateUtil.unParseToDateFormat(searchBean.getAccdate()) + "000000"))); + predicates.add(criteriaBuilder.le(root.get("endtime").as(Long.class), Long.valueOf(DateUtil.unParseToDateFormat(searchBean.getAccdate()) + "235959"))); + } + + if (!StringUtil.isEmpty(searchBean.getStatus())) { + if ("success".equalsIgnoreCase(searchBean.getStatus())) { + predicates.add(criteriaBuilder.equal(root.get("errcode").as(String.class), "0")); + } else { + predicates.add(criteriaBuilder.notEqual(root.get("errcode").as(String.class), "0")); + predicates.add(criteriaBuilder.notEqual(root.get("errcode").as(String.class), "-99")); + } + } + return criteriaBuilder.and(predicates.toArray(new Predicate[0])); + } + }, pageable); + return new PageResult<>(page); + } +} diff --git a/payapi/src/main/resources/data-postgresql.sql b/payapi/src/main/resources/data-postgresql.sql index 89ba0eee..4298c90a 100644 --- a/payapi/src/main/resources/data-postgresql.sql +++ b/payapi/src/main/resources/data-postgresql.sql @@ -1,6 +1,6 @@ --pg-- -INSERT INTO "tb_period" ("period_year", "period_month", "startdate", "enddate", "settleflag" , "tenantid") -VALUES (to_number(to_char(CURRENT_TIMESTAMP,'yyyy'),'9999'),to_number(to_char(CURRENT_TIMESTAMP,'MM'),'99'), to_char(CURRENT_TIMESTAMP,'yyyyMM')||'01', to_char((to_date(to_char(CURRENT_TIMESTAMP+'1 month','yyyyMM')||'01','yyyyMMdd')-1)::Timestamp,'yyyyMMdd'), 0, '{tenantid}'); +INSERT INTO "tb_period" ("id", "period_year", "period_month", "startdate", "enddate", "settleflag" , "tenantid") +VALUES ('8a53b7826c65b925016c65bfa7c3001c',to_number(to_char(CURRENT_TIMESTAMP,'yyyy'),'9999'),to_number(to_char(CURRENT_TIMESTAMP,'MM'),'99'), to_char(CURRENT_TIMESTAMP,'yyyyMM')||'01', to_char((to_date(to_char(CURRENT_TIMESTAMP+'1 month','yyyyMM')||'01','yyyyMMdd')-1)::Timestamp,'yyyyMMdd'), 0, '{tenantid}'); insert into TB_SETTLECTL(BOOKSETNO,PERIODYEAR,PERIODMONTH,STATDATE,SETTLEDATE,STATUS,updtime, "tenantid") values (1,to_number(to_char(CURRENT_TIMESTAMP,'yyyy'),'9999'),to_number(to_char(CURRENT_TIMESTAMP,'MM'),'99'),to_number(to_char(CURRENT_TIMESTAMP,'yyyyMMdd'),'99999999'),to_number(to_char(CURRENT_TIMESTAMP,'yyyyMMdd'),'99999999'),0,to_char(CURRENT_TIMESTAMP,'yyyyMMddhh24miss'), '{tenantid}'); diff --git a/payapi/src/main/resources/data.sql b/payapi/src/main/resources/data.sql index c1771156..80a95a29 100644 --- a/payapi/src/main/resources/data.sql +++ b/payapi/src/main/resources/data.sql @@ -63,6 +63,8 @@ INSERT INTO "tb_function" ("id", "createtime", "isleaf", "lastsaved", "menuicon" VALUES (30, NULL, 1, NULL, '', '/report/subjectdetail', '科目明细账', 2, 20, '{tenantid}'); INSERT INTO "tb_function" ("id", "createtime", "isleaf", "lastsaved", "menuicon", "menuurl", "name", "ordernum", "parentid", tenantid) VALUES (31, NULL, 1, NULL, '', '/report/shopbusiness', '商户营业情况表', 3, 20, '{tenantid}'); +INSERT INTO "tb_function" ("id", "createtime", "isleaf", "lastsaved", "menuicon", "menuurl", "name", "ordernum", "parentid", tenantid) +VALUES (32, NULL, 1, NULL, '', '/settlelog/index', '结算日志', 5, 3, '{tenantid}'); INSERT INTO "tb_role_function" ("id", "functionid", "roleid", tenantid) @@ -117,6 +119,8 @@ INSERT INTO "tb_role_function" ("id", "functionid", "roleid", tenantid) VALUES ('ff8080816b7947ed016b79557736007b', 12, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); INSERT INTO "tb_role_function" ("id", "functionid", "roleid", tenantid) VALUES ('ff8080816b7947ed016b795577370081', 18, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); +INSERT INTO "tb_role_function" ("id", "functionid", "roleid", tenantid) +VALUES ('ff8080816c8468e8016c846d7a570017', 32, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) VALUES (4, '1', 4, '添加功能', '/function/add', '{tenantid}'); @@ -244,6 +248,10 @@ INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) VALUES (74, '', 31, '查询', '/report/shopbusiness', '{tenantid}'); INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) VALUES (76, '', 18, '新增', '/param/addsourcetype', '{tenantid}'); +INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) +VALUES (77, '', 32, '查询', '/settlelog/index', '{tenantid}'); +INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) +VALUES (78, '', 32, '查询', '/settlelog/dosettle', '{tenantid}'); INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", tenantid) VALUES ('ff8080816b7947ed016b795577300036', 16, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); @@ -371,7 +379,10 @@ INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", "tenantid VALUES ('ff8080816bbb130c016bbb6ea2f700c9', 76, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", "tenantid") VALUES ('ff8080816bbb130c016bbb6ea2f600b3', 26, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); - +INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", "tenantid") +VALUES ('ff8080816c8468e8016c846d7a5d0018', 77, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); +INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", "tenantid") +VALUES ('ff8080816c85279d016c852aa829000d', 78, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); INSERT INTO "tb_subject" ("subjid","subjno", "balflag", "displayflag", "endflag", "fsubjno", "opendate", "subjlevel", "subjname", "subjtype", "tenantid") VALUES (1, '1001', 1, 'y', 1, NULL, 20190430, 1, '库存现金', 1, '{tenantid}'); diff --git a/payapi/src/main/resources/templates/system/settlelog/index.html b/payapi/src/main/resources/templates/system/settlelog/index.html new file mode 100644 index 00000000..3ba86e15 --- /dev/null +++ b/payapi/src/main/resources/templates/system/settlelog/index.html @@ -0,0 +1,152 @@ +
+
+

结算日志

+ + 系统中心 + 结算日志 + +
+
+
+ 搜索: +   + + + + +
+
+
+
+ + \ No newline at end of file -- 2.17.1