Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
98aa5320
Commit
98aa5320
authored
May 07, 2022
by
翁国栋
Committed by
284718418@qq.com
Mar 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保单过期定时器
parent
c1c9c63c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
src/main/java/cn/timer/api/controller/insure/task/InsureTaskTiming.java
+61
-0
No files found.
src/main/java/cn/timer/api/controller/insure/task/InsureTaskTiming.java
0 → 100644
View file @
98aa5320
package
cn
.
timer
.
api
.
controller
.
insure
.
task
;
import
cn.hutool.core.date.DateUtil
;
import
cn.timer.api.bean.insure.InsureLog
;
import
cn.timer.api.bean.insure.InsurePolicy
;
import
cn.timer.api.bean.insure.InsureUser
;
import
cn.timer.api.bean.yggl.YgglMainEmp
;
import
cn.timer.api.dao.insure.InsurePolicyMapper
;
import
cn.timer.api.dao.insure.InsureUserMapper
;
import
cn.timer.api.dao.yggl.YgglMainEmpMapper
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @Description TODO
* @Author wgd
* @Date 2022/5/5 11:20
*/
@Configuration
//1.主要用于标记配置类,兼备Component的效果。
@EnableScheduling
// 2.开启定时任务
@Slf4j
public
class
InsureTaskTiming
{
@Autowired
private
InsureUserMapper
insureUserMapper
;
@Autowired
private
YgglMainEmpMapper
ygglMainEmpMapper
;
@Scheduled
(
cron
=
"0 0 0 1 * ?"
)
//每月第一天
public
void
updateInsureStatusTask
()
throws
ParseException
{
Date
now
=
DateUtil
.
date
();
/*获取正常的保单*/
List
<
InsurePolicy
>
insurePolicyList
=
InsurePolicy
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
InsurePolicy
>().
lambda
().
eq
(
InsurePolicy:
:
getStatus
,
"1"
).
lt
(
InsurePolicy:
:
getPolicyDateEnd
,
now
));
if
(
insurePolicyList
.
size
()
>
0
)
{
/*获取已经过期保单*/
for
(
InsurePolicy
insurePolicy
:
insurePolicyList
)
{
List
<
InsureUser
>
insureUsersList
=
InsureUser
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
InsureUser
>().
lambda
()
.
eq
(
InsureUser:
:
getPolicyId
,
insurePolicy
.
getId
()).
eq
(
InsureUser:
:
getStatus
,
1
)
.
eq
(
InsureUser:
:
getInsureStatus
,
1
));
if
(
insureUsersList
.
size
()
>
0
)
{
int
count
=
ygglMainEmpMapper
.
updateInsure
(
insureUsersList
.
stream
().
map
(
InsureUser:
:
getUserId
).
toArray
(
Integer
[]::
new
));
log
.
info
(
"总共更新员工投保状态"
,
count
);
int
uCount
=
insureUserMapper
.
updateInsure
(
insurePolicyList
.
stream
().
map
(
InsurePolicy:
:
getId
).
toArray
(
Integer
[]::
new
));
log
.
info
(
"总共更新投保人投保状态"
,
uCount
);
}
insurePolicy
.
setStatus
(
"3"
);
insurePolicy
.
updateById
();
}
}
log
.
error
(
"暂无过期保单"
);
}
}
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