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
9e1827ab
Commit
9e1827ab
authored
Mar 18, 2019
by
chase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge档案管理
parent
48adb09f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
180 additions
and
197 deletions
+180
-197
POIUtil.java
atms-api/src/main/java/pwc/taxtech/atms/common/POIUtil.java
+1
-5
TaxDocumentServiceImpl.java
...pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
+3
-3
ReportServiceImpl.java
.../pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
+45
-11
DFFS.java
.../taxtech/atms/vat/service/impl/report/functions/DFFS.java
+64
-88
JFFS.java
.../taxtech/atms/vat/service/impl/report/functions/JFFS.java
+66
-89
TaxDocumentMapper.java
...src/main/java/pwc/taxtech/atms/dao/TaxDocumentMapper.java
+1
-1
No files found.
atms-api/src/main/java/pwc/taxtech/atms/common/POIUtil.java
View file @
9e1827ab
...
...
@@ -117,7 +117,7 @@ public class POIUtil {
return
row
;
}
public
static
Row
createAndCloneRow
(
Workbook
wb
,
Sheet
sheet
,
Integer
destRowIndex
,
Row
fromRow
)
{
public
static
Row
createAndCloneRow
(
Workbook
wb
,
Sheet
sheet
,
Integer
destRowIndex
,
Row
fromRow
)
{
Row
toRow
=
null
;
if
(
sheet
.
getRow
(
destRowIndex
)
!=
null
)
{
int
lastRowNo
=
sheet
.
getLastRowNum
();
...
...
@@ -136,10 +136,6 @@ public class POIUtil {
boolean
copyValueFlag
)
{
CellStyle
newstyle
=
wb
.
createCellStyle
();
copyCellStyle
(
wb
,
srcCell
.
getCellStyle
(),
newstyle
);
if
(
srcCell
.
getColumnIndex
()==
7
){
newstyle
.
setLocked
(
false
);
}
// distCell.setEncoding(srcCell.getEncoding());
//样式
distCell
.
setCellStyle
(
newstyle
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
View file @
9e1827ab
...
...
@@ -190,15 +190,15 @@ public class TaxDocumentServiceImpl {
taxDocument
.
setCreatorId
(
authUserHelper
.
getCurrentUserId
());
taxDocument
.
setUploadTime
(
new
Date
());
taxDocument
.
setYearRedundancy
(
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
));
Long
id
=
taxDocumentMapper
.
insert
(
taxDocument
);
int
num
=
taxDocumentMapper
.
insert
(
taxDocument
);
//根据公司Id 设置业务线
String
businessLine
=
organizationService
.
queryBusinessByCompanyId
(
taxDocument
.
getCompanyId
());
if
(
StringUtils
.
isNotBlank
(
businessLine
))
{
taxDocument
.
setBusinessLine
(
businessLine
);
}
if
(
id
>
0
)
{
if
(
num
>
0
)
{
OperationLogTaxDocument
actionEntity
=
buildOperationLogTaxDocument
();
actionEntity
.
setId
(
id
.
toString
());
actionEntity
.
setId
(
taxDocument
.
getId
()
.
toString
());
actionEntity
.
setOperationAction
(
"新增"
);
actionEntity
.
setUpdateState
(
taxDocument
.
toString
());
boolean
result
=
operationLogTaxDocService
.
addTaxDocumentList
(
actionEntity
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
View file @
9e1827ab
...
...
@@ -366,7 +366,19 @@ public class ReportServiceImpl extends BaseService {
@Transactional
public
void
assemblePeriodTemplate
(
Template
template
,
Workbook
workbook
,
String
projectId
,
Integer
period
,
Integer
addRowIndex
)
throws
ServiceException
{
List
<
Integer
>
hasHandDatas
=
Arrays
.
asList
(
TaxesCalculateReportEnum
.
Column
.
Column_5
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_6
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_7
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_8
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_10
.
getIndex
());
List
<
Integer
>
hasFormulaDatas
=
Arrays
.
asList
(
TaxesCalculateReportEnum
.
Column
.
Column_4
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_5
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_6
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_7
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_8
.
getIndex
(),
TaxesCalculateReportEnum
.
Column
.
Column_10
.
getIndex
());
try
{
Date
now
=
new
Date
();
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
...
...
@@ -397,11 +409,7 @@ public class ReportServiceImpl extends BaseService {
}
cellTemplate
.
setIsReadOnly
(
cell
.
getCellStyle
().
getLocked
()
?
1
:
0
);
cellTemplateList
.
add
(
cellTemplate
);
//todo: 这里没有Config数据只有在上传模板以后,在界面里面可以配置公式
if
(
hasKeyIn
(
cell
))
{
cell
.
setCellValue
(
StringUtils
.
EMPTY
);
addManualConfig
(
template
.
getId
(),
cellTemplateId
,
cell
,
now
,
cellTemplateConfigList
);
}
else
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
StringUtils
.
isNotBlank
(
POIUtil
.
getCellFormulaString
(
cell
)))
{
if
(
hasFormulaDatas
.
contains
(
c
)
&&
StringUtils
.
isNotBlank
(
POIUtil
.
getCellFormulaString
(
cell
)))
{
PeriodCellTemplateConfig
periodCellTemplateConfig
=
new
PeriodCellTemplateConfig
();
periodCellTemplateConfig
.
setId
(
distributedIdService
.
nextId
());
periodCellTemplateConfig
.
setPeriod
(
period
);
...
...
@@ -420,6 +428,8 @@ public class ReportServiceImpl extends BaseService {
fixedParsedFormula
(
periodCellTemplateConfig
);
fixedAccountCode
(
periodCellTemplateConfig
);
cellTemplateConfigList
.
add
(
periodCellTemplateConfig
);
}
if
(
hasHandDatas
.
contains
(
c
))
{
addManualConfig
(
template
.
getId
(),
cellTemplateId
,
cell
,
now
,
cellTemplateConfigList
);
}
}
else
{
...
...
@@ -696,8 +706,9 @@ public class ReportServiceImpl extends BaseService {
Sheet
sheet
=
tWorkbook
.
getSheetAt
(
0
);
RevenueConfigExample
example
=
new
RevenueConfigExample
();
List
<
RevenueConfig
>
dataList
=
revenueConfigMapper
.
selectByExample
(
example
);
List
<
Integer
>
unLockStyles
=
Arrays
.
asList
();
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
Project
project
=
projectMapper
.
selectByPrimaryKey
(
projectId
);
int
rowIndex
=
1
;
Row
sourceRow
=
sheet
.
getRow
(
3
);
for
(
RevenueConfig
config
:
dataList
)
{
...
...
@@ -705,11 +716,34 @@ public class ReportServiceImpl extends BaseService {
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_1
.
getIndex
()).
setCellValue
(
"1-"
+
rowIndex
);
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_3
.
getIndex
()).
setCellValue
(
config
.
getName
());
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_2
.
getIndex
()).
setCellValue
(
""
);
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_4
.
getIndex
()).
setCellValue
(
"PC(\"VAT020\",\"C\",\"增值税进项税\",\"G\")"
);
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_5
.
getIndex
()).
setCellValue
(
""
);
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_4
.
getIndex
()).
setCellValue
(
"PC(\"TimeInterval\",\"\""
);
//判断帐载收入明细
if
(
0
==
config
.
getAccountType
())
{
//0值
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_5
.
getIndex
()).
setCellValue
(
0.00
);
}
else
if
(
1
==
config
.
getAccountType
())
{
//科目
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_5
.
getIndex
()).
setCellValue
(
"DFFS(\""
+
config
.
getTbSegment3
()
+
"\","
+
project
.
getYear
()
+
","
+
period
+
","
+
1
+
",\""
+
config
.
getTbSegment5
()
+
"\",\""
+
config
.
getTbSegment6
()
+
"\")-"
+
"JFFS(\""
+
config
.
getTbSegment3
()
+
"\","
+
project
.
getYear
()
+
","
+
period
+
","
+
1
+
",\""
+
config
.
getTbSegment5
()
+
"\",\""
+
config
.
getTbSegment6
()
+
"\")"
);
}
else
if
(
2
==
config
.
getAccountType
()){
//手工输入
}
else
{
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_5
.
getIndex
()).
setCellValue
(
""
);
}
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_6
.
getIndex
()).
setCellValue
(
""
);
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_7
.
getIndex
()).
setCellValue
(
""
);
if
(
1
==
config
.
getTaxBase
())
{
//账载
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_8
.
getIndex
()).
setCellValue
(
"WPNAME(\"VAT020\",\"B\",\""
+
config
.
getName
()+
"\",\"E\")"
);
}
else
if
(
2
==
config
.
getTaxBase
())
{
//开票收入
}
else
if
(
3
==
config
.
getTaxBase
())
{
//手工录入
}
else
if
(
4
==
config
.
getTaxBase
())
{
//借方发生额
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_8
.
getIndex
()).
setCellValue
(
"JFFS(\""
+
config
.
getTbSegment3
()
+
"\","
+
project
.
getYear
()
+
","
+
period
+
","
+
1
+
",\"\",\"\")"
);
}
else
if
(
5
==
config
.
getTaxBase
())
{
//贷方发生额
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_8
.
getIndex
()).
setCellValue
(
"DFFS(\""
+
config
.
getTbSegment3
()
+
"\","
+
project
.
getYear
()
+
","
+
period
+
","
+
1
+
",\"\",\"\")"
);
}
else
{
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_8
.
getIndex
()).
setCellValue
(
""
);
}
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_8
.
getIndex
()).
setCellValue
(
"WPNAME(\"VAT020\",\"C\",\"增值税进项税\",\"G\")"
);
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_9
.
getIndex
()).
setCellValue
(
config
.
getTaxRate
().
multiply
(
new
BigDecimal
(
100
)).
intValue
()
+
"%"
);
row
.
getCell
(
TaxesCalculateReportEnum
.
Column
.
Column_10
.
getIndex
()).
setCellValue
(
0
);
...
...
@@ -1693,7 +1727,7 @@ public class ReportServiceImpl extends BaseService {
return
operationResultDto
;
}
@
Autowired
@
Resource
private
PwcReportAttachMapper
pwcReportAttachMapper
;
public
void
bindPwcAttach
(
Long
activeCol
,
Long
activeRow
,
String
activeTemplateId
,
FileDto
file
)
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/DFFS.java
View file @
9e1827ab
...
...
@@ -2,17 +2,17 @@ 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.StringUtils
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
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.common.util.DateUtils
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.constant.Constant
;
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.
*
;
import
pwc.taxtech.atms.entity.
Organization
;
import
pwc.taxtech.atms.vat.entity.*
;
import
java.math.BigDecimal
;
...
...
@@ -27,17 +27,17 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
if
(
args
.
length
<
5
)
{
if
(
args
.
length
<
6
)
{
return
null
;
}
int
type
=
getInt
Param
(
args
[
0
],
ec
);
String
code
=
getString
Param
(
args
[
1
],
ec
);
int
year
=
getIntParam
(
args
[
2
],
ec
);
int
period
=
getIntParam
(
args
[
3
],
ec
);
int
sourceDataType
=
getIntParam
(
args
[
4
],
ec
);
String
formulaExpression
=
"DFFS("
+
type
+
",\""
+
code
+
"\","
+
year
+
","
+
period
+
","
+
sourceDataType
+
")"
;
String
code
=
getString
Param
(
args
[
0
],
ec
);
int
year
=
getInt
Param
(
args
[
1
],
ec
);
int
period
=
getIntParam
(
args
[
2
],
ec
);
int
sourceDataType
=
getIntParam
(
args
[
3
],
ec
);
//科目代码
String
segment5
=
getStringParam
(
args
[
4
],
ec
);
//利润中心代码
String
segment6
=
getStringParam
(
args
[
5
],
ec
);
//产品代码
String
formulaExpression
=
"DFFS(\""
+
code
+
"\","
+
year
+
","
+
period
+
","
+
sourceDataType
+
",\""
+
segment5
+
"\",\""
+
segment6
+
"\
")"
;
logger
.
debug
(
formulaExpression
);
year
=
getYear
(
year
);
...
...
@@ -48,84 +48,54 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
year
=
year
+
yearOffset
;
List
<
ReportCellDataSourceDto
>
dataSource
=
Lists
.
newArrayList
();
if
(
type
==
0
){
EnterpriseAccountSetOrgExample
example
=
new
EnterpriseAccountSetOrgExample
();
example
.
createCriteria
().
andEffectiveDateLessThanOrEqualTo
(
DateUtils
.
getNow
()).
andExpiredDateGreaterThanOrEqualTo
(
DateUtils
.
getNow
()).
andOrganizationIdEqualTo
(
orgId
);
List
<
EnterpriseAccountSetOrg
>
enterpriseAccountSetOrgs
=
SpringContextUtil
.
enterpriseAccountSetOrgMapper
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isEmpty
(
enterpriseAccountSetOrgs
)){
return
NumberEval
.
ZERO
;
}
AccountMappingExample
accountMappingExample
=
new
AccountMappingExample
();
accountMappingExample
.
createCriteria
().
andOrganizationIdEqualTo
(
orgId
).
andEnterpriseAccountSetIdEqualTo
(
enterpriseAccountSetOrgs
.
get
(
0
).
getEnterpriseAccountSetId
()).
andStandardAccountCodeEqualTo
(
code
);
List
<
AccountMapping
>
accountMappings
=
SpringContextUtil
.
accountMappingMapper
.
selectByExample
(
accountMappingExample
);
double
result
=
0
;
for
(
AccountMapping
a
:
accountMappings
){
if
(
sourceDataType
==
1
){
result
+=
countForTrialBalance
(
a
.
getEnterpriseAccountCode
(),
dataSource
,
period
,
year
,
orgId
);
}
else
if
(
sourceDataType
==
2
){
result
+=
countForAdjBalance
(
a
.
getEnterpriseAccountCode
(),
dataSource
,
period
,
year
,
orgId
);
}
else
if
(
sourceDataType
==
3
){
result
+=
countForTrialFinalBalance
(
a
.
getEnterpriseAccountCode
(),
dataSource
,
period
,
year
,
orgId
);
}
else
{
return
NumberEval
.
ZERO
;
}
}
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
new
BigDecimal
(
result
),
period
,
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
result
),
dataSoureId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
result
);
}
else
if
(
type
==
1
){
double
result
=
0.00
;
if
(
sourceDataType
==
1
){
result
=
countForTrialBalance
(
code
,
dataSource
,
period
,
year
,
orgId
);
}
else
if
(
sourceDataType
==
2
){
result
=
countForAdjBalance
(
code
,
dataSource
,
period
,
year
,
orgId
);
}
else
if
(
sourceDataType
==
3
){
result
=
countForTrialFinalBalance
(
code
,
dataSource
,
period
,
year
,
orgId
);
}
else
{
return
NumberEval
.
ZERO
;
}
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
new
BigDecimal
(
result
),
period
,
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
result
),
dataSoureId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
result
);
}
return
NumberEval
.
ZERO
;
double
result
=
0.00
;
if
(
sourceDataType
==
1
)
{
result
=
countForTrialBalance
(
code
,
dataSource
,
period
,
year
,
orgId
,
segment5
,
segment6
);
}
else
if
(
sourceDataType
==
2
)
{
result
=
countForAdjBalance
(
code
,
dataSource
,
period
,
year
,
orgId
,
segment5
,
segment6
);
}
else
if
(
sourceDataType
==
3
)
{
result
=
countForTrialFinalBalance
(
code
,
dataSource
,
period
,
year
,
orgId
,
segment5
,
segment6
);
}
else
{
return
NumberEval
.
ZERO
;
}
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
new
BigDecimal
(
result
),
period
,
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
result
),
dataSoureId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
result
);
}
private
int
pardePeriod
(
int
period
,
int
year
){
return
Integer
.
parseInt
(
""
+
year
+
(
period
>
9
?
period
:
(
"0"
+
period
)));
private
int
pardePeriod
(
int
period
,
int
year
)
{
return
Integer
.
parseInt
(
""
+
year
+
(
period
>
9
?
period
:
(
"0"
+
period
)));
}
private
double
countForTrialBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
)
{
private
double
countForTrialBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
,
String
segment5
,
String
segment6
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
TrialBalanceExample
glBalanceExample
=
new
TrialBalanceExample
();
TrialBalanceExample
.
Criteria
c1
=
glBalanceExample
.
createCriteria
().
andSegment3EqualTo
(
code
)
.
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
TrialBalanceExample
.
Criteria
c2
=
glBalanceExample
.
createCriteria
().
andSegment4EqualTo
(
code
)
.
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
if
(
organization
!=
null
){
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
c2
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
glBalanceExample
.
or
(
c2
);
if
(
StringUtils
.
isNotBlank
(
segment5
)){
c1
.
andSegment5EqualTo
(
segment5
);
}
if
(
StringUtils
.
isNotBlank
(
segment6
)){
c1
.
andSegment5EqualTo
(
segment6
);
}
List
<
TrialBalance
>
list
=
SpringContextUtil
.
trialBalanceMapper
.
selectByExample
(
glBalanceExample
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
0.0
;
}
List
<
TrialBalance
>
temp
=
list
.
stream
().
filter
(
x
->
code
.
equalsIgnoreCase
(
x
.
getSegment3
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
temp
=
list
;
}
for
(
TrialBalance
balance
:
temp
)
{
for
(
TrialBalance
balance
:
temp
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
setAmount
(
balance
.
getPeriodCr
());
dto
.
setPeriod
(
period
);
...
...
@@ -136,28 +106,31 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
}
return
temp
.
stream
().
mapToDouble
(
a
->
a
.
getPeriodCr
().
doubleValue
()).
sum
();
}
private
double
countForAdjBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
){
private
double
countForAdjBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
,
String
segment5
,
String
segment6
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
AdjustmentTableExample
glBalanceExample
=
new
AdjustmentTableExample
();
AdjustmentTableExample
.
Criteria
c1
=
glBalanceExample
.
createCriteria
().
andSegment3EqualTo
(
code
)
.
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
AdjustmentTableExample
.
Criteria
c2
=
glBalanceExample
.
createCriteria
().
andSegment4EqualTo
(
code
)
.
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
if
(
organization
!=
null
){
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
c2
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
glBalanceExample
.
or
(
c2
);
if
(
StringUtils
.
isNotBlank
(
segment5
)){
c1
.
andSegment5EqualTo
(
segment5
);
}
if
(
StringUtils
.
isNotBlank
(
segment6
)){
c1
.
andSegment5EqualTo
(
segment6
);
}
List
<
AdjustmentTable
>
list
=
SpringContextUtil
.
adjustmentTableMapper
.
selectByExample
(
glBalanceExample
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
0.0
;
}
List
<
AdjustmentTable
>
temp
=
list
.
stream
().
filter
(
x
->
code
.
equalsIgnoreCase
(
x
.
getSegment3
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
temp
=
list
;
}
for
(
AdjustmentTable
balance
:
temp
)
{
for
(
AdjustmentTable
balance
:
temp
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
setAmount
(
balance
.
getPeriodCrBeq
());
dto
.
setPeriod
(
period
);
...
...
@@ -168,28 +141,31 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
}
return
temp
.
stream
().
mapToDouble
(
a
->
a
.
getPeriodCrBeq
().
doubleValue
()).
sum
();
}
private
double
countForTrialFinalBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
){
private
double
countForTrialFinalBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
,
String
segment5
,
String
segment6
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
TrialBalanceFinalExample
glBalanceExample
=
new
TrialBalanceFinalExample
();
TrialBalanceFinalExample
.
Criteria
c1
=
glBalanceExample
.
createCriteria
().
andSegment3EqualTo
(
code
)
.
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
TrialBalanceFinalExample
.
Criteria
c2
=
glBalanceExample
.
createCriteria
().
andSegment4EqualTo
(
code
)
.
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
if
(
organization
!=
null
){
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
c2
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
glBalanceExample
.
or
(
c2
);
if
(
StringUtils
.
isNotBlank
(
segment5
)){
c1
.
andSegment5EqualTo
(
segment5
);
}
if
(
StringUtils
.
isNotBlank
(
segment6
)){
c1
.
andSegment5EqualTo
(
segment6
);
}
List
<
TrialBalanceFinal
>
list
=
SpringContextUtil
.
trialBalanceFinalMapper
.
selectByExample
(
glBalanceExample
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
0.0
;
}
List
<
TrialBalanceFinal
>
temp
=
list
.
stream
().
filter
(
x
->
code
.
equalsIgnoreCase
(
x
.
getSegment3
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
temp
=
list
;
}
for
(
TrialBalanceFinal
balance
:
temp
)
{
for
(
TrialBalanceFinal
balance
:
temp
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
setAmount
(
balance
.
getPeriodCr
());
dto
.
setPeriod
(
period
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/JFFS.java
View file @
9e1827ab
...
...
@@ -2,17 +2,17 @@ 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.StringUtils
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
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.common.util.DateUtils
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.constant.Constant
;
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.
*
;
import
pwc.taxtech.atms.entity.
Organization
;
import
pwc.taxtech.atms.vat.entity.*
;
import
java.math.BigDecimal
;
...
...
@@ -27,17 +27,17 @@ public class JFFS extends FunctionBase implements FreeRefFunction {
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
if
(
args
.
length
<
5
)
{
if
(
args
.
length
<
6
)
{
return
null
;
}
int
type
=
getInt
Param
(
args
[
0
],
ec
);
String
code
=
getString
Param
(
args
[
1
],
ec
);
int
year
=
getIntParam
(
args
[
2
],
ec
);
int
period
=
getIntParam
(
args
[
3
],
ec
);
int
sourceDataType
=
getIntParam
(
args
[
4
],
ec
);
String
formulaExpression
=
"JFFS("
+
type
+
",\""
+
code
+
"\","
+
year
+
","
+
period
+
","
+
sourceDataType
+
")"
;
String
code
=
getString
Param
(
args
[
0
],
ec
);
int
year
=
getInt
Param
(
args
[
1
],
ec
);
int
period
=
getIntParam
(
args
[
2
],
ec
);
int
sourceDataType
=
getIntParam
(
args
[
3
],
ec
);
//科目代码
String
segment5
=
getStringParam
(
args
[
4
],
ec
);
//利润中心代码
String
segment6
=
getStringParam
(
args
[
5
],
ec
);
//产品代码
String
formulaExpression
=
"JFFS(\""
+
code
+
"\","
+
year
+
","
+
period
+
","
+
sourceDataType
+
",\""
+
segment5
+
"\",\""
+
segment6
+
"\
")"
;
logger
.
debug
(
formulaExpression
);
year
=
getYear
(
year
);
...
...
@@ -48,149 +48,126 @@ public class JFFS extends FunctionBase implements FreeRefFunction {
year
=
year
+
yearOffset
;
List
<
ReportCellDataSourceDto
>
dataSource
=
Lists
.
newArrayList
();
if
(
type
==
0
){
EnterpriseAccountSetOrgExample
example
=
new
EnterpriseAccountSetOrgExample
();
example
.
createCriteria
().
andEffectiveDateLessThanOrEqualTo
(
DateUtils
.
getNow
()).
andExpiredDateGreaterThanOrEqualTo
(
DateUtils
.
getNow
()).
andOrganizationIdEqualTo
(
orgId
);
List
<
EnterpriseAccountSetOrg
>
enterpriseAccountSetOrgs
=
SpringContextUtil
.
enterpriseAccountSetOrgMapper
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isEmpty
(
enterpriseAccountSetOrgs
)){
return
NumberEval
.
ZERO
;
}
AccountMappingExample
accountMappingExample
=
new
AccountMappingExample
();
accountMappingExample
.
createCriteria
().
andOrganizationIdEqualTo
(
orgId
)
.
andEnterpriseAccountSetIdEqualTo
(
enterpriseAccountSetOrgs
.
get
(
0
).
getEnterpriseAccountSetId
())
.
andStandardAccountCodeEqualTo
(
code
);
List
<
AccountMapping
>
accountMappings
=
SpringContextUtil
.
accountMappingMapper
.
selectByExample
(
accountMappingExample
);
double
result
=
0
;
for
(
AccountMapping
a
:
accountMappings
){
if
(
sourceDataType
==
1
){
result
+=
countForTrialBalance
(
a
.
getEnterpriseAccountCode
(),
dataSource
,
period
,
year
,
orgId
);
}
else
if
(
sourceDataType
==
2
){
result
+=
countForAdjBalance
(
a
.
getEnterpriseAccountCode
(),
dataSource
,
period
,
year
,
orgId
);
}
else
if
(
sourceDataType
==
3
){
result
+=
countForTrialFinalBalance
(
a
.
getEnterpriseAccountCode
(),
dataSource
,
period
,
year
,
orgId
);
}
else
{
return
NumberEval
.
ZERO
;
}
}
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
new
BigDecimal
(
result
),
period
,
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
result
),
dataSoureId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
result
);
}
else
if
(
type
==
1
){
double
result
=
0.00
;
if
(
sourceDataType
==
1
){
result
=
countForTrialBalance
(
code
,
dataSource
,
period
,
year
,
orgId
);
}
else
if
(
sourceDataType
==
2
){
result
=
countForAdjBalance
(
code
,
dataSource
,
period
,
year
,
orgId
);
}
else
if
(
sourceDataType
==
3
){
result
=
countForTrialFinalBalance
(
code
,
dataSource
,
period
,
year
,
orgId
);
}
else
{
return
NumberEval
.
ZERO
;
}
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
new
BigDecimal
(
result
),
period
,
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
result
),
dataSoureId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
result
);
}
return
NumberEval
.
ZERO
;
double
result
=
0.00
;
if
(
sourceDataType
==
1
)
{
result
=
countForTrialBalance
(
code
,
dataSource
,
period
,
year
,
orgId
,
segment5
,
segment6
);
}
else
if
(
sourceDataType
==
2
)
{
result
=
countForAdjBalance
(
code
,
dataSource
,
period
,
year
,
orgId
,
segment5
,
segment6
);
}
else
if
(
sourceDataType
==
3
)
{
result
=
countForTrialFinalBalance
(
code
,
dataSource
,
period
,
year
,
orgId
,
segment5
,
segment6
);
}
else
{
return
NumberEval
.
ZERO
;
}
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
new
BigDecimal
(
result
),
period
,
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
());
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
result
),
dataSoureId
,
formulaContext
.
getProjectId
());
return
new
NumberEval
(
result
);
}
private
int
pardePeriod
(
int
period
,
int
year
){
return
Integer
.
parseInt
(
""
+
year
+
(
period
>
9
?
period
:
(
"0"
+
period
)));
private
int
pardePeriod
(
int
period
,
int
year
)
{
return
Integer
.
parseInt
(
""
+
year
+
(
period
>
9
?
period
:
(
"0"
+
period
)));
}
private
double
countForTrialBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
)
{
private
double
countForTrialBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
,
String
segment5
,
String
segment6
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
TrialBalanceExample
example
=
new
TrialBalanceExample
();
TrialBalanceExample
.
Criteria
c1
=
example
.
createCriteria
().
andSegment3EqualTo
(
code
).
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
TrialBalanceExample
.
Criteria
c2
=
example
.
createCriteria
().
andSegment4EqualTo
(
code
).
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
if
(
organization
!=
null
){
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
c2
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
example
.
or
(
c2
);
if
(
StringUtils
.
isNotBlank
(
segment5
)){
c1
.
andSegment5EqualTo
(
segment5
);
}
if
(
StringUtils
.
isNotBlank
(
segment6
)){
c1
.
andSegment5EqualTo
(
segment6
);
}
List
<
TrialBalance
>
list
=
SpringContextUtil
.
trialBalanceMapper
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
0.0
;
}
List
<
TrialBalance
>
temp
=
list
.
stream
().
filter
(
x
->
code
.
equalsIgnoreCase
(
x
.
getSegment3
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
temp
=
list
;
}
for
(
TrialBalance
balance
:
temp
)
{
for
(
TrialBalance
balance
:
temp
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
setAmount
(
balance
.
getPeriodDr
());
dto
.
setPeriod
(
period
);
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
contain
.
add
(
dto
);
}
return
temp
.
stream
().
mapToDouble
(
a
->
a
.
getPeriodDr
().
doubleValue
()).
sum
();
}
private
double
countForAdjBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
){
private
double
countForAdjBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
,
String
segment5
,
String
segment6
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
AdjustmentTableExample
example
=
new
AdjustmentTableExample
();
AdjustmentTableExample
.
Criteria
c1
=
example
.
createCriteria
().
andSegment3EqualTo
(
code
).
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
AdjustmentTableExample
.
Criteria
c2
=
example
.
createCriteria
().
andSegment4EqualTo
(
code
).
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
if
(
organization
!=
null
){
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
c2
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
example
.
or
(
c2
);
if
(
StringUtils
.
isNotBlank
(
segment5
)){
c1
.
andSegment5EqualTo
(
segment5
);
}
if
(
StringUtils
.
isNotBlank
(
segment6
)){
c1
.
andSegment5EqualTo
(
segment6
);
}
List
<
AdjustmentTable
>
list
=
SpringContextUtil
.
adjustmentTableMapper
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
0.0
;
}
List
<
AdjustmentTable
>
temp
=
list
.
stream
().
filter
(
x
->
code
.
equalsIgnoreCase
(
x
.
getSegment3
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
temp
=
list
;
}
for
(
AdjustmentTable
balance
:
temp
)
{
for
(
AdjustmentTable
balance
:
temp
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
setAmount
(
balance
.
getPeriodDrBeq
());
dto
.
setPeriod
(
period
);
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
contain
.
add
(
dto
);
}
return
temp
.
stream
().
mapToDouble
(
a
->
a
.
getPeriodDrBeq
().
doubleValue
()).
sum
();
}
private
double
countForTrialFinalBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
){
private
double
countForTrialFinalBalance
(
String
code
,
List
<
ReportCellDataSourceDto
>
contain
,
int
period
,
int
year
,
String
orgId
,
String
segment5
,
String
segment6
)
{
Organization
organization
=
SpringContextUtil
.
organizationMapper
.
selectByPrimaryKey
(
orgId
);
TrialBalanceFinalExample
example
=
new
TrialBalanceFinalExample
();
TrialBalanceFinalExample
.
Criteria
c1
=
example
.
createCriteria
().
andSegment3EqualTo
(
code
).
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
TrialBalanceFinalExample
.
Criteria
c2
=
example
.
createCriteria
().
andSegment4EqualTo
(
code
).
andPeriodEqualTo
(
pardePeriod
(
period
,
year
));
if
(
organization
!=
null
){
if
(
organization
!=
null
)
{
c1
.
andOrganizationIdEqualTo
(
organization
.
getId
());
c2
.
andOrganizationIdEqualTo
(
organization
.
getId
());
}
example
.
or
(
c2
);
if
(
StringUtils
.
isNotBlank
(
segment5
)){
c1
.
andSegment5EqualTo
(
segment5
);
}
if
(
StringUtils
.
isNotBlank
(
segment6
)){
c1
.
andSegment5EqualTo
(
segment6
);
}
List
<
TrialBalanceFinal
>
list
=
SpringContextUtil
.
trialBalanceFinalMapper
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
0.0
;
}
List
<
TrialBalanceFinal
>
temp
=
list
.
stream
().
filter
(
x
->
code
.
equalsIgnoreCase
(
x
.
getSegment3
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
if
(
CollectionUtils
.
isEmpty
(
temp
))
{
temp
=
list
;
}
for
(
TrialBalanceFinal
balance
:
temp
)
{
for
(
TrialBalanceFinal
balance
:
temp
)
{
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
setAmount
(
balance
.
getPeriodDr
());
dto
.
setPeriod
(
period
);
dto
.
setIsOnlyManualInput
(
Boolean
.
FALSE
);
dto
.
setName
(
Constant
.
DataSourceName
.
ReportDataSource
);
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
dto
.
setType
(
FormulaDataSourceType
.
TrialBalanceSource
.
getCode
());
contain
.
add
(
dto
);
}
return
temp
.
stream
().
mapToDouble
(
a
->
a
.
getPeriodDr
().
doubleValue
()).
sum
();
...
...
atms-dao/src/main/java/pwc/taxtech/atms/dao/TaxDocumentMapper.java
View file @
9e1827ab
...
...
@@ -41,7 +41,7 @@ public interface TaxDocumentMapper extends MyMapper {
*
* @mbg.generated
*/
Long
insert
(
TaxDocument
record
);
int
insert
(
TaxDocument
record
);
/**
* This method was generated by MyBatis Generator.
...
...
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