Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
B
byh-family-doctor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
包
包
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
杨凯
byh-family-doctor
Commits
c75a038e
提交
c75a038e
authored
3月 22, 2024
作者:
杨凯
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:家庭医生初始化
上级
4edbc3cd
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
336 行增加
和
173 行删除
+336
-173
ScheduleTask.java
...com/ebaiyihui/family/doctor/server/task/ScheduleTask.java
+129
-169
SignedTask.java
...a/com/ebaiyihui/family/doctor/server/task/SignedTask.java
+204
-0
MobileBenefitPackageMapper.xml
.../src/main/resources/mapper/MobileBenefitPackageMapper.xml
+3
-4
没有找到文件。
family-doctor-server/src/main/java/com/ebaiyihui/family/doctor/server/task/ScheduleTask.java
浏览文件 @
c75a038e
package
com
.
ebaiyihui
.
family
.
doctor
.
server
.
task
;
package
com
.
ebaiyihui
.
family
.
doctor
.
server
.
task
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSON
;
import
com.ebaiyihui.family.doctor.common.bo.Result
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.ebaiyihui.family.doctor.common.dto.HealthInfoDTO
;
import
com.ebaiyihui.family.doctor.server.common.enums.WhetherEnum
;
import
com.ebaiyihui.family.doctor.common.dto.SendImMsgDTO
;
import
com.ebaiyihui.family.doctor.server.entity.ScheduleRecordEntity
;
import
com.ebaiyihui.family.doctor.server.common.constants.CommonConstants
;
import
com.ebaiyihui.family.doctor.server.mapper.ScheduleRecordMapper
;
import
com.ebaiyihui.family.doctor.server.common.constants.ImConstants
;
import
com.ebaiyihui.family.doctor.server.common.enums.MsgTempTypeEnum
;
import
com.ebaiyihui.family.doctor.server.common.enums.StatusEnum
;
import
com.ebaiyihui.family.doctor.server.entity.MobileBenefitPackageEntity
;
import
com.ebaiyihui.family.doctor.server.entity.PatientSignEntity
;
import
com.ebaiyihui.family.doctor.server.mapper.MobileBenefitPackageMapper
;
import
com.ebaiyihui.family.doctor.server.service.ImMsgTemplateService
;
import
com.ebaiyihui.family.doctor.server.service.PatientSignService
;
import
com.ebaiyihui.family.doctor.server.util.DateUtils
;
import
com.ebaiyihui.family.doctor.server.util.DateUtils
;
import
com.ebaiyihui.family.doctor.server.util.ThirdOrderPushUtil
;
import
com.ebaiyihui.framework.response.BaseResponse
;
import
com.ebaiyihui.imforward.client.vo.IMQueryMsgReqVO
;
import
com.ebaiyihui.imforward.client.vo.IMQueryUserLoginReqVO
;
import
com.ebaiyihui.imforward.client.vo.IMQueryUserLoginRspVO
;
import
com.ebaiyihui.imforward.client.vo.IMSingleMsgResultVO
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* @ClassName: TaskSchedule
* @ClassName: TaskSchedule
...
@@ -38,168 +29,137 @@ import java.util.List;
...
@@ -38,168 +29,137 @@ import java.util.List;
@Slf4j
@Slf4j
public
class
ScheduleTask
{
public
class
ScheduleTask
{
@Autowired
private
static
final
String
MONDAY
=
"星期一"
;
private
ImMsgTemplateService
imMsgTemplateService
;
@Autowired
private
PatientSignService
patientSignSevice
;
@Autowired
private
MobileBenefitPackageMapper
mobileBenefitPackageMapper
;
@Autowired
@Autowired
private
ThirdOrderPushUtil
thirdOrderPushUtil
;
private
ScheduleRecordMapper
scheduleRecordMapper
;
// @Scheduled(cron = "0 0 10 * * ?")
// @Scheduled(cron = "0 0/2 * * * ?")
public
void
healthRecordWhetherUpdate
()
{
@Scheduled
(
cron
=
"0 0 0 * * ?"
)
List
<
PatientSignEntity
>
patientSignEntities
=
patientSignSevice
.
selectList
(
new
PatientSignEntity
());
public
void
regularTimeExport
()
{
if
(!
patientSignEntities
.
isEmpty
())
{
for
(
PatientSignEntity
ps
:
patientSignEntities
)
{
HealthInfoDTO
healthInfoDTO
=
new
HealthInfoDTO
();
/*
healthInfoDTO
.
setPhone
(
ps
.
getPatientPhone
());
* 某天
// 查询用户健康档案30天内是否有更新
* 某业务
String
result
=
thirdOrderPushUtil
.
getHealthRecordWhetherUpdate
(
healthInfoDTO
);
* 某医生
Result
<
Boolean
>
res
=
JSONObject
.
parseObject
(
result
,
Result
.
class
);
* 某科室 下的开通循环排班的数据
Boolean
flag
=
res
.
getData
();
*
SendImMsgDTO
sendImMsgDTO
=
new
SendImMsgDTO
();
* 此条件下 第5周 开通排班 未停诊 的数据
sendImMsgDTO
.
setAppCode
(
CommonConstants
.
APP_CODE
);
*
sendImMsgDTO
.
setOrganId
(
CommonConstants
.
ORGAN_CODE
);
* 对比这两个list 去掉重复 新增(不停诊 日期为第5周的当天)
sendImMsgDTO
.
setAdmId
(
ps
.
getAdmId
());
*
if
(!
flag
)
{
* 定时任务时间修改
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_PUSH_HEAL_REC
.
getValue
());
*
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
*/
}
String
currentDateSimpleToString
=
DateUtils
.
getCurrentDateSimpleToString
();
// 1、签约完成定时任务第10天,主动触发 2、定时任务之后每隔15天,主动触发
log
.
info
(
"当前时间{}"
,
JSON
.
toJSONString
(
currentDateSimpleToString
));
Date
curDate
=
new
Date
();
String
weekChinese
=
DateUtils
.
getWeekChinese
(
currentDateSimpleToString
);
int
difDay
=
DateUtils
.
daysBetween
(
ps
.
getCreateTime
(),
curDate
);
log
.
info
(
"当前时间是{}"
,
JSON
.
toJSONString
(
weekChinese
));
int
afterFifteenDay
=
DateUtils
.
daysBetween
(
ps
.
getCreateTime
(),
curDate
);
if
(!
MONDAY
.
equals
(
weekChinese
))
{
if
(
10
==
difDay
||
afterFifteenDay
%
15
==
0
)
{
return
;
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT__SIG_SUC
.
getValue
());
}
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
//周末
// 1、当用户有触发过‘报告异常’问诊 2、定时任务触发20天后主动触发
String
oneDayForWeekLast
=
DateUtils
.
getOneDayForWeekLast
(
currentDateSimpleToString
);
if
(
20
==
difDay
)
{
Date
weekDateFirst
=
DateUtils
.
strToDateNoTry
(
currentDateSimpleToString
);
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_REP_ANO
.
getValue
());
Date
weekDateLast
=
DateUtils
.
strToDateNoTry
(
oneDayForWeekLast
);
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
List
<
String
>
dateRange
=
DateUtils
.
getDateRange
(
weekDateFirst
,
weekDateLast
);
// 1、当用户与医生7天未进行沟通 2、判断后主动触发
log
.
info
(
"一周的日期{}"
,
JSON
.
toJSONString
(
dateRange
));
// {"appCode":"EHOS_PATIENT","appointmentId":["9ad0b140bd1b4b86b1aa68f59c9dbf9a"],"businessCode":"jtys","msgType":"1","page":0,"pageSize":999,"sortOrder":"ASC","userId":"18170905967"}
IMQueryMsgReqVO
imQueryMsgReqVO
=
new
IMQueryMsgReqVO
();
for
(
String
schDate
:
dateRange
)
{
imQueryMsgReqVO
.
setAppCode
(
ImConstants
.
IM_PAT_ACCOUNT_NUM
);
QueryWrapper
<
ScheduleRecordEntity
>
schWapper
=
new
QueryWrapper
<>();
imQueryMsgReqVO
.
setBusinessCode
(
ImConstants
.
IM_QUERY_ACCOUNT_CODE
);
ScheduleRecordEntity
scheduleRecordEntity
=
new
ScheduleRecordEntity
();
imQueryMsgReqVO
.
setMsgType
(
"1"
);
scheduleRecordEntity
.
setIsCycleSchedule
(
WhetherEnum
.
ALLOW
.
getValue
());
imQueryMsgReqVO
.
setPageSize
(
10
);
scheduleRecordEntity
.
setScheduleDate
(
DateUtils
.
strToDateNoTry
(
schDate
));
imQueryMsgReqVO
.
setSortOrder
(
"DESC"
);
schWapper
.
setEntity
(
scheduleRecordEntity
);
List
<
String
>
appointmentIds
=
new
ArrayList
<>();
log
.
info
(
"某天开通循环排班列表入参{}"
,
JSON
.
toJSONString
(
schWapper
));
appointmentIds
.
add
(
ps
.
getAdmId
());
List
<
ScheduleRecordEntity
>
list
=
scheduleRecordMapper
.
selectList
(
schWapper
);
imQueryMsgReqVO
.
setAppointmentId
(
appointmentIds
);
log
.
info
(
"某天开通循环排班列表出参{}"
,
JSON
.
toJSONString
(
list
));
imQueryMsgReqVO
.
setUserId
(
ps
.
getPatientUserId
());
if
(
CollectionUtils
.
isEmpty
(
list
))
{
String
sendTimeStr
=
"2023-12-01 00:00:00"
;
continue
;
try
{
}
BaseResponse
<
List
<
IMSingleMsgResultVO
>>
msgContent
=
patientSignSevice
.
getAllMsgContent
(
imQueryMsgReqVO
);
//根据业务分组
if
(
"1"
.
equals
(
msgContent
.
getCode
()))
{
Map
<
Integer
,
List
<
ScheduleRecordEntity
>>
servTypeCollect
=
List
<
IMSingleMsgResultVO
>
imSingleMsgResultVOS
=
msgContent
.
getData
();
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
ScheduleRecordEntity:
:
getServType
));
IMQueryUserLoginReqVO
imQueryUserLoginReqVO
=
new
IMQueryUserLoginReqVO
();
for
(
Integer
servType
:
servTypeCollect
.
keySet
())
{
imQueryUserLoginReqVO
.
setAppCode
(
ImConstants
.
IM_PAT_ACCOUNT_NUM
);
List
<
ScheduleRecordEntity
>
servTypeList
=
servTypeCollect
.
get
(
servType
);
imQueryUserLoginReqVO
.
setUserId
(
ps
.
getPatientUserId
());
//根据医生分组
BaseResponse
<
IMQueryUserLoginRspVO
>
sdkLogin
=
patientSignSevice
.
querySdkLogin
(
imQueryUserLoginReqVO
);
Map
<
String
,
List
<
ScheduleRecordEntity
>>
doctorCollect
=
if
(
"1"
.
equals
(
sdkLogin
.
getCode
()))
{
servTypeList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ScheduleRecordEntity:
:
getDoctorId
));
IMQueryUserLoginRspVO
imQueryUserLoginRspVO
=
sdkLogin
.
getData
();
for
(
String
docId
:
doctorCollect
.
keySet
())
{
String
sdkAccount
=
imQueryUserLoginRspVO
.
getSdkAccount
();
List
<
ScheduleRecordEntity
>
scheduleDeptList
=
doctorCollect
.
get
(
docId
);
for
(
IMSingleMsgResultVO
imSingleMsgResultVO
:
imSingleMsgResultVOS
)
{
//根据科室分组
if
(
imSingleMsgResultVO
.
getSender
().
equals
(
sdkAccount
))
{
Map
<
String
,
List
<
ScheduleRecordEntity
>>
deptCollect
=
sendTimeStr
=
imSingleMsgResultVO
.
getSendTime
();
scheduleDeptList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ScheduleRecordEntity:
:
getDeptId
));
for
(
String
deptId
:
deptCollect
.
keySet
())
{
//某天某医生某科室的所有排班
List
<
ScheduleRecordEntity
>
rangeList
=
deptCollect
.
get
(
deptId
);
QueryWrapper
<
ScheduleRecordEntity
>
nextWrapper
=
new
QueryWrapper
<>();
ScheduleRecordEntity
nextSchedule
=
new
ScheduleRecordEntity
();
nextSchedule
.
setStatus
(
WhetherEnum
.
ALLOW
.
getValue
());
nextSchedule
.
setDoctorId
(
docId
);
nextSchedule
.
setDeptId
(
deptId
);
nextSchedule
.
setServType
(
servType
);
nextSchedule
.
setScheduleDate
(
DateUtils
.
getNextWeek
(
schDate
,
3
));
nextWrapper
.
setEntity
(
nextSchedule
);
log
.
info
(
"第5周当天排班入参{}"
,
JSON
.
toJSONString
(
schWapper
));
List
<
ScheduleRecordEntity
>
nextScheList
=
scheduleRecordMapper
.
selectList
(
nextWrapper
);
log
.
info
(
"第5周当天排班出参{}"
,
JSON
.
toJSONString
(
nextScheList
));
if
(
CollectionUtils
.
isEmpty
(
nextScheList
))
{
rangeList
.
stream
().
forEach
(
rangeVo
->
{
ScheduleRecordEntity
schedule
=
new
ScheduleRecordEntity
();
BeanUtils
.
copyProperties
(
rangeVo
,
schedule
);
schedule
.
setStatus
(
WhetherEnum
.
ALLOW
.
getValue
());
schedule
.
setScheduleDate
(
DateUtils
.
getNextWeek
(
schDate
,
3
));
// schedule.setAvailableCount(rangeVo.getTotalCount());
log
.
info
(
"排班新增入参:"
+
schedule
.
toString
());
scheduleRecordMapper
.
insert
(
schedule
);
});
continue
;
}
ArrayList
<
ScheduleRecordEntity
>
rangeSch
=
new
ArrayList
<>();
//如果第5周有排班 和当前对比 去除重复的时段
for
(
ScheduleRecordEntity
rangeReq
:
rangeList
)
{
Boolean
flag
=
false
;
for
(
ScheduleRecordEntity
rangeRes
:
nextScheList
)
{
Boolean
aBoolean
=
DateUtils
.
rangeCompare
(
DateUtils
.
strToDateNoTryForMinute
(
rangeReq
.
getStartTime
()),
DateUtils
.
strToDateNoTryForMinute
(
rangeReq
.
getEndTime
()),
DateUtils
.
strToDateNoTryForMinute
(
rangeRes
.
getStartTime
()),
DateUtils
.
strToDateNoTryForMinute
(
rangeRes
.
getEndTime
()));
if
(
aBoolean
)
{
flag
=
true
;
break
;
break
;
}
}
}
}
if
(
flag
)
{
continue
;
}
else
{
rangeSch
.
add
(
rangeReq
);
}
}
Date
sendTime
=
DateUtils
.
parseDate
(
sendTimeStr
,
DateUtils
.
FULL_FORMAT
);
int
difSendDay
=
DateUtils
.
daysBetween
(
sendTime
,
curDate
);
if
(
7
==
difSendDay
)
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_UN_CON
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"获取发送消息异常"
,
e
);
}
}
}
}
// @Scheduled(cron = "0 0 20 * * ?")
public
void
holidayPush
()
{
List
<
PatientSignEntity
>
patientSignEntities
=
patientSignSevice
.
selectList
(
new
PatientSignEntity
());
try
{
if
(!
patientSignEntities
.
isEmpty
())
{
for
(
PatientSignEntity
ps
:
patientSignEntities
)
{
SendImMsgDTO
sendImMsgDTO
=
new
SendImMsgDTO
();
sendImMsgDTO
.
setAppCode
(
CommonConstants
.
APP_CODE
);
sendImMsgDTO
.
setOrganId
(
CommonConstants
.
ORGAN_CODE
);
sendImMsgDTO
.
setAdmId
(
ps
.
getAdmId
());
Date
curDate
=
new
Date
();
Date
qmBeforeDay
=
DateUtils
.
getQingMingBeforeDay
(
curDate
);
Date
curDay
=
DateUtils
.
parseDate
(
DateUtils
.
getFormatDateString
(
curDate
,
DateUtils
.
SIMPLE_FORMAT
),
DateUtils
.
SIMPLE_FORMAT
);
if
(
qmBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_TSD
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
Date
laborBeforeDay
=
DateUtils
.
getLaborBeforeDay
(
curDate
);
if
(
laborBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_LD
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
Date
duanWuBeforeDay
=
DateUtils
.
getLaborBeforeDay
(
curDate
);
if
(
duanWuBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_TDBF
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
Date
zhongQiuBeforeDay
=
DateUtils
.
getZhongQiuBeforeDay
(
curDate
);
if
(
zhongQiuBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_MAF
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
}
Date
guoQingBeforeDay
=
DateUtils
.
getGuoQingBeforeDay
(
curDate
);
if
(
CollectionUtils
.
isEmpty
(
rangeSch
))
{
if
(
guoQingBeforeDay
.
equals
(
curDay
))
{
continue
;
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_MAF
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
}
log
.
info
(
"rangeList{}"
,
JSON
.
toJSONString
(
rangeSch
));
rangeSch
.
stream
().
forEach
(
rangeVo
->
{
ScheduleRecordEntity
schedule
=
new
ScheduleRecordEntity
();
BeanUtils
.
copyProperties
(
rangeVo
,
schedule
);
schedule
.
setStatus
(
WhetherEnum
.
ALLOW
.
getValue
());
schedule
.
setScheduleDate
(
DateUtils
.
getNextWeek
(
schDate
,
3
));
// schedule.setAvailableCount(rangeVo.getTotalCount());
log
.
info
(
"排班新增入参:"
+
schedule
.
toString
());
scheduleRecordMapper
.
insert
(
schedule
);
});
continue
;
}
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"节日日期转换异常"
,
e
);
}
}
}
}
// @Scheduled(cron = "0 0 1 * * ?")
public
void
orderInvalidation
()
{
List
<
MobileBenefitPackageEntity
>
mobileBenefitPackageEntities
=
mobileBenefitPackageMapper
.
queryMaxOneList
();
try
{
if
(!
mobileBenefitPackageEntities
.
isEmpty
())
{
for
(
MobileBenefitPackageEntity
mbp
:
mobileBenefitPackageEntities
)
{
Date
curTime
=
new
Date
();
Date
endTime
=
DateUtils
.
parseDate
(
mbp
.
getBenefitsEndTime
(),
DateUtils
.
FULL_FORMAT
);
PatientSignEntity
patientSignEntity
=
patientSignSevice
.
getOneByPhone
(
mbp
.
getPhone
());
mbp
.
setVersion
(
1
);
if
(
endTime
.
after
(
curTime
))
{
patientSignEntity
.
setPackageOrderId
(
mbp
.
getActivateOrderId
());
patientSignEntity
.
setSignEndTime
(
endTime
);
}
else
{
patientSignEntity
.
setStatus
(
StatusEnum
.
FINISH_APPLY
.
getValue
());
}
patientSignSevice
.
updateById
(
patientSignEntity
);
mobileBenefitPackageMapper
.
updateVersion
(
mbp
);
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"日期转换异常"
,
e
);
}
}
}
}
family-doctor-server/src/main/java/com/ebaiyihui/family/doctor/server/task/SignedTask.java
0 → 100644
浏览文件 @
c75a038e
package
com
.
ebaiyihui
.
family
.
doctor
.
server
.
task
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ebaiyihui.family.doctor.common.bo.Result
;
import
com.ebaiyihui.family.doctor.common.dto.HealthInfoDTO
;
import
com.ebaiyihui.family.doctor.common.dto.SendImMsgDTO
;
import
com.ebaiyihui.family.doctor.server.common.constants.CommonConstants
;
import
com.ebaiyihui.family.doctor.server.common.constants.ImConstants
;
import
com.ebaiyihui.family.doctor.server.common.enums.MsgTempTypeEnum
;
import
com.ebaiyihui.family.doctor.server.common.enums.StatusEnum
;
import
com.ebaiyihui.family.doctor.server.entity.MobileBenefitPackageEntity
;
import
com.ebaiyihui.family.doctor.server.entity.PatientSignEntity
;
import
com.ebaiyihui.family.doctor.server.mapper.MobileBenefitPackageMapper
;
import
com.ebaiyihui.family.doctor.server.service.ImMsgTemplateService
;
import
com.ebaiyihui.family.doctor.server.service.PatientSignService
;
import
com.ebaiyihui.family.doctor.server.util.DateUtils
;
import
com.ebaiyihui.family.doctor.server.util.ThirdOrderPushUtil
;
import
com.ebaiyihui.framework.response.BaseResponse
;
import
com.ebaiyihui.imforward.client.vo.IMQueryMsgReqVO
;
import
com.ebaiyihui.imforward.client.vo.IMQueryUserLoginReqVO
;
import
com.ebaiyihui.imforward.client.vo.IMQueryUserLoginRspVO
;
import
com.ebaiyihui.imforward.client.vo.IMSingleMsgResultVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* @ClassName: SignedTask
* @Author:yanliang
* @Date:2024/3/22 10:20
* @Description
*/
@Component
@Slf4j
public
class
SignedTask
{
@Autowired
private
ImMsgTemplateService
imMsgTemplateService
;
@Autowired
private
PatientSignService
patientSignSevice
;
@Autowired
private
MobileBenefitPackageMapper
mobileBenefitPackageMapper
;
@Autowired
private
ThirdOrderPushUtil
thirdOrderPushUtil
;
// @Scheduled(cron = "0 0 10 * * ?")
public
void
healthRecordWhetherUpdate
()
{
List
<
PatientSignEntity
>
patientSignEntities
=
patientSignSevice
.
selectList
(
new
PatientSignEntity
());
if
(!
patientSignEntities
.
isEmpty
())
{
for
(
PatientSignEntity
ps
:
patientSignEntities
)
{
HealthInfoDTO
healthInfoDTO
=
new
HealthInfoDTO
();
healthInfoDTO
.
setPhone
(
ps
.
getPatientPhone
());
// 查询用户健康档案30天内是否有更新
String
result
=
thirdOrderPushUtil
.
getHealthRecordWhetherUpdate
(
healthInfoDTO
);
Result
<
Boolean
>
res
=
JSONObject
.
parseObject
(
result
,
Result
.
class
);
Boolean
flag
=
res
.
getData
();
SendImMsgDTO
sendImMsgDTO
=
new
SendImMsgDTO
();
sendImMsgDTO
.
setAppCode
(
CommonConstants
.
APP_CODE
);
sendImMsgDTO
.
setOrganId
(
CommonConstants
.
ORGAN_CODE
);
sendImMsgDTO
.
setAdmId
(
ps
.
getAdmId
());
if
(!
flag
)
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_PUSH_HEAL_REC
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
// 1、签约完成定时任务第10天,主动触发 2、定时任务之后每隔15天,主动触发
Date
curDate
=
new
Date
();
int
difDay
=
DateUtils
.
daysBetween
(
ps
.
getCreateTime
(),
curDate
);
int
afterFifteenDay
=
DateUtils
.
daysBetween
(
ps
.
getCreateTime
(),
curDate
);
if
(
10
==
difDay
||
afterFifteenDay
%
15
==
0
)
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT__SIG_SUC
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
// 1、当用户有触发过‘报告异常’问诊 2、定时任务触发20天后主动触发
if
(
20
==
difDay
)
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_REP_ANO
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
// 1、当用户与医生7天未进行沟通 2、判断后主动触发
// {"appCode":"EHOS_PATIENT","appointmentId":["9ad0b140bd1b4b86b1aa68f59c9dbf9a"],"businessCode":"jtys","msgType":"1","page":0,"pageSize":999,"sortOrder":"ASC","userId":"18170905967"}
IMQueryMsgReqVO
imQueryMsgReqVO
=
new
IMQueryMsgReqVO
();
imQueryMsgReqVO
.
setAppCode
(
ImConstants
.
IM_PAT_ACCOUNT_NUM
);
imQueryMsgReqVO
.
setBusinessCode
(
ImConstants
.
IM_QUERY_ACCOUNT_CODE
);
imQueryMsgReqVO
.
setMsgType
(
"1"
);
imQueryMsgReqVO
.
setPageSize
(
10
);
imQueryMsgReqVO
.
setSortOrder
(
"DESC"
);
List
<
String
>
appointmentIds
=
new
ArrayList
<>();
appointmentIds
.
add
(
ps
.
getAdmId
());
imQueryMsgReqVO
.
setAppointmentId
(
appointmentIds
);
imQueryMsgReqVO
.
setUserId
(
ps
.
getPatientUserId
());
String
sendTimeStr
=
"2023-12-01 00:00:00"
;
try
{
BaseResponse
<
List
<
IMSingleMsgResultVO
>>
msgContent
=
patientSignSevice
.
getAllMsgContent
(
imQueryMsgReqVO
);
if
(
"1"
.
equals
(
msgContent
.
getCode
()))
{
List
<
IMSingleMsgResultVO
>
imSingleMsgResultVOS
=
msgContent
.
getData
();
IMQueryUserLoginReqVO
imQueryUserLoginReqVO
=
new
IMQueryUserLoginReqVO
();
imQueryUserLoginReqVO
.
setAppCode
(
ImConstants
.
IM_PAT_ACCOUNT_NUM
);
imQueryUserLoginReqVO
.
setUserId
(
ps
.
getPatientUserId
());
BaseResponse
<
IMQueryUserLoginRspVO
>
sdkLogin
=
patientSignSevice
.
querySdkLogin
(
imQueryUserLoginReqVO
);
if
(
"1"
.
equals
(
sdkLogin
.
getCode
()))
{
IMQueryUserLoginRspVO
imQueryUserLoginRspVO
=
sdkLogin
.
getData
();
String
sdkAccount
=
imQueryUserLoginRspVO
.
getSdkAccount
();
for
(
IMSingleMsgResultVO
imSingleMsgResultVO
:
imSingleMsgResultVOS
)
{
if
(
imSingleMsgResultVO
.
getSender
().
equals
(
sdkAccount
))
{
sendTimeStr
=
imSingleMsgResultVO
.
getSendTime
();
break
;
}
}
}
Date
sendTime
=
DateUtils
.
parseDate
(
sendTimeStr
,
DateUtils
.
FULL_FORMAT
);
int
difSendDay
=
DateUtils
.
daysBetween
(
sendTime
,
curDate
);
if
(
7
==
difSendDay
)
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_UN_CON
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"获取发送消息异常"
,
e
);
}
}
}
}
// @Scheduled(cron = "0 0 20 * * ?")
public
void
holidayPush
()
{
List
<
PatientSignEntity
>
patientSignEntities
=
patientSignSevice
.
selectList
(
new
PatientSignEntity
());
try
{
if
(!
patientSignEntities
.
isEmpty
())
{
for
(
PatientSignEntity
ps
:
patientSignEntities
)
{
SendImMsgDTO
sendImMsgDTO
=
new
SendImMsgDTO
();
sendImMsgDTO
.
setAppCode
(
CommonConstants
.
APP_CODE
);
sendImMsgDTO
.
setOrganId
(
CommonConstants
.
ORGAN_CODE
);
sendImMsgDTO
.
setAdmId
(
ps
.
getAdmId
());
Date
curDate
=
new
Date
();
Date
qmBeforeDay
=
DateUtils
.
getQingMingBeforeDay
(
curDate
);
Date
curDay
=
DateUtils
.
parseDate
(
DateUtils
.
getFormatDateString
(
curDate
,
DateUtils
.
SIMPLE_FORMAT
),
DateUtils
.
SIMPLE_FORMAT
);
if
(
qmBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_TSD
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
Date
laborBeforeDay
=
DateUtils
.
getLaborBeforeDay
(
curDate
);
if
(
laborBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_LD
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
Date
duanWuBeforeDay
=
DateUtils
.
getLaborBeforeDay
(
curDate
);
if
(
duanWuBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_TDBF
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
Date
zhongQiuBeforeDay
=
DateUtils
.
getZhongQiuBeforeDay
(
curDate
);
if
(
zhongQiuBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_MAF
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
Date
guoQingBeforeDay
=
DateUtils
.
getGuoQingBeforeDay
(
curDate
);
if
(
guoQingBeforeDay
.
equals
(
curDay
))
{
sendImMsgDTO
.
setType
(
MsgTempTypeEnum
.
ACT_FU_MAF
.
getValue
());
imMsgTemplateService
.
sendImMsg
(
sendImMsgDTO
);
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"节日日期转换异常"
,
e
);
}
}
// @Scheduled(cron = "0 0 1 * * ?")
public
void
orderInvalidation
()
{
List
<
MobileBenefitPackageEntity
>
mobileBenefitPackageEntities
=
mobileBenefitPackageMapper
.
queryMaxOneList
();
try
{
if
(!
mobileBenefitPackageEntities
.
isEmpty
())
{
for
(
MobileBenefitPackageEntity
mbp
:
mobileBenefitPackageEntities
)
{
Date
curTime
=
new
Date
();
Date
endTime
=
DateUtils
.
parseDate
(
mbp
.
getBenefitsEndTime
(),
DateUtils
.
FULL_FORMAT
);
PatientSignEntity
patientSignEntity
=
patientSignSevice
.
getOneByPhone
(
mbp
.
getPhone
());
mbp
.
setVersion
(
1
);
if
(
endTime
.
after
(
curTime
))
{
patientSignEntity
.
setPackageOrderId
(
mbp
.
getActivateOrderId
());
patientSignEntity
.
setSignEndTime
(
endTime
);
}
else
{
patientSignEntity
.
setStatus
(
StatusEnum
.
FINISH_APPLY
.
getValue
());
}
patientSignSevice
.
updateById
(
patientSignEntity
);
mobileBenefitPackageMapper
.
updateVersion
(
mbp
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"日期转换异常"
,
e
);
}
}
}
family-doctor-server/src/main/resources/mapper/MobileBenefitPackageMapper.xml
浏览文件 @
c75a038e
...
@@ -8,9 +8,9 @@
...
@@ -8,9 +8,9 @@
INSERT INTO mobile_benefit_package (
INSERT INTO mobile_benefit_package (
<if
test=
"productId != '' and productId != null"
>
productId,
</if>
<if
test=
"productId != '' and productId != null"
>
productId,
</if>
<if
test=
"userId != '' and userId != null"
>
userId,
</if>
<if
test=
"userId != '' and userId != null"
>
userId,
</if>
<if
test=
"activateOrderId != '' and activateOrderId != null"
>
o
rderId,
</if>
<if
test=
"activateOrderId != '' and activateOrderId != null"
>
benefitO
rderId,
</if>
<if
test=
"timeLimit != 0 and timeLimit != null"
>
timeLimit,
</if>
<if
test=
"timeLimit != 0 and timeLimit != null"
>
timeLimit,
</if>
<if
test=
"orderId != '' and orderId != null"
>
benefitO
rderId,
</if>
<if
test=
"orderId != '' and orderId != null"
>
o
rderId,
</if>
<if
test=
"benefitsStartTime != '' and benefitsStartTime != null"
>
benefitsStartTime,
</if>
<if
test=
"benefitsStartTime != '' and benefitsStartTime != null"
>
benefitsStartTime,
</if>
<if
test=
"benefitsEndTime != '' and benefitsEndTime != null"
>
benefitsEndTime,
</if>
<if
test=
"benefitsEndTime != '' and benefitsEndTime != null"
>
benefitsEndTime,
</if>
<if
test=
"isRenew != '' and isRenew != null"
>
isRenew,
</if>
<if
test=
"isRenew != '' and isRenew != null"
>
isRenew,
</if>
...
@@ -58,8 +58,7 @@
...
@@ -58,8 +58,7 @@
FROM
FROM
mobile_benefit_package
mobile_benefit_package
WHERE
WHERE
phone = #{mobile} and orderId = #{activateOrderId}
phone = #{mobile} and activateOrderId = #{activateOrderId}
and NOW() BETWEEN STR_TO_DATE(benefitsStartTime, '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(benefitsEndTime, '%Y-%m-%d %H:%i:%s')
ORDER BY
ORDER BY
x_create_time DESC
x_create_time DESC
LIMIT 0,1
LIMIT 0,1
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论