Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
platform
/
finance_serv
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 641a032e
authored
Sep 17, 2018
by
王军业
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[分权限导入]
1 parent
272550b1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
3 deletions
code/finance_serv/src/main/java/com/vion/financial/constant/ColumnExample.java
code/finance_serv/src/main/java/com/vion/financial/controller/ContractController.java
code/finance_serv/src/main/java/com/vion/financial/handler/ImportExcel.java
code/finance_serv/src/main/java/com/vion/financial/service/ContractService.java
code/finance_serv/src/main/java/com/vion/financial/service/imp/ContractServiceImpl.java
code/finance_serv/src/main/java/com/vion/financial/constant/ColumnExample.java
0 → 100644
View file @
641a032
package
com
.
vion
.
financial
.
constant
;
public
class
ColumnExample
{
/**
* 商务部
*/
public
static
String
[]
rank1
=
{
"合同编号"
,
"签订日期"
,
"产品线类型"
,
"销售员"
,
"省"
,
"市"
,
"县"
,
"客户名称"
,
"项目名称"
,
"合同金额"
,
"质保周期"
,
"合同性质"
,
"维保服务期开始节点"
,
"维保服务期结束节点"
};
/**
* 财务部
*/
public
static
String
[]
rank2
=
{
"合同编号"
,
"暂停金额"
,
"坏账金额"
,
"豁免金额"
,
"折扣金额"
,
"合同状态"
,
"回款金额"
,
"回款日期"
,
"回款备注"
,
"开票金额"
,
"开票OA流水号"
,
"开票备注"
,
"是否归档"
,
"确认收入金额"
,
"账款状态"
,
"折扣金额备注"
,
"暂停金额备注"
,
"豁免金额备注"
,
"坏账金额备注"
,
"合同备注"
,
"预付款天数"
,
"预付款比例"
,
"预付款条件"
,
"到货款天数"
,
"到货款比例"
,
"到货款付款条件"
,
"验收款天数"
,
"验收款比例"
,
"验收款付款条件"
,
"质保款天数"
,
"质保款比例"
,
"质保款付款条件"
,
"质保款类型"
};
/**
* 生产部
*/
public
static
String
[]
rank3
=
{
"合同编号"
,
"发货日期"
,
"到货验收时间"
};
/**
* 工程部
*/
public
static
String
[]
rank4
=
{
"合同编号"
,
"初验"
,
"初验日期"
,
"初验备注"
,
"终验"
,
"终验日期"
,
"终验备注"
};
}
code/finance_serv/src/main/java/com/vion/financial/controller/ContractController.java
View file @
641a032
...
...
@@ -110,7 +110,7 @@ public class ContractController extends BaseController {
@PostMapping
(
value
=
"/import"
)
@ResponseBody
public
Object
importExcel
(
@RequestParam
(
"file"
)
MultipartFile
file
,
String
ranke
)
{
return
contractService
.
importExcel
(
file
);
return
contractService
.
importExcel
(
file
,
ranke
);
}
}
code/finance_serv/src/main/java/com/vion/financial/handler/ImportExcel.java
View file @
641a032
...
...
@@ -2,12 +2,18 @@ package com.vion.financial.handler;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.vion.financial.constant.ColumnExample
;
import
com.vion.financial.excel.ImportModel
;
import
cn.afterturn.easypoi.excel.ExcelImportUtil
;
...
...
@@ -49,4 +55,53 @@ public class ImportExcel {
return
list
;
}
public
Boolean
IsIlegal
(
MultipartFile
file
,
String
ranke
)
throws
Exception
{
Boolean
isIlegal
=
false
;
String
[]
columns
=
null
;
ImportParams
importParams
=
new
ImportParams
();
IExcelDataHandler
<
ImportModel
>
handle
=
new
ImportHandle
();
handle
.
setNeedHandlerFields
(
new
String
[]
{
"合同编号"
});
importParams
.
setDataHanlder
(
handle
);
importParams
.
setNeedVerfiy
(
true
);
ExcelImportResult
<
Map
>
result
=
ExcelImportUtil
.
importExcelMore
(
file
.
getInputStream
(),
Map
.
class
,
importParams
);
switch
(
ranke
)
{
case
"1"
:
columns
=
ColumnExample
.
rank1
;
break
;
case
"2"
:
columns
=
ColumnExample
.
rank2
;
break
;
case
"3"
:
columns
=
ColumnExample
.
rank3
;
break
;
case
"4"
:
columns
=
ColumnExample
.
rank4
;
break
;
default
:
break
;
}
List
<
Map
>
successList
=
result
.
getList
();
if
(
successList
!=
null
&&
successList
.
size
()
>
0
)
{
Map
<
String
,
Object
>
headerTitle
=
successList
.
get
(
0
);
if
(
headerTitle
.
size
()==
columns
.
length
)
{
Set
<
String
>
hashColumns
=
new
HashSet
<
String
>(
Arrays
.
asList
(
columns
));
if
(
hashColumns
==
headerTitle
)
{
isIlegal
=
true
;
}
}
/* for(String key : headerTitle.keySet()) {
System.out.println("kry=" + key);
}*/
}
/* List<Map> failList=result.getFailList();
List<List<Map>> list = new ArrayList<List<Map>>(2);
list.add(successList);
list.add(failList);
return list;*/
return
isIlegal
;
}
}
code/finance_serv/src/main/java/com/vion/financial/service/ContractService.java
View file @
641a032
...
...
@@ -16,5 +16,5 @@ public interface ContractService {
Boolean
isDelete
(
String
s
);
Object
selectByCondition
(
SelectVo
selectVo
);
void
exportExcel
(
SelectVo
selectVo
,
HttpServletResponse
response
);
Object
importExcel
(
MultipartFile
file
);
Object
importExcel
(
MultipartFile
file
,
String
ranke
);
}
code/finance_serv/src/main/java/com/vion/financial/service/imp/ContractServiceImpl.java
View file @
641a032
...
...
@@ -531,13 +531,18 @@ public class ContractServiceImpl implements ContractService {
@Override
public
Object
importExcel
(
MultipartFile
file
)
{
public
Object
importExcel
(
MultipartFile
file
,
String
ranke
)
{
logger
.
info
(
"========================导入合同Excel表格==========================="
);
//ImportExcel importExcel = new ImportExcel();
try
{
ImportExcel
importExcel
=
new
ImportExcel
();
if
(!
importExcel
.
IsIlegal
(
file
,
ranke
))
{
failCode
.
setEcode
(
"500"
);
failCode
.
setEnote
(
"导入异常"
);
return
failCode
;
}
List
<
List
<
ImportModel
>>
list
=
importExcel
.
Import
(
file
);
String
s
=
"s"
;
if
(
importExcel
.
flag
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment