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
a913acb5
Commit
a913acb5
authored
Nov 08, 2018
by
eddie.woo
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_oracle' of
http://code.tech.tax.asia.pwcinternal.com/root/atms
into dev_oracle
parents
252ed411
1f52b42a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
12 deletions
+138
-12
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+18
-2
ReportServiceImpl.java
.../pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
+37
-10
PeriodCellDataMapper.java
...n/java/pwc/taxtech/atms/vat/dao/PeriodCellDataMapper.java
+33
-0
MergerManaualCellData.java
.../java/pwc/taxtech/atms/vat/dpo/MergerManaualCellData.java
+50
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
a913acb5
...
@@ -14,6 +14,7 @@ import org.slf4j.Logger;
...
@@ -14,6 +14,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
pwc.taxtech.atms.common.POIUtil
;
import
pwc.taxtech.atms.common.POIUtil
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.constant.enums.CellDataSourceType
;
import
pwc.taxtech.atms.constant.enums.CellDataSourceType
;
...
@@ -26,6 +27,7 @@ import pwc.taxtech.atms.exception.Exceptions;
...
@@ -26,6 +27,7 @@ import pwc.taxtech.atms.exception.Exceptions;
import
pwc.taxtech.atms.service.impl.DistributedIdService
;
import
pwc.taxtech.atms.service.impl.DistributedIdService
;
import
pwc.taxtech.atms.service.impl.HttpFileService
;
import
pwc.taxtech.atms.service.impl.HttpFileService
;
import
pwc.taxtech.atms.vat.dao.*
;
import
pwc.taxtech.atms.vat.dao.*
;
import
pwc.taxtech.atms.vat.dpo.MergerManaualCellData
;
import
pwc.taxtech.atms.vat.dpo.PeriodCellTemplateConfigExtendDto
;
import
pwc.taxtech.atms.vat.dpo.PeriodCellTemplateConfigExtendDto
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.*
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.*
;
...
@@ -83,6 +85,20 @@ public class ReportGeneratorImpl {
...
@@ -83,6 +85,20 @@ public class ReportGeneratorImpl {
return
periodResources
;
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
)
{
public
void
updateWorkbookCaclsValueToDb
(
String
projectId
,
Integer
period
,
Workbook
workbook
,
PeriodResources
resources
,
PeriodJob
job
)
{
for
(
int
i
=
0
;
i
<
workbook
.
getNumberOfSheets
();
i
++)
{
for
(
int
i
=
0
;
i
<
workbook
.
getNumberOfSheets
();
i
++)
{
Sheet
sheet
=
workbook
.
getSheetAt
(
i
);
Sheet
sheet
=
workbook
.
getSheetAt
(
i
);
...
@@ -336,9 +352,9 @@ public class ReportGeneratorImpl {
...
@@ -336,9 +352,9 @@ public class ReportGeneratorImpl {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
job
.
setStatus
(
WrapPeriodJobDto
.
STATUS_ERROR
);
job
.
setStatus
(
WrapPeriodJobDto
.
STATUS_ERROR
);
job
.
setErrorMsg
(
"cacals report for code "
+
code
+
" failed"
);
job
.
setErrorMsg
(
"cacals report for code "
+
code
+
" failed"
);
}
finally
{
}
finally
{
job
.
setCurrentStep
(
code
);
job
.
setCurrentStep
(
code
);
periodJobMapper
.
updateByPrimaryKey
(
job
);
periodJobMapper
.
updateByPrimaryKey
(
job
);
}
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
View file @
a913acb5
...
@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl;
...
@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Sets
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.usermodel.Workbook
;
...
@@ -10,6 +11,7 @@ import org.slf4j.Logger;
...
@@ -10,6 +11,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
pwc.taxtech.atms.common.CommonUtils
;
import
pwc.taxtech.atms.common.CommonUtils
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
...
@@ -198,7 +200,12 @@ public class ReportServiceImpl {
...
@@ -198,7 +200,12 @@ public class ReportServiceImpl {
periodDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
)
periodDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
)
.
andPeriodEqualTo
(
period
);
.
andPeriodEqualTo
(
period
);
List
<
PeriodDataSource
>
periodDataSources
=
periodDataSourceMapper
.
selectByExample
(
periodDataSourceExample
);
List
<
PeriodDataSource
>
periodDataSources
=
periodDataSourceMapper
.
selectByExample
(
periodDataSourceExample
);
List
<
Long
>
periodDsIds
=
Lists
.
newArrayList
(
Long
.
MAX_VALUE
);
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
>
periodManualDsIds
=
new
ArrayList
<>();
List
<
Long
>
periodManualCellDataIds
=
new
ArrayList
<>();
List
<
Long
>
periodManualCellDataIds
=
new
ArrayList
<>();
...
@@ -216,27 +223,36 @@ public class ReportServiceImpl {
...
@@ -216,27 +223,36 @@ public class ReportServiceImpl {
periodCellDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
periodCellDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
.
andDataSourceIdIn
(
periodManualDsIds
);
.
andDataSourceIdIn
(
periodManualDsIds
);
List
<
PeriodCellDataSource
>
manualCellDataSource
=
periodCellDataSourceMapper
.
selectByExample
(
periodCellDataSourceExample
);
List
<
PeriodCellDataSource
>
manualCellDataSource
=
periodCellDataSourceMapper
.
selectByExample
(
periodCellDataSourceExample
);
if
(!
manualCellDataSource
.
isEmpty
())
if
(!
manualCellDataSource
.
isEmpty
())
{
periodManualCellDataIds
.
addAll
(
manualCellDataSource
.
stream
().
map
(
PeriodCellDataSource:
:
getCellDataId
)
periodManualCellDataIds
.
addAll
(
manualCellDataSource
.
stream
().
map
(
PeriodCellDataSource:
:
getCellDataId
)
.
collect
(
Collectors
.
toList
()));
.
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
{
}
else
{
periodDsIds
.
addAll
(
periodDataSources
.
stream
().
map
(
m
->
m
.
getId
()).
collect
(
Collectors
.
toList
()));
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
periodDataSourceDetailExample
=
new
PeriodDataSourceDetailExample
();
periodDataSourceDetailExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
periodDataSourceDetailExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
.
andDataSourceIdIn
(
periodDsIds
);
.
andDataSourceIdIn
(
Lists
.
newArrayList
(
periodDsIds
)
);
periodDataSourceDetailMapper
.
deleteByExample
(
periodDataSourceDetailExample
);
periodDataSourceDetailMapper
.
deleteByExample
(
periodDataSourceDetailExample
);
PeriodCellDataSourceExample
periodCellDataSourceExample
=
new
PeriodCellDataSourceExample
();
PeriodCellDataSourceExample
periodCellDataSourceExample
=
new
PeriodCellDataSourceExample
();
periodCellDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
periodCellDataSourceExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
.
andDataSourceIdIn
(
periodDsIds
);
.
andDataSourceIdIn
(
Lists
.
newArrayList
(
periodDsIds
)
);
periodCellDataSourceMapper
.
deleteByExample
(
periodCellDataSourceExample
);
periodCellDataSourceMapper
.
deleteByExample
(
periodCellDataSourceExample
);
PeriodDataSourceExample
periodDataSourceDeleteExample
=
new
PeriodDataSourceExample
();
PeriodDataSourceExample
periodDataSourceDeleteExample
=
new
PeriodDataSourceExample
();
periodDataSourceDeleteExample
.
createCriteria
().
andIdIn
(
periodDsIds
);
periodDataSourceDeleteExample
.
createCriteria
().
andIdIn
(
Lists
.
newArrayList
(
periodDsIds
)
);
periodDataSourceMapper
.
deleteByExample
(
periodDataSourceDeleteExample
);
periodDataSourceMapper
.
deleteByExample
(
periodDataSourceDeleteExample
);
PeriodReportExample
periodReportExample
=
new
PeriodReportExample
();
PeriodReportExample
periodReportExample
=
new
PeriodReportExample
();
...
@@ -247,18 +263,18 @@ public class ReportServiceImpl {
...
@@ -247,18 +263,18 @@ public class ReportServiceImpl {
reportIds
.
addAll
(
reports
.
stream
().
map
(
m
->
m
.
getId
()).
collect
(
Collectors
.
toList
()));
reportIds
.
addAll
(
reports
.
stream
().
map
(
m
->
m
.
getId
()).
collect
(
Collectors
.
toList
()));
PeriodCellDataExample
periodCellDataExample
=
new
PeriodCellDataExample
();
PeriodCellDataExample
periodCellDataExample
=
new
PeriodCellDataExample
();
if
(
!
periodManualCellDataIds
.
isEmpty
()
)
{
if
(
isMergeManualData
)
{
periodCellDataExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
).
andReportIdIn
(
if
(
periodManualCellDataIds
.
isEmpty
())
periodManualCellDataIds
.
add
(
Long
.
MAX_VALUE
);
reportIds
).
andIdNotIn
(
periodManualCellDataIds
);
periodCellDataExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
).
andIdNotIn
(
periodManualCellDataIds
);
}
else
{
}
else
{
periodCellDataExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
).
andReportIdIn
(
periodCellDataExample
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
);
reportIds
);
}
}
periodCellDataMapper
.
deleteByExample
(
periodCellDataExample
);
periodCellDataMapper
.
deleteByExample
(
periodCellDataExample
);
periodReportMapper
.
deleteByExample
(
periodReportExample
);
periodReportMapper
.
deleteByExample
(
periodReportExample
);
}
}
@Transactional
private
void
updateConfig
(
String
projectId
,
Integer
period
,
Boolean
isMergeManualData
,
List
<
Template
>
templates
,
PeriodJob
job
)
{
private
void
updateConfig
(
String
projectId
,
Integer
period
,
Boolean
isMergeManualData
,
List
<
Template
>
templates
,
PeriodJob
job
)
{
try
{
try
{
List
<
Long
>
exceptTemplateIds
=
templateMapper
.
getIdsForExceptTemplate
();
List
<
Long
>
exceptTemplateIds
=
templateMapper
.
getIdsForExceptTemplate
();
...
@@ -482,6 +498,8 @@ public class ReportServiceImpl {
...
@@ -482,6 +498,8 @@ public class ReportServiceImpl {
new
Thread
(
new
Runnable
()
{
new
Thread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
try
{
updateConfig
(
projectId
,
periodParam
,
isMergeManualData
,
templates
,
genJob
);
updateConfig
(
projectId
,
periodParam
,
isMergeManualData
,
templates
,
genJob
);
PeriodResources
resources
=
reportGenerator
.
getPeriodResources
(
projectId
,
periodParam
,
PeriodResources
resources
=
reportGenerator
.
getPeriodResources
(
projectId
,
periodParam
,
...
@@ -496,9 +514,18 @@ public class ReportServiceImpl {
...
@@ -496,9 +514,18 @@ public class ReportServiceImpl {
evaluator
.
evaluateAll
();
evaluator
.
evaluateAll
();
reportGenerator
.
updateWorkbookCaclsValueToDb
(
projectId
,
periodParam
,
workbook
,
resources
,
genJob
);
reportGenerator
.
updateWorkbookCaclsValueToDb
(
projectId
,
periodParam
,
workbook
,
resources
,
genJob
);
reportGenerator
.
updateManaCellDataWithNewReport
(
projectId
,
periodParam
);
genJob
.
setStatus
(
WrapPeriodJobDto
.
STATUS_END
);
genJob
.
setStatus
(
WrapPeriodJobDto
.
STATUS_END
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
genJob
.
setStatus
(
WrapPeriodJobDto
.
STATUS_ERROR
);
genJob
.
setErrorMsg
(
"Server error"
);
}
finally
{
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
}
}
}
}).
start
();
}).
start
();
operationResultDto
.
setData
(
genJob
);
operationResultDto
.
setData
(
genJob
);
operationResultDto
.
setResult
(
true
);
operationResultDto
.
setResult
(
true
);
...
...
atms-dao/src/main/java/pwc/taxtech/atms/vat/dao/PeriodCellDataMapper.java
View file @
a913acb5
...
@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param;
...
@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.session.RowBounds
;
import
org.apache.ibatis.session.RowBounds
;
import
pwc.taxtech.atms.MyVatMapper
;
import
pwc.taxtech.atms.MyVatMapper
;
import
pwc.taxtech.atms.vat.dpo.MergerManaualCellData
;
import
pwc.taxtech.atms.vat.entity.PCTEntity
;
import
pwc.taxtech.atms.vat.entity.PCTEntity
;
import
pwc.taxtech.atms.vat.entity.PeriodCellData
;
import
pwc.taxtech.atms.vat.entity.PeriodCellData
;
import
pwc.taxtech.atms.vat.entity.PeriodCellDataExample
;
import
pwc.taxtech.atms.vat.entity.PeriodCellDataExample
;
...
@@ -130,4 +131,35 @@ public interface PeriodCellDataMapper extends MyVatMapper {
...
@@ -130,4 +131,35 @@ public interface PeriodCellDataMapper extends MyVatMapper {
" </foreach>"
+
" </foreach>"
+
"</script>"
)
"</script>"
)
List
<
PCTEntity
>
queryByPCTs
(
@Param
(
"list"
)
Set
<
PCTEntity
>
parameter
,
@Param
(
"projectId"
)
String
projectId
);
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/dpo/MergerManaualCellData.java
0 → 100644
View file @
a913acb5
package
pwc
.
taxtech
.
atms
.
vat
.
dpo
;
public
class
MergerManaualCellData
{
private
Long
id
;
private
Long
reportId
;
private
Long
cellTemplateId
;
private
Long
templateId
;
private
Long
newReportId
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Long
getReportId
()
{
return
reportId
;
}
public
void
setReportId
(
Long
reportId
)
{
this
.
reportId
=
reportId
;
}
public
Long
getCellTemplateId
()
{
return
cellTemplateId
;
}
public
void
setCellTemplateId
(
Long
cellTemplateId
)
{
this
.
cellTemplateId
=
cellTemplateId
;
}
public
Long
getTemplateId
()
{
return
templateId
;
}
public
void
setTemplateId
(
Long
templateId
)
{
this
.
templateId
=
templateId
;
}
public
Long
getNewReportId
()
{
return
newReportId
;
}
public
void
setNewReportId
(
Long
newReportId
)
{
this
.
newReportId
=
newReportId
;
}
}
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