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
e3f2030c
Commit
e3f2030c
authored
Sep 03, 2018
by
frank.xa.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed keyvalue formula paresed issue
parent
10871ac9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
9 deletions
+62
-9
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+1
-1
ReportServiceImpl.java
.../pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
+28
-7
GZSD.java
.../taxtech/atms/vat/service/impl/report/functions/GZSD.java
+33
-1
No files found.
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
e3f2030c
...
...
@@ -162,7 +162,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
otherFormulaCells
.
add
(
cell
);
}
//kv 公式处理
}
else
if
(
v
.
getFormula
().
startsWith
(
"@"
))
{
}
else
if
(
v
.
getFormula
().
contains
(
"@"
))
{
if
(
StringUtils
.
isNotBlank
(
v
.
getKeyValueParsedFormula
()))
{
cell
.
setCellFormula
(
v
.
getKeyValueParsedFormula
());
logger
.
debug
(
"formula:"
+
v
.
getKeyValueParsedFormula
());
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
View file @
e3f2030c
...
...
@@ -23,6 +23,8 @@ import java.math.BigDecimal;
import
java.sql.Struct
;
import
java.text.Normalizer
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
@Component
...
...
@@ -249,14 +251,33 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
periodCellTemplateConfig
.
setCellTemplateConfigId
(
cellTemplateConfig
.
getId
());
periodCellTemplateConfig
.
setKeyValueParsedFormula
(
StringUtils
.
EMPTY
);
if
(
cellTemplateConfig
.
getFormula
().
startsWith
(
"@"
))
{
//todo: get the keyvalue from table add to keyvalue parsed formula
KeyValueConfigExample
keyValueConfigExample
=
new
KeyValueConfigExample
();
keyValueConfigExample
.
createCriteria
().
andKeyCodeEqualTo
(
StringUtils
.
removeStart
(
cellTemplateConfig
.
getFormula
(),
"@"
));
Optional
<
KeyValueConfig
>
keyValueConfig
=
keyValueConfigMapper
.
selectByExample
(
keyValueConfigExample
).
stream
().
findFirst
();
if
(
keyValueConfig
.
isPresent
())
{
periodCellTemplateConfig
.
setKeyValueParsedFormula
(
keyValueConfig
.
get
().
getFormula
());
if
(
cellTemplateConfig
.
getFormula
().
contains
(
"@"
))
{
String
regex
=
"@[0-9A-Z.]+"
;
Pattern
pp
=
Pattern
.
compile
(
regex
);
Matcher
mm
=
pp
.
matcher
(
cellTemplateConfig
.
getFormula
());
String
replace_result
=
cellTemplateConfig
.
getFormula
();
Boolean
replace
=
true
;
while
(
mm
.
find
())
{
KeyValueConfigExample
keyValueConfigExample
=
new
KeyValueConfigExample
();
keyValueConfigExample
.
createCriteria
().
andKeyCodeEqualTo
(
StringUtils
.
removeStart
(
mm
.
group
(),
"@"
));
Optional
<
KeyValueConfig
>
keyValueConfig
=
keyValueConfigMapper
.
selectByExample
(
keyValueConfigExample
).
stream
().
findFirst
();
if
(
keyValueConfig
.
isPresent
()
&&
StringUtils
.
isNotBlank
(
keyValueConfig
.
get
().
getFormula
()))
{
replace_result
=
replace_result
.
replace
(
mm
.
group
(),
keyValueConfig
.
get
().
getFormula
());
}
else
{
replace
=
false
;
}
}
if
(
replace
)
{
periodCellTemplateConfig
.
setKeyValueParsedFormula
(
replace_result
);
}
//todo: get the keyvalue from table add to keyvalue parsed formula
// KeyValueConfigExample keyValueConfigExample = new KeyValueConfigExample();
// keyValueConfigExample.createCriteria().andKeyCodeEqualTo(StringUtils.removeStart(cellTemplateConfig.getFormula(), "@"));
// Optional<KeyValueConfig> keyValueConfig = keyValueConfigMapper.selectByExample(keyValueConfigExample).stream().findFirst();
// if (keyValueConfig.isPresent()) {
// periodCellTemplateConfig.setKeyValueParsedFormula(keyValueConfig.get().getFormula());
// }
}
periodCellTemplateConfigList
.
add
(
periodCellTemplateConfig
);
//logger.debug("cellTemplateConfig copy end,used time: " + (System.currentTimeMillis() - startTime) + " ms");
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/GZSD.java
View file @
e3f2030c
...
...
@@ -40,6 +40,8 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
return
null
;
}
BigDecimal
decimal_zero
=
new
BigDecimal
(
"0.0"
);
Integer
taxCategory
=
getIntParam
(
args
[
0
],
ec
);
Integer
resultType
=
getIntParam
(
args
[
1
],
ec
);
String
formulaExpression
=
"GZSD("
+
taxCategory
+
","
+
resultType
+
")"
;
...
...
@@ -74,6 +76,20 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
matchedRule
=
Optional
.
ofNullable
(
taxRuleSettings
.
size
()>
0
?
taxRuleSettings
.
get
(
0
):
null
);
if
(!
matchedRule
.
isPresent
())
{
NumberFormat
nf
=
NumberFormat
.
getPercentInstance
();
nf
.
setMaximumFractionDigits
(
2
);
List
<
FormulaDataSourceDto
>
dataSourceDtoList
=
new
ArrayList
<>();
FormulaDataSourceDto
formulaDataSourceDto
=
new
FormulaDataSourceDto
();
formulaDataSourceDto
.
setOperationType
(
EnumOperationType
.
Single
.
getCode
());
formulaDataSourceDto
.
setType
(
FormulaDataSourceType
.
Report
.
getCode
());
formulaDataSourceDto
.
setResultType
(
KeyValueConfigResultType
.
Percentage
.
getCode
());
formulaDataSourceDto
.
setAmount
(
decimal_zero
);
formulaDataSourceDto
.
setName
(
nf
.
format
(
decimal_zero
));
dataSourceDtoList
.
add
(
formulaDataSourceDto
);
Long
dataSourceId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSourceDtoList
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
decimal_zero
,
formulaContext
.
getPeriod
(),
formulaContext
.
getReportTemplateGroupID
());
saveFormulaBlock
(
formulaContext
.
getPeriod
(),
ec
,
formulaExpression
,
decimal_zero
,
dataSourceId
);
return
NumberEval
.
ZERO
;
}
}
...
...
@@ -102,7 +118,23 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
//todo: @本期应(实)纳税额 ,@GDZC.BQ.QMYE 这种类型的数据,重新计算,按照keyvalue的配置
//return new NumberEval(matchedRule.get().getTaxBase());
NumberFormat
nf
=
NumberFormat
.
getPercentInstance
();
nf
.
setMaximumFractionDigits
(
2
);
List
<
FormulaDataSourceDto
>
dataSourceDtoList
=
new
ArrayList
<>();
FormulaDataSourceDto
formulaDataSourceDto
=
new
FormulaDataSourceDto
();
formulaDataSourceDto
.
setOperationType
(
EnumOperationType
.
Single
.
getCode
());
formulaDataSourceDto
.
setType
(
FormulaDataSourceType
.
Report
.
getCode
());
formulaDataSourceDto
.
setResultType
(
KeyValueConfigResultType
.
Percentage
.
getCode
());
formulaDataSourceDto
.
setAmount
(
decimal_zero
);
formulaDataSourceDto
.
setName
(
nf
.
format
(
decimal_zero
));
dataSourceDtoList
.
add
(
formulaDataSourceDto
);
Long
dataSourceId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSourceDtoList
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
decimal_zero
,
formulaContext
.
getPeriod
(),
formulaContext
.
getReportTemplateGroupID
());
saveFormulaBlock
(
formulaContext
.
getPeriod
(),
ec
,
formulaExpression
,
decimal_zero
,
dataSourceId
);
return
NumberEval
.
ZERO
;
}
return
NumberEval
.
ZERO
;
//
return NumberEval.ZERO;
}
}
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