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
c24c5ac8
Commit
c24c5ac8
authored
Jul 22, 2021
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DMP 收入导入
parent
bd6da457
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
19 deletions
+63
-19
ContractRepository.java
src/main/java/common/repository/ContractRepository.java
+6
-0
DmpIncomeServiceImpl.java
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
+57
-19
No files found.
src/main/java/common/repository/ContractRepository.java
View file @
c24c5ac8
...
...
@@ -3,6 +3,7 @@ package common.repository;
import
common.model.Contract
;
import
common.model.Role
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -153,4 +154,9 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query
(
value
=
"select id from contract where contract_code = ?1 "
,
nativeQuery
=
true
)
List
<
Long
>
findIdByCode
(
String
relationCode
);
@Transactional
@Modifying
@Query
(
value
=
"delete from contract where contract_code = ?1 and platform=?2"
,
nativeQuery
=
true
)
void
deleteByCode
(
String
contractCode
,
String
platform
);
}
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
View file @
c24c5ac8
...
...
@@ -182,7 +182,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
if
(
workbook
==
null
)
{
return
ResultModel
.
ERROR
(
"获取上传文件错误"
);
}
int
rowNumber
=
checkSheetTitle
(
workbook
,
"合同编号\t收入月份\t结算周期\t系统结算\t按月结算\t税率\t确认收入"
,
"\t
"
);
int
rowNumber
=
checkSheetTitle
(
workbook
,
platform
+
"_income
"
);
if
(
rowNumber
==
-
1
)
{
return
ResultModel
.
ERROR
(
"模板表头错误"
);
}
else
if
(
rowNumber
<=
1
)
{
...
...
@@ -220,7 +220,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
return
ResultModel
.
ERROR
(
"请上传对应项目模板处理的数据"
);
}
int
rowNumber
=
checkSheetTitle
(
workbook
,
"我方签约主体\t客户签约主体\t客户简称\t第三方签约主体\t行政区域\t隶属集团\t行业分类\t合同开始日期\t合同结束日期\t签约销售\t客户主账号\t合同编号\t签约类型\t业务类型\t协议类型\t合同金额\t关联合同编号"
,
"\t"
);
int
rowNumber
=
checkSheetTitle
(
workbook
,
platform
);
if
(
rowNumber
==
-
1
)
{
return
ResultModel
.
ERROR
(
"模板表头错误"
);
}
else
if
(
rowNumber
<=
1
)
{
...
...
@@ -232,8 +232,8 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
.
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
,
Lo
ng
>
barrioCityMap
=
barrioCityRepository
.
findAll
()
.
stream
().
collect
(
Collectors
.
toMap
(
BarrioCity:
:
get
Name
,
BarrioCity:
:
getId
));
Map
<
Long
,
Stri
ng
>
barrioCityMap
=
barrioCityRepository
.
findAll
()
.
stream
().
collect
(
Collectors
.
toMap
(
BarrioCity:
:
get
Id
,
BarrioCity:
:
getName
));
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getName
,
ContractBody:
:
getCode
,
(
v1
,
v2
)
->
v1
));
...
...
@@ -250,7 +250,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
contract
.
setType
(
"main"
);
contract
.
setCreateAccount
(
loginAccount
.
getId
());
contract
.
setCreateName
(
loginAccount
.
getName
());
contract
.
setCreateTime
(
new
Date
());
contract
.
setDs
(
DateTime
.
now
().
toString
(
"yyyy-MM-dd"
));
//填充数据
...
...
@@ -274,16 +274,16 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
return
erroValueTip
(
i
,
"客户签约主体"
);
}
if
(!
barrioCityMap
.
containsKey
(
contract
.
getBarrio
Name
()))
{
if
(!
barrioCityMap
.
containsKey
(
contract
.
getBarrio
Id
()))
{
return
erroValueTip
(
i
,
"行政区域"
);
}
else
{
contract
.
setBarrio
Id
(
barrioCityMap
.
get
(
contract
.
getBarrioName
()));
contract
.
setBarrio
Name
(
barrioCityMap
.
get
(
contract
.
getBarrioId
()));
}
if
(!
salseMap
.
containsKey
(
contract
.
getSaleName
()))
{
return
erroValueTip
(
i
,
"签约销售"
);
}
else
{
contract
.
setSale
(
salseMap
.
get
(
contract
.
get
MyBody
Name
()));
contract
.
setSale
(
salseMap
.
get
(
contract
.
get
Sale
Name
()));
}
if
(
StringUtils
.
isEmpty
(
contract
.
getEmail
()))
{
...
...
@@ -293,7 +293,10 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
if
(
StringUtils
.
isEmpty
(
contract
.
getContractCode
()))
{
return
erroValueTip
(
i
,
"合同编号"
);
}
else
{
contract
.
setCodeNum
(
Integer
.
parseInt
(
contract
.
getContractCode
().
split
(
"-"
)[
3
]));
String
[]
codeArr
=
contract
.
getContractCode
().
split
(
"-"
);
if
(
codeArr
.
length
==
4
)
{
contract
.
setCodeNum
(
Integer
.
parseInt
(
codeArr
[
3
]));
}
}
if
(!
CONTRACT_TYPE_NAME
.
containsKey
(
contract
.
getContractType
()))
{
...
...
@@ -329,7 +332,6 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
35
);
CompletableFuture
[]
futures
=
allContracts
.
stream
()
.
map
(
contract
->
CompletableFuture
.
runAsync
(()
->
{
if
(!
StringUtils
.
isEmpty
(
contract
.
getRelationCode
()))
{
List
<
Long
>
idList
=
contractRepository
.
findIdByCode
(
contract
.
getRelationCode
());
if
(!
idList
.
isEmpty
())
{
...
...
@@ -343,6 +345,10 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
if
(
contract
.
getRelationContract
()
<
0
)
{
contract
.
setRelationCode
(
null
);
}
//删除已经重复的记录
contractRepository
.
deleteByCode
(
contract
.
getContractCode
(),
platform
);
contract
.
setCreateTime
(
new
Date
());
contractRepository
.
save
(
contract
);
},
executorService
).
exceptionally
((
t
)
->
null
)
...
...
@@ -357,19 +363,35 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
return
ResultModel
.
OK
();
}
private
int
checkSheetTitle
(
Workbook
workbook
,
String
sheetTitle
,
String
code
)
{
private
int
checkSheetTitle
(
Workbook
workbook
,
String
platform
)
{
String
sheetTitle
=
null
;
String
code
=
"\t"
;
if
(
"dmp"
.
equals
(
platform
))
{
//dmp 合同
sheetTitle
=
"我方签约主体\t客户签约主体\t客户简称\t第三方签约主体\t行政区域\t隶属集团\t行业分类\t合同开始日期\t合同结束日期\t签约销售\t客户主账号\t合同编号\t签约类型\t业务类型\t协议类型\t合同金额\t关联合同编号"
;
}
else
if
(
"dmp_income"
.
equals
(
platform
))
{
//dmp 收入
sheetTitle
=
"合同编号\t收入月份\t结算周期\t系统结算\t按月结算\t税率\t确认收入"
;
}
if
(
sheetTitle
==
null
)
{
return
-
1
;
}
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Row
row
=
sheet
.
getRow
(
0
);
int
titl
eLength
=
sheetTitle
.
split
(
"\t"
).
length
;
int
sh
eLength
=
sheetTitle
.
split
(
"\t"
).
length
;
StringBuffer
titleUp
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
titl
eLength
;
i
++)
{
for
(
int
i
=
0
;
i
<
sh
eLength
;
i
++)
{
if
(
i
>
0
)
titleUp
.
append
(
code
);
titleUp
.
append
(
row
.
getCell
(
i
));
}
if
(!
titleUp
.
toString
().
equals
(
sheetTitle
))
{
return
-
1
;
}
return
titleLength
;
//总行数
sheLength
=
sheet
.
getLastRowNum
()
+
1
;
return
sheLength
;
}
private
Workbook
getWorkbook
(
MultipartFile
excelfile
)
{
...
...
@@ -399,7 +421,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
//合同编号 收入月份 结算周期 系统结算 按月结算 税率 确认收入
DmpIncome
income
=
new
DmpIncome
();
income
.
setContractCode
(
getCellStringValue
(
rowItem
,
0
));
income
.
setIncomeMonth
(
getCell
StringValue
(
rowItem
,
1
));
income
.
setIncomeMonth
(
getCell
DateValue
(
rowItem
,
1
,
"yyyy-MM"
));
income
.
setPeriod
(
getCellStringValue
(
rowItem
,
2
));
income
.
setSysSettlement
(
getCellStringValue
(
rowItem
,
3
));
income
.
setMonthSettlement
(
getCellStringValue
(
rowItem
,
4
));
...
...
@@ -411,6 +433,13 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
if
(
StringUtils
.
isEmpty
(
income
.
getContractCode
()))
{
return
null
;
}
//保留小数
income
.
setConfirmSettlement
(
new
BigDecimal
(
income
.
getConfirmSettlement
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
());
//
income
.
setTaxRate
(
Double
.
parseDouble
(
income
.
getTaxRate
())
*
100
+
"%"
);
if
(
StringUtils
.
isEmpty
(
income
.
getSysSettlement
()))
{
income
.
setSysSettlement
(
"0"
);
}
DmpIncome
one
=
dmpIncomeRepository
.
findByCodeMonth
(
income
.
getContractCode
(),
income
.
getIncomeMonth
());
if
(
one
!=
null
)
{
...
...
@@ -423,6 +452,10 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
}
private
String
getCellDateValue
(
Row
row
,
int
index
)
{
return
getCellDateValue
(
row
,
index
,
null
);
}
private
String
getCellDateValue
(
Row
row
,
int
index
,
String
fm
)
{
Cell
cell
=
row
.
getCell
(
index
);
if
(
cell
==
null
)
{
...
...
@@ -431,14 +464,19 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
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
))
{
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
)
&&
!
"yyyy\"年\"m\"月\";@"
.
equals
(
dfmate
)
)
{
return
"erro"
;
}
if
(
fm
==
null
)
{
fm
=
"yyyy-MM-dd"
;
}
if
(
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
isCellDateFormatted
(
cell
))
{
// 用于转化为日期格式
Date
d
=
cell
.
getDateCellValue
();
DateFormat
formater
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
DateFormat
formater
=
new
SimpleDateFormat
(
fm
);
return
formater
.
format
(
d
);
}
return
cell
.
toString
();
...
...
@@ -446,7 +484,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
private
String
getCellStringValue
(
Row
row
,
int
index
)
{
Cell
cell
=
row
.
getCell
(
index
);
return
cell
==
null
?
""
:
cell
.
toString
();
return
cell
==
null
?
""
:
cell
.
toString
()
.
trim
()
;
}
private
String
getCellStringValue
(
Row
row
,
int
index
,
String
defaulValue
)
{
...
...
@@ -461,7 +499,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
contract
.
setCustomerShort
(
getCellStringValue
(
rowItem
,
2
));
// 第三方签约主体 行政区域 隶属集团 行业分类
contract
.
setCustomerThird
(
getCellStringValue
(
rowItem
,
3
));
contract
.
setBarrio
Name
(
getCellStringValue
(
rowItem
,
4
));
contract
.
setBarrio
Id
(
new
BigDecimal
(
getCellStringValue
(
rowItem
,
4
,
"0"
)).
longValue
(
));
contract
.
setBelongGroup
(
getCellStringValue
(
rowItem
,
5
));
contract
.
setTradeName
(
getCellStringValue
(
rowItem
,
6
));
// 合同开始日期 合同结束日期 签约销售 客户主账号
...
...
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