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
ea289174
Commit
ea289174
authored
Feb 21, 2019
by
chase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增税金计算公式(按type定位)
parent
03000ff9
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
427 additions
and
24 deletions
+427
-24
CurrentPeriodBo.java
...ain/java/pwc/taxtech/atms/dto/vatdto/CurrentPeriodBo.java
+5
-0
ReportCellDataSourceDto.java
.../pwc/taxtech/atms/dto/vatdto/ReportCellDataSourceDto.java
+18
-2
WPNAMEParasBo.java
.../main/java/pwc/taxtech/atms/dto/vatdto/WPNAMEParasBo.java
+1
-1
WPTYPEParasBo.java
.../main/java/pwc/taxtech/atms/dto/vatdto/WPTYPEParasBo.java
+213
-0
FormulaAgent.java
.../java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
+39
-7
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+1
-1
ReportServiceImpl.java
.../pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
+1
-1
WPNAME.java
...axtech/atms/vat/service/impl/report/functions/WPNAME.java
+3
-12
WPTYPE.java
...axtech/atms/vat/service/impl/report/functions/WPTYPE.java
+85
-0
FormulaAdminMapper.java
...rc/main/java/pwc/taxtech/atms/dao/FormulaAdminMapper.java
+61
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/CurrentPeriodBo.java
View file @
ea289174
...
...
@@ -4,6 +4,11 @@ public class CurrentPeriodBo {
int
curYear
=
0
;
int
curPeriod
;
public
CurrentPeriodBo
(
int
curYear
,
int
curPeriod
)
{
this
.
curYear
=
curYear
;
this
.
curPeriod
=
curPeriod
;
}
public
CurrentPeriodBo
(
int
period
)
{
this
.
curPeriod
=
period
;
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/ReportCellDataSourceDto.java
View file @
ea289174
...
...
@@ -35,9 +35,25 @@ public class ReportCellDataSourceDto extends DataSourceDto {
this
.
name
=
DataSourceName
.
ReportDataSource
;
this
.
year
=
year
;
this
.
period
=
period
;
this
.
columnIndex
=
cellTemplateData
.
getColumnIndex
()
-
1
;
this
.
columnIndex
=
cellTemplateData
.
getColumnIndex
();
this
.
columnName
=
cellTemplateData
.
getColumnName
();
this
.
rowIndex
=
cellTemplateData
.
getRowIndex
()
-
1
;
this
.
rowIndex
=
cellTemplateData
.
getRowIndex
();
this
.
rowName
=
cellTemplateData
.
getRowName
();
this
.
reportTemplateId
=
cellTemplateData
.
getReportTemplateId
();
this
.
cellTemplateId
=
cellTemplateData
.
getCellTemplateId
()
+
""
;
this
.
resultType
=
cellTemplateData
.
getResultType
();
this
.
isOnlyManualInput
=
false
;
this
.
reportName
=
parasBo
.
getReportCode
();
}
public
void
extractFromGroup
(
WPTYPEParasBo
parasBo
,
Integer
period
,
Integer
year
,
CellTemplatePerGroupDto
cellTemplateData
)
{
this
.
tag
=
"WPTYPE"
;
this
.
name
=
DataSourceName
.
ReportDataSource
;
this
.
year
=
year
;
this
.
period
=
period
;
this
.
columnIndex
=
cellTemplateData
.
getColumnIndex
();
this
.
columnName
=
cellTemplateData
.
getColumnName
();
this
.
rowIndex
=
cellTemplateData
.
getRowIndex
();
this
.
rowName
=
cellTemplateData
.
getRowName
();
this
.
reportTemplateId
=
cellTemplateData
.
getReportTemplateId
();
this
.
cellTemplateId
=
cellTemplateData
.
getCellTemplateId
()
+
""
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/WPNAMEParasBo.java
View file @
ea289174
...
...
@@ -174,7 +174,7 @@ public class WPNAMEParasBo {
@Override
public
String
toString
()
{
return
"
BB
ParasBo{"
+
return
"
WPNAME
ParasBo{"
+
"reportCode='"
+
reportCode
+
'\''
+
", columnIndex="
+
columnIndex
+
", rowColumnIndex="
+
rowColumnIndex
+
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/WPTYPEParasBo.java
0 → 100644
View file @
ea289174
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.EvaluationException
;
import
org.apache.poi.ss.formula.eval.ValueEval
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
pwc
.
taxtech
.
atms
.
common
.
util
.
FormulaUtil
.*;
import
static
pwc
.
taxtech
.
atms
.
exception
.
Exceptions
.
BAD_BBVO_PARAMS
;
public
class
WPTYPEParasBo
{
private
String
reportCode
;
private
Integer
columnIndex
;
private
Integer
rowColumnIndex
;
private
BigDecimal
taxRate
;
private
Integer
revenueType
;
private
Integer
taxType
;
private
String
rowName
;
private
String
formulaExpression
;
private
List
<
PeriodCellDataTemplate
>
expressionData
=
new
ArrayList
<>();
public
static
class
PeriodCellDataTemplate
{
Integer
period
;
Long
cellTemplateId
;
@Override
public
String
toString
()
{
return
period
+
":"
+
cellTemplateId
;
}
public
PeriodCellDataTemplate
(
Integer
period
,
Long
cellTemplateId
)
{
this
.
period
=
period
;
this
.
cellTemplateId
=
cellTemplateId
;
}
}
public
void
putPeriodCellTempate
(
Integer
period
,
Long
cellTemplateId
)
{
if
(
period
<
1
||
period
>
12
||
cellTemplateId
<
0
)
throw
BAD_BBVO_PARAMS
;
expressionData
.
add
(
new
PeriodCellDataTemplate
(
period
,
cellTemplateId
));
}
public
WPTYPEParasBo
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
throws
EvaluationException
{
StringBuilder
expression
=
new
StringBuilder
(
""
);
begin
(
expression
);
reportCode
=
resolverString
(
args
,
ec
,
0
);
concatPara
(
expression
,
reportCode
);
try
{
rowColumnIndex
=
resolverInteger
(
args
,
ec
,
1
);
split
(
expression
);
concatPara
(
expression
,
rowColumnIndex
);
}
catch
(
Exception
e
)
{
String
columnStr
=
resolverString
(
args
,
ec
,
1
);
split
(
expression
);
concatPara
(
expression
,
columnStr
);
int
rtn
=
0
;
columnStr
=
columnStr
.
toUpperCase
();
char
[]
excelCol
=
columnStr
.
toCharArray
();
for
(
int
i
=
columnStr
.
length
()
-
1
;
i
>=
0
;
i
--)
{
if
(
excelCol
[
i
]
>=
'A'
&&
excelCol
[
i
]
<=
'Z'
)
{
rtn
+=
((
int
)
Math
.
pow
(
26
,
excelCol
.
length
-
1
-
i
)
*
(
excelCol
[
i
]
-
64
));
}
else
{
rtn
=
-
1
;
}
}
rowColumnIndex
=
rtn
;
}
taxRate
=
new
BigDecimal
(
resolverString
(
args
,
ec
,
2
));
split
(
expression
);
concatPara
(
expression
,
String
.
valueOf
(
taxRate
));
revenueType
=
resolverInteger
(
args
,
ec
,
3
);
split
(
expression
);
concatPara
(
expression
,
revenueType
);
taxType
=
resolverInteger
(
args
,
ec
,
4
);
split
(
expression
);
concatPara
(
expression
,
taxType
);
try
{
columnIndex
=
resolverInteger
(
args
,
ec
,
5
);
split
(
expression
);
concatPara
(
expression
,
columnIndex
);
}
catch
(
Exception
e
)
{
String
columnStr
=
resolverString
(
args
,
ec
,
5
);
split
(
expression
);
concatPara
(
expression
,
columnStr
);
int
rtn
=
0
;
columnStr
=
columnStr
.
toUpperCase
();
char
[]
excelCol
=
columnStr
.
toCharArray
();
for
(
int
i
=
columnStr
.
length
()
-
1
;
i
>=
0
;
i
--)
{
if
(
excelCol
[
i
]
>=
'A'
&&
excelCol
[
i
]
<=
'Z'
)
{
rtn
+=
((
int
)
Math
.
pow
(
26
,
excelCol
.
length
-
1
-
i
)
*
(
excelCol
[
i
]
-
64
));
}
else
{
rtn
=
-
1
;
}
}
columnIndex
=
rtn
;
}
end
(
expression
);
formulaExpression
=
expression
.
toString
();
}
private
StringBuilder
begin
(
StringBuilder
expression
)
{
return
expression
.
append
(
"WPTYPE("
);
}
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
BigDecimal
getTaxRate
()
{
return
taxRate
;
}
public
void
setTaxRate
(
BigDecimal
taxRate
)
{
this
.
taxRate
=
taxRate
;
}
public
Integer
getRevenueType
()
{
return
revenueType
;
}
public
void
setRevenueType
(
Integer
revenueType
)
{
this
.
revenueType
=
revenueType
;
}
public
Integer
getTaxType
()
{
return
taxType
;
}
public
void
setTaxType
(
Integer
taxType
)
{
this
.
taxType
=
taxType
;
}
public
String
expression
()
{
return
formulaExpression
;
}
public
String
getReportCode
()
{
return
this
.
reportCode
;
}
public
void
setReportCode
(
String
reportCode
)
{
this
.
reportCode
=
reportCode
;
}
public
Integer
getColumnIndex
()
{
return
this
.
columnIndex
;
}
public
void
setColumnIndex
(
Integer
columnIndex
)
{
this
.
columnIndex
=
columnIndex
;
}
public
String
getRowName
()
{
return
rowName
;
}
public
void
setRowName
(
String
rowName
)
{
this
.
rowName
=
rowName
;
}
public
Integer
getRowColumnIndex
()
{
return
rowColumnIndex
;
}
public
void
setRowColumnIndex
(
Integer
rowColumnIndex
)
{
this
.
rowColumnIndex
=
rowColumnIndex
;
}
public
String
getFormulaExpression
()
{
return
this
.
formulaExpression
;
}
public
void
setFormulaExpression
(
String
formulaExpression
)
{
this
.
formulaExpression
=
formulaExpression
;
}
public
List
<
PeriodCellDataTemplate
>
getExpressionData
()
{
return
this
.
expressionData
;
}
public
void
setExpressionData
(
List
<
PeriodCellDataTemplate
>
expressionData
)
{
this
.
expressionData
=
expressionData
;
}
@Override
public
String
toString
()
{
return
"WPTYPEParasBo{"
+
"reportCode='"
+
reportCode
+
'\''
+
", columnIndex="
+
columnIndex
+
", rowColumnIndex="
+
rowColumnIndex
+
", taxRate="
+
taxRate
+
", revenueType="
+
revenueType
+
", taxType="
+
taxType
+
", rowName="
+
rowName
+
'}'
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
View file @
ea289174
...
...
@@ -18,6 +18,7 @@ import pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper;
import
pwc.taxtech.atms.vat.dao.PeriodReportMapper
;
import
pwc.taxtech.atms.vat.entity.*
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
FIRST_OR_DEFAULT
;
...
...
@@ -37,12 +38,13 @@ public class FormulaAgent {
@Autowired
private
PeriodDataSourceMapper
periodDataSourceMapper
;
public
List
<
CellTemplatePerGroupDto
>
getCellTemplateGroupDto
(
Long
templateGroupId
,
String
projectId
,
String
code
,
Integer
rowIndex
,
Integer
columnIndex
,
Integer
period
)
{
return
adminMp
.
getCellTemplatePerGroupDto
(
templateGroupId
,
code
,
rowIndex
,
columnIndex
,
projectId
,
period
);
public
List
<
CellTemplatePerGroupDto
>
getCellTemplateGroupDto
(
Long
templateGroupId
,
String
projectId
,
String
code
,
Integer
rowIndex
,
Integer
columnIndex
,
Integer
period
)
{
return
adminMp
.
getCellTemplatePerGroupDto
(
templateGroupId
,
code
,
rowIndex
,
columnIndex
,
projectId
,
period
);
}
/**
* 根据列index及row名称查询项目报表模板
*
* @param templateGroupId
* @param projectId
* @param code
...
...
@@ -51,16 +53,46 @@ public class FormulaAgent {
* @param period
* @return
*/
public
List
<
CellTemplatePerGroupDto
>
getCellTemplateByNameAndIndex
(
Long
templateGroupId
,
String
projectId
,
String
code
,
Integer
rowColumnIndex
,
String
rowName
,
Integer
columnIndex
,
Integer
period
)
{
public
List
<
CellTemplatePerGroupDto
>
getCellTemplateByNameAndIndex
(
Long
templateGroupId
,
String
projectId
,
String
code
,
Integer
rowColumnIndex
,
String
rowName
,
Integer
columnIndex
,
Integer
period
)
{
return
adminMp
.
getCellTemplateByNameAndIndex
(
templateGroupId
,
code
,
rowColumnIndex
,
rowName
,
columnIndex
,
projectId
,
period
);
}
return
adminMp
.
getCellTemplateByNameAndIndex
(
templateGroupId
,
code
,
rowColumnIndex
,
rowName
,
columnIndex
,
projectId
,
period
);
/**
* 根据收入类型配置及列index查询报表模板
* @param templateGroupId
* @param code
* @param rowColumnIndex
* @param taxRate
* @param revenueType
* @param taxType
* @param columnIndex
* @param projectId
* @param period
* @param orgId
* @param startDate
* @param endDate
* @return
*/
public
List
<
CellTemplatePerGroupDto
>
getCellTemplateByTypeAndIndex
(
Long
templateGroupId
,
String
projectId
,
String
code
,
Integer
rowColumnIndex
,
BigDecimal
taxRate
,
Integer
revenueType
,
Integer
taxType
,
Integer
columnIndex
,
Integer
period
,
String
orgId
,
String
startDate
,
String
endDate
)
{
return
adminMp
.
getCellTemplateByTypeAndIndex
(
templateGroupId
,
projectId
,
code
,
rowColumnIndex
,
taxRate
,
revenueType
,
taxType
,
columnIndex
,
period
,
orgId
,
startDate
,
endDate
);
}
public
Project
getFixedProject
(
String
projectId
,
Integer
year
)
{
return
adminMp
.
getFixedProject
(
projectId
,
year
);
return
adminMp
.
getFixedProject
(
projectId
,
year
);
}
public
List
<
PeriodDataSource
>
queryManualDataSource
(
Long
templateId
,
String
projectId
,
Integer
period
)
{
public
List
<
PeriodDataSource
>
queryManualDataSource
(
Long
templateId
,
String
projectId
,
Integer
period
)
{
PeriodDataSourceExample
example
=
new
PeriodDataSourceExample
();
example
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
.
andCellTemplateIdEqualTo
(
templateId
).
andTypeEqualTo
(
10
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
ea289174
...
...
@@ -512,7 +512,7 @@ public class ReportGeneratorImpl {
FreeRefFunction
[]
functionImpls
=
{
new
SGSR
(
formulaContext
),
new
FSJZ
(
formulaContext
),
new
ND
(
formulaContext
),
new
BB
(
formulaContext
),
new
XXFP
(
formulaContext
),
new
GZSD
(
formulaContext
),
new
PC
(
formulaContext
)
,
new
JXFPMX
(
formulaContext
),
new
JXFP
(
formulaContext
),
new
PSUM
(
formulaContext
),
new
DFFS
(
formulaContext
),
new
JFFS
(
formulaContext
),
new
WPSR
(
formulaContext
),
new
WPNAME
(
formulaContext
)};
new
JFFS
(
formulaContext
),
new
WPSR
(
formulaContext
),
new
WPNAME
(
formulaContext
)
,
new
WPTYPE
(
formulaContext
)
};
UDFFinder
udfs
=
new
DefaultUDFFinder
(
functions
,
functionImpls
);
UDFFinder
udfToolpack
=
new
AggregatingUDFFinder
(
udfs
);
workbook
.
addToolPack
(
udfToolpack
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
View file @
ea289174
...
...
@@ -48,7 +48,7 @@ public class ReportServiceImpl {
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ReportServiceImpl
.
class
);
private
BlockingQueue
<
PeriodJob
>
queue
=
new
LinkedBlockingQueue
<>();
private
final
static
String
[]
functions
=
{
"SGSR"
,
"FSJZ"
,
"ND"
,
"BB"
,
"XXFP"
,
"GZSD"
,
"PC"
,
"JXFPMX"
,
"JXFP"
,
"PSUM"
,
"DFFS"
,
"JFFS"
,
"WPSR"
,
"WPNAME"
};
"JXFP"
,
"PSUM"
,
"DFFS"
,
"JFFS"
,
"WPSR"
,
"WPNAME"
,
"WPTYPE"
};
@Autowired
private
ReportGeneratorImpl
reportGenerator
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/WPNAME.java
View file @
ea289174
...
...
@@ -49,23 +49,16 @@ public class WPNAME extends FunctionBase implements FreeRefFunction {
public
ValueEval
wrapExceptionEval
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
throws
Exception
{
List
<
Object
>
ds
=
new
ArrayList
<>();
return
new
NumberEval
(
bb
(
new
WPNAMEParasBo
(
args
,
ec
),
ec
,
ds
,
null
).
doubleValue
());
return
new
NumberEval
(
bb
(
new
WPNAMEParasBo
(
args
,
ec
),
ec
,
ds
).
doubleValue
());
}
public
BigDecimal
bb
(
WPNAMEParasBo
bo
,
OperationEvaluationContext
ec
,
List
<
Object
>
dataSource
,
WPNAMEParasBo
rootBo
)
throws
Exception
{
CurrentPeriodBo
curPeriod
=
CurrentPeriodBo
.
getPeriod
(
formulaContext
.
getPeriod
(),
formulaContext
.
getPeriod
());
curPeriod
.
setCurYear
(
formulaContext
.
getYear
());
public
BigDecimal
bb
(
WPNAMEParasBo
bo
,
OperationEvaluationContext
ec
,
List
<
Object
>
dataSource
)
throws
Exception
{
ReportCellDataSourceDto
nullCellDto
=
new
ReportCellDataSourceDto
();
dataSource
.
add
(
nullCellDto
);
BigDecimal
cellValue
=
BigDecimal
.
ZERO
;
CellTemplatePerGroupDto
cellTemplateData
=
null
;
try
{
List
<
CellTemplatePerGroupDto
>
cellTemplateDataList
;
//根据目标列+名称定位数据行,再根据参数列+数据行定位sheet单元格
cellTemplateDataList
=
agent
.
getCellTemplateByNameAndIndex
(
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
(),
bo
.
getReportCode
(),
bo
.
getRowColumnIndex
()-
1
,
bo
.
getRowName
(),
bo
.
getColumnIndex
()
-
1
,
formulaContext
.
getPeriod
());
...
...
@@ -81,15 +74,13 @@ public class WPNAME extends FunctionBase implements FreeRefFunction {
logger
.
warn
(
"[BB_Exception] some error {}"
,
bo
.
toString
());
throw
e
;
}
finally
{
if
(
rootBo
==
null
)
{
LOGGER
.
warn
(
"[BB_Exception] error for bb cacls for {} and current for {}"
,
bo
.
toString
(),
curPeriod
.
toString
());
LOGGER
.
warn
(
"[BB_Exception] error for bb cacls for {}"
,
bo
.
toString
());
Long
dataSourceId
=
saveDataSource
(
ec
,
dataSource
,
FormulaDataSourceDetailType
.
ReportCellDataSourceDto
,
cellValue
,
formulaContext
.
getPeriod
(),
formulaContext
.
getReportTemplateGroupId
(),
cellTemplateData
.
getColumnIndex
(),
cellTemplateData
.
getRowIndex
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
formulaContext
.
getPeriod
(),
ec
,
bo
.
expression
(),
cellValue
,
dataSourceId
,
formulaContext
.
getProjectId
());
}
}
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/WPTYPE.java
0 → 100644
View file @
ea289174
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.NumberEval
;
import
org.apache.poi.ss.formula.eval.StringEval
;
import
org.apache.poi.ss.formula.eval.ValueEval
;
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.dpo.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.dto.vatdto.WPTYPEParasBo
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.exception.FormulaException
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
WPTYPE
extends
FunctionBase
implements
FreeRefFunction
{
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
WPTYPE
.
class
);
final
static
ValueEval
defaultEval
=
new
StringEval
(
"0"
);
final
static
BigDecimal
defaultBigDecimal
=
new
BigDecimal
(
"0"
);
public
WPTYPE
(
FormulaContext
context
)
{
super
(
context
);
}
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
try
{
return
wrapExceptionEval
(
args
,
ec
);
}
catch
(
Exception
e
)
{
if
(
e
instanceof
FormulaException
)
LOGGER
.
warn
(
"Formula Exception || {}"
,
e
.
getMessage
());
e
.
printStackTrace
();
return
defaultEval
;
}
}
public
ValueEval
wrapExceptionEval
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
throws
Exception
{
List
<
Object
>
ds
=
new
ArrayList
<>();
return
new
NumberEval
(
bb
(
new
WPTYPEParasBo
(
args
,
ec
),
ec
,
ds
).
doubleValue
());
}
public
BigDecimal
bb
(
WPTYPEParasBo
bo
,
OperationEvaluationContext
ec
,
List
<
Object
>
dataSource
)
throws
Exception
{
List
<
CellTemplatePerGroupDto
>
cellTemplateDataList
=
new
ArrayList
<
CellTemplatePerGroupDto
>();
BigDecimal
cellValue
=
BigDecimal
.
ZERO
;
try
{
String
queryDate
=
formulaContext
.
getYear
()
+
"-"
+
(
formulaContext
.
getPeriod
()
<
10
?
"0"
+
formulaContext
.
getPeriod
()
:
formulaContext
.
getPeriod
());
//根据type数据行,再根据参数列+数据行定位sheet单元格
cellTemplateDataList
=
agent
.
getCellTemplateByTypeAndIndex
(
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
(),
bo
.
getReportCode
(),
bo
.
getRowColumnIndex
()
-
1
,
bo
.
getTaxRate
(),
bo
.
getRevenueType
(),
bo
.
getTaxType
(),
bo
.
getColumnIndex
()
-
1
,
formulaContext
.
getPeriod
(),
formulaContext
.
getOrganizationId
(),
queryDate
,
queryDate
);
MyAsserts
.
assertNotEmpty
(
cellTemplateDataList
,
Exceptions
.
BB_CELL_TEMP_NULL
);
for
(
CellTemplatePerGroupDto
cellTemplateData
:
cellTemplateDataList
)
{
int
index
=
ec
.
getWorkbook
().
getSheetIndex
(
bo
.
getReportCode
());
BigDecimal
curCellVal
=
getCellValue
(
index
,
ec
,
formulaContext
,
agent
,
cellTemplateData
.
getRowIndex
(),
bo
.
getColumnIndex
()
-
1
,
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()));
cellValue
=
cellValue
.
add
(
curCellVal
);
ReportCellDataSourceDto
nullCellDto
=
new
ReportCellDataSourceDto
();
nullCellDto
.
extractFromGroup
(
bo
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
cellTemplateData
);
nullCellDto
.
setAmount
(
curCellVal
);
dataSource
.
add
(
nullCellDto
);
}
return
cellValue
;
}
catch
(
Exception
e
)
{
logger
.
warn
(
"[BB_Exception] some error {}"
,
bo
.
toString
());
throw
e
;
}
finally
{
LOGGER
.
warn
(
"[BB_Exception] error for bb cacls for {}"
,
bo
.
toString
());
Long
dataSourceId
=
saveDataSource
(
ec
,
dataSource
,
FormulaDataSourceDetailType
.
ReportCellDataSourceDto
,
cellValue
,
formulaContext
.
getPeriod
(),
formulaContext
.
getReportTemplateGroupId
(),
ec
.
getColumnIndex
(),
ec
.
getRowIndex
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
formulaContext
.
getPeriod
(),
ec
,
bo
.
getFormulaExpression
(),
cellValue
,
dataSourceId
,
formulaContext
.
getProjectId
());
}
}
}
atms-dao/src/main/java/pwc/taxtech/atms/dao/FormulaAdminMapper.java
View file @
ea289174
...
...
@@ -8,6 +8,7 @@ import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
import
pwc.taxtech.atms.dpo.GroupId
;
import
pwc.taxtech.atms.entity.Project
;
import
java.math.BigDecimal
;
import
java.util.List
;
@Mapper
...
...
@@ -128,4 +129,64 @@ public interface FormulaAdminMapper extends MyMapper {
@Param
(
"columnIndex"
)
Integer
columnIndex
,
@Param
(
"projectId"
)
String
projectId
,
@Param
(
"period"
)
Integer
period
);
@Select
(
"select "
+
" detail.*, "
+
" source_cell.cell_template_id AS cellTemplateID,"
+
" source_cell.column_index AS columnIndex,"
+
" source_cell.column_name AS columnName,"
+
" source_cell.row_name AS rowName,"
+
" source_cell.data_type AS resultType "
+
"from ("
+
" select "
+
" template.template_id AS reportTemplateID,"
+
" template.template_group_id AS reportTemplateGroupID,"
+
" template.code AS reportCode,"
+
" cell_template.row_index AS rowIndex "
+
" from "
+
" revenue_config revenue "
+
" inner join "
+
" period_cell_template as cell_template "
+
" on "
+
" revenue.name = cell_template.row_name "
+
" and "
+
" cell_template.column_index = #{rowColumnIndex}"
+
" inner join "
+
" period_template as template "
+
" on template.template_id = cell_template.report_template_id"
+
" where "
+
" revenue.org_id = #{orgId}"
+
" and revenue.tax_rate = #{taxRate}"
+
" and revenue.revenue_type = #{revenueType}"
+
" and revenue.tax_type = #{taxType}"
+
" and revenue.start_date <= #{startDate}"
+
" and revenue.end_date>= #{endDate}"
+
" and template.template_group_id = #{templateGroupId}"
+
" and template.is_active_association = 1"
+
" and template.code = #{code}"
+
" and template.project_id = #{projectId}"
+
" and template.period = #{period}"
+
" and cell_template.project_id = #{projectId}"
+
" and cell_template.period = #{period}) as detail,"
+
" period_cell_template as source_cell"
+
" where source_cell.project_id = #{projectId}"
+
" and source_cell.period = #{period}"
+
" and detail.reportTemplateID = source_cell.report_template_id"
+
" and detail.rowIndex = source_cell.row_index"
+
" and source_cell.column_index = #{columnIndex}"
)
List
<
CellTemplatePerGroupDto
>
getCellTemplateByTypeAndIndex
(
@Param
(
"templateGroupId"
)
Long
templateGroupId
,
@Param
(
"projectId"
)
String
projectId
,
@Param
(
"code"
)
String
code
,
@Param
(
"rowColumnIndex"
)
Integer
rowColumnIndex
,
@Param
(
"taxRate"
)
BigDecimal
taxRate
,
@Param
(
"revenueType"
)
Integer
revenueType
,
@Param
(
"taxType"
)
Integer
taxType
,
@Param
(
"columnIndex"
)
Integer
columnIndex
,
@Param
(
"period"
)
Integer
period
,
@Param
(
"orgId"
)
String
orgId
,
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
}
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