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
42dd42e1
Commit
42dd42e1
authored
Jul 22, 2018
by
neo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev] ImportInputInvoiceItemData impl
parent
703733d3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
3 deletions
+68
-3
ImportInputInvoiceItemDto.java
...wc/taxtech/atms/dto/vatdto/ImportInputInvoiceItemDto.java
+3
-1
InputInvoiceDataImportServiceImpl.java
...s/vat/service/impl/InputInvoiceDataImportServiceImpl.java
+65
-2
No files found.
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/ImportInputInvoiceItemDto.java
View file @
42dd42e1
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
pwc.taxtech.atms.vat.entity.InputVATInvoiceItem
;
import
java.util.List
;
public
class
ImportInputInvoiceItemDto
{
public
List
<
InputVATInvoiceItem
Dto
>
InputInvoiceItemList
;
public
List
<
InputVATInvoiceItem
>
InputInvoiceItemList
;
public
int
ImportType
;
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/InputInvoiceDataImportServiceImpl.java
View file @
42dd42e1
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
org.apache.ibatis.jdbc.ScriptRunner
;
import
org.apache.ibatis.session.SqlSession
;
import
org.mybatis.spring.SqlSessionTemplate
;
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
;
import
pwc.taxtech.atms.dto.PagingResultDto
;
...
...
@@ -13,12 +19,20 @@ import pwc.taxtech.atms.vat.entity.InputVATInvoiceExample;
import
pwc.taxtech.atms.vat.entity.InputVATInvoiceItem
;
import
pwc.taxtech.atms.vat.entity.InputVATInvoiceItemExample
;
import
java.io.StringReader
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
@Service
public
class
InputInvoiceDataImportServiceImpl
extends
VatAbstractService
{
private
static
final
String
_tableName
=
"InputVATInvoice"
;
private
static
final
String
_itemTableName
=
"InputVATInvoiceItem"
;
private
static
final
String
_validationTableName
=
"ValidationInfo"
;
@Autowired
private
SqlSessionTemplate
dynamicSqlSessionTemplate
;
public
PagingResultDto
<
InputVATInvoiceDto
>
getInputInvoiceTreeViewData
(
InputInvoicePreviewQueryParam
paras
)
{
PagingResultDto
<
InputVATInvoiceDto
>
qResult
=
new
PagingResultDto
<>();
...
...
@@ -75,11 +89,60 @@ public class InputInvoiceDataImportServiceImpl extends VatAbstractService {
return
inputVATInvoiceItemMapper
.
selectByExample
(
example
);
}
public
OperationResultDto
ImportInputInvoiceItemData
(
List
<
InputVATInvoiceItemDto
>
inputInvoiceItemList
,
int
importType
,
String
id
)
{
return
null
;
public
OperationResultDto
ImportInputInvoiceItemData
(
List
<
InputVATInvoiceItem
>
inputInvoiceItemDtoList
,
int
importType
,
String
userID
)
{
if
(
inputInvoiceItemDtoList
.
size
()
>
0
)
{
int
period
=
Integer
.
parseInt
(
inputInvoiceItemDtoList
.
get
(
0
).
getID
());
inputInvoiceItemDtoList
.
forEach
(
item
->
{
//导入之前需要将汇总表的主键更新到明细表中,如果找不到汇总信息,则设置为空
InputVATInvoiceExample
example
=
new
InputVATInvoiceExample
();
example
.
createCriteria
().
andInvoiceCodeEqualTo
(
item
.
getInvoiceCode
()).
andInvoiceNumberEqualTo
(
item
.
getInvoiceNumber
());
InputVATInvoice
invoiceTotal
=
inputVATInvoiceMapper
.
selectByExample
(
example
).
stream
().
findFirst
().
get
();
item
.
setInputVATInvoiceID
(
invoiceTotal
==
null
?
""
:
invoiceTotal
.
getID
());
item
.
setID
(
UUID
.
randomUUID
().
toString
());
item
.
setCreatorID
(
userID
);
item
.
setCreateTime
(
new
Date
());
});
//如果是覆盖导入,则先删除该期间的数据,再进行数据导入
if
(
importType
==
EnumTbImportType
.
CoverImport
.
getCode
())
{
ClearTableData
(
period
,
_itemTableName
,
EnumValidationType
.
InputVoiceItem
.
getCode
());
}
//将进项发票明细数据转换为datatable
//调用sqlBulk进行快速导入
inputInvoiceItemDtoList
.
forEach
(
m
->
inputVATInvoiceItemMapper
.
insert
(
m
));
// ValidateInputInvoiceItemInfo(period, userID);//todo:[validation] to be continue (neo)
}
return
new
OperationResultDto
(
true
);
}
public
OperationResultDto
ImportInputInvoiceData
(
List
<
InputVATInvoiceDto
>
inputInvoiceList
,
int
importType
,
String
id
)
{
return
null
;
}
private
void
ClearTableData
(
int
period
,
String
tableName
,
int
importTypeId
)
{
String
clearCommand
=
""
;
if
(
tableName
!=
_validationTableName
)
{
//删除主数据表中的数据
clearCommand
+=
"DELETE FROM "
+
tableName
+
" WHERE PeriodID = "
+
period
+
";"
;
//如果是删除主表信息,则还需要删除明细表数据
if
(
tableName
==
_tableName
)
{
clearCommand
+=
"DELETE FROM "
+
_itemTableName
+
" WHERE PeriodID = "
+
period
+
";"
;
}
}
//删除验证信息表中的数据
clearCommand
+=
"DELETE FROM "
+
_validationTableName
+
" WHERE PeriodID = "
+
period
+
" AND ImportTypeId = "
+
importTypeId
+
";"
;
exeCommand
(
clearCommand
);
}
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
));
}
}
}
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