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
52af2507
Commit
52af2507
authored
Sep 27, 2021
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2580_fix2' into 2580_fix
parents
50f5e68c
065258b1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
342 additions
and
209 deletions
+342
-209
DmpIncomeController.java
src/main/java/common/controller/DmpIncomeController.java
+3
-4
Contract.java
src/main/java/common/model/Contract.java
+2
-0
DmpIncome.java
src/main/java/common/model/DmpIncome.java
+175
-164
ContractRepository.java
src/main/java/common/repository/ContractRepository.java
+3
-0
DmpIncomeRepository.java
src/main/java/common/repository/DmpIncomeRepository.java
+0
-1
DmpIncomeService.java
src/main/java/common/service/DmpIncomeService.java
+7
-6
DmpIncomeServiceImpl.java
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
+80
-28
ShareIncomeServiceImpl.java
...main/java/common/service/impl/ShareIncomeServiceImpl.java
+0
-0
CASIPSendTimeTask.java
src/main/java/track/task/CASIPSendTimeTask.java
+72
-6
No files found.
src/main/java/common/controller/DmpIncomeController.java
View file @
52af2507
...
...
@@ -38,17 +38,16 @@ public class DmpIncomeController {
}
@PostMapping
(
"/delete"
)
public
ResultModel
deleteItem
(
Long
id
)
{
public
ResultModel
deleteItem
(
@RequestBody
DmpIncome
dmpIncome
)
{
//删除数据
return
ResultModel
.
OK
(
dmpIncomeService
.
delete
(
id
));
return
ResultModel
.
OK
(
dmpIncomeService
.
delete
(
dmpIncome
));
}
@PostMapping
(
"/upload"
)
public
ResultModel
uploadList
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@CurrentAccount
User
loginAccount
)
{
//上传收入数据
dmpIncomeService
.
uploadFile
(
file
,
"dmp"
,
loginAccount
);
return
ResultModel
.
OK
();
return
dmpIncomeService
.
uploadFile
(
file
,
"dmp"
,
loginAccount
);
}
...
...
src/main/java/common/model/Contract.java
View file @
52af2507
...
...
@@ -198,6 +198,8 @@ public class Contract {
this
.
contractType
=
contractType
;
}
public
String
getStartDate
()
{
return
startDate
;
}
...
...
src/main/java/common/model/DmpIncome.java
View file @
52af2507
...
...
@@ -9,168 +9,179 @@ import java.util.Date;
@Entity
public
class
DmpIncome
{
private
Long
id
;
// ID
private
String
contractCode
;
//合同编号
private
String
incomeMonth
;
//收入月份
private
String
period
;
//结算周期
private
String
sysSettlement
;
//系统结算
private
String
monthSettlement
;
//按月结算
private
String
confirmSettlement
;
//确认结算
private
String
taxRate
;
//税率
private
Date
createTime
;
private
Date
modifyTime
;
private
String
uploadUser
;
private
String
myBodyCode
;
//contract_code, my_body_name, customer_body, customer_short, business_type, agreement_type
private
String
myBodyName
,
customerBody
,
customerShort
,
businessType
,
agreementType
;
@Id
@GeneratedValue
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getContractCode
()
{
return
contractCode
;
}
public
void
setContractCode
(
String
contractCode
)
{
this
.
contractCode
=
contractCode
;
}
public
String
getIncomeMonth
()
{
return
incomeMonth
;
}
public
void
setIncomeMonth
(
String
incomeMonth
)
{
this
.
incomeMonth
=
incomeMonth
;
}
public
String
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
String
period
)
{
this
.
period
=
period
;
}
public
String
getSysSettlement
()
{
return
sysSettlement
;
}
public
void
setSysSettlement
(
String
sysSettlement
)
{
this
.
sysSettlement
=
sysSettlement
;
}
public
String
getMonthSettlement
()
{
return
monthSettlement
;
}
public
void
setMonthSettlement
(
String
monthSettlement
)
{
this
.
monthSettlement
=
monthSettlement
;
}
public
String
getConfirmSettlement
()
{
return
confirmSettlement
;
}
public
void
setConfirmSettlement
(
String
confirmSettlement
)
{
this
.
confirmSettlement
=
confirmSettlement
;
}
public
String
getTaxRate
()
{
return
taxRate
;
}
public
void
setTaxRate
(
String
taxRate
)
{
this
.
taxRate
=
taxRate
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getModifyTime
()
{
return
modifyTime
;
}
public
void
setModifyTime
(
Date
modifyTime
)
{
this
.
modifyTime
=
modifyTime
;
}
public
String
getUploadUser
()
{
return
uploadUser
;
}
public
void
setUploadUser
(
String
uploadUser
)
{
this
.
uploadUser
=
uploadUser
;
}
@Transient
public
String
getMyBodyName
()
{
return
myBodyName
;
}
public
void
setMyBodyName
(
String
myBodyName
)
{
this
.
myBodyName
=
myBodyName
;
}
@Transient
public
String
getCustomerBody
()
{
return
customerBody
;
}
public
void
setCustomerBody
(
String
customerBody
)
{
this
.
customerBody
=
customerBody
;
}
@Transient
public
String
getCustomerShort
()
{
return
customerShort
;
}
public
void
setCustomerShort
(
String
customerShort
)
{
this
.
customerShort
=
customerShort
;
}
@Transient
public
String
getBusinessType
()
{
return
businessType
;
}
public
void
setBusinessType
(
String
businessType
)
{
this
.
businessType
=
businessType
;
}
@Transient
public
String
getAgreementType
()
{
return
agreementType
;
}
public
void
setAgreementType
(
String
agreementType
)
{
this
.
agreementType
=
agreementType
;
}
public
String
getMyBodyCode
()
{
return
myBodyCode
;
}
public
void
setMyBodyCode
(
String
myBodyCode
)
{
this
.
myBodyCode
=
myBodyCode
;
}
private
Long
id
;
// ID
private
String
contractCode
;
//合同编号
private
String
incomeMonth
;
//收入月份
private
String
period
;
//结算周期
private
String
sysSettlement
;
//系统结算
private
String
monthSettlement
;
//按月结算
private
String
confirmSettlement
;
//确认结算
private
String
taxRate
;
//税率
private
Date
createTime
;
private
Date
modifyTime
;
private
String
uploadUser
;
private
int
index
;
private
String
myBodyCode
;
//contract_code, my_body_name, customer_body, customer_short, business_type, agreement_type
private
String
myBodyName
,
customerBody
,
customerShort
,
businessType
,
agreementType
;
@Id
@GeneratedValue
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getContractCode
()
{
return
contractCode
;
}
public
void
setContractCode
(
String
contractCode
)
{
this
.
contractCode
=
contractCode
;
}
public
String
getIncomeMonth
()
{
return
incomeMonth
;
}
public
void
setIncomeMonth
(
String
incomeMonth
)
{
this
.
incomeMonth
=
incomeMonth
;
}
public
String
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
String
period
)
{
this
.
period
=
period
;
}
public
String
getSysSettlement
()
{
return
sysSettlement
;
}
public
void
setSysSettlement
(
String
sysSettlement
)
{
this
.
sysSettlement
=
sysSettlement
;
}
public
String
getMonthSettlement
()
{
return
monthSettlement
;
}
public
void
setMonthSettlement
(
String
monthSettlement
)
{
this
.
monthSettlement
=
monthSettlement
;
}
public
String
getConfirmSettlement
()
{
return
confirmSettlement
;
}
public
void
setConfirmSettlement
(
String
confirmSettlement
)
{
this
.
confirmSettlement
=
confirmSettlement
;
}
public
String
getTaxRate
()
{
return
taxRate
;
}
public
void
setTaxRate
(
String
taxRate
)
{
this
.
taxRate
=
taxRate
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getModifyTime
()
{
return
modifyTime
;
}
public
void
setModifyTime
(
Date
modifyTime
)
{
this
.
modifyTime
=
modifyTime
;
}
public
String
getUploadUser
()
{
return
uploadUser
;
}
public
void
setUploadUser
(
String
uploadUser
)
{
this
.
uploadUser
=
uploadUser
;
}
@Transient
public
String
getMyBodyName
()
{
return
myBodyName
;
}
public
void
setMyBodyName
(
String
myBodyName
)
{
this
.
myBodyName
=
myBodyName
;
}
@Transient
public
String
getCustomerBody
()
{
return
customerBody
;
}
public
void
setCustomerBody
(
String
customerBody
)
{
this
.
customerBody
=
customerBody
;
}
@Transient
public
String
getCustomerShort
()
{
return
customerShort
;
}
public
void
setCustomerShort
(
String
customerShort
)
{
this
.
customerShort
=
customerShort
;
}
@Transient
public
String
getBusinessType
()
{
return
businessType
;
}
public
void
setBusinessType
(
String
businessType
)
{
this
.
businessType
=
businessType
;
}
@Transient
public
String
getAgreementType
()
{
return
agreementType
;
}
public
void
setAgreementType
(
String
agreementType
)
{
this
.
agreementType
=
agreementType
;
}
@Transient
public
int
getIndex
()
{
return
index
;
}
public
void
setIndex
(
int
index
)
{
this
.
index
=
index
;
}
public
String
getMyBodyCode
()
{
return
myBodyCode
;
}
public
void
setMyBodyCode
(
String
myBodyCode
)
{
this
.
myBodyCode
=
myBodyCode
;
}
}
src/main/java/common/repository/ContractRepository.java
View file @
52af2507
...
...
@@ -165,4 +165,7 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Modifying
@Query
(
value
=
"delete from contract where contract_code = ?1 and platform=?2"
,
nativeQuery
=
true
)
void
deleteByCode
(
String
contractCode
,
String
platform
);
@Query
(
value
=
"select * from contract where platform=?1 and email =?2"
,
nativeQuery
=
true
)
List
<
Contract
>
findbyEmailAndPlatform
(
String
cas
,
String
originEmail
);
}
src/main/java/common/repository/DmpIncomeRepository.java
View file @
52af2507
...
...
@@ -17,5 +17,4 @@ public interface DmpIncomeRepository extends JpaRepository<DmpIncome, Long> {
@Query
(
value
=
"select * from dmp_income where contract_code = ?1 and income_month =?2 limit 1 "
,
nativeQuery
=
true
)
DmpIncome
findByCodeMonth
(
String
contractCode
,
String
incomeMonth
);
}
src/main/java/common/service/DmpIncomeService.java
View file @
52af2507
...
...
@@ -14,17 +14,17 @@ import java.util.List;
public
interface
DmpIncomeService
{
List
<
DmpIncome
>
listByCode
(
String
contractCode
);
List
<
DmpIncome
>
listByCode
(
String
contractCode
);
List
<
DmpIncome
>
listByDs
(
String
start
,
String
end
);
List
<
DmpIncome
>
listByDs
(
String
start
,
String
end
);
HSSFWorkbook
exportIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
);
HSSFWorkbook
exportIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
);
DmpIncome
update
(
DmpIncome
dmpIncome
);
DmpIncome
update
(
DmpIncome
dmpIncome
);
Long
delete
(
Long
id
);
Long
delete
(
DmpIncome
dmpIncome
);
ResultModel
uploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
);
ResultModel
uploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
);
ResultModel
contractUploadFile
(
MultipartFile
file
,
String
platform
,
User
loginAccount
);
...
...
@@ -45,4 +45,5 @@ public interface DmpIncomeService {
List
pdListByDs
(
String
startDate
,
String
endDate
);
HSSFWorkbook
exportPdIncomeList
(
String
startDate
,
String
endDate
,
String
bodyCode
,
String
serchName
);
}
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
View file @
52af2507
...
...
@@ -70,6 +70,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
PdAttachmentRepository
pdAttachmentRepository
;
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
();
...
...
@@ -89,6 +90,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
CONTRACT_TYPE_NAME
.
put
(
"补充协议"
,
"2"
);
BUSINESS_TYPE_NAME
.
put
(
"VIP"
,
"1"
);
//业务类型 1 VIP 2 共管
BUSINESS_TYPE_NAME
.
put
(
"共管"
,
"2"
);
BUSINESS_TYPE_NAME
.
put
(
"前置机"
,
"3"
);
SETAGREEMENT_TYPE_NAME
.
put
(
"普通协议"
,
"1"
);
//协议类型 1 普通协议 2 框架协议
SETAGREEMENT_TYPE_NAME
.
put
(
"框架协议"
,
"2"
);
}
...
...
@@ -223,7 +225,8 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
row
.
createCell
(
i
).
setCellValue
(
title
[
i
]);
}
String
[]
bussinesName
=
new
String
[]{
""
,
"VIP"
,
"共管"
};
String
[]
bussinesName
=
new
String
[]{
""
,
"VIP"
,
"共管"
,
"前置机"
};
for
(
int
j
=
0
;
j
<
dmpIncomes
.
size
();
j
++)
{
HSSFRow
rowBody
=
sheet
.
createRow
(
j
+
1
);
DmpIncome
income
=
dmpIncomes
.
get
(
j
);
...
...
@@ -261,12 +264,13 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
}
@Override
public
Long
delete
(
Long
id
)
{
if
(
id
==
null
)
{
public
Long
delete
(
DmpIncome
dmpIncome
)
{
if
(
dmpIncome
.
getId
()
==
null
)
{
return
null
;
}
dmpIncomeRepository
.
delete
(
id
);
return
id
;
dmpIncomeRepository
.
delete
(
dmpIncome
.
getId
()
);
return
dmpIncome
.
getId
()
;
}
@Override
...
...
@@ -285,27 +289,56 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
DecimalFormat
df
=
new
DecimalFormat
(
"##,##0.00"
);
CompletableFuture
.
runAsync
(()
->
{
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
30
);
CompletableFuture
[]
futures
=
Stream
.
iterate
(
1
,
n
->
n
+
1
).
limit
(
rowNumber
-
1
).
map
(
index
->
CompletableFuture
.
runAsync
(
()
->
{
DmpIncome
income
=
saveDmpIncomeItem
(
sheet
,
index
,
loginAccount
);
if
(
income
!=
null
)
{
income
.
setConfirmSettlement
(
new
BigDecimal
(
income
.
getConfirmSettlement
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
());
dmpIncomeRepository
.
save
(
income
);
}
},
executorService
)
.
exceptionally
((
t
)
->
null
)
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
CompletableFuture
.
allOf
(
futures
).
join
();
executorService
.
shutdownNow
();
stopWatch
.
stop
();
logger
.
info
(
"dmp income upload {} line data use all {}s "
,
rowNumber
-
1
,
stopWatch
.
getTotalTimeSeconds
());
});
StringBuffer
erroMessage
=
new
StringBuffer
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
Map
<
String
,
String
>
incomeMap
=
new
HashMap
<>();
List
<
DmpIncome
>
dmpIncomeList
=
Stream
.
iterate
(
1
,
n
->
n
+
1
).
limit
(
rowNumber
-
1
).
map
(
index
->
{
DmpIncome
income
=
saveDmpIncomeItem
(
sheet
,
index
,
loginAccount
);
String
key
=
income
.
getIncomeMonth
()
+
income
.
getContractCode
();
if
(
incomeMap
.
containsKey
(
key
))
{
return
null
;
}
incomeMap
.
put
(
key
,
"1"
);
return
income
;
}).
filter
(
in
->
in
!=
null
).
collect
(
Collectors
.
toList
());
if
(
dmpIncomeList
.
isEmpty
())
{
return
ResultModel
.
OK
();
}
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
30
);
final
int
[]
indexLine
=
{
0
};
CompletableFuture
[]
futures
=
dmpIncomeList
.
stream
().
map
(
income
->
CompletableFuture
.
runAsync
(
()
->
{
DmpIncome
one
=
dmpIncomeRepository
.
findByCodeMonth
(
income
.
getContractCode
(),
income
.
getIncomeMonth
());
if
(
one
!=
null
)
{
// 同一合同同一月份不重复保存
return
;
}
indexLine
[
0
]
=
income
.
getIndex
();
if
(
"erro"
.
equals
(
income
.
getIncomeMonth
()))
{
erroMessage
.
append
(
income
.
getIndex
()).
append
(
" 行 收入月份错误"
).
append
(
";\n"
);
}
else
{
income
.
setConfirmSettlement
(
new
BigDecimal
(
income
.
getConfirmSettlement
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
());
dmpIncomeRepository
.
save
(
income
);
}
},
executorService
)
.
exceptionally
((
t
)
->
{
erroMessage
.
append
(
indexLine
[
0
]).
append
(
" 行 错误"
).
append
(
t
.
getMessage
()).
append
(
";\n"
);
logger
.
error
(
"the line "
+
indexLine
[
0
],
t
);
return
null
;
})
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
CompletableFuture
.
allOf
(
futures
).
join
();
executorService
.
shutdownNow
();
stopWatch
.
stop
();
logger
.
info
(
"dmp income upload {} line data use all {}s "
,
rowNumber
-
1
,
stopWatch
.
getTotalTimeSeconds
());
if
(
erroMessage
.
length
()
>
0
)
{
return
ResultModel
.
ERROR
(
erroMessage
.
toString
());
}
return
ResultModel
.
OK
();
}
...
...
@@ -354,8 +387,20 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
contract
.
setDs
(
DateTime
.
now
().
toString
(
"yyyy-MM-dd"
));
//填充数据
fillDataByRow
(
contract
,
rowItem
);
String
sysErro
=
null
;
try
{
//填充数据
fillDataByRow
(
contract
,
rowItem
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"the line "
+
i
,
e
);
sysErro
=
e
.
getMessage
();
}
if
(
sysErro
!=
null
)
{
return
erroValueTip
(
i
,
sysErro
);
}
//校验数据有效性
if
(
"erro"
.
equals
(
contract
.
getStartDate
())
||
"erro"
.
equals
(
contract
.
getEndDate
()))
{
return
erroValueTip
(
i
,
"开始时间或结束时间"
);
...
...
@@ -400,10 +445,14 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
}
}
if
(!
CONTRACT_TYPE_NAME
.
containsKey
(
contract
.
getContractType
()))
{
if
(!
CONTRACT_TYPE_NAME
.
containsKey
(
contract
.
getContractType
())
&&
!
"续签"
.
equals
(
contract
.
getContractType
()))
{
return
erroValueTip
(
i
,
"签约类型"
);
}
else
{
contract
.
setContractType
(
CONTRACT_TYPE_NAME
.
get
(
contract
.
getContractType
()));
if
(
"续签"
.
equals
(
contract
.
getContractType
()))
{
contract
.
setContractType
(
"1"
);
}
}
if
(!
BUSINESS_TYPE_NAME
.
containsKey
(
contract
.
getBusinessTypeName
()))
{
...
...
@@ -521,6 +570,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
Row
rowItem
=
sheet
.
getRow
(
index
);
//合同编号 收入月份 结算周期 系统结算 按月结算 税率 确认收入
DmpIncome
income
=
new
DmpIncome
();
income
.
setIndex
(
index
);
income
.
setContractCode
(
getCellStringValue
(
rowItem
,
0
));
income
.
setIncomeMonth
(
getCellDateValue
(
rowItem
,
1
,
"yyyy-MM"
));
income
.
setPeriod
(
getCellStringValue
(
rowItem
,
2
));
...
...
@@ -545,6 +595,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
// 同一合同同一月份不重复保存
return
null
;
}
return
income
;
}
...
...
@@ -729,4 +780,5 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
pdAttachmentRepository
.
delete
(
id
);
return
attachment
;
}
}
src/main/java/common/service/impl/ShareIncomeServiceImpl.java
View file @
52af2507
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/main/java/track/task/CASIPSendTimeTask.java
View file @
52af2507
...
...
@@ -8,12 +8,17 @@ import common.repository.ContractRepository;
import
common.repository.PackageBaseRepository
;
import
org.joda.time.DateTime
;
import
org.joda.time.Days
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
import
util.Constant
;
import
util.DateUtil
;
import
util.HttpClientUtil
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -34,23 +39,23 @@ public class CASIPSendTimeTask {
PackageBaseRepository
packageBaseRepository
;
public
void
task
(){
public
void
task
()
{
logger
.
info
(
"CAS的IP定制发送日定时任务"
);
List
<
PackageBase
>
packageBases
=
packageBaseRepository
.
findByPlatAndStatus
(
"cas"
,
1
);
Map
<
Long
,
PackageBase
>
packageBaseMap
=
new
HashMap
<>();
for
(
PackageBase
base
:
packageBases
)
{
packageBaseMap
.
put
(
base
.
getId
(),
base
);
}
List
<
Contract
>
contracts
=
contractRepository
.
findByPlatformAndShareSign
(
"cas"
,
0
);
List
<
Contract
>
contracts
=
contractRepository
.
findByPlatformAndShareSign
(
"cas"
,
0
);
for
(
Contract
contract
:
contracts
)
{
PackageBase
packageBase
=
packageBaseMap
.
get
(
contract
.
getPriceLevel
());
ADIUser
adiUser
=
adiAccountService
.
findOne
(
contract
.
getEmail
(),
packageBase
==
null
?
""
:
packageBase
.
getPackageName
());
if
(
adiUser
!=
null
&&!
StringUtils
.
isEmpty
(
adiUser
.
getSendTime
()))
{
ADIUser
adiUser
=
adiAccountService
.
findOne
(
contract
.
getEmail
(),
packageBase
==
null
?
""
:
packageBase
.
getPackageName
());
if
(
adiUser
!=
null
&&
!
StringUtils
.
isEmpty
(
adiUser
.
getSendTime
()))
{
contract
.
setShareSign
(
1
);
DateTime
sendTime
=
new
DateTime
(
DateUtil
.
parseDate
(
DateUtil
.
C_TIME_PATTON_DEFAULT
,
adiUser
.
getSendTime
()));
DateTime
sendTime
=
new
DateTime
(
DateUtil
.
parseDate
(
DateUtil
.
C_TIME_PATTON_DEFAULT
,
adiUser
.
getSendTime
()));
DateTime
startDate
=
new
DateTime
(
contract
.
getStartDate
());
if
(
sendTime
.
isBefore
(
startDate
))
{
if
(
sendTime
.
isBefore
(
startDate
))
{
sendTime
=
startDate
;
}
DateTime
endDate
=
new
DateTime
(
contract
.
getEndDate
());
...
...
@@ -62,5 +67,66 @@ public class CASIPSendTimeTask {
contractRepository
.
save
(
contract
);
}
}
//定时同步变更的账号到对应合同
syncChangedAccount
(
packageBaseMap
);
}
//定时同步变更的账号到对应合同 (packType: 国内 海外)
public
void
syncChangedAccount
(
Map
<
Long
,
PackageBase
>
packageBaseMap
)
{
String
ds
=
DateTime
.
now
().
plusDays
(-
1
).
toString
(
"yyyy-MM-dd"
);
//国内
String
url
=
Constant
.
adiUrl
.
split
(
","
)[
0
]
+
"/adi/api/user/change/day?date="
+
ds
;
syncChangedAccount
(
packageBaseMap
,
url
,
"国内"
);
//海外
url
=
Constant
.
adiUrl
.
split
(
","
)[
1
]
+
"/adi/api/user/overseas/change/day?date="
+
ds
;
syncChangedAccount
(
packageBaseMap
,
url
,
"海外"
);
}
//定时同步变更的账号到对应合同 (packType: 国内 海外)
public
void
syncChangedAccount
(
Map
<
Long
,
PackageBase
>
packageBaseMap
,
String
url
,
String
packType
)
{
String
request
=
HttpClientUtil
.
doHttpGetRequest
(
url
,
""
);
try
{
JSONObject
rs
=
new
JSONObject
(
request
);
if
(
"200"
.
equals
(
rs
.
get
(
"code"
)
+
""
))
{
if
(
rs
.
get
(
"content"
)
!=
null
&&
!
rs
.
get
(
"content"
).
toString
().
startsWith
(
"["
))
{
return
;
}
JSONArray
array
=
(
JSONArray
)
rs
.
get
(
"content"
);
for
(
int
i
=
0
;
i
<
array
.
length
();
i
++)
{
JSONObject
object
=
(
JSONObject
)
array
.
get
(
i
);
String
newEmail
=
object
.
getString
(
"newEmail"
);
String
originEmail
=
object
.
getString
(
"originEmail"
);
if
(
StringUtils
.
isEmpty
(
newEmail
)
||
StringUtils
.
isEmpty
(
originEmail
))
{
continue
;
}
List
<
Contract
>
contracts
=
contractRepository
.
findbyEmailAndPlatform
(
"cas"
,
originEmail
);
if
(
contracts
==
null
)
{
continue
;
}
List
<
Contract
>
updateList
=
new
ArrayList
<>();
for
(
Contract
contract
:
contracts
)
{
PackageBase
packageBase
=
packageBaseMap
.
get
(
contract
.
getPriceLevel
());
if
(
packageBase
.
getPackageName
().
contains
(
packType
))
{
contract
.
setEmail
(
newEmail
);
updateList
.
add
(
contract
);
}
}
if
(!
updateList
.
isEmpty
())
{
//更新账号
contractRepository
.
save
(
contracts
);
}
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"syncChangedAccount erro "
+
packType
,
e
);
}
}
}
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