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
e6927810
Commit
e6927810
authored
Nov 19, 2018
by
sherlock
Browse files
Options
Browse Files
Download
Plain Diff
export order
parents
3a20ec59
778416ae
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
475 additions
and
480 deletions
+475
-480
MyAsserts.java
...src/main/java/pwc/taxtech/atms/common/util/MyAsserts.java
+4
-0
Constant.java
...api/src/main/java/pwc/taxtech/atms/constant/Constant.java
+1
-0
BBParasBo.java
.../src/main/java/pwc/taxtech/atms/dto/vatdto/BBParasBo.java
+0
-14
Exceptions.java
.../src/main/java/pwc/taxtech/atms/exception/Exceptions.java
+2
-0
InputInvoiceDao.java
...c/main/java/pwc/taxtech/atms/vat/dao/InputInvoiceDao.java
+10
-11
FormulaAgent.java
.../java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
+19
-22
InputInvoiceDataImportServiceImpl.java
...s/vat/service/impl/InputInvoiceDataImportServiceImpl.java
+8
-6
OutputInvoiceServiceImpl.java
...xtech/atms/vat/service/impl/OutputInvoiceServiceImpl.java
+9
-7
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+81
-185
ReportServiceImpl.java
.../pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
+1
-1
BB.java
...wc/taxtech/atms/vat/service/impl/report/functions/BB.java
+52
-20
FunctionBase.java
.../atms/vat/service/impl/report/functions/FunctionBase.java
+0
-21
PSUM.java
.../taxtech/atms/vat/service/impl/report/functions/PSUM.java
+180
-0
DataInitTest.java
...i/src/test/java/pwc/taxtech/atms/common/DataInitTest.java
+50
-5
FormulaAdminMapper.java
...rc/main/java/pwc/taxtech/atms/dao/FormulaAdminMapper.java
+44
-25
CellDataMapper.java
...rc/main/java/pwc/taxtech/atms/vat/dao/CellDataMapper.java
+0
-19
PeriodCellDataMapper.java
...n/java/pwc/taxtech/atms/vat/dao/PeriodCellDataMapper.java
+0
-51
PCTEntity.java
.../src/main/java/pwc/taxtech/atms/vat/entity/PCTEntity.java
+0
-88
OutputInvoiceExtendsMapper.xml
...xtech/atms/invoice/extends/OutputInvoiceExtendsMapper.xml
+1
-1
restart.sh
atms-invoice/restart.sh
+0
-2
preview-trial-balance.ctrl.js
...trols/preview-trial-balance/preview-trial-balance.ctrl.js
+11
-0
vat-report-view.html
.../app/common/controls/vat-report-view/vat-report-view.html
+2
-2
No files found.
atms-api/src/main/java/pwc/taxtech/atms/common/util/MyAsserts.java
View file @
e6927810
...
...
@@ -38,6 +38,10 @@ public class MyAsserts {
if
(
obj
==
null
||
obj
.
isEmpty
())
throw
exception
;
}
public
static
void
assertNotEmpty
(
Collection
obj
,
FormulaException
exception
)
{
if
(
obj
==
null
||
obj
.
isEmpty
())
throw
exception
;
}
public
static
void
assertNotEmpty
(
Collection
obj
,
ApiException
exception
)
{
if
(
obj
==
null
||
obj
.
isEmpty
())
throw
exception
;
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/constant/Constant.java
View file @
e6927810
...
...
@@ -113,6 +113,7 @@ public final class Constant {
public
static
class
DateFormat
{
public
static
final
String
DEFAULT
=
"yyyy-MM-dd"
;
public
static
final
String
YEAR_MONTH
=
"yyyy-MM"
;
public
static
final
String
YYYYMM
=
"yyyyMM"
;
public
static
final
String
YYYY_MM_DD_HH_MM_SS
=
"yyyy-MM-dd HH:mm:ss"
;
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/BBParasBo.java
View file @
e6927810
...
...
@@ -118,20 +118,6 @@ public class BBParasBo {
return
formulaExpression
;
}
public
String
expressionData
()
{
if
(!
expressionData
.
isEmpty
())
{
StringBuilder
builder
=
new
StringBuilder
(
"PCT("
);
for
(
int
i
=
0
;
i
<
expressionData
.
size
();
i
++)
{
builder
.
append
(
expressionData
.
get
(
i
).
toString
());
if
(
i
<
expressionData
.
size
()
-
1
)
builder
.
append
(
","
);
}
builder
.
append
(
")"
);
return
builder
.
toString
();
}
return
"0"
;
}
@Override
public
String
toString
()
{
return
"BBParasBo{"
+
...
...
atms-api/src/main/java/pwc/taxtech/atms/exception/Exceptions.java
View file @
e6927810
...
...
@@ -19,4 +19,6 @@ public class Exceptions {
public
static
final
ApiException
NOT_FOUND_TEMPLATE_GROUP_EXCEPTION
=
new
NotFoundException
(
"not found template group"
);
public
static
final
ApiException
NOT_FOUND_EXCEPTION
=
new
NotFoundException
(
"not found resources"
);
public
static
final
ApiException
REPORT_IN_PROCESS_OR_AGREED_EXCEPTION
=
new
PreconditionFailedException
(
"report in approval or agreed result"
);
public
static
final
FormulaException
PROJECT_NOT_FOUND
=
new
FormulaException
(
"project not found"
);;
public
static
final
FormulaException
PSUM_CELL_TEMP_NULL
=
new
FormulaException
(
"cell template group is null or empty"
);
;
}
atms-api/src/main/java/pwc/taxtech/atms/vat/dao/InputInvoiceDao.java
View file @
e6927810
...
...
@@ -21,13 +21,12 @@ public class InputInvoiceDao {
public
List
<
InputInvoice
>
getInputInvoice
(
Integer
period
,
String
invoiceType
,
String
checkPass
,
String
scanPass
,
String
notPass
)
{
InputInvoiceExample
example
=
new
InputInvoiceExample
();
InputInvoiceExample
.
Criteria
criteria
=
example
.
createCriteria
();
// InputInvoiceExample.Criteria criteria1 = example.createCriteria();
// if(period != null)
{
//
Calendar date = Calendar.getInstance();
//
String year = String.valueOf(date.get(Calendar.YEAR));
// criteria.andRZSQEqualTo(year + "-"
+ (period > 9 ? period.toString() : "0" + period.toString()));
//
}
if
(
period
!=
null
)
{
Calendar
date
=
Calendar
.
getInstance
();
String
year
=
String
.
valueOf
(
date
.
get
(
Calendar
.
YEAR
));
criteria
.
andRZSQEqualTo
(
year
+
(
period
>
9
?
period
.
toString
()
:
"0"
+
period
.
toString
()));
}
if
(
invoiceType
!=
null
)
{
criteria
.
andFPLXEqualTo
(
String
.
valueOf
(
invoiceType
));
...
...
@@ -44,11 +43,11 @@ public class InputInvoiceDao {
// criteria1.andRZJGEqualTo(pass);
// example.or(criteria1);
}
criteria
.
andFPZTNotEqualTo
(
"1"
);
// 过滤作废状态
List
<
InputInvoice
>
list
=
inputInvoiceMapper
.
selectByExample
(
example
).
stream
().
filter
(
x
->
{
return
x
.
getRZSQ
().
endsWith
(
"-"
+
(
period
.
intValue
()
>
9
?
period
.
toString
()
:
"0"
+
period
.
toString
()));
}).
collect
(
Collectors
.
toList
());
// return inputInvoiceMapper.selectByExample(example);
return
list
;
// List<InputInvoice> list = inputInvoiceMapper.selectByExample(example).stream().filter(x -> {
// return x.getRZSQ().endsWith("-" + (period.intValue() > 9 ? period.toString() : "0" + period.toString()));
// }).collect(Collectors.toList());
return
inputInvoiceMapper
.
selectByExample
(
example
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
View file @
e6927810
...
...
@@ -8,16 +8,15 @@ import pwc.taxtech.atms.dao.FormulaAdminMapper;
import
pwc.taxtech.atms.dao.ProjectServiceTypeMapper
;
import
pwc.taxtech.atms.dpo.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dpo.GroupId
;
import
pwc.taxtech.atms.entity.Project
;
import
pwc.taxtech.atms.entity.ProjectServiceType
;
import
pwc.taxtech.atms.entity.ProjectServiceTypeExample
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.dao.CellDataMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodCellDataMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper
;
import
pwc.taxtech.atms.vat.dao.PeriodReportMapper
;
import
pwc.taxtech.atms.vat.entity.PeriodCellData
;
import
pwc.taxtech.atms.vat.entity.PeriodCellDataExample
;
import
pwc.taxtech.atms.vat.entity.PeriodReport
;
import
pwc.taxtech.atms.vat.entity.PeriodReportExample
;
import
pwc.taxtech.atms.vat.entity.*
;
import
java.util.List
;
...
...
@@ -35,25 +34,23 @@ public class FormulaAgent {
private
PeriodCellDataMapper
periodCellDataMapper
;
@Autowired
private
ProjectServiceTypeMapper
projectServiceTypeMapper
;
@Autowired
private
PeriodDataSourceMapper
periodDataSourceMapper
;
public
List
<
CellTemplatePerGroupDto
>
getCellTemplateGroupDto
(
Long
templateGroupId
,
String
projectId
,
String
code
,
Integer
rowIndex
,
Integer
columnIndex
,
Integer
period
)
{
return
adminMp
.
getCellTemplatePerGroupDto
(
templateGroupId
,
code
,
rowIndex
,
columnIndex
,
projectId
,
period
);
}
public
Project
getFixedProject
(
String
projectId
,
Integer
year
)
{
return
adminMp
.
getFixedProject
(
projectId
,
year
);
}
public
List
<
PeriodDataSource
>
queryManualDataSource
(
Long
templateId
,
String
projectId
,
Integer
period
){
PeriodDataSourceExample
example
=
new
PeriodDataSourceExample
();
example
.
createCriteria
().
andProjectIdEqualTo
(
projectId
).
andPeriodEqualTo
(
period
)
.
andCellTemplateIdEqualTo
(
templateId
).
andTypeEqualTo
(
10
);
return
periodDataSourceMapper
.
selectByExample
(
example
);
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
=
projectServiceTypeMapper
.
selectByExample
(
pst
);
List
<
CellTemplatePerGroupDto
>
cellTemplates
=
adminMp
.
getCellTemplatePerGroupDto
(
templateGroupId
);
if
(
pstReult
==
null
||
pstReult
.
isEmpty
())
{
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
(
adminMp
.
getCellTemplatePerGroupDto
(
groupId
.
groupId
));
}
}
return
cellTemplates
;
}
private
PeriodReport
getReportByTemplate
(
String
templateId
,
Integer
periodId
,
String
projectId
)
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/InputInvoiceDataImportServiceImpl.java
View file @
e6927810
...
...
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
pwc.taxtech.atms.common.util.DateUtils
;
import
pwc.taxtech.atms.constant.Constant
;
import
pwc.taxtech.atms.constant.enums.EnumTbImportType
;
import
pwc.taxtech.atms.constant.enums.EnumValidationType
;
import
pwc.taxtech.atms.dao.OrganizationMapper
;
...
...
@@ -58,17 +59,18 @@ public class InputInvoiceDataImportServiceImpl {
Project
project
=
projectMapper
.
selectByPrimaryKey
(
projectId
);
Organization
organization
=
organizationMapper
.
selectByPrimaryKey
(
project
.
getOrganizationId
());
InputInvoiceExample
invoiceExample
=
new
InputInvoiceExample
();
invoiceExample
.
createCriteria
().
andGFSHEqualTo
(
organization
.
getTaxPayerNumber
()).
andRZSJBetween
(
DateUtils
.
getPeriodBeginFormat
(
project
.
getYear
(),
paras
.
getPeriodStart
()),
DateUtils
.
getPeriodEndFormat
(
project
.
getYear
(),
paras
.
getPeriodEnd
()))
.
andRZJGEqualTo
(
INPUT_RZJG_SUCCESS
).
andRZZTEqualTo
(
INPUT_RZZT_OVER
);
invoiceExample
.
createCriteria
().
andGFSHEqualTo
(
organization
.
getTaxPayerNumber
()).
andRZSQBetween
(
DateUtils
.
getPeriodBeginFormat
(
project
.
getYear
(),
paras
.
getPeriodStart
(),
Constant
.
DateFormat
.
YYYYMM
),
DateUtils
.
getPeriodEndFormat
(
project
.
getYear
(),
paras
.
getPeriodEnd
(),
Constant
.
DateFormat
.
YYYYMM
)).
andRZJGEqualTo
(
INPUT_RZJG_SUCCESS
).
andRZZTEqualTo
(
INPUT_RZZT_OVER
)
.
andFPZTNotEqualTo
(
"1"
);
PageHelper
.
startPage
(
paras
.
getPageInfo
().
getPageIndex
(),
paras
.
getPageInfo
().
getPageSize
());
List
<
InputInvoice
>
invoices
=
inputInvoiceMapper
.
selectByExample
(
invoiceExample
);
DecimalFormat
df
=
new
DecimalFormat
(
"#,###.00"
);
invoices
.
stream
().
forEach
(
x
->
{
x
.
setHJJE
(
df
.
format
(
new
BigDecimal
(
x
.
getHJJE
())));
x
.
setHJSE
(
df
.
format
(
new
BigDecimal
(
x
.
getHJSE
())));
x
.
setRZJG
(
convertRzjg
(
x
.
getRZJG
()));
x
.
setHJJE
(
df
.
format
(
new
BigDecimal
(
x
.
getHJJE
())));
x
.
setHJSE
(
df
.
format
(
new
BigDecimal
(
x
.
getHJSE
())));
x
.
setRZJG
(
convertRzjg
(
x
.
getRZJG
()));
}
);
PageInfo
<
InputInvoice
>
pageInfo
=
new
PageInfo
<>(
invoices
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/OutputInvoiceServiceImpl.java
View file @
e6927810
...
...
@@ -78,14 +78,16 @@ public class OutputInvoiceServiceImpl {
Organization
organization
=
organizationMapper
.
selectByPrimaryKey
(
project
.
getOrganizationId
());
OutputInvoiceExample
outputInvoiceExample
=
new
OutputInvoiceExample
();
if
(
organization
.
getTaxPayerNumber
()
==
null
)
{
if
(
organization
.
getTaxPayerNumber
()
==
null
)
{
outputInvoiceExample
.
createCriteria
().
andXFSHIsNull
().
andKPZTEqualTo
(
OUTPUT_KPZT_YES
).
andKPRQBetween
(
DateUtils
.
getPeriodBegin
(
project
.
getYear
(),
queryDto
.
getPeriodStart
()),
DateUtils
.
getPeriodEnd
(
project
.
getYear
(),
queryDto
.
getPeriodEnd
()));
DateUtils
.
getPeriodEnd
(
project
.
getYear
(),
queryDto
.
getPeriodEnd
()))
.
andFPZTNotEqualTo
(
"1"
);
}
else
{
outputInvoiceExample
.
createCriteria
().
andXFSHEqualTo
(
organization
.
getTaxPayerNumber
()).
andKPZTEqualTo
(
OUTPUT_KPZT_YES
).
andKPRQBetween
(
DateUtils
.
getPeriodBegin
(
project
.
getYear
(),
queryDto
.
getPeriodStart
()),
DateUtils
.
getPeriodEnd
(
project
.
getYear
(),
queryDto
.
getPeriodEnd
()));
DateUtils
.
getPeriodEnd
(
project
.
getYear
(),
queryDto
.
getPeriodEnd
()))
.
andFPZTNotEqualTo
(
"1"
);
}
...
...
@@ -260,7 +262,7 @@ public class OutputInvoiceServiceImpl {
private
List
<
OutputVATInvoiceInfoDto
>
getQueryList
(
QueryOutputDto
queryDto
,
String
projectId
)
{
List
<
OutputVATInvoiceInfoDto
>
rList
=
outputInvoiceMapper
.
selectOutputInvoiceInfoLeftJoinItem
(
queryDto
);
Organization
organization
=
organizationMapper
.
selectByPrimaryKey
(
projectMapper
.
selectByPrimaryKey
(
projectId
).
getOrganizationId
());
if
(
organization
==
null
)
{
if
(
organization
==
null
)
{
return
Lists
.
newArrayList
();
}
OutputInvoiceExample
e
=
new
OutputInvoiceExample
();
...
...
@@ -268,14 +270,14 @@ public class OutputInvoiceServiceImpl {
List
<
String
>
fpqqlshList
=
outputInvoiceMapper
.
selectByExample
(
e
).
stream
().
map
(
OutputInvoice:
:
getFPQQLSH
).
collect
(
Collectors
.
toList
());
rList
=
rList
.
stream
().
filter
(
a
->
fpqqlshList
.
contains
(
a
.
getFpqqlsh
())).
collect
(
Collectors
.
toList
());
rList
.
forEach
(
x
->
{
if
(
x
.
getInvoiceDate
()
!=
null
)
{
if
(
x
.
getInvoiceDate
()
!=
null
)
{
CAL
.
setTime
(
x
.
getInvoiceDate
());
x
.
setPeriodId
(
CAL
.
get
(
Calendar
.
MONTH
)
+
1
);
}
if
(
x
.
getTaxAmount
()
==
null
||
x
.
getAmount
()
==
null
||
x
.
getTaxRate
()
==
null
)
{
if
(
x
.
getTaxAmount
()
==
null
||
x
.
getAmount
()
==
null
||
x
.
getTaxRate
()
==
null
)
{
OutputInvoiceExample
outputInvoiceExample
=
new
OutputInvoiceExample
();
outputInvoiceExample
.
createCriteria
().
andIDEqualTo
(
x
.
getInvoiceId
());
OutputInvoice
outputInvoice
=
outputInvoiceMapper
.
selectByExample
(
outputInvoiceExample
).
get
(
0
);
OutputInvoice
outputInvoice
=
outputInvoiceMapper
.
selectByExample
(
outputInvoiceExample
).
get
(
0
);
x
.
setAmount
(
outputInvoice
.
getHJJE
()
==
null
?
BigDecimal
.
ZERO
:
new
BigDecimal
(
outputInvoice
.
getHJJE
()));
x
.
setTaxRate
(
outputInvoice
.
getSLV
()
==
null
?
BigDecimal
.
ZERO
:
new
BigDecimal
(
outputInvoice
.
getSLV
()));
x
.
setTaxAmount
(
outputInvoice
.
getHJSE
()
==
null
?
BigDecimal
.
ZERO
:
new
BigDecimal
(
outputInvoice
.
getHJSE
()));
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
e6927810
...
...
@@ -95,7 +95,7 @@ public class ReportGeneratorImpl {
String
code
=
sheet
.
getSheetName
();
logger
.
info
(
"-------------------------------------Begin Job [{}]------------------------------------------------------"
,
code
);
setStatus
(
job
,
STATUS_END
);
setStatus
(
job
,
code
,
STATUS_BEGIN
);
setStatus
(
job
,
code
,
STATUS_BEGIN
);
job
.
setCurrentStep
(
code
);
periodJobMapper
.
updateByPrimaryKey
(
job
);
...
...
@@ -177,104 +177,86 @@ public class ReportGeneratorImpl {
periodCellTemplateConfigMapper
.
updateByPrimaryKeySelective
(
periodCellTemplateConfig
);
}
String
regexNormalCell
=
"[A-Z]{1,2}((?!0)[0-9]{1,3})"
;
p
=
Pattern
.
compile
(
regexNormalCell
);
m
=
p
.
matcher
(
sourceFormula
);
while
(
m
.
find
())
{
//如果找到普通单元格的公式,就去workbook里查找对应的格子取数据,然后放到DataSource,作为普通单元格数据源的数据
//找到一个格子就加一条数据
String
findStr
=
m
.
group
();
//A12,A13,A15,how to get A and 12 or A and 13
String
regexColumn
=
"[A-Z]{1,2}"
;
Pattern
pp
=
Pattern
.
compile
(
regexColumn
);
Matcher
mm
=
pp
.
matcher
(
findStr
);
while
(
mm
.
find
())
{
String
colStr
=
mm
.
group
();
int
colNum
=
FormulaHelper
.
excelColStrToNum
(
colStr
,
colStr
.
length
());
int
rowNum
=
Integer
.
parseInt
(
StringUtils
.
removeStart
(
findStr
,
colStr
));
Row
row
=
sheet
.
getRow
(
rowNum
-
1
);
if
(
row
!=
null
)
{
Cell
cell
=
row
.
getCell
(
colNum
-
1
);
if
(
cell
!=
null
)
{
//开始取值然后存放到DataSource
PeriodDataSource
dataSource
=
new
PeriodDataSource
();
dataSource
.
setId
(
distributedIdService
.
nextId
());
dataSource
.
setColumnIndex
(
colNum
-
1
);
dataSource
.
setRowIndex
(
rowNum
-
1
);
if
(((
XSSFCell
)
cell
).
getRawValue
()
!=
"#VALUE!"
)
{
// if(StringUtils.isNotBlank(cell.getStringCellValue())
// && StringUtils.isNumeric(cell.getStringCellValue().replace(".", ""))){
// dataSource.setAmount(new BigDecimal(cell.getStringCellValue()));
// }
// else if(StringUtils.isBlank(cell.getStringCellValue())){
// dataSource.setAmount(new BigDecimal(Double.toString(cell.getNumericCellValue())));
// }
//// else {
//// cell.setCellFormula(cell.getStringCellValue());
//// FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
//// dataSource.setAmount(new BigDecimal(formulaEvaluator.evaluate(cell).getNumberValue()));
//// }
dataSource
.
setAmount
(
new
BigDecimal
(
((
XSSFCell
)
cell
).
getRawValue
()
!=
null
?
((
XSSFCell
)
cell
).
getRawValue
()
:
(
StringUtils
.
isNotBlank
(
cell
.
getStringCellValue
()))
?
cell
.
getStringCellValue
()
:
Double
.
toString
(
cell
.
getNumericCellValue
())));
}
else
{
dataSource
.
setAmount
(
new
BigDecimal
(
"0.0"
));
}
dataSource
.
setName
(
"ReportDataSource"
);
dataSource
.
setDescription
(
findStr
);
dataSource
.
setCreateTime
(
new
Date
());
dataSource
.
setUpdateTime
(
new
Date
());
dataSource
.
setCreateBy
(
"Admin"
);
dataSource
.
setUpdateBy
(
"Admin"
);
dataSource
.
setPeriod
(
period
);
dataSource
.
setCellTemplateId
(
periodCellTemplateConfig
.
getCellTemplateId
());
dataSource
.
setType
(
FormulaDataSourceType
.
Report
.
getCode
());
dataSource
.
setProjectId
(
projectId
);
periodDataSourceMapper
.
insertSelective
(
dataSource
);
//这里有个问题就是DataSource的数据有了,但是celldatasource的数据没有,后面无法关联celldata和DataSource
//解决办法就是 在存DataSource的时候就先把celldata的数据加好
//然后把celldatasource的数据也加好
//然后在外面去更新celldata和celldatasource的数据
//还有就是把公式里的数据源放到内存,在所有算完之后再统一加数据源
String
regexNormalCell
=
"[A-Z]{1,2}((?!0)[0-9]{1,3})"
;
// todo 这里原生引用计算废弃,改用BB
p
=
Pattern
.
compile
(
regexNormalCell
);
m
=
p
.
matcher
(
sourceFormula
);
while
(
m
.
find
())
{
//如果找到普通单元格的公式,就去workbook里查找对应的格子取数据,然后放到DataSource,作为普通单元格数据源的数据
//找到一个格子就加一条数据
String
findStr
=
m
.
group
();
//A12,A13,A15,how to get A and 12 or A and 13
String
regexColumn
=
"[A-Z]{1,2}"
;
Pattern
pp
=
Pattern
.
compile
(
regexColumn
);
Matcher
mm
=
pp
.
matcher
(
findStr
);
while
(
mm
.
find
())
{
String
colStr
=
mm
.
group
();
int
colNum
=
FormulaHelper
.
excelColStrToNum
(
colStr
,
colStr
.
length
());
int
rowNum
=
Integer
.
parseInt
(
StringUtils
.
removeStart
(
findStr
,
colStr
));
Row
row
=
sheet
.
getRow
(
rowNum
-
1
);
if
(
row
!=
null
)
{
Cell
cell
=
row
.
getCell
(
colNum
-
1
);
if
(
cell
!=
null
)
{
//开始取值然后存放到DataSource
PeriodDataSource
dataSource
=
new
PeriodDataSource
();
dataSource
.
setId
(
distributedIdService
.
nextId
());
dataSource
.
setColumnIndex
(
colNum
-
1
);
dataSource
.
setRowIndex
(
rowNum
-
1
);
if
(((
XSSFCell
)
cell
).
getRawValue
()
!=
"#VALUE!"
)
{
dataSource
.
setAmount
(
new
BigDecimal
(
((
XSSFCell
)
cell
).
getRawValue
()
!=
null
?
((
XSSFCell
)
cell
).
getRawValue
()
:
(
StringUtils
.
isNotBlank
(
cell
.
getStringCellValue
()))
?
cell
.
getStringCellValue
()
:
Double
.
toString
(
cell
.
getNumericCellValue
())));
}
else
{
dataSource
.
setAmount
(
new
BigDecimal
(
"0.0"
));
}
dataSource
.
setName
(
"ReportDataSource"
);
dataSource
.
setDescription
(
findStr
);
dataSource
.
setCreateTime
(
new
Date
());
dataSource
.
setUpdateTime
(
new
Date
());
dataSource
.
setCreateBy
(
"Admin"
);
dataSource
.
setUpdateBy
(
"Admin"
);
dataSource
.
setPeriod
(
period
);
dataSource
.
setCellTemplateId
(
periodCellTemplateConfig
.
getCellTemplateId
());
dataSource
.
setType
(
FormulaDataSourceType
.
Report
.
getCode
());
dataSource
.
setProjectId
(
projectId
);
periodDataSourceMapper
.
insertSelective
(
dataSource
);
//这里有个问题就是DataSource的数据有了,但是celldatasource的数据没有,后面无法关联celldata和DataSource
//解决办法就是 在存DataSource的时候就先把celldata的数据加好
//然后把celldatasource的数据也加好
//然后在外面去更新celldata和celldatasource的数据
//还有就是把公式里的数据源放到内存,在所有算完之后再统一加数据源
}
}
}
}
Optional
<
PeriodCellTemplate
>
tempPeriodCellTemplate
=
resources
.
getPeriodCellTemplates
().
stream
()
.
filter
(
a
->
a
.
getCellTemplateId
().
equals
(
periodCellTemplateConfig
.
getCellTemplateId
()))
.
findFirst
();
if
(
tempPeriodCellTemplate
.
isPresent
())
{
PeriodCellData
cellData
=
new
PeriodCellData
();
Long
cellDataId
=
distributedIdService
.
nextId
();
cellData
.
setId
(
cellDataId
);
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
)
{
Cell
cell
=
sheet
.
getRow
(
tempPeriodCellTemplate
.
get
().
getRowIndex
())
.
getCell
(
tempPeriodCellTemplate
.
get
().
getColumnIndex
());
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"
;
}
Optional
<
PeriodCellTemplate
>
tempPeriodCellTemplate
=
resources
.
getPeriodCellTemplates
().
stream
()
.
filter
(
a
->
a
.
getCellTemplateId
().
equals
(
periodCellTemplateConfig
.
getCellTemplateId
()))
.
findFirst
();
if
(
tempPeriodCellTemplate
.
isPresent
())
{
PeriodCellData
cellData
=
new
PeriodCellData
();
Long
cellDataId
=
distributedIdService
.
nextId
();
cellData
.
setId
(
cellDataId
);
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
)
{
Cell
cell
=
sheet
.
getRow
(
tempPeriodCellTemplate
.
get
().
getRowIndex
())
.
getCell
(
tempPeriodCellTemplate
.
get
().
getColumnIndex
());
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"
;
}
//evaluator.evaluate(cell);
// if (cell.getCellTypeEnum().equals(CellType.NUMERIC)||cell.getCellTypeEnum().equals(CellType.FORMULA)) {
// data = Double.toString(cell.getNumericCellValue());
// } else {
// data = cell.getStringCellValue();
// }
}
}
else
{
data
=
"0.0"
;
}
...
...
@@ -291,19 +273,11 @@ public class ReportGeneratorImpl {
cellData
.
setData
(
data
);
}
//cellData.setData(new BigDecimal(data).toString());
// PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample();
// periodFormulaBlockExample.createCriteria().andPeriodEqualTo(period)
// .andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId());
if
(
StringUtils
.
isBlank
(
resultFormula
))
{
resultFormula
=
null
;
}
// if (isFind) {
cellData
.
setFormulaExp
(
resultFormula
);
// } else {
// cellData.setFormulaExp(EMPTY);
// }
cellData
.
setCreateBy
(
"Admin"
);
cellData
.
setCreateTime
(
new
Date
());
cellData
.
setUpdateBy
(
"Admin"
);
...
...
@@ -355,9 +329,10 @@ public class ReportGeneratorImpl {
if
(
cellDataList
.
size
()
==
1
)
{
PeriodCellData
cellData
=
cellDataList
.
get
(
0
);
PeriodDataSource
dataSource
=
dataSourceList
.
get
(
0
);
cellData
.
setData
(
dataSource
.
getAmount
()
+
""
);
if
(
StringUtils
.
isEmpty
(
cellData
.
getData
().
trim
()))
cellData
.
setData
(
"0.0"
);
if
(
StringUtils
.
isEmpty
(
cellData
.
getFormulaExp
().
trim
()))
cellData
.
setFormulaExp
(
dataSource
.
getAmount
()
+
"
"
);
cellData
.
setFormulaExp
(
"0.0
"
);
PeriodCellDataSource
cellDataSource
=
new
PeriodCellDataSource
();
cellDataSource
.
setId
(
distributedIdService
.
nextId
());
...
...
@@ -384,8 +359,8 @@ public class ReportGeneratorImpl {
cellData
.
setPeriod
(
period
);
PeriodDataSource
dataSource
=
dataSourceList
.
get
(
0
);
cellData
.
setData
(
dataSource
.
getAmount
()
+
"
"
);
cellData
.
setFormulaExp
(
dataSource
.
getAmount
()
+
"
"
);
cellData
.
setData
(
"0.0
"
);
cellData
.
setFormulaExp
(
"0.0
"
);
PeriodCellDataSource
cellDataSource
=
new
PeriodCellDataSource
();
cellDataSource
.
setId
(
distributedIdService
.
nextId
());
...
...
@@ -599,7 +574,7 @@ public class ReportGeneratorImpl {
public
void
addFunctionsAndContext
(
Workbook
workbook
,
String
[]
functions
,
FormulaContext
formulaContext
)
{
FreeRefFunction
[]
functionImpls
=
{
new
SGSR
(
formulaContext
),
new
FSJZ
(
formulaContext
),
new
ND
(
formulaContext
),
new
BB
(
formulaContext
),
new
XXFP
(
formulaContext
),
new
GZSD
(
formulaContext
),
new
ProjectContext
(
formulaContext
)
,
new
JXFPMX
(
formulaContext
),
new
JXFP
(
formulaContext
)};
,
new
JXFPMX
(
formulaContext
),
new
JXFP
(
formulaContext
)
,
new
PSUM
(
formulaContext
)
,
new
DFFS
(
formulaContext
)
};
UDFFinder
udfs
=
new
DefaultUDFFinder
(
functions
,
functionImpls
);
UDFFinder
udfToolpack
=
new
AggregatingUDFFinder
(
udfs
);
workbook
.
addToolPack
(
udfToolpack
);
...
...
@@ -616,7 +591,6 @@ public class ReportGeneratorImpl {
List
<
PeriodCellTemplateConfigExtendDto
>
periodCellTemplateConfigExtendDtos
=
periodCellTemplateConfigMapper
.
getPeriodCellTemplateConfigExtendDtos
(
templateIdList
,
period
,
projectId
);
fixedPCTParsedFormula
(
periodCellTemplateConfigExtendDtos
,
projectId
,
period
);
List
<
CellCalcInfoDto
>
cellCalcInfoDtos
=
new
ArrayList
<>();
Map
<
String
,
List
<
PeriodCellTemplateConfigExtendDto
>>
myStream
=
new
HashMap
<>();
for
(
PeriodCellTemplateConfigExtendDto
pctce
:
periodCellTemplateConfigExtendDtos
)
{
...
...
@@ -649,84 +623,6 @@ public class ReportGeneratorImpl {
return
cellCalcInfoDtos
;
}
private
void
fixedPCTParsedFormula
(
List
<
PeriodCellTemplateConfigExtendDto
>
periodCellTemplateConfigExtendDtos
,
String
projectId
,
int
period
)
{
Map
<
String
,
List
<
PCTEntity
>>
formulaMapToPCT
=
new
HashMap
<>();
Map
<
PeriodCellTemplateConfig
,
List
<
String
>>
configMapToPCTs
=
new
HashMap
<>();
Set
<
PCTEntity
>
parameter
=
new
HashSet
<>();
periodCellTemplateConfigExtendDtos
.
forEach
(
p
->
{
String
formula
=
p
.
getFormula
();
String
parsedFormula
=
p
.
getParsedFormula
();
if
(
formula
.
contains
(
"BB("
))
{
logger
.
debug
(
"period cell template config contains bb formula {}"
,
formula
);
if
(
parsedFormula
.
contains
(
"PCT("
))
{
List
<
String
>
parsedPCTs
=
new
ArrayList
<>();
byte
[]
parsedFormulaBytes
=
parsedFormula
.
getBytes
();
Integer
begin
=
null
;
for
(
int
i
=
0
;
i
<
parsedFormulaBytes
.
length
;
i
++)
{
if
(
i
<
parsedFormulaBytes
.
length
-
3
&&
parsedFormulaBytes
[
i
]
==
'P'
&&
parsedFormulaBytes
[
i
+
1
]
==
'C'
&&
parsedFormulaBytes
[
i
+
2
]
==
'T'
&&
parsedFormulaBytes
[
i
+
3
]
==
'('
)
{
begin
=
i
;
}
else
if
(
parsedFormulaBytes
[
i
]
==
')'
&&
begin
!=
null
)
{
parsedPCTs
.
add
(
new
String
(
Arrays
.
copyOfRange
(
parsedFormulaBytes
,
begin
,
i
+
1
)));
begin
=
null
;
}
}
if
(!
parsedPCTs
.
isEmpty
())
{
configMapToPCTs
.
put
(
p
,
parsedPCTs
);
}
parsedPCTs
.
stream
().
forEach
(
m
->
{
String
periodCPT
=
m
.
substring
(
m
.
indexOf
(
"("
)
+
1
,
m
.
indexOf
(
")"
));
if
(
periodCPT
.
contains
(
","
))
{
formulaMapToPCT
.
put
(
m
,
Arrays
.
asList
(
periodCPT
.
split
(
","
)).
stream
().
map
(
n
->
new
PCTEntity
(
n
))
.
collect
(
Collectors
.
toList
()));
}
else
{
formulaMapToPCT
.
put
(
m
,
Lists
.
newArrayList
(
new
PCTEntity
(
periodCPT
)));
}
parameter
.
addAll
(
formulaMapToPCT
.
get
(
m
));
});
}
else
{
logger
.
warn
(
"bb formula parsedformula must contains PCT but not found {}"
,
parsedFormula
);
}
}
});
if
(!
parameter
.
isEmpty
())
{
List
<
PCTEntity
>
pctResults
=
periodCellDataMapper
.
queryByPCTs
(
parameter
,
projectId
);
Map
<
PCTEntity
,
PCTEntity
>
pctCache
=
new
HashMap
<>();
pctResults
.
forEach
(
m
->
{
pctCache
.
put
(
m
,
m
);
});
configMapToPCTs
.
forEach
((
k
,
v
)
->
{
v
.
forEach
(
pctStr
->
{
List
<
PCTEntity
>
entities
=
formulaMapToPCT
.
get
(
pctStr
);
StringBuilder
result
=
new
StringBuilder
(
"0"
);
for
(
PCTEntity
entity
:
entities
)
{
if
(
pctCache
.
containsKey
(
entity
))
{
PCTEntity
pct
=
pctCache
.
get
(
entity
);
if
(
pct
.
getDsCount
()
==
1
&&
pct
.
getAmount
()
!=
null
)
{
result
.
append
(
"+"
).
append
(
pct
.
getAmount
());
}
else
if
(
pct
.
getDsCount
()
>
1
&&
pct
.
getAmount
()
!=
null
&&
!
StringUtils
.
isEmpty
(
pct
.
getFormulaExp
().
trim
()))
{
result
.
append
(
"+"
).
append
(
pct
.
getFormulaExp
()).
append
(
"+"
).
append
(
pct
.
getAmount
());
}
else
if
(
pct
.
getAmount
()
==
null
&&
!
StringUtils
.
isNotEmpty
(
pct
.
getData
()))
{
result
.
append
(
pct
.
getData
());
}
}
}
k
.
setParsedFormula
(
k
.
getParsedFormula
().
replace
(
pctStr
,
result
.
toString
()));
});
});
}
}
private
String
convertListToString
(
List
<
String
>
list
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
list
.
forEach
(
s
->
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportServiceImpl.java
View file @
e6927810
...
...
@@ -50,7 +50,7 @@ import static pwc.taxtech.atms.dto.vatdto.WrapPeriodJobDto.*;
public
class
ReportServiceImpl
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ReportServiceImpl
.
class
);
private
BlockingQueue
<
PeriodJob
>
queue
=
new
LinkedBlockingQueue
<>();
private
final
static
String
[]
functions
=
{
"SGSR"
,
"FSJZ"
,
"ND"
,
"BB"
,
"XXFP"
,
"GZSD"
,
"ProjectContext"
,
"JXFPMX"
,
"JXFP"
};
private
final
static
String
[]
functions
=
{
"SGSR"
,
"FSJZ"
,
"ND"
,
"BB"
,
"XXFP"
,
"GZSD"
,
"ProjectContext"
,
"JXFPMX"
,
"JXFP"
,
"PSUM"
,
"DFFS"
};
@Autowired
private
ReportGeneratorImpl
reportGenerator
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/BB.java
View file @
e6927810
...
...
@@ -12,9 +12,11 @@ import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
import
pwc.taxtech.atms.dto.vatdto.BBParasBo
;
import
pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.entity.Project
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.exception.FormulaException
;
import
pwc.taxtech.atms.vat.entity.PeriodCellData
;
import
pwc.taxtech.atms.vat.entity.PeriodDataSource
;
import
java.lang.reflect.Field
;
import
java.math.BigDecimal
;
...
...
@@ -59,14 +61,18 @@ public class BB extends FunctionBase implements FreeRefFunction {
BigDecimal
cellValue
=
BigDecimal
.
ZERO
;
try
{
CellTemplatePerGroupDto
cellTemplateData
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
()).
stream
().
filter
(
dto
->
dto
.
getRowIndex
()
==
bo
.
getRowIndex
()
-
1
&&
dto
.
getColumnIndex
()
==
bo
.
getColumnIndex
()
-
1
&&
dto
.
getReportCode
().
equals
(
bo
.
getReportCode
()))
.
findFirst
().
orElseThrow
(()
->
{
return
Exceptions
.
BB_CELL_TEMP_NULL
;
});
MyAsserts
.
assertNotNull
(
cellTemplateData
,
Exceptions
.
BB_CELL_TEMP_NULL
);
List
<
CellTemplatePerGroupDto
>
cellTemplateDataList
;
if
(
curPeriod
.
getCurYear
()
!=
formulaContext
.
getYear
())
{
Project
project
=
agent
.
getFixedProject
(
formulaContext
.
getProjectId
(),
curPeriod
.
getCurYear
());
MyAsserts
.
assertNotNull
(
project
,
Exceptions
.
PROJECT_NOT_FOUND
);
cellTemplateDataList
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupId
(),
project
.
getId
(),
bo
.
getReportCode
(),
bo
.
getRowIndex
()
-
1
,
bo
.
getColumnIndex
()
-
1
,
curPeriod
.
getCurPeriod
());
}
else
{
cellTemplateDataList
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
(),
bo
.
getReportCode
(),
bo
.
getRowIndex
()
-
1
,
bo
.
getColumnIndex
()
-
1
,
curPeriod
.
getCurPeriod
());
}
MyAsserts
.
assertNotEmpty
(
cellTemplateDataList
,
Exceptions
.
BB_CELL_TEMP_NULL
);
CellTemplatePerGroupDto
cellTemplateData
=
cellTemplateDataList
.
get
(
0
);
nullCellDto
.
fixedWithGroup
(
cellTemplateData
);
// todo: fix datasource name by templateList(neo)
...
...
@@ -94,24 +100,40 @@ public class BB extends FunctionBase implements FreeRefFunction {
WorkbookEvaluator
evaluator
=
(
WorkbookEvaluator
)
evaluatorField
.
get
(
ec
);
int
index
=
ec
.
getWorkbook
().
getSheetIndex
(
bo
.
getReportCode
());
if
(
index
<
0
)
logger
.
warn
(
"not found sheet code {}"
,
bo
.
getReportCode
());
if
(
index
<
0
)
logger
.
warn
(
"[BB_Exception] not found sheet code {} with {}"
,
bo
.
getReportCode
(),
bo
.
toString
());
ValueEval
eval
=
evaluator
.
evaluate
(
ec
.
getWorkbook
().
getSheet
(
index
)
.
getCell
(
bo
.
getRowIndex
()
-
1
,
bo
.
getColumnIndex
()
-
1
));
bo
.
putPeriodCellTempate
(
formulaContext
.
getPeriod
(),
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()));
if
(
eval
instanceof
ErrorEval
)
{
LOGGER
.
warn
(
"error eval for bb {} and error code {} and error String {}"
,
bo
.
toString
(),
List
<
PeriodDataSource
>
dss
=
agent
.
queryManualDataSource
(
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()),
formulaContext
.
getProjectId
(),
formulaContext
.
getPeriod
());
if
(
eval
instanceof
ErrorEval
||
eval
==
null
||
eval
instanceof
BlankEval
)
{
LOGGER
.
warn
(
"[BB_Exception] error eval for bb {} and error code {} and error String {}"
,
bo
.
toString
(),
((
ErrorEval
)
eval
).
getErrorCode
(),
((
ErrorEval
)
eval
).
getErrorString
());
if
(!
dss
.
isEmpty
())
cellValue
=
dss
.
get
(
0
).
getAmount
();
}
else
{
String
evalStr
=
OperandResolver
.
coerceValueToString
(
eval
);
logger
.
debug
(
"[BB_debug] eval other cell value {}"
,
evalStr
);
try
{
cellValue
=
new
BigDecimal
(
evalStr
).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
);
if
(!
dss
.
isEmpty
())
cellValue
=
cellValue
.
add
(
dss
.
get
(
0
).
getAmount
());
}
catch
(
Exception
e
)
{
if
(!
dss
.
isEmpty
())
cellValue
=
dss
.
get
(
0
).
getAmount
();
else
throw
e
;
}
}
cellValue
=
new
BigDecimal
(
OperandResolver
.
coerceValueToDouble
(
eval
));
nullCellDto
.
extractFromGroup
(
bo
,
formulaContext
.
getPeriod
(),
formulaContext
.
getYear
(),
cellTemplateData
);
nullCellDto
.
setAmount
(
cellValue
);
return
cellValue
;
}
// bo.disCount();
PeriodCellData
cellData
=
null
;
String
projectId
=
agent
.
getPastProjectId
(
curPeriod
.
getCurYear
(),
...
...
@@ -120,15 +142,22 @@ public class BB extends FunctionBase implements FreeRefFunction {
MyAsserts
.
assertNotEmpty
(
projectId
,
Exceptions
.
PROJECT_EMPTY
);
cellData
=
agent
.
getCellData
(
cellTemplateData
.
getReportTemplateId
(),
cellTemplateData
.
getCellTemplateId
(),
curPeriod
.
getCurPeriod
(),
formulaContext
.
getProjectId
());
List
<
PeriodDataSource
>
dss
=
agent
.
queryManualDataSource
(
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()),
formulaContext
.
getProjectId
(),
bo
.
getPeriod
());
nullCellDto
.
extractFromGroup
(
bo
,
curPeriod
,
cellData
,
cellTemplateData
);
// todo: fix datasource name by templateList(neo)
MyAsserts
.
assertNotNull
(
cellData
.
getData
(),
Exceptions
.
BB_CELL_DATA_NULL
);
// cellValue= RoundValue(cellValue, cellDataType)TODO:maybe fixd round by cellDataTyep(KV neo)
cellValue
=
new
BigDecimal
(
cellData
.
getData
()).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
);
if
(
cellData
.
getData
()
==
null
&&
!
dss
.
isEmpty
())
{
cellValue
=
dss
.
get
(
0
).
getAmount
();
}
else
if
(
cellData
.
getData
()
!=
null
&&
dss
.
isEmpty
())
{
cellValue
=
new
BigDecimal
(
cellData
.
getData
()).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
);
}
else
if
(
cellData
.
getData
()
!=
null
&&
!
dss
.
isEmpty
())
{
cellValue
=
dss
.
get
(
0
).
getAmount
().
add
(
new
BigDecimal
(
cellData
.
getData
()).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
));
}
else
throw
Exceptions
.
BB_CELL_DATA_NULL
;
nullCellDto
.
setAmount
(
cellValue
);
if
(
rootBo
!=
null
)
{
rootBo
.
putPeriodCellTempate
(
curPeriod
.
getCurPeriod
(),
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()));
...
...
@@ -138,15 +167,18 @@ public class BB extends FunctionBase implements FreeRefFunction {
LOGGER
.
debug
(
"cell static value "
);
return
cellValue
;
}
catch
(
Exception
e
)
{
logger
.
warn
(
"[BB_Exception] some error {}"
,
bo
.
toString
());
throw
e
;
}
finally
{
if
(
rootBo
==
null
)
{
LOGGER
.
warn
(
"error for bb cacls for {} and current for {}"
,
bo
.
toString
(),
curPeriod
.
toString
());
LOGGER
.
warn
(
"
[BB_Exception]
error for bb cacls for {} and current for {}"
,
bo
.
toString
(),
curPeriod
.
toString
());
Long
dataSourceId
=
saveDataSource
(
ec
,
dataSource
,
FormulaDataSourceDetailType
.
ReportCellDataSourceDto
,
cellValue
,
formulaContext
.
getPeriod
(),
formulaContext
.
getReportTemplateGroupId
(),
bo
.
getColumnIndex
()
-
1
,
bo
.
getRowIndex
()
-
1
,
formulaContext
.
getProjectId
());
saveFormulaBlock
(
formulaContext
.
getPeriod
(),
ec
,
bo
.
expression
(),
bo
.
expressionData
()
,
dataSourceId
,
formulaContext
.
getProjectId
());
bo
.
expression
(),
cellValue
,
dataSourceId
,
formulaContext
.
getProjectId
());
}
}
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/FunctionBase.java
View file @
e6927810
...
...
@@ -178,25 +178,4 @@ public class FunctionBase {
periodFormulaBlock
.
setUpdateTime
(
creatime
);
SpringContextUtil
.
periodFormulaBlockMapper
.
insertSelective
(
periodFormulaBlock
);
}
public
void
saveFormulaBlock
(
int
period
,
OperationEvaluationContext
ec
,
String
formulaExpression
,
String
val
,
Long
dataSourceId
,
String
projectId
)
{
Long
cellTemplateId
=
getCellTemplateId
(
period
,
ec
);
Date
creatime
=
new
Date
();
PeriodFormulaBlock
periodFormulaBlock
=
new
PeriodFormulaBlock
();
periodFormulaBlock
.
setProjectId
(
projectId
);
periodFormulaBlock
.
setId
(
SpringContextUtil
.
distributedIdService
.
nextId
());
periodFormulaBlock
.
setPeriod
(
period
);
periodFormulaBlock
.
setReportId
(
0L
);
periodFormulaBlock
.
setCellTemplateId
(
cellTemplateId
);
periodFormulaBlock
.
setFormulaExpression
(
formulaExpression
);
periodFormulaBlock
.
setData
(
val
);
periodFormulaBlock
.
setDataSourceId
(
dataSourceId
);
periodFormulaBlock
.
setCreateBy
(
"Admin"
);
periodFormulaBlock
.
setCreateTime
(
creatime
);
periodFormulaBlock
.
setUpdateBy
(
"Admin"
);
periodFormulaBlock
.
setUpdateTime
(
creatime
);
SpringContextUtil
.
periodFormulaBlockMapper
.
insertSelective
(
periodFormulaBlock
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/PSUM.java
0 → 100644
View file @
e6927810
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.WorkbookEvaluator
;
import
org.apache.poi.ss.formula.eval.*
;
import
org.apache.poi.ss.formula.functions.FreeRefFunction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType
;
import
pwc.taxtech.atms.dpo.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.entity.PeriodDataSource
;
import
java.lang.reflect.Field
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
PSUM
extends
FunctionBase
implements
FreeRefFunction
{
private
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
PSUM
.
class
);
final
static
ValueEval
defaultEval
=
new
StringEval
(
"0"
);
public
PSUM
(
FormulaContext
formulaContext
)
{
super
(
formulaContext
);
}
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
String
param
=
getStringParam
(
args
[
0
],
ec
);
String
expression
=
"PSUM(\""
+
param
+
"\")"
;
List
<
Object
>
dataSource
=
new
ArrayList
<>();
BigDecimal
cellValue
=
new
BigDecimal
(
0
);
try
{
List
<
PCell
>
pCells
;
if
(
param
.
contains
(
":"
))
{
pCells
=
getPCellListFromArea
(
param
);
}
else
if
(
param
.
contains
(
","
))
{
pCells
=
getPCellList
(
param
);
}
else
{
LOGGER
.
error
(
"[PSUM] error , psum must contains : or ,"
);
throw
Exceptions
.
BAD_BBVO_PARAMS
;
}
cellValue
=
evaluatePCells
(
pCells
,
ec
,
this
.
formulaContext
,
dataSource
);
return
new
NumberEval
(
cellValue
.
doubleValue
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
defaultEval
;
}
finally
{
Long
dataSourceId
=
saveDataSource
(
ec
,
dataSource
,
FormulaDataSourceDetailType
.
ReportCellDataSourceDto
,
cellValue
,
formulaContext
.
getPeriod
(),
formulaContext
.
getReportTemplateGroupId
(),
ec
.
getColumnIndex
()
-
1
,
ec
.
getRowIndex
()
-
1
,
formulaContext
.
getProjectId
());
saveFormulaBlock
(
formulaContext
.
getPeriod
(),
ec
,
expression
,
cellValue
,
dataSourceId
,
formulaContext
.
getProjectId
());
}
}
private
BigDecimal
evaluatePCells
(
List
<
PCell
>
pCells
,
OperationEvaluationContext
ec
,
FormulaContext
formulaContext
,
List
<
Object
>
dataSource
)
throws
NoSuchFieldException
,
IllegalAccessException
{
BigDecimal
bigDecimal
=
new
BigDecimal
(
0
);
for
(
PCell
pCell
:
pCells
)
{
Field
evaluatorField
=
OperationEvaluationContext
.
class
.
getDeclaredField
(
"_bookEvaluator"
);
evaluatorField
.
setAccessible
(
true
);
WorkbookEvaluator
evaluator
=
(
WorkbookEvaluator
)
evaluatorField
.
get
(
ec
);
ValueEval
eval
=
evaluator
.
evaluate
(
ec
.
getWorkbook
().
getSheet
(
ec
.
getSheetIndex
())
.
getCell
(
pCell
.
rowIndex
-
1
,
pCell
.
columnIndex
-
1
));
List
<
CellTemplatePerGroupDto
>
cellTemplateDataList
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupId
(),
formulaContext
.
getProjectId
(),
ec
.
getWorkbook
().
getSheetName
(
ec
.
getSheetIndex
()),
pCell
.
rowIndex
-
1
,
pCell
.
columnIndex
-
1
,
formulaContext
.
getPeriod
());
MyAsserts
.
assertNotEmpty
(
cellTemplateDataList
,
Exceptions
.
PSUM_CELL_TEMP_NULL
);
CellTemplatePerGroupDto
cellTemplateData
=
cellTemplateDataList
.
get
(
0
);
List
<
PeriodDataSource
>
dss
=
agent
.
queryManualDataSource
(
Long
.
parseLong
(
cellTemplateData
.
getCellTemplateId
()),
formulaContext
.
getProjectId
(),
formulaContext
.
getPeriod
());
BigDecimal
cellValue
=
new
BigDecimal
(
0
);
if
(
eval
instanceof
ErrorEval
||
eval
==
null
||
eval
instanceof
BlankEval
)
{
LOGGER
.
warn
(
"[PSUM_Exception] error eval for pcell {} and error code {} and error String {}"
,
pCell
.
toString
(),
((
ErrorEval
)
eval
).
getErrorCode
(),
((
ErrorEval
)
eval
).
getErrorString
());
if
(!
dss
.
isEmpty
())
cellValue
=
dss
.
get
(
0
).
getAmount
();
}
else
{
String
evalStr
=
OperandResolver
.
coerceValueToString
(
eval
);
logger
.
debug
(
"[PSUM_debug] eval other cell value {}"
,
evalStr
);
try
{
cellValue
=
new
BigDecimal
(
evalStr
).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
);
if
(!
dss
.
isEmpty
())
cellValue
=
cellValue
.
add
(
dss
.
get
(
0
).
getAmount
());
}
catch
(
Exception
e
)
{
if
(!
dss
.
isEmpty
())
cellValue
=
dss
.
get
(
0
).
getAmount
();
else
throw
e
;
}
}
ReportCellDataSourceDto
dto
=
new
ReportCellDataSourceDto
();
dto
.
fixedWithGroup
(
cellTemplateData
);
dto
.
setAmount
(
cellValue
);
dto
.
setPeriod
(
formulaContext
.
getPeriod
());
dto
.
setProjectId
(
formulaContext
.
getProjectId
());
dto
.
setReportName
(
cellTemplateData
.
getReportCode
());
dataSource
.
add
(
dto
);
bigDecimal
=
bigDecimal
.
add
(
cellValue
);
}
return
bigDecimal
;
}
public
static
class
PCell
{
int
rowIndex
;
int
columnIndex
;
public
PCell
(
int
rowIndex
,
int
columnIndex
)
{
this
.
rowIndex
=
rowIndex
;
this
.
columnIndex
=
columnIndex
;
}
@Override
public
String
toString
()
{
return
"PCell{"
+
"rowIndex="
+
rowIndex
+
", columnIndex="
+
columnIndex
+
'}'
;
}
}
public
static
PCell
getColumnIndex
(
String
columnStr
)
{
columnStr
=
columnStr
.
toUpperCase
();
char
[]
excelCol
=
columnStr
.
toCharArray
();
int
c
=
0
;
int
r
=
0
;
int
splitIndex
=
0
;
for
(
int
i
=
columnStr
.
length
()
-
1
;
i
>=
0
;
i
--)
{
if
(
excelCol
[
i
]
>=
'A'
&&
excelCol
[
i
]
<=
'Z'
)
{
c
+=
((
int
)
Math
.
pow
(
26
,
splitIndex
-
i
-
1
)
*
(
excelCol
[
i
]
-
64
));
}
else
if
(
excelCol
[
i
]
>=
'0'
&&
excelCol
[
i
]
<=
'9'
)
{
r
+=
((
int
)
Math
.
pow
(
10
,
excelCol
.
length
-
1
-
i
)
*
(
excelCol
[
i
]
-
48
));
splitIndex
=
i
;
}
else
{
c
=
-
1
;
r
=
-
1
;
}
}
return
new
PCell
(
r
,
c
);
}
public
static
void
main
(
String
[]
args
)
{
List
<
PCell
>
result
=
getPCellListFromArea
(
"A1:C3"
);
System
.
out
.
println
(
result
.
size
());
}
static
List
<
PCell
>
getPCellListFromArea
(
String
areaStr
)
{
String
[]
area
=
areaStr
.
split
(
":"
);
List
<
PCell
>
pCells
=
new
ArrayList
<>();
PCell
begin
=
getColumnIndex
(
area
[
0
]);
PCell
end
=
getColumnIndex
(
area
[
1
]);
for
(
int
i
=
begin
.
rowIndex
;
i
<=
end
.
rowIndex
;
i
++)
{
for
(
int
j
=
begin
.
columnIndex
;
j
<=
end
.
columnIndex
;
j
++)
{
pCells
.
add
(
new
PCell
(
i
,
j
));
}
}
return
pCells
;
}
static
List
<
PCell
>
getPCellList
(
String
listStr
)
{
String
[]
list
=
listStr
.
split
(
","
);
List
<
PCell
>
pCells
=
new
ArrayList
<>(
list
.
length
);
for
(
String
s
:
list
)
{
pCells
.
add
(
getColumnIndex
(
s
));
}
return
pCells
;
}
}
atms-api/src/test/java/pwc/taxtech/atms/common/DataInitTest.java
View file @
e6927810
...
...
@@ -93,7 +93,7 @@ public class DataInitTest extends CommonIT {
@Test
public
void
initInput
()
throws
Exception
{
Workbook
workbook
=
WorkbookFactory
.
create
(
new
File
(
"C:\\Users\\Eddie Wu\\Desktop\\导入
/导入模板_进项主表_绿能_201809
.xls"
));
Workbook
workbook
=
WorkbookFactory
.
create
(
new
File
(
"C:\\Users\\Eddie Wu\\Desktop\\导入
\\进销项/导入模板_进项主表_乐叶_201807
.xls"
));
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
for
(
int
r
=
1
;
r
<=
sheet
.
getLastRowNum
();
r
++)
{
try
{
...
...
@@ -119,7 +119,7 @@ public class DataInitTest extends CommonIT {
invoice
.
setFPZT
(
sheet
.
getRow
(
r
).
getCell
(
27
).
getStringCellValue
());
invoice
.
setCYZT
(
sheet
.
getRow
(
r
).
getCell
(
28
).
getStringCellValue
());
invoice
.
setRZZT
(
sheet
.
getRow
(
r
).
getCell
(
29
).
getStringCellValue
());
invoice
.
setRZSQ
(
sheet
.
getRow
(
r
).
getCell
(
30
).
getStringCellValue
(
));
invoice
.
setRZSQ
(
StringUtils
.
replace
(
sheet
.
getRow
(
r
).
getCell
(
30
).
getStringCellValue
(),
"-"
,
""
));
invoice
.
setRZSJ
(
sheet
.
getRow
(
r
).
getCell
(
31
).
getStringCellValue
());
invoice
.
setRZJG
(
sheet
.
getRow
(
r
).
getCell
(
32
).
getStringCellValue
());
invoice
.
setCJSJ
(
sheet
.
getRow
(
r
).
getCell
(
34
).
getStringCellValue
());
...
...
@@ -172,7 +172,7 @@ public class DataInitTest extends CommonIT {
@Test
public
void
initOutput
()
throws
Exception
{
Workbook
workbook
=
WorkbookFactory
.
create
(
new
File
(
"C:\\Users\\Eddie Wu\\Desktop\\导入
/导入模板_销项主表_绿能_201809(1)
.xlsx"
));
Workbook
workbook
=
WorkbookFactory
.
create
(
new
File
(
"C:\\Users\\Eddie Wu\\Desktop\\导入
\\进销项/导入模板_销项主表_绿能_201809
.xlsx"
));
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
for
(
int
r
=
1
;
r
<=
sheet
.
getLastRowNum
();
r
++)
{
try
{
...
...
@@ -184,7 +184,7 @@ public class DataInitTest extends CommonIT {
}
OutputInvoice
outputInvoice
=
new
OutputInvoice
();
outputInvoice
.
setID
(
CommonUtils
.
getUUID
());
outputInvoice
.
setFPQQLSH
(
CommonUtils
.
getUUID
());
outputInvoice
.
setFPQQLSH
(
sheet
.
getRow
(
r
).
getCell
(
1
).
getStringCellValue
());
outputInvoice
.
setFPDM
(
sheet
.
getRow
(
r
).
getCell
(
2
).
getStringCellValue
());
outputInvoice
.
setFPHM
(
sheet
.
getRow
(
r
).
getCell
(
3
).
getStringCellValue
());
outputInvoice
.
setKPRQ
(
sheet
.
getRow
(
r
).
getCell
(
4
).
getStringCellValue
());
...
...
@@ -202,7 +202,52 @@ public class DataInitTest extends CommonIT {
outputInvoice
.
setJSHJ
(
sheet
.
getRow
(
r
).
getCell
(
35
).
getStringCellValue
());
// outputInvoice.setSLV(sheet.getRow(r).getCell(42).getStringCellValue());
// outputInvoice.setHTBH(sheet.getRow(r).getCell(54).getStringCellValue());
outputInvoiceMapper
.
insertSelective
(
outputInvoice
);
OutputInvoiceExample
example
=
new
OutputInvoiceExample
();
example
.
createCriteria
().
andFPDMEqualTo
(
outputInvoice
.
getFPDM
()).
andFPHMEqualTo
(
outputInvoice
.
getFPHM
());
if
(
outputInvoiceMapper
.
selectByExample
(
example
).
size
()
>
0
)
{
outputInvoiceMapper
.
updateByExampleSelective
(
outputInvoice
,
example
);
}
else
{
outputInvoiceMapper
.
insertSelective
(
outputInvoice
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
System
.
out
.
println
(
"end"
);
}
@Test
public
void
initOutputDetail
()
throws
Exception
{
Workbook
workbook
=
WorkbookFactory
.
create
(
new
File
(
"C:\\Users\\Eddie Wu\\Desktop\\导入\\进销项/导入模板_销项明细_绿能_201809.xlsx"
));
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
for
(
int
r
=
1
;
r
<=
sheet
.
getLastRowNum
();
r
++)
{
try
{
for
(
int
c
=
0
;
c
<=
sheet
.
getRow
(
r
).
getLastCellNum
();
c
++)
{
Cell
cell
=
sheet
.
getRow
(
r
).
getCell
(
c
);
if
(
null
!=
cell
)
{
cell
.
setCellType
(
CellType
.
STRING
);
}
}
OutputInvoiceDetail
detail
=
new
OutputInvoiceDetail
();
detail
.
setID
(
CommonUtils
.
getUUID
());
detail
.
setFPQQLSH
(
sheet
.
getRow
(
r
).
getCell
(
1
).
getStringCellValue
());
detail
.
setSPMC
(
sheet
.
getRow
(
r
).
getCell
(
2
).
getStringCellValue
());
detail
.
setGGXH
(
sheet
.
getRow
(
r
).
getCell
(
3
).
getStringCellValue
());
detail
.
setDW
(
sheet
.
getRow
(
r
).
getCell
(
4
).
getStringCellValue
());
detail
.
setDJ
(
sheet
.
getRow
(
r
).
getCell
(
5
).
getStringCellValue
());
detail
.
setSL
(
sheet
.
getRow
(
r
).
getCell
(
6
).
getStringCellValue
());
detail
.
setJE
(
sheet
.
getRow
(
r
).
getCell
(
7
).
getStringCellValue
());
detail
.
setSLV
(
sheet
.
getRow
(
r
).
getCell
(
8
).
getStringCellValue
());
detail
.
setSE
(
sheet
.
getRow
(
r
).
getCell
(
9
).
getStringCellValue
());
detail
.
setMXXH
(
NumberUtils
.
createBigDecimal
(
sheet
.
getRow
(
r
).
getCell
(
15
).
getStringCellValue
()));
detail
.
setFPHXZ
(
sheet
.
getRow
(
r
).
getCell
(
16
).
getStringCellValue
());
OutputInvoiceDetailExample
example
=
new
OutputInvoiceDetailExample
();
example
.
createCriteria
().
andFPQQLSHEqualTo
(
detail
.
getFPQQLSH
());
if
(
outputInvoiceDetailMapper
.
selectByExample
(
example
).
size
()
>
0
)
{
outputInvoiceDetailMapper
.
updateByExampleSelective
(
detail
,
example
);
}
else
{
outputInvoiceDetailMapper
.
insertSelective
(
detail
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
atms-dao/src/main/java/pwc/taxtech/atms/dao/FormulaAdminMapper.java
View file @
e6927810
...
...
@@ -6,37 +6,43 @@ import org.apache.ibatis.annotations.Select;
import
pwc.taxtech.atms.MyMapper
;
import
pwc.taxtech.atms.dpo.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dpo.GroupId
;
import
pwc.taxtech.atms.entity.Project
;
import
java.util.List
;
@Mapper
public
interface
FormulaAdminMapper
extends
MyMapper
{
@Select
(
"SELECT "
+
" cell_template.id AS cellTemplateID, "
+
" template.id AS reportTemplateID, "
+
" template.template_group_id AS reportTemplateGroupID, "
+
" cell_template.row_index AS rowIndex, "
+
" cell_template.column_index AS columnIndex, "
+
" template.Code AS reportCode, "
+
" cell_template.column_name AS columnName, "
+
" cell_template.row_name AS rowName, "
+
" cell_template.data_type AS resultType "
+
"FROM "
+
" template "
+
" JOIN "
+
" cell_template ON template.id = cell_template.report_template_id "
+
"WHERE "
+
" template.id IN ( "
+
" SELECT "
+
" ID "
+
" FROM "
+
" TEMPLATE "
+
" WHERE "
+
" TEMPLATE_GROUP_ID = #{groupId} "
+
" AND IS_ACTIVE_ASSOCIATION = 1 "
+
" )"
)
List
<
CellTemplatePerGroupDto
>
getCellTemplatePerGroupDto
(
@Param
(
"groupId"
)
Long
groupId
);
@Select
(
""
+
"SELECT "
+
" cell_template.CELL_TEMPLATE_ID AS cellTemplateID, "
+
" template.TEMPLATE_ID AS reportTemplateID, "
+
" template.template_group_id AS reportTemplateGroupID, "
+
" cell_template.row_index AS rowIndex, "
+
" cell_template.column_index AS columnIndex, "
+
" template.Code AS reportCode, "
+
" cell_template.column_name AS columnName, "
+
" cell_template.row_name AS rowName, "
+
" cell_template.data_type AS resultType "
+
"FROM "
+
" period_template template "
+
" JOIN period_cell_template cell_template ON template.TEMPLATE_ID = cell_template.report_template_id "
+
"WHERE "
+
" template.TEMPLATE_ID IN ( SELECT TEMPLATE_ID FROM period_template WHERE TEMPLATE_GROUP_ID = #{templateGroupId} "
+
" AND IS_ACTIVE_ASSOCIATION = 1 AND CODE = #{code} ) "
+
" AND ROW_INDEX = #{rowIndex} "
+
" AND COLUMN_INDEX = #{columnIndex} "
+
" AND template.PROJECT_ID = #{projectId} "
+
" AND template.PERIOD = #{period} "
+
" AND cell_template.PROJECT_ID = #{projectId} "
+
" AND cell_template.PERIOD = #{period}"
+
""
)
List
<
CellTemplatePerGroupDto
>
getCellTemplatePerGroupDto
(
@Param
(
"templateGroupId"
)
Long
templateGroupId
,
@Param
(
"code"
)
String
code
,
@Param
(
"rowIndex"
)
Integer
rowIndex
,
@Param
(
"columnIndex"
)
Integer
columnIndex
,
@Param
(
"projectId"
)
String
projectId
,
@Param
(
"period"
)
Integer
period
);
@Select
(
"SELECT "
+
...
...
@@ -64,4 +70,17 @@ public interface FormulaAdminMapper extends MyMapper {
" AND ROWNUM=1"
+
"ORDER BY ps.Service_Type_ID "
)
String
getPastProjectId
(
@Param
(
"year"
)
int
year
,
@Param
(
"orgId"
)
String
organizationId
);
@Select
(
""
+
"SELECT "
+
" p.ID AS id, "
+
" p.CODE AS code, "
+
" p.NAME AS name, "
+
" p.ORGANIZATION_ID AS organizationId "
+
"FROM "
+
" PROJECT p "
+
" JOIN ( SELECT CODE, ORGANIZATION_ID FROM PROJECT WHERE ID = #{projectId} ) t ON p.CODE = t.CODE "
+
" AND p.ORGANIZATION_ID = t.ORGANIZATION_ID AND p.YEAR = #{year}"
+
""
)
Project
getFixedProject
(
@Param
(
"projectId"
)
String
projectId
,
@Param
(
"year"
)
Integer
year
);
}
atms-dao/src/main/java/pwc/taxtech/atms/vat/dao/CellDataMapper.java
View file @
e6927810
...
...
@@ -2,15 +2,12 @@ package pwc.taxtech.atms.vat.dao;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.session.RowBounds
;
import
pwc.taxtech.atms.MyVatMapper
;
import
pwc.taxtech.atms.vat.entity.CellData
;
import
pwc.taxtech.atms.vat.entity.CellDataExample
;
import
pwc.taxtech.atms.vat.entity.PCTEntity
;
import
java.util.List
;
import
java.util.Set
;
@Mapper
public
interface
CellDataMapper
extends
MyVatMapper
{
...
...
@@ -110,19 +107,4 @@ public interface CellDataMapper extends MyVatMapper {
*/
int
updateByPrimaryKey
(
CellData
record
);
@Select
(
"<script>"
+
"SELECT "
+
" R.PERIOD, C.CELL_TEMPLATE_ID AS CELLTEMPLATEID, DATA "
+
"FROM "
+
" CELL_DATA C, "
+
" REPORT R "
+
"WHERE "
+
" C.REPORT_ID = R.ID AND "
+
" "
+
" <foreach item=\"item\" index=\"index\" collection=\"list\""
+
" open=\"(\" separator=\"OR\" close=\")\">"
+
" ( R.PERIOD=#{item.period} AND C.CELL_TEMPLATE_ID=#{item.cellTemplateId} )"
+
" </foreach>"
+
"</script>"
)
List
<
PCTEntity
>
queryByPCTs
(
@Param
(
"list"
)
Set
<
PCTEntity
>
parameter
);
}
\ No newline at end of file
atms-dao/src/main/java/pwc/taxtech/atms/vat/dao/PeriodCellDataMapper.java
View file @
e6927810
...
...
@@ -2,16 +2,12 @@ package pwc.taxtech.atms.vat.dao;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.session.RowBounds
;
import
pwc.taxtech.atms.MyVatMapper
;
import
pwc.taxtech.atms.vat.dpo.MergerManaualCellData
;
import
pwc.taxtech.atms.vat.entity.PCTEntity
;
import
pwc.taxtech.atms.vat.entity.PeriodCellData
;
import
pwc.taxtech.atms.vat.entity.PeriodCellDataExample
;
import
java.util.List
;
import
java.util.Set
;
@Mapper
public
interface
PeriodCellDataMapper
extends
MyVatMapper
{
...
...
@@ -111,51 +107,5 @@ public interface PeriodCellDataMapper extends MyVatMapper {
*/
int
updateByPrimaryKey
(
PeriodCellData
record
);
int
batchInsert2
(
List
<
PeriodCellData
>
list
);
int
batchInsert
(
List
<
PeriodCellData
>
list
);
@Select
(
"<script>"
+
"SELECT "
+
" count( pcds.DATA_SOURCE_ID ) AS dsCount, "
+
" pcd.ID as cellId, "
+
" pcd.DATA as data, "
+
" pcd.FORMULA_EXP as formulaExp, "
+
" pcd.CELL_TEMPLATE_ID as cellTemplateId, "
+
" pcd.PERIOD as period, "
+
" temp.AMOUNT as amount "
+
"FROM "
+
" PERIOD_CELL_DATA pcd "
+
" JOIN PERIOD_CELL_DATA_SOURCE pcds ON pcd.ID = pcds.CELL_DATA_ID "
+
" LEFT JOIN ( "
+
" SELECT "
+
" pcd.ID, "
+
" pds.TYPE, "
+
" pds.AMOUNT, "
+
" pds.PERIOD, "
+
" pds.PROJECT_ID "
+
" FROM "
+
" PERIOD_CELL_DATA pcd "
+
" JOIN PERIOD_CELL_DATA_SOURCE pcds ON pcd.ID = pcds.CELL_DATA_ID "
+
" JOIN PERIOD_DATA_SOURCE pds ON pcds.DATA_SOURCE_ID = pds.ID "
+
" WHERE "
+
" pcd.PROJECT_ID = #{projectId} "
+
" AND pds.TYPE = 10 "
+
" ) temp ON pcd.ID = temp.ID AND pcd.PROJECT_ID = temp.PROJECT_ID and pcd.PERIOD = temp.period "
+
"WHERE "
+
" pcd.PERIOD = 10 "
+
" AND pcd.PROJECT_ID = #{projectId} AND "
+
" <foreach item=\"item\" index=\"index\" collection=\"list\""
+
" open=\"(\" separator=\"OR\" close=\")\">"
+
" ( pcd.PERIOD=#{item.period} AND pcd.CELL_TEMPLATE_ID=#{item.cellTemplateId} )"
+
" </foreach>"
+
"GROUP BY "
+
" pcd.ID, "
+
" pcd.DATA, "
+
" pcd.FORMULA_EXP, "
+
" pcd.CELL_TEMPLATE_ID, "
+
" pcd.PERIOD, "
+
" temp.AMOUNT"
+
"</script>"
)
List
<
PCTEntity
>
queryByPCTs
(
@Param
(
"list"
)
Set
<
PCTEntity
>
parameter
,
@Param
(
"projectId"
)
String
projectId
);
}
\ No newline at end of file
atms-dao/src/main/java/pwc/taxtech/atms/vat/entity/PCTEntity.java
deleted
100644 → 0
View file @
3a20ec59
package
pwc
.
taxtech
.
atms
.
vat
.
entity
;
public
class
PCTEntity
{
Integer
period
;
Long
cellTemplateId
;
String
data
;
String
formulaExp
;
Long
cellId
;
String
amount
;
Integer
dsCount
;
public
PCTEntity
()
{
}
public
PCTEntity
(
String
pctStr
)
{
String
[]
pct
=
pctStr
.
split
(
":"
);
this
.
period
=
Integer
.
parseInt
(
pct
[
0
]);
this
.
cellTemplateId
=
Long
.
parseLong
(
pct
[
1
]);
}
@Override
public
int
hashCode
()
{
return
(
period
+
""
+
cellTemplateId
).
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
PCTEntity
target
=
(
PCTEntity
)
obj
;
return
period
.
intValue
()
==
target
.
period
.
intValue
()
&&
cellTemplateId
.
longValue
()
==
target
.
cellTemplateId
.
longValue
();
}
public
Integer
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
Integer
period
)
{
this
.
period
=
period
;
}
public
Long
getCellTemplateId
()
{
return
cellTemplateId
;
}
public
void
setCellTemplateId
(
Long
cellTemplateId
)
{
this
.
cellTemplateId
=
cellTemplateId
;
}
public
String
getData
()
{
return
data
;
}
public
void
setData
(
String
data
)
{
this
.
data
=
data
;
}
public
String
getFormulaExp
()
{
return
formulaExp
;
}
public
void
setFormulaExp
(
String
formulaExp
)
{
this
.
formulaExp
=
formulaExp
;
}
public
Long
getCellId
()
{
return
cellId
;
}
public
void
setCellId
(
Long
cellId
)
{
this
.
cellId
=
cellId
;
}
public
String
getAmount
()
{
return
amount
;
}
public
void
setAmount
(
String
amount
)
{
this
.
amount
=
amount
;
}
public
Integer
getDsCount
()
{
return
dsCount
;
}
public
void
setDsCount
(
Integer
dsCount
)
{
this
.
dsCount
=
dsCount
;
}
}
atms-dao/src/main/resources/pwc/taxtech/atms/invoice/extends/OutputInvoiceExtendsMapper.xml
View file @
e6927810
...
...
@@ -284,7 +284,7 @@
JOIN
OUTPUT_INVOICE_DETAIL INVOICEDETAIL
ON
INVOICE.FPQQLSH = INVOICEDETAIL.FPQQLSH
INVOICE.FPQQLSH = INVOICEDETAIL.FPQQLSH
and INVOICE.FPZT != '1'
ORDER BY
INVOICE.FPHM
</select>
...
...
atms-invoice/restart.sh
deleted
100755 → 0
View file @
3a20ec59
kill
-9
`
ps
-ef
|grep java |
grep
atms-invoice |
awk
'{print $2}'
`
nohup
mvn clean spring-boot:run &
atms-web/src/main/webapp/app/common/controls/preview-trial-balance/preview-trial-balance.ctrl.js
View file @
e6927810
...
...
@@ -182,6 +182,17 @@
if
(
treeData
&&
treeData
.
calculateData
)
{
treeData
.
calculateData
.
TitleName
=
$translate
.
instant
(
'Total'
);
$scope
.
subtotals
=
treeData
.
calculateData
;
var
tmp
=
parseInt
(
$scope
.
subtotals
.
begDebitBal
.
replace
(
/
\,
/g
,
''
))
-
parseInt
(
$scope
.
subtotals
.
begCreditBal
.
replace
(
/
\,
/g
,
''
))
+
parseInt
(
$scope
.
subtotals
.
debitBal
.
replace
(
/
\,
/g
,
''
))
-
parseInt
(
$scope
.
subtotals
.
creditBal
.
replace
(
/
\,
/g
,
''
))
-
parseInt
(
$scope
.
subtotals
.
endDebitBal
.
replace
(
/
\,
/g
,
''
))
+
parseInt
(
$scope
.
subtotals
.
endCreditBal
.
replace
(
/
\,
/g
,
''
));
if
(
0
!==
tmp
)
{
swal
({
title
:
$translate
.
instant
(
'WarningTitle'
),
text
:
'试算平衡表金额不平衡!差异:'
+
tmp
,
type
:
"warning"
,
confirmButtonText
:
$translate
.
instant
(
'Confirm'
)
});
}
}
$
(
'.filter-button'
).
popover
(
"hide"
);
...
...
atms-web/src/main/webapp/app/common/controls/vat-report-view/vat-report-view.html
View file @
e6927810
...
...
@@ -6,8 +6,8 @@
class=
"fa fa-floppy-o"
></i>
{{'报表提审'}}
</span>
<span
ng-if=
"!isBSPL"
ng-click=
"doApprove();"
><i
class=
"fa fa-floppy-o"
></i>
{{'报表审批'}}
</span>
<
span
ng-if=
"!isBSPL"
ng-click=
"saveReportCache();"
><i
class=
"fa fa-floppy-o"
></i>
{{'Save' | translate}}
</span
>
<
!--<span ng-if="!isBSPL" ng-click="saveReportCache();"><i-->
<!--class="fa fa-floppy-o"></i> {{'Save' | translate}}</span>--
>
</div>
<div
class=
'report-container'
id=
"reportContainer"
>
...
...
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