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
00227a49
Commit
00227a49
authored
Nov 25, 2021
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传附件
parent
c3405769
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
878 additions
and
758 deletions
+878
-758
pom.xml
pom.xml
+2
-1
AttachmnetUploadController.java
...in/java/common/controller/AttachmnetUploadController.java
+65
-0
PdController.java
src/main/java/common/controller/PdController.java
+18
-17
PdAttachment.java
src/main/java/common/model/PdAttachment.java
+30
-0
PdAttachmentRepository.java
src/main/java/common/repository/PdAttachmentRepository.java
+8
-0
DmpIncomeService.java
src/main/java/common/service/DmpIncomeService.java
+1
-1
DmpIncomeServiceImpl.java
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
+749
-737
Constant.java
src/main/java/util/Constant.java
+1
-0
ddb.properties
src/main/resources/ddb.properties
+4
-2
No files found.
pom.xml
View file @
00227a49
...
@@ -178,7 +178,7 @@
...
@@ -178,7 +178,7 @@
<redis.event.database>
13
</redis.event.database>
<redis.event.database>
13
</redis.event.database>
<!--Redis setting//end-->
<!--Redis setting//end-->
<downhost>
http://172.23.6.108:9001
</downhost>
<ddb.accesskey>
AKIAOS2UEXIFNVER2O6A
</ddb.accesskey>
<ddb.accesskey>
AKIAOS2UEXIFNVER2O6A
</ddb.accesskey>
<ddb.secretkey>
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
</ddb.secretkey>
<ddb.secretkey>
3CQeG23urzxP7J5Vj4K7n3iKZIrmErukhvWGKsHI
</ddb.secretkey>
<ddb.region>
cn-north-1
</ddb.region>
<ddb.region>
cn-north-1
</ddb.region>
...
@@ -286,6 +286,7 @@
...
@@ -286,6 +286,7 @@
<redis.event.database>
13
</redis.event.database>
<redis.event.database>
13
</redis.event.database>
<!--Redis setting//end-->
<!--Redis setting//end-->
<downhost>
http://172.31.25.137:9001
</downhost>
<ddb.accesskey>
AKIA3XXNRTS2KXU632MD
</ddb.accesskey>
<ddb.accesskey>
AKIA3XXNRTS2KXU632MD
</ddb.accesskey>
<ddb.secretkey>
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
</ddb.secretkey>
<ddb.secretkey>
uqL8SJyaLDEE6NWv7NCXnVjM6Th/NdU030gL/UzV
</ddb.secretkey>
<ddb.region>
cn-north-1
</ddb.region>
<ddb.region>
cn-north-1
</ddb.region>
...
...
src/main/java/common/controller/AttachmnetUploadController.java
0 → 100644
View file @
00227a49
package
common
.
controller
;
import
common.model.DmpIncome
;
import
common.model.PdAttachment
;
import
common.model.User
;
import
common.service.DmpIncomeService
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
security.annotation.CurrentAccount
;
import
util.ResultModel
;
@Controller
@RequestMapping
(
"{platform}"
)
public
class
AttachmnetUploadController
{
@Autowired
DmpIncomeService
dmpIncomeService
;
//上传附件
@PostMapping
(
"/upload/attachment"
)
@ResponseBody
public
ResultModel
uploadAttach
(
@RequestParam
(
"file"
)
MultipartFile
[]
files
,
String
contractCode
,
@CurrentAccount
User
user
)
{
String
erroNames
=
""
;
for
(
MultipartFile
file
:
files
)
{
PdAttachment
attachment
=
dmpIncomeService
.
uploadPdAttach
(
file
,
contractCode
,
user
);
if
(
attachment
.
getFaild
())
{
erroNames
+=
" "
+
attachment
.
getFileOrginName
();
}
}
if
(!
StringUtils
.
isEmpty
(
erroNames
))
{
return
ResultModel
.
ERROR
(
5001
,
"文件:"
+
erroNames
+
"上传失败"
);
}
return
ResultModel
.
OK
();
}
//下载附加
@RequestMapping
(
value
=
"/download/attachment/{id}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
public
ResponseEntity
<
byte
[]>
getDownloadResponseEntity
(
@PathVariable
Long
id
)
{
return
dmpIncomeService
.
downloadAttach
(
id
);
}
//删除附件
@PostMapping
(
"/delete/attachment/{id}"
)
@ResponseBody
public
ResultModel
deleteAttach
(
@PathVariable
Long
id
)
{
return
ResultModel
.
OK
(
dmpIncomeService
.
deleteAttach
(
id
));
}
//附件列表
@GetMapping
(
"/list/attachment"
)
@ResponseBody
public
ResultModel
attachList
(
String
code
,
String
startDate
,
String
endDate
,
@PathVariable
String
platform
)
{
return
dmpIncomeService
.
attachList
(
code
,
startDate
,
endDate
,
platform
);
}
}
src/main/java/common/controller/PdController.java
View file @
00227a49
...
@@ -48,22 +48,23 @@ public class PdController {
...
@@ -48,22 +48,23 @@ public class PdController {
return
ResultModel
.
OK
(
dmpIncomeService
.
pdDelete
(
income
));
return
ResultModel
.
OK
(
dmpIncomeService
.
pdDelete
(
income
));
}
}
//上传附件
////上传附件
@PostMapping
(
"/upload/attachment"
)
//@PostMapping("/upload/attachment")
public
ResultModel
uploadAttach
(
@RequestParam
(
"file"
)
MultipartFile
file
,
String
contractCode
,
@CurrentAccount
User
user
)
{
//public ResultModel uploadAttach(@RequestParam("file") MultipartFile file, String contractCode, @CurrentAccount User user) {
//
// return ResultModel.OK(dmpIncomeService.uploadPdAttach(file, contractCode, user));
//}
//
////下载附加
//@RequestMapping(value = "download/attachment/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
//public ResponseEntity<byte[]> getDownloadResponseEntity(@PathVariable Long id) {
// return dmpIncomeService.downloadAttach(id);
//}
//
////删除附件
//@PostMapping("/delete/load/attachment/{id}")
//public ResultModel deleteAttach(@PathVariable Long id) {
// return ResultModel.OK(dmpIncomeService.deleteAttach(id));
//}
return
ResultModel
.
OK
(
dmpIncomeService
.
uploadPdAttach
(
file
,
contractCode
,
user
));
}
//下载附加
@RequestMapping
(
value
=
"download/attachment/{id}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
public
ResponseEntity
<
byte
[]>
getDownloadResponseEntity
(
@PathVariable
Long
id
)
{
return
dmpIncomeService
.
downloadAttach
(
id
);
}
//删除附件
@PostMapping
(
"/delete/load/attachment/{id}"
)
public
ResultModel
deleteAttach
(
@PathVariable
Long
id
)
{
return
ResultModel
.
OK
(
dmpIncomeService
.
deleteAttach
(
id
));
}
}
}
src/main/java/common/model/PdAttachment.java
View file @
00227a49
...
@@ -3,6 +3,7 @@ package common.model;
...
@@ -3,6 +3,7 @@ package common.model;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.Transient
;
import
java.util.Date
;
import
java.util.Date
;
@Entity
@Entity
...
@@ -13,7 +14,10 @@ public class PdAttachment {
...
@@ -13,7 +14,10 @@ public class PdAttachment {
private
String
fileName
;
//文件名
private
String
fileName
;
//文件名
private
String
fileType
;
//文件类型
private
String
fileType
;
//文件类型
private
Date
uploadDate
;
//上传日期
private
Date
uploadDate
;
//上传日期
private
String
uploadDateValue
;
private
String
uploadUser
;
private
String
uploadUser
;
private
Boolean
isFaild
;
// 是否失败
private
String
downloadUrl
;
@Id
@Id
@GeneratedValue
@GeneratedValue
...
@@ -72,4 +76,30 @@ public class PdAttachment {
...
@@ -72,4 +76,30 @@ public class PdAttachment {
public
void
setFileType
(
String
fileType
)
{
public
void
setFileType
(
String
fileType
)
{
this
.
fileType
=
fileType
;
this
.
fileType
=
fileType
;
}
}
@Transient
public
Boolean
getFaild
()
{
return
isFaild
;
}
public
void
setFaild
(
Boolean
faild
)
{
isFaild
=
faild
;
}
public
String
getUploadDateValue
()
{
return
uploadDateValue
;
}
public
void
setUploadDateValue
(
String
uploadDateValue
)
{
this
.
uploadDateValue
=
uploadDateValue
;
}
@Transient
public
String
getDownloadUrl
()
{
return
downloadUrl
;
}
public
void
setDownloadUrl
(
String
downloadUrl
)
{
this
.
downloadUrl
=
downloadUrl
;
}
}
}
src/main/java/common/repository/PdAttachmentRepository.java
View file @
00227a49
...
@@ -2,6 +2,14 @@ package common.repository;
...
@@ -2,6 +2,14 @@ package common.repository;
import
common.model.PdAttachment
;
import
common.model.PdAttachment
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
java.util.List
;
public
interface
PdAttachmentRepository
extends
JpaRepository
<
PdAttachment
,
Long
>
{
public
interface
PdAttachmentRepository
extends
JpaRepository
<
PdAttachment
,
Long
>
{
List
<
PdAttachment
>
findBycontractCode
(
String
code
);
@Query
(
value
=
"select * from pd_attachment where contract_code=?1 and upload_date >= ?2 and upload_date <= ?3"
,
nativeQuery
=
true
)
List
<
PdAttachment
>
findBycontractCodeAndDate
(
String
code
,
String
startDate
,
String
endDate
);
}
}
src/main/java/common/service/DmpIncomeService.java
View file @
00227a49
...
@@ -7,7 +7,6 @@ import common.model.User;
...
@@ -7,7 +7,6 @@ import common.model.User;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
tkio.model.Account
;
import
util.ResultModel
;
import
util.ResultModel
;
import
java.util.List
;
import
java.util.List
;
...
@@ -46,4 +45,5 @@ public interface DmpIncomeService {
...
@@ -46,4 +45,5 @@ public interface DmpIncomeService {
HSSFWorkbook
exportPdIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
);
HSSFWorkbook
exportPdIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
);
ResultModel
attachList
(
String
code
,
String
startDate
,
String
endDate
,
String
platform
);
}
}
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
View file @
00227a49
...
@@ -26,7 +26,7 @@ import util.ResultModel;
...
@@ -26,7 +26,7 @@ import util.ResultModel;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.
math.MathContext
;
import
java.
net.URLEncoder
;
import
java.text.DateFormat
;
import
java.text.DateFormat
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -40,745 +40,757 @@ import java.util.stream.Stream;
...
@@ -40,745 +40,757 @@ import java.util.stream.Stream;
@Service
@Service
public
class
DmpIncomeServiceImpl
implements
DmpIncomeService
{
public
class
DmpIncomeServiceImpl
implements
DmpIncomeService
{
Logger
logger
=
LoggerFactory
.
getLogger
(
DmpIncomeServiceImpl
.
class
);
Logger
logger
=
LoggerFactory
.
getLogger
(
DmpIncomeServiceImpl
.
class
);
@Autowired
@Autowired
DmpIncomeRepository
dmpIncomeRepository
;
DmpIncomeRepository
dmpIncomeRepository
;
@Autowired
@Autowired
ContractRepository
contractRepository
;
ContractRepository
contractRepository
;
@Autowired
@Autowired
TradeTypeRepsitory
tradeTypeRepsitory
;
TradeTypeRepsitory
tradeTypeRepsitory
;
@Autowired
@Autowired
SalesRepository
salesRepository
;
SalesRepository
salesRepository
;
@Autowired
@Autowired
PackageBaseRepository
packageBaseRepository
;
PackageBaseRepository
packageBaseRepository
;
@Autowired
@Autowired
BarrioCityRepository
barrioCityRepository
;
BarrioCityRepository
barrioCityRepository
;
@Autowired
@Autowired
ContractBodyRepository
contractBodyRepository
;
ContractBodyRepository
contractBodyRepository
;
@Autowired
@Autowired
PdIncomeRepository
pdIncomeRepository
;
PdIncomeRepository
pdIncomeRepository
;
@Autowired
@Autowired
PdAttachmentRepository
pdAttachmentRepository
;
PdAttachmentRepository
pdAttachmentRepository
;
public
static
final
Map
<
String
,
String
>
SHEET_NAMES
=
new
HashMap
();
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
>
CONTRACT_TYPE_NAME
=
new
HashMap
();
private
static
final
Map
<
String
,
String
>
BUSINESS_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
();
private
static
final
Map
<
String
,
String
>
SETAGREEMENT_TYPE_NAME
=
new
HashMap
();
static
{
static
{
SHEET_NAMES
.
put
(
"tkio"
,
"TrackingIO"
);
SHEET_NAMES
.
put
(
"tkio"
,
"TrackingIO"
);
SHEET_NAMES
.
put
(
"dmp"
,
"DMP"
);
SHEET_NAMES
.
put
(
"dmp"
,
"DMP"
);
SHEET_NAMES
.
put
(
"fake"
,
"防作弊卫士"
);
SHEET_NAMES
.
put
(
"fake"
,
"防作弊卫士"
);
SHEET_NAMES
.
put
(
"adi"
,
"ADI"
);
SHEET_NAMES
.
put
(
"adi"
,
"ADI"
);
SHEET_NAMES
.
put
(
"ads"
,
"ADS"
);
SHEET_NAMES
.
put
(
"ads"
,
"ADS"
);
SHEET_NAMES
.
put
(
"abtest"
,
"ABTEST"
);
SHEET_NAMES
.
put
(
"abtest"
,
"ABTEST"
);
SHEET_NAMES
.
put
(
"cas"
,
"CAS"
);
SHEET_NAMES
.
put
(
"cas"
,
"CAS"
);
CONTRACT_TYPE_NAME
.
put
(
"首次签约"
,
"0"
);
CONTRACT_TYPE_NAME
.
put
(
"首次签约"
,
"0"
);
CONTRACT_TYPE_NAME
.
put
(
"续约"
,
"1"
);
CONTRACT_TYPE_NAME
.
put
(
"续约"
,
"1"
);
CONTRACT_TYPE_NAME
.
put
(
"补充协议"
,
"2"
);
CONTRACT_TYPE_NAME
.
put
(
"补充协议"
,
"2"
);
BUSINESS_TYPE_NAME
.
put
(
"VIP"
,
"1"
);
//业务类型 1 VIP 2 共管
BUSINESS_TYPE_NAME
.
put
(
"VIP"
,
"1"
);
//业务类型 1 VIP 2 共管
BUSINESS_TYPE_NAME
.
put
(
"共管"
,
"2"
);
BUSINESS_TYPE_NAME
.
put
(
"共管"
,
"2"
);
BUSINESS_TYPE_NAME
.
put
(
"前置机"
,
"3"
);
BUSINESS_TYPE_NAME
.
put
(
"前置机"
,
"3"
);
SETAGREEMENT_TYPE_NAME
.
put
(
"普通协议"
,
"1"
);
//协议类型 1 普通协议 2 框架协议
SETAGREEMENT_TYPE_NAME
.
put
(
"普通协议"
,
"1"
);
//协议类型 1 普通协议 2 框架协议
SETAGREEMENT_TYPE_NAME
.
put
(
"框架协议"
,
"2"
);
SETAGREEMENT_TYPE_NAME
.
put
(
"框架协议"
,
"2"
);
}
}
@Override
@Override
public
List
<
DmpIncome
>
listByCode
(
String
contractCode
)
{
public
List
<
DmpIncome
>
listByCode
(
String
contractCode
)
{
List
<
DmpIncome
>
dmpIncomes
=
dmpIncomeRepository
.
findByContractCode
(
contractCode
);
List
<
DmpIncome
>
dmpIncomes
=
dmpIncomeRepository
.
findByContractCode
(
contractCode
);
return
dmpIncomes
;
return
dmpIncomes
;
}
}
@Override
@Override
public
List
<
DmpIncome
>
listByDs
(
String
start
,
String
end
)
{
public
List
<
DmpIncome
>
listByDs
(
String
start
,
String
end
)
{
List
<
DmpIncome
>
dmpIncomes
=
dmpIncomeRepository
.
findByContractDs
(
start
,
end
);
List
<
DmpIncome
>
dmpIncomes
=
dmpIncomeRepository
.
findByContractDs
(
start
,
end
);
if
(
dmpIncomes
.
isEmpty
())
{
if
(
dmpIncomes
.
isEmpty
())
{
return
dmpIncomes
;
return
dmpIncomes
;
}
}
List
<
String
>
codes
=
dmpIncomes
.
stream
().
map
(
v
->
v
.
getContractCode
()).
collect
(
Collectors
.
toList
());
List
<
String
>
codes
=
dmpIncomes
.
stream
().
map
(
v
->
v
.
getContractCode
()).
collect
(
Collectors
.
toList
());
List
<
Object
[]>
contracts
=
contractRepository
.
findByDmpContractCode
(
codes
);
List
<
Object
[]>
contracts
=
contractRepository
.
findByDmpContractCode
(
codes
);
Map
<
String
,
Object
[]>
names
=
contracts
.
stream
().
collect
(
Collectors
.
toMap
(
v
->
v
[
0
]
+
""
,
v
->
v
,
(
v1
,
v2
)
->
v1
));
Map
<
String
,
Object
[]>
names
=
contracts
.
stream
().
collect
(
Collectors
.
toMap
(
v
->
v
[
0
]
+
""
,
v
->
v
,
(
v1
,
v2
)
->
v1
));
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getCode
,
ContractBody:
:
getName
,
(
v1
,
v2
)
->
v1
));
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getCode
,
ContractBody:
:
getName
,
(
v1
,
v2
)
->
v1
));
for
(
DmpIncome
dmpIncome
:
dmpIncomes
)
{
for
(
DmpIncome
dmpIncome
:
dmpIncomes
)
{
Object
[]
nameItem
=
names
.
get
(
dmpIncome
.
getContractCode
());
Object
[]
nameItem
=
names
.
get
(
dmpIncome
.
getContractCode
());
//my_body_name, customer_body, customer_short, business_type, agreement_type
//my_body_name, customer_body, customer_short, business_type, agreement_type
if
(
nameItem
!=
null
)
{
if
(
nameItem
!=
null
)
{
dmpIncome
.
setMyBodyCode
(
nameItem
[
1
]
+
""
);
dmpIncome
.
setMyBodyCode
(
nameItem
[
1
]
+
""
);
dmpIncome
.
setMyBodyName
(
nameItem
[
2
]
+
""
);
dmpIncome
.
setMyBodyName
(
nameItem
[
2
]
+
""
);
dmpIncome
.
setCustomerBody
(
nameItem
[
3
]
+
""
);
dmpIncome
.
setCustomerBody
(
nameItem
[
3
]
+
""
);
dmpIncome
.
setCustomerShort
(
nameItem
[
4
]
+
""
);
dmpIncome
.
setCustomerShort
(
nameItem
[
4
]
+
""
);
dmpIncome
.
setBusinessType
(
nameItem
[
5
]
+
""
);
dmpIncome
.
setBusinessType
(
nameItem
[
5
]
+
""
);
dmpIncome
.
setAgreementType
(
nameItem
[
6
]
+
""
);
dmpIncome
.
setAgreementType
(
nameItem
[
6
]
+
""
);
if
(
StringUtils
.
isEmpty
(
dmpIncome
.
getMyBodyName
())
||
dmpIncome
.
getMyBodyName
().
equals
(
"null"
))
{
if
(
StringUtils
.
isEmpty
(
dmpIncome
.
getMyBodyName
())
||
dmpIncome
.
getMyBodyName
().
equals
(
"null"
))
{
dmpIncome
.
setMyBodyName
(
cBodyMap
.
get
(
nameItem
[
1
]));
dmpIncome
.
setMyBodyName
(
cBodyMap
.
get
(
nameItem
[
1
]));
}
}
}
}
}
}
return
dmpIncomes
;
return
dmpIncomes
;
}
}
@Override
@Override
public
List
<
PdIncome
>
pdListByDs
(
String
startDate
,
String
endDate
)
{
public
List
<
PdIncome
>
pdListByDs
(
String
startDate
,
String
endDate
)
{
List
<
PdIncome
>
pdIncomes
=
pdIncomeRepository
.
findByDs
(
startDate
,
endDate
);
List
<
PdIncome
>
pdIncomes
=
pdIncomeRepository
.
findByDs
(
startDate
,
endDate
);
if
(
pdIncomes
.
isEmpty
())
{
if
(
pdIncomes
.
isEmpty
())
{
return
pdIncomes
;
return
pdIncomes
;
}
}
List
<
String
>
codes
=
pdIncomes
.
stream
().
map
(
v
->
v
.
getContractCode
()).
distinct
().
collect
(
Collectors
.
toList
());
List
<
String
>
codes
=
pdIncomes
.
stream
().
map
(
v
->
v
.
getContractCode
()).
distinct
().
collect
(
Collectors
.
toList
());
List
<
Object
[]>
contracts
=
contractRepository
.
findShortByContractCode
(
codes
,
"pd"
);
List
<
Object
[]>
contracts
=
contractRepository
.
findShortByContractCode
(
codes
,
"pd"
);
Map
<
String
,
Object
[]>
names
=
contracts
.
stream
().
collect
(
Collectors
.
toMap
(
v
->
v
[
0
]
+
""
,
v
->
v
,
(
v1
,
v2
)
->
v1
));
Map
<
String
,
Object
[]>
names
=
contracts
.
stream
().
collect
(
Collectors
.
toMap
(
v
->
v
[
0
]
+
""
,
v
->
v
,
(
v1
,
v2
)
->
v1
));
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getCode
,
ContractBody:
:
getName
,
(
v1
,
v2
)
->
v1
));
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getCode
,
ContractBody:
:
getName
,
(
v1
,
v2
)
->
v1
));
for
(
PdIncome
pdIncome
:
pdIncomes
)
{
for
(
PdIncome
pdIncome
:
pdIncomes
)
{
Object
[]
nameItem
=
names
.
get
(
pdIncome
.
getContractCode
());
Object
[]
nameItem
=
names
.
get
(
pdIncome
.
getContractCode
());
//my_body_name, customer_body, customer_short, business_type, agreement_type
//my_body_name, customer_body, customer_short, business_type, agreement_type
if
(
nameItem
!=
null
)
{
if
(
nameItem
!=
null
)
{
pdIncome
.
setMyBodyCode
(
nameItem
[
1
]
+
""
);
pdIncome
.
setMyBodyCode
(
nameItem
[
1
]
+
""
);
pdIncome
.
setMyBodyName
(
nameItem
[
2
]
+
""
);
pdIncome
.
setMyBodyName
(
nameItem
[
2
]
+
""
);
pdIncome
.
setCustomerBody
(
nameItem
[
3
]
+
""
);
pdIncome
.
setCustomerBody
(
nameItem
[
3
]
+
""
);
pdIncome
.
setCustomerShort
(
nameItem
[
4
]
==
null
?
""
:
nameItem
[
4
]
+
""
);
pdIncome
.
setCustomerShort
(
nameItem
[
4
]
==
null
?
""
:
nameItem
[
4
]
+
""
);
pdIncome
.
setBusinessType
(
nameItem
[
5
]
+
""
);
pdIncome
.
setBusinessType
(
nameItem
[
5
]
+
""
);
pdIncome
.
setAgreementType
(
nameItem
[
6
]
+
""
);
pdIncome
.
setAgreementType
(
nameItem
[
6
]
+
""
);
pdIncome
.
setProductType
(
nameItem
[
7
]
+
""
);
pdIncome
.
setProductType
(
nameItem
[
7
]
+
""
);
if
(
StringUtils
.
isEmpty
(
pdIncome
.
getMyBodyName
())
||
pdIncome
.
getMyBodyName
().
equals
(
"null"
))
{
if
(
StringUtils
.
isEmpty
(
pdIncome
.
getMyBodyName
())
||
pdIncome
.
getMyBodyName
().
equals
(
"null"
))
{
pdIncome
.
setMyBodyName
(
cBodyMap
.
get
(
nameItem
[
1
]));
pdIncome
.
setMyBodyName
(
cBodyMap
.
get
(
nameItem
[
1
]));
}
else
{
}
else
{
pdIncome
.
setMyBodyName
(
""
);
pdIncome
.
setMyBodyName
(
""
);
}
}
}
}
}
}
return
pdIncomes
;
return
pdIncomes
;
}
}
@Override
@Override
public
HSSFWorkbook
exportPdIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
)
{
public
HSSFWorkbook
exportPdIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
)
{
List
<
PdIncome
>
pdIncomes
=
this
.
pdListByDs
(
startDate
,
endDate
);
List
<
PdIncome
>
pdIncomes
=
this
.
pdListByDs
(
startDate
,
endDate
);
pdIncomes
=
pdIncomes
.
stream
()
pdIncomes
=
pdIncomes
.
stream
()
.
filter
(
v
->
StringUtils
.
isEmpty
(
bodyCode
)
||
"all"
.
equals
(
bodyCode
)
||
bodyCode
.
equals
(
v
.
getMyBodyName
()))
.
filter
(
v
->
StringUtils
.
isEmpty
(
bodyCode
)
||
"all"
.
equals
(
bodyCode
)
||
bodyCode
.
equals
(
v
.
getMyBodyName
()))
.
filter
(
v
->
StringUtils
.
isEmpty
(
serchName
)
||
(
v
.
getContractCode
().
contains
(
serchName
)
||
v
.
getCustomerBody
().
contains
(
serchName
)
||
v
.
getMyBodyName
().
contains
(
serchName
)))
.
filter
(
v
->
StringUtils
.
isEmpty
(
serchName
)
||
(
v
.
getContractCode
().
contains
(
serchName
)
||
v
.
getCustomerBody
().
contains
(
serchName
)
||
v
.
getMyBodyName
().
contains
(
serchName
)))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
DecimalFormat
df
=
new
DecimalFormat
(
"##,##0.00"
);
DecimalFormat
df
=
new
DecimalFormat
(
"##,##0.00"
);
//创建工作薄对象
//创建工作薄对象
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
//这里也可以设置sheet的Name
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
//这里也可以设置sheet的Name
//创建工作表对象
//创建工作表对象
HSSFSheet
sheet
=
workbook
.
createSheet
();
HSSFSheet
sheet
=
workbook
.
createSheet
();
//创建工作表的行
//创建工作表的行
HSSFRow
row
=
sheet
.
createRow
(
0
);
HSSFRow
row
=
sheet
.
createRow
(
0
);
//表头
//表头
String
[]
title
=
"我方签约主体,签约方,客户简称,合同编号,录入日期,结算日期,产品类型,收入类型,税率,确认收入"
.
split
(
","
);
String
[]
title
=
"我方签约主体,签约方,客户简称,合同编号,录入日期,结算日期,产品类型,收入类型,税率,确认收入"
.
split
(
","
);
for
(
int
i
=
0
;
i
<
title
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
title
.
length
;
i
++)
{
row
.
createCell
(
i
).
setCellValue
(
title
[
i
]);
row
.
createCell
(
i
).
setCellValue
(
title
[
i
]);
}
}
for
(
int
j
=
0
;
j
<
pdIncomes
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
pdIncomes
.
size
();
j
++)
{
HSSFRow
rowBody
=
sheet
.
createRow
(
j
+
1
);
HSSFRow
rowBody
=
sheet
.
createRow
(
j
+
1
);
PdIncome
income
=
pdIncomes
.
get
(
j
);
PdIncome
income
=
pdIncomes
.
get
(
j
);
String
[]
dataItem
=
new
String
[]{
String
[]
dataItem
=
new
String
[]{
income
.
getMyBodyName
(),
income
.
getCustomerBody
(),
income
.
getCustomerShort
(),
income
.
getMyBodyName
(),
income
.
getCustomerBody
(),
income
.
getCustomerShort
(),
income
.
getContractCode
(),
income
.
getInputDate
(),
income
.
getSettlementDate
(),
income
.
getContractCode
(),
income
.
getInputDate
(),
income
.
getSettlementDate
(),
income
.
getProductType
(),
income
.
getIncomeType
(),
income
.
getProductType
(),
income
.
getIncomeType
(),
income
.
getTaxRate
(),
income
.
getConfirmIncome
()
income
.
getTaxRate
(),
income
.
getConfirmIncome
()
};
};
for
(
int
w
=
0
;
w
<
dataItem
.
length
;
w
++)
{
for
(
int
w
=
0
;
w
<
dataItem
.
length
;
w
++)
{
rowBody
.
createCell
(
w
).
setCellValue
(
dataItem
[
w
]);
rowBody
.
createCell
(
w
).
setCellValue
(
dataItem
[
w
]);
}
}
}
}
return
workbook
;
return
workbook
;
}
}
@Override
@Override
public
HSSFWorkbook
exportIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
)
{
public
HSSFWorkbook
exportIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
)
{
List
<
DmpIncome
>
dmpIncomes
=
this
.
listByDs
(
startDate
,
endDate
);
List
<
DmpIncome
>
dmpIncomes
=
this
.
listByDs
(
startDate
,
endDate
);
dmpIncomes
=
dmpIncomes
.
stream
()
dmpIncomes
=
dmpIncomes
.
stream
()
.
filter
(
v
->
StringUtils
.
isEmpty
(
bodyCode
)
||
"all"
.
equals
(
bodyCode
)
||
bodyCode
.
equals
(
v
.
getMyBodyName
()))
.
filter
(
v
->
StringUtils
.
isEmpty
(
bodyCode
)
||
"all"
.
equals
(
bodyCode
)
||
bodyCode
.
equals
(
v
.
getMyBodyName
()))
.
filter
(
v
->
StringUtils
.
isEmpty
(
serchName
)
||
(
v
.
getContractCode
().
contains
(
serchName
)
||
v
.
getCustomerBody
().
contains
(
serchName
)
||
v
.
getMyBodyName
().
contains
(
serchName
)))
.
filter
(
v
->
StringUtils
.
isEmpty
(
serchName
)
||
(
v
.
getContractCode
().
contains
(
serchName
)
||
v
.
getCustomerBody
().
contains
(
serchName
)
||
v
.
getMyBodyName
().
contains
(
serchName
)))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
DecimalFormat
df
=
new
DecimalFormat
(
"##,##0.00"
);
DecimalFormat
df
=
new
DecimalFormat
(
"##,##0.00"
);
//创建工作薄对象
//创建工作薄对象
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
//这里也可以设置sheet的Name
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
//这里也可以设置sheet的Name
//创建工作表对象
//创建工作表对象
HSSFSheet
sheet
=
workbook
.
createSheet
();
HSSFSheet
sheet
=
workbook
.
createSheet
();
//创建工作表的行
//创建工作表的行
HSSFRow
row
=
sheet
.
createRow
(
0
);
HSSFRow
row
=
sheet
.
createRow
(
0
);
//表头
//表头
String
[]
title
=
"我方签约主体,收入月份,签约方,客户简称,合同编号,业务类型,结算周期,系统结算,按月结算,税率,确认收入"
.
split
(
","
);
String
[]
title
=
"我方签约主体,收入月份,签约方,客户简称,合同编号,业务类型,结算周期,系统结算,按月结算,税率,确认收入"
.
split
(
","
);
for
(
int
i
=
0
;
i
<
title
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
title
.
length
;
i
++)
{
row
.
createCell
(
i
).
setCellValue
(
title
[
i
]);
row
.
createCell
(
i
).
setCellValue
(
title
[
i
]);
}
}
String
[]
bussinesName
=
new
String
[]{
""
,
"VIP"
,
"共管"
,
"前置机"
};
String
[]
bussinesName
=
new
String
[]{
""
,
"VIP"
,
"共管"
,
"前置机"
};
for
(
int
j
=
0
;
j
<
dmpIncomes
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
dmpIncomes
.
size
();
j
++)
{
HSSFRow
rowBody
=
sheet
.
createRow
(
j
+
1
);
HSSFRow
rowBody
=
sheet
.
createRow
(
j
+
1
);
DmpIncome
income
=
dmpIncomes
.
get
(
j
);
DmpIncome
income
=
dmpIncomes
.
get
(
j
);
String
bussinesTypeName
=
income
.
getBusinessType
()
==
null
?
""
:
bussinesName
[
Integer
.
parseInt
(
income
.
getBusinessType
())];
String
bussinesTypeName
=
income
.
getBusinessType
()
==
null
?
""
:
bussinesName
[
Integer
.
parseInt
(
income
.
getBusinessType
())];
String
[]
dataItem
=
new
String
[]{
String
[]
dataItem
=
new
String
[]{
income
.
getMyBodyName
(),
income
.
getIncomeMonth
(),
income
.
getCustomerBody
(),
income
.
getMyBodyName
(),
income
.
getIncomeMonth
(),
income
.
getCustomerBody
(),
income
.
getCustomerShort
(),
income
.
getContractCode
(),
bussinesTypeName
,
income
.
getCustomerShort
(),
income
.
getContractCode
(),
bussinesTypeName
,
income
.
getPeriod
(),
income
.
getSysSettlement
(),
income
.
getMonthSettlement
(),
income
.
getPeriod
(),
income
.
getSysSettlement
(),
income
.
getMonthSettlement
(),
income
.
getTaxRate
(),
income
.
getConfirmSettlement
()
income
.
getTaxRate
(),
income
.
getConfirmSettlement
()
};
};
for
(
int
w
=
0
;
w
<
dataItem
.
length
;
w
++)
{
for
(
int
w
=
0
;
w
<
dataItem
.
length
;
w
++)
{
rowBody
.
createCell
(
w
).
setCellValue
(
dataItem
[
w
]);
rowBody
.
createCell
(
w
).
setCellValue
(
dataItem
[
w
]);
}
}
}
}
return
workbook
;
return
workbook
;
}
}
@Override
@Override
public
DmpIncome
update
(
DmpIncome
dmpIncome
)
{
public
DmpIncome
update
(
DmpIncome
dmpIncome
)
{
if
(
dmpIncome
.
getId
()
==
null
)
{
if
(
dmpIncome
.
getId
()
==
null
)
{
return
null
;
return
null
;
}
}
DmpIncome
dbItem
=
dmpIncomeRepository
.
findOne
(
dmpIncome
.
getId
());
DmpIncome
dbItem
=
dmpIncomeRepository
.
findOne
(
dmpIncome
.
getId
());
dbItem
.
setIncomeMonth
(
dmpIncome
.
getIncomeMonth
());
dbItem
.
setIncomeMonth
(
dmpIncome
.
getIncomeMonth
());
dbItem
.
setPeriod
(
dmpIncome
.
getPeriod
());
dbItem
.
setPeriod
(
dmpIncome
.
getPeriod
());
dbItem
.
setSysSettlement
(
dmpIncome
.
getSysSettlement
());
dbItem
.
setSysSettlement
(
dmpIncome
.
getSysSettlement
());
dbItem
.
setMonthSettlement
(
dmpIncome
.
getMonthSettlement
());
dbItem
.
setMonthSettlement
(
dmpIncome
.
getMonthSettlement
());
dbItem
.
setTaxRate
(
dmpIncome
.
getTaxRate
());
dbItem
.
setTaxRate
(
dmpIncome
.
getTaxRate
());
dbItem
.
setConfirmSettlement
(
dmpIncome
.
getConfirmSettlement
());
dbItem
.
setConfirmSettlement
(
dmpIncome
.
getConfirmSettlement
());
dmpIncomeRepository
.
save
(
dbItem
);
dmpIncomeRepository
.
save
(
dbItem
);
return
dbItem
;
return
dbItem
;
}
}
@Override
@Override
public
Long
delete
(
DmpIncome
dmpIncome
)
{
public
Long
delete
(
DmpIncome
dmpIncome
)
{
if
(
dmpIncome
.
getId
()
==
null
)
{
if
(
dmpIncome
.
getId
()
==
null
)
{
return
null
;
return
null
;
}
}
dmpIncomeRepository
.
delete
(
dmpIncome
.
getId
());
dmpIncomeRepository
.
delete
(
dmpIncome
.
getId
());
return
dmpIncome
.
getId
();
return
dmpIncome
.
getId
();
}
}
@Override
@Override
public
ResultModel
uploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
public
ResultModel
uploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
Workbook
workbook
=
getWorkbook
(
file
);
Workbook
workbook
=
getWorkbook
(
file
);
if
(
workbook
==
null
)
{
if
(
workbook
==
null
)
{
return
ResultModel
.
ERROR
(
"获取上传文件错误"
);
return
ResultModel
.
ERROR
(
"获取上传文件错误"
);
}
}
int
rowNumber
=
checkSheetTitle
(
workbook
,
platform
+
"_income"
);
int
rowNumber
=
checkSheetTitle
(
workbook
,
platform
+
"_income"
);
if
(
rowNumber
==
-
1
)
{
if
(
rowNumber
==
-
1
)
{
return
ResultModel
.
ERROR
(
"模板表头错误"
);
return
ResultModel
.
ERROR
(
"模板表头错误"
);
}
else
if
(
rowNumber
<=
1
)
{
}
else
if
(
rowNumber
<=
1
)
{
return
ResultModel
.
ERROR
(
"文件为空"
);
return
ResultModel
.
ERROR
(
"文件为空"
);
}
}
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
DecimalFormat
df
=
new
DecimalFormat
(
"##,##0.00"
);
DecimalFormat
df
=
new
DecimalFormat
(
"##,##0.00"
);
StringBuffer
erroMessage
=
new
StringBuffer
();
StringBuffer
erroMessage
=
new
StringBuffer
();
StopWatch
stopWatch
=
new
StopWatch
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
stopWatch
.
start
();
Map
<
String
,
String
>
incomeMap
=
new
HashMap
<>();
Map
<
String
,
String
>
incomeMap
=
new
HashMap
<>();
List
<
DmpIncome
>
dmpIncomeList
=
Stream
.
iterate
(
1
,
n
->
n
+
1
).
limit
(
rowNumber
-
1
).
map
(
index
->
{
List
<
DmpIncome
>
dmpIncomeList
=
Stream
.
iterate
(
1
,
n
->
n
+
1
).
limit
(
rowNumber
-
1
).
map
(
index
->
{
DmpIncome
income
=
saveDmpIncomeItem
(
sheet
,
index
,
loginAccount
);
DmpIncome
income
=
saveDmpIncomeItem
(
sheet
,
index
,
loginAccount
);
String
key
=
income
.
getIncomeMonth
()
+
income
.
getContractCode
();
String
key
=
income
.
getIncomeMonth
()
+
income
.
getContractCode
();
if
(
incomeMap
.
containsKey
(
key
))
{
if
(
incomeMap
.
containsKey
(
key
))
{
return
null
;
return
null
;
}
}
incomeMap
.
put
(
key
,
"1"
);
incomeMap
.
put
(
key
,
"1"
);
return
income
;
return
income
;
}).
filter
(
in
->
in
!=
null
).
collect
(
Collectors
.
toList
());
}).
filter
(
in
->
in
!=
null
).
collect
(
Collectors
.
toList
());
if
(
dmpIncomeList
.
isEmpty
())
{
if
(
dmpIncomeList
.
isEmpty
())
{
return
ResultModel
.
OK
();
return
ResultModel
.
OK
();
}
}
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
30
);
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
30
);
final
int
[]
indexLine
=
{
0
};
final
int
[]
indexLine
=
{
0
};
CompletableFuture
[]
futures
=
dmpIncomeList
.
stream
().
map
(
income
->
CompletableFuture
[]
futures
=
dmpIncomeList
.
stream
().
map
(
income
->
CompletableFuture
.
runAsync
(
CompletableFuture
.
runAsync
(
()
->
{
()
->
{
DmpIncome
one
=
dmpIncomeRepository
.
findByCodeMonth
(
income
.
getContractCode
(),
income
.
getIncomeMonth
());
DmpIncome
one
=
dmpIncomeRepository
.
findByCodeMonth
(
income
.
getContractCode
(),
income
.
getIncomeMonth
());
if
(
one
!=
null
)
{
if
(
one
!=
null
)
{
// 同一合同同一月份不重复保存
// 同一合同同一月份不重复保存
return
;
return
;
}
}
indexLine
[
0
]
=
income
.
getIndex
();
indexLine
[
0
]
=
income
.
getIndex
();
if
(
"erro"
.
equals
(
income
.
getIncomeMonth
()))
{
if
(
"erro"
.
equals
(
income
.
getIncomeMonth
()))
{
erroMessage
.
append
(
income
.
getIndex
()).
append
(
" 行 收入月份错误"
).
append
(
";\n"
);
erroMessage
.
append
(
income
.
getIndex
()).
append
(
" 行 收入月份错误"
).
append
(
";\n"
);
}
else
{
}
else
{
income
.
setConfirmSettlement
(
new
BigDecimal
(
income
.
getConfirmSettlement
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
());
income
.
setConfirmSettlement
(
new
BigDecimal
(
income
.
getConfirmSettlement
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
());
dmpIncomeRepository
.
save
(
income
);
dmpIncomeRepository
.
save
(
income
);
}
}
},
executorService
)
},
executorService
)
.
exceptionally
((
t
)
->
{
.
exceptionally
((
t
)
->
{
erroMessage
.
append
(
indexLine
[
0
]).
append
(
" 行 错误"
).
append
(
t
.
getMessage
()).
append
(
";\n"
);
erroMessage
.
append
(
indexLine
[
0
]).
append
(
" 行 错误"
).
append
(
t
.
getMessage
()).
append
(
";\n"
);
logger
.
error
(
"the line "
+
indexLine
[
0
],
t
);
logger
.
error
(
"the line "
+
indexLine
[
0
],
t
);
return
null
;
return
null
;
})
})
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
CompletableFuture
.
allOf
(
futures
).
join
();
CompletableFuture
.
allOf
(
futures
).
join
();
executorService
.
shutdownNow
();
executorService
.
shutdownNow
();
stopWatch
.
stop
();
stopWatch
.
stop
();
logger
.
info
(
"dmp income upload {} line data use all {}s "
,
rowNumber
-
1
,
stopWatch
.
getTotalTimeSeconds
());
logger
.
info
(
"dmp income upload {} line data use all {}s "
,
rowNumber
-
1
,
stopWatch
.
getTotalTimeSeconds
());
if
(
erroMessage
.
length
()
>
0
)
{
if
(
erroMessage
.
length
()
>
0
)
{
return
ResultModel
.
ERROR
(
erroMessage
.
toString
());
return
ResultModel
.
ERROR
(
erroMessage
.
toString
());
}
}
return
ResultModel
.
OK
();
return
ResultModel
.
OK
();
}
}
@Override
@Override
public
ResultModel
contractUploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
public
ResultModel
contractUploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
)
{
Workbook
workbook
=
getWorkbook
(
file
);
Workbook
workbook
=
getWorkbook
(
file
);
if
(
workbook
==
null
)
{
if
(
workbook
==
null
)
{
return
ResultModel
.
ERROR
(
"获取上传文件错误"
);
return
ResultModel
.
ERROR
(
"获取上传文件错误"
);
}
}
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
String
sheetName
=
sheet
.
getSheetName
();
String
sheetName
=
sheet
.
getSheetName
();
if
(!
sheetName
.
equalsIgnoreCase
(
SHEET_NAMES
.
get
(
platform
)))
{
if
(!
sheetName
.
equalsIgnoreCase
(
SHEET_NAMES
.
get
(
platform
)))
{
return
ResultModel
.
ERROR
(
"请上传对应项目模板处理的数据"
);
return
ResultModel
.
ERROR
(
"请上传对应项目模板处理的数据"
);
}
}
int
rowNumber
=
checkSheetTitle
(
workbook
,
platform
);
int
rowNumber
=
checkSheetTitle
(
workbook
,
platform
);
if
(
rowNumber
==
-
1
)
{
if
(
rowNumber
==
-
1
)
{
return
ResultModel
.
ERROR
(
"模板表头错误"
);
return
ResultModel
.
ERROR
(
"模板表头错误"
);
}
else
if
(
rowNumber
<=
1
)
{
}
else
if
(
rowNumber
<=
1
)
{
return
ResultModel
.
ERROR
(
"文件为空"
);
return
ResultModel
.
ERROR
(
"文件为空"
);
}
}
List
<
Contract
>
allContracts
=
new
ArrayList
<>();
List
<
Contract
>
allContracts
=
new
ArrayList
<>();
Map
<
String
,
Long
>
tradTypeMap
=
tradeTypeRepsitory
.
findAll
()
Map
<
String
,
Long
>
tradTypeMap
=
tradeTypeRepsitory
.
findAll
()
.
stream
().
collect
(
Collectors
.
toMap
(
TradeType:
:
getName
,
TradeType:
:
getId
));
.
stream
().
collect
(
Collectors
.
toMap
(
TradeType:
:
getName
,
TradeType:
:
getId
));
Map
<
String
,
Long
>
salseMap
=
salesRepository
.
findSaleByStatus
(
0
)
Map
<
String
,
Long
>
salseMap
=
salesRepository
.
findSaleByStatus
(
0
)
.
stream
().
collect
(
Collectors
.
toMap
(
Sales:
:
getName
,
Sales:
:
getId
));
.
stream
().
collect
(
Collectors
.
toMap
(
Sales:
:
getName
,
Sales:
:
getId
));
Map
<
Long
,
String
>
barrioCityMap
=
barrioCityRepository
.
findAll
()
Map
<
Long
,
String
>
barrioCityMap
=
barrioCityRepository
.
findAll
()
.
stream
().
collect
(
Collectors
.
toMap
(
BarrioCity:
:
getId
,
BarrioCity:
:
getName
));
.
stream
().
collect
(
Collectors
.
toMap
(
BarrioCity:
:
getId
,
BarrioCity:
:
getName
));
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
Map
<
String
,
String
>
cBodyMap
=
contractBodyRepository
.
findAllDis
()
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getName
,
ContractBody:
:
getCode
,
(
v1
,
v2
)
->
v1
));
.
stream
().
collect
(
Collectors
.
toMap
(
ContractBody:
:
getName
,
ContractBody:
:
getCode
,
(
v1
,
v2
)
->
v1
));
for
(
int
i
=
1
;
i
<
rowNumber
;
i
++)
{
for
(
int
i
=
1
;
i
<
rowNumber
;
i
++)
{
Row
rowItem
=
sheet
.
getRow
(
i
);
Row
rowItem
=
sheet
.
getRow
(
i
);
if
(
rowItem
==
null
)
{
if
(
rowItem
==
null
)
{
break
;
break
;
}
}
Contract
contract
=
new
Contract
();
Contract
contract
=
new
Contract
();
contract
.
setPlatform
(
platform
);
contract
.
setPlatform
(
platform
);
contract
.
setProduct
(
platform
);
contract
.
setProduct
(
platform
);
contract
.
setStatus
(
"normal"
);
contract
.
setStatus
(
"normal"
);
contract
.
setType
(
"main"
);
contract
.
setType
(
"main"
);
contract
.
setCreateAccount
(
loginAccount
.
getId
());
contract
.
setCreateAccount
(
loginAccount
.
getId
());
contract
.
setCreateName
(
loginAccount
.
getName
());
contract
.
setCreateName
(
loginAccount
.
getName
());
contract
.
setDs
(
DateTime
.
now
().
toString
(
"yyyy-MM-dd"
));
contract
.
setDs
(
DateTime
.
now
().
toString
(
"yyyy-MM-dd"
));
String
sysErro
=
null
;
String
sysErro
=
null
;
try
{
try
{
//填充数据
//填充数据
fillDataByRow
(
contract
,
rowItem
);
fillDataByRow
(
contract
,
rowItem
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"the line "
+
i
,
e
);
logger
.
error
(
"the line "
+
i
,
e
);
sysErro
=
e
.
getMessage
();
sysErro
=
e
.
getMessage
();
}
}
if
(
sysErro
!=
null
)
{
if
(
sysErro
!=
null
)
{
return
erroValueTip
(
i
,
sysErro
);
return
erroValueTip
(
i
,
sysErro
);
}
}
//校验数据有效性
//校验数据有效性
if
(
"erro"
.
equals
(
contract
.
getStartDate
())
||
"erro"
.
equals
(
contract
.
getEndDate
()))
{
if
(
"erro"
.
equals
(
contract
.
getStartDate
())
||
"erro"
.
equals
(
contract
.
getEndDate
()))
{
return
erroValueTip
(
i
,
"开始时间或结束时间"
);
return
erroValueTip
(
i
,
"开始时间或结束时间"
);
}
}
if
(!
tradTypeMap
.
containsKey
(
contract
.
getTradeName
()))
{
if
(!
tradTypeMap
.
containsKey
(
contract
.
getTradeName
()))
{
return
erroValueTip
(
i
,
"行业分类"
);
return
erroValueTip
(
i
,
"行业分类"
);
}
else
{
}
else
{
contract
.
setTradeType
(
Integer
.
parseInt
(
tradTypeMap
.
get
(
contract
.
getTradeName
())
+
""
));
contract
.
setTradeType
(
Integer
.
parseInt
(
tradTypeMap
.
get
(
contract
.
getTradeName
())
+
""
));
}
}
if
(!
cBodyMap
.
containsKey
(
contract
.
getMyBodyName
()))
{
if
(!
cBodyMap
.
containsKey
(
contract
.
getMyBodyName
()))
{
return
erroValueTip
(
i
,
"我方签约主体"
);
return
erroValueTip
(
i
,
"我方签约主体"
);
}
else
{
}
else
{
contract
.
setMyBodyCode
(
cBodyMap
.
get
(
contract
.
getMyBodyName
()));
contract
.
setMyBodyCode
(
cBodyMap
.
get
(
contract
.
getMyBodyName
()));
}
}
if
(
StringUtils
.
isEmpty
(
contract
.
getCustomerBody
()))
{
if
(
StringUtils
.
isEmpty
(
contract
.
getCustomerBody
()))
{
return
erroValueTip
(
i
,
"客户签约主体"
);
return
erroValueTip
(
i
,
"客户签约主体"
);
}
}
if
(!
barrioCityMap
.
containsKey
(
contract
.
getBarrioId
()))
{
if
(!
barrioCityMap
.
containsKey
(
contract
.
getBarrioId
()))
{
return
erroValueTip
(
i
,
"行政区域"
);
return
erroValueTip
(
i
,
"行政区域"
);
}
else
{
}
else
{
contract
.
setBarrioName
(
barrioCityMap
.
get
(
contract
.
getBarrioId
()));
contract
.
setBarrioName
(
barrioCityMap
.
get
(
contract
.
getBarrioId
()));
}
}
if
(!
salseMap
.
containsKey
(
contract
.
getSaleName
()))
{
if
(!
salseMap
.
containsKey
(
contract
.
getSaleName
()))
{
return
erroValueTip
(
i
,
"签约销售"
);
return
erroValueTip
(
i
,
"签约销售"
);
}
else
{
}
else
{
contract
.
setSale
(
salseMap
.
get
(
contract
.
getSaleName
()));
contract
.
setSale
(
salseMap
.
get
(
contract
.
getSaleName
()));
}
}
/*if (StringUtils.isEmpty(contract.getEmail())) {
/*if (StringUtils.isEmpty(contract.getEmail())) {
return erroValueTip(i, "客户主账号");
return erroValueTip(i, "客户主账号");
}*/
}*/
if
(
StringUtils
.
isEmpty
(
contract
.
getContractCode
()))
{
if
(
StringUtils
.
isEmpty
(
contract
.
getContractCode
()))
{
return
erroValueTip
(
i
,
"合同编号"
);
return
erroValueTip
(
i
,
"合同编号"
);
}
else
{
}
else
{
String
[]
codeArr
=
contract
.
getContractCode
().
split
(
"-"
);
String
[]
codeArr
=
contract
.
getContractCode
().
split
(
"-"
);
if
(
codeArr
.
length
==
4
)
{
if
(
codeArr
.
length
==
4
)
{
contract
.
setCodeNum
(
Integer
.
parseInt
(
codeArr
[
3
]));
contract
.
setCodeNum
(
Integer
.
parseInt
(
codeArr
[
3
]));
}
}
}
}
if
(!
CONTRACT_TYPE_NAME
.
containsKey
(
contract
.
getContractType
())
&&
!
"续签"
.
equals
(
contract
.
getContractType
()))
{
if
(!
CONTRACT_TYPE_NAME
.
containsKey
(
contract
.
getContractType
())
&&
!
"续签"
.
equals
(
contract
.
getContractType
()))
{
return
erroValueTip
(
i
,
"签约类型"
);
return
erroValueTip
(
i
,
"签约类型"
);
}
else
{
}
else
{
contract
.
setContractType
(
CONTRACT_TYPE_NAME
.
get
(
contract
.
getContractType
()));
contract
.
setContractType
(
CONTRACT_TYPE_NAME
.
get
(
contract
.
getContractType
()));
if
(
"续签"
.
equals
(
contract
.
getContractType
()))
{
if
(
"续签"
.
equals
(
contract
.
getContractType
()))
{
contract
.
setContractType
(
"1"
);
contract
.
setContractType
(
"1"
);
}
}
}
}
if
(!
BUSINESS_TYPE_NAME
.
containsKey
(
contract
.
getBusinessTypeName
()))
{
if
(!
BUSINESS_TYPE_NAME
.
containsKey
(
contract
.
getBusinessTypeName
()))
{
return
erroValueTip
(
i
,
"业务类型"
);
return
erroValueTip
(
i
,
"业务类型"
);
}
else
{
}
else
{
contract
.
setBusinessType
(
Integer
.
parseInt
(
BUSINESS_TYPE_NAME
.
get
(
contract
.
getBusinessTypeName
())));
contract
.
setBusinessType
(
Integer
.
parseInt
(
BUSINESS_TYPE_NAME
.
get
(
contract
.
getBusinessTypeName
())));
}
}
if
(!
SETAGREEMENT_TYPE_NAME
.
containsKey
(
contract
.
getAgreementTypeName
()))
{
if
(!
SETAGREEMENT_TYPE_NAME
.
containsKey
(
contract
.
getAgreementTypeName
()))
{
return
erroValueTip
(
i
,
"协议类型"
);
return
erroValueTip
(
i
,
"协议类型"
);
}
else
{
}
else
{
contract
.
setAgreementType
(
Integer
.
parseInt
(
SETAGREEMENT_TYPE_NAME
.
get
(
contract
.
getAgreementTypeName
())));
contract
.
setAgreementType
(
Integer
.
parseInt
(
SETAGREEMENT_TYPE_NAME
.
get
(
contract
.
getAgreementTypeName
())));
}
}
allContracts
.
add
(
contract
);
allContracts
.
add
(
contract
);
}
}
if
(
allContracts
.
isEmpty
())
{
if
(
allContracts
.
isEmpty
())
{
return
ResultModel
.
ERROR
(
"上传内容为空"
);
return
ResultModel
.
ERROR
(
"上传内容为空"
);
}
}
//allContracts.stream().map(v->v.getRelationCode()).collect(Collectors.toList())
//allContracts.stream().map(v->v.getRelationCode()).collect(Collectors.toList())
CompletableFuture
.
runAsync
(()
->
{
CompletableFuture
.
runAsync
(()
->
{
StopWatch
stopWatch
=
new
StopWatch
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
stopWatch
.
start
();
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
35
);
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
35
);
CompletableFuture
[]
futures
=
allContracts
.
stream
()
CompletableFuture
[]
futures
=
allContracts
.
stream
()
.
map
(
contract
->
CompletableFuture
.
runAsync
(()
->
{
.
map
(
contract
->
CompletableFuture
.
runAsync
(()
->
{
if
(!
StringUtils
.
isEmpty
(
contract
.
getRelationCode
()))
{
if
(!
StringUtils
.
isEmpty
(
contract
.
getRelationCode
()))
{
List
<
Long
>
idList
=
contractRepository
.
findIdByCode
(
contract
.
getRelationCode
());
List
<
Long
>
idList
=
contractRepository
.
findIdByCode
(
contract
.
getRelationCode
());
if
(!
idList
.
isEmpty
())
{
if
(!
idList
.
isEmpty
())
{
contract
.
setRelationContract
(
idList
.
get
(
0
));
contract
.
setRelationContract
(
idList
.
get
(
0
));
}
else
{
}
else
{
contract
.
setRelationContract
(-
1L
);
contract
.
setRelationContract
(-
1L
);
}
}
}
else
{
}
else
{
contract
.
setRelationContract
(-
1L
);
contract
.
setRelationContract
(-
1L
);
}
}
if
(
contract
.
getRelationContract
()
<
0
)
{
if
(
contract
.
getRelationContract
()
<
0
)
{
contract
.
setRelationCode
(
null
);
contract
.
setRelationCode
(
null
);
}
}
//删除已经重复的记录
//删除已经重复的记录
contractRepository
.
deleteByCode
(
contract
.
getContractCode
(),
platform
);
contractRepository
.
deleteByCode
(
contract
.
getContractCode
(),
platform
);
contract
.
setCreateTime
(
new
Date
());
contract
.
setCreateTime
(
new
Date
());
contractRepository
.
save
(
contract
);
contractRepository
.
save
(
contract
);
},
executorService
).
exceptionally
((
t
)
->
null
)
},
executorService
).
exceptionally
((
t
)
->
null
)
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
CompletableFuture
.
allOf
(
futures
).
join
();
CompletableFuture
.
allOf
(
futures
).
join
();
executorService
.
shutdownNow
();
executorService
.
shutdownNow
();
stopWatch
.
stop
();
stopWatch
.
stop
();
logger
.
info
(
"{} contract upload {} line data use all {}s "
,
platform
,
allContracts
.
size
(),
stopWatch
.
getTotalTimeSeconds
());
logger
.
info
(
"{} contract upload {} line data use all {}s "
,
platform
,
allContracts
.
size
(),
stopWatch
.
getTotalTimeSeconds
());
});
});
return
ResultModel
.
OK
();
return
ResultModel
.
OK
();
}
}
private
int
checkSheetTitle
(
Workbook
workbook
,
String
platform
)
{
private
int
checkSheetTitle
(
Workbook
workbook
,
String
platform
)
{
String
sheetTitle
=
null
;
String
sheetTitle
=
null
;
String
code
=
"\t"
;
String
code
=
"\t"
;
if
(
"dmp"
.
equals
(
platform
))
{
if
(
"dmp"
.
equals
(
platform
))
{
//dmp 合同
//dmp 合同
sheetTitle
=
"我方签约主体\t客户签约主体\t客户简称\t第三方签约主体\t行政区域\t隶属集团\t行业分类\t合同开始日期\t合同结束日期\t签约销售\t客户主账号\t合同编号\t签约类型\t业务类型\t协议类型\t合同金额\t关联合同编号"
;
sheetTitle
=
"我方签约主体\t客户签约主体\t客户简称\t第三方签约主体\t行政区域\t隶属集团\t行业分类\t合同开始日期\t合同结束日期\t签约销售\t客户主账号\t合同编号\t签约类型\t业务类型\t协议类型\t合同金额\t关联合同编号"
;
}
else
if
(
"dmp_income"
.
equals
(
platform
))
{
}
else
if
(
"dmp_income"
.
equals
(
platform
))
{
//dmp 收入
//dmp 收入
sheetTitle
=
"合同编号\t收入月份\t结算周期\t系统结算\t按月结算\t税率\t确认收入"
;
sheetTitle
=
"合同编号\t收入月份\t结算周期\t系统结算\t按月结算\t税率\t确认收入"
;
}
}
if
(
sheetTitle
==
null
)
{
if
(
sheetTitle
==
null
)
{
return
-
1
;
return
-
1
;
}
}
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Row
row
=
sheet
.
getRow
(
0
);
Row
row
=
sheet
.
getRow
(
0
);
int
sheLength
=
sheetTitle
.
split
(
"\t"
).
length
;
int
sheLength
=
sheetTitle
.
split
(
"\t"
).
length
;
StringBuffer
titleUp
=
new
StringBuffer
();
StringBuffer
titleUp
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
sheLength
;
i
++)
{
for
(
int
i
=
0
;
i
<
sheLength
;
i
++)
{
if
(
i
>
0
)
titleUp
.
append
(
code
);
if
(
i
>
0
)
titleUp
.
append
(
code
);
titleUp
.
append
(
row
.
getCell
(
i
));
titleUp
.
append
(
row
.
getCell
(
i
));
}
}
if
(!
titleUp
.
toString
().
equals
(
sheetTitle
))
{
if
(!
titleUp
.
toString
().
equals
(
sheetTitle
))
{
return
-
1
;
return
-
1
;
}
}
//总行数
//总行数
sheLength
=
sheet
.
getLastRowNum
()
+
1
;
sheLength
=
sheet
.
getLastRowNum
()
+
1
;
return
sheLength
;
return
sheLength
;
}
}
private
Workbook
getWorkbook
(
MultipartFile
excelfile
)
{
private
Workbook
getWorkbook
(
MultipartFile
excelfile
)
{
InputStream
stream
=
null
;
InputStream
stream
=
null
;
Workbook
workbook
=
null
;
Workbook
workbook
=
null
;
try
{
try
{
stream
=
excelfile
.
getInputStream
();
stream
=
excelfile
.
getInputStream
();
workbook
=
WorkbookFactory
.
create
(
stream
);
workbook
=
WorkbookFactory
.
create
(
stream
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
""
,
e
);
logger
.
error
(
""
,
e
);
}
finally
{
}
finally
{
if
(
stream
!=
null
)
{
if
(
stream
!=
null
)
{
try
{
try
{
stream
.
close
();
stream
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
error
(
""
,
e
);
logger
.
error
(
""
,
e
);
}
}
}
}
}
}
return
workbook
;
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
);
//合同编号 收入月份 结算周期 系统结算 按月结算 税率 确认收入
//合同编号 收入月份 结算周期 系统结算 按月结算 税率 确认收入
DmpIncome
income
=
new
DmpIncome
();
DmpIncome
income
=
new
DmpIncome
();
income
.
setIndex
(
index
);
income
.
setIndex
(
index
);
income
.
setContractCode
(
getCellStringValue
(
rowItem
,
0
));
income
.
setContractCode
(
getCellStringValue
(
rowItem
,
0
));
income
.
setIncomeMonth
(
getCellDateValue
(
rowItem
,
1
,
"yyyy-MM"
));
income
.
setIncomeMonth
(
getCellDateValue
(
rowItem
,
1
,
"yyyy-MM"
));
income
.
setPeriod
(
getCellStringValue
(
rowItem
,
2
));
income
.
setPeriod
(
getCellStringValue
(
rowItem
,
2
));
income
.
setSysSettlement
(
getCellStringValue
(
rowItem
,
3
));
income
.
setSysSettlement
(
getCellStringValue
(
rowItem
,
3
));
income
.
setMonthSettlement
(
getCellStringValue
(
rowItem
,
4
));
income
.
setMonthSettlement
(
getCellStringValue
(
rowItem
,
4
));
income
.
setTaxRate
(
getCellStringValue
(
rowItem
,
5
));
income
.
setTaxRate
(
getCellStringValue
(
rowItem
,
5
));
income
.
setConfirmSettlement
(
getCellStringValue
(
rowItem
,
6
));
income
.
setConfirmSettlement
(
getCellStringValue
(
rowItem
,
6
));
// 时间 上传人
// 时间 上传人
income
.
setCreateTime
(
new
Date
());
income
.
setCreateTime
(
new
Date
());
income
.
setUploadUser
(
user
.
getName
());
income
.
setUploadUser
(
user
.
getName
());
if
(
StringUtils
.
isEmpty
(
income
.
getContractCode
()))
{
if
(
StringUtils
.
isEmpty
(
income
.
getContractCode
()))
{
return
null
;
return
null
;
}
}
Double
drate
=
StringUtils
.
isEmpty
(
income
.
getTaxRate
())
?
0
:
Double
.
parseDouble
(
income
.
getTaxRate
());
Double
drate
=
StringUtils
.
isEmpty
(
income
.
getTaxRate
())
?
0
:
Double
.
parseDouble
(
income
.
getTaxRate
());
drate
=
new
BigDecimal
(
drate
*
100
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
drate
=
new
BigDecimal
(
drate
*
100
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
income
.
setTaxRate
(
drate
+
"%"
);
income
.
setTaxRate
(
drate
+
"%"
);
if
(
StringUtils
.
isEmpty
(
income
.
getSysSettlement
()))
{
if
(
StringUtils
.
isEmpty
(
income
.
getSysSettlement
()))
{
income
.
setSysSettlement
(
"0"
);
income
.
setSysSettlement
(
"0"
);
}
}
DmpIncome
one
=
dmpIncomeRepository
.
findByCodeMonth
(
income
.
getContractCode
(),
income
.
getIncomeMonth
());
DmpIncome
one
=
dmpIncomeRepository
.
findByCodeMonth
(
income
.
getContractCode
(),
income
.
getIncomeMonth
());
if
(
one
!=
null
)
{
if
(
one
!=
null
)
{
// 同一合同同一月份不重复保存
// 同一合同同一月份不重复保存
return
null
;
return
null
;
}
}
return
income
;
return
income
;
}
}
private
String
getCellDateValue
(
Row
row
,
int
index
)
{
private
String
getCellDateValue
(
Row
row
,
int
index
)
{
return
getCellDateValue
(
row
,
index
,
null
);
return
getCellDateValue
(
row
,
index
,
null
);
}
}
private
String
getCellDateValue
(
Row
row
,
int
index
,
String
fm
)
{
private
String
getCellDateValue
(
Row
row
,
int
index
,
String
fm
)
{
Cell
cell
=
row
.
getCell
(
index
);
Cell
cell
=
row
.
getCell
(
index
);
if
(
cell
==
null
)
{
if
(
cell
==
null
)
{
return
"erro"
;
return
"erro"
;
}
}
String
dfmate
=
cell
.
getCellStyle
().
getDataFormatString
();
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
)
&&
!
"yyyy\"年\"m\"月\";@"
.
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"
;
return
"erro"
;
}
}
if
(
fm
==
null
)
{
if
(
fm
==
null
)
{
fm
=
"yyyy-MM-dd"
;
fm
=
"yyyy-MM-dd"
;
}
}
if
(
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
isCellDateFormatted
(
cell
))
{
if
(
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
isCellDateFormatted
(
cell
))
{
// 用于转化为日期格式
// 用于转化为日期格式
Date
d
=
cell
.
getDateCellValue
();
Date
d
=
cell
.
getDateCellValue
();
DateFormat
formater
=
new
SimpleDateFormat
(
fm
);
DateFormat
formater
=
new
SimpleDateFormat
(
fm
);
return
formater
.
format
(
d
);
return
formater
.
format
(
d
);
}
}
return
cell
.
toString
();
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
().
trim
();
return
cell
==
null
?
""
:
cell
.
toString
().
trim
();
}
}
private
String
getCellStringValue
(
Row
row
,
int
index
,
String
defaulValue
)
{
private
String
getCellStringValue
(
Row
row
,
int
index
,
String
defaulValue
)
{
Cell
cell
=
row
.
getCell
(
index
);
Cell
cell
=
row
.
getCell
(
index
);
return
cell
==
null
?
defaulValue
:
cell
.
toString
();
return
cell
==
null
?
defaulValue
:
cell
.
toString
();
}
}
private
void
fillDataByRow
(
Contract
contract
,
Row
rowItem
)
{
private
void
fillDataByRow
(
Contract
contract
,
Row
rowItem
)
{
//我方签约主体 客户签约主体 客户简称
//我方签约主体 客户签约主体 客户简称
contract
.
setMyBodyName
(
getCellStringValue
(
rowItem
,
0
));
contract
.
setMyBodyName
(
getCellStringValue
(
rowItem
,
0
));
contract
.
setCustomerBody
(
getCellStringValue
(
rowItem
,
1
));
contract
.
setCustomerBody
(
getCellStringValue
(
rowItem
,
1
));
contract
.
setCustomerShort
(
getCellStringValue
(
rowItem
,
2
));
contract
.
setCustomerShort
(
getCellStringValue
(
rowItem
,
2
));
// 第三方签约主体 行政区域 隶属集团 行业分类
// 第三方签约主体 行政区域 隶属集团 行业分类
contract
.
setCustomerThird
(
getCellStringValue
(
rowItem
,
3
));
contract
.
setCustomerThird
(
getCellStringValue
(
rowItem
,
3
));
contract
.
setBarrioId
(
new
BigDecimal
(
getCellStringValue
(
rowItem
,
4
,
"0"
)).
longValue
());
contract
.
setBarrioId
(
new
BigDecimal
(
getCellStringValue
(
rowItem
,
4
,
"0"
)).
longValue
());
contract
.
setBelongGroup
(
getCellStringValue
(
rowItem
,
5
));
contract
.
setBelongGroup
(
getCellStringValue
(
rowItem
,
5
));
contract
.
setTradeName
(
getCellStringValue
(
rowItem
,
6
));
contract
.
setTradeName
(
getCellStringValue
(
rowItem
,
6
));
// 合同开始日期 合同结束日期 签约销售 客户主账号
// 合同开始日期 合同结束日期 签约销售 客户主账号
contract
.
setStartDate
(
getCellDateValue
(
rowItem
,
7
));
contract
.
setStartDate
(
getCellDateValue
(
rowItem
,
7
));
contract
.
setEndDate
(
getCellDateValue
(
rowItem
,
8
));
contract
.
setEndDate
(
getCellDateValue
(
rowItem
,
8
));
contract
.
setSaleName
(
getCellStringValue
(
rowItem
,
9
));
contract
.
setSaleName
(
getCellStringValue
(
rowItem
,
9
));
contract
.
setEmail
(
getCellStringValue
(
rowItem
,
10
));
contract
.
setEmail
(
getCellStringValue
(
rowItem
,
10
));
// 合同编号 签约类型 业务类型 协议类型 合同金额 关联合同编号
// 合同编号 签约类型 业务类型 协议类型 合同金额 关联合同编号
contract
.
setContractCode
(
getCellStringValue
(
rowItem
,
11
));
contract
.
setContractCode
(
getCellStringValue
(
rowItem
,
11
));
contract
.
setContractType
(
getCellStringValue
(
rowItem
,
12
));
contract
.
setContractType
(
getCellStringValue
(
rowItem
,
12
));
contract
.
setBusinessTypeName
(
getCellStringValue
(
rowItem
,
13
));
contract
.
setBusinessTypeName
(
getCellStringValue
(
rowItem
,
13
));
contract
.
setAgreementTypeName
(
getCellStringValue
(
rowItem
,
14
));
contract
.
setAgreementTypeName
(
getCellStringValue
(
rowItem
,
14
));
contract
.
setMoney
(
Double
.
parseDouble
(
getCellStringValue
(
rowItem
,
15
,
"0"
)));
contract
.
setMoney
(
Double
.
parseDouble
(
getCellStringValue
(
rowItem
,
15
,
"0"
)));
contract
.
setRelationCode
(
getCellStringValue
(
rowItem
,
16
));
contract
.
setRelationCode
(
getCellStringValue
(
rowItem
,
16
));
}
}
private
ResultModel
erroValueTip
(
int
line
,
String
title
)
{
private
ResultModel
erroValueTip
(
int
line
,
String
title
)
{
return
ResultModel
.
ERROR
(
"第"
+
line
+
"行,["
+
title
+
"]错误"
);
return
ResultModel
.
ERROR
(
"第"
+
line
+
"行,["
+
title
+
"]错误"
);
}
}
@Override
@Override
public
List
listpdIncomeByCode
(
String
code
)
{
public
List
listpdIncomeByCode
(
String
code
)
{
return
pdIncomeRepository
.
findByContractCode
(
code
);
return
pdIncomeRepository
.
findByContractCode
(
code
);
}
}
@Override
@Override
public
PdIncome
pdCreate
(
PdIncome
income
,
User
user
)
{
public
PdIncome
pdCreate
(
PdIncome
income
,
User
user
)
{
income
.
setCreateTime
(
new
Date
());
income
.
setCreateTime
(
new
Date
());
income
.
setInputDate
(
DateTime
.
now
().
toString
(
"yyyy-MM-dd"
));
income
.
setInputDate
(
DateTime
.
now
().
toString
(
"yyyy-MM-dd"
));
income
.
setInputUser
(
user
.
getName
());
income
.
setInputUser
(
user
.
getName
());
income
=
cacluConfirmIncome
(
income
);
income
=
cacluConfirmIncome
(
income
);
return
pdIncomeRepository
.
save
(
income
);
return
pdIncomeRepository
.
save
(
income
);
}
}
private
PdIncome
cacluConfirmIncome
(
PdIncome
income
)
{
private
PdIncome
cacluConfirmIncome
(
PdIncome
income
)
{
if
(!
StringUtils
.
isEmpty
(
income
.
getAcceptanceAmount
()))
{
if
(!
StringUtils
.
isEmpty
(
income
.
getAcceptanceAmount
()))
{
Double
rax
=
Double
.
parseDouble
(
income
.
getTaxRate
().
replace
(
"%"
,
""
))
/
100
+
1
;
Double
rax
=
Double
.
parseDouble
(
income
.
getTaxRate
().
replace
(
"%"
,
""
))
/
100
+
1
;
Double
confirmIncome
=
Double
.
parseDouble
(
income
.
getAcceptanceAmount
())
/
rax
;
Double
confirmIncome
=
Double
.
parseDouble
(
income
.
getAcceptanceAmount
())
/
rax
;
income
.
setConfirmIncome
(
new
BigDecimal
(
confirmIncome
).
setScale
(
2
,
BigDecimal
.
ROUND_UP
).
toString
());
income
.
setConfirmIncome
(
new
BigDecimal
(
confirmIncome
).
setScale
(
2
,
BigDecimal
.
ROUND_UP
).
toString
());
}
else
{
}
else
{
income
.
setConfirmIncome
(
"0"
);
income
.
setConfirmIncome
(
"0"
);
}
}
return
income
;
return
income
;
}
}
@Override
@Override
public
PdIncome
pdUpdate
(
PdIncome
income
)
{
public
PdIncome
pdUpdate
(
PdIncome
income
)
{
PdIncome
item
=
pdIncomeRepository
.
findOne
(
income
.
getId
());
PdIncome
item
=
pdIncomeRepository
.
findOne
(
income
.
getId
());
item
.
setModifyTime
(
new
Date
());
item
.
setModifyTime
(
new
Date
());
item
.
setAcceptanceAmount
(
income
.
getAcceptanceAmount
());
item
.
setAcceptanceAmount
(
income
.
getAcceptanceAmount
());
item
.
setConfirmIncome
(
cacluConfirmIncome
(
income
).
getConfirmIncome
());
item
.
setConfirmIncome
(
cacluConfirmIncome
(
income
).
getConfirmIncome
());
item
.
setIncomeType
(
income
.
getIncomeType
());
item
.
setIncomeType
(
income
.
getIncomeType
());
item
.
setTaxRate
(
income
.
getTaxRate
());
item
.
setTaxRate
(
income
.
getTaxRate
());
item
.
setSettlementDate
(
income
.
getSettlementDate
());
item
.
setSettlementDate
(
income
.
getSettlementDate
());
pdIncomeRepository
.
save
(
item
);
pdIncomeRepository
.
save
(
item
);
return
item
;
return
item
;
}
}
@Override
@Override
public
int
pdDelete
(
PdIncome
income
)
{
public
int
pdDelete
(
PdIncome
income
)
{
pdIncomeRepository
.
delete
(
income
.
getId
());
pdIncomeRepository
.
delete
(
income
.
getId
());
return
1
;
return
1
;
}
}
@Override
@Override
public
PdAttachment
uploadPdAttach
(
MultipartFile
file
,
String
contractCode
,
User
user
)
{
public
PdAttachment
uploadPdAttach
(
MultipartFile
file
,
String
contractCode
,
User
user
)
{
InputStream
inputStream
=
null
;
InputStream
inputStream
=
null
;
PdAttachment
attachment
=
new
PdAttachment
();
try
{
try
{
inputStream
=
file
.
getInputStream
();
inputStream
=
file
.
getInputStream
();
PdAttachment
attachment
=
new
PdAttachment
();
attachment
.
setUploadDate
(
new
Date
());
attachment
.
setUploadDate
(
new
Date
());
attachment
.
setUploadDateValue
(
new
DateTime
(
attachment
.
getUploadDate
()).
toString
(
"yyyy-MM-dd HH:mm:ss"
));
attachment
.
setUploadUser
(
user
.
getName
());
attachment
.
setUploadUser
(
user
.
getName
());
attachment
.
setFileOrginName
(
file
.
getOriginalFilename
());
attachment
.
setFileOrginName
(
file
.
getOriginalFilename
());
attachment
.
setFileName
(
contractCode
+
"_"
+
file
.
getOriginalFilename
());
attachment
.
setFileName
(
contractCode
+
"_"
+
file
.
getOriginalFilename
());
attachment
.
setContractCode
(
contractCode
);
attachment
.
setContractCode
(
contractCode
);
attachment
.
setFileType
(
file
.
getContentType
());
attachment
.
setFileType
(
file
.
getContentType
());
// 上传文件
attachment
.
setFaild
(
false
);
String
s3key
=
Constant
.
uploadPath
+
attachment
.
getFileName
();
// 上传文件
String
contentType
=
file
.
getContentType
();
String
s3key
=
Constant
.
uploadPath
+
"/"
+
attachment
.
getFileName
();
AwsS3Util
.
getInstance
().
uploadStreamToS3
(
Constant
.
bucket
,
s3key
,
String
contentType
=
file
.
getContentType
();
inputStream
,
contentType
,
file
.
getSize
());
AwsS3Util
.
getInstance
().
uploadStreamToS3
(
Constant
.
bucket
,
s3key
,
pdAttachmentRepository
.
save
(
attachment
);
inputStream
,
contentType
,
file
.
getSize
());
pdAttachmentRepository
.
save
(
attachment
);
return
attachment
;
return
attachment
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
}
finally
{
}
finally
{
if
(
inputStream
!=
null
)
{
if
(
inputStream
!=
null
)
{
try
{
try
{
inputStream
.
close
();
inputStream
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
}
}
}
}
}
}
return
null
;
attachment
.
setFaild
(
true
);
}
return
attachment
;
}
@Override
public
ResponseEntity
<
byte
[]>
downloadAttach
(
Long
id
)
{
@Override
public
ResponseEntity
<
byte
[]>
downloadAttach
(
Long
id
)
{
PdAttachment
attachment
=
pdAttachmentRepository
.
findOne
(
id
);
final
String
s3key
=
Constant
.
uploadPath
+
attachment
.
getFileName
();
PdAttachment
attachment
=
pdAttachmentRepository
.
findOne
(
id
);
String
fileName
=
attachment
.
getFileOrginName
();
final
String
s3key
=
Constant
.
uploadPath
+
"/"
+
attachment
.
getFileName
();
InputStream
in
=
null
;
String
fileName
=
attachment
.
getFileOrginName
();
byte
[]
content
;
String
fileType
=
attachment
.
getFileType
();
InputStream
in
=
null
;
try
{
byte
[]
content
;
in
=
AwsS3Util
.
getInstance
().
downloadStreamFromS3
(
Constant
.
bucket
,
s3key
);
String
fileType
=
attachment
.
getFileType
();
content
=
IOUtils
.
toByteArray
(
in
);
try
{
HttpHeaders
headers
=
new
HttpHeaders
();
fileName
=
URLEncoder
.
encode
(
fileName
,
"UTF-8"
);
headers
.
set
(
"filename"
,
fileName
);
in
=
AwsS3Util
.
getInstance
().
downloadStreamFromS3
(
Constant
.
bucket
,
s3key
);
headers
.
add
(
"content-disposition"
,
"attachment; filename="
+
fileName
);
content
=
IOUtils
.
toByteArray
(
in
);
headers
.
add
(
"Content-Type"
,
fileType
);
HttpHeaders
headers
=
new
HttpHeaders
();
return
new
ResponseEntity
<>(
content
,
headers
,
org
.
springframework
.
http
.
HttpStatus
.
CREATED
);
headers
.
set
(
"filename"
,
fileName
);
}
catch
(
Exception
e
)
{
headers
.
add
(
"content-disposition"
,
"attachment;filename="
+
fileName
);
logger
.
error
(
"s3key:"
+
s3key
+
" bucket:"
+
Constant
.
bucket
,
e
);
headers
.
add
(
"Content-Type"
,
fileType
);
}
finally
{
return
new
ResponseEntity
<>(
content
,
headers
,
org
.
springframework
.
http
.
HttpStatus
.
CREATED
);
IOUtils
.
closeQuietly
(
in
);
}
catch
(
Exception
e
)
{
}
logger
.
error
(
"s3key:"
+
s3key
+
" bucket:"
+
Constant
.
bucket
,
e
);
return
null
;
}
finally
{
}
IOUtils
.
closeQuietly
(
in
);
}
@Override
return
null
;
public
PdAttachment
deleteAttach
(
Long
id
)
{
}
PdAttachment
attachment
=
pdAttachmentRepository
.
findOne
(
id
);
final
String
s3key
=
Constant
.
uploadPath
+
attachment
.
getFileName
();
@Override
AwsS3Util
.
getInstance
().
deleteS3Object
(
Constant
.
bucket
,
s3key
);
public
PdAttachment
deleteAttach
(
Long
id
)
{
pdAttachmentRepository
.
delete
(
id
);
PdAttachment
attachment
=
pdAttachmentRepository
.
findOne
(
id
);
return
attachment
;
final
String
s3key
=
Constant
.
uploadPath
+
attachment
.
getFileName
();
}
AwsS3Util
.
getInstance
().
deleteS3Object
(
Constant
.
bucket
,
s3key
);
pdAttachmentRepository
.
delete
(
id
);
return
attachment
;
}
@Override
public
ResultModel
attachList
(
String
code
,
String
startDate
,
String
endDate
,
String
platform
)
{
List
<
PdAttachment
>
attachments
;
if
(
StringUtils
.
isEmpty
(
startDate
))
{
attachments
=
pdAttachmentRepository
.
findBycontractCodeAndDate
(
code
,
startDate
,
endDate
);
}
else
{
attachments
=
pdAttachmentRepository
.
findBycontractCode
(
code
);
}
return
ResultModel
.
OK
(
attachments
);
}
}
}
src/main/java/util/Constant.java
View file @
00227a49
...
@@ -45,6 +45,7 @@ public class Constant {
...
@@ -45,6 +45,7 @@ public class Constant {
public
static
String
ddbregion
=
ddbBundle
.
getString
(
"ddb.region"
);
public
static
String
ddbregion
=
ddbBundle
.
getString
(
"ddb.region"
);
public
static
String
bucket
=
ddbBundle
.
getString
(
"ddb.bucket"
);
public
static
String
bucket
=
ddbBundle
.
getString
(
"ddb.bucket"
);
public
static
String
uploadPath
=
ddbBundle
.
getString
(
"ddb.upload.path"
);
public
static
String
uploadPath
=
ddbBundle
.
getString
(
"ddb.upload.path"
);
public
static
String
downhost
=
ddbBundle
.
getString
(
"downhost"
);
}
}
src/main/resources/ddb.properties
View file @
00227a49
...
@@ -2,4 +2,6 @@ ddb.accesskey=${ddb.accesskey}
...
@@ -2,4 +2,6 @@ ddb.accesskey=${ddb.accesskey}
ddb.secretkey
=
${ddb.secretkey}
ddb.secretkey
=
${ddb.secretkey}
ddb.region
=
${ddb.region}
ddb.region
=
${ddb.region}
ddb.bucket
=
${ddb.bucket}
ddb.bucket
=
${ddb.bucket}
ddb.upload.path
=
${ddb.upload.path}
ddb.upload.path
=
${ddb.upload.path}
\ No newline at end of file
downhost
=
${downhost}
\ No newline at end of file
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