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
649d4716
Commit
649d4716
authored
Jul 22, 2018
by
neo.wang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_neo' into 'dev'
Dev neo See merge request root/atms!79
parents
1b005937
703733d3
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
739 additions
and
217 deletions
+739
-217
MyAsserts.java
...src/main/java/pwc/taxtech/atms/common/util/MyAsserts.java
+1
-0
DataImport.java
...i/src/main/java/pwc/taxtech/atms/constant/DataImport.java
+13
-0
VatErpImportValidation.java
...ava/pwc/taxtech/atms/constant/VatErpImportValidation.java
+2
-0
ImportType.java
...main/java/pwc/taxtech/atms/constant/enums/ImportType.java
+16
-0
CustomsInvoiceController.java
...pwc/taxtech/atms/controller/CustomsInvoiceController.java
+2
-3
FinanceDataImportController.java
.../taxtech/atms/controller/FinanceDataImportController.java
+244
-179
ImportCustomsInvoiceDto.java
.../pwc/taxtech/atms/dto/vatdto/ImportCustomsInvoiceDto.java
+3
-1
ImportDataDto.java
.../main/java/pwc/taxtech/atms/dto/vatdto/ImportDataDto.java
+10
-0
InvoiceMappingDto.java
...n/java/pwc/taxtech/atms/dto/vatdto/InvoiceMappingDto.java
+22
-8
VoucherDtoOnlyForImport.java
.../pwc/taxtech/atms/dto/vatdto/VoucherDtoOnlyForImport.java
+32
-0
VoucherMappingDto.java
...n/java/pwc/taxtech/atms/dto/vatdto/VoucherMappingDto.java
+17
-0
FinanceDataImportService.java
...wc/taxtech/atms/vat/service/FinanceDataImportService.java
+0
-10
CustomsInvoiceServiceImpl.java
...tech/atms/vat/service/impl/CustomsInvoiceServiceImpl.java
+21
-2
FileUploadAdapter.java
.../pwc/taxtech/atms/vat/service/impl/FileUploadAdapter.java
+1
-0
FinanceDataImportServiceImpl.java
...h/atms/vat/service/impl/FinanceDataImportServiceImpl.java
+117
-3
JournalEntryImportServiceImpl.java
.../atms/vat/service/impl/JournalEntryImportServiceImpl.java
+143
-8
VoucherInvoiceMappingServiceImpl.java
...ms/vat/service/impl/VoucherInvoiceMappingServiceImpl.java
+95
-3
No files found.
atms-api/src/main/java/pwc/taxtech/atms/common/util/MyAsserts.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
common
.
util
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.exception.ApiException
;
import
pwc.taxtech.atms.exception.FormulaException
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/constant/DataImport.java
0 → 100644
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
constant
;
public
class
DataImport
{
public
static
final
String
DuplicateInputInvoices
=
"DuplicateInputInvoice"
;
public
static
final
String
InputInvoiceAlreadyPassed
=
"InputInvoiceAlreadyPassed"
;
public
static
final
String
NotHaveTotalInvoice
=
"NotHaveTotalInvoice"
;
public
static
final
String
LessThanDetailsTotal
=
"LessThanDetailsTotal"
;
public
static
final
String
DuplicateInDB
=
"DuplicateInDB"
;
public
static
final
String
DuplicateInFile
=
"DuplicateInFile"
;
public
static
final
String
EmptyField
=
"EmptyField"
;
public
static
final
String
OverLengthField
=
"OverLengthField"
;
}
atms-api/src/main/java/pwc/taxtech/atms/constant/VatErpImportValidation.java
View file @
649d4716
...
...
@@ -6,6 +6,8 @@ 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
ImportMethod_OneClick
=
"oneClick"
;
public
static
final
String
ImportMethod_Universal
=
"universal"
;
public
static
final
String
Const_ComBalanceAcctValidate
=
"试算平衡表科目存在于企业科目列表中"
;
public
static
final
String
Const_ComBalanceAcctUnValidate
=
"试算平衡表中出现的科目不在科目表中"
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/constant/enums/ImportType.java
0 → 100644
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
constant
.
enums
;
public
enum
ImportType
{
Override
(
0
),
Append
(
1
);
private
Integer
code
;
ImportType
(
Integer
code
)
{
this
.
code
=
code
;
}
public
Integer
getCode
()
{
return
code
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/controller/CustomsInvoiceController.java
View file @
649d4716
...
...
@@ -257,9 +257,8 @@ public class CustomsInvoiceController {
}
@RequestMapping
(
value
=
"ImportCustomsInvoice"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseEntity
ImportBalanceList
(
@RequestBody
ImportCustomsInvoiceDto
importDto
)
{
public
ResponseEntity
ImportBalanceList
(
@RequestBody
ImportCustomsInvoiceDto
importDto
)
{
String
userId
=
identityService
.
getIdentityUser
().
getID
();
return
ResponseEntity
.
ok
(
customsInvoiceService
.
ImportCustomsInvoice
(
importDto
.
CustomsList
,
importDto
.
ImportType
,
userId
));
return
ResponseEntity
.
ok
(
customsInvoiceService
.
ImportCustomsInvoice
(
importDto
.
CustomsList
,
importDto
.
ImportType
,
userId
));
}
}
atms-api/src/main/java/pwc/taxtech/atms/controller/FinanceDataImportController.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
controller
;
import
io.swagger.annotations.ApiOperation
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
org.thymeleaf.util.StringUtils
;
import
pwc.taxtech.atms.constant.DataImport
;
import
pwc.taxtech.atms.constant.VatErpImportValidation
;
import
pwc.taxtech.atms.constant.enums.ImportType
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.dto.vatdto.ImportDataDto
;
import
pwc.taxtech.atms.service.IdentityService
;
import
pwc.taxtech.atms.vat.service.FinanceDataImportService
;
import
pwc.taxtech.atms.vat.service.impl.FinanceDataImportServiceImpl
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.UUID
;
@RestController
@RequestMapping
(
"/api/v1/financeImportData"
)
public
class
FinanceDataImportController
{
private
final
static
String
ImportMethod_OneClick
=
"oneClick"
;
private
final
static
String
OneClickUploadPath
=
"~/FinanceDataUpload/OneClickFile"
;
private
final
static
String
UniversalUploadExcelPath
=
"~/FinanceDataUpload/UniversalExcelFile"
;
private
final
static
String
UniversalUploadCsvPath
=
"~/FinanceDataUpload/UniversalCsvlFile"
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
FinanceDataImportController
.
class
);
@Autowired
private
FinanceDataImportService
financeDataImport
;
private
FinanceDataImportService
Impl
financeDataImport
;
@Autowired
private
IdentityService
identityService
;
...
...
@@ -25,183 +56,217 @@ public class FinanceDataImportController {
return
ResponseEntity
.
ok
().
body
(
financeDataImport
.
getBasicValidationResults
(
identityService
.
getIdentityUser
().
getID
()));
}
@RequestMapping
(
value
=
"importData/financeDataUpload"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseEntity
FinanceDataUpload
()
{
// string importMethod = HttpContext.Current.Request.Params["importMethod"];
// if (HttpContext.Current.Request.Files.Count == 0)
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "NoFile" });
// }
//
// if (string.IsNullOrEmpty(importMethod))
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "importMethod is empty" });
// }
//
// if (!IsSameFileExtenstion(HttpContext.Current.Request.Files))
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "file extension is not same" });
// }
//
// try
// {
// OperationResultDto<ImportDataDto> result = new OperationResultDto<ImportDataDto>();
// int uploadFileCount = 0;
// string mappedPath = "";
// string fileGuid = Guid.NewGuid().ToString().ToUpper();
// var firstUploadFile = HttpContext.Current.Request.Files[0];
// string fileExtension = firstUploadFile.FileName.Substring(firstUploadFile.FileName.LastIndexOf(".") + 1, firstUploadFile.FileName.Length - firstUploadFile.FileName.LastIndexOf(".") - 1);
//
// for (int i = 0; i < HttpContext.Current.Request.Files.Count; i++)
// {
// var file = HttpContext.Current.Request.Files[i];
// mappedPath = SetUploadFolderPath(importMethod, fileExtension);
// var fileFullPath = Path.Combine(mappedPath, fileGuid + "_" + Path.GetFileName(file.FileName));
// if (SaveFile(file, mappedPath, fileFullPath))
// {
// uploadFileCount++;
// }
// }
//
// if (uploadFileCount == HttpContext.Current.Request.Files.Count)
// {
// result.Result = true;
// result.ResultMsg = string.Empty;
// result.Data = new ImportDataDto { Guid = fileGuid, Number = uploadFileCount, FileExtension = fileExtension };
//
// }
// return Ok(result);
// }
// catch (Exception ex)
// {
// Dictionary<Guid, string> error = new Dictionary<Guid, string>();
// error.Add(System.Guid.NewGuid(), ex.StackTrace);
// OperationResultDto<ImportDataDto> errorResult = new OperationResultDto<ImportDataDto>()
// {
// Result = false,
// ResultMsg = "Upload File error",
// Errors = error,
// Data = new ImportDataDto { Guid = string.Empty, Number = 0, FileExtension = string.Empty }
// };
//
// return Ok(errorResult);
// }
return
ResponseEntity
.
ok
().
build
();
}
@RequestMapping
(
value
=
"importData/importFinancedata"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseEntity
FinanceImportData
()
{
// string userId = _identityService.IdentityUser.ID;
// string importMethod = HttpContext.Current.Request.Params["importMethod"];
// string fileName = HttpContext.Current.Request.Params["fileName"];
// string importTypeStr = HttpContext.Current.Request.Params["importType"];
// string fileGuid = HttpContext.Current.Request.Params["fileGuid"];
// string periodStr = HttpContext.Current.Request.Params["period"];
// string fileExtension = HttpContext.Current.Request.Params["fileExtension"];
// string strProjectYear = HttpContext.Current.Request.Params["projectYear"];
// #region 参数为空即返回
// if (string.IsNullOrEmpty(importMethod))
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "importMethod is empty" });
// }
//
// if (string.IsNullOrEmpty(fileName))
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "fileName is empty" });
// }
//
// if (string.IsNullOrEmpty(importTypeStr))
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "importType is empty" });
// }
//
// if (string.IsNullOrEmpty(fileGuid))
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "fileGuid is empty" });
// }
//
// if (string.IsNullOrEmpty(periodStr))
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "periodStr is empty" });
// }
//
// if (string.IsNullOrEmpty(fileExtension))
// {
// return this.Ok(new OperationResultDto() { Result = false, ResultMsg = "fileExtension is empty" });
// }
//
// #endregion
// int importType = int.Parse(importTypeStr);
// int projectYear = !string.IsNullOrEmpty(strProjectYear) ? int.Parse(strProjectYear) : -1;
// int period = int.Parse(periodStr);
// int importFileCount = 0;
// var mappedPath = SetUploadFolderPath(importMethod, fileExtension);
// OperationResultDto<List<ImportDataDto>> result = new OperationResultDto<List<ImportDataDto>>();
// List<ImportDataDto> importResults = new List<ImportDataDto>();
// List<string> fileList = fileName.Split(',').ToList();
// List<string> toDeleteFilesPath = new List<string>();
// #region 导入数据
//
// if (importType == (int)DataImport.ImportType.Override)
// {
// //如果导入文件只有voucher的话,那么就不用删除CustBalance表中当前期间的数据
// bool isClearCustTb = fileList.Count == 1 && fileList.First().ToLower().StartsWith(VatGlobal.VoucherTbName.ToLower()) ? false : true;
// //1. 删除TB相关表的数据
// _financeDataImport.ClearTable(period,isClearCustTb);
// }
// //2. 删除ValidationInfo中Erp相关的数据
// _financeDataImport.DeleteErpValidation();
//
// //3. 开始导入数据
// foreach (var f in fileList)
// {
// var fileFullPath = Path.Combine(mappedPath, fileGuid + "_" + Path.GetFileName(f));
// var schemaPath = HostingEnvironment.MapPath("~/Resource");
// toDeleteFilesPath.Add(fileFullPath);
// var importResult = _financeDataImport.ImportData(projectYear, importMethod, importType, period, fileFullPath, f, schemaPath, userId);
// if (importResult.Result)
// {
// importFileCount++;
// }
// else
// {
// importResults.Add(importResult);
// }
// }
//
// if (importFileCount == fileList.Count)
// {
// _financeDataImport.UpdateCompanyBalanceNullValue();
// result.Result = true;
// result.ResultMsg = string.Empty;
// result.Data = importResults;
// toDeleteFilesPath.ForEach(f =>
// {
// if (File.Exists(f))
// {
// File.Delete(f);
// _logger.Log(LogLevel.Info, "成功删除财务数据导入文件:" + f);
// }
// });
//
// }
// else
// {
// result.Result = false;
// result.Data = importResults;
// result.ResultMsg = "导入数据出错: " + "\r\n";
// foreach (var r in importResults)
// {
// result.ResultMsg += r.FileName + "\r\n";
// }
// }
//
// #endregion
//
// return Ok(result);
return
ResponseEntity
.
ok
().
build
();
@RequestMapping
(
value
=
"importData/financeDataUpload"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
public
ResponseEntity
FinanceDataUpload
(
@RequestParam
String
importMethod
,
MultipartHttpServletRequest
request
)
{
if
(
request
.
getFileMap
().
size
()
==
0
)
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"NoFile"
));
}
if
(
StringUtils
.
isEmpty
(
importMethod
))
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"importMethod is empty"
));
}
if
(!
IsSameFileExtenstion
(
request
.
getFileMap
()))
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"file extension is not same"
));
}
try
{
OperationResultDto
<
ImportDataDto
>
result
=
new
OperationResultDto
<>();
int
uploadFileCount
=
0
;
String
mappedPath
=
""
;
String
fileGuid
=
UUID
.
randomUUID
().
toString
().
toUpperCase
();
String
fileExtension
=
getExtension
(
request
.
getFileMap
());
for
(
MultipartFile
file
:
request
.
getFileMap
().
values
())
{
mappedPath
=
SetUploadFolderPath
(
importMethod
,
fileExtension
);
String
fileFullPath
=
Paths
.
get
(
mappedPath
,
fileGuid
+
"_"
+
file
.
getName
()).
toString
();
if
(
SaveFile
(
file
,
mappedPath
,
fileFullPath
))
{
uploadFileCount
++;
}
}
if
(
uploadFileCount
==
request
.
getFileMap
().
size
())
{
result
.
setResult
(
true
);
result
.
setResultMsg
(
""
);
ImportDataDto
dataDto
=
new
ImportDataDto
();
dataDto
.
Guid
=
fileGuid
;
dataDto
.
Number
=
uploadFileCount
;
dataDto
.
FileExtension
=
fileExtension
;
result
.
setData
(
dataDto
);
}
return
ResponseEntity
.
ok
(
result
);
}
catch
(
Exception
ex
)
{
Map
<
String
,
String
>
error
=
new
HashMap
<>();
ex
.
printStackTrace
();
error
.
put
(
UUID
.
randomUUID
().
toString
(),
ex
.
getMessage
());
OperationResultDto
<
ImportDataDto
>
errorResult
=
new
OperationResultDto
<
ImportDataDto
>(
false
,
"Upload File error"
);
errorResult
.
setErrors
(
error
);
ImportDataDto
dataDto
=
new
ImportDataDto
();
dataDto
.
Guid
=
""
;
dataDto
.
Number
=
0
;
dataDto
.
FileExtension
=
""
;
errorResult
.
setData
(
dataDto
);
return
ResponseEntity
.
ok
(
errorResult
);
}
}
@RequestMapping
(
value
=
"importData/importFinancedata"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
public
ResponseEntity
FinanceImportData
(
@RequestParam
String
importMethod
,
@RequestParam
String
fileName
,
@RequestParam
String
importType
,
@RequestParam
String
fileGuid
,
@RequestParam
Integer
period
,
@RequestParam
String
fileExtension
,
@RequestParam
String
projectYear
,
MultipartHttpServletRequest
request
)
{
String
userId
=
identityService
.
getIdentityUser
().
getID
();
if
(
StringUtils
.
isEmpty
(
importMethod
))
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"importMethod is empty"
));
}
if
(
StringUtils
.
isEmpty
(
fileName
))
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"fileName is empty"
));
}
if
(
StringUtils
.
isEmpty
(
importType
))
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"importType is empty"
));
}
if
(
StringUtils
.
isEmpty
(
fileGuid
))
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"fileGuid is empty"
));
}
if
(
period
==
null
)
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"periodStr is empty"
));
}
if
(
StringUtils
.
isEmpty
(
fileExtension
))
{
return
ResponseEntity
.
ok
(
new
OperationResultDto
(
false
,
"fileExtension is empty"
));
}
Integer
projectYearInt
=
!
StringUtils
.
isEmpty
(
projectYear
)
?
Integer
.
parseInt
(
projectYear
)
:
-
1
;
int
importFileCount
=
0
;
String
mappedPath
=
SetUploadFolderPath
(
importMethod
,
fileExtension
);
OperationResultDto
<
List
<
ImportDataDto
>>
result
=
new
OperationResultDto
<>();
List
<
ImportDataDto
>
importResults
=
new
ArrayList
<>();
String
[]
fileList
=
fileName
.
split
(
","
);
List
<
String
>
toDeleteFilesPath
=
new
ArrayList
<>();
if
(
importType
.
equals
(
ImportType
.
Override
.
getCode
()
+
""
))
{
//如果导入文件只有voucher的话,那么就不用删除CustBalance表中当前期间的数据
Boolean
isClearCustTb
=
fileList
.
length
==
1
&&
fileList
[
0
].
toLowerCase
().
startsWith
(
VatErpImportValidation
.
VoucherTbName
.
toLowerCase
())
?
false
:
true
;
//1. 删除TB相关表的数据
financeDataImport
.
ClearTable
(
period
,
isClearCustTb
);
}
//2. 删除ValidationInfo中Erp相关的数据
financeDataImport
.
DeleteErpValidation
();
//3. 开始导入数据
for
(
MultipartFile
f
:
request
.
getFileMap
().
values
())
{
String
fileFullPath
=
Paths
.
get
(
mappedPath
,
fileGuid
+
"_"
+
f
.
getName
()).
toString
();
String
schemaPath
=
"~/Resource"
;
toDeleteFilesPath
.
add
(
fileFullPath
);
ImportDataDto
importResult
=
financeDataImport
.
ImportData
(
projectYear
,
importMethod
,
importType
,
period
,
fileFullPath
,
f
,
schemaPath
,
userId
);
if
(
importResult
.
Result
)
{
importFileCount
++;
}
else
{
importResults
.
add
(
importResult
);
}
}
if
(
importFileCount
==
fileList
.
length
)
{
financeDataImport
.
UpdateCompanyBalanceNullValue
();
result
.
setResult
(
true
);
result
.
setResultMsg
(
""
);
result
.
setData
(
importResults
);
toDeleteFilesPath
.
forEach
(
f
->
{
if
(
new
File
(
f
).
exists
())
{
new
File
(
f
).
delete
();
logger
.
info
(
"成功删除财务数据导入文件:"
+
f
);
}
});
}
else
{
result
.
setResult
(
false
);
result
.
setData
(
importResults
);
String
msg
=
"导入数据出错: "
+
"\r\n"
;
for
(
ImportDataDto
m
:
importResults
)
msg
+=
(
m
.
FileName
+
"\r\n"
);
result
.
setResultMsg
(
msg
);
}
return
ResponseEntity
.
ok
(
result
);
}
private
Boolean
IsSameFileExtenstion
(
Map
<
String
,
MultipartFile
>
files
)
{
Set
<
String
>
extension
=
new
HashSet
<>();
for
(
MultipartFile
file
:
files
.
values
())
{
extension
.
add
(
file
.
getName
().
substring
(
file
.
getName
().
lastIndexOf
(
"."
)
+
1
,
file
.
getName
().
length
()
-
file
.
getName
().
lastIndexOf
(
"."
)));
}
if
(
extension
.
size
()
==
1
)
{
return
true
;
}
else
{
return
false
;
}
}
private
String
getExtension
(
Map
<
String
,
MultipartFile
>
files
)
{
MultipartFile
file
=
files
.
values
().
stream
().
findFirst
().
get
();
return
file
.
getName
().
substring
(
file
.
getName
().
lastIndexOf
(
"."
)
+
1
,
file
.
getName
().
length
()
-
file
.
getName
().
lastIndexOf
(
"."
));
}
private
String
SetUploadFolderPath
(
String
importMethod
,
String
fileExtension
)
{
String
folderPath
=
""
;
if
(
importMethod
==
ImportMethod_OneClick
)
{
folderPath
=
OneClickUploadPath
;
}
else
{
if
(
fileExtension
==
"csv"
)
{
folderPath
=
UniversalUploadCsvPath
;
}
if
(
fileExtension
==
"xls"
||
fileExtension
==
"xlsx"
)
{
folderPath
=
UniversalUploadExcelPath
;
}
}
return
folderPath
;
}
private
Boolean
SaveFile
(
MultipartFile
file
,
String
mappedPath
,
String
fileFullPath
)
{
Map
<
String
,
String
>
error
=
new
HashMap
<>();
try
{
if
(!
new
File
(
mappedPath
).
exists
())
{
new
File
(
mappedPath
).
mkdirs
();
}
SaveAs
(
file
,
fileFullPath
);
}
catch
(
Exception
ex
)
{
return
false
;
}
return
true
;
}
private
void
SaveAs
(
MultipartFile
file
,
String
fileFullPath
)
{
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
new
File
(
fileFullPath
));
InputStream
inputStream
=
file
.
getInputStream
();)
{
byte
[]
buffer
=
new
byte
[
4096
];
int
bytesRead
;
while
((
bytesRead
=
inputStream
.
read
(
buffer
,
0
,
buffer
.
length
))
>
0
)
{
fos
.
write
(
buffer
,
0
,
bytesRead
);
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/ImportCustomsInvoiceDto.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
pwc.taxtech.atms.vat.entity.CustomsInvoice
;
import
java.util.List
;
public
class
ImportCustomsInvoiceDto
{
public
List
<
CustomsInvoice
Dto
>
CustomsList
;
public
List
<
CustomsInvoice
>
CustomsList
;
public
int
ImportType
;
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/ImportDataDto.java
0 → 100644
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
public
class
ImportDataDto
{
public
Boolean
Result
;
public
String
Guid
;
public
Integer
Number
;
public
String
FileExtension
;
public
String
FileName
;
public
String
ErrorMsg
;
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/InvoiceMappingDto.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
pwc.taxtech.atms.vat.entity.InvoiceMapping
;
import
java.util.Date
;
public
class
InvoiceMappingDto
{
public
String
ID
;
public
String
TranCode
;
public
String
InvoiceCode
;
public
String
InvoiceNumber
;
public
Integer
Period
;
public
String
CreatorID
;
public
Date
CreateTime
;
public
Boolean
IsDuplicate
;
public
String
ID
;
public
String
TranCode
;
public
String
InvoiceCode
;
public
String
InvoiceNumber
;
public
Integer
Period
;
public
String
CreatorID
;
public
Date
CreateTime
;
public
Boolean
IsDuplicate
;
public
InvoiceMapping
extractInvoiceMapping
()
{
InvoiceMapping
invoiceMapping
=
new
InvoiceMapping
();
invoiceMapping
.
setID
(
ID
);
invoiceMapping
.
setTranCode
(
TranCode
);
invoiceMapping
.
setInvoiceCode
(
InvoiceCode
);
invoiceMapping
.
setInvoiceNumber
(
InvoiceNumber
);
invoiceMapping
.
setPeriod
(
Period
);
invoiceMapping
.
setCreatorID
(
CreatorID
);
invoiceMapping
.
setCreateTime
(
CreateTime
);
return
invoiceMapping
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/VoucherDtoOnlyForImport.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
pwc.taxtech.atms.vat.entity.Voucher
;
import
java.math.BigDecimal
;
import
java.util.Date
;
...
...
@@ -25,4 +27,34 @@ public class VoucherDtoOnlyForImport {
public
Integer
Status
;
public
Integer
PartBilledPeriod
;
public
Integer
BilledPeriod
;
public
Integer
getPeriod
()
{
return
Period
;
}
public
Voucher
extractVoucher
(){
Voucher
voucher
=
new
Voucher
();
voucher
.
setVoucherID
(
VoucherID
);
voucher
.
setVID
(
VID
);
voucher
.
setDate
(
date
);
voucher
.
setGroup
(
Group
);
voucher
.
setPeriod
(
Period
);
voucher
.
setCustomerCode
(
CustomerCode
);
voucher
.
setCustomerName
(
CustomerName
);
voucher
.
setSummary
(
Summary
);
voucher
.
setAcctCode
(
AcctCode
);
voucher
.
setDebit
(
Debit
);
voucher
.
setCredit
(
Credit
);
voucher
.
setAttach
(
Attach
);
voucher
.
setItemID
(
ItemID
);
voucher
.
setCreateTime
(
CreateTime
);
voucher
.
setImportType
(
ImportType
);
voucher
.
setCreatorID
(
CreatorID
);
voucher
.
setMonthID
(
MonthID
);
voucher
.
setOriginalPeriod
(
OriginalPeriod
);
voucher
.
setStatus
(
Status
);
voucher
.
setPartBilledPeriod
(
PartBilledPeriod
);
voucher
.
setBilledPeriod
(
BilledPeriod
);
return
voucher
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/VoucherMappingDto.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
pwc.taxtech.atms.vat.entity.VoucherMapping
;
import
java.util.Date
;
import
java.util.List
;
public
class
VoucherMappingDto
{
public
String
ID
;
...
...
@@ -12,4 +15,18 @@ public class VoucherMappingDto {
public
String
CreatorID
;
public
Date
CreateTime
;
public
Boolean
IsDuplicate
;
public
VoucherMapping
extractVoucherMapping
(){
VoucherMapping
voucherMapping
=
new
VoucherMapping
();
voucherMapping
.
setID
(
ID
);
voucherMapping
.
setTranCode
(
TranCode
);
voucherMapping
.
setVID
(
VID
);
voucherMapping
.
setGroup
(
Group
);
voucherMapping
.
setPeriod
(
Period
);
voucherMapping
.
setItemID
(
ItemID
);
voucherMapping
.
setCreatorID
(
CreatorID
);
voucherMapping
.
setCreateTime
(
CreateTime
);
return
voucherMapping
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/FinanceDataImportService.java
deleted
100644 → 0
View file @
1b005937
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/CustomsInvoiceServiceImpl.java
View file @
649d4716
...
...
@@ -3,6 +3,7 @@ package pwc.taxtech.atms.vat.service.impl;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
pwc.taxtech.atms.common.CommonUtils
;
import
pwc.taxtech.atms.constant.enums.EnumTbImportType
;
import
pwc.taxtech.atms.constant.enums.EnumValidationType
;
import
pwc.taxtech.atms.dto.FieldsMapper
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
...
...
@@ -99,7 +100,25 @@ public class CustomsInvoiceServiceImpl extends VatAbstractService {
return
resultOpt
;
}
public
OperationResultDto
ImportCustomsInvoice
(
List
<
CustomsInvoiceDto
>
customsList
,
int
importType
,
String
userId
)
{
return
null
;
public
OperationResultDto
ImportCustomsInvoice
(
List
<
CustomsInvoice
>
custList
,
int
importType
,
String
userId
)
{
try
{
int
periodId
=
0
;
if
(
importType
==
EnumTbImportType
.
CoverImport
.
getCode
())
{
periodId
=
custList
.
get
(
0
).
getPeriodId
().
intValue
();
CustomsInvoiceExample
example
=
new
CustomsInvoiceExample
();
example
.
createCriteria
().
andPeriodIdEqualTo
(
periodId
);
customsInvoiceMapper
.
deleteByExample
(
example
);
}
custList
.
forEach
(
c
->
{
c
.
setCreatorID
(
userId
);
});
custList
.
forEach
(
m
->
customsInvoiceMapper
.
insert
(
m
));
// UpdateCustomsInvoiceValidation(userId, periodId);//todo:[validation] to be continue (neo)
return
new
OperationResultDto
(
true
,
""
);
}
catch
(
Exception
ex
)
{
return
new
OperationResultDto
(
false
,
ex
.
getMessage
());
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FileUploadAdapter.java
View file @
649d4716
...
...
@@ -124,6 +124,7 @@ public class FileUploadAdapter {
}
private
FileParamBean
getQueryStringParameters
(
MultipartHttpServletRequest
request
)
{
FileParamBean
param
=
new
FileParamBean
();
param
.
fileName
=
request
.
getParameter
(
FILE_NAME
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FinanceDataImportServiceImpl.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.collect.Lists
;
import
org.apache.ibatis.jdbc.ScriptRunner
;
import
org.apache.ibatis.session.SqlSession
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
pwc.taxtech.atms.constant.VatErpImportValidation
;
import
pwc.taxtech.atms.constant.enums.EnumValidationType
;
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.ImportDataDto
;
import
pwc.taxtech.atms.dto.vatdto.VoucherAccountMto
;
import
pwc.taxtech.atms.dto.vatdto.VoucherBalanceDto
;
import
pwc.taxtech.atms.dto.vatdto.VoucherDto
;
...
...
@@ -18,14 +27,16 @@ 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
javax.sound.sampled.DataLine
;
import
java.awt.image.BufferedImage
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.StringReader
;
import
java.net.MalformedURLException
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
...
...
@@ -41,13 +52,15 @@ import static pwc.taxtech.atms.constant.enums.EnumValidationType.ErpBasicCheck;
import
static
pwc
.
taxtech
.
atms
.
constant
.
enums
.
ImageType
.
Alert
;
@Service
public
class
FinanceDataImportServiceImpl
implements
FinanceDataImportService
{
public
class
FinanceDataImportServiceImpl
{
@Autowired
private
ValidationInfoMapper
validationInfoMapper
;
@Autowired
private
VoucherMapper
voucherMapper
;
@Autowired
private
SqlSessionTemplate
dynamicSqlSessionTemplate
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
FinanceDataImportServiceImpl
.
class
);
@Override
public
OperationResultDto
<
List
<
DataCheckDto
>>
getBasicValidationResults
(
String
userId
)
{
Integer
number
=
1
;
List
<
DataCheckDto
>
results
=
new
ArrayList
<>();
...
...
@@ -324,4 +337,105 @@ public class FinanceDataImportServiceImpl implements FinanceDataImportService {
private
List
<
ValidationInfo
>
getValidationData
(
Integer
typeId
)
{
return
getValidationData
(
typeId
,
null
);
}
public
Boolean
ClearTable
(
int
period
,
Boolean
isClearCustTb
)
{
if
(
isClearCustTb
==
null
)
isClearCustTb
=
true
;
ClearCustTable
(
period
,
VatErpImportValidation
.
CompanyBalanceTbName
);
if
(
isClearCustTb
)
{
ClearCustTable
(
period
,
VatErpImportValidation
.
CustBalanceTb
);
}
ClearCustTable
(
period
,
VatErpImportValidation
.
BalanceTb
);
ClearVoucherTable
(
period
);
ClearRemapTable
(
period
);
return
true
;
}
private
void
ClearVoucherTable
(
int
period
)
{
String
command
=
IsImportByPeriod
(
period
)
?
"DELETE FROM "
+
VatErpImportValidation
.
VoucherTbName
+
" WHERE Period = "
+
period
:
"TRUNCATE TABLE "
+
VatErpImportValidation
.
VoucherTbName
;
exeCommand
(
command
);
}
private
boolean
IsImportByPeriod
(
int
period
)
{
return
period
>=
0
;
}
private
void
ClearRemapTable
(
int
period
)
{
String
command
=
IsImportByPeriod
(
period
)
?
"DELETE FROM "
+
VatErpImportValidation
.
AccountRemapTb
+
" WHERE Period = "
+
period
:
"TRUNCATE TABLE "
+
VatErpImportValidation
.
AccountRemapTb
;
exeCommand
(
command
);
}
private
void
ClearCustTable
(
int
period
,
String
tbName
)
{
String
command
=
""
;
if
(
IsImportByPeriod
(
period
)
&&
tbName
!=
VatErpImportValidation
.
BalanceTb
)
{
if
(
tbName
==
VatErpImportValidation
.
CompanyBalanceTbName
)
{
command
=
String
.
format
(
"DELETE FROM %s WHERE PeriodId = %s"
,
tbName
,
period
);
}
if
(
tbName
==
VatErpImportValidation
.
CustBalanceTb
)
{
command
=
String
.
format
(
"DELETE FROM %s WHERE PeriodId >= %s"
,
tbName
,
period
);
}
}
else
{
command
=
"TRUNCATE TABLE "
+
tbName
;
}
exeCommand
(
command
);
}
private
void
exeCommand
(
String
command
)
{
try
(
SqlSession
sqlSession
=
dynamicSqlSessionTemplate
.
getSqlSessionFactory
().
openSession
();)
{
ScriptRunner
scriptRunner
=
new
ScriptRunner
(
sqlSession
.
getConnection
());
scriptRunner
.
setAutoCommit
(
true
);
scriptRunner
.
runScript
(
new
StringReader
(
command
));
}
}
public
void
DeleteErpValidation
()
{
List
<
Integer
>
deleteTypes
=
Lists
.<
Integer
>
newArrayList
(
EnumValidationType
.
ErpBasicCheck
.
getCode
(),
EnumValidationType
.
ErpCorrect
.
getCode
(),
EnumValidationType
.
ErpDuplicate
.
getCode
());
ValidationInfoExample
example
=
new
ValidationInfoExample
();
example
.
createCriteria
().
andImportTypeIdIn
(
deleteTypes
);
validationInfoMapper
.
deleteByExample
(
example
);
}
public
ImportDataDto
ImportData
(
String
projectYear
,
String
importMethod
,
String
importType
,
Integer
period
,
String
fileFullPath
,
MultipartFile
f
,
String
schemaPath
,
String
userId
)
{
logger
.
info
(
"开始导入数据: importMethod: {0}, importType: {1}"
,
importMethod
,
importType
);
ImportDataDto
importResult
=
new
ImportDataDto
();
String
ZipFileFolder
=
""
;
try
{
if
(
importMethod
==
VatErpImportValidation
.
ImportMethod_OneClick
)
{
// UnZipDataFile(fileFullPath, schemaPath);//todo: import data tobe continue(neo)
// ImportBalance(ZipFileFolder, period);
// ImportVoucher(ZipFileFolder, period);
}
if
(
importMethod
==
VatErpImportValidation
.
ImportMethod_Universal
)
{
// UniversalImportData(period, fileFullPath, f.getName(), schemaPath);
}
// SynAccountFromTaxAdmin(period, userId);
importResult
.
Result
=
true
;
}
catch
(
Exception
ex
)
{
importResult
.
Result
=
false
;
}
return
importResult
;
}
public
void
UpdateCompanyBalanceNullValue
()
{
String
command
=
"UPDATE CompanyBalance SET BegDebitBal = 0 WHERE BegDebitBal IS NULL"
+
" UPDATE CompanyBalance SET BegCreditBal = 0 WHERE BegCreditBal IS NULL"
+
" UPDATE CompanyBalance SET BegBal = 0 WHERE BegBal IS NULL"
+
" UPDATE CompanyBalance SET EndBal = 0 WHERE EndBal IS NULL"
+
" UPDATE CompanyBalance SET EndDebitBal = 0 WHERE EndDebitBal IS NULL"
+
" UPDATE CompanyBalance SET EndCreditBal = 0 WHERE EndCreditBal IS NULL"
+
" UPDATE CompanyBalance SET DebitBal = 0 WHERE DebitBal IS NULL"
+
" UPDATE CompanyBalance SET CreditBal = 0 WHERE CreditBal IS NULL"
;
exeCommand
(
command
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/JournalEntryImportServiceImpl.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
com.google.common.collect.Lists
;
import
com.mysql.jdbc.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
pwc.taxtech.atms.common.PagingList
;
import
pwc.taxtech.atms.constant.Constant
;
import
pwc.taxtech.atms.constant.DataImport
;
import
pwc.taxtech.atms.constant.enums.EnumTbImportType
;
import
pwc.taxtech.atms.constant.enums.EnumValidationType
;
import
pwc.taxtech.atms.constant.enums.VatImportType
;
import
pwc.taxtech.atms.dto.FieldsMapper
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
...
...
@@ -11,13 +18,24 @@ import pwc.taxtech.atms.dto.vatdto.VoucherDto;
import
pwc.taxtech.atms.dto.vatdto.VoucherDtoOnlyForImport
;
import
pwc.taxtech.atms.vat.dao.JournalEntryImportMapper
;
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
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.function.ToDoubleFunction
;
import
java.util.function.ToIntFunction
;
import
java.util.stream.Collectors
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
WholeYear
;
...
...
@@ -29,6 +47,11 @@ public class JournalEntryImportServiceImpl {
@Autowired
ValidationInfoMapper
validationInfoMapper
;
private
final
static
String
_tableName
=
"Voucher"
;
private
final
static
String
_validationTableName
=
"ValidationInfo"
;
@Autowired
private
VoucherMapper
voucherMapper
;
public
PagingResultDto
<
VoucherDto
>
qeryJournalEntryData
(
QueryJeDto
queryJeDto
)
{
PagingResultDto
<
VoucherDto
>
qResult
=
new
PagingResultDto
<
VoucherDto
>();
qResult
.
setPageInfo
(
queryJeDto
.
getPageInfo
());
...
...
@@ -88,25 +111,137 @@ public class JournalEntryImportServiceImpl {
if
(
period
.
intValue
()
!=
WholeYear
)
validationInfoExample
.
createCriteria
().
andImportTypeIdEqualTo
(
type
).
andPeriodIdEqualTo
(
period
);
else
validationInfoExample
.
createCriteria
().
andImportTypeIdEqualTo
(
type
);
return
validationInfoMapper
.
selectByExample
(
validationInfoExample
);
}
public
void
ImportJournalEntryData
(
List
<
VoucherDtoOnlyForImport
>
journalEntryList
,
Integer
importType
,
String
userID
)
{
if
(
journalEntryList
.
size
()
>
0
)
{
Set
<
Integer
>
periods
=
journalEntryList
.
stream
().
collect
(
Collectors
.
groupingBy
(
VoucherDtoOnlyForImport:
:
getPeriod
,
Collectors
.
counting
())).
keySet
();
return
validationInfoMapper
.
selectByExample
(
validationInfoExample
);
journalEntryList
.
forEach
(
m
->
{
m
.
VoucherID
=
UUID
.
randomUUID
().
toString
();
m
.
CreatorID
=
userID
;
m
.
CreateTime
=
new
Date
();
});
if
(
importType
==
EnumTbImportType
.
CoverImport
.
getCode
())
{
periods
.
forEach
(
m
->
ClearTableData
(
m
,
_tableName
));
}
public
void
ImportJournalEntryData
(
List
<
VoucherDtoOnlyForImport
>
voucherList
,
Integer
importType
,
String
id
)
{
journalEntryList
.
forEach
(
m
->
voucherMapper
.
insert
(
m
.
extractVoucher
()));
// ValidateJournalEntryByPeriods(userID);//todo:[validation] to be continue (neo)
}
}
private
void
ClearTableData
(
Integer
period
,
String
tableName
)
{
switch
(
tableName
)
{
case
_tableName:
VoucherExample
example
=
new
VoucherExample
();
example
.
createCriteria
().
andPeriodEqualTo
(
period
).
andImportTypeEqualTo
(
VatImportType
.
JournalEntry
.
getCode
());
voucherMapper
.
deleteByExample
(
period
>
0
?
example
:
null
);
break
;
case
_validationTableName:
ValidationInfoExample
example1
=
new
ValidationInfoExample
();
example1
.
createCriteria
().
andPeriodIdEqualTo
(
period
).
andImportTypeIdEqualTo
(
EnumValidationType
.
JournalEntry
.
getCode
());
validationInfoMapper
.
deleteByExample
(
period
>
0
?
example1
:
null
);
}
}
public
OperationResultDto
<
List
<
OperationResultDto
<
List
<
VoucherDtoOnlyForImport
>>>>
ImportAuditAdjust
(
List
<
VoucherDtoOnlyForImport
>
voucherList
,
int
period
,
Integer
importType
,
String
id
)
{
return
null
;
int
period
,
Integer
importType
,
String
userID
)
{
OperationResultDto
<
List
<
OperationResultDto
<
List
<
VoucherDtoOnlyForImport
>>>>
result
=
new
OperationResultDto
<>();
result
.
setResult
(
true
);
int
num
=
1
;
for
(
VoucherDtoOnlyForImport
v
:
voucherList
)
{
v
.
VoucherID
=
UUID
.
randomUUID
().
toString
();
v
.
VID
=
String
.
format
(
"%sNO%s"
,
new
SimpleDateFormat
(
"MMddHHmmss"
).
format
(
new
Date
()),
num
);
v
.
Group
=
v
.
VID
;
num
++;
v
.
CreatorID
=
userID
;
if
(
v
.
CreateTime
==
null
)
{
v
.
date
=
new
Date
();
v
.
CreateTime
=
v
.
date
;
}
v
.
ImportType
=
VatImportType
.
AuditAdjust
.
getCode
();
}
public
List
<
VoucherDto
>
GetAuditAdjust
(
int
period
)
{
return
null
;
result
.
setData
(
new
ArrayList
<>());
List
<
VoucherDtoOnlyForImport
>
emptyItems
=
voucherList
.
stream
().
filter
(
dto
->
StringUtils
.
isEmptyOrWhitespaceOnly
(
dto
.
AcctCode
)
||
dto
.
Credit
==
null
||
dto
.
Debit
==
null
).
collect
(
Collectors
.
toList
());
if
(
emptyItems
.
size
()
>
0
)
{
result
.
setResult
(
false
);
OperationResultDto
<
List
<
VoucherDtoOnlyForImport
>>
rr
=
new
OperationResultDto
<>();
rr
.
setData
(
emptyItems
);
rr
.
setResult
(
false
);
rr
.
setResultMsg
(
DataImport
.
EmptyField
);
result
.
getData
().
add
(
rr
);
}
public
PagingResultDto
<
VoucherDto
>
QueryAuditAdjust
(
QueryJeDto
queryDto
)
{
return
null
;
emptyItems
=
voucherList
.
stream
().
filter
(
dto
->
(
dto
.
AcctCode
!=
null
&&
dto
.
AcctCode
.
length
()
>
50
)
||
(
dto
.
Summary
!=
null
&&
dto
.
Summary
.
length
()
>
500
)).
collect
(
Collectors
.
toList
());
if
(
emptyItems
.
size
()
>
0
)
{
result
.
setResult
(
false
);
result
.
setResult
(
false
);
OperationResultDto
<
List
<
VoucherDtoOnlyForImport
>>
rr
=
new
OperationResultDto
<>();
rr
.
setData
(
emptyItems
);
rr
.
setResult
(
false
);
rr
.
setResultMsg
(
DataImport
.
OverLengthField
);
result
.
getData
().
add
(
rr
);
}
if
(
result
.
getResult
())
{
if
(
importType
==
EnumTbImportType
.
CoverImport
.
getCode
())
{
Set
<
Integer
>
perods
=
voucherList
.
stream
().
collect
(
Collectors
.
groupingBy
(
VoucherDtoOnlyForImport:
:
getPeriod
,
Collectors
.
counting
())).
keySet
();
VoucherExample
example
=
new
VoucherExample
();
example
.
createCriteria
().
andPeriodIn
(
Lists
.
newArrayList
(
period
)).
andImportTypeEqualTo
(
VatImportType
.
AuditAdjust
.
getCode
());
voucherMapper
.
deleteByExample
(
example
);
}
voucherList
.
forEach
(
m
->
voucherMapper
.
insert
(
m
.
extractVoucher
()));
}
return
result
;
}
public
List
<
Voucher
>
GetAuditAdjust
(
int
period
)
{
VoucherExample
example
=
new
VoucherExample
();
example
.
createCriteria
().
andPeriodEqualTo
(
period
).
andImportTypeEqualTo
(
VatImportType
.
AuditAdjust
.
getCode
());
List
<
Voucher
>
result
=
voucherMapper
.
selectByExample
(
example
);
result
.
stream
().
sorted
(
Comparator
.
comparing
(
Voucher:
:
getAcctCode
));
return
result
;
}
public
PagingResultDto
<
Voucher
>
QueryAuditAdjust
(
QueryJeDto
queryDto
)
{
PagingResultDto
<
Voucher
>
qRsult
=
new
PagingResultDto
<>();
qRsult
.
setPageInfo
(
queryDto
.
getPageInfo
());
qRsult
.
setList
(
new
ArrayList
<>());
qRsult
.
setCalculateData
(
new
Voucher
());
VoucherExample
example
=
new
VoucherExample
();
VoucherExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andImportTypeEqualTo
(
VatImportType
.
AuditAdjust
.
getCode
());
if
(
queryDto
.
getPeriodId
()
>
Constant
.
WholeYear
)
criteria
.
andPeriodEqualTo
(
queryDto
.
getPeriodId
());
List
<
Voucher
>
query
=
voucherMapper
.
selectByExample
(
example
);
qRsult
.
getPageInfo
().
setTotalCount
(
query
.
size
());
BigDecimal
sumDebit
=
new
BigDecimal
(
0
);
BigDecimal
sumCredit
=
new
BigDecimal
(
0
);
if
(
query
.
size
()
>
0
)
for
(
Voucher
v
:
query
)
{
sumDebit
=
sumDebit
.
add
(
v
.
getDebit
());
sumCredit
=
sumCredit
.
add
(
v
.
getCredit
());
}
qRsult
.
getCalculateData
().
setDebit
(
sumDebit
);
qRsult
.
getCalculateData
().
setCredit
(
sumCredit
);
if
(
qRsult
.
getPageInfo
().
getTotalCount
()>
0
){
PagingList
pagingList
=
new
PagingList
(
query
,
qRsult
.
getPageInfo
());
qRsult
.
setList
(
pagingList
.
getPagingList
());
}
return
qRsult
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/VoucherInvoiceMappingServiceImpl.java
View file @
649d4716
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
com.mysql.jdbc.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
pwc.taxtech.atms.
dao.AreaRegionMapper
;
import
pwc.taxtech.atms.
constant.DataImport
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.dto.vatdto.InvoiceMappingDto
;
import
pwc.taxtech.atms.dto.vatdto.VoucherMappingDto
;
...
...
@@ -13,8 +14,10 @@ import pwc.taxtech.atms.vat.entity.InvoiceMappingExample;
import
pwc.taxtech.atms.vat.entity.VoucherMapping
;
import
pwc.taxtech.atms.vat.entity.VoucherMappingExample
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
public
class
VoucherInvoiceMappingServiceImpl
{
...
...
@@ -45,11 +48,100 @@ public class VoucherInvoiceMappingServiceImpl {
public
OperationResultDto
<
List
<
OperationResultDto
<
List
<
VoucherMappingDto
>>>>
saveVourcherMappings
(
List
<
VoucherMappingDto
>
list
,
int
period
,
boolean
isAddition
)
{
return
null
;
OperationResultDto
<
List
<
OperationResultDto
<
List
<
VoucherMappingDto
>>>>
result
=
new
OperationResultDto
<>();
result
.
setResult
(
true
);
result
.
setData
(
new
ArrayList
<
OperationResultDto
<
List
<
VoucherMappingDto
>>>());
List
<
VoucherMappingDto
>
emptyItems
=
list
.
stream
().
filter
(
m
->
StringUtils
.
isEmptyOrWhitespaceOnly
(
m
.
TranCode
)
||
StringUtils
.
isEmptyOrWhitespaceOnly
(
m
.
VID
)
||
StringUtils
.
isEmptyOrWhitespaceOnly
(
m
.
Group
)
||
StringUtils
.
isEmptyOrWhitespaceOnly
(
m
.
ItemID
)).
collect
(
Collectors
.
toList
());
if
(
emptyItems
.
size
()
>
0
)
{
result
.
setResult
(
false
);
OperationResultDto
<
List
<
VoucherMappingDto
>>
rr
=
new
OperationResultDto
<>();
rr
.
setData
(
emptyItems
);
rr
.
setResult
(
false
);
rr
.
setResultMsg
(
DataImport
.
EmptyField
);
result
.
getData
().
add
(
rr
);
}
emptyItems
=
list
.
stream
().
filter
(
dto
->
dto
.
TranCode
!=
null
&&
dto
.
TranCode
.
length
()
>
50
||
(
dto
.
VID
!=
null
&&
dto
.
VID
.
length
()
>
50
)
||
(
dto
.
Group
!=
null
&&
dto
.
Group
.
length
()
>
50
)
||
(
dto
.
ItemID
!=
null
&&
dto
.
ItemID
.
length
()
>
50
)
).
collect
(
Collectors
.
toList
());
if
(
emptyItems
.
size
()
>
0
)
{
result
.
setResult
(
false
);
OperationResultDto
<
List
<
VoucherMappingDto
>>
rr
=
new
OperationResultDto
<>();
rr
.
setData
(
emptyItems
);
rr
.
setResult
(
false
);
rr
.
setResultMsg
(
DataImport
.
OverLengthField
);
result
.
getData
().
add
(
rr
);
}
if
(
result
.
getResult
())
{
if
(!
isAddition
)
{
VoucherMappingExample
voucherMappingExample
=
new
VoucherMappingExample
();
voucherMappingExample
.
createCriteria
().
andPeriodEqualTo
(
period
);
voucherMappingMapper
.
deleteByExample
(
voucherMappingExample
);
}
list
.
forEach
(
m
->
voucherMappingMapper
.
insert
(
m
.
extractVoucherMapping
()));
}
// ValidDBVoucherMapping(period); todo:[validation] to be continue (neo)
return
result
;
}
public
OperationResultDto
<
List
<
OperationResultDto
<
List
<
InvoiceMappingDto
>>>>
SaveInvoiceMappings
(
List
<
InvoiceMappingDto
>
list
,
int
period
,
boolean
isAddition
)
{
return
null
;
OperationResultDto
<
List
<
OperationResultDto
<
List
<
InvoiceMappingDto
>>>>
result
=
new
OperationResultDto
<>();
result
.
setResult
(
true
);
result
.
setData
(
new
ArrayList
<
OperationResultDto
<
List
<
InvoiceMappingDto
>>>());
List
<
InvoiceMappingDto
>
emptyItems
=
list
.
stream
().
filter
(
m
->
StringUtils
.
isEmptyOrWhitespaceOnly
(
m
.
TranCode
)
||
StringUtils
.
isEmptyOrWhitespaceOnly
(
m
.
InvoiceCode
)
||
StringUtils
.
isEmptyOrWhitespaceOnly
(
m
.
InvoiceNumber
)).
collect
(
Collectors
.
toList
());
if
(
emptyItems
.
size
()
>
0
)
{
result
.
setResult
(
false
);
OperationResultDto
<
List
<
InvoiceMappingDto
>>
rr
=
new
OperationResultDto
<>();
rr
.
setData
(
emptyItems
);
rr
.
setResult
(
false
);
rr
.
setResultMsg
(
DataImport
.
EmptyField
);
result
.
getData
().
add
(
rr
);
}
emptyItems
=
list
.
stream
().
filter
(
dto
->
dto
.
TranCode
!=
null
&&
dto
.
TranCode
.
length
()
>
50
||
(
dto
.
InvoiceCode
!=
null
&&
dto
.
InvoiceCode
.
length
()
>
50
)
||
(
dto
.
InvoiceNumber
!=
null
&&
dto
.
InvoiceNumber
.
length
()
>
50
)
).
collect
(
Collectors
.
toList
());
if
(
emptyItems
.
size
()
>
0
)
{
result
.
setResult
(
false
);
OperationResultDto
<
List
<
InvoiceMappingDto
>>
rr
=
new
OperationResultDto
<>();
rr
.
setData
(
emptyItems
);
rr
.
setResult
(
false
);
rr
.
setResultMsg
(
DataImport
.
OverLengthField
);
result
.
getData
().
add
(
rr
);
}
if
(
result
.
getResult
())
{
if
(!
isAddition
)
{
InvoiceMappingExample
invoiceMappingExample
=
new
InvoiceMappingExample
();
invoiceMappingExample
.
createCriteria
().
andPeriodEqualTo
(
period
);
invoiceMappingMapper
.
deleteByExample
(
invoiceMappingExample
);
}
list
.
forEach
(
m
->
invoiceMappingMapper
.
insert
(
m
.
extractInvoiceMapping
()));
}
// ValidDBInvoiceMapping(period);todo:[validation] to be continue (neo)
return
result
;
}
}
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