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
4da82e2b
Commit
4da82e2b
authored
Mar 12, 2019
by
kevin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#自定义公式
parent
2aeee399
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
326 additions
and
17 deletions
+326
-17
SpringContextUtil.java
.../java/pwc/taxtech/atms/common/util/SpringContextUtil.java
+50
-0
StringUtil.java
...rc/main/java/pwc/taxtech/atms/common/util/StringUtil.java
+91
-0
AccountController.java
...n/java/pwc/taxtech/atms/controller/AccountController.java
+3
-5
TableRule.java
atms-api/src/main/java/pwc/taxtech/atms/dto/TableRule.java
+30
-0
CitReportServiceImpl.java
...a/pwc/taxtech/atms/service/impl/CitReportServiceImpl.java
+1
-1
FormulaAgent.java
.../java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
+76
-7
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+2
-1
RSUMIF.java
...axtech/atms/vat/service/impl/report/functions/RSUMIF.java
+1
-3
TABLESUMIF.java
...ch/atms/vat/service/impl/report/functions/TABLESUMIF.java
+72
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/common/util/SpringContextUtil.java
View file @
4da82e2b
...
...
@@ -10,6 +10,10 @@ import pwc.taxtech.atms.invoice.OutputInvoiceDetailMapper;
import
pwc.taxtech.atms.invoice.OutputInvoiceMapper
;
import
pwc.taxtech.atms.service.impl.DistributedIdService
;
import
pwc.taxtech.atms.vat.dao.*
;
import
pwc.taxtech.atms.vat.entity.BalanceSheet
;
import
java.util.HashMap
;
import
java.util.Map
;
//用来获取spring托管的bean
@Component
...
...
@@ -55,6 +59,23 @@ public class SpringContextUtil implements ApplicationContextAware {
public
static
TrialBalanceMapper
trialBalanceMapper
;
public
static
AdjustmentTableMapper
adjustmentTableMapper
;
public
static
TrialBalanceFinalMapper
trialBalanceFinalMapper
;
public
static
ProfitLossStatementMapper
profitLossStatementMapper
;
public
static
CashFlowMapper
cashFlowMapper
;
public
static
BalanceSheetManualMapper
balanceSheetManualMapper
;
public
static
ProfitLossStatementManualMapper
profitLossStatementManualMapper
;
public
static
CashFlowManualMapper
cashFlowManualMapper
;
public
static
BalanceSheetFinalMapper
balanceSheetFinalMapper
;
public
static
CashFlowFinalMapper
cashFlowFinalMapper
;
public
static
CitBalanceSheetPrcAdjustMapper
citBalanceSheetPrcAdjustMapper
;
public
static
CitProfitPrcAdjustMapper
citProfitPrcAdjustMapper
;
public
static
BalanceSheetMapper
balanceSheetMapper
;
public
static
Map
map
=
new
HashMap
<
String
,
Object
>();
/**
* 获取bean
...
...
@@ -111,5 +132,34 @@ public class SpringContextUtil implements ApplicationContextAware {
trialBalanceMapper
=
webApplicationContext
.
getBean
(
TrialBalanceMapper
.
class
);
adjustmentTableMapper
=
webApplicationContext
.
getBean
(
AdjustmentTableMapper
.
class
);
trialBalanceFinalMapper
=
webApplicationContext
.
getBean
(
TrialBalanceFinalMapper
.
class
);
profitLossStatementMapper
=
webApplicationContext
.
getBean
(
ProfitLossStatementMapper
.
class
);
cashFlowMapper
=
webApplicationContext
.
getBean
(
CashFlowMapper
.
class
);
balanceSheetManualMapper
=
webApplicationContext
.
getBean
(
BalanceSheetManualMapper
.
class
);
profitLossStatementManualMapper
=
webApplicationContext
.
getBean
(
ProfitLossStatementManualMapper
.
class
);
cashFlowManualMapper
=
webApplicationContext
.
getBean
(
CashFlowManualMapper
.
class
);
balanceSheetFinalMapper
=
webApplicationContext
.
getBean
(
BalanceSheetFinalMapper
.
class
);
cashFlowFinalMapper
=
webApplicationContext
.
getBean
(
CashFlowFinalMapper
.
class
);
citBalanceSheetPrcAdjustMapper
=
webApplicationContext
.
getBean
(
CitBalanceSheetPrcAdjustMapper
.
class
);
citProfitPrcAdjustMapper
=
webApplicationContext
.
getBean
(
CitProfitPrcAdjustMapper
.
class
);
balanceSheetMapper
=
webApplicationContext
.
getBean
(
BalanceSheetMapper
.
class
);
/* map.put("balance_sheet", balanceMapper);
map.put("profit_loss_statement",profitLossStatementMapper);
map.put("cash_flow", cashFlowMapper);
map.put("balance_sheet_manual", balanceSheetManualMapper);
map.put("profit_loss_statement_manual", profitLossStatementManualMapper);
map.put("cash_flow_manual", cashFlowManualMapper);
map.put("balance_sheet_final", balanceSheetFinalMapper);
map.put("profit_loss_statement_final", profitLossStatementManualMapper);
map.put("cash_flow_final", cashFlowFinalMapper);
map.put("cit_balance_sheet_prc_adjust", citBalanceSheetPrcAdjustMapper);
map.put("cit_profit_prc_adjust", citProfitPrcAdjustMapper);*/
}
}
atms-api/src/main/java/pwc/taxtech/atms/common/util/StringUtil.java
0 → 100644
View file @
4da82e2b
package
pwc
.
taxtech
.
atms
.
common
.
util
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* @ClassName StringUtil
* Description TODO
* @Author pwc kevin
* @Date 3/11/2019 5:29 PM
* Version 1.0
**/
public
class
StringUtil
{
/**
* 下划线转驼峰法(默认小驼峰)
*
* @param line
* 源字符串
* @param smallCamel
* 大小驼峰,是否为小驼峰(驼峰,第一个字符是大写还是小写)
* @return 转换后的字符串
*/
public
static
String
underline2Camel
(
String
line
,
boolean
...
smallCamel
)
{
if
(
line
==
null
||
""
.
equals
(
line
))
{
return
""
;
}
StringBuffer
sb
=
new
StringBuffer
();
Pattern
pattern
=
Pattern
.
compile
(
"([A-Za-z\\d]+)(_)?"
);
Matcher
matcher
=
pattern
.
matcher
(
line
);
//匹配正则表达式
while
(
matcher
.
find
())
{
String
word
=
matcher
.
group
();
//当是true 或则是空的情况
if
((
smallCamel
.
length
==
0
||
smallCamel
[
0
]
)
&&
matcher
.
start
()==
0
){
sb
.
append
(
Character
.
toLowerCase
(
word
.
charAt
(
0
)));
}
else
{
sb
.
append
(
Character
.
toUpperCase
(
word
.
charAt
(
0
)));
}
int
index
=
word
.
lastIndexOf
(
'_'
);
if
(
index
>
0
)
{
sb
.
append
(
word
.
substring
(
1
,
index
).
toLowerCase
());
}
else
{
sb
.
append
(
word
.
substring
(
1
).
toLowerCase
());
}
}
return
sb
.
toString
();
}
/**
* 驼峰法转下划线
*
* @param line
* 源字符串
* @return 转换后的字符串
*/
public
static
String
camel2Underline
(
String
line
)
{
if
(
line
==
null
||
""
.
equals
(
line
))
{
return
""
;
}
line
=
String
.
valueOf
(
line
.
charAt
(
0
)).
toUpperCase
()
.
concat
(
line
.
substring
(
1
));
StringBuffer
sb
=
new
StringBuffer
();
Pattern
pattern
=
Pattern
.
compile
(
"[A-Z]([a-z\\d]+)?"
);
Matcher
matcher
=
pattern
.
matcher
(
line
);
while
(
matcher
.
find
())
{
String
word
=
matcher
.
group
();
sb
.
append
(
word
.
toUpperCase
());
sb
.
append
(
matcher
.
end
()
==
line
.
length
()
?
""
:
"_"
);
}
return
sb
.
toString
();
}
/* public static void main(String[] args) {
String line = "are_you_dou_bi_yellowcong";
//下划线转驼峰(大驼峰)
//AreYouDouBiYellowcong
String camel = underline2Camel(line, true);
System.out.println(camel);
//下划线转驼峰(小驼峰)
//areYouDouBiYellowcong
camel = underline2Camel(line);
System.out.println(camel);
//驼峰转下划线
//ARE_YOU_DOU_BI_YELLOWCONG
System.out.println(camel2Underline(camel));
}*/
}
atms-api/src/main/java/pwc/taxtech/atms/controller/AccountController.java
View file @
4da82e2b
...
...
@@ -4,15 +4,12 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
pwc.taxtech.atms.dto.LoginOutputDto
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.dto.user.UserPasswordDto
;
import
pwc.taxtech.atms.service.impl.UserAccountServiceImpl
;
import
pwc.taxtech.atms.vat.service.impl.FormulaAgent
;
@RestController
@RequestMapping
(
"/api/v1/Account/"
)
...
...
@@ -37,4 +34,5 @@ public class AccountController {
logger
.
debug
(
"enter forgetPassword"
);
return
userAccountService
.
forgetPassword
(
mail
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/TableRule.java
0 → 100644
View file @
4da82e2b
package
pwc
.
taxtech
.
atms
.
dto
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @ClassName DataTablesEnum
* Description TODO
* @Author pwc kevin
* @Date 3/11/2019 2:30 PM
* Version 1.0
**/
public
class
TableRule
{
public
static
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
static
{
map
.
put
(
"EBSZCFZB"
,
"balance_sheet"
);
map
.
put
(
"EBSLRB"
,
"profit_loss_statement"
);
map
.
put
(
"EBSXJLLB"
,
"cash_flow"
);
map
.
put
(
"RGDRZCFZB"
,
"balance_sheet_manual"
);
map
.
put
(
"RGDRLRB"
,
"profit_loss_statement_manual"
);
map
.
put
(
"RGDRXJLLB"
,
"cash_flow_manual"
);
map
.
put
(
"ZXZCFZB"
,
"balance_sheet_final"
);
map
.
put
(
"ZXLLB"
,
"profit_loss_statement_final"
);
map
.
put
(
"ZXXJLLB"
,
"cash_flow_final"
);
map
.
put
(
"CITZCFZB"
,
"cit_balance_sheet_prc_adjust"
);
map
.
put
(
"CITLRB"
,
"cit_profit_prc_adjust"
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/CitReportServiceImpl.java
View file @
4da82e2b
...
...
@@ -58,7 +58,7 @@ public class CitReportServiceImpl extends BaseService {
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
CitReportServiceImpl
.
class
);
private
final
static
String
[]
functions
=
{
"SGSR"
,
"FSJZ"
,
"ND"
,
"BB"
,
"XXFP"
,
"GZSD"
,
"PC"
,
"JXFPMX"
,
"JXFP"
,
"PSUM"
,
"DFFS"
,
"JFFS"
,
"WPSR"
,
"WPNAME"
,
"WPTYPE"
};
"JXFP"
,
"PSUM"
,
"DFFS"
,
"JFFS"
,
"WPSR"
,
"WPNAME"
,
"WPTYPE"
,
"SUM2"
,
"SUM"
,
"RSUMIF"
,
"TABLESUM2"
};
@Autowired
private
OrganizationServiceTemplateGroupMapper
orgServiceTemplateGroupMapper
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
View file @
4da82e2b
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Component
;
import
pwc.taxtech.atms.MyVatMapper
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.common.util.StringUtil
;
import
pwc.taxtech.atms.constant.enums.EnumServiceType
;
import
pwc.taxtech.atms.dao.FormulaAdminMapper
;
import
pwc.taxtech.atms.dao.ProjectServiceTypeMapper
;
import
pwc.taxtech.atms.dpo.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dpo.GroupId
;
import
pwc.taxtech.atms.dto.TableRule
;
import
pwc.taxtech.atms.entity.Project
;
import
pwc.taxtech.atms.entity.ProjectServiceType
;
import
pwc.taxtech.atms.entity.ProjectServiceTypeExample
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.dao.CellDataMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodCellDataMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodReportMapper
;
import
pwc.taxtech.atms.vat.dao.*
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
FIRST_OR_DEFAULT
;
...
...
@@ -59,6 +63,7 @@ public class FormulaAgent {
/**
* 根据收入类型配置及列index查询报表模板
*
* @param templateGroupId
* @param code
* @param rowColumnIndex
...
...
@@ -85,7 +90,7 @@ public class FormulaAgent {
String
orgId
,
String
startDate
,
String
endDate
)
{
return
adminMp
.
getCellTemplateByTypeAndIndex
(
templateGroupId
,
projectId
,
code
,
rowColumnIndex
,
taxRate
,
revenueType
,
taxType
,
columnIndex
,
period
,
orgId
,
startDate
,
endDate
);
return
adminMp
.
getCellTemplateByTypeAndIndex
(
templateGroupId
,
projectId
,
code
,
rowColumnIndex
,
taxRate
,
revenueType
,
taxType
,
columnIndex
,
period
,
orgId
,
startDate
,
endDate
);
}
public
Project
getFixedProject
(
String
projectId
,
Integer
year
)
{
...
...
@@ -132,11 +137,75 @@ public class FormulaAgent {
return
cellData
;
}
public
List
<
CellTemplatePerGroupDto
>
getCellDataByPos
(
Long
templateId
,
Integer
period
,
String
cellRow
,
String
cellCol
,
String
projectId
)
{
return
adminMp
.
getCellDataByPos
(
templateId
,
period
,
cellRow
,
cellCol
,
projectId
);
public
List
<
CellTemplatePerGroupDto
>
getCellDataByPos
(
Long
templateId
,
Integer
period
,
String
cellRow
,
String
cellCol
,
String
projectId
)
{
return
adminMp
.
getCellDataByPos
(
templateId
,
period
,
cellRow
,
cellCol
,
projectId
);
}
public
List
<
CellTemplatePerGroupDto
>
getTableData
(
String
tableName
,
String
getField
,
String
selectFilter
,
String
year
,
String
selectPeriod
)
{
return
adminMp
.
getTableData
(
tableName
,
getField
,
selectFilter
,
year
,
selectPeriod
);
}
public
static
String
buildSql
(
String
tableName
,
String
getField
,
String
filter
,
String
filterValue
,
Integer
period
,
String
year
,
FormulaContext
formulaContext
)
{
String
sql
=
""
;
String
[]
split
=
filterValue
.
split
(
" "
);
String
para3
=
null
;
if
(
split
[
0
].
indexOf
(
">="
)
!=
-
1
)
{
filterValue
=
"> "
+
split
[
1
]
+
"and"
+
filter
+
" ="
+
split
[
1
];
}
if
(
split
[
0
].
indexOf
(
"<="
)
!=
-
1
)
{
filterValue
=
"< "
+
split
[
1
]
+
"and"
+
filter
+
" ="
+
split
[
1
];
}
if
(
"CITZCFZB"
.
equals
(
tableName
)
||
(
"CITLRB"
.
equals
(
tableName
)))
{
return
_buildSql
(
getField
,
tableName
,
filter
,
filterValue
,
period
,
formulaContext
,
year
,
false
);
}
return
_buildSql
(
getField
,
tableName
,
filter
,
filterValue
,
period
,
formulaContext
,
year
,
true
);
}
public
static
String
_buildSql
(
String
getField
,
String
tableName
,
String
filter
,
String
filterValue
,
Integer
period
,
FormulaContext
formulaContext
,
String
year
,
boolean
bool
)
{
String
sql
=
"select "
+
getField
+
" from "
+
tableName
+
" where 1=1 and "
+
filter
+
filterValue
;
String
_p
=
""
;
if
(
formulaContext
.
getPeriod
()
-
period
<
10
)
{
_p
=
year
+
"'0"
+
(
formulaContext
.
getPeriod
()
-
period
)
+
"'"
;
}
else
{
_p
=
year
+
(
formulaContext
.
getPeriod
()
-
period
);
}
if
(
period
==
0
)
{
sql
+=
" and tms-period = "
+
formulaContext
.
getPeriod
();
}
else
if
(
period
==
-
99
)
{
sql
+=
"and tms-period between '"
+
year
+
"01' and "
+
(
formulaContext
.
getPeriod
()
-
1
);
}
else
if
(
period
==
99
)
{
sql
+=
"and tms-period between '"
+
year
+
"01' and "
+
(
formulaContext
.
getPeriod
());
}
else
{
sql
+=
"and tms-period between "
+
_p
+
"and "
+
(
formulaContext
.
getPeriod
()
-
1
);
}
if
(
bool
)
{
sql
+=
" and period = '"
+
year
+
period
+
"'"
;
}
return
sql
;
}
@Autowired
JdbcTemplate
jdbcTemplate
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
buildSql
(
"balance_sheet"
,
"end_bal"
,
"beg_bal"
,
"> 0.00"
,
201810
,
"2"
,
null
));
;
}
public
Long
getTableDataByName
(
String
tableName
,
String
getField
,
String
filter
,
String
filterValue
,
Integer
period
,
String
year
,
FormulaContext
formulaContext
)
{
List
<
Map
<
String
,
Object
>>
stringObjectMap
=
jdbcTemplate
.
queryForList
(
buildSql
(
TableRule
.
map
.
get
(
tableName
),
getField
,
filter
,
filterValue
,
period
,
year
,
formulaContext
));
Long
rev
=
0L
;
for
(
int
i
=
0
,
j
=
stringObjectMap
.
size
();
i
<
j
;
i
++)
{
if
(
i
==
1
)
{
rev
=
Long
.
parseLong
(
String
.
valueOf
(
stringObjectMap
.
get
(
i
).
get
(
StringUtil
.
underline2Camel
(
getField
))));
}
else
{
rev
=
rev
+
Long
.
parseLong
(
String
.
valueOf
(
stringObjectMap
.
get
(
i
).
get
(
StringUtil
.
underline2Camel
(
getField
))));
}
}
return
rev
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
4da82e2b
...
...
@@ -512,7 +512,8 @@ 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
WPTYPE
(
formulaContext
)};
new
JFFS
(
formulaContext
),
new
WPSR
(
formulaContext
),
new
WPNAME
(
formulaContext
),
new
WPTYPE
(
formulaContext
),
new
SUM2
(
formulaContext
),
new
SUM
(
formulaContext
),
new
RSUMIF
(
formulaContext
),
new
TABLESUMIF
(
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/report/functions/RSUMIF.java
View file @
4da82e2b
...
...
@@ -30,7 +30,7 @@ import static pwc.taxtech.atms.common.util.FormulaUtil.resolverString;
public
class
RSUMIF
extends
FunctionBase
implements
FreeRefFunction
{
final
static
ValueEval
defaultEval
=
new
StringEval
(
"0"
);
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
BB
.
class
);
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RSUMIF
.
class
);
String
tableName
;
String
getField
;
//取值列字段
Map
<
String
,
String
>
fileterMap
=
new
HashMap
<
String
,
String
>();
...
...
@@ -53,7 +53,6 @@ public class RSUMIF extends FunctionBase implements FreeRefFunction {
}
catch
(
Exception
e
)
{
if
(
e
instanceof
FormulaException
)
LOGGER
.
warn
(
"Formula Exception || {}"
,
e
.
getMessage
());
e
.
printStackTrace
();
return
defaultEval
;
}
...
...
@@ -99,7 +98,6 @@ public class RSUMIF extends FunctionBase implements FreeRefFunction {
fileterMap
.
put
(
resolverString
(
args
,
ec
,
i
),
resolverString
(
args
,
ec
,
i
+
1
));
}
}
if
(
period
==
0
)
{
selectPeriod
=
"t.period = "
+
formulaContext
.
getPeriod
();
}
else
if
(
period
==
-
99
)
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/TABLESUMIF.java
0 → 100644
View file @
4da82e2b
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.EvaluationException
;
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.dto.OperationResultDto
;
import
pwc.taxtech.atms.dto.TableRule
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
pwc
.
taxtech
.
atms
.
common
.
util
.
FormulaUtil
.
resolverInteger
;
import
static
pwc
.
taxtech
.
atms
.
common
.
util
.
FormulaUtil
.
resolverString
;
/**
* @ClassName TABLESUMIF
* Description TODO
* @Author pwc kevin
* @Date 3/11/2019 2:52 PM
* Version 1.0
**/
public
class
TABLESUMIF
extends
FunctionBase
implements
FreeRefFunction
{
private
String
tableName
;
public
TABLESUMIF
(
FormulaContext
formulaContext
)
{
super
(
formulaContext
);
}
//进行参数验证
public
void
parameterCheck
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
argsLength
=
args
.
length
;
if
(
argsLength
!=
6
)
//参数小于当做异常处理, 最后俩参数可以取默认值
throw
Exceptions
.
parameterError
;
try
{
tableName
=
resolverString
(
args
,
ec
,
0
);
Map
<
String
,
String
>
map
=
TableRule
.
map
;
if
(!
map
.
containsKey
(
tableName
))
throw
Exceptions
.
parameterError
;
}
catch
(
EvaluationException
e
)
{
e
.
printStackTrace
();
}
}
Integer
argsLength
;
String
getField
;
Integer
period
;
String
year
;
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
parameterCheck
(
args
,
ec
);
try
{
tableName
=
resolverString
(
args
,
ec
,
0
);
getField
=
resolverString
(
args
,
ec
,
1
);
String
filter
=
resolverString
(
args
,
ec
,
2
);
String
filterValue
=
resolverString
(
args
,
ec
,
3
);
period
=
resolverInteger
(
args
,
ec
,
4
);
//会计期间
year
=
resolverString
(
args
,
ec
,
5
);
//会计年度
new
NumberEval
(
agent
.
getTableDataByName
(
tableName
,
getField
,
filter
,
filterValue
,
period
,
year
,
formulaContext
));
}
catch
(
EvaluationException
e
)
{
e
.
printStackTrace
();
return
new
NumberEval
(
0.00
);
}
return
new
NumberEval
(
0.00
);
}
}
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