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
d3e9c1b1
Commit
d3e9c1b1
authored
Aug 07, 2018
by
neo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev] fixed bb formula save formula block to db
parent
1905d7b7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
76 deletions
+91
-76
FormulaDataSourceDetailType.java
...tech/atms/constant/enums/FormulaDataSourceDetailType.java
+2
-1
BBParasBo.java
.../src/main/java/pwc/taxtech/atms/dto/vatdto/BBParasBo.java
+43
-0
CloseableFormulaDataSource.java
...c/taxtech/atms/dto/vatdto/CloseableFormulaDataSource.java
+0
-34
BB.java
...wc/taxtech/atms/vat/service/impl/report/functions/BB.java
+46
-41
No files found.
atms-api/src/main/java/pwc/taxtech/atms/constant/enums/FormulaDataSourceDetailType.java
View file @
d3e9c1b1
...
...
@@ -7,7 +7,8 @@ public enum FormulaDataSourceDetailType {
InputInvoiceDataSourceDto
(
3
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
InputInvoiceDataSourceDto
.
class
),
InputInvoiceDetailDataSourceDto
(
4
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
InputInvoiceDetailDataSourceDto
.
class
),
OutputInvoiceDataSourceDto
(
5
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
OutputInvoiceDataSourceDto
.
class
),
AssetDetailDataSourceDto
(
5
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
AssetDetailDataSourceDto
.
class
);
AssetDetailDataSourceDto
(
5
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
AssetDetailDataSourceDto
.
class
),
ReportCellDataSourceDto
(
6
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
ReportCellDataSourceDto
.
class
);
private
Integer
code
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/BBParasBo.java
View file @
d3e9c1b1
...
...
@@ -15,13 +15,22 @@ public class BBParasBo {
private
Integer
rowIndex
;
private
Integer
period
;
private
Integer
year
;
private
String
formulaExpression
;
public
BBParasBo
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
throws
EvaluationException
{
StringBuilder
expression
=
new
StringBuilder
(
""
);
begin
(
expression
);
reportCode
=
resolverString
(
args
,
ec
,
0
);
concatPara
(
expression
,
reportCode
);
try
{
columnIndex
=
resolverInteger
(
args
,
ec
,
1
);
split
(
expression
);
concatPara
(
expression
,
columnIndex
);
}
catch
(
Exception
e
)
{
String
columnStr
=
resolverString
(
args
,
ec
,
1
);
split
(
expression
);
concatPara
(
expression
,
columnStr
);
int
rtn
=
0
;
columnStr
=
columnStr
.
toUpperCase
();
char
[]
excelCol
=
columnStr
.
toCharArray
();
...
...
@@ -35,8 +44,42 @@ public class BBParasBo {
columnIndex
=
rtn
;
}
rowIndex
=
resolverInteger
(
args
,
ec
,
2
);
split
(
expression
);
concatPara
(
expression
,
rowIndex
);
period
=
args
.
length
>=
4
?
resolverInteger
(
args
,
ec
,
3
)
:
0
;
year
=
args
.
length
==
5
?
resolverInteger
(
args
,
ec
,
4
)
:
0
;
formulaExpression
=
expression
.
toString
();
}
private
StringBuilder
begin
(
StringBuilder
expression
)
{
return
expression
.
append
(
"BB("
);
}
private
StringBuilder
end
(
StringBuilder
expression
)
{
return
expression
.
append
(
")"
);
}
private
StringBuilder
split
(
StringBuilder
expression
)
{
return
expression
.
append
(
","
);
}
private
StringBuilder
concatPara
(
StringBuilder
expression
,
String
para
)
{
return
expression
.
append
(
"\""
).
append
(
para
).
append
(
"\""
);
}
private
StringBuilder
concatPara
(
StringBuilder
expression
,
Integer
para
)
{
return
expression
.
append
(
para
);
}
public
String
expression
(
Integer
currentPeriod
,
Integer
currentYear
)
{
StringBuilder
builder
=
new
StringBuilder
(
formulaExpression
);
split
(
builder
);
concatPara
(
builder
,
currentPeriod
);
split
(
builder
);
concatPara
(
builder
,
currentYear
);
end
(
builder
);
formulaExpression
=
builder
.
toString
();
return
formulaExpression
;
}
public
void
disCount
()
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/CloseableFormulaDataSource.java
deleted
100644 → 0
View file @
1905d7b7
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
pwc.taxtech.atms.vat.service.impl.FormulaAgent
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
CloseableFormulaDataSource
implements
AutoCloseable
{
private
List
<
ReportCellDataSourceDto
>
dataSourceList
=
new
ArrayList
<>();
private
FormulaAgent
agent
;
public
CloseableFormulaDataSource
(
FormulaAgent
agent
)
{
this
.
agent
=
agent
;
}
public
void
addDS
(
ReportCellDataSourceDto
ds
){
dataSourceList
.
add
(
ds
);
}
public
void
addDS
(
List
<
ReportCellDataSourceDto
>
dss
){
dataSourceList
.
addAll
(
dss
);
}
public
void
clean
(){
dataSourceList
.
clear
();
}
@Override
public
void
close
()
throws
Exception
{
if
(!
dataSourceList
.
isEmpty
()){
agent
.
save
(
dataSourceList
);
//TODO: save datasources;
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/BB.java
View file @
d3e9c1b1
...
...
@@ -8,15 +8,17 @@ import org.apache.poi.ss.formula.functions.FreeRefFunction;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType
;
import
pwc.taxtech.atms.dto.vatdto.BBParasBo
;
import
pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dto.vatdto.CloseableFormulaDataSource
;
import
pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.entity.CellData
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
BB
extends
FunctionBase
implements
FreeRefFunction
{
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
BB
.
class
);
...
...
@@ -39,58 +41,61 @@ public class BB extends FunctionBase implements FreeRefFunction {
}
public
ValueEval
wrapExceptionEval
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
throws
Exception
{
return
new
NumberEval
(
bb
(
new
BBParasBo
(
args
,
ec
)).
doubleValue
());
return
new
NumberEval
(
bb
(
new
BBParasBo
(
args
,
ec
)
,
ec
).
doubleValue
());
}
public
BigDecimal
bb
(
BBParasBo
bo
)
throws
Exception
{
try
(
CloseableFormulaDataSource
closeDataSource
=
new
CloseableFormulaDataSource
(
formulaContext
.
getFormulaAgent
()))
{
CurrentPeriodBo
curPeriod
=
CurrentPeriodBo
.
getPeriod
(
bo
.
getPeriod
().
intValue
(),
formulaContext
.
getPeriod
());
curPeriod
.
fixedCurYear
(
getYear
(
bo
.
getYear
()));
public
BigDecimal
bb
(
BBParasBo
bo
,
OperationEvaluationContext
ec
)
throws
Exception
{
List
<
Object
>
ds
=
new
ArrayList
<>();
CurrentPeriodBo
curPeriod
=
CurrentPeriodBo
.
getPeriod
(
bo
.
getPeriod
().
intValue
(),
formulaContext
.
getPeriod
());
curPeriod
.
fixedCurYear
(
getYear
(
bo
.
getYear
()));
ReportCellDataSourceDto
nullCellDto
=
ReportCellDataSourceDto
.
nullDataSource
(
bo
,
curPeriod
);
closeDataSource
.
addDS
(
nullCellDto
);
ReportCellDataSourceDto
nullCellDto
=
ReportCellDataSourceDto
.
nullDataSource
(
bo
,
curPeriod
);
ds
.
add
(
nullCellDto
);
CellTemplatePerGroupDto
cellTemplateData
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupID
(),
formulaContext
.
getProjectID
()).
stream
().
filter
(
dto
->
dto
.
getRowIndex
()
==
bo
.
getColumnIndex
()
-
1
&&
dto
.
getColumnIndex
()
==
bo
.
getColumnIndex
()
-
1
).
findFirst
().
get
();
CellTemplatePerGroupDto
cellTemplateData
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupID
(),
formulaContext
.
getProjectID
()).
stream
().
filter
(
dto
->
dto
.
getRowIndex
()
==
bo
.
getColumnIndex
()
-
1
&&
dto
.
getColumnIndex
()
==
bo
.
getColumnIndex
()
-
1
).
findFirst
().
get
();
MyAsserts
.
assertNotNull
(
cellTemplateData
,
Exceptions
.
BB_CELL_TEMP_NULL
);
nullCellDto
.
fixedWithGroup
(
cellTemplateData
);
MyAsserts
.
assertNotNull
(
cellTemplateData
,
Exceptions
.
BB_CELL_TEMP_NULL
);
nullCellDto
.
fixedWithGroup
(
cellTemplateData
);
// todo: fix datasource name by templateList(neo)
if
(
curPeriod
.
getCurPeriod
()
==
-
99
)
{
closeDataSource
.
clean
();
BigDecimal
returnEval
=
defaultBigDecimal
;
if
(
formulaContext
.
getPeriod
()
<=
1
)
{
return
defaultBigDecimal
;
}
for
(
int
p
=
1
;
p
<
formulaContext
.
getPeriod
();
p
++)
{
returnEval
=
returnEval
.
add
(
bb
(
new
BBParasBo
(
bo
,
p
,
curPeriod
.
getCurYear
())));
}
// todo: fix datasource name by templateList(neo)
if
(
curPeriod
.
getCurPeriod
()
==
-
99
)
{
ds
.
clear
();
BigDecimal
returnEval
=
defaultBigDecimal
;
if
(
formulaContext
.
getPeriod
()
<=
1
)
{
return
defaultBigDecimal
;
}
return
returnEval
;
for
(
int
p
=
1
;
p
<
formulaContext
.
getPeriod
();
p
++)
{
returnEval
=
returnEval
.
add
(
bb
(
new
BBParasBo
(
bo
,
p
,
curPeriod
.
getCurYear
()),
ec
));
}
bo
.
disCount
();
String
dbName
=
agent
.
getPastProjectDbName
(
curPeriod
.
getCurYear
(),
formulaContext
.
getOrganizationID
());
CellData
cellData
=
agent
.
getCellData
(
dbName
,
cellTemplateData
.
getReportTemplateID
(),
cellTemplateData
.
getCellTemplateID
(),
curPeriod
.
getCurPeriod
());
nullCellDto
=
ReportCellDataSourceDto
.
extractFromGroup
(
bo
,
curPeriod
,
cellData
,
cellTemplateData
);
closeDataSource
.
clean
();
closeDataSource
.
addDS
(
nullCellDto
);
// todo: fix datasource name by templateList(neo)
return
returnEval
;
}
MyAsserts
.
assertNotNull
(
cellData
.
getData
(),
Exceptions
.
BB_CELL_DATA_NULL
);
bo
.
disCount
();
String
dbName
=
agent
.
getPastProjectDbName
(
curPeriod
.
getCurYear
(),
formulaContext
.
getOrganizationID
());
CellData
cellData
=
agent
.
getCellData
(
dbName
,
cellTemplateData
.
getReportTemplateID
(),
cellTemplateData
.
getCellTemplateID
(),
curPeriod
.
getCurPeriod
());
nullCellDto
=
ReportCellDataSourceDto
.
extractFromGroup
(
bo
,
curPeriod
,
cellData
,
cellTemplateData
);
ds
.
clear
();
ds
.
add
(
nullCellDto
);
// todo: fix datasource name by templateList(neo)
MyAsserts
.
assertNotNull
(
cellData
.
getData
(),
Exceptions
.
BB_CELL_DATA_NULL
);
// cellValue= RoundValue(cellValue, cellDataType)TODO:maybe fixd round by cellDataTyep(KV neo)
BigDecimal
cellValue
=
new
BigDecimal
(
cellData
.
getData
()).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
);
nullCellDto
.
setAmount
(
cellValue
);
LOGGER
.
debug
(
"cell static value "
);
return
cellValue
;
}
BigDecimal
cellValue
=
new
BigDecimal
(
cellData
.
getData
()).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
);
Long
dataSourceID
=
saveDataSource
(
ec
,
ds
,
FormulaDataSourceDetailType
.
ReportCellDataSourceDto
,
cellValue
,
curPeriod
.
getCurPeriod
(),
formulaContext
.
getReportTemplateGroupID
());
saveFormulaBlock
(
curPeriod
.
getCurPeriod
(),
ec
,
bo
.
expression
(
curPeriod
.
getCurPeriod
(),
curPeriod
.
getCurYear
()),
cellValue
,
dataSourceID
);
nullCellDto
.
setAmount
(
cellValue
);
LOGGER
.
debug
(
"cell static value "
);
return
cellValue
;
}
}
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