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
c2f4df04
Commit
c2f4df04
authored
Jul 21, 2021
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DMP 收入
parent
37ebb5dc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
308 additions
and
48 deletions
+308
-48
DmpIncomeController.java
src/main/java/common/controller/DmpIncomeController.java
+5
-3
Contract.java
src/main/java/common/model/Contract.java
+20
-0
DmpIncome.java
src/main/java/common/model/DmpIncome.java
+2
-2
DmpIncomeService.java
src/main/java/common/service/DmpIncomeService.java
+2
-0
ContractServiceImpl.java
src/main/java/common/service/impl/ContractServiceImpl.java
+9
-0
DmpIncomeServiceImpl.java
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
+270
-43
No files found.
src/main/java/common/controller/DmpIncomeController.java
View file @
c2f4df04
...
@@ -44,11 +44,13 @@ public class DmpIncomeController {
...
@@ -44,11 +44,13 @@ public class DmpIncomeController {
}
}
@PostMapping
(
"/upload
/{platform}
"
)
@PostMapping
(
"/upload"
)
public
ResultModel
uploadList
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@
PathVariable
String
platform
,
@
CurrentAccount
User
loginAccount
)
{
public
ResultModel
uploadList
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@CurrentAccount
User
loginAccount
)
{
//上传收入数据
//上传收入数据
dmpIncomeService
.
uploadFile
(
file
,
platform
,
loginAccount
);
dmpIncomeService
.
uploadFile
(
file
,
"dmp"
,
loginAccount
);
return
ResultModel
.
OK
();
return
ResultModel
.
OK
();
}
}
}
}
src/main/java/common/model/Contract.java
View file @
c2f4df04
...
@@ -107,6 +107,8 @@ public class Contract {
...
@@ -107,6 +107,8 @@ public class Contract {
private
int
businessType
;
//业务类型 1 VIP 2 共管
private
int
businessType
;
//业务类型 1 VIP 2 共管
private
int
agreementType
;
//协议类型 1 普通协议 2 框架协议
private
int
agreementType
;
//协议类型 1 普通协议 2 框架协议
private
String
businessTypeName
;
//业务类型 1 VIP 2 共管
private
String
agreementTypeName
;
//协议类型 1 普通协议 2 框架协议
@Id
@Id
@GeneratedValue
@GeneratedValue
...
@@ -791,4 +793,22 @@ public class Contract {
...
@@ -791,4 +793,22 @@ public class Contract {
public
void
setAgreementType
(
int
agreementType
)
{
public
void
setAgreementType
(
int
agreementType
)
{
this
.
agreementType
=
agreementType
;
this
.
agreementType
=
agreementType
;
}
}
@Transient
public
String
getBusinessTypeName
()
{
return
businessTypeName
;
}
public
void
setBusinessTypeName
(
String
businessTypeName
)
{
this
.
businessTypeName
=
businessTypeName
;
}
@Transient
public
String
getAgreementTypeName
()
{
return
agreementTypeName
;
}
public
void
setAgreementTypeName
(
String
agreementTypeName
)
{
this
.
agreementTypeName
=
agreementTypeName
;
}
}
}
src/main/java/common/model/DmpIncome.java
View file @
c2f4df04
...
@@ -9,8 +9,8 @@ import java.util.Date;
...
@@ -9,8 +9,8 @@ import java.util.Date;
@Entity
@Entity
public
class
DmpIncome
{
public
class
DmpIncome
{
private
Long
id
;
private
Long
id
;
// ID
private
String
contractCode
;
private
String
contractCode
;
//合同编号
private
String
incomeMonth
;
//收入月份
private
String
incomeMonth
;
//收入月份
private
String
period
;
//结算周期
private
String
period
;
//结算周期
private
String
sysSettlement
;
//系统结算
private
String
sysSettlement
;
//系统结算
...
...
src/main/java/common/service/DmpIncomeService.java
View file @
c2f4df04
...
@@ -21,4 +21,6 @@ public interface DmpIncomeService {
...
@@ -21,4 +21,6 @@ public interface DmpIncomeService {
Long
delete
(
Long
id
);
Long
delete
(
Long
id
);
ResultModel
uploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
);
ResultModel
uploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
);
ResultModel
contractUploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
);
}
}
src/main/java/common/service/impl/ContractServiceImpl.java
View file @
c2f4df04
...
@@ -232,6 +232,9 @@ public class ContractServiceImpl implements ContractService {
...
@@ -232,6 +232,9 @@ public class ContractServiceImpl implements ContractService {
@Autowired
@Autowired
private
CalculationFlowRepository
calculationFlowRepository
;
private
CalculationFlowRepository
calculationFlowRepository
;
@Autowired
private
DmpIncomeService
dmpIncomeService
;
@Override
@Override
public
Map
<
String
,
Object
>
checkAccount
(
String
email
,
String
platfrom
)
{
public
Map
<
String
,
Object
>
checkAccount
(
String
email
,
String
platfrom
)
{
...
@@ -2487,6 +2490,12 @@ public class ContractServiceImpl implements ContractService {
...
@@ -2487,6 +2490,12 @@ public class ContractServiceImpl implements ContractService {
@Override
@Override
public
ResultModel
uploadBatchInfo
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
public
ResultModel
uploadBatchInfo
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
if
(
"dmp"
.
equals
(
platform
))
{
return
dmpIncomeService
.
contractUploadFile
(
file
,
platform
,
loginAccount
);
}
InputStream
stream
=
null
;
InputStream
stream
=
null
;
try
{
try
{
int
row_length
;
int
row_length
;
...
...
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
View file @
c2f4df04
package
common
.
service
.
impl
;
package
common
.
service
.
impl
;
import
common.model.DmpIncome
;
import
common.model.*
;
import
common.model.User
;
import
common.repository.*
;
import
common.repository.ContractRepository
;
import
common.repository.DmpIncomeRepository
;
import
common.service.DmpIncomeService
;
import
common.service.DmpIncomeService
;
import
org.apache.poi.hssf.usermodel.HSSFRow
;
import
org.apache.poi.hssf.usermodel.HSSFRow
;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.*
;
import
org.joda.time.DateTime
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StopWatch
;
import
org.springframework.util.StopWatch
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
util.ResultModel
;
import
util.ResultModel
;
import
javax.sql.DataSource
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.text.DateFormat
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.util.Date
;
import
java.text.SimpleDateFormat
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
...
@@ -45,8 +43,43 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
...
@@ -45,8 +43,43 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
ContractRepository
contractRepository
;
ContractRepository
contractRepository
;
@Autowired
@Autowired
@Qualifier
(
"dataSource"
)
TradeTypeRepsitory
tradeTypeRepsitory
;
DataSource
dataSource
;
@Autowired
SalesRepository
salesRepository
;
@Autowired
PackageBaseRepository
packageBaseRepository
;
@Autowired
BarrioCityRepository
barrioCityRepository
;
@Autowired
ContractBodyRepository
contractBodyRepository
;
public
static
final
Map
<
String
,
String
>
SHEET_NAMES
=
new
HashMap
();
private
static
final
Map
<
String
,
String
>
CONTRACT_TYPE_NAME
=
new
HashMap
();
private
static
final
Map
<
String
,
String
>
BUSINESS_TYPE_NAME
=
new
HashMap
();
private
static
final
Map
<
String
,
String
>
SETAGREEMENT_TYPE_NAME
=
new
HashMap
();
static
{
SHEET_NAMES
.
put
(
"tkio"
,
"TrackingIO"
);
SHEET_NAMES
.
put
(
"dmp"
,
"DMP"
);
SHEET_NAMES
.
put
(
"fake"
,
"防作弊卫士"
);
SHEET_NAMES
.
put
(
"adi"
,
"ADI"
);
SHEET_NAMES
.
put
(
"ads"
,
"ADS"
);
SHEET_NAMES
.
put
(
"abtest"
,
"ABTEST"
);
SHEET_NAMES
.
put
(
"cas"
,
"CAS"
);
CONTRACT_TYPE_NAME
.
put
(
"首次签约"
,
"0"
);
CONTRACT_TYPE_NAME
.
put
(
"续约"
,
"1"
);
CONTRACT_TYPE_NAME
.
put
(
"补充协议"
,
"2"
);
BUSINESS_TYPE_NAME
.
put
(
"VIP"
,
"1"
);
//业务类型 1 VIP 2 共管
BUSINESS_TYPE_NAME
.
put
(
"共管"
,
"2"
);
SETAGREEMENT_TYPE_NAME
.
put
(
"普通协议"
,
"1"
);
//协议类型 1 普通协议 2 框架协议
SETAGREEMENT_TYPE_NAME
.
put
(
"框架协议"
,
"2"
);
}
@Override
@Override
...
@@ -144,46 +177,19 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
...
@@ -144,46 +177,19 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
@Override
@Override
public
ResultModel
uploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
public
ResultModel
uploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
InputStream
stream
=
null
;
Workbook
workbook
=
null
;
try
{
stream
=
file
.
getInputStream
();
workbook
=
WorkbookFactory
.
create
(
stream
);
}
catch
(
Exception
e
)
{
logger
.
error
(
""
,
e
);
}
finally
{
if
(
stream
!=
null
)
{
try
{
stream
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
""
,
e
);
}
}
}
Workbook
workbook
=
getWorkbook
(
file
);
if
(
workbook
==
null
)
{
if
(
workbook
==
null
)
{
return
ResultModel
.
ERROR
(
"获取上传文件错误"
);
return
ResultModel
.
ERROR
(
"获取上传文件错误"
);
}
}
int
rowNumber
=
checkSheetTitle
(
workbook
,
"合同编号\t收入月份\t结算周期\t系统结算\t按月结算\t税率\t确认收入"
,
"\t"
);
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
if
(
rowNumber
==
-
1
)
{
Row
row
=
sheet
.
getRow
(
0
);
String
sheetTitle
=
"合同编号\t收入月份\t结算周期\t系统结算\t按月结算\t税率\t确认收入"
;
int
titleLength
=
sheetTitle
.
split
(
"\t"
).
length
;
StringBuffer
titleUp
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
titleLength
;
i
++)
{
if
(
i
>
0
)
titleUp
.
append
(
"\t"
);
titleUp
.
append
(
row
.
getCell
(
i
));
}
if
(!
titleUp
.
toString
().
equals
(
sheetTitle
))
{
return
ResultModel
.
ERROR
(
"模板表头错误"
);
return
ResultModel
.
ERROR
(
"模板表头错误"
);
}
}
else
if
(
rowNumber
<=
1
)
{
int
rowNumber
=
sheet
.
getLastRowNum
();
if
(
rowNumber
<=
1
)
{
return
ResultModel
.
ERROR
(
"文件为空"
);
return
ResultModel
.
ERROR
(
"文件为空"
);
}
}
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
CompletableFuture
.
runAsync
(()
->
{
CompletableFuture
.
runAsync
(()
->
{
StopWatch
stopWatch
=
new
StopWatch
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
stopWatch
.
start
();
...
@@ -202,6 +208,42 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
...
@@ -202,6 +208,42 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
return
ResultModel
.
OK
();
return
ResultModel
.
OK
();
}
}
private
int
checkSheetTitle
(
Workbook
workbook
,
String
sheetTitle
,
String
code
)
{
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Row
row
=
sheet
.
getRow
(
0
);
int
titleLength
=
sheetTitle
.
split
(
"\t"
).
length
;
StringBuffer
titleUp
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
titleLength
;
i
++)
{
if
(
i
>
0
)
titleUp
.
append
(
code
);
titleUp
.
append
(
row
.
getCell
(
i
));
}
if
(!
titleUp
.
toString
().
equals
(
sheetTitle
))
{
return
-
1
;
}
return
titleLength
;
}
private
Workbook
getWorkbook
(
MultipartFile
excelfile
)
{
InputStream
stream
=
null
;
Workbook
workbook
=
null
;
try
{
stream
=
excelfile
.
getInputStream
();
workbook
=
WorkbookFactory
.
create
(
stream
);
}
catch
(
Exception
e
)
{
logger
.
error
(
""
,
e
);
}
finally
{
if
(
stream
!=
null
)
{
try
{
stream
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
""
,
e
);
}
}
}
return
workbook
;
}
private
DmpIncome
saveDmpIncomeItem
(
Sheet
sheet
,
int
index
,
User
user
)
{
private
DmpIncome
saveDmpIncomeItem
(
Sheet
sheet
,
int
index
,
User
user
)
{
//logger.info(" line index {}", index);
//logger.info(" line index {}", index);
Row
rowItem
=
sheet
.
getRow
(
index
);
Row
rowItem
=
sheet
.
getRow
(
index
);
...
@@ -231,10 +273,195 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
...
@@ -231,10 +273,195 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
}
}
private
String
getCellDateValue
(
Row
row
,
int
index
)
{
Cell
cell
=
row
.
getCell
(
index
);
if
(
cell
==
null
)
{
return
"erro"
;
}
String
dfmate
=
cell
.
getCellStyle
().
getDataFormatString
();
if
(!
"yyyy/mm;@"
.
equals
(
dfmate
)
&&
!
"m/d/yy"
.
equals
(
dfmate
)
&&
!
"yy/m/d"
.
equals
(
dfmate
)
&&
!
"mm/dd/yy"
.
equals
(
dfmate
)
&&
!
"dd-mmm-yy"
.
equals
(
dfmate
)
&&
!
"yyyy/m/d"
.
equals
(
dfmate
)
&&
!
"yyyy/m/d;@"
.
equals
(
dfmate
))
{
return
"erro"
;
}
if
(
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
isCellDateFormatted
(
cell
))
{
// 用于转化为日期格式
Date
d
=
cell
.
getDateCellValue
();
DateFormat
formater
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
formater
.
format
(
d
);
}
return
cell
.
toString
();
}
private
String
getCellStringValue
(
Row
row
,
int
index
)
{
private
String
getCellStringValue
(
Row
row
,
int
index
)
{
Cell
cell
=
row
.
getCell
(
index
);
Cell
cell
=
row
.
getCell
(
index
);
return
cell
==
null
?
""
:
cell
.
toString
();
return
cell
==
null
?
""
:
cell
.
toString
();
}
}
private
String
getCellStringValue
(
Row
row
,
int
index
,
String
defaulValue
)
{
Cell
cell
=
row
.
getCell
(
index
);
return
cell
==
null
?
defaulValue
:
cell
.
toString
();
}
@Override
public
ResultModel
contractUploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
Workbook
workbook
=
getWorkbook
(
file
);
if
(
workbook
==
null
)
{
return
ResultModel
.
ERROR
(
"获取上传文件错误"
);
}
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
String
sheetName
=
sheet
.
getSheetName
();
if
(!
sheetName
.
equalsIgnoreCase
(
SHEET_NAMES
.
get
(
platform
)))
{
return
ResultModel
.
ERROR
(
"请上传对应项目模板处理的数据"
);
}
int
rowNumber
=
checkSheetTitle
(
workbook
,
"我方签约主体\t客户签约主体\t客户简称\t第三方签约主体\t行政区域\t隶属集团\t行业分类\t合同开始日期\t合同结束日期\t签约销售\t客户主账号\t合同编号\t签约类型\t业务类型\t协议类型\t合同金额\t关联合同编号"
,
"\t"
);
if
(
rowNumber
==
-
1
)
{
return
ResultModel
.
ERROR
(
"模板表头错误"
);
}
else
if
(
rowNumber
<=
1
)
{
return
ResultModel
.
ERROR
(
"文件为空"
);
}
List
<
Contract
>
allContracts
=
new
ArrayList
<>();
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
>
barrioCityMap
=
barrioCityRepository
.
findAll
()
.
stream
().
collect
(
Collectors
.
toMap
(
BarrioCity:
:
getName
,
BarrioCity:
:
getId
));
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getName
,
ContractBody:
:
getCode
,
(
v1
,
v2
)
->
v1
));
for
(
int
i
=
1
;
i
<
rowNumber
;
i
++)
{
Row
rowItem
=
sheet
.
getRow
(
i
);
if
(
rowItem
==
null
)
{
break
;
}
Contract
contract
=
new
Contract
();
contract
.
setPlatform
(
platform
);
contract
.
setProduct
(
platform
);
contract
.
setStatus
(
"normal"
);
contract
.
setType
(
"main"
);
contract
.
setCreateAccount
(
loginAccount
.
getId
());
contract
.
setCreateName
(
loginAccount
.
getName
());
contract
.
setCreateTime
(
new
Date
());
contract
.
setDs
(
DateTime
.
now
().
toString
(
"yyyy-MM-dd"
));
//填充数据
fillDataByRow
(
contract
,
rowItem
);
//校验数据有效性
if
(
"erro"
.
equals
(
contract
.
getStartDate
())
||
"erro"
.
equals
(
contract
.
getEndDate
()))
{
return
erroValueTip
(
i
,
"开始时间或结束时间"
);
}
if
(!
tradTypeMap
.
containsKey
(
contract
.
getTradeName
()))
{
return
erroValueTip
(
i
,
"行业分类"
);
}
else
{
contract
.
setTradeType
(
Integer
.
parseInt
(
tradTypeMap
.
get
(
contract
.
getTradeName
())
+
""
));
}
if
(!
cBodyMap
.
containsKey
(
contract
.
getMyBodyName
()))
{
return
erroValueTip
(
i
,
"我方签约主体"
);
}
else
{
contract
.
setMyBodyCode
(
cBodyMap
.
get
(
contract
.
getMyBodyName
()));
}
if
(
StringUtils
.
isEmpty
(
contract
.
getCustomerBody
()))
{
return
erroValueTip
(
i
,
"客户签约主体"
);
}
if
(!
barrioCityMap
.
containsKey
(
contract
.
getBarrioName
()))
{
return
erroValueTip
(
i
,
"行政区域"
);
}
else
{
contract
.
setBarrioId
(
barrioCityMap
.
get
(
contract
.
getBarrioName
()));
}
if
(!
salseMap
.
containsKey
(
contract
.
getSaleName
()))
{
return
erroValueTip
(
i
,
"签约销售"
);
}
else
{
contract
.
setSale
(
salseMap
.
get
(
contract
.
getMyBodyName
()));
}
if
(
StringUtils
.
isEmpty
(
contract
.
getEmail
()))
{
return
erroValueTip
(
i
,
"客户主账号"
);
}
if
(
StringUtils
.
isEmpty
(
contract
.
getContractCode
()))
{
return
erroValueTip
(
i
,
"合同编号"
);
}
else
{
contract
.
setCodeNum
(
Integer
.
parseInt
(
contract
.
getContractCode
().
split
(
"-"
)[
3
]));
}
if
(!
CONTRACT_TYPE_NAME
.
containsKey
(
contract
.
getContractType
()))
{
return
erroValueTip
(
i
,
"签约类型"
);
}
else
{
contract
.
setContractType
(
CONTRACT_TYPE_NAME
.
get
(
contract
.
getContractType
()));
}
if
(!
BUSINESS_TYPE_NAME
.
containsKey
(
contract
.
getBusinessTypeName
()))
{
return
erroValueTip
(
i
,
"业务类型"
);
}
else
{
contract
.
setBusinessType
(
Integer
.
parseInt
(
BUSINESS_TYPE_NAME
.
get
(
contract
.
getBusinessTypeName
())));
}
if
(!
SETAGREEMENT_TYPE_NAME
.
containsKey
(
contract
.
getAgreementTypeName
()))
{
return
erroValueTip
(
i
,
"业务类型"
);
}
else
{
contract
.
setAgreementType
(
Integer
.
parseInt
(
SETAGREEMENT_TYPE_NAME
.
get
(
contract
.
getAgreementTypeName
())));
}
allContracts
.
add
(
contract
);
}
if
(
allContracts
.
isEmpty
())
{
return
ResultModel
.
ERROR
(
"上传内容为空"
);
}
CompletableFuture
.
runAsync
(()
->
{
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
35
);
CompletableFuture
[]
futures
=
allContracts
.
stream
()
.
map
(
contract
->
CompletableFuture
.
runAsync
(
()
->
contractRepository
.
save
(
contract
),
executorService
)
.
exceptionally
((
t
)
->
null
)
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
CompletableFuture
.
allOf
(
futures
).
join
();
executorService
.
shutdownNow
();
stopWatch
.
stop
();
logger
.
info
(
"{} contract upload {} line data use all {}s "
,
platform
,
allContracts
.
size
(),
stopWatch
.
getTotalTimeSeconds
());
});
return
ResultModel
.
OK
();
}
private
void
fillDataByRow
(
Contract
contract
,
Row
rowItem
)
{
//我方签约主体 客户签约主体 客户简称
contract
.
setMyBodyName
(
getCellStringValue
(
rowItem
,
0
));
contract
.
setCustomerBody
(
getCellStringValue
(
rowItem
,
1
));
contract
.
setCustomerShort
(
getCellStringValue
(
rowItem
,
2
));
// 第三方签约主体 行政区域 隶属集团 行业分类
contract
.
setCustomerThird
(
getCellStringValue
(
rowItem
,
3
));
contract
.
setBarrioName
(
getCellStringValue
(
rowItem
,
4
));
contract
.
setBelongGroup
(
getCellStringValue
(
rowItem
,
5
));
contract
.
setTradeName
(
getCellStringValue
(
rowItem
,
6
));
// 合同开始日期 合同结束日期 签约销售 客户主账号
contract
.
setStartDate
(
getCellDateValue
(
rowItem
,
7
));
contract
.
setEndDate
(
getCellDateValue
(
rowItem
,
8
));
contract
.
setSaleName
(
getCellStringValue
(
rowItem
,
9
));
contract
.
setEmail
(
getCellStringValue
(
rowItem
,
10
));
// 合同编号 签约类型 业务类型 协议类型 合同金额 关联合同编号
contract
.
setContractCode
(
getCellStringValue
(
rowItem
,
11
));
contract
.
setContractType
(
getCellStringValue
(
rowItem
,
12
));
contract
.
setBusinessTypeName
(
getCellStringValue
(
rowItem
,
13
));
contract
.
setAgreementTypeName
(
getCellStringValue
(
rowItem
,
14
));
contract
.
setMoney
(
Double
.
parseDouble
(
getCellStringValue
(
rowItem
,
15
,
"0"
)));
contract
.
setRelationContract
(
new
BigDecimal
(
getCellStringValue
(
rowItem
,
16
,
"0"
)).
longValue
());
}
private
ResultModel
erroValueTip
(
int
line
,
String
title
)
{
return
ResultModel
.
ERROR
(
"第"
+
line
+
"行,["
+
title
+
"]错误"
);
}
}
}
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