Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
manager
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
reyun
manager
Commits
1f63568c
Commit
1f63568c
authored
5 years ago
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合同导入
parent
a4666868
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
10 deletions
+100
-10
ContractServiceImpl.java
src/main/java/common/service/impl/ContractServiceImpl.java
+100
-10
合同模板.xlsx
src/main/resources/temp/upload/tkio/合同模板.xlsx
+0
-0
No files found.
src/main/java/common/service/impl/ContractServiceImpl.java
View file @
1f63568c
...
...
@@ -13,6 +13,8 @@ import dic.RoleEnum;
import
net.sf.json.JSONArray
;
import
org.apache.poi.ss.usermodel.*
;
import
org.joda.time.DateTime
;
import
org.joda.time.format.DateTimeFormat
;
import
org.joda.time.format.DateTimeFormatter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
...
...
@@ -2066,8 +2068,23 @@ public class ContractServiceImpl implements ContractService {
}
String
platform
=
SHEET_NAMES
.
get
(
sheetName
);
Map
<
String
,
Long
>
tradTypeMap
=
tradeTypeRepsitory
.
findAll
().
stream
().
collect
(
Collectors
.
toMap
(
TradeType:
:
getName
,
TradeType:
:
getId
));
Map
<
String
,
Long
>
salseMap
=
salesRepository
.
findSaleByStatus
(
0
).
stream
().
collect
(
Collectors
.
toMap
(
Sales:
:
getName
,
Sales:
:
getId
));
Map
<
String
,
Long
>
tradTypeMap
=
tradeTypeRepsitory
.
findAll
()
.
stream
().
collect
(
Collectors
.
toMap
(
TradeType:
:
getName
,
TradeType:
:
getId
));
Map
<
String
,
Long
>
salseMap
=
salesRepository
.
findSaleByStatus
(
0
)
.
stream
().
collect
(
Collectors
.
toMap
(
Sales:
:
getName
,
Sales:
:
getId
));
Map
<
String
,
Long
>
packageMap
=
null
;
if
(
"tkio"
.
equals
(
platform
)
||
"io"
.
equals
(
platform
))
{
packageMap
=
packageTypeRepository
.
findIsNewAll
()
.
stream
().
collect
(
Collectors
.
toMap
(
PackageType:
:
getPackageName
,
PackageType:
:
getId
));
}
else
{
packageMap
=
packageBaseRepository
.
findByPlatAndStatus
(
platform
,
1
)
.
stream
().
collect
(
Collectors
.
toMap
(
PackageBase:
:
getPackageName
,
PackageBase:
:
getId
));
}
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getName
,
ContractBody:
:
getCode
));
Row
row
=
sheet
.
getRow
(
0
);
if
(!
UPLOAD_TITLE
.
equals
(
parseRowData
(
row
,
row_length
,
null
)))
{
...
...
@@ -2078,9 +2095,15 @@ public class ContractServiceImpl implements ContractService {
int
rowNumber
=
sheet
.
getLastRowNum
();
List
<
Object
[]>
args_data
=
new
ArrayList
<>();
String
extend_row_sql
=
",platform,product,my_body_code"
;
int
extend_row
=
3
;
DateTimeFormatter
fmt
=
DateTimeFormat
.
forPattern
(
"yyyy/mm/dd"
);
for
(
int
j
=
1
;
j
<=
rowNumber
;
j
++)
{
Row
row_data
=
sheet
.
getRow
(
j
);
Object
[]
s_data
=
new
Object
[
row_length
];
Object
[]
s_data
=
new
Object
[
row_length
+
extend_row
];
String
bodyCode
=
null
;
for
(
int
w
=
0
;
w
<
row_length
;
w
++)
{
Cell
cell
=
row_data
.
getCell
(
w
);
if
(
null
!=
cell
&&
!
cell
.
getCellTypeEnum
().
equals
(
CellType
.
BLANK
))
{
...
...
@@ -2088,23 +2111,75 @@ public class ContractServiceImpl implements ContractService {
}
else
{
String
dataSTR
=
formatter
.
formatCellValue
(
cell
);
int
line_num
=
j
+
1
;
if
(
w
==
2
&&
!
tradTypeMap
.
containsKey
(
dataSTR
))
{
return
ResultModel
.
ERROR
(
"第"
+
(
j
+
1
)
+
"行[行业分类]错误"
);
}
else
if
(
w
==
5
&&
!
salseMap
.
containsKey
(
dataSTR
))
{
return
ResultModel
.
ERROR
(
"第"
+
(
j
+
1
)
+
"行[签约销售]错误"
);
if
(
w
==
0
)
{
if
(!
cBodyMap
.
containsKey
(
dataSTR
))
{
return
ResultModel
.
ERROR
(
"第"
+
line_num
+
"行[我方签约主体]错误"
);
}
else
{
s_data
[
w
]
=
dataSTR
;
bodyCode
=
cBodyMap
.
get
(
dataSTR
);
}
}
else
if
(
w
==
2
)
{
if
(!
tradTypeMap
.
containsKey
(
dataSTR
))
{
return
ResultModel
.
ERROR
(
"第"
+
line_num
+
"行[行业分类]错误"
);
}
else
{
s_data
[
w
]
=
tradTypeMap
.
get
(
dataSTR
);
}
}
else
if
(
w
==
5
)
{
if
(!
salseMap
.
containsKey
(
dataSTR
))
{
return
ResultModel
.
ERROR
(
"第"
+
line_num
+
"行[签约销售]错误"
);
}
else
{
s_data
[
w
]
=
salseMap
.
get
(
dataSTR
);
}
}
else
if
(
w
==
8
)
{
if
(!
CONTRACT_TYPE
.
containsKey
(
dataSTR
))
{
return
ResultModel
.
ERROR
(
"第"
+
line_num
+
"行[签约类型]错误"
);
}
else
{
s_data
[
w
]
=
salseMap
.
get
(
dataSTR
);
}
}
else
if
(
w
==
9
)
{
if
(
packageMap
!=
null
&&
!
packageMap
.
containsKey
(
dataSTR
))
{
return
ResultModel
.
ERROR
(
"第"
+
line_num
+
"行[套餐]错误"
);
}
else
{
s_data
[
w
]
=
packageMap
.
get
(
dataSTR
);
}
}
else
if
(
w
==
3
||
w
==
4
)
{
try
{
String
pattern
=
"yyyy/MM/dd"
;
DateTime
dateTime
=
DateTime
.
parse
(
dataSTR
,
DateTimeFormat
.
forPattern
(
pattern
));
s_data
[
w
]
=
dateTime
.
toString
(
"yyyy-MM-dd"
);
}
catch
(
Exception
e
)
{
return
ResultModel
.
ERROR
(
"第"
+
line_num
+
"行[日期]错误"
);
}
}
else
{
s_data
[
w
]
=
dataSTR
;
}
}
}
s_data
[
extend_row
]
=
platform
;
s_data
[
extend_row
+
1
]
=
platform
;
s_data
[
extend_row
+
2
]
=
bodyCode
;
args_data
.
add
(
s_data
);
}
jdbcTemplate
.
batchUpdate
(
"insert into contract (my_body_name,customer_body,trade_type,start_date,end_date,sale,email,contract_code, type_id,price_level,money) "
+
"values (?,?,?,?,?,?,?,?,?,?,?)"
,
args_data
);
String
baseSql
=
"my_body_name,customer_body,trade_type,start_date,end_date,sale,email,contract_code, contract_type,price_level,money"
;
baseSql
=
baseSql
+
extend_row_sql
;
String
endSql
=
null
;
for
(
int
ed
=
0
,
s
=
baseSql
.
split
(
","
).
length
;
ed
<
s
;
ed
++)
{
if
(
endSql
==
null
)
{
endSql
=
"?"
;
}
else
{
endSql
=
endSql
+
",?"
;
}
}
jdbcTemplate
.
batchUpdate
(
"insert into contract ("
+
baseSql
+
" ) values ("
+
endSql
+
")"
,
args_data
);
return
ResultModel
.
OK
();
return
null
;
}
...
...
@@ -2131,4 +2206,19 @@ public class ContractServiceImpl implements ContractService {
return
content
;
}
public
static
void
main
(
String
[]
args
)
{
String
dateStr
=
"2019/4/31"
;
// //根据时间表达式生成DateTimeFormatter对象
// DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy/MM/dd");
// //2019-10-28T10:23:12.000+08:00
// DateTime dateTime = fmt.parseDateTime(dateStr);
// System.out.println(dateTime.getDayOfMonth());
// dateTime = dateTime.plusDays(-1);
// System.out.println(dateTime.toString("yyyy-MM-dd"));
String
pattern
=
"yyyy/MM/dd"
;
DateTime
dateTime2
=
DateTime
.
parse
(
dateStr
,
DateTimeFormat
.
forPattern
(
pattern
));
System
.
out
.
println
(
dateTime2
.
toString
(
"yyyy-MM-dd"
));
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/temp/upload/tkio/合同模板.xlsx
0 → 100644
View file @
1f63568c
File added
This diff is collapsed.
Click to expand it.
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