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
cb7ce216
Commit
cb7ce216
authored
Nov 20, 2018
by
sherlock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DFFS cell value
parent
59f49ed5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
5 deletions
+35
-5
DFFS.java
.../taxtech/atms/vat/service/impl/report/functions/DFFS.java
+35
-5
No files found.
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/DFFS.java
View file @
cb7ce216
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.NumberEval
;
import
org.apache.poi.ss.formula.eval.ValueEval
;
import
org.apache.poi.ss.formula.functions.FreeRefFunction
;
import
pwc.taxtech.atms.common.util.DateUtils
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.constant.Constant
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType
;
import
pwc.taxtech.atms.dpo.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.entity.AccountMapping
;
import
pwc.taxtech.atms.entity.AccountMappingExample
;
import
pwc.taxtech.atms.entity.EnterpriseAccountSetOrg
;
import
pwc.taxtech.atms.entity.EnterpriseAccountSetOrgExample
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.entity.GlBalance
;
import
pwc.taxtech.atms.vat.entity.GlBalanceExample
;
import
java.math.BigDecimal
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -34,7 +43,7 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
int
year
=
getIntParam
(
args
[
2
],
ec
);
int
period
=
getIntParam
(
args
[
3
],
ec
);
String
formulaExpression
=
"DFFS("
+
type
+
",
"
+
code
+
","
String
formulaExpression
=
"DFFS("
+
type
+
",
\""
+
code
+
"\
","
+
year
+
","
+
period
+
")"
;
logger
.
debug
(
formulaExpression
);
...
...
@@ -46,7 +55,7 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
year
=
year
+
yearOffset
;
Date
date
=
DateUtils
.
strToDate
(
year
+
"-"
+
period
+
"-"
+
15
);
List
<
GlBalance
>
list
;
List
<
ReportCellDataSourceDto
>
dataSource
=
Lists
.
newArrayList
()
;
if
(
type
==
0
){
EnterpriseAccountSetOrgExample
example
=
new
EnterpriseAccountSetOrgExample
();
example
.
createCriteria
().
andEffectiveDateLessThanOrEqualTo
(
date
).
andExpiredDateGreaterThanOrEqualTo
(
date
).
andOrganizationIdEqualTo
(
orgId
);
...
...
@@ -58,18 +67,30 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
accountMappingExample
.
createCriteria
().
andOrganizationIdEqualTo
(
orgId
).
andEnterpriseAccountSetIdEqualTo
(
enterpriseAccountSetOrgs
.
get
(
0
).
getEnterpriseAccountSetId
());
List
<
AccountMapping
>
accountMappings
=
SpringContextUtil
.
accountMappingMapper
.
selectByExample
(
accountMappingExample
);
double
result
=
0
;
for
(
AccountMapping
a
:
accountMappings
){
result
+=
count
(
a
.
getEnterpriseAccountCode
());
result
+=
count
(
a
.
getEnterpriseAccountCode
()
,
dataSource
,
period
);
}
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
new
BigDecimal
(
result
),
period
,
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
result
),
dataSoureId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
result
);
}
else
if
(
type
==
1
){
return
new
NumberEval
(
count
(
code
));
double
result
=
count
(
code
,
dataSource
,
period
);
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
new
BigDecimal
(
result
),
period
,
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
result
),
dataSoureId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
result
);
}
return
NumberEval
.
ZERO
;
}
private
double
count
(
String
code
){
private
double
count
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
){
GlBalanceExample
glBalanceExample
=
new
GlBalanceExample
();
GlBalanceExample
.
Criteria
c1
=
glBalanceExample
.
createCriteria
().
andSegment3EqualTo
(
code
);
GlBalanceExample
.
Criteria
c2
=
glBalanceExample
.
createCriteria
().
andSegment4EqualTo
(
code
);
...
...
@@ -82,6 +103,15 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
if
(
CollectionUtils
.
isEmpty
(
temp
)){
temp
=
list
;
}
for
(
GlBalance
glBalance
:
temp
){
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
setAmount
(
glBalance
.
getPtdCr
());
dto
.
setPeriod
(
period
);
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
contain
.
add
(
dto
);
}
return
temp
.
stream
().
mapToDouble
(
a
->
a
.
getPtdCr
().
doubleValue
()).
sum
();
}
}
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