Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
6a18d012
Commit
6a18d012
authored
Jun 21, 2018
by
neo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev] financeImportData datacheck impl
parent
b9b317ba
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
830 additions
and
7 deletions
+830
-7
Constant.java
...api/src/main/java/pwc/taxtech/atms/constant/Constant.java
+16
-7
VatErpImportValidation.java
...ava/pwc/taxtech/atms/constant/VatErpImportValidation.java
+51
-0
ErpCheckType.java
...in/java/pwc/taxtech/atms/constant/enums/ErpCheckType.java
+70
-0
ImageType.java
.../main/java/pwc/taxtech/atms/constant/enums/ImageType.java
+25
-0
FinanceDataImportController.java
.../taxtech/atms/controller/FinanceDataImportController.java
+27
-0
DataCheckDto.java
...c/main/java/pwc/taxtech/atms/dto/vatdto/DataCheckDto.java
+85
-0
VoucherAccountMto.java
...n/java/pwc/taxtech/atms/dto/vatdto/VoucherAccountMto.java
+31
-0
VoucherBalanceDto.java
...n/java/pwc/taxtech/atms/dto/vatdto/VoucherBalanceDto.java
+114
-0
ValidationInfoMapper.java
...n/java/pwc/taxtech/atms/vat/dao/ValidationInfoMapper.java
+58
-0
FinanceDataImportService.java
...wc/taxtech/atms/vat/service/FinanceDataImportService.java
+10
-0
FinanceDataImportServiceImpl.java
...h/atms/vat/service/impl/FinanceDataImportServiceImpl.java
+343
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/constant/Constant.java
View file @
6a18d012
...
...
@@ -23,14 +23,22 @@ public final class Constant {
public
static
final
UUID
USER_ID_FOR_UPLOAD
=
UUID
.
fromString
(
"64D39CF7-467E-4414-B334-AA4B55A4E2B3"
);
public
static
final
String
UPLOAD_FOLDER_NAME
=
"Upload"
;
public
static
final
String
CURRENT_USER_HOME
=
"~"
;
public
static
final
String
CURRENT_USER_UPLOAD_FOLDER
=
CURRENT_USER_HOME
+
File
.
separator
+
UPLOAD_FOLDER_NAME
;
public
static
final
String
UPLOAD_FOLDER_NAME
=
"Upload"
;
public
static
final
String
CURRENT_USER_HOME
=
"~"
;
public
static
final
String
CURRENT_USER_UPLOAD_FOLDER
=
CURRENT_USER_HOME
+
File
.
separator
+
UPLOAD_FOLDER_NAME
;
public
static
final
String
CURRENT_IMAGE_PATH
=
CURRENT_USER_HOME
+
File
.
separator
+
"Resource"
+
File
.
separator
+
"Images"
;
public
static
final
String
IMAGE_PATH_INFORMATION
=
CURRENT_IMAGE_PATH
+
File
.
separator
+
"information.png"
;
public
static
final
String
IMAGE_PATH_ERROR
=
CURRENT_IMAGE_PATH
+
File
.
separator
+
"error.png"
;
public
static
final
String
IMAGE_PATH_SUCCESS
=
CURRENT_IMAGE_PATH
+
File
.
separator
+
"success.png"
;
public
static
final
String
IMAGE_PATH_WARN
=
CURRENT_IMAGE_PATH
+
File
.
separator
+
"warning1.png"
;
public
static
final
boolean
DEFAULT_RESULT
=
true
;
public
static
final
int
FIRST_OR_DEFAULT
=
0
;
public
static
final
boolean
DEFAULT_RESULT
=
true
;
public
static
final
int
HEADER_ROW_INDEX
=
0
;
public
static
final
boolean
DEFAULT_HAS_HEADER
=
true
;
public
static
final
int
FIRST_OR_DEFAULT
=
0
;
public
static
final
int
HEADER_ROW_INDEX
=
0
;
public
static
final
boolean
DEFAULT_HAS_HEADER
=
true
;
public
static
final
String
IMAGE_FORMART_
=
"png"
;
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/constant/VatErpImportValidation.java
View file @
6a18d012
...
...
@@ -6,4 +6,55 @@ public class VatErpImportValidation {
public
static
final
String
BalanceTb
=
"Balance"
;
public
static
final
String
AccountRemapTb
=
"AccountRemap"
;
public
static
final
String
VoucherTbName
=
"Voucher"
;
public
static
final
String
Const_ComBalanceAcctValidate
=
"试算平衡表科目存在于企业科目列表中"
;
public
static
final
String
Const_ComBalanceAcctUnValidate
=
"试算平衡表中出现的科目不在科目表中"
;
public
static
final
String
Const_ComBalanceAcctUnValidate_Tips
=
"请在企业科目中补全该科目信息。"
;
public
static
final
String
Const_VoucherAcctValidate
=
"凭证表中科目存在于企业科目列表中"
;
public
static
final
String
Const_VoucherAcctUnValidate
=
"凭证表中出现的科目不在科目表中"
;
public
static
final
String
Const_VoucherAcctUnValidate_Tips
=
"请在企业科目中补全该科目信息。"
;
public
static
final
String
Const_VSingleDebitCreditValidate
=
"凭证表中凭证借贷平衡"
;
public
static
final
String
Const_VSingleDebitCreditUnValidate
=
"凭证表中凭证借贷不平衡"
;
public
static
final
String
Const_VSingleDebitCreditUnValidate_Tips
=
"凭证借贷不平衡会导致系统计算所得的试算平衡表也借贷不平衡。"
;
public
static
final
String
Const_VEmptyCheckValidateItemID
=
"凭证表中凭证分录号完整"
;
public
static
final
String
Const_VEmptyCheckUnValidateItemID
=
"凭证表中凭证分录号为空"
;
public
static
final
String
Const_VEmptyCheckUnValidateItemID_Tips
=
"凭证分录号为空 ,系统无法正确判断凭证是否重复。"
;
public
static
final
String
Const_VEmptyCheckValidateGroup
=
"凭证表中凭证类型完整"
;
public
static
final
String
Const_VEmptyCheckUnValidateGroup
=
"凭证表中凭证类型为空"
;
public
static
final
String
Const_VEmptyCheckUnValidateGroup_Tips
=
"凭证类型为空,系统无法正确判断此分录属于哪张凭证,所有类型为空的会作为同一张凭证对待。"
;
public
static
final
String
Const_VEmptyCheckValidateAcctCode
=
"凭证表中科目代码完整"
;
public
static
final
String
Const_VEmptyCheckUnValidateAcctCode
=
"凭证表中科目代码为空"
;
public
static
final
String
Const_VEmptyCheckUnValidateAcctCode_Tips
=
"凭证科目代码为空,系统会在后续的所有计算中忽略此分录。"
;
public
static
final
String
Const_VEmptyCheckValidateSummary
=
"凭证表中凭证摘要完整"
;
public
static
final
String
Const_VEmptyCheckUnValidateSummary
=
"凭证表中凭证摘要为空"
;
public
static
final
String
Const_VEmptyCheckUnValidateSummary_Tips
=
"凭证摘要为空,不符合财务准则,查看明细时,不易识别分录目的。"
;
public
static
final
String
Const_AcctBegBalAcctLevelValidate
=
"试算平衡表中期初余额上下级平衡"
;
public
static
final
String
Const_AcctBegBalAcctLevelUnValidate
=
"试算平衡表中期初余额上下级不平衡"
;
public
static
final
String
Const_AcctBegBalAcctLevelUnValidate_Tips
=
"期初余额不正确会导致后续报表或分析的不准确。"
;
public
static
final
String
Const_BegBalValidate
=
"试算平衡表中期初余额借贷平衡"
;
public
static
final
String
Const_BegBalUnValidate
=
"试算平衡表中期初余额借贷不平衡"
;
public
static
final
String
Const_BegBalUnValidate_Tips
=
"期初余额不正确会导致后续报表或分析的不准确。"
;
public
static
final
String
Const_CompCustEndBalValidate
=
"系统计算所得的试算平衡表期末余额与导入的一致"
;
public
static
final
String
Const_CompCustEndBalUnValidate
=
"系统计算所得的试算平衡表期末余额与导入的不一致"
;
public
static
final
String
Const_CompCustAmountValidate
=
"系统计算所得的试算平衡表期间发生额与导入的一致"
;
public
static
final
String
Const_CompCustAmountUnValidate
=
"系统计算所得的试算平衡表期间发生额与导入的不一致"
;
public
static
final
String
Const_CompCustBegBalValidate
=
"系统计算所得的试算平衡表期初余额与导入的一致"
;
public
static
final
String
Const_CompCustBegBalUnValidate
=
"系统计算所得的试算平衡表期初余额与导入的不一致"
;
public
static
final
String
Const_BegEndBalValidate
=
"系统计算所得的上月期末与导入的本月期初一致"
;
public
static
final
String
Const_BegEndBalUnValidate
=
"系统计算所得的上月期末与导入的本月期初不一致"
;
public
static
final
String
Const_JournalEntryDebitCreditUnValidate
=
"凭证借贷不平衡"
;
public
static
final
String
Const_JournalEntrySummaryEmptyUnValidate
=
"凭证摘要为空"
;
public
static
final
String
Const_AccountMapping_NotMapStd
=
"没有对应标准科目"
;
public
static
final
String
Const_AccountMapping_NotMapStd_Tips
=
"没有对应标准科目会导致后续报表不准确"
;
}
atms-api/src/main/java/pwc/taxtech/atms/constant/enums/ErpCheckType.java
0 → 100644
View file @
6a18d012
package
pwc
.
taxtech
.
atms
.
constant
.
enums
;
public
enum
ErpCheckType
{
Success
(
0
),
ComBalanceAcctUnValidate
(
1
),
//Const_ComBalanceAcctUnValidate (")试算平衡表中出现的科目不在科目表中";
VoucherAcctValidate
(
2
),
// Const_VoucherAcctUnValidate (")凭证表中出现的科目不在科目表中";
VSingleDebitCreditUnValidate
(
3
),
//Const_VSingleDebitCreditUnValidate (")凭证表中凭证借贷不平衡";
VEmptyCheckUnValidateItemID
(
4
),
//Const_VEmptyCheckUnValidateItemID (")凭证表中凭证分录号为空";
VEmptyCheckUnValidateGroup
(
5
),
//Const_VEmptyCheckUnValidateGroup (")凭证表中凭证类型为空";
VEmptyCheckUnValidateAcctCode
(
6
),
//Const_VEmptyCheckUnValidateAcctCode (")凭证表中科目代码为空";
VEmptyCheckUnValidateSummary
(
7
),
//Const_VEmptyCheckUnValidateSummary (")凭证表中凭证摘要为空";
AcctBegBalAcctLevelUnValidate
(
8
),
// Const_AcctBegBalAcctLevelUnValidate (")试算平衡表中期初余额上下级不平衡";
BegBalUnValidate
(
9
),
//Const_BegBalUnValidate (")试算平衡表中期初余额借贷不平衡";
CompCustEndBalUnValidate
(
10
),
//Const_CompCustEndBalUnValidate (")系统计算所得的试算平衡表期末余额与导入的不一致";
CompCustAmountUnValidate
(
11
),
//Const_CompCustAmountUnValidate (")系统计算所得的试算平衡表期间发生与导入的不一致";
CompCustBegBalUnValidate
(
12
),
//Const_CompCustBegBalUnValidate (")系统计算所得的试算平衡表期初余额与导入的不一致";
BegEndBalUnValidate
(
13
),
//Const_BegEndBalUnValidate (")系统计算所得的上月期末与导入的本月期初不一致";
DuplicatedVoucher
(
14
),
//Voucher重复数据检查
DuplicatedTb
(
15
),
CustomInvoice_DuplicatePayNum
(
20
),
//海关清单:海关缴款书号码重复
Tb_NoAcctCode
(
30
),
//Tb验证 科目不在科目表中
Tb_PeriodBalance
(
31
),
//本月期初(月期末 )
Tb_BegBalDebitAndCreditBanlace
(
32
),
//期初余额借贷平衡
Tb_BegBalUpAndDownBanlace
(
33
),
//期初余额上下级平衡
Tb_CurentDebitAndCreditBanlace
(
34
),
//发生额借贷平衡
Tb_CurrentUpAndDownBanlace
(
35
),
//发生额上下级平衡
Tb_EndBalDebitAndCreditBanlace
(
36
),
//期末借贷平衡
Tb_EndBalUpAndDownBanlace
(
37
),
//期末上下级平衡
Tb_CurrentBalance
(
38
),
//期末(初)+(借-贷)*方向
Tb_DuplicatedData
(
39
),
//重复数据
Mapping_DuplicatedData
(
45
),
//重复数据
JE_AcctInvalid
(
50
),
//凭证表中的科目不在科目表中
JE_DebitAndCreditBanlace
(
51
),
//凭证借贷平衡
JE_DuplicatedData
(
52
),
//重复数据
JE_SummaryEmpty
(
53
),
//摘要为空
JE_GroupEmpty
(
53
),
//凭证类型为空
JE_ItemIdEmpty
(
54
),
//分录号为空
Invoice_DuplicatedData
(
60
),
//进项发票汇总重复
Invoice_ErrorData
(
61
),
//进项发票信息错误
Invoice_CertificationResultError
(
62
),
//进项发票认证结果错误
InvoiceItem_NotHaveTotalInvoice
(
65
),
//进项明细与进项汇总表无关联
InvoiceItem_AmountCompare
(
66
),
//进项汇总表与明细表金额,税额比对
InvoiceItem_TaxRateCompare
(
67
),
//金额与税率的乘积与导入的税额比较
Output_DuplicatedData
(
80
),
//销项发票重复
OutputItem_TaxRateCompare
(
81
),
//金额与税率的乘积与导入的税额比较
AccountMapping_NotMapStd
(
90
),
//Const_AccountMapping_NotMapStd 没有对应标准科目
Shimao_Tb
(
100
),
//世贸数据正确性验证
Shimao_OutputInvoice
(
101
),
//世贸销项正确性验证
Shimao_JournalEntry
(
102
),
//序时帐正确性验证
Shimao_InputInvoice
(
103
);
//世贸进项正确性验证
private
Integer
code
;
ErpCheckType
(
Integer
code
)
{
this
.
code
=
code
;
}
public
Integer
getCode
()
{
return
code
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/constant/enums/ImageType.java
0 → 100644
View file @
6a18d012
package
pwc
.
taxtech
.
atms
.
constant
.
enums
;
public
enum
ImageType
{
Success
(
1
),
//成功
Alert
(
2
),
//提示
Warning
(
3
),
//警告
Error
(
4
);
//错误
private
Integer
code
;
ImageType
(
Integer
code
)
{
this
.
code
=
code
;
}
public
Integer
getCode
()
{
return
code
;
}
public
static
ImageType
fromCode
(
Integer
code
){
for
(
ImageType
type:
ImageType
.
values
()){
if
(
type
.
getCode
().
intValue
()==
code
.
intValue
())
return
type
;
}
throw
new
RuntimeException
(
"not support image type code"
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/controller/FinanceDataImportController.java
0 → 100644
View file @
6a18d012
package
pwc
.
taxtech
.
atms
.
controller
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.service.IdentityService
;
import
pwc.taxtech.atms.vat.service.FinanceDataImportService
;
@RestController
@RequestMapping
(
"/api/v1/financeImportData"
)
public
class
FinanceDataImportController
{
@Autowired
private
FinanceDataImportService
financeDataImport
;
@Autowired
private
IdentityService
identityService
;
@ApiOperation
(
value
=
""
)
@RequestMapping
(
value
=
"checkData/basicCheck"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
getBasicValidationResults
()
{
return
ResponseEntity
.
ok
().
body
(
financeDataImport
.
getBasicValidationResults
(
identityService
.
getIdentityUser
().
getID
()));
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/DataCheckDto.java
0 → 100644
View file @
6a18d012
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
public
class
DataCheckDto
{
private
String
imagePic
;
private
Integer
imageTypeId
;
private
Integer
num
;
private
String
dataCheckType
;
private
Integer
errorCount
;
private
Integer
period
;
private
String
tips
;
private
Integer
erpCheckTypeId
;
private
String
validationDetails
;
public
String
getImagePic
()
{
return
imagePic
;
}
public
void
setImagePic
(
String
imagePic
)
{
this
.
imagePic
=
imagePic
;
}
public
Integer
getImageTypeId
()
{
return
imageTypeId
;
}
public
void
setImageTypeId
(
Integer
imageTypeId
)
{
this
.
imageTypeId
=
imageTypeId
;
}
public
Integer
getNum
()
{
return
num
;
}
public
void
setNum
(
Integer
num
)
{
this
.
num
=
num
;
}
public
String
getDataCheckType
()
{
return
dataCheckType
;
}
public
void
setDataCheckType
(
String
dataCheckType
)
{
this
.
dataCheckType
=
dataCheckType
;
}
public
Integer
getErrorCount
()
{
return
errorCount
;
}
public
void
setErrorCount
(
Integer
errorCount
)
{
this
.
errorCount
=
errorCount
;
}
public
Integer
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
Integer
period
)
{
this
.
period
=
period
;
}
public
String
getTips
()
{
return
tips
;
}
public
void
setTips
(
String
tips
)
{
this
.
tips
=
tips
;
}
public
Integer
getErpCheckTypeId
()
{
return
erpCheckTypeId
;
}
public
void
setErpCheckTypeId
(
Integer
erpCheckTypeId
)
{
this
.
erpCheckTypeId
=
erpCheckTypeId
;
}
public
String
getValidationDetails
()
{
return
validationDetails
;
}
public
void
setValidationDetails
(
String
validationDetails
)
{
this
.
validationDetails
=
validationDetails
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/VoucherAccountMto.java
0 → 100644
View file @
6a18d012
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
public
class
VoucherAccountMto
{
private
String
accountCode
;
private
String
accountName
;
private
Integer
count
;
public
String
getAccountCode
()
{
return
accountCode
;
}
public
void
setAccountCode
(
String
accountCode
)
{
this
.
accountCode
=
accountCode
;
}
public
String
getAccountName
()
{
return
accountName
;
}
public
void
setAccountName
(
String
accountName
)
{
this
.
accountName
=
accountName
;
}
public
Integer
getCount
()
{
return
count
;
}
public
void
setCount
(
Integer
count
)
{
this
.
count
=
count
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/VoucherBalanceDto.java
0 → 100644
View file @
6a18d012
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
java.util.List
;
public
class
VoucherBalanceDto
{
private
String
acctCode
;
private
Float
credit
;
private
Integer
date
;
private
Float
debit
;
private
String
group
;
private
String
groupNum
;
private
String
itemID
;
private
Integer
period
;
private
String
summary
;
private
String
vID
;
private
String
customerCode
;
private
List
<
VoucherBalanceDto
>
children
;
public
String
getAcctCode
()
{
return
acctCode
;
}
public
void
setAcctCode
(
String
acctCode
)
{
this
.
acctCode
=
acctCode
;
}
public
Float
getCredit
()
{
return
credit
;
}
public
void
setCredit
(
Float
credit
)
{
this
.
credit
=
credit
;
}
public
Integer
getDate
()
{
return
date
;
}
public
void
setDate
(
Integer
date
)
{
this
.
date
=
date
;
}
public
Float
getDebit
()
{
return
debit
;
}
public
void
setDebit
(
Float
debit
)
{
this
.
debit
=
debit
;
}
public
String
getGroup
()
{
return
group
;
}
public
void
setGroup
(
String
group
)
{
this
.
group
=
group
;
}
public
String
getGroupNum
()
{
return
groupNum
;
}
public
void
setGroupNum
(
String
groupNum
)
{
this
.
groupNum
=
groupNum
;
}
public
String
getItemID
()
{
return
itemID
;
}
public
void
setItemID
(
String
itemID
)
{
this
.
itemID
=
itemID
;
}
public
Integer
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
Integer
period
)
{
this
.
period
=
period
;
}
public
String
getSummary
()
{
return
summary
;
}
public
void
setSummary
(
String
summary
)
{
this
.
summary
=
summary
;
}
public
String
getvID
()
{
return
vID
;
}
public
void
setvID
(
String
vID
)
{
this
.
vID
=
vID
;
}
public
String
getCustomerCode
()
{
return
customerCode
;
}
public
void
setCustomerCode
(
String
customerCode
)
{
this
.
customerCode
=
customerCode
;
}
public
List
<
VoucherBalanceDto
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
VoucherBalanceDto
>
children
)
{
this
.
children
=
children
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/dao/ValidationInfoMapper.java
View file @
6a18d012
...
...
@@ -3,8 +3,11 @@ package pwc.taxtech.atms.vat.dao;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.session.RowBounds
;
import
pwc.taxtech.atms.MyVatMapper
;
import
pwc.taxtech.atms.dto.vatdto.VoucherAccountMto
;
import
pwc.taxtech.atms.dto.vatdto.VoucherBalanceDto
;
import
pwc.taxtech.atms.vat.entity.ValidationInfo
;
import
pwc.taxtech.atms.vat.entity.ValidationInfoExample
;
...
...
@@ -105,4 +108,58 @@ public interface ValidationInfoMapper extends MyVatMapper {
* @mbg.generated
*/
int
updateByPrimaryKey
(
ValidationInfo
record
);
@Select
(
"SELECT "
+
" c.AcctCode as AccountCode, COUNT(1) as Count "
+
"FROM "
+
" CompanyBalance c "
+
" LEFT JOIN "
+
" EnterpriseAccount a ON c.AcctCode = a.AcctCode "
+
"WHERE "
+
" a.IsDummy != 1 "
+
" AND (c.AcctCode != '' AND c.AcctCode != NULL) "
+
"GROUP BY c.AcctCode"
)
List
<
VoucherAccountMto
>
getCompanyBalanceAcctChecks
();
@Select
(
"SELECT "
+
" c.AcctCode as AccountCode, COUNT(1) as Count "
+
"FROM "
+
" Voucher c "
+
" LEFT JOIN "
+
" EnterpriseAccount a ON c.AcctCode = a.AcctCode "
+
"WHERE "
+
" a.IsDummy != 1 "
+
" AND (c.AcctCode != '' AND c.AcctCode != NULL) "
+
"GROUP BY c.AcctCode"
)
List
<
VoucherAccountMto
>
getVoucherAccountChecks
();
@Select
(
"SELECT "
+
" vv.VID, "
+
" vv.Group, "
+
" vv.Period, "
+
" vv.CustomerCode, "
+
" vv.Summary, "
+
" vv.AcctCode, "
+
" vv.Debit, "
+
" vv.Credit, "
+
" vv.ItemID "
+
"FROM "
+
" Voucher vv "
+
" JOIN "
+
" (SELECT "
+
" v.VID, "
+
" v.Period, "
+
" v.Group, "
+
" MAX(v.Date) AS `Date`, "
+
" SUM(v.Debit) AS Debit, "
+
" SUM(v.Credit) AS Credit "
+
" FROM "
+
" Voucher v "
+
" GROUP BY v.VID , v.Period , v.Group "
+
" HAVING Debit != Credit) q ON vv.VID = q.VID AND vv.Period = q.Period "
+
" AND vv.Group = q.Group "
+
""
)
List
<
VoucherBalanceDto
>
getSingleVoucherCheck
();
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/vat/service/FinanceDataImportService.java
0 → 100644
View file @
6a18d012
package
pwc
.
taxtech
.
atms
.
vat
.
service
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.dto.vatdto.DataCheckDto
;
import
java.util.List
;
public
interface
FinanceDataImportService
{
OperationResultDto
<
List
<
DataCheckDto
>>
getBasicValidationResults
(
String
userId
);
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FinanceDataImportServiceImpl.java
0 → 100644
View file @
6a18d012
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
pwc.taxtech.atms.constant.VatErpImportValidation
;
import
pwc.taxtech.atms.constant.enums.ErpCheckType
;
import
pwc.taxtech.atms.constant.enums.ImageType
;
import
pwc.taxtech.atms.dto.FieldsMapper
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.dto.vatdto.DataCheckDto
;
import
pwc.taxtech.atms.dto.vatdto.ValidationInfoDto
;
import
pwc.taxtech.atms.dto.vatdto.VoucherAccountMto
;
import
pwc.taxtech.atms.dto.vatdto.VoucherBalanceDto
;
import
pwc.taxtech.atms.dto.vatdto.VoucherDto
;
import
pwc.taxtech.atms.vat.dao.ValidationInfoMapper
;
import
pwc.taxtech.atms.vat.dao.VoucherMapper
;
import
pwc.taxtech.atms.vat.entity.ValidationInfo
;
import
pwc.taxtech.atms.vat.entity.ValidationInfoExample
;
import
pwc.taxtech.atms.vat.entity.Voucher
;
import
pwc.taxtech.atms.vat.entity.VoucherExample
;
import
pwc.taxtech.atms.vat.service.FinanceDataImportService
;
import
sun.misc.BASE64Encoder
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.*;
import
static
pwc
.
taxtech
.
atms
.
constant
.
VATCommon
.
ReValidate
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
VATCommon
.
ValidationExisted
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
enums
.
EnumValidationType
.
ErpBasicCheck
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
enums
.
ImageType
.
Alert
;
public
class
FinanceDataImportServiceImpl
implements
FinanceDataImportService
{
@Autowired
private
ValidationInfoMapper
validationInfoMapper
;
@Autowired
private
VoucherMapper
voucherMapper
;
@Override
public
OperationResultDto
<
List
<
DataCheckDto
>>
getBasicValidationResults
(
String
userId
)
{
Integer
number
=
1
;
List
<
DataCheckDto
>
results
=
new
ArrayList
<>();
OperationResultDto
<
List
<
DataCheckDto
>>
operationResult
=
new
OperationResultDto
<>();
List
<
ValidationInfoDto
>
dtos
=
getValidationData
(
ErpBasicCheck
.
getCode
());
if
(
dtos
!=
null
&&
dtos
.
size
()
>
0
)
{
dtos
.
forEach
(
b
->
{
DataCheckDto
dataCheckDto
=
new
DataCheckDto
();
dataCheckDto
.
setDataCheckType
(
b
.
getValidationResult
());
dataCheckDto
.
setImageTypeId
(
b
.
getErrorLevel
()
!=
null
?
b
.
getErrorLevel
()
:
-
1
);
dataCheckDto
.
setTips
(
b
.
getValidationTips
());
dataCheckDto
.
setErrorCount
(
b
.
getNumber
()
!=
null
?
b
.
getNumber
()
:
-
1
);
dataCheckDto
.
setErpCheckTypeId
(
b
.
getErpCheckTypeId
()
!=
null
?
b
.
getErpCheckTypeId
()
:
-
1
);
dataCheckDto
.
setValidationDetails
(
b
.
getValidationDetails
());
results
.
add
(
dataCheckDto
);
operationResult
.
setResultMsg
(
ValidationExisted
);
});
}
else
{
List
<
VoucherAccountMto
>
comAcctChks
=
validationInfoMapper
.
getCompanyBalanceAcctChecks
();
List
<
VoucherAccountMto
>
vAcctChks
=
validationInfoMapper
.
getVoucherAccountChecks
();
List
<
VoucherBalanceDto
>
vDebCrdSingleChk
=
getSingleVoucherCheck
();
List
<
VoucherDto
>
vEmptyItem
=
getVoucherEmptyCheck
(
true
,
false
,
false
,
false
,
false
);
List
<
VoucherDto
>
vEmptyGroup
=
getVoucherEmptyCheck
(
false
,
false
,
true
,
false
,
false
);
List
<
VoucherDto
>
vEmptyAcctCode
=
getVoucherEmptyCheck
(
false
,
false
,
false
,
true
,
false
);
List
<
VoucherDto
>
vEmptySummary
=
getVoucherEmptyCheck
(
false
,
false
,
false
,
false
,
true
);
if
(
comAcctChks
.
size
()
==
0
)
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Success
,
VatErpImportValidation
.
Const_ComBalanceAcctValidate
,
0
,
""
,
ErpCheckType
.
Success
));
}
else
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Warning
,
VatErpImportValidation
.
Const_ComBalanceAcctUnValidate
,
comAcctChks
.
size
(),
VatErpImportValidation
.
Const_ComBalanceAcctUnValidate_Tips
,
ErpCheckType
.
ComBalanceAcctUnValidate
,
0
,
JSON
.
toJSONString
(
comAcctChks
)));
}
if
(
vAcctChks
.
size
()
==
0
)
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Success
,
VatErpImportValidation
.
Const_VoucherAcctValidate
,
0
,
""
,
ErpCheckType
.
Success
));
}
else
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Warning
,
VatErpImportValidation
.
Const_VoucherAcctUnValidate
,
vAcctChks
.
size
(),
VatErpImportValidation
.
Const_VoucherAcctUnValidate_Tips
,
ErpCheckType
.
VoucherAcctValidate
,
0
,
JSON
.
toJSONString
(
vAcctChks
)));
}
if
(
vDebCrdSingleChk
.
size
()
==
0
)
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Success
,
VatErpImportValidation
.
Const_VSingleDebitCreditValidate
,
0
,
""
,
ErpCheckType
.
Success
));
}
else
{
results
.
add
(
setDataCheckItem
(
Alert
,
VatErpImportValidation
.
Const_VSingleDebitCreditUnValidate
,
vDebCrdSingleChk
.
size
(),
VatErpImportValidation
.
Const_VSingleDebitCreditUnValidate_Tips
,
ErpCheckType
.
VSingleDebitCreditUnValidate
,
0
,
JSON
.
toJSONString
(
vDebCrdSingleChk
)));
}
if
(
vEmptyItem
.
size
()
==
0
)
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Success
,
VatErpImportValidation
.
Const_VEmptyCheckValidateItemID
,
0
,
""
,
ErpCheckType
.
Success
));
}
else
{
results
.
add
(
setDataCheckItem
(
Alert
,
VatErpImportValidation
.
Const_VEmptyCheckUnValidateItemID
,
vEmptyItem
.
size
(),
VatErpImportValidation
.
Const_VEmptyCheckUnValidateItemID_Tips
,
ErpCheckType
.
VEmptyCheckUnValidateItemID
,
0
,
JSON
.
toJSONString
(
vEmptyItem
)));
}
if
(
vEmptyGroup
.
size
()
==
0
)
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Success
,
VatErpImportValidation
.
Const_VEmptyCheckValidateGroup
,
0
,
""
,
ErpCheckType
.
Success
));
}
else
{
results
.
add
(
setDataCheckItem
(
Alert
,
VatErpImportValidation
.
Const_VEmptyCheckUnValidateGroup
,
vEmptyGroup
.
size
(),
VatErpImportValidation
.
Const_VEmptyCheckUnValidateGroup_Tips
,
ErpCheckType
.
VEmptyCheckUnValidateGroup
,
0
,
JSON
.
toJSONString
(
vEmptyGroup
)));
}
if
(
vEmptyAcctCode
.
size
()
==
0
)
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Success
,
VatErpImportValidation
.
Const_VEmptyCheckValidateAcctCode
,
0
,
""
,
ErpCheckType
.
Success
));
}
else
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Error
,
VatErpImportValidation
.
Const_VEmptyCheckUnValidateAcctCode
,
vEmptyAcctCode
.
size
(),
VatErpImportValidation
.
Const_VEmptyCheckUnValidateAcctCode_Tips
,
ErpCheckType
.
VEmptyCheckUnValidateAcctCode
,
0
,
JSON
.
toJSONString
(
vEmptyAcctCode
)));
}
if
(
vEmptySummary
.
size
()
==
0
)
{
results
.
add
(
setDataCheckItem
(
ImageType
.
Success
,
VatErpImportValidation
.
Const_VEmptyCheckValidateSummary
,
0
,
""
,
ErpCheckType
.
Success
));
}
else
{
results
.
add
(
setDataCheckItem
(
Alert
,
VatErpImportValidation
.
Const_VEmptyCheckUnValidateSummary
,
vEmptySummary
.
size
(),
VatErpImportValidation
.
Const_VEmptyCheckUnValidateSummary_Tips
,
ErpCheckType
.
VEmptyCheckUnValidateSummary
,
0
,
JSON
.
toJSONString
(
vEmptySummary
)));
}
operationResult
.
setResultMsg
(
ReValidate
);
convertDataCheckDtoToValidationInfo
(
results
,
ErpBasicCheck
.
getCode
(),
userId
).
forEach
(
m
->
{
validationInfoMapper
.
insert
(
m
);
});
}
results
.
sort
(
Comparator
.
comparing
(
DataCheckDto:
:
getDataCheckType
));
for
(
DataCheckDto
m
:
results
)
{
m
.
setNum
(
number
);
m
.
setImagePic
(
setCheckImage
(
ImageType
.
fromCode
(
m
.
getImageTypeId
())));
number
++;
}
operationResult
.
setResult
(
true
);
operationResult
.
setData
(
results
);
return
operationResult
;
}
private
List
<
ValidationInfo
>
convertDataCheckDtoToValidationInfo
(
List
<
DataCheckDto
>
basicItems
,
int
typeId
,
String
userId
)
{
List
<
ValidationInfo
>
results
=
new
ArrayList
<>();
basicItems
.
forEach
(
item
->
{
ValidationInfo
vi
=
new
ValidationInfo
();
vi
.
setID
(
UUID
.
randomUUID
().
toString
());
vi
.
setValidationResult
(
item
.
getDataCheckType
());
vi
.
setValidationDetails
(
item
.
getValidationDetails
());
vi
.
setErrorLevel
(
item
.
getImageTypeId
());
vi
.
setValidationTips
(
item
.
getTips
());
vi
.
setNumber
(
item
.
getErrorCount
());
vi
.
setImportTypeId
(
typeId
);
vi
.
setErpCheckTypeId
(
item
.
getErpCheckTypeId
());
vi
.
setPeriodId
(
item
.
getPeriod
());
vi
.
setCreateTime
(
new
Date
());
vi
.
setCreatorId
(
userId
);
});
return
results
;
}
private
String
setCheckImage
(
ImageType
imageTypeId
)
{
String
imgbase64
=
null
;
switch
(
imageTypeId
)
{
case
Alert:
imgbase64
=
imageToBase64ByImagePath
(
IMAGE_PATH_INFORMATION
,
IMAGE_FORMART_
);
break
;
case
Error:
imgbase64
=
imageToBase64ByImagePath
(
IMAGE_PATH_ERROR
,
IMAGE_FORMART_
);
break
;
case
Success:
imgbase64
=
imageToBase64ByImagePath
(
IMAGE_PATH_SUCCESS
,
IMAGE_FORMART_
);
break
;
case
Warning:
imgbase64
=
imageToBase64ByImagePath
(
IMAGE_PATH_WARN
,
IMAGE_FORMART_
);
break
;
}
return
imgbase64
;
}
private
String
imageToBase64ByImagePath
(
String
imagPath
,
String
format
)
{
try
(
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
())
{
BufferedImage
bufferedImage
=
ImageIO
.
read
(
new
File
(
imagPath
));
ImageIO
.
write
(
bufferedImage
,
format
,
outputStream
);
BASE64Encoder
encoder
=
new
BASE64Encoder
();
return
encoder
.
encode
(
outputStream
.
toByteArray
());
}
catch
(
MalformedURLException
e1
)
{
e1
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
throw
new
RuntimeException
(
"read image some error"
);
//TODO:should be replace some exception filter(neo)
}
private
DataCheckDto
setDataCheckItem
(
ImageType
imageType
,
String
type
,
int
count
,
String
tips
,
ErpCheckType
checkType
,
int
periodId
,
String
validationDetails
)
{
DataCheckDto
rawData
=
new
DataCheckDto
();
rawData
.
setImageTypeId
(
imageType
.
getCode
());
rawData
.
setDataCheckType
(
type
);
rawData
.
setErrorCount
(
count
);
rawData
.
setTips
(
tips
);
rawData
.
setPeriod
(
periodId
);
rawData
.
setErpCheckTypeId
(
checkType
.
getCode
());
rawData
.
setValidationDetails
(
validationDetails
);
return
rawData
;
}
private
DataCheckDto
setDataCheckItem
(
ImageType
imageType
,
String
type
,
int
count
,
String
tips
,
ErpCheckType
checkType
)
{
DataCheckDto
rawData
=
new
DataCheckDto
();
rawData
.
setImageTypeId
(
imageType
.
getCode
());
rawData
.
setDataCheckType
(
type
);
rawData
.
setErrorCount
(
count
);
rawData
.
setTips
(
tips
);
rawData
.
setPeriod
(
0
);
rawData
.
setErpCheckTypeId
(
checkType
.
getCode
());
rawData
.
setValidationDetails
(
null
);
return
rawData
;
}
private
List
<
VoucherDto
>
getVoucherEmptyCheck
(
boolean
itemID
,
boolean
period
,
boolean
group
,
boolean
acctCode
,
boolean
summary
)
{
VoucherExample
example
=
new
VoucherExample
();
if
(
itemID
)
{
example
.
createCriteria
().
andItemIDIsNotNull
();
if
(
voucherMapper
.
countByExample
(
example
)
>
0
)
{
example
.
createCriteria
().
andItemIDIsNull
();
}
}
else
if
(
period
)
{
example
.
createCriteria
().
andPeriodIsNull
();
}
else
if
(
group
)
{
example
.
createCriteria
().
andGroupIsNull
();
}
else
if
(
acctCode
)
{
example
.
createCriteria
().
andAcctCodeIsNull
();
}
else
if
(
summary
)
{
example
.
createCriteria
().
andSummaryIsNull
();
}
List
<
Voucher
>
vouchers
=
voucherMapper
.
selectByExample
(
example
);
if
(
vouchers
!=
null
&&
!
vouchers
.
isEmpty
())
{
List
<
VoucherDto
>
dtos
=
new
ArrayList
<>(
vouchers
.
size
());
vouchers
.
forEach
(
m
->
{
VoucherDto
dto
=
new
VoucherDto
();
try
{
FieldsMapper
.
map
(
m
,
dto
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
dtos
.
add
(
dto
);
});
return
dtos
;
}
return
new
ArrayList
<>();
}
private
List
<
VoucherBalanceDto
>
getSingleVoucherCheck
()
{
List
<
VoucherBalanceDto
>
vouchers
=
validationInfoMapper
.
getSingleVoucherCheck
();
if
(
vouchers
!=
null
&&
!
vouchers
.
isEmpty
())
{
List
<
VoucherBalanceDto
>
parentVouchers
=
vouchers
.
stream
().
filter
(
dto
->
dto
.
getCustomerCode
()
==
null
||
dto
.
getCustomerCode
().
isEmpty
()).
collect
(
Collectors
.
toList
());
parentVouchers
.
forEach
(
m
->
{
List
<
VoucherBalanceDto
>
children
=
parentVouchers
.
stream
().
filter
(
dto
->
m
.
getvID
().
equals
(
dto
.
getvID
())
&&
m
.
getPeriod
().
intValue
()
==
dto
.
getPeriod
().
intValue
()
&&
m
.
getGroup
().
equals
(
dto
.
getGroup
())
&&
dto
.
getCustomerCode
()
!=
null
&&
!
dto
.
getCustomerCode
().
isEmpty
()).
collect
(
Collectors
.
toList
());
children
.
sort
(
Comparator
.
comparing
(
VoucherBalanceDto:
:
getItemID
));
m
.
setChildren
(
children
);
});
parentVouchers
.
sort
(
Comparator
.
comparing
(
VoucherBalanceDto:
:
getAcctCode
));
parentVouchers
.
sort
(
Comparator
.
comparing
(
VoucherBalanceDto:
:
getvID
));
parentVouchers
.
sort
(
Comparator
.
comparing
(
VoucherBalanceDto:
:
getGroup
));
parentVouchers
.
sort
(
Comparator
.
comparing
(
VoucherBalanceDto:
:
getItemID
));
return
parentVouchers
;
}
return
new
ArrayList
<>();
}
//判断ValidationInfo中是否存在typeId的数据
private
List
<
ValidationInfoDto
>
getValidationData
(
Integer
typeId
,
Integer
periodId
)
{
ValidationInfoExample
example
=
new
ValidationInfoExample
();
if
(
periodId
!=
null
&&
periodId
>
0
)
{
example
.
createCriteria
().
andImportTypeIdEqualTo
(
typeId
.
intValue
()).
andPeriodIdEqualTo
(
periodId
.
intValue
());
}
else
example
.
createCriteria
().
andImportTypeIdEqualTo
(
typeId
.
intValue
());
List
<
ValidationInfo
>
infos
=
validationInfoMapper
.
selectByExample
(
example
);
List
<
ValidationInfoDto
>
dots
=
new
ArrayList
<>(
infos
.
size
());
infos
.
forEach
(
m
->
{
ValidationInfoDto
dto
=
new
ValidationInfoDto
();
try
{
FieldsMapper
.
map
(
m
,
dto
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
dots
.
add
(
dto
);
});
return
dots
;
}
private
List
<
ValidationInfoDto
>
getValidationData
(
Integer
typeId
)
{
return
getValidationData
(
typeId
,
null
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment