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
092ecc04
Commit
092ecc04
authored
Jul 06, 2018
by
neo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DEV] add aop exclude for angent mapper
parent
6edf0b16
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
46 deletions
+73
-46
CloseableFormulaDataSource.java
...c/taxtech/atms/dto/vatdto/CloseableFormulaDataSource.java
+1
-1
FormulaAgent.java
.../java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
+25
-19
ReportFormulaFactory.java
...c/taxtech/atms/vat/service/impl/ReportFormulaFactory.java
+0
-1
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+40
-21
FormulaContext.java
...tms/vat/service/impl/report/functions/FormulaContext.java
+1
-0
applicationContext.xml
atms-api/src/main/resources/applicationContext.xml
+6
-4
No files found.
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/CloseableFormulaDataSource.java
View file @
092ecc04
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
pwc.taxtech.atms.vat.service.impl.
report.functions.
FormulaAgent
;
import
pwc.taxtech.atms.vat.service.impl.FormulaAgent
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/
report/functions/
FormulaAgent.java
→
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
View file @
092ecc04
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
org.springframework.
stereotype.Service
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
org.springframework.
beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
pwc.taxtech.atms.constant.enums.EnumServiceType
;
import
pwc.taxtech.atms.dao.FormulaAdminMapper
;
import
pwc.taxtech.atms.dto.GroupId
;
import
pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.entitiy.ProjectServiceType
;
import
pwc.taxtech.atms.entitiy.ProjectServiceTypeExample
;
import
pwc.taxtech.atms.vat.dao.CellDataMapper
;
import
pwc.taxtech.atms.vat.dao.FormulaProjectMapper
;
import
pwc.taxtech.atms.vat.dao.ReportMapper
;
import
pwc.taxtech.atms.vat.entity.CellData
;
import
pwc.taxtech.atms.vat.entity.CellDataExample
;
import
pwc.taxtech.atms.vat.entity.Report
;
...
...
@@ -16,32 +20,33 @@ import java.util.List;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
FIRST_OR_DEFAULT
;
@Service
public
class
FormulaAgent
{
// @Autowired
// public FormulaAdminMapper formulaAdminMapper;
// @Autowired
// public FormulaProjectMapper projectMp;
// @Autowired
// public ReportMapper reportMapper;
// @Autowired
// public CellDataMapper cellDataMapper;
@Repository
public
class
FormulaAgent
extends
VatAbstractService
{
@Autowired
public
FormulaAdminMapper
adminMp
;
@Autowired
public
FormulaProjectMapper
projectMp
;
@Autowired
public
ReportMapper
reportMapper
;
@Autowired
public
CellDataMapper
cellDataMapper
;
public
List
<
CellTemplatePerGroupDto
>
getCellTemplateGroupDto
(
Long
templateGroupId
,
String
projectId
)
{
ProjectServiceTypeExample
pst
=
new
ProjectServiceTypeExample
();
pst
.
createCriteria
().
andTemplateGroupIDEqualTo
(
Long
.
valueOf
(
templateGroupId
))
.
andServiceTypeIDEqualTo
(
EnumServiceType
.
VAT
.
getCode
()
+
""
);
List
<
ProjectServiceType
>
pstReult
=
SpringContextUtil
.
projectServiceTypeMapper
.
selectByExample
(
pst
);
List
<
ProjectServiceType
>
pstReult
=
projectServiceTypeMapper
.
selectByExample
(
pst
);
List
<
CellTemplatePerGroupDto
>
cellTemplates
=
SpringContextUtil
.
formulaAdminMapper
.
getCellTemplatePerGroupDto
(
templateGroupId
);
List
<
CellTemplatePerGroupDto
>
cellTemplates
=
adminMp
.
getCellTemplatePerGroupDto
(
templateGroupId
);
if
(
pstReult
==
null
||
pstReult
.
isEmpty
())
{
List
<
GroupId
>
groupIds
=
SpringContextUtil
.
formulaAdminMapper
.
getTemplateGroupId
(
projectId
);
List
<
GroupId
>
groupIds
=
adminMp
.
getTemplateGroupId
(
projectId
);
GroupId
groupId
;
if
(
groupIds
.
size
()
>
0
)
{
groupId
=
groupIds
.
stream
().
filter
(
m
->
m
.
isDefault
!=
1
).
findFirst
().
get
();
if
(
groupId
==
null
)
groupId
=
groupIds
.
get
(
0
);
cellTemplates
.
addAll
(
SpringContextUtil
.
formulaAdminMapper
.
getCellTemplatePerGroupDto
(
groupId
.
groupId
));
cellTemplates
.
addAll
(
adminMp
.
getCellTemplatePerGroupDto
(
groupId
.
groupId
));
}
}
return
cellTemplates
;
...
...
@@ -51,7 +56,7 @@ public class FormulaAgent {
ReportExample
example
=
new
ReportExample
();
example
.
createCriteria
().
andTemplateIdEqualTo
(
Long
.
valueOf
(
templateId
))
.
andPeriodEqualTo
(
periodId
);
List
<
Report
>
reports
=
SpringContextUtil
.
reportMapper
.
selectByExample
(
example
);
List
<
Report
>
reports
=
reportMapper
.
selectByExample
(
example
);
if
(
reports
!=
null
||
!
reports
.
isEmpty
())
return
reports
.
get
(
FIRST_OR_DEFAULT
);
return
null
;
...
...
@@ -60,9 +65,10 @@ public class FormulaAgent {
public
CellData
getCellDataListByTemplate
(
String
templateId
,
Long
reportId
)
{
CellDataExample
dataExample
=
new
CellDataExample
();
dataExample
.
createCriteria
().
andCellTemplateIdEqualTo
(
Long
.
valueOf
(
templateId
));
List
<
CellData
>
cellDataList
=
SpringContextUtil
.
cellDataMapper
.
selectByExample
(
dataExample
);
List
<
CellData
>
cellDataList
=
cellDataMapper
.
selectByExample
(
dataExample
);
if
(
cellDataList
!=
null
||
!
cellDataList
.
isEmpty
())
return
cellDataList
.
get
(
FIRST_OR_DEFAULT
);
return
null
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportFormulaFactory.java
View file @
092ecc04
...
...
@@ -18,7 +18,6 @@ import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.entity.CellData
;
import
pwc.taxtech.atms.vat.entity.Report
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaAgent
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext
;
import
java.math.BigDecimal
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
092ecc04
...
...
@@ -6,7 +6,12 @@ import org.apache.poi.ss.formula.functions.FreeRefFunction;
import
org.apache.poi.ss.formula.udf.AggregatingUDFFinder
;
import
org.apache.poi.ss.formula.udf.DefaultUDFFinder
;
import
org.apache.poi.ss.formula.udf.UDFFinder
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.usermodel.WorkbookFactory
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -15,15 +20,33 @@ import org.springframework.stereotype.Service;
import
pwc.taxtech.atms.common.POIUtil
;
import
pwc.taxtech.atms.constant.enums.CellDataSourceType
;
import
pwc.taxtech.atms.service.impl.DistributedIDService
;
import
pwc.taxtech.atms.vat.dao.*
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.dao.CellDataMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodCellTemplateConfigMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodCellTemplateMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodTemplateMapper
;
import
pwc.taxtech.atms.vat.dao.ReportMapper
;
import
pwc.taxtech.atms.vat.entity.CellData
;
import
pwc.taxtech.atms.vat.entity.PeriodCellTemplate
;
import
pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig
;
import
pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfigExample
;
import
pwc.taxtech.atms.vat.entity.PeriodCellTemplateExample
;
import
pwc.taxtech.atms.vat.entity.PeriodTemplate
;
import
pwc.taxtech.atms.vat.entity.PeriodTemplateExample
;
import
pwc.taxtech.atms.vat.entity.Report
;
import
pwc.taxtech.atms.vat.service.ReportGenerator
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.*
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FSJZ
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.ND
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.SGSR
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -55,7 +78,7 @@ public class ReportGeneratorImpl implements ReportGenerator {
List
<
PeriodTemplate
>
periodTemplateList
=
periodTemplateMapper
.
selectByExample
(
periodTemplateExample
);
List
<
Long
>
periodTemplateIDList
=
periodTemplateList
.
stream
().
map
(
PeriodTemplate:
:
getTemplateId
).
collect
(
Collectors
.
toList
());
Long
templateGroupID
=
periodTemplateList
.
size
()
>
0
?
periodTemplateList
.
get
(
0
).
getTemplateGroupId
():
0
;
Long
templateGroupID
=
periodTemplateList
.
size
()
>
0
?
periodTemplateList
.
get
(
0
).
getTemplateGroupId
()
:
0
;
PeriodCellTemplateExample
periodCellTemplateExample
=
new
PeriodCellTemplateExample
();
periodCellTemplateExample
.
createCriteria
().
andReportTemplateIdIn
(
periodTemplateIDList
);
...
...
@@ -74,10 +97,7 @@ public class ReportGeneratorImpl implements ReportGenerator {
Workbook
newWorkbook
=
workbook
.
get
();
addFunctionsToWorkbook
(
newWorkbook
,
templateGroupID
);
addFunctionsToWorkbook
(
newWorkbook
,
templateGroupID
);
int
sheetCount
=
newWorkbook
.
getNumberOfSheets
();
for
(
int
i
=
0
;
i
<
sheetCount
;
i
++)
{
Sheet
sheet
=
newWorkbook
.
getSheetAt
(
i
);
...
...
@@ -119,7 +139,7 @@ public class ReportGeneratorImpl implements ReportGenerator {
cell
=
row
.
getCell
(
k
.
getColumnIndex
());
//todo:后面单独处理kv的公式
if
(!
v
.
getFormula
().
contains
(
"@"
))
{
if
(!
v
.
getFormula
().
contains
(
"@"
))
{
cell
.
setCellFormula
(
v
.
getFormula
());
}
});
...
...
@@ -157,17 +177,16 @@ public class ReportGeneratorImpl implements ReportGenerator {
List
<
PeriodCellTemplateConfig
>
periodCellTemplateConfigs
=
periodCellTemplateConfigList
.
stream
().
filter
(
a
->
a
.
getReportTemplateId
().
equals
(
templateID
)).
collect
(
Collectors
.
toList
());
for
(
PeriodCellTemplateConfig
periodCellTemplateConfig
:
periodCellTemplateConfigs
)
{
Optional
<
PeriodCellTemplate
>
tempPeriodCellTemplate
=
periodCellTemplateList
.
stream
().
filter
(
a
->
a
.
getCellTemplateId
().
equals
(
periodCellTemplateConfig
.
getCellTemplateId
())).
findFirst
();
if
(
tempPeriodCellTemplate
!=
null
)
{
Optional
<
PeriodCellTemplate
>
tempPeriodCellTemplate
=
periodCellTemplateList
.
stream
().
filter
(
a
->
a
.
getCellTemplateId
().
equals
(
periodCellTemplateConfig
.
getCellTemplateId
())).
findFirst
();
if
(
tempPeriodCellTemplate
!=
null
)
{
CellData
cellData
=
new
CellData
();
cellData
.
setId
(
distributedIDService
.
nextId
());
cellData
.
setReportId
(
reportID
);
cellData
.
setCellTemplateId
(
tempPeriodCellTemplate
.
get
().
getCellTemplateId
());
String
data
;
if
(
sheet
.
getRow
(
tempPeriodCellTemplate
.
get
().
getRowIndex
())!=
null
&&
sheet
.
getRow
(
tempPeriodCellTemplate
.
get
().
getRowIndex
()).
getCell
(
tempPeriodCellTemplate
.
get
().
getColumnIndex
())!=
null
){
data
=
Double
.
toString
(
sheet
.
getRow
(
tempPeriodCellTemplate
.
get
().
getRowIndex
()).
getCell
(
tempPeriodCellTemplate
.
get
().
getColumnIndex
()).
getNumericCellValue
());
}
else
{
if
(
sheet
.
getRow
(
tempPeriodCellTemplate
.
get
().
getRowIndex
())
!=
null
&&
sheet
.
getRow
(
tempPeriodCellTemplate
.
get
().
getRowIndex
()).
getCell
(
tempPeriodCellTemplate
.
get
().
getColumnIndex
())
!=
null
)
{
data
=
Double
.
toString
(
sheet
.
getRow
(
tempPeriodCellTemplate
.
get
().
getRowIndex
()).
getCell
(
tempPeriodCellTemplate
.
get
().
getColumnIndex
()).
getNumericCellValue
());
}
else
{
data
=
StringUtils
.
EMPTY
;
}
cellData
.
setData
(
data
);
...
...
@@ -236,15 +255,15 @@ public class ReportGeneratorImpl implements ReportGenerator {
*
* @param workbook 工作簿
*/
private
void
addFunctionsToWorkbook
(
Workbook
workbook
,
Long
templateGroupID
)
{
String
[]
functionNames
=
{
"SGSR"
,
"FSJZ"
,
"ND"
};
private
void
addFunctionsToWorkbook
(
Workbook
workbook
,
Long
templateGroupID
)
{
String
[]
functionNames
=
{
"SGSR"
,
"FSJZ"
,
"ND"
};
FormulaContext
formulaContext
=
new
FormulaContext
();
formulaContext
.
setFormulaAgent
(
formulaAgent
);
formulaContext
.
setPeriod
(
6
);
//todo: assign value later
formulaContext
.
setReportTemplateGroupID
(
templateGroupID
);
FreeRefFunction
[]
functionImpls
=
{
new
SGSR
(
formulaContext
),
new
FSJZ
(
formulaContext
),
new
ND
(
formulaContext
)};
FreeRefFunction
[]
functionImpls
=
{
new
SGSR
(
formulaContext
),
new
FSJZ
(
formulaContext
),
new
ND
(
formulaContext
)};
UDFFinder
udfs
=
new
DefaultUDFFinder
(
functionNames
,
functionImpls
);
UDFFinder
udfToolpack
=
new
AggregatingUDFFinder
(
udfs
);
workbook
.
addToolPack
(
udfToolpack
);
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/FormulaContext.java
View file @
092ecc04
...
...
@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl.report.functions;
import
lombok.Getter
;
import
lombok.Setter
;
import
pwc.taxtech.atms.vat.service.impl.FormulaAgent
;
@Setter
@Getter
...
...
atms-api/src/main/resources/applicationContext.xml
View file @
092ecc04
...
...
@@ -74,13 +74,14 @@
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut
id=
"txPointcut2"
expression=
"execution(public * pwc.taxtech.atms..*.*(..)) && @target(org.springframework.stereotype.Service)"
/>
<aop:config
proxy-target-class=
"true"
>
<aop:pointcut
id=
"txPointcut2"
expression=
"execution(public * pwc.taxtech.atms..*.*(..)) && @target(org.springframework.stereotype.Service)
and !execution(* pwc.taxtech.atms.vat.service.impl.FormulaAgent.*(..))"
/>
<aop:advisor
pointcut-ref=
"txPointcut2"
advice-ref=
"txAdvice"
/>
</aop:config>
<aop:aspectj-autoproxy
/>
<tx:annotation-driven
proxy-target-class=
"true"
/>
</beans>
\ No newline at end of file
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