定时任务
This commit is contained in:
parent
46b88d4de0
commit
665d3883a9
@ -1,11 +0,0 @@
|
||||
package com.xinelu.mobile.service.subscribemessagesendrecord;
|
||||
|
||||
/**
|
||||
* @Description 订阅消息数据业务层
|
||||
* @Author zh
|
||||
* @Date 2024-05-24
|
||||
*/
|
||||
public interface SubscribeMessageSendDataService {
|
||||
|
||||
void subscribeMessageSendDataTask();
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
package com.xinelu.mobile.service.subscribemessagesendrecord.impl;
|
||||
|
||||
import com.xinelu.common.config.WeChatAppletChatConfig;
|
||||
import com.xinelu.common.enums.PatientTypeEnum;
|
||||
import com.xinelu.common.enums.RouteNodeNameEnum;
|
||||
import com.xinelu.common.enums.SubscribeStatusEnum;
|
||||
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
|
||||
import com.xinelu.mobile.service.subscribemessagesendrecord.SubscribeMessageSendDataService;
|
||||
import com.xinelu.mobile.utils.WeChatOfficialAccountUtils;
|
||||
import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 订阅消息数据实现层
|
||||
* @Author zh
|
||||
* @Date 2024-05-24
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SubscribeMessageSendDataServiceImpl implements SubscribeMessageSendDataService {
|
||||
|
||||
@Resource
|
||||
private HomePageMapper homePageMapper;
|
||||
@Resource
|
||||
private WeChatAppletChatConfig weChatAppletChatConfig;
|
||||
@Resource
|
||||
private WeChatOfficialAccountUtils weChatOfficialAccountUtils;
|
||||
|
||||
public void subscribeMessageSendDataTask() {
|
||||
List<PatientVO> patient = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getSignTemplateId());
|
||||
List<Long> collect = patient.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
return;
|
||||
}
|
||||
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(collect);
|
||||
List<PatientVO> patientVOS = new ArrayList<>();
|
||||
for (PatientVO signPatientManageRouteNode : signPatientManageRouteNodes) {
|
||||
if (Objects.isNull(signPatientManageRouteNode.getAppletPushSign()) || signPatientManageRouteNode.getAppletPushSign() != 1) {
|
||||
continue;
|
||||
}
|
||||
if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_DISCHARGE.getInfo()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getInfo())) {
|
||||
PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO());
|
||||
if (patientVO.getPatientType().equals(PatientTypeEnum.DISCHARGED_PATIENT.getInfo())) {
|
||||
LocalDate localDate = patientVO.getDischargeTime().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_ADMISSION.getInfo())) {
|
||||
PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO());
|
||||
if (patientVO.getPatientType().equals(PatientTypeEnum.IN_HOSPITAL_PATIENT.getInfo())) {
|
||||
LocalDate localDate = patientVO.getAdmissionTime().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_CONSULTATION.getInfo()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getInfo())) {
|
||||
PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO());
|
||||
if (patientVO.getPatientType().equals(PatientTypeEnum.OUTPATIENT.getInfo()) && patientVO.getDischargeTime() == null) {
|
||||
LocalDate localDate = patientVO.getVisitDate().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PatientVO patientVO : patientVOS) {
|
||||
weChatOfficialAccountUtils.sendOfficialAccountTemplateMessage(patientVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,21 +1,83 @@
|
||||
package com.xinelu.quartz.service.impl;
|
||||
|
||||
import com.xinelu.mobile.service.subscribemessagesendrecord.SubscribeMessageSendDataService;
|
||||
import com.xinelu.common.config.WeChatAppletChatConfig;
|
||||
import com.xinelu.common.enums.PatientTypeEnum;
|
||||
import com.xinelu.common.enums.RouteNodeNameEnum;
|
||||
import com.xinelu.common.enums.SubscribeStatusEnum;
|
||||
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
|
||||
import com.xinelu.mobile.utils.WeChatOfficialAccountUtils;
|
||||
import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO;
|
||||
import com.xinelu.quartz.service.SubscribeTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
||||
|
||||
@Resource
|
||||
private SubscribeMessageSendDataService subscribeMessageSendRecordService;
|
||||
private HomePageMapper homePageMapper;
|
||||
@Resource
|
||||
private WeChatAppletChatConfig weChatAppletChatConfig;
|
||||
@Resource
|
||||
private WeChatOfficialAccountUtils weChatOfficialAccountUtils;
|
||||
|
||||
@Override
|
||||
public void signPatientManageRouteNodeTask() {
|
||||
subscribeMessageSendRecordService.subscribeMessageSendDataTask();
|
||||
List<PatientVO> patient = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getSignTemplateId());
|
||||
List<Long> collect = patient.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
return;
|
||||
}
|
||||
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(collect);
|
||||
List<PatientVO> patientVOS = new ArrayList<>();
|
||||
for (PatientVO signPatientManageRouteNode : signPatientManageRouteNodes) {
|
||||
if (Objects.isNull(signPatientManageRouteNode.getAppletPushSign()) || signPatientManageRouteNode.getAppletPushSign() != 1) {
|
||||
continue;
|
||||
}
|
||||
if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_DISCHARGE.getInfo()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getInfo())) {
|
||||
PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO());
|
||||
if (patientVO.getPatientType().equals(PatientTypeEnum.DISCHARGED_PATIENT.getInfo())) {
|
||||
LocalDate localDate = patientVO.getDischargeTime().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_ADMISSION.getInfo())) {
|
||||
PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO());
|
||||
if (patientVO.getPatientType().equals(PatientTypeEnum.IN_HOSPITAL_PATIENT.getInfo())) {
|
||||
LocalDate localDate = patientVO.getAdmissionTime().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_CONSULTATION.getInfo()) || signPatientManageRouteNode.getRouteNodeName().equals(RouteNodeNameEnum.AFTER_VISIT_DISCHARGE.getInfo())) {
|
||||
PatientVO patientVO = patient.stream().filter(Objects::nonNull).filter(item -> signPatientManageRouteNode.getPatientId().equals(item.getPatientId())).findFirst().orElse(new PatientVO());
|
||||
if (patientVO.getPatientType().equals(PatientTypeEnum.OUTPATIENT.getInfo()) && patientVO.getDischargeTime() == null) {
|
||||
LocalDate localDate = patientVO.getVisitDate().plusDays(signPatientManageRouteNode.getRouteNodeDay());
|
||||
boolean before = localDate.isEqual(LocalDate.now());
|
||||
if (before) {
|
||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||
patientVOS.add(signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PatientVO patientVO : patientVOS) {
|
||||
weChatOfficialAccountUtils.sendOfficialAccountTemplateMessage(patientVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user