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
b44044d9
Commit
b44044d9
authored
Mar 30, 2019
by
CN\Frank XA Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add report validation function code --frank
parent
6b940574
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
188 additions
and
7 deletions
+188
-7
CellDataDto.java
...rc/main/java/pwc/taxtech/atms/dto/vatdto/CellDataDto.java
+10
-0
CitReportServiceImpl.java
...a/pwc/taxtech/atms/service/impl/CitReportServiceImpl.java
+98
-3
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+1
-1
ReportServiceImpl.java
.../pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
+0
-0
PeriodCellTemplateConfigDto.java
...pwc/taxtech/atms/vat/dpo/PeriodCellTemplateConfigDto.java
+76
-0
spread-js-tip.svc.js
.../src/main/webapp/app/common/services/spread-js-tip.svc.js
+3
-3
No files found.
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/CellDataDto.java
View file @
b44044d9
...
@@ -60,6 +60,8 @@ public class CellDataDto {
...
@@ -60,6 +60,8 @@ public class CellDataDto {
private
Boolean
isConfigured
;
private
Boolean
isConfigured
;
private
String
validationResult
;
public
String
getCellId
()
{
public
String
getCellId
()
{
return
this
.
cellId
;
return
this
.
cellId
;
}
}
...
@@ -259,4 +261,12 @@ public class CellDataDto {
...
@@ -259,4 +261,12 @@ public class CellDataDto {
public
void
setIsConfigured
(
Boolean
configured
)
{
public
void
setIsConfigured
(
Boolean
configured
)
{
this
.
isConfigured
=
configured
;
this
.
isConfigured
=
configured
;
}
}
public
String
getValidationResult
()
{
return
validationResult
;
}
public
void
setValidationResult
(
String
validationResult
)
{
this
.
validationResult
=
validationResult
;
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/CitReportServiceImpl.java
View file @
b44044d9
...
@@ -9,8 +9,10 @@ import com.google.common.collect.Sets;
...
@@ -9,8 +9,10 @@ import com.google.common.collect.Sets;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.map.HashedMap
;
import
org.apache.commons.collections.map.HashedMap
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
...
@@ -25,7 +27,9 @@ import pwc.taxtech.atms.constant.Constant;
...
@@ -25,7 +27,9 @@ import pwc.taxtech.atms.constant.Constant;
import
pwc.taxtech.atms.constant.enums.*
;
import
pwc.taxtech.atms.constant.enums.*
;
import
pwc.taxtech.atms.dao.*
;
import
pwc.taxtech.atms.dao.*
;
import
pwc.taxtech.atms.dpo.ReportDto
;
import
pwc.taxtech.atms.dpo.ReportDto
;
import
pwc.taxtech.atms.dto.*
;
import
pwc.taxtech.atms.dto.CitAssetsListDto
;
import
pwc.taxtech.atms.dto.CitDistributionDto
;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.dto.export.ExportDto
;
import
pwc.taxtech.atms.dto.export.ExportDto
;
import
pwc.taxtech.atms.dto.vatdto.*
;
import
pwc.taxtech.atms.dto.vatdto.*
;
import
pwc.taxtech.atms.entity.*
;
import
pwc.taxtech.atms.entity.*
;
...
@@ -35,6 +39,7 @@ import pwc.taxtech.atms.vat.dao.*;
...
@@ -35,6 +39,7 @@ import pwc.taxtech.atms.vat.dao.*;
import
pwc.taxtech.atms.vat.dpo.DataSourceCellDataDto
;
import
pwc.taxtech.atms.vat.dpo.DataSourceCellDataDto
;
import
pwc.taxtech.atms.vat.dpo.DataSourceExtendDto
;
import
pwc.taxtech.atms.vat.dpo.DataSourceExtendDto
;
import
pwc.taxtech.atms.vat.dpo.InputVATInvoiceItemExtendDto
;
import
pwc.taxtech.atms.vat.dpo.InputVATInvoiceItemExtendDto
;
import
pwc.taxtech.atms.vat.dpo.PeriodCellTemplateConfigDto
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.service.impl.ReportGeneratorImpl
;
import
pwc.taxtech.atms.vat.service.impl.ReportGeneratorImpl
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper
;
...
@@ -219,6 +224,60 @@ public class CitReportServiceImpl extends BaseService {
...
@@ -219,6 +224,60 @@ public class CitReportServiceImpl extends BaseService {
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
reportGenerator
.
updateWorkbookCaclsValueToDb
(
projectId
,
periodParam
,
workbook
,
resources
,
isMergeManualData
,
genJob
);
reportGenerator
.
updateWorkbookCaclsValueToDb
(
projectId
,
periodParam
,
workbook
,
resources
,
isMergeManualData
,
genJob
);
//===============================================start validation compute==========================================================
//todo: 1.get the data from workbook, then put the data into new workbook
Workbook
workbook4Validate
=
reportGenerator
.
createWorkBookByPeriodTemplate
(
resources
.
getPeriodTemplates
(),
genJob
);
copyDataToWorkbook4Validate
(
workbook
,
workbook4Validate
);
//todo: 2.get the validate formula in the cell_template_config
List
<
PeriodCellTemplateConfig
>
periodCellTemplateConfigs
=
resources
.
getPeriodCellTemplateConfigs
().
stream
()
.
filter
(
a
->
a
.
getDataSourceType
().
equals
(
CellDataSourceType
.
Validation
.
getCode
())).
collect
(
Collectors
.
toList
());
List
<
PeriodCellTemplateConfigDto
>
periodCellTemplateConfigDtos
=
new
ArrayList
<>();
periodCellTemplateConfigs
.
forEach
(
a
->
{
if
(
StringUtils
.
isNotBlank
(
a
.
getValidation
()))
{
Optional
<
Template
>
template
=
templates
.
stream
().
filter
(
t
->
t
.
getId
().
equals
(
a
.
getReportTemplateId
())).
findFirst
();
String
templateCode
=
template
.
isPresent
()
?
template
.
get
().
getCode
()
:
""
;
Integer
sheetNumber
=
template
.
isPresent
()
?
template
.
get
().
getOrderIndex
()
:
null
;
Optional
<
PeriodCellTemplate
>
periodCellTemplate
=
resources
.
getPeriodCellTemplates
().
stream
().
filter
(
c
->
c
.
getCellTemplateId
().
equals
(
a
.
getCellTemplateId
())).
findFirst
();
Integer
rowNumber
=
periodCellTemplate
.
isPresent
()
?
periodCellTemplate
.
get
().
getRowIndex
()
:
null
;
Integer
colNumber
=
periodCellTemplate
.
isPresent
()
?
periodCellTemplate
.
get
().
getColumnIndex
()
:
null
;
if
(
StringUtils
.
isNotBlank
(
templateCode
)
&&
rowNumber
!=
null
&&
colNumber
!=
null
)
{
String
replaceFormula
=
String
.
format
(
"BB(\"%s\",%d,%d,0,0)"
,
templateCode
,
colNumber
,
rowNumber
);
a
.
setParsedValidation
(
a
.
getValidation
().
replace
(
"aa()"
,
replaceFormula
));
PeriodCellTemplateConfigDto
periodCellTemplateConfigDto
=
new
PeriodCellTemplateConfigDto
();
periodCellTemplateConfigDto
.
setSheetNumber
(
sheetNumber
);
periodCellTemplateConfigDto
.
setRowNumber
(
rowNumber
);
periodCellTemplateConfigDto
.
setColNumber
(
colNumber
);
periodCellTemplateConfigDto
.
setValidation
(
a
.
getValidation
());
periodCellTemplateConfigDto
.
setParsedValidation
(
a
.
getParsedValidation
());
periodCellTemplateConfigDto
.
setCellTemplateId
(
periodCellTemplate
.
get
().
getCellTemplateId
());
periodCellTemplateConfigDto
.
setProjectId
(
projectId
);
periodCellTemplateConfigDto
.
setPeriodParam
(
periodParam
);
periodCellTemplateConfigDtos
.
add
(
periodCellTemplateConfigDto
);
}
}
});
//todo: 3.use the validate formula to recalculate the new workbook
periodCellTemplateConfigDtos
.
forEach
(
a
->
{
workbook4Validate
.
getSheetAt
(
a
.
getSheetNumber
()
-
1
).
getRow
(
a
.
getRowNumber
()).
getCell
(
a
.
getColNumber
()).
setCellFormula
(
a
.
getParsedValidation
());
});
reportGenerator
.
addFunctionsAndContext
(
workbook4Validate
,
functions
,
reportGenerator
.
initContext
(
resources
,
periodParam
));
FormulaEvaluator
validateEvaluator
=
workbook4Validate
.
getCreationHelper
().
createFormulaEvaluator
();
validateEvaluator
.
evaluateAll
();
//todo: 4.then save the validation result to cellData table
periodCellTemplateConfigDtos
.
forEach
(
a
->
{
//todo: according to periodParam , projectId, cellTemplateId to update the cellData table
PeriodCellDataExample
periodCellDataExample
=
new
PeriodCellDataExample
();
periodCellDataExample
.
createCriteria
().
andCellTemplateIdEqualTo
(
a
.
getCellTemplateId
()).
andProjectIdEqualTo
(
a
.
getProjectId
()).
andPeriodEqualTo
(
a
.
getPeriodParam
());
Optional
<
PeriodCellData
>
cellData
=
periodCellDataMapper
.
selectByExample
(
periodCellDataExample
).
stream
().
findFirst
();
if
(
cellData
.
isPresent
())
{
cellData
.
get
().
setValidateFormulaExp
(
a
.
getParsedValidation
());
Boolean
result
=
workbook4Validate
.
getSheetAt
(
a
.
getSheetNumber
()
-
1
).
getRow
(
a
.
getRowNumber
()).
getCell
(
a
.
getColNumber
()).
getBooleanCellValue
();
cellData
.
get
().
setValidateResult
(
result
.
toString
());
periodCellDataMapper
.
updateByPrimaryKey
(
cellData
.
get
());
}
});
//===============================================end validation compute==============================================================
setStatus
(
genJob
,
STATUS_END
);
setStatus
(
genJob
,
STATUS_END
);
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
periodJobMapper
.
updateByPrimaryKey
(
genJob
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -239,6 +298,42 @@ public class CitReportServiceImpl extends BaseService {
...
@@ -239,6 +298,42 @@ public class CitReportServiceImpl extends BaseService {
return
operationResultDto
;
return
operationResultDto
;
}
}
private
void
copyDataToWorkbook4Validate
(
Workbook
workbook
,
Workbook
workbook4Validate
)
{
int
sheetNumber
=
workbook
.
getNumberOfSheets
();
for
(
int
i
=
0
;
i
<
sheetNumber
;
i
++)
{
Sheet
sheet
=
workbook
.
getSheetAt
(
i
);
for
(
Row
row
:
sheet
)
{
for
(
Cell
cell
:
row
)
{
String
data
;
String
result
;
data
=
((
XSSFCell
)
cell
).
getRawValue
();
if
(
data
!=
null
&&
data
.
equals
(
"#VALUE!"
))
{
FormulaEvaluator
formulaEvaluator
=
new
XSSFFormulaEvaluator
((
XSSFWorkbook
)
workbook
);
try
{
data
=
formulaEvaluator
.
evaluate
(
cell
).
getStringValue
();
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getStackTrace
().
toString
());
data
=
"0.0"
;
}
}
if
(
StringUtils
.
isNotBlank
(
data
))
{
Pattern
pattern
=
Pattern
.
compile
(
"[0-9.]*"
);
Matcher
isNum
=
pattern
.
matcher
(
data
);
if
(
isNum
.
matches
())
{
result
=
new
BigDecimal
(
data
).
toString
();
}
else
{
result
=
data
;
}
}
else
{
result
=
data
;
}
workbook4Validate
.
getSheetAt
(
i
).
getRow
(
row
.
getRowNum
()).
getCell
(
cell
.
getColumnIndex
()).
setCellValue
(
result
);
}
}
}
}
/**
/**
* 根据projectId(卡片ID)获取模板
* 根据projectId(卡片ID)获取模板
*
*
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
b44044d9
...
@@ -313,7 +313,7 @@ public class ReportGeneratorImpl {
...
@@ -313,7 +313,7 @@ public class ReportGeneratorImpl {
cellDataSource
.
setPeriod
(
period
);
cellDataSource
.
setPeriod
(
period
);
cellDataSource
.
setProjectId
(
projectId
);
cellDataSource
.
setProjectId
(
projectId
);
SpringContextUtil
.
periodCellDataSourceMapper
.
insertSelective
(
cellDataSource
);
SpringContextUtil
.
periodCellDataSourceMapper
.
insertSelective
(
cellDataSource
);
periodCellDataMapper
.
insert
(
cellData
);
periodCellDataMapper
.
insert
Selective
(
cellData
);
}
else
{
}
else
{
logger
.
warn
(
"should not be !!!"
);
logger
.
warn
(
"should not be !!!"
);
}
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
View file @
b44044d9
This diff is collapsed.
Click to expand it.
atms-dao/src/main/java/pwc/taxtech/atms/vat/dpo/PeriodCellTemplateConfigDto.java
0 → 100644
View file @
b44044d9
package
pwc
.
taxtech
.
atms
.
vat
.
dpo
;
public
class
PeriodCellTemplateConfigDto
{
private
String
validation
;
private
String
parsedValidation
;
private
Integer
sheetNumber
;
private
Integer
rowNumber
;
private
Integer
colNumber
;
private
Long
cellTemplateId
;
private
String
projectId
;
private
Integer
periodParam
;
public
String
getValidation
()
{
return
validation
;
}
public
void
setValidation
(
String
validation
)
{
this
.
validation
=
validation
;
}
public
String
getParsedValidation
()
{
return
parsedValidation
;
}
public
void
setParsedValidation
(
String
parsedValidation
)
{
this
.
parsedValidation
=
parsedValidation
;
}
public
Integer
getSheetNumber
()
{
return
sheetNumber
;
}
public
void
setSheetNumber
(
Integer
sheetNumber
)
{
this
.
sheetNumber
=
sheetNumber
;
}
public
Integer
getRowNumber
()
{
return
rowNumber
;
}
public
void
setRowNumber
(
Integer
rowNumber
)
{
this
.
rowNumber
=
rowNumber
;
}
public
Integer
getColNumber
()
{
return
colNumber
;
}
public
void
setColNumber
(
Integer
colNumber
)
{
this
.
colNumber
=
colNumber
;
}
public
Long
getCellTemplateId
()
{
return
cellTemplateId
;
}
public
void
setCellTemplateId
(
Long
cellTemplateId
)
{
this
.
cellTemplateId
=
cellTemplateId
;
}
public
String
getProjectId
()
{
return
projectId
;
}
public
void
setProjectId
(
String
projectId
)
{
this
.
projectId
=
projectId
;
}
public
Integer
getPeriodParam
()
{
return
periodParam
;
}
public
void
setPeriodParam
(
Integer
periodParam
)
{
this
.
periodParam
=
periodParam
;
}
}
atms-web/src/main/webapp/app/common/services/spread-js-tip.svc.js
View file @
b44044d9
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
exceptionMsg
=
$translate
.
instant
(
'ModelException'
);
exceptionMsg
=
$translate
.
instant
(
'ModelException'
);
}
}
if
(
!
_
.
isEmpty
(
cellData
.
validation
ErrorLis
t
))
{
if
(
!
_
.
isEmpty
(
cellData
.
validation
Resul
t
))
{
hasException
=
true
;
hasException
=
true
;
if
(
_
.
isEmpty
(
exceptionMsg
))
{
if
(
_
.
isEmpty
(
exceptionMsg
))
{
exceptionMsg
=
$translate
.
instant
(
'ValidationException'
);
exceptionMsg
=
$translate
.
instant
(
'ValidationException'
);
...
@@ -94,13 +94,13 @@
...
@@ -94,13 +94,13 @@
}
}
if
(
hasException
)
{
if
(
hasException
)
{
cell
.
value
(
cell
.
text
()
+
' '
);
// Edmond TODO: Temp move cell value for CIT demo
//
cell.value(cell.text() + ' '); // Edmond TODO: Temp move cell value for CIT demo
icons
.
push
(
hasExceptionImg
);
icons
.
push
(
hasExceptionImg
);
infos
.
push
(
exceptionMsg
);
infos
.
push
(
exceptionMsg
);
}
}
try
{
try
{
cell
.
cellType
(
new
IconsCellType
(
icons
,
infos
,
tips
));
cell
.
cellType
(
new
IconsCellType
(
icons
,
infos
,
tips
))
.
hAlign
(
0
)
;
}
}
catch
(
e
)
{
catch
(
e
)
{
}
}
...
...
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