定时任务
This commit is contained in:
parent
deda0da48b
commit
4d2ed89d41
@ -348,4 +348,9 @@ public class Constants {
|
||||
* 资讯编码前缀
|
||||
*/
|
||||
public static final String INFO_CODE = "IC";
|
||||
|
||||
/**
|
||||
* 泉医微信小程序ACCESS_TOKEN前缀(测试使用)
|
||||
*/
|
||||
public static final String NURSE_STATION_APPLET_ACCESS_TOKEN = "NURSE_STATION_APPLET_ACCESS_TOKEN";
|
||||
}
|
||||
|
||||
@ -19,16 +19,6 @@ import com.xinelu.manage.mapper.specialdiseaseroute.SpecialDiseaseRouteMapper;
|
||||
import com.xinelu.manage.service.specialdiseasenode.ISpecialDiseaseNodeService;
|
||||
import com.xinelu.manage.vo.specialdiseasenode.SpecialDiseaseNodeVO;
|
||||
import com.xinelu.manage.vo.specialdiseaseroute.SpecialDiseaseRouteVO;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -39,6 +29,12 @@ import org.jsoup.select.Elements;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 专病路径-管理节点信息Service业务层处理
|
||||
*
|
||||
@ -147,6 +143,7 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService
|
||||
if (StringUtils.isNotBlank(diseaseNode.getRouteNodeName()) && Objects.nonNull(diseaseNode.getRouteNodeDay()) && StringUtils.isNotBlank(diseaseNode.getTaskType()) && StringUtils.isNotBlank(diseaseNode.getTaskSubdivision()) && StringUtils.isNotBlank(diseaseNode.getTaskStatus())) {
|
||||
diseaseNode.setRouteId(specialDiseaseRoute.getId());
|
||||
diseaseNode.setRouteName(specialDiseaseNode.getRouteName());
|
||||
diseaseNode.setTemplateType(diseaseNode.getTaskSubdivisiontemplateType());
|
||||
diseaseNode.setUpdateTime(LocalDateTime.now());
|
||||
diseaseNode.setUpdateBy(SecurityUtils.getUsername());
|
||||
specialDiseaseNodeVOS.add(diseaseNode);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.xinelu.manage.vo.specialdiseasenode;
|
||||
|
||||
import com.xinelu.manage.domain.specialdiseasenode.SpecialDiseaseNode;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ -22,4 +21,6 @@ public class SpecialDiseaseNodeVO extends SpecialDiseaseNode {
|
||||
private String taskSubdivisionName;
|
||||
|
||||
private String taskStatusName;
|
||||
|
||||
private String taskSubdivisiontemplateType;
|
||||
}
|
||||
|
||||
@ -6,13 +6,8 @@ import com.xinelu.common.config.WeChatOfficialAccountConfig;
|
||||
import com.xinelu.common.constant.Constants;
|
||||
import com.xinelu.common.entity.AccessToken;
|
||||
import com.xinelu.common.entity.MessageValueEntity;
|
||||
import com.xinelu.common.enums.PatientTypeEnum;
|
||||
import com.xinelu.common.enums.RouteNodeNameEnum;
|
||||
import com.xinelu.common.enums.SubscribeStatusEnum;
|
||||
import com.xinelu.common.exception.ServiceException;
|
||||
import com.xinelu.common.utils.http.HttpUtils;
|
||||
import com.xinelu.manage.service.specialdiseaseroute.ISpecialDiseaseRouteService;
|
||||
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
|
||||
import com.xinelu.mobile.vo.wechatofficialaccountcallback.PatientVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -21,9 +16,10 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 院后公众号公众方法工具类
|
||||
@ -39,6 +35,8 @@ public class WeChatOfficialAccountUtils {
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Resource
|
||||
private WeChatOfficialAccountConfig weChatOfficialAccountConfig;
|
||||
@Resource
|
||||
private WeChatAppletChatConfig weChatAppletChatConfig;
|
||||
|
||||
|
||||
/**
|
||||
@ -53,12 +51,18 @@ public class WeChatOfficialAccountUtils {
|
||||
*/
|
||||
public String getWeChatOfficialAccountAccessToken() {
|
||||
String accessToken;
|
||||
String accessTokenRedisKey = Constants.WE_CHAT_OFFICIAL_ACCOUNT_ACCESS_TOKEN + "accessToken";
|
||||
//小程序
|
||||
String accessTokenRedisKey = Constants.NURSE_STATION_APPLET_ACCESS_TOKEN + "accessToken";
|
||||
//公众号
|
||||
//String accessTokenRedisKey = Constants.WE_CHAT_OFFICIAL_ACCOUNT_ACCESS_TOKEN + "accessToken";
|
||||
//从Redis中取出accessToken
|
||||
Object object = redisTemplate.opsForValue().get(accessTokenRedisKey);
|
||||
if (Objects.isNull(object)) {
|
||||
//没有,获取accessToken
|
||||
String accessTokenUrl = Constants.WE_CHAT_ACCESS_TOKEN_URL + "&appid=" + weChatOfficialAccountConfig.getOfficialAccountAppId() + "&secret=" + weChatOfficialAccountConfig.getOfficialAccountAppSecret();
|
||||
//小程序
|
||||
String accessTokenUrl = Constants.WE_CHAT_ACCESS_TOKEN_URL + "&appid=" + weChatAppletChatConfig.getAppletId() + "&secret=" + weChatAppletChatConfig.getSecret();
|
||||
//公众号
|
||||
//String accessTokenUrl = Constants.WE_CHAT_ACCESS_TOKEN_URL + "&appid=" + weChatOfficialAccountConfig.getOfficialAccountAppId() + "&secret=" + weChatOfficialAccountConfig.getOfficialAccountAppSecret();
|
||||
//发送请求
|
||||
String result = HttpUtils.sendGet(accessTokenUrl);
|
||||
if (StringUtils.isBlank(result)) {
|
||||
@ -92,22 +96,26 @@ public class WeChatOfficialAccountUtils {
|
||||
//定义模板内容,公众模板内容
|
||||
Map<String, Object> paramsMap = new LinkedHashMap<>();
|
||||
paramsMap.put("touser", patientVO.getOpenId());
|
||||
paramsMap.put("template_id", "WUCYtSbH-QFRV_fMcfmn86QLsz1zo881QW7fQNTWOjc");
|
||||
paramsMap.put("template_id", "S_c9bR4znSWpXg-6ACIMn7AkaR11dzo113XM8w4CKz0");
|
||||
paramsMap.put("page", "/postDischarge/homePage/subscriptionMessage?id =" + patientVO.getSignPatientManageRouteNodeId());
|
||||
//微信小程序跳转内容
|
||||
Map<String, Object> miniprogramMap = new LinkedHashMap<>();
|
||||
miniprogramMap.put("appid", "wxdc32268eca6b78f9");
|
||||
miniprogramMap.put("pagepath", "pages/startup/startup");
|
||||
// Map<String, Object> miniprogramMap = new LinkedHashMap<>();
|
||||
//miniprogramMap.put("appid", "wxdc32268eca6b78f9");
|
||||
// miniprogramMap.put("pagepath", "/postDischarge/homePage/subscriptionMessage?id =" + patientVO.getSignPatientManageRouteNodeId());
|
||||
//微信小程序模板data内容
|
||||
Map<String, Object> dataMap = new LinkedHashMap<>();
|
||||
dataMap.put("phrase7", new MessageValueEntity("泉医陪护"));
|
||||
dataMap.put("character_string3", new MessageValueEntity("000026315412331612100"));
|
||||
dataMap.put("time6", new MessageValueEntity("2024-03-25 16:21:32"));
|
||||
dataMap.put("time10", new MessageValueEntity("2024-03-27 10:00:00"));
|
||||
dataMap.put("thing11", new MessageValueEntity("济南市槐荫区首诺城市之光东座22楼E10"));
|
||||
paramsMap.put("miniprogram", miniprogramMap);
|
||||
// dataMap.put("phrase7", new MessageValueEntity("泉医陪护"));
|
||||
// dataMap.put("character_string3", new MessageValueEntity("000026315412331612100"));
|
||||
// dataMap.put("time6", new MessageValueEntity("2024-03-25 16:21:32"));
|
||||
// dataMap.put("time10", new MessageValueEntity("2024-03-27 10:00:00"));
|
||||
// dataMap.put("thing11", new MessageValueEntity("济南市槐荫区首诺城市之光东座22楼E10"));
|
||||
//paramsMap.put("miniprogram", miniprogramMap);
|
||||
dataMap.put("thing1", new MessageValueEntity("每日签到"));
|
||||
dataMap.put("thing2", new MessageValueEntity(LocalDate.now().getYear() + "年" + LocalDate.now().getMonthValue() + "月" + LocalDate.now().getDayOfMonth() + "日签到成功"));
|
||||
dataMap.put("thing3", new MessageValueEntity(patientVO.getRouteNodeName() + "第" + patientVO.getRouteNodeDay()));
|
||||
paramsMap.put("data", dataMap);
|
||||
//拼接请求地址并发送
|
||||
String messageUrl = Constants.OFFICIAL_ACCOUNT_TEMPLATE_SEND_URL + accessToken;
|
||||
String messageUrl = Constants.OFFICIAL_ACCOUNT_SUBSCRIBE_SEND_URL + accessToken;
|
||||
String param = JSON.toJSONString(paramsMap);
|
||||
String result = HttpUtils.sendPostJson(messageUrl, param);
|
||||
//返回参数映射
|
||||
@ -132,6 +140,9 @@ public class WeChatOfficialAccountUtils {
|
||||
case Constants.ARGUMENT_INVALID:
|
||||
log.error("参数无效!");
|
||||
break;
|
||||
case Constants.API_UNAUTHORIZED:
|
||||
log.error("API 功能未授权!");
|
||||
break;
|
||||
case Constants.DENY_SUBSCRIPTION:
|
||||
log.error("用户拒接订阅!");
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user