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
aef2ca5c
Commit
aef2ca5c
authored
Feb 19, 2019
by
zhkwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CIT固定资产-资产清单补充及优化以及部分导入工具类
parent
15fef97a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
73 deletions
+114
-73
AssetListServiceImpl.java
...a/pwc/taxtech/atms/service/impl/AssetListServiceImpl.java
+34
-72
CitCommonUtil.java
...ain/java/pwc/taxtech/atms/service/impl/CitCommonUtil.java
+55
-0
FileService.java
.../main/java/pwc/taxtech/atms/service/impl/FileService.java
+23
-0
MenuServiceImpl.java
...n/java/pwc/taxtech/atms/service/impl/MenuServiceImpl.java
+1
-0
app-data-import.html
...webapp/app/framework/app-data-import/app-data-import.html
+1
-1
No files found.
atms-api/src/main/java/pwc/taxtech/atms/service/impl/AssetListServiceImpl.java
View file @
aef2ca5c
...
@@ -146,41 +146,29 @@ public class AssetListServiceImpl extends BaseService {
...
@@ -146,41 +146,29 @@ public class AssetListServiceImpl extends BaseService {
*/
*/
public
OperationResultDto
assetsImport
(
InputStream
inputStream
,
String
fileName
,
String
projectId
)
throws
IOException
,
InvalidFormatException
,
ParseException
{
public
OperationResultDto
assetsImport
(
InputStream
inputStream
,
String
fileName
,
String
projectId
)
throws
IOException
,
InvalidFormatException
,
ParseException
{
logger
.
debug
(
"导入excel文件开始"
);
logger
.
debug
(
"导入excel文件开始"
);
String
filePath
=
FileUtils
.
getTempDirectory
().
getAbsolutePath
()
+
File
.
separator
+
"citAsset"
+
File
.
separator
//定义返回变量
+
CommonUtils
.
getUUID
()
+
"_"
+
fileName
;
OperationResultDto
<
Object
>
importResult
=
new
OperationResultDto
<>();
//保存导入的文件
OperationResultDto
<
Object
>
saveResult
=
fileService
.
saveFile
(
inputStream
,
filePath
);
//判断是否成功导入
if
(
saveResult
.
getResult
()
!=
null
&&
!
saveResult
.
getResult
())
{
return
saveResult
;
}
//获取保存文件的输入流
InputStream
newInputStream
=
Files
.
findFileAsStream
(
filePath
);
//用CustomerController中的方法获取Excel文件的数据
// Collection<Map> excelMapCollection = fileService.readExcelAndClose(newInputStream);
//通过输入流获取当前workbook
//通过输入流获取当前workbook
Workbook
workbook
=
WorkbookFactory
.
create
(
newInputStream
);
Workbook
workbook
=
fileService
.
getWorkbook
(
inputStream
,
fileName
,
"citAsset"
);
if
(
workbook
==
null
){
importResult
.
setResult
(
false
);
importResult
.
setResultMsg
(
"读取Excel出现内部错误"
);
return
importResult
;
}
//目前资产导入只有一个Sheet页,所以只取第一个Sheet即可
//目前资产导入只有一个Sheet页,所以只取第一个Sheet即可
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
if
(
sheet
==
null
)
{
if
(
sheet
==
null
)
{
saveResult
.
setResult
(
false
);
importResult
.
setResult
(
false
);
return
saveResult
;
importResult
.
setResultMsg
(
"读取Excel出现内部错误"
);
return
importResult
;
}
}
//在循环取数据外定义资产类别map,防止map重新定义,不能过滤重复资产类别
//在循环取数据外定义资产类别map,防止map重新定义,不能过滤重复资产类别
Set
assetNameSet
=
new
HashSet
();
Set
assetNameSet
=
new
HashSet
();
List
<
CitAssetGroupResult
>
citAssetGroupResults
=
selectGroupResult
(
projectId
);
List
<
CitAssetGroupResult
>
citAssetGroupResults
=
selectGroupResult
(
projectId
);
//计算当前期间
Calendar
now
=
Calendar
.
getInstance
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
now
.
get
(
Calendar
.
YEAR
));
if
(
now
.
get
(
Calendar
.
MONTH
)
+
1
<
10
){
sb
.
append
(
0
);
}
sb
.
append
(
now
.
get
(
Calendar
.
MONTH
)
+
1
);
StringBuilder
periodSb
=
CitCommonUtil
.
getPeriod
();
List
<
CitAssetsList
>
citAssetsLists
=
new
ArrayList
<>();
List
<
CitAssetsList
>
citAssetsLists
=
new
ArrayList
<>();
StringBuilder
errorMsgSb
=
new
StringBuilder
(
"第"
);
StringBuilder
errorMsgSb
=
new
StringBuilder
(
"第"
);
//通过循环来完成sheet获取每一行每一列数据并进行相关逻辑处理
//通过循环来完成sheet获取每一行每一列数据并进行相关逻辑处理
...
@@ -190,18 +178,18 @@ public class AssetListServiceImpl extends BaseService {
...
@@ -190,18 +178,18 @@ public class AssetListServiceImpl extends BaseService {
//赋值projectId
//赋值projectId
citAsset
.
setProjectId
(
projectId
);
citAsset
.
setProjectId
(
projectId
);
citAsset
.
setPeriod
(
Integer
.
valueOf
(
s
b
.
toString
()));
citAsset
.
setPeriod
(
Integer
.
valueOf
(
periodS
b
.
toString
()));
//获取该行数据
//获取该行数据
Row
rowData
=
sheet
.
getRow
(
rowNum
);
Row
rowData
=
sheet
.
getRow
(
rowNum
);
//因模板固定,则按照写死的做法处理数据单元格数据
//因模板固定,则按照写死的做法处理数据单元格数据
citAsset
=
cellToCitAsset
(
rowData
,
citAsset
,
assetNameSet
,
citAssetGroupResults
);
citAsset
=
cellToCitAsset
(
rowData
,
citAsset
,
assetNameSet
,
citAssetGroupResults
);
if
(
citAsset
==
null
){
if
(
citAsset
==
null
){
save
Result
.
setResult
(
false
);
import
Result
.
setResult
(
false
);
errorMsgSb
.
append
(
rowNum
+
","
);
errorMsgSb
.
append
(
rowNum
+
","
);
}
}
if
(!
save
Result
.
getResult
()){
if
(!
import
Result
.
getResult
()){
save
Result
.
setResultMsg
(
"行数据为空或格式错误!"
);
import
Result
.
setResultMsg
(
"行数据为空或格式错误!"
);
}
}
//目前没有进行税法分类,标注状态
//目前没有进行税法分类,标注状态
citAsset
.
setStatus
(
0
);
citAsset
.
setStatus
(
0
);
...
@@ -224,12 +212,12 @@ public class AssetListServiceImpl extends BaseService {
...
@@ -224,12 +212,12 @@ public class AssetListServiceImpl extends BaseService {
CitAssetGroupResult
citAssetGroupResult
=
new
CitAssetGroupResult
();
CitAssetGroupResult
citAssetGroupResult
=
new
CitAssetGroupResult
();
citAssetGroupResult
.
setId
(
idService
.
nextId
());
citAssetGroupResult
.
setId
(
idService
.
nextId
());
citAssetGroupResult
.
setProjectId
(
projectId
);
citAssetGroupResult
.
setProjectId
(
projectId
);
citAssetGroupResult
.
setPeriod
(
Integer
.
valueOf
(
s
b
.
toString
()));
citAssetGroupResult
.
setPeriod
(
Integer
.
valueOf
(
periodS
b
.
toString
()));
citAssetGroupResult
.
setAssetName
(
it
.
next
());
citAssetGroupResult
.
setAssetName
(
it
.
next
());
assetGroupResultMapper
.
insertSelective
(
citAssetGroupResult
);
assetGroupResultMapper
.
insertSelective
(
citAssetGroupResult
);
}
}
save
Result
.
setResult
(
true
);
import
Result
.
setResult
(
true
);
return
save
Result
;
return
import
Result
;
}
}
/**
/**
...
@@ -243,58 +231,58 @@ public class AssetListServiceImpl extends BaseService {
...
@@ -243,58 +231,58 @@ public class AssetListServiceImpl extends BaseService {
//获取资产编号
//获取资产编号
Cell
cell
=
rowData
.
getCell
(
1
);
Cell
cell
=
rowData
.
getCell
(
1
);
Object
value
=
getValue
(
cell
);
Object
value
=
CitCommonUtil
.
getValue
(
cell
);
if
(
value
==
null
)
{
if
(
value
==
null
)
{
return
null
;
return
null
;
}
}
citAsset
.
setAssetNumber
(
value
.
toString
());
citAsset
.
setAssetNumber
(
value
.
toString
());
//获取资产描述
//获取资产描述
citAsset
.
setAssetDescription
(
getValue
(
rowData
.
getCell
(
5
)).
toString
());
citAsset
.
setAssetDescription
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
5
)).
toString
());
//获取资产类别
//获取资产类别
String
assetName
=
getValue
(
rowData
.
getCell
(
7
)).
toString
();
String
assetName
=
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
7
)).
toString
();
citAsset
.
setAssetGroupName
(
assetName
);
citAsset
.
setAssetGroupName
(
assetName
);
//获取购入日期
//获取购入日期
Date
date
=
new
Date
();
Date
date
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
citAsset
.
setBuyDate
(
sdf
.
parse
(
getValue
(
rowData
.
getCell
(
15
)).
toString
()));
citAsset
.
setBuyDate
(
sdf
.
parse
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
15
)).
toString
()));
//获取开始折旧日期,DD没有提供,我们要根据购入日期和税法分类做预处理自己转化
//获取开始折旧日期,DD没有提供,我们要根据购入日期和税法分类做预处理自己转化
// citAsset.setDepreciationDate(sdf.parse(getValue(rowData.getCell(15)).toString()));
// citAsset.setDepreciationDate(sdf.parse(
CitCommonUtil.
getValue(rowData.getCell(15)).toString()));
//获取折旧期限,接下来计算需要用到,所以赋给一个对象
//获取折旧期限,接下来计算需要用到,所以赋给一个对象
Integer
depreciationPeriod
=
Integer
.
valueOf
(
getValue
(
rowData
.
getCell
(
30
)).
toString
());
Integer
depreciationPeriod
=
Integer
.
valueOf
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
30
)).
toString
());
citAsset
.
setDepreciationPeriod
(
depreciationPeriod
);
citAsset
.
setDepreciationPeriod
(
depreciationPeriod
);
//获取原值,接下来计算需要用到,所以赋给一个对象
//获取原值,接下来计算需要用到,所以赋给一个对象
BigDecimal
acquisitionValue
=
new
BigDecimal
(
getValue
(
rowData
.
getCell
(
16
)).
toString
());
BigDecimal
acquisitionValue
=
new
BigDecimal
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
16
)).
toString
());
citAsset
.
setAcquisitionValue
(
acquisitionValue
);
citAsset
.
setAcquisitionValue
(
acquisitionValue
);
//获取原值调整值0----列数待定,滴滴无调整值
//获取原值调整值0----列数待定,滴滴无调整值
// citAsset.setAdjustmentValue(new BigDecimal(getValue(rowData.getCell(32)).toString()));
// citAsset.setAdjustmentValue(new BigDecimal(
CitCommonUtil.
getValue(rowData.getCell(32)).toString()));
//获取报废日期
//获取报废日期
Cell
cell1
=
rowData
.
getCell
(
37
);
Cell
cell1
=
rowData
.
getCell
(
37
);
if
(
rowData
.
getCell
(
37
)
!=
null
&&
getValue
(
rowData
.
getCell
(
37
))
!=
null
)
{
if
(
rowData
.
getCell
(
37
)
!=
null
&&
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
37
))
!=
null
)
{
citAsset
.
setDisposedDate
(
sdf
.
parse
(
getValue
(
rowData
.
getCell
(
37
)).
toString
()));
citAsset
.
setDisposedDate
(
sdf
.
parse
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
37
)).
toString
()));
}
}
//获取残值额,原为残值率现为残值额,接下来计算需要用到,所以赋给一个对象
//获取残值额,原为残值率现为残值额,接下来计算需要用到,所以赋给一个对象
BigDecimal
residualRate
=
new
BigDecimal
(
getValue
(
rowData
.
getCell
(
20
)).
toString
());
BigDecimal
residualRate
=
new
BigDecimal
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
20
)).
toString
());
citAsset
.
setResidualRate
(
residualRate
);
citAsset
.
setResidualRate
(
residualRate
);
//获取本年折旧额
//获取本年折旧额
citAsset
.
setYearDepreciationAmount
(
new
BigDecimal
(
getValue
(
rowData
.
getCell
(
24
)).
toString
()));
citAsset
.
setYearDepreciationAmount
(
new
BigDecimal
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
24
)).
toString
()));
// 获取本年调整额----列数待定 滴滴无本年调整额
// 获取本年调整额----列数待定 滴滴无本年调整额
// citAsset.setYearAdjustmentAmount(new BigDecimal(getValue(rowData.getCell(25)).toString()));
// citAsset.setYearAdjustmentAmount(new BigDecimal(
CitCommonUtil.
getValue(rowData.getCell(25)).toString()));
//获取财务原值---计算方法:原值+原值调整值,暂时不考虑调整值
//获取财务原值---计算方法:原值+原值调整值,暂时不考虑调整值
citAsset
.
setAccountAcquisitionValue
(
acquisitionValue
);
citAsset
.
setAccountAcquisitionValue
(
acquisitionValue
);
//获取财务每月折旧额----(原值-残值额)/折旧期限
//获取财务每月折旧额----(原值-残值额)/折旧期限
citAsset
.
setAccountMonthDepreciationAmount
(
acquisitionValue
.
subtract
(
residualRate
).
divide
(
new
BigDecimal
(
depreciationPeriod
),
2
));
citAsset
.
setAccountMonthDepreciationAmount
(
acquisitionValue
.
subtract
(
residualRate
).
divide
(
new
BigDecimal
(
depreciationPeriod
),
2
));
//获取财务本年折旧额
//获取财务本年折旧额
citAsset
.
setAccountYearDepreciationAmount
(
new
BigDecimal
(
getValue
(
rowData
.
getCell
(
24
)).
toString
()));
citAsset
.
setAccountYearDepreciationAmount
(
new
BigDecimal
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
24
)).
toString
()));
//获取财务累计折旧额,接下来计算需要用到,所以赋给一个对象
//获取财务累计折旧额,接下来计算需要用到,所以赋给一个对象
BigDecimal
accountTotalDepreciationAmount
=
new
BigDecimal
(
getValue
(
rowData
.
getCell
(
25
)).
toString
());
BigDecimal
accountTotalDepreciationAmount
=
new
BigDecimal
(
CitCommonUtil
.
getValue
(
rowData
.
getCell
(
25
)).
toString
());
citAsset
.
setAccountTotalDepreciationAmount
(
accountTotalDepreciationAmount
);
citAsset
.
setAccountTotalDepreciationAmount
(
accountTotalDepreciationAmount
);
//年终剩余价值,
//年终剩余价值,
citAsset
.
setYearEndValue
(
acquisitionValue
.
subtract
(
accountTotalDepreciationAmount
));
citAsset
.
setYearEndValue
(
acquisitionValue
.
subtract
(
accountTotalDepreciationAmount
));
...
@@ -314,32 +302,6 @@ public class AssetListServiceImpl extends BaseService {
...
@@ -314,32 +302,6 @@ public class AssetListServiceImpl extends BaseService {
return
citAsset
;
return
citAsset
;
}
}
/**
* 导入Excel时根据单元格类型获取单元格的值
* @param cell
* @return
*/
public
static
Object
getValue
(
Cell
cell
)
{
Object
obj
=
null
;
switch
(
cell
.
getCellTypeEnum
())
{
case
BOOLEAN:
obj
=
cell
.
getBooleanCellValue
();
break
;
case
ERROR:
obj
=
cell
.
getErrorCellValue
();
break
;
case
NUMERIC:
obj
=
cell
.
getNumericCellValue
();
break
;
case
STRING:
obj
=
cell
.
getStringCellValue
();
break
;
default
:
break
;
}
return
obj
;
}
/**
/**
* 根据projectId获取资产类别数据
* 根据projectId获取资产类别数据
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/CitCommonUtil.java
0 → 100644
View file @
aef2ca5c
package
pwc
.
taxtech
.
atms
.
service
.
impl
;
import
org.apache.poi.ss.usermodel.Cell
;
import
java.util.Calendar
;
/**
* @author ZhiKai Z Wei
*/
public
class
CitCommonUtil
{
/**
* 计算当前期间
* @return
*/
public
static
StringBuilder
getPeriod
(){
//计算当前期间
Calendar
now
=
Calendar
.
getInstance
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
now
.
get
(
Calendar
.
YEAR
));
if
(
now
.
get
(
Calendar
.
MONTH
)
+
1
<
10
){
sb
.
append
(
0
);
}
sb
.
append
(
now
.
get
(
Calendar
.
MONTH
)
+
1
);
return
sb
;
}
/**
* 导入Excel时根据单元格类型获取单元格的值
* @param cell
* @return
*/
public
static
Object
getValue
(
Cell
cell
)
{
Object
obj
=
null
;
switch
(
cell
.
getCellTypeEnum
())
{
case
BOOLEAN:
obj
=
cell
.
getBooleanCellValue
();
break
;
case
ERROR:
obj
=
cell
.
getErrorCellValue
();
break
;
case
NUMERIC:
obj
=
cell
.
getNumericCellValue
();
break
;
case
STRING:
obj
=
cell
.
getStringCellValue
();
break
;
default
:
break
;
}
return
obj
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/FileService.java
View file @
aef2ca5c
package
pwc
.
taxtech
.
atms
.
service
.
impl
;
package
pwc
.
taxtech
.
atms
.
service
.
impl
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.poi.openxml4j.exceptions.InvalidFormatException
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.usermodel.WorkbookFactory
;
import
org.apache.poi.ss.usermodel.WorkbookFactory
;
import
org.nutz.lang.Files
;
import
org.nutz.lang.Files
;
...
@@ -198,4 +203,22 @@ public class FileService {
...
@@ -198,4 +203,22 @@ public class FileService {
}
}
}
}
public
Workbook
getWorkbook
(
InputStream
inputStream
,
String
fileName
,
String
fileDir
)
throws
IOException
,
InvalidFormatException
{
String
filePath
=
FileUtils
.
getTempDirectory
().
getAbsolutePath
()
+
File
.
separator
+
fileDir
+
File
.
separator
+
CommonUtils
.
getUUID
()
+
"_"
+
fileName
;
//保存导入的文件
OperationResultDto
<
Object
>
saveResult
=
saveFile
(
inputStream
,
filePath
);
//判断是否成功导入
if
(
saveResult
.
getResult
()
!=
null
&&
!
saveResult
.
getResult
())
{
return
null
;
}
//获取保存文件的输入流
InputStream
newInputStream
=
Files
.
findFileAsStream
(
filePath
);
//通过输入流获取当前workbook
Workbook
workbook
=
WorkbookFactory
.
create
(
newInputStream
);
return
workbook
;
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/MenuServiceImpl.java
View file @
aef2ca5c
...
@@ -143,6 +143,7 @@ public class MenuServiceImpl {
...
@@ -143,6 +143,7 @@ public class MenuServiceImpl {
menuIds
.
add
(
"a9b1cd87-89ef-4dae-b798-b19e9bbe0821"
);
menuIds
.
add
(
"a9b1cd87-89ef-4dae-b798-b19e9bbe0821"
);
menuIds
.
add
(
"a9b1cd87-89ef-4dae-b798-b19e9bbe0822"
);
menuIds
.
add
(
"a9b1cd87-89ef-4dae-b798-b19e9bbe0822"
);
menuIds
.
add
(
"a9b1cd87-89ef-4dae-b798-b19e9bbe0823"
);
menuIds
.
add
(
"a9b1cd87-89ef-4dae-b798-b19e9bbe0823"
);
menuIds
.
add
(
"a9b1cd87-89ef-4dae-b798-b19e9bbe0824"
);
menuIds
.
add
(
"b8c74ee9-e5d7-467b-8565-e77efe6a499f"
);
menuIds
.
add
(
"b8c74ee9-e5d7-467b-8565-e77efe6a499f"
);
// List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList());
// List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList());
return
menuIds
;
return
menuIds
;
...
...
atms-web/src/main/webapp/app/framework/app-data-import/app-data-import.html
View file @
aef2ca5c
<div
id=
"app-data-import"
class=
"app-data-import "
>
<div
id=
"app-data-import"
class=
"app-data-import "
>
<nav
class=
"navbar navbar-custom"
role=
"navigation"
<nav
class=
"navbar navbar-custom"
role=
"navigation"
style=
"margin-bottom: 0; background-image:url(../../../app-resources/images/leftbarbg.png); height:
100%
;width: 260px"
>
style=
"margin-bottom: 0; background-image:url(../../../app-resources/images/leftbarbg.png); height:
auto
;width: 260px"
>
<div
class=
"sidebar navbarfix"
role=
"navigation"
>
<div
class=
"sidebar navbarfix"
role=
"navigation"
>
<div
class=
"sidebar-nav navbar-collapse"
id=
"sidebar-area"
style=
"height:100%;width: 260px"
>
<div
class=
"sidebar-nav navbar-collapse"
id=
"sidebar-area"
style=
"height:100%;width: 260px"
>
<div
class=
"app-data-import-side-bar"
style=
"height: 100%"
>
<div
class=
"app-data-import-side-bar"
style=
"height: 100%"
>
...
...
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