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
3a967848
Commit
3a967848
authored
Nov 21, 2018
by
eddie.woo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
e02c2c8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
2 deletions
+47
-2
WPSR.java
.../taxtech/atms/vat/service/impl/report/functions/WPSR.java
+47
-2
No files found.
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/WPSR.java
View file @
3a967848
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
...
...
@@ -8,6 +9,10 @@ import org.apache.poi.ss.formula.eval.ValueEval;
import
org.apache.poi.ss.formula.functions.FreeRefFunction
;
import
pwc.taxtech.atms.common.util.DateUtils
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.constant.DataSourceName
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceType
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.entity.Organization
;
import
pwc.taxtech.atms.entity.Project
;
import
pwc.taxtech.atms.vat.dao.HlOutputInterfaceLineMapper
;
...
...
@@ -44,6 +49,7 @@ public class WPSR extends FunctionBase implements FreeRefFunction {
return
ZERO_EVAL
;
}
ValueEval
result
=
ZERO_EVAL
;
String
formulaExpression
=
"WPSR("
+
type
+
","
+
rate
+
")"
;
try
{
int
period
=
formulaContext
.
getPeriod
();
int
year
=
formulaContext
.
getYear
();
...
...
@@ -57,10 +63,28 @@ public class WPSR extends FunctionBase implements FreeRefFunction {
HlOutputInterfaceLineExample
lineExample
=
new
HlOutputInterfaceLineExample
();
lineExample
.
createCriteria
().
andSjfyrqBetween
(
periodStart
,
periodEnd
).
andSfkpNotEqualTo
(
"1"
)
.
andEbsSrbjEqualTo
(
"1"
).
andYwstidEqualTo
(
organization
.
getCode
());
//排除 状态1:已开票,即未开票和预开票
List
<
HlOutputInterfaceLine
>
lineList
=
interfaceLineMapper
.
selectByExample
(
lineExample
);
//todo 无订单业务
List
<
HlOutputInterfaceLine
>
lineList
=
interfaceLineMapper
.
selectByExample
(
lineExample
);
BigDecimal
tmp
=
BigDecimal
.
ZERO
;
if
(!
CollectionUtils
.
isEmpty
(
lineList
))
{
result
=
new
StringEval
(
getSum
(
lineList
,
rateStr
).
toPlainString
());
tmp
=
tmp
.
add
(
getSum
(
lineList
,
rateStr
));
}
//无订单业务
HlOutputInterfaceLineExample
lineExampleWdd
=
new
HlOutputInterfaceLineExample
();
lineExampleWdd
.
createCriteria
().
andSjfyrqBetween
(
periodStart
,
periodEnd
).
andContextEqualTo
(
"ETMS"
)
.
andEbsSrbjEqualTo
(
"1"
).
andYwstidEqualTo
(
organization
.
getCode
()).
andTaxrateEqualTo
(
rateStr
);
HlOutputInterfaceLineExample
.
Criteria
criteria2
=
lineExampleWdd
.
createCriteria
().
andSjfyrqBetween
(
periodStart
,
periodEnd
)
.
andContextEqualTo
(
"ETMS"
).
andEbsSrbjEqualTo
(
"1"
).
andYwstidEqualTo
(
organization
.
getCode
())
.
andTaxrateEqualTo
(
rateStr
.
substring
(
1
));
// 兼容税率为.16 这种数据
lineExampleWdd
.
or
(
criteria2
);
List
<
HlOutputInterfaceLine
>
lineListWdd
=
interfaceLineMapper
.
selectByExample
(
lineExampleWdd
);
if
(!
CollectionUtils
.
isEmpty
(
lineListWdd
))
{
List
<
String
>
idList
=
lineListWdd
.
stream
().
map
(
HlOutputInterfaceLine:
:
getUuid
).
collect
(
Collectors
.
toList
());
HlOutputOrderKpsqmxbExample
mxbExample
=
new
HlOutputOrderKpsqmxbExample
();
mxbExample
.
createCriteria
().
andIdIn
(
idList
);
tmp
=
tmp
.
add
(
kpsqmxbMapper
.
selectByExample
(
mxbExample
).
stream
().
map
(
o
->
NumberUtils
.
createBigDecimal
(
o
.
getHjje
())).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
));
}
result
=
new
StringEval
(
tmp
.
toPlainString
());
}
else
if
(
2
==
type
)
{
//跨月开票
HlOutputInterfaceLineExample
lineExample
=
new
HlOutputInterfaceLineExample
();
...
...
@@ -74,6 +98,27 @@ public class WPSR extends FunctionBase implements FreeRefFunction {
}
catch
(
Exception
e
)
{
logger
.
error
(
"evaluate WPSR error."
,
e
);
}
//todo data source 显示优化
try
{
BigDecimal
val
=
NumberUtils
.
createBigDecimal
(
result
.
toString
());
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
setAmount
(
val
);
dto
.
setName
(
DataSourceName
.
ReportDataSource
);
dto
.
setPeriod
(
formulaContext
.
getPeriod
());
dto
.
setProjectId
(
formulaContext
.
getProjectId
());
// dto.setRowIndex(pCell.rowIndex-1);
// dto.setColumnIndex(pCell.columnIndex-1);
dto
.
setColumnName
(
""
);
dto
.
setRowName
(
""
);
dto
.
setReportName
(
ec
.
getWorkbook
().
getSheetName
(
ec
.
getSheetIndex
()));
dto
.
setType
(
FormulaDataSourceType
.
Report
.
getCode
());
Long
dataSourceId
=
saveDataSource
(
ec
,
Lists
.
newArrayList
(
dto
),
FormulaDataSourceDetailType
.
InputInvoiceDataSourceDto
,
val
,
formulaContext
.
getPeriod
(),
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
formulaContext
.
getPeriod
(),
ec
,
formulaExpression
,
val
,
dataSourceId
,
formulaContext
.
getProjectId
());
}
catch
(
Exception
e
)
{
logger
.
error
(
"saveDataSource or saveFormulaBlock error."
,
e
);
}
return
result
;
}
...
...
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