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
289e24a7
Commit
289e24a7
authored
Nov 09, 2018
by
neo.wang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_oracle_neo' into 'dev_oracle'
Dev oracle neo See merge request root/atms!180
parents
e522e8a9
f6a33be1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
111 deletions
+116
-111
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+23
-28
ReportServiceImpl.java
.../pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
+13
-42
FormulaAdminMapper.java
...rc/main/java/pwc/taxtech/atms/dao/FormulaAdminMapper.java
+9
-1
PeriodCellDataMapper.java
...n/java/pwc/taxtech/atms/vat/dao/PeriodCellDataMapper.java
+35
-40
PCTEntity.java
.../src/main/java/pwc/taxtech/atms/vat/entity/PCTEntity.java
+36
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
289e24a7
...
...
@@ -85,24 +85,12 @@ public class ReportGeneratorImpl {
return
periodResources
;
}
@Transactional
public
void
updateManaCellDataWithNewReport
(
String
projectId
,
Integer
period
)
{
List
<
MergerManaualCellData
>
result
=
periodCellDataMapper
.
selectManualToBeMerged
(
projectId
,
period
);
if
(!
result
.
isEmpty
())
{
result
.
forEach
(
m
->
{
PeriodCellData
pcd
=
new
PeriodCellData
();
pcd
.
setId
(
m
.
getId
());
pcd
.
setReportId
(
m
.
getNewReportId
());
periodCellDataMapper
.
updateByPrimaryKeySelective
(
pcd
);
});
}
}
@Transactional
public
void
updateWorkbookCaclsValueToDb
(
String
projectId
,
Integer
period
,
Workbook
workbook
,
PeriodResources
resources
,
PeriodJob
job
)
{
for
(
int
i
=
0
;
i
<
workbook
.
getNumberOfSheets
();
i
++)
{
Sheet
sheet
=
workbook
.
getSheetAt
(
i
);
String
code
=
sheet
.
getSheetName
();
job
.
setCurrentStep
(
code
);
Optional
<
PeriodTemplate
>
periodTemplate
=
resources
.
getPeriodTemplates
().
stream
()
.
filter
(
a
->
a
.
getCode
().
equals
(
code
))
.
findFirst
();
...
...
@@ -325,15 +313,19 @@ public class ReportGeneratorImpl {
cellData
.
setUpdateTime
(
new
Date
());
cellData
.
setProjectId
(
projectId
);
cellData
.
setPeriod
(
period
);
periodCellDataMapper
.
insertSelective
(
cellData
);
//after insert celldata, insert the celldatasource for link celldata and datasource
PeriodDataSourceExample
dataSourceExample
=
new
PeriodDataSourceExample
();
dataSourceExample
.
createCriteria
().
andPeriodEqualTo
(
period
)
dataSourceExample
.
createCriteria
().
andPeriodEqualTo
(
period
)
.
andProjectIdEqualTo
(
projectId
)
.
andCellTemplateIdEqualTo
(
tempPeriodCellTemplate
.
get
().
getCellTemplateId
());
List
<
PeriodDataSource
>
dataSourceList
=
SpringContextUtil
.
periodDataSourceMapper
.
selectByExample
(
dataSourceExample
);
for
(
int
ii
=
0
;
ii
<
dataSourceList
.
size
();
ii
++)
{
PeriodDataSource
dataSource
=
dataSourceList
.
get
(
ii
);
if
(
dataSource
.
getType
().
intValue
()
==
10
)
{
//s手工数据源
cellData
.
setData
(
dataSource
.
getAmount
()
+
""
);
}
PeriodCellDataSource
cellDataSource
=
new
PeriodCellDataSource
();
cellDataSource
.
setId
(
distributedIdService
.
nextId
());
cellDataSource
.
setCellTemplateId
(
tempPeriodCellTemplate
.
get
().
getCellTemplateId
());
...
...
@@ -345,6 +337,8 @@ public class ReportGeneratorImpl {
cellDataSource
.
setProjectId
(
projectId
);
SpringContextUtil
.
periodCellDataSourceMapper
.
insertSelective
(
cellDataSource
);
}
periodCellDataMapper
.
insertSelective
(
cellData
);
}
}
}
...
...
@@ -353,9 +347,7 @@ public class ReportGeneratorImpl {
e
.
printStackTrace
();
job
.
setStatus
(
WrapPeriodJobDto
.
STATUS_ERROR
);
job
.
setErrorMsg
(
"cacals report for code "
+
code
+
" failed"
);
}
finally
{
job
.
setCurrentStep
(
code
);
periodJobMapper
.
updateByPrimaryKey
(
job
);
}
}
...
...
@@ -642,24 +634,27 @@ public class ReportGeneratorImpl {
if
(!
parameter
.
isEmpty
())
{
List
<
PCTEntity
>
pctResults
=
periodCellDataMapper
.
queryByPCTs
(
parameter
,
projectId
);
Map
<
PCTEntity
,
BigDecimal
>
pctCache
=
new
HashMap
<>();
Map
<
PCTEntity
,
PCTEntity
>
pctCache
=
new
HashMap
<>();
pctResults
.
forEach
(
m
->
{
BigDecimal
data
=
null
;
try
{
data
=
new
BigDecimal
(
m
.
getData
());
}
catch
(
NumberFormatException
e
)
{
logger
.
warn
(
"number format ecption for parameter {}"
,
m
);
data
=
BigDecimal
.
ZERO
;
}
pctCache
.
put
(
m
,
data
);
pctCache
.
put
(
m
,
m
);
});
configMapToPCTs
.
forEach
((
k
,
v
)
->
{
v
.
forEach
(
pctStr
->
{
List
<
PCTEntity
>
entities
=
formulaMapToPCT
.
get
(
pctStr
);
BigDecimal
result
=
new
BigDecimal
(
"0"
);
StringBuilder
result
=
new
StringBuilder
(
"0"
);
for
(
PCTEntity
entity
:
entities
)
{
result
=
pctCache
.
containsKey
(
entity
)
?
result
.
add
(
pctCache
.
get
(
entity
))
:
result
;
if
(
pctCache
.
containsKey
(
entity
)){
PCTEntity
pct
=
pctCache
.
get
(
entity
);
if
(
pct
.
getDsCount
()==
1
&&
pct
.
getAmount
()!=
null
){
result
.
append
(
"+"
).
append
(
pct
.
getAmount
());
}
else
if
(
pct
.
getDsCount
()>
1
&&
pct
.
getAmount
()!=
null
&&!
StringUtils
.
isEmpty
(
pct
.
getFormulaExp
())){
result
.
append
(
"+"
).
append
(
pct
.
getFormulaExp
()).
append
(
"+"
).
append
(
pct
.
getAmount
());
}
else
if
(
pct
.
getAmount
()==
null
&&!
StringUtils
.
isNotEmpty
(
pct
.
getData
())){
result
.
append
(
pct
.
getData
());
}
}
}
k
.
setParsedFormula
(
k
.
getParsedFormula
().
replace
(
pctStr
,
result
.
toString
()));
});
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
View file @
289e24a7
...
...
@@ -201,13 +201,8 @@ public class ReportServiceImpl {
.
andPeriodEqualTo
(
period
);
List
<
PeriodDataSource
>
periodDataSources
=
periodDataSourceMapper
.
selectByExample
(
periodDataSourceExample
);
PeriodCellDataSourceExample
allMappingExample
=
new
PeriodCellDataSourceExample
();
allMappingExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
);
List
<
PeriodCellDataSource
>
allPcds
=
periodCellDataSourceMapper
.
selectByExample
(
allMappingExample
);
Set
<
Long
>
periodDsIds
=
Sets
.
newHashSet
(
Long
.
MAX_VALUE
);
List
<
Long
>
periodManualDsIds
=
new
ArrayList
<>();
List
<
Long
>
periodManualCellDataIds
=
new
ArrayList
<>();
if
(
isMergeManualData
)
{
periodDataSources
.
forEach
(
m
->
{
...
...
@@ -218,36 +213,17 @@ public class ReportServiceImpl {
}
});
if
(!
periodManualDsIds
.
isEmpty
())
{
PeriodCellDataSourceExample
periodCellDataSourceExample
=
new
PeriodCellDataSourceExample
();
periodCellDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
.
andDataSourceIdIn
(
periodManualDsIds
);
List
<
PeriodCellDataSource
>
manualCellDataSource
=
periodCellDataSourceMapper
.
selectByExample
(
periodCellDataSourceExample
);
if
(!
manualCellDataSource
.
isEmpty
())
{
periodManualCellDataIds
.
addAll
(
manualCellDataSource
.
stream
().
map
(
PeriodCellDataSource:
:
getCellDataId
)
.
collect
(
Collectors
.
toList
()));
}
}
if
(!
allPcds
.
isEmpty
())
{
List
<
Long
>
allPcdsIds
=
allPcds
.
stream
().
map
(
m
->
m
.
getDataSourceId
()).
collect
(
Collectors
.
toList
());
allPcdsIds
.
removeAll
(
periodManualDsIds
);
periodDsIds
.
addAll
(
allPcdsIds
);
}
}
else
{
periodDsIds
.
addAll
(
periodDataSources
.
stream
().
map
(
m
->
m
.
getId
()).
collect
(
Collectors
.
toList
()));
if
(!
allPcds
.
isEmpty
())
periodDsIds
.
addAll
(
allPcds
.
stream
().
map
(
m
->
m
.
getDataSourceId
()).
collect
(
Collectors
.
toList
()));
}
PeriodDataSourceDetailExample
periodDataSourceDetailExample
=
new
PeriodDataSourceDetailExample
();
periodDataSourceDetailExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
.
andDataSourceIdIn
(
Lists
.
newArrayList
(
periodDsIds
));
periodDataSourceDetailMapper
.
deleteByExample
(
periodDataSourceDetailExample
);
PeriodCellDataSourceExample
periodCellDataSourceExample
=
new
PeriodCellDataSourceExample
();
periodCellDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
.
andDataSourceIdIn
(
Lists
.
newArrayList
(
periodDsIds
));
periodCellDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
);
periodCellDataSourceMapper
.
deleteByExample
(
periodCellDataSourceExample
);
...
...
@@ -257,35 +233,31 @@ public class ReportServiceImpl {
PeriodReportExample
periodReportExample
=
new
PeriodReportExample
();
periodReportExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
);
periodReportMapper
.
deleteByExample
(
periodReportExample
);
List
<
PeriodReport
>
reports
=
periodReportMapper
.
selectByExample
(
periodReportExample
);
List
<
Long
>
reportIds
=
Lists
.
newArrayList
(
Long
.
MAX_VALUE
);
reportIds
.
addAll
(
reports
.
stream
().
map
(
m
->
m
.
getId
()).
collect
(
Collectors
.
toList
()));
PeriodCellDataExample
periodCellDataExample
=
new
PeriodCellDataExample
();
if
(
isMergeManualData
)
{
if
(
periodManualCellDataIds
.
isEmpty
())
periodManualCellDataIds
.
add
(
Long
.
MAX_VALUE
);
periodCellDataExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
).
andIdNotIn
(
periodManualCellDataIds
);
}
else
{
periodCellDataExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
);
}
periodCellDataExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
);
periodCellDataMapper
.
deleteByExample
(
periodCellDataExample
);
periodReportMapper
.
deleteByExample
(
periodReportExample
);
}
@Transactional
private
void
updateConfig
(
String
projectId
,
Integer
period
,
Boolean
isMergeManualData
,
List
<
Template
>
templates
,
PeriodJob
job
)
{
try
{
job
.
setStatus
(
WrapPeriodJobDto
.
STATUS_BEGIN
);
List
<
Long
>
exceptTemplateIds
=
templateMapper
.
getIdsForExceptTemplate
();
clearPeriodData
(
projectId
,
period
,
exceptTemplateIds
,
isMergeManualData
);
copyTemplateAndConfigFromAdmin
(
projectId
,
templates
,
period
);
}
catch
(
Exception
ex
)
{
job
.
setStatus
(
WrapPeriodJobDto
.
STATUS_ERROR
);
job
.
setErrorMsg
(
"error update config with projectId "
+
projectId
+
" period"
+
period
);
periodJobMapper
.
updateByPrimaryKey
(
job
);
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
finally
{
periodJobMapper
.
updateByPrimaryKey
(
job
);
}
}
...
...
@@ -515,15 +487,14 @@ public class ReportServiceImpl {
reportGenerator
.
updateWorkbookCaclsValueToDb
(
projectId
,
periodParam
,
workbook
,
resources
,
genJob
);
reportGenerator
.
updateManaCellDataWithNewReport
(
projectId
,
periodParam
);
genJob
.
setStatus
(
WrapPeriodJobDto
.
STATUS_END
);
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
genJob
.
setStatus
(
WrapPeriodJobDto
.
STATUS_ERROR
);
genJob
.
setErrorMsg
(
"Server error"
);
}
finally
{
genJob
.
setErrorMsg
(
"Sever error"
);
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
e
.
printStackTrace
();
}
}
}).
start
();
...
...
atms-dao/src/main/java/pwc/taxtech/atms/dao/FormulaAdminMapper.java
View file @
289e24a7
...
...
@@ -27,7 +27,15 @@ public interface FormulaAdminMapper extends MyMapper {
" JOIN "
+
" cell_template ON template.id = cell_template.report_template_id "
+
"WHERE "
+
" template.template_group_id = #{groupId}"
)
" template.id IN ( "
+
" SELECT "
+
" ID "
+
" FROM "
+
" TEMPLATE "
+
" WHERE "
+
" TEMPLATE_GROUP_ID = #{groupId} "
+
" AND IS_ACTIVE_ASSOCIATION = 1 "
+
" )"
)
List
<
CellTemplatePerGroupDto
>
getCellTemplatePerGroupDto
(
@Param
(
"groupId"
)
Long
groupId
);
...
...
atms-dao/src/main/java/pwc/taxtech/atms/vat/dao/PeriodCellDataMapper.java
View file @
289e24a7
...
...
@@ -116,50 +116,46 @@ public interface PeriodCellDataMapper extends MyVatMapper {
int
batchInsert
(
List
<
PeriodCellData
>
list
);
@Select
(
"<script>"
+
"SELECT "
+
" R.PERIOD, C.CELL_TEMPLATE_ID AS CELLTEMPLATEID, DATA "
+
"SELECT "
+
" count( pcds.DATA_SOURCE_ID ) AS dsCount, "
+
" pcd.ID as cellId, "
+
" pcd.DATA as data, "
+
" pcd.FORMULA_EXP as formulaExp, "
+
" pcd.CELL_TEMPLATE_ID as cellTemplateId, "
+
" pcd.PERIOD as period, "
+
" temp.AMOUNT as amount "
+
"FROM "
+
" PERIOD_CELL_DATA C, "
+
" PERIOD_REPORT R "
+
" PERIOD_CELL_DATA pcd "
+
" JOIN PERIOD_CELL_DATA_SOURCE pcds ON pcd.ID = pcds.CELL_DATA_ID "
+
" LEFT JOIN ( "
+
" SELECT "
+
" pcd.ID, "
+
" pds.TYPE, "
+
" pds.AMOUNT, "
+
" pds.PERIOD, "
+
" pds.PROJECT_ID "
+
" FROM "
+
" PERIOD_CELL_DATA pcd "
+
" JOIN PERIOD_CELL_DATA_SOURCE pcds ON pcd.ID = pcds.CELL_DATA_ID "
+
" JOIN PERIOD_DATA_SOURCE pds ON pcds.DATA_SOURCE_ID = pds.ID "
+
" WHERE "
+
" pcd.PROJECT_ID = #{projectId} "
+
" AND pds.TYPE = 10 "
+
" ) temp ON pcd.ID = temp.ID AND pcd.PROJECT_ID = temp.PROJECT_ID and pcd.PERIOD = temp.period "
+
"WHERE "
+
" C.REPORT_ID = R.ID"
+
" AND C.PROJECT_ID = #{projectId} AND "
+
" "
+
" pcd.PERIOD = 10 "
+
" AND pcd.PROJECT_ID = #{projectId} AND "
+
" <foreach item=\"item\" index=\"index\" collection=\"list\""
+
" open=\"(\" separator=\"OR\" close=\")\">"
+
" (
R.PERIOD=#{item.period} AND C
.CELL_TEMPLATE_ID=#{item.cellTemplateId} )"
+
" (
pcd.PERIOD=#{item.period} AND pcd
.CELL_TEMPLATE_ID=#{item.cellTemplateId} )"
+
" </foreach>"
+
"GROUP BY "
+
" pcd.ID, "
+
" pcd.DATA, "
+
" pcd.FORMULA_EXP, "
+
" pcd.CELL_TEMPLATE_ID, "
+
" pcd.PERIOD, "
+
" temp.AMOUNT"
+
"</script>"
)
List
<
PCTEntity
>
queryByPCTs
(
@Param
(
"list"
)
Set
<
PCTEntity
>
parameter
,
@Param
(
"projectId"
)
String
projectId
);
@Select
(
""
+
"SELECT "
+
" d.ID AS id, "
+
" d.REPORT_ID AS reportId, "
+
" d.CELL_TEMPLATE_ID AS cellTemplateId, "
+
" p.REPORT_TEMPLATE_ID AS templateId, "
+
" t.ID AS newReportId "
+
"FROM "
+
" PERIOD_CELL_DATA d "
+
" JOIN PERIOD_CELL_TEMPLATE p ON d.CELL_TEMPLATE_ID = p.CELL_TEMPLATE_ID "
+
" LEFT JOIN PERIOD_REPORT t ON p.REPORT_TEMPLATE_ID = t.TEMPLATE_ID "
+
"WHERE "
+
" d.PROJECT_ID = #{projectId} "
+
" AND p.PROJECT_ID = #{projectId} "
+
" AND t.PROJECT_ID = #{projectId} "
+
" AND d.PERIOD = #{period} "
+
" AND p.PERIOD = #{period} "
+
" AND t.PERIOD = #{period} "
+
" AND d.REPORT_ID NOT IN ( "
+
" SELECT "
+
" ID "
+
" FROM "
+
" PERIOD_REPORT "
+
" WHERE "
+
" PROJECT_ID = #{projectId} "
+
" AND PERIOD = #{period} "
+
" )"
+
""
)
List
<
MergerManaualCellData
>
selectManualToBeMerged
(
@Param
(
"projectId"
)
String
projectId
,
@Param
(
"period"
)
Integer
period
);
}
\ No newline at end of file
atms-dao/src/main/java/pwc/taxtech/atms/vat/entity/PCTEntity.java
View file @
289e24a7
...
...
@@ -4,6 +4,10 @@ public class PCTEntity {
Integer
period
;
Long
cellTemplateId
;
String
data
;
String
formulaExp
;
Long
cellId
;
String
amount
;
Integer
dsCount
;
public
PCTEntity
()
{
}
...
...
@@ -49,4 +53,36 @@ public class PCTEntity {
public
void
setData
(
String
data
)
{
this
.
data
=
data
;
}
public
String
getFormulaExp
()
{
return
formulaExp
;
}
public
void
setFormulaExp
(
String
formulaExp
)
{
this
.
formulaExp
=
formulaExp
;
}
public
Long
getCellId
()
{
return
cellId
;
}
public
void
setCellId
(
Long
cellId
)
{
this
.
cellId
=
cellId
;
}
public
String
getAmount
()
{
return
amount
;
}
public
void
setAmount
(
String
amount
)
{
this
.
amount
=
amount
;
}
public
Integer
getDsCount
()
{
return
dsCount
;
}
public
void
setDsCount
(
Integer
dsCount
)
{
this
.
dsCount
=
dsCount
;
}
}
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