Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
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
poc
poc-api
Commits
7da339bf
Commit
7da339bf
authored
Dec 13, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 用户权益过期处理
parent
44dee86e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
2 deletions
+173
-2
MemberEquityScheduler.java
...va/cn/com/poc/equity/scheduler/MemberEquityScheduler.java
+56
-0
JobConfiguration.java
...java/cn/com/yict/framemax/frame/job/JobConfiguration.java
+112
-0
config.properties
src/main/resources/framemax-config/config.properties
+5
-2
No files found.
src/main/java/cn/com/poc/equity/scheduler/MemberEquityScheduler.java
0 → 100644
View file @
7da339bf
package
cn
.
com
.
poc
.
equity
.
scheduler
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.DateUtils
;
import
cn.com.poc.equity.aggregate.MemberEquityService
;
import
cn.com.poc.equity.constants.EquityEnum
;
import
cn.com.poc.equity.constants.ModifyEventEnum
;
import
cn.com.poc.equity.domain.modifyEquityInfo.ExpiredModifyEventInfo
;
import
cn.com.poc.equity.entity.BizMemberEquityEntity
;
import
cn.com.poc.equity.service.BizMemberEquityService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
@Component
public
class
MemberEquityScheduler
{
@Resource
private
MemberEquityService
memberEquityService
;
@Resource
private
BizMemberEquityService
bizMemberEquityService
;
/**
* 权益信息状态更新-【过期】
* 每分钟执行一次
*
* @throws Exception
*/
@Scheduled
(
cron
=
"0 0/1 * * * ?"
)
public
void
memberEquityExpiredStatus
()
throws
Exception
{
BizMemberEquityEntity
bizMemberEquityEntity
=
new
BizMemberEquityEntity
();
bizMemberEquityEntity
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
List
<
BizMemberEquityEntity
>
entities
=
bizMemberEquityService
.
findByExample
(
bizMemberEquityEntity
,
null
);
if
(
CollectionUtils
.
isEmpty
(
entities
))
{
return
;
}
Date
currDateTime
=
DateUtils
.
getCurrDateTime
();
for
(
BizMemberEquityEntity
entity
:
entities
)
{
if
(
entity
.
getEquityLevel
().
equals
(
EquityEnum
.
TYPE
.
normal
.
name
()))
{
break
;
}
if
(
currDateTime
.
after
(
entity
.
getExpiredDate
()))
{
ExpiredModifyEventInfo
expiredModifyEventInfo
=
new
ExpiredModifyEventInfo
();
memberEquityService
.
changeEquityLevel
(
entity
.
getMemberId
(),
ModifyEventEnum
.
expired
,
EquityEnum
.
TYPE
.
normal
,
EquityEnum
.
VALIDITY_UNIT
.
indefinite
,
expiredModifyEventInfo
);
}
}
}
}
src/main/java/cn/com/yict/framemax/frame/job/JobConfiguration.java
0 → 100644
View file @
7da339bf
package
cn
.
com
.
yict
.
framemax
.
frame
.
job
;
import
cn.com.yict.framemax.core.config.Config
;
import
cn.com.yict.framemax.core.spring.condition.OnExpression
;
import
cn.com.yict.framemax.frame.job.rest.FmxJobLogRest
;
import
cn.com.yict.framemax.frame.job.rest.FmxJobRest
;
import
cn.com.yict.framemax.frame.job.rest.impl.FmxJobLogRestImpl
;
import
cn.com.yict.framemax.frame.job.rest.impl.FmxJobRestImpl
;
import
cn.com.yict.framemax.frame.job.service.FmxJobLogService
;
import
cn.com.yict.framemax.frame.job.service.FmxJobService
;
import
cn.com.yict.framemax.frame.job.service.ScheduleService
;
import
cn.com.yict.framemax.frame.job.service.impl.FmxJobLogServiceImpl
;
import
cn.com.yict.framemax.frame.job.service.impl.FmxJobServiceImpl
;
import
cn.com.yict.framemax.frame.job.service.impl.ScheduleServiceImpl
;
import
cn.com.yict.framemax.frame.job.support.JobDataListQueryProvider
;
import
org.quartz.CronTrigger
;
import
org.quartz.impl.jdbcjobstore.StdJDBCDelegate
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.quartz.SchedulerFactoryBean
;
import
org.springframework.util.StringUtils
;
import
javax.sql.DataSource
;
import
java.util.Properties
;
@Configuration
@OnExpression
(
"!'true'.equals('${framemax-frame.job.disable:}')"
)
public
class
JobConfiguration
{
@Bean
(
name
=
"fmxJobRest"
)
public
FmxJobRest
fmxJobRest
()
{
return
new
FmxJobRestImpl
();
}
@Bean
(
name
=
"fmxJobLogRest"
)
public
FmxJobLogRest
fmxJobLogRest
()
{
return
new
FmxJobLogRestImpl
();
}
@Bean
(
name
=
"scheduleService"
)
public
ScheduleService
scheduleService
()
{
ScheduleServiceImpl
scheduleService
=
new
ScheduleServiceImpl
();
String
instruction
=
Config
.
get
(
"framemax-frame.job.misfire.instruction"
);
if
(
"MISFIRE_INSTRUCTION_DO_NOTHING"
.
equalsIgnoreCase
(
instruction
))
{
scheduleService
.
setMisfireInstruction
(
CronTrigger
.
MISFIRE_INSTRUCTION_DO_NOTHING
);
}
else
if
(
"MISFIRE_INSTRUCTION_FIRE_ONCE_NOW"
.
equalsIgnoreCase
(
instruction
))
{
scheduleService
.
setMisfireInstruction
(
CronTrigger
.
MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
);
}
else
if
(
"MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY"
.
equalsIgnoreCase
(
instruction
))
{
scheduleService
.
setMisfireInstruction
(
CronTrigger
.
MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
);
}
else
{
// 默认重跑
scheduleService
.
setMisfireInstruction
(
CronTrigger
.
MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
);
}
return
scheduleService
;
}
@Bean
(
name
=
"fmxJobService"
)
public
FmxJobService
fmxJobService
()
{
return
new
FmxJobServiceImpl
();
}
@Bean
(
name
=
"fmxJobLogService"
)
public
FmxJobLogService
fmxJobLogService
()
{
return
new
FmxJobLogServiceImpl
();
}
@Bean
(
name
=
"fmxJobDataListQueryProvider"
)
public
JobDataListQueryProvider
jobDataListQueryProvider
()
{
return
new
JobDataListQueryProvider
();
}
@Bean
(
name
=
"framemax-frame.job.scheduler"
)
public
SchedulerFactoryBean
scheduler
(
ApplicationContext
applicationContext
)
{
String
beanName
=
Config
.
get
(
"framemax-data.dataSourceBeanName"
);
DataSource
dataSource
=
applicationContext
.
getBean
(
beanName
,
DataSource
.
class
);
SchedulerFactoryBean
factory
=
new
SchedulerFactoryBean
();
factory
.
setDataSource
(
dataSource
);
Properties
props
=
new
Properties
();
props
.
setProperty
(
"org.quartz.scheduler.instanceName"
,
"ClusterScheduler"
);
props
.
setProperty
(
"org.quartz.scheduler.instanceId"
,
"AUTO"
);
props
.
setProperty
(
"org.quartz.scheduler.rmi.export"
,
"false"
);
props
.
setProperty
(
"org.quartz.threadPool.class"
,
"org.quartz.simpl.SimpleThreadPool"
);
props
.
setProperty
(
"org.quartz.threadPool.threadCount"
,
"20"
);
props
.
setProperty
(
"org.quartz.threadPool.threadPriority"
,
"5"
);
props
.
setProperty
(
"org.quartz.jobStore.class"
,
"org.quartz.impl.jdbcjobstore.JobStoreTX"
);
props
.
setProperty
(
"org.quartz.jobStore.driverDelegateClass"
,
StdJDBCDelegate
.
class
.
getName
());
props
.
setProperty
(
"org.quartz.jobStore.isClustered"
,
"true"
);
props
.
setProperty
(
"org.quartz.jobStore.clusterCheckinInterval"
,
"15000"
);
props
.
setProperty
(
"org.quartz.jobStore.maxMisfiresToHandleAtATime"
,
"20"
);
props
.
setProperty
(
"org.quartz.jobStore.misfireThreshold"
,
"60000"
);
props
.
setProperty
(
"org.quartz.jobStore.tablePrefix"
,
"qrtz_"
);
props
.
setProperty
(
"org.quartz.jobStore.acquireTriggersWithinLock"
,
"true"
);
String
misfireThreshold
=
Config
.
get
(
"framemax-frame.job.misfire.threshold"
);
if
(!
StringUtils
.
isEmpty
(
misfireThreshold
))
{
props
.
setProperty
(
"org.quartz.jobStore.misfireThreshold"
,
misfireThreshold
);
}
factory
.
setQuartzProperties
(
props
);
factory
.
setSchedulerName
(
"framemax-frame.job.ClusterScheduler"
);
factory
.
setStartupDelay
(
30
);
factory
.
setApplicationContextSchedulerContextKey
(
"applicationContextKey"
);
factory
.
setOverwriteExistingJobs
(
true
);
factory
.
setAutoStartup
(
true
);
return
factory
;
}
}
src/main/resources/framemax-config/config.properties
View file @
7da339bf
...
...
@@ -40,7 +40,7 @@ framemax-frame.message.noticeMessageHandler=classpath:/framemax-frame/message/no
#\u670D\u52A1\u5B58\u653E\u56FE\u7247\u5730\u5740
uploadPath
=
data/upload/
#
Ѷƽӿ
#
\uFFFD\uFFFD\u0476\uFFFD\u01BD\u04FF\uFFFD
tencent.secretId
=
AKIDoT5WlIoBbu32pOisreFfuxsCIDtOegT2
tencent.secretKey
=
TmskOq9GAsRoyugHguwpX2gCbryxmQt9
tencent.appId
=
1251105573
...
...
@@ -73,4 +73,7 @@ tencent.speech.synthesizer.secretKey=4yg9kIdpoptnmP9nFUaadnt32QEqEOOB
project.name
=
"poc-api"
#18n
i18n.disable
=
false
\ No newline at end of file
i18n.disable
=
false
#job
framemax-frame.job.disable
=
false
\ 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