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
e3c6ed6c
Commit
e3c6ed6c
authored
May 15, 2019
by
chase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bpm公式
parent
a30927ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
38 deletions
+85
-38
TBM.java
...c/taxtech/atms/vat/service/impl/report/functions/TBM.java
+85
-38
No files found.
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/TBM.java
View file @
e3c6ed6c
...
...
@@ -20,7 +20,7 @@ import java.util.List;
import
java.util.stream.Collectors
;
/**
*
根据报表项目与科目映射取出科目代码,再通过入参进行TB表数据计算
* 根据报表项目与科目映射取出科目代码,再通过入参进行TB表数据计算
*/
public
class
TBM
extends
FunctionBase
implements
FreeRefFunction
{
public
TBM
(
FormulaContext
formulaContext
)
{
...
...
@@ -37,21 +37,22 @@ public class TBM extends FunctionBase implements FreeRefFunction {
String
mappingName
=
getStringParam
(
args
[
1
],
ec
);
//映射名称
int
calculateType
=
getIntParam
(
args
[
2
],
ec
);
//计算类型,当取利润时候,1:贷方-借方,2:借方-贷方。当取资产时,1:正数,2:负数
int
sourceDataType
=
getIntParam
(
args
[
3
],
ec
);
//取值数据源
String
formulaExpression
=
"TBM("
+
evenType
+
",\""
+
mappingName
+
"\","
+
calculateType
+
","
+
sourceDataType
+
")"
;
String
formulaExpression
=
"TBM("
+
evenType
+
",\""
+
mappingName
+
"\","
+
calculateType
+
","
+
sourceDataType
+
")"
;
List
<
ReportCellDataSourceDto
>
dataSource
=
Lists
.
newArrayList
();
List
<
String
>
segment3List
=
getSegment3List
(
evenType
,
mappingName
);
if
(
CollectionUtils
.
isEmpty
(
segment3List
)){
List
<
String
>
segment3List
=
getSegment3List
(
evenType
,
mappingName
);
if
(
CollectionUtils
.
isEmpty
(
segment3List
))
{
return
NumberEval
.
ZERO
;
}
double
result
=
0.00
;
if
(
sourceDataType
==
1
)
{
result
=
countForTrialBalance
(
evenType
,
calculateType
,
segment3List
,
dataSource
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
formulaContext
.
getOrganizationId
());
result
=
countForTrialBalance
(
evenType
,
calculateType
,
segment3List
,
dataSource
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
formulaContext
.
getOrganizationId
());
}
else
if
(
sourceDataType
==
2
)
{
result
=
countForAdjBalance
(
evenType
,
calculateType
,
segment3List
,
dataSource
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
formulaContext
.
getOrganizationId
());
result
=
countForAdjBalance
(
evenType
,
calculateType
,
segment3List
,
dataSource
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
formulaContext
.
getOrganizationId
());
}
else
if
(
sourceDataType
==
3
)
{
result
=
countForTrialFinalBalance
(
evenType
,
calculateType
,
segment3List
,
dataSource
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
formulaContext
.
getOrganizationId
());
result
=
countForTrialFinalBalance
(
evenType
,
calculateType
,
segment3List
,
dataSource
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
formulaContext
.
getOrganizationId
());
}
else
{
return
NumberEval
.
ZERO
;
}
...
...
@@ -63,11 +64,11 @@ public class TBM extends FunctionBase implements FreeRefFunction {
}
public
List
<
String
>
getSegment3List
(
int
eventType
,
String
mappingName
)
{
public
List
<
String
>
getSegment3List
(
int
eventType
,
String
mappingName
)
{
TrialBalanceMappingExample
example
=
new
TrialBalanceMappingExample
();
if
(
eventType
==
1
)
{
if
(
eventType
==
1
)
{
example
.
createCriteria
().
andPlTypeEqualTo
(
mappingName
);
}
else
if
(
eventType
==
2
)
{
}
else
if
(
eventType
==
2
)
{
example
.
createCriteria
().
andBsTypeEqualTo
(
mappingName
);
}
List
<
TrialBalanceMapping
>
dataList
=
SpringContextUtil
.
trialBalanceMappingMapper
.
selectByExample
(
example
);
...
...
@@ -75,14 +76,25 @@ public class TBM extends FunctionBase implements FreeRefFunction {
.
map
(
o
->
o
.
getSegment3
()).
collect
(
Collectors
.
toList
());
}
private
int
par
d
ePeriod
(
int
period
,
int
year
)
{
private
int
par
s
ePeriod
(
int
period
,
int
year
)
{
return
Integer
.
parseInt
(
""
+
year
+
(
period
>
9
?
period
:
(
"0"
+
period
)));
}
private
double
countForTrialBalance
(
int
eventType
,
int
calculateType
,
List
<
String
>
segment3List
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
)
{
private
int
parseLastPeriod
(
int
period
,
int
year
)
{
if
(
period
==
1
)
{
period
=
12
;
year
-=
1
;
}
else
{
period
-=
1
;
}
return
Integer
.
parseInt
(
""
+
year
+
(
period
>
9
?
period
:
(
"0"
+
period
)));
}
private
double
countForTrialBalance
(
int
eventType
,
int
calculateType
,
List
<
String
>
segment3List
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
TrialBalanceExample
glBalanceExample
=
new
TrialBalanceExample
();
TrialBalanceExample
.
Criteria
c1
=
glBalanceExample
.
createCriteria
().
andSegment3In
(
segment3List
)
.
andPeriodEqualTo
(
par
d
ePeriod
(
period
,
year
));
.
andPeriodEqualTo
(
par
s
ePeriod
(
period
,
year
));
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
...
...
@@ -93,20 +105,20 @@ public class TBM extends FunctionBase implements FreeRefFunction {
BigDecimal
amount
=
new
BigDecimal
(
0
);
for
(
TrialBalance
balance
:
list
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
if
(
eventType
==
1
)
{
if
(
calculateType
==
1
)
{
if
(
eventType
==
1
)
{
if
(
calculateType
==
1
)
{
dto
.
setAmount
(
balance
.
getPeriodCrBeq
().
subtract
(
balance
.
getPeriodDrBeq
()));
}
else
if
(
calculateType
==
2
)
{
}
else
if
(
calculateType
==
2
)
{
dto
.
setAmount
(
balance
.
getPeriodDrBeq
().
subtract
(
balance
.
getPeriodCrBeq
()));
}
}
else
if
(
eventType
==
2
)
{
if
(
calculateType
==
1
)
{
}
else
if
(
eventType
==
2
)
{
if
(
calculateType
==
1
)
{
dto
.
setAmount
(
balance
.
getEndBalBeq
());
}
else
if
(
calculateType
==
2
)
{
}
else
if
(
calculateType
==
2
)
{
dto
.
setAmount
(
balance
.
getEndBalBeq
().
multiply
(
new
BigDecimal
(-
1
)));
}
}
amount
=
amount
.
add
(
dto
.
getAmount
()
==
null
?(
new
BigDecimal
(
0
)):
dto
.
getAmount
());
amount
=
amount
.
add
(
dto
.
getAmount
()
==
null
?
(
new
BigDecimal
(
0
))
:
dto
.
getAmount
());
dto
.
setPeriod
(
period
);
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
...
...
@@ -116,11 +128,11 @@ public class TBM extends FunctionBase implements FreeRefFunction {
return
amount
.
doubleValue
();
}
private
double
countForAdjBalance
(
int
eventType
,
int
calculateType
,
List
<
String
>
segment3List
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
)
{
private
double
countForAdjBalance
(
int
eventType
,
int
calculateType
,
List
<
String
>
segment3List
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
AdjustmentTableExample
glBalanceExample
=
new
AdjustmentTableExample
();
AdjustmentTableExample
.
Criteria
c1
=
glBalanceExample
.
createCriteria
().
andSegment3In
(
segment3List
)
.
andPeriodEqualTo
(
par
d
ePeriod
(
period
,
year
));
.
andPeriodEqualTo
(
par
s
ePeriod
(
period
,
year
));
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
...
...
@@ -129,36 +141,71 @@ public class TBM extends FunctionBase implements FreeRefFunction {
return
0.0
;
}
BigDecimal
amount
=
new
BigDecimal
(
0
);
//计算本期发生
for
(
AdjustmentTable
balance
:
list
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
if
(
eventType
==
1
)
{
if
(
calculateType
==
1
)
{
if
(
eventType
==
1
)
{
if
(
calculateType
==
1
)
{
dto
.
setAmount
(
balance
.
getPeriodCrBeq
().
subtract
(
balance
.
getPeriodDrBeq
()));
}
else
if
(
calculateType
==
2
)
{
}
else
if
(
calculateType
==
2
)
{
dto
.
setAmount
(
balance
.
getPeriodDrBeq
().
subtract
(
balance
.
getPeriodCrBeq
()));
}
}
else
if
(
eventType
==
2
)
{
if
(
calculateType
==
1
)
{
}
else
if
(
eventType
==
2
)
{
if
(
calculateType
==
1
)
{
dto
.
setAmount
(
balance
.
getEndBalBeq
());
}
else
if
(
calculateType
==
2
)
{
}
else
if
(
calculateType
==
2
)
{
dto
.
setAmount
(
balance
.
getEndBalBeq
().
multiply
(
new
BigDecimal
(-
1
)));
}
}
amount
=
amount
.
add
(
dto
.
getAmount
()
==
null
?(
new
BigDecimal
(
0
)):
dto
.
getAmount
());
amount
=
amount
.
add
(
dto
.
getAmount
()
==
null
?
(
new
BigDecimal
(
0
))
:
dto
.
getAmount
());
dto
.
setPeriod
(
period
);
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
contain
.
add
(
dto
);
}
//计算往期发生
glBalanceExample
=
new
AdjustmentTableExample
();
c1
=
glBalanceExample
.
createCriteria
().
andSegment3In
(
segment3List
)
.
andPeriodEqualTo
(
parseLastPeriod
(
period
,
year
));
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
list
=
SpringContextUtil
.
adjustmentTableMapper
.
selectByExample
(
glBalanceExample
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
BigDecimal
lastAmount
=
new
BigDecimal
(
0
);
for
(
AdjustmentTable
balance
:
list
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
if
(
eventType
==
1
)
{
if
(
calculateType
==
1
)
{
dto
.
setAmount
(
balance
.
getPeriodCrBeq
().
subtract
(
balance
.
getPeriodDrBeq
()));
}
else
if
(
calculateType
==
2
)
{
dto
.
setAmount
(
balance
.
getPeriodDrBeq
().
subtract
(
balance
.
getPeriodCrBeq
()));
}
}
else
if
(
eventType
==
2
)
{
if
(
calculateType
==
1
)
{
dto
.
setAmount
(
balance
.
getEndBalBeq
());
}
else
if
(
calculateType
==
2
)
{
dto
.
setAmount
(
balance
.
getEndBalBeq
().
multiply
(
new
BigDecimal
(-
1
)));
}
}
lastAmount
=
lastAmount
.
add
(
dto
.
getAmount
()
==
null
?
(
new
BigDecimal
(
0
))
:
dto
.
getAmount
());
dto
.
setPeriod
(
period
);
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
contain
.
add
(
dto
);
}
return
amount
.
add
(
lastAmount
.
multiply
(
new
BigDecimal
(-
1
))).
doubleValue
();
}
return
amount
.
doubleValue
();
}
private
double
countForTrialFinalBalance
(
int
eventType
,
int
calculateType
,
List
<
String
>
segment3List
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
)
{
private
double
countForTrialFinalBalance
(
int
eventType
,
int
calculateType
,
List
<
String
>
segment3List
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
TrialBalanceFinalExample
glBalanceExample
=
new
TrialBalanceFinalExample
();
TrialBalanceFinalExample
.
Criteria
c1
=
glBalanceExample
.
createCriteria
().
andSegment3In
(
segment3List
)
.
andPeriodEqualTo
(
par
d
ePeriod
(
period
,
year
));
.
andPeriodEqualTo
(
par
s
ePeriod
(
period
,
year
));
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
...
...
@@ -169,20 +216,20 @@ public class TBM extends FunctionBase implements FreeRefFunction {
BigDecimal
amount
=
new
BigDecimal
(
0
);
for
(
TrialBalanceFinal
balance
:
list
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
if
(
eventType
==
1
)
{
if
(
calculateType
==
1
)
{
if
(
eventType
==
1
)
{
if
(
calculateType
==
1
)
{
dto
.
setAmount
(
balance
.
getPeriodCrBeq
().
subtract
(
balance
.
getPeriodDrBeq
()));
}
else
if
(
calculateType
==
2
)
{
}
else
if
(
calculateType
==
2
)
{
dto
.
setAmount
(
balance
.
getPeriodDrBeq
().
subtract
(
balance
.
getPeriodCrBeq
()));
}
}
else
if
(
eventType
==
2
)
{
if
(
calculateType
==
1
)
{
}
else
if
(
eventType
==
2
)
{
if
(
calculateType
==
1
)
{
dto
.
setAmount
(
balance
.
getEndBalBeq
());
}
else
if
(
calculateType
==
2
)
{
}
else
if
(
calculateType
==
2
)
{
dto
.
setAmount
(
balance
.
getEndBalBeq
().
multiply
(
new
BigDecimal
(-
1
)));
}
}
amount
=
amount
.
add
(
dto
.
getAmount
()
==
null
?(
new
BigDecimal
(
0
)):
dto
.
getAmount
());
amount
=
amount
.
add
(
dto
.
getAmount
()
==
null
?
(
new
BigDecimal
(
0
))
:
dto
.
getAmount
());
dto
.
setPeriod
(
period
);
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
...
...
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