Commit 25ae910c061426cef06e582b5dc344b2a1f4b7a0
1 parent
d6dc0538e9
Exists in
master
公众号获取access_token 放入配置文件中。
疾病分类推送 慢性病:确诊后第30天推送一次,间隔90天进行第二次推送 普通疾病:确诊15天后 推送
Showing 15 changed files with 455 additions and 62 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TestController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushIllnessMsgMapper.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushIllnessTypeDataResult.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushIllnessMsgService.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushIllnessMsgServiceImpl.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AccessTokenServlet.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeData.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeTask.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/DateUtil.java
- talkonlineweb/src/main/resources/application-dev.yml
- talkonlineweb/src/main/resources/application-prod.yml
- talkonlineweb/src/main/resources/application.yml
- talkonlineweb/src/main/resources/mapper/LymsPushIllnessMsgMapper.xml
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java
View file @
25ae910
... | ... | @@ -50,7 +50,7 @@ |
50 | 50 | if(StringUtil.isNotEmpty(hisInfo.getHospitalId())) { |
51 | 51 | query.eq("hospitalId", hisInfo.getHospitalId()); |
52 | 52 | } |
53 | - query.orderByDesc("createdtime"); | |
53 | + query.orderByDesc("created"); | |
54 | 54 | if(null!=hisInfo.getUpType()){ |
55 | 55 | query.eq("up_type", hisInfo.getUpType()); |
56 | 56 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TestController.java
View file @
25ae910
... | ... | @@ -5,9 +5,7 @@ |
5 | 5 | import com.lyms.talkonlineweb.annotation.TokenRequired; |
6 | 6 | import com.lyms.talkonlineweb.domain.LymsPcase; |
7 | 7 | import com.lyms.talkonlineweb.service.LymsPcaseService; |
8 | -import com.lyms.talkonlineweb.task.GetPatientInfoTask; | |
9 | -import com.lyms.talkonlineweb.task.PushArticleTask; | |
10 | -import com.lyms.talkonlineweb.task.PushArticleTaskData; | |
8 | +import com.lyms.talkonlineweb.task.*; | |
11 | 9 | import lombok.extern.java.Log; |
12 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
13 | 11 | import org.springframework.web.bind.annotation.GetMapping; |
... | ... | @@ -28,6 +26,10 @@ |
28 | 26 | public GetPatientInfoTask getPatientInfoTask; |
29 | 27 | @Autowired |
30 | 28 | private LymsPcaseService lymsPcaseService;//病例 |
29 | + @Autowired | |
30 | + private PushIllnessTypeData pushIllnessTypeData; | |
31 | + @Autowired | |
32 | + private PushIllnessTypeTask pushIllnessTypeTask; | |
31 | 33 | |
32 | 34 | @GetMapping("test") |
33 | 35 | @TokenRequired |
... | ... | @@ -45,6 +47,17 @@ |
45 | 47 | @TokenRequired |
46 | 48 | public void test0() { |
47 | 49 | pushArticleTaskData.pushArtcleData(); |
50 | + } | |
51 | + | |
52 | + @GetMapping("test1") | |
53 | + @TokenRequired | |
54 | + public void test1() { | |
55 | + pushIllnessTypeData.PushIllnessTypeData(); | |
56 | + } | |
57 | + @GetMapping("test2") | |
58 | + @TokenRequired | |
59 | + public void test2() { | |
60 | + pushIllnessTypeTask.PushIllnessTypeTask(); | |
48 | 61 | } |
49 | 62 | |
50 | 63 |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushIllnessMsgMapper.java
View file @
25ae910
1 | +package com.lyms.talkonlineweb.mapper; | |
2 | + | |
3 | +import com.lyms.talkonlineweb.domain.LymsPushIllnessMsg; | |
4 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
5 | +import com.lyms.talkonlineweb.result.PushIllnessTypeDataResult; | |
6 | +import org.apache.ibatis.annotations.Mapper; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +/** | |
11 | + * @Entity com.lyms.talkonlineweb.domain.LymsPushIllnessMsg | |
12 | + */ | |
13 | +@Mapper | |
14 | +public interface LymsPushIllnessMsgMapper extends BaseMapper<LymsPushIllnessMsg> { | |
15 | + | |
16 | + List<PushIllnessTypeDataResult> getPatientIllenssType(); | |
17 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushIllnessTypeDataResult.java
View file @
25ae910
1 | +package com.lyms.talkonlineweb.result; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.util.Date; | |
6 | + | |
7 | +@Data | |
8 | +public class PushIllnessTypeDataResult { | |
9 | + /** | |
10 | + * 患者id | |
11 | + */ | |
12 | + private Integer id; | |
13 | + /** | |
14 | + * 患者手机号/患者小程序登录账号 | |
15 | + */ | |
16 | + private String phone; | |
17 | + /** | |
18 | + * 患者小程序登录密码 | |
19 | + */ | |
20 | + private String passwd; | |
21 | + /** | |
22 | + * 患者公众号id | |
23 | + */ | |
24 | + private String gzopenid; | |
25 | + /** | |
26 | + * 患者姓名 | |
27 | + */ | |
28 | + private String pname; | |
29 | + /** | |
30 | + * 患者病例id | |
31 | + */ | |
32 | + private Integer pcid; | |
33 | + /** | |
34 | + * 就诊医院 | |
35 | + */ | |
36 | + private String hname; | |
37 | + /** | |
38 | + * 就诊科室 | |
39 | + */ | |
40 | + private String dname; | |
41 | + /** | |
42 | + * 就诊医生 | |
43 | + */ | |
44 | + private String dtname; | |
45 | + /** | |
46 | + * 患者疾病id | |
47 | + */ | |
48 | + private Integer code; | |
49 | + /** | |
50 | + * 患者疾病名称 | |
51 | + */ | |
52 | + private String value; | |
53 | + /** | |
54 | + * 患者疾病分类 1普通疾病,2慢性病 | |
55 | + */ | |
56 | + private Integer illnessType; | |
57 | + /** | |
58 | + * 已推送的患者疾病 1普通疾病,2慢性病 | |
59 | + */ | |
60 | + private Integer pushIllness; | |
61 | + /** | |
62 | + * 已推送的 次数 | |
63 | + * 疾病分类推送数据:慢性疾病 确诊后30天推送一次(1),间隔90天进行第二次推送(2)。普通疾病:确诊15天后 推送(1)。 | |
64 | + */ | |
65 | + private Integer pushCount; | |
66 | + /** | |
67 | + * 已推送的结果 | |
68 | + * 推送状态:0待推送。1:成功,2 失败', | |
69 | + */ | |
70 | + private Integer pushType; | |
71 | + /** | |
72 | + * 病例创建时间(用于 推送周期) | |
73 | + */ | |
74 | + private Date createdtime; | |
75 | + /** | |
76 | + * 推送记录id(用于更新推送记录) | |
77 | + */ | |
78 | + private Integer mid; | |
79 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushIllnessMsgService.java
View file @
25ae910
1 | +package com.lyms.talkonlineweb.service; | |
2 | + | |
3 | +import com.lyms.talkonlineweb.domain.LymsPushIllnessMsg; | |
4 | +import com.baomidou.mybatisplus.extension.service.IService; | |
5 | +import com.lyms.talkonlineweb.result.PushIllnessTypeDataResult; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * | |
11 | + */ | |
12 | +public interface LymsPushIllnessMsgService extends IService<LymsPushIllnessMsg> { | |
13 | + | |
14 | + List<PushIllnessTypeDataResult> getPatientIllenssType(); | |
15 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushIllnessMsgServiceImpl.java
View file @
25ae910
1 | +package com.lyms.talkonlineweb.service.impl; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
4 | +import com.lyms.talkonlineweb.domain.LymsPushIllnessMsg; | |
5 | +import com.lyms.talkonlineweb.mapper.LymsPatientMapper; | |
6 | +import com.lyms.talkonlineweb.result.PushIllnessTypeDataResult; | |
7 | +import com.lyms.talkonlineweb.service.LymsPushIllnessMsgService; | |
8 | +import com.lyms.talkonlineweb.mapper.LymsPushIllnessMsgMapper; | |
9 | +import org.springframework.beans.factory.annotation.Autowired; | |
10 | +import org.springframework.stereotype.Service; | |
11 | + | |
12 | +import java.util.List; | |
13 | + | |
14 | +/** | |
15 | + * | |
16 | + */ | |
17 | +@Service | |
18 | +public class LymsPushIllnessMsgServiceImpl extends ServiceImpl<LymsPushIllnessMsgMapper, LymsPushIllnessMsg> | |
19 | + implements LymsPushIllnessMsgService{ | |
20 | + @Autowired | |
21 | + private LymsPushIllnessMsgMapper lymsPushIllnessMsgMapper; | |
22 | + | |
23 | + @Override | |
24 | + public List<PushIllnessTypeDataResult> getPatientIllenssType() { | |
25 | + return lymsPushIllnessMsgMapper.getPatientIllenssType(); | |
26 | + } | |
27 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AccessTokenServlet.java
View file @
25ae910
... | ... | @@ -2,9 +2,10 @@ |
2 | 2 | |
3 | 3 | import com.alibaba.fastjson.JSONObject; |
4 | 4 | import com.lyms.talkonlineweb.util.Constant; |
5 | -import com.lyms.talkonlineweb.util.HttpUtil; | |
6 | 5 | import com.lyms.talkonlineweb.util.StringUtil; |
7 | 6 | import com.lyms.talkonlineweb.util.WeiXinUtil; |
7 | +import lombok.extern.log4j.Log4j2; | |
8 | +import org.springframework.beans.factory.annotation.Value; | |
8 | 9 | import org.springframework.stereotype.Component; |
9 | 10 | |
10 | 11 | import javax.annotation.PostConstruct; |
11 | 12 | |
12 | 13 | |
13 | 14 | |
... | ... | @@ -17,16 +18,24 @@ |
17 | 18 | * (微信公众号规定2小时token失效,每天只能获取2000次。) |
18 | 19 | */ |
19 | 20 | @Component |
21 | +@Log4j2 | |
20 | 22 | public class AccessTokenServlet extends HttpServlet implements Runnable { |
23 | + @Value("${getAccessToken.on_off}") | |
24 | + public boolean on_off;//配置yml 微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突) | |
25 | + | |
21 | 26 | public static String accessToken = null; |
22 | 27 | |
23 | 28 | /** |
24 | 29 | * 启动后开启线程每5分钟获取一次token |
25 | 30 | * @throws ServletException |
26 | 31 | */ |
27 | -// @PostConstruct//部署时开启注释,启动线程(测试环境部署不要开启。会与线上环境冲突) | |
32 | + @PostConstruct//部署时开启注释,启动线程(测试环境部署不要开启。会与线上环境冲突) | |
28 | 33 | public void init() throws ServletException { |
29 | - new Thread(new AccessTokenServlet()).start(); //启动线程 | |
34 | + if(on_off){ | |
35 | + new Thread(new AccessTokenServlet()).start(); //启动线程 | |
36 | + }else { | |
37 | + log.info("测试环境不予获取access_token"); | |
38 | + } | |
30 | 39 | } |
31 | 40 | public void run(){ |
32 | 41 | while (true){ |
... | ... | @@ -38,7 +47,7 @@ |
38 | 47 | Thread.sleep(1000 * 3); //获取的access_token为空 休眠3秒 |
39 | 48 | } |
40 | 49 | }catch(Exception e){ |
41 | - System.out.println("发生异常:"+e.getMessage()); | |
50 | + log.info("发生异常:"+e.getMessage()); | |
42 | 51 | e.printStackTrace(); |
43 | 52 | try{ |
44 | 53 | Thread.sleep(1000 * 10); //发生异常休眠1秒 |
45 | 54 | |
... | ... | @@ -62,12 +71,12 @@ |
62 | 71 | + "&secret=" + Constant.GZ_SECRET; |
63 | 72 | String tokenJsonStr = WeiXinUtil.repeatDoGetPost(getTokenApi, "GET", null); |
64 | 73 | if(StringUtil.isEmpty(tokenJsonStr)){ |
65 | - System.out.println("获取TOKEN :失败,repeatDoGetPost返回值为空>>>>>>>"); | |
74 | + log.info("获取TOKEN :失败,repeatDoGetPost返回值为空>>>>>>>"); | |
66 | 75 | return null; |
67 | 76 | } |
68 | 77 | JSONObject tokenJson = JSONObject.parseObject(tokenJsonStr); |
69 | 78 | String token = tokenJson.get("access_token").toString(); |
70 | - System.out.println("获取到的TOKEN : " + token); | |
79 | + log.info("获取到的TOKEN : " + token); | |
71 | 80 | return token; |
72 | 81 | } |
73 | 82 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeData.java
View file @
25ae910
1 | 1 | package com.lyms.talkonlineweb.task; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.Query; | |
4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |
6 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
7 | +import com.lyms.talkonlineweb.domain.LymsPushIllnessMsg; | |
8 | +import com.lyms.talkonlineweb.domain.LymsPushMessages; | |
9 | +import com.lyms.talkonlineweb.result.PushIllnessTypeDataResult; | |
3 | 10 | import com.lyms.talkonlineweb.service.*; |
11 | +import com.lyms.talkonlineweb.util.DateUtil; | |
12 | +import com.lyms.talkonlineweb.util.StringUtil; | |
4 | 13 | import lombok.extern.log4j.Log4j2; |
5 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
6 | 15 | import org.springframework.stereotype.Component; |
7 | 16 | import org.springframework.transaction.annotation.Transactional; |
8 | 17 | import org.springframework.scheduling.annotation.Scheduled; |
9 | 18 | |
19 | +import java.util.*; | |
20 | + | |
10 | 21 | /** |
11 | 22 | * 疾病分类推送数据整理(1普通疾病,2慢性病) |
12 | 23 | * 慢性病:确诊后第一个月推送一次,间隔3个月进行第二次推送 |
... | ... | @@ -18,25 +29,7 @@ |
18 | 29 | public class PushIllnessTypeData { |
19 | 30 | |
20 | 31 | @Autowired |
21 | - private LymsArticleService lymsArticleService; | |
22 | - @Autowired | |
23 | - private PatientInfoService patientInfoService; | |
24 | - @Autowired | |
25 | - private LymsPushedartService lymsPushedartService;//推送的历史记录 | |
26 | - @Autowired | |
27 | - private PushArticleService pushArticleService;//推送文章新逻辑shiy改 | |
28 | - @Autowired | |
29 | - LymsPushMessagesService lymsPushMessagesService; | |
30 | - @Autowired | |
31 | - private LymsDictService lymsDictService; | |
32 | - @Autowired | |
33 | - public PushArticleTask pushArticleTask; | |
34 | - @Autowired | |
35 | - public LymsPushAttentionRecordService lymsPushAttentionRecordService; | |
36 | - @Autowired | |
37 | - private LymsPatientAttentionService lymsPatientAttentionService; | |
38 | - @Autowired | |
39 | - private LymsPatientService lymsPatientService;//患者 | |
32 | + private LymsPushIllnessMsgService lymsPushIllnessMsgService; | |
40 | 33 | |
41 | 34 | |
42 | 35 | |
43 | 36 | |
44 | 37 | |
... | ... | @@ -44,9 +37,84 @@ |
44 | 37 | * 每天00:00点执行-要推送的公众号信息数据整理 |
45 | 38 | */ |
46 | 39 | // @Scheduled(cron = "0 0 0 * * ?") |
47 | - @Transactional(rollbackFor = Exception.class) | |
48 | 40 | public void PushIllnessTypeData(){ |
41 | + Map param=new HashMap<>(); | |
42 | + param.put("push_type", 0); | |
43 | + final List<LymsPushIllnessMsg> list = lymsPushIllnessMsgService.listByMap(param); | |
44 | + if(CollectionUtils.isNotEmpty(list)){ | |
45 | + log.info("要推送的文章已存在不需要再次推送>>>>>>"); | |
46 | + return; | |
47 | + } | |
48 | + List<PushIllnessTypeDataResult> result= lymsPushIllnessMsgService.getPatientIllenssType(); | |
49 | + for (PushIllnessTypeDataResult dataResult : result) { | |
50 | + LymsPushIllnessMsg lymsPushIllnessMsg = new LymsPushIllnessMsg(); | |
51 | + try { | |
52 | + if(null!=dataResult.getCreatedtime() && StringUtil.isNotEmpty(dataResult.getGzopenid()) && | |
53 | + StringUtil.isNotEmpty(dataResult.getPhone()) && StringUtil.isNotEmpty(dataResult.getPasswd())) { | |
49 | 54 | |
55 | + long newDate = DateUtil.getYmdDate(new Date()).getTime(); | |
56 | + long illenssDate_15 = DateUtil.addDay(DateUtil.getYmdDate(dataResult.getCreatedtime()), 15).getTime(); | |
57 | + long illenssDate_30 = DateUtil.addDay(DateUtil.getYmdDate(dataResult.getCreatedtime()), 30).getTime(); | |
58 | + long illenssDate_120 = DateUtil.addDay(DateUtil.getYmdDate(dataResult.getCreatedtime()), 120).getTime(); | |
59 | + | |
60 | + //普通疾病 | |
61 | + if (1== dataResult.getIllnessType() ) { | |
62 | + if(null==dataResult.getPushType()) { | |
63 | + if (newDate >= illenssDate_15) { | |
64 | + continue; | |
65 | + } | |
66 | + } | |
67 | + lymsPushIllnessMsg.setIllnessType(1); | |
68 | + String text = "患者接受治疗疾病症状应逐渐消退,症状减轻后药量需要减少,及时来医院复诊可以让医生调整用药量," + | |
69 | + "如果患者出现症状加重的情况需及时来医院调整药物用量或更换药物种类。" + | |
70 | + "用药请按照医嘱进行,不要自行增加或减少药物用量,症状消失后可来院复诊检查是否需要用药维持"; | |
71 | + lymsPushIllnessMsg.setContent(text); | |
72 | + } | |
73 | + //慢性疾病 | |
74 | + if (2== dataResult.getIllnessType()) { | |
75 | + if(null==dataResult.getPushType()){ | |
76 | + if(newDate >= illenssDate_30){ | |
77 | + continue; | |
78 | + } | |
79 | + dataResult.setPushCount(1); | |
80 | + }else { | |
81 | + if(1==dataResult.getPushType()){ | |
82 | + if(newDate >= illenssDate_120){ | |
83 | + continue; | |
84 | + } | |
85 | + dataResult.setPushCount(2); | |
86 | + } | |
87 | + } | |
88 | + lymsPushIllnessMsg.setIllnessType(2); | |
89 | + lymsPushIllnessMsg.setPushCount(dataResult.getPushCount()); | |
90 | + String text="患者出院后疾病症状应逐渐减轻,如果患者出现症状加重或症状反复,需立即前往医院就诊。" + | |
91 | + "用药请按医嘱服用药物,不要自行增添或减少药物用量,中间不要停药,药物不足时可自行来医院复诊取药。"; | |
92 | + lymsPushIllnessMsg.setContent(text); | |
93 | + } | |
94 | + | |
95 | + lymsPushIllnessMsg.setPid(dataResult.getId()); | |
96 | + lymsPushIllnessMsg.setPhone(dataResult.getPhone()); | |
97 | + lymsPushIllnessMsg.setPasswd(dataResult.getPasswd()); | |
98 | + lymsPushIllnessMsg.setGzopenid(dataResult.getGzopenid()); | |
99 | + lymsPushIllnessMsg.setPname(dataResult.getPname()); | |
100 | + lymsPushIllnessMsg.setPcid(dataResult.getPcid()); | |
101 | + lymsPushIllnessMsg.setHname(dataResult.getHname()); | |
102 | + lymsPushIllnessMsg.setDname(dataResult.getDname()); | |
103 | + lymsPushIllnessMsg.setDtname(dataResult.getDtname()); | |
104 | + lymsPushIllnessMsg.setCode(dataResult.getCode()); | |
105 | + lymsPushIllnessMsg.setValue(dataResult.getValue()); | |
106 | + if(null!=dataResult.getMid()){//存在id是要更新推送记录,失败或慢性病第二次推送 | |
107 | + lymsPushIllnessMsg.setId(dataResult.getMid()); | |
108 | + lymsPushIllnessMsg.setPushType(0); | |
109 | + } | |
110 | + lymsPushIllnessMsgService.saveOrUpdate(lymsPushIllnessMsg); | |
111 | + }else { | |
112 | + log.info("推送者数据有空值,不予推送。>>>>>>"); | |
113 | + } | |
114 | + } catch (Exception e) { | |
115 | + e.printStackTrace(); | |
116 | + } | |
117 | + } | |
50 | 118 | |
51 | 119 | } |
52 | 120 |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeTask.java
View file @
25ae910
... | ... | @@ -4,7 +4,10 @@ |
4 | 4 | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
5 | 5 | import com.lyms.talkonlineweb.domain.*; |
6 | 6 | import com.lyms.talkonlineweb.service.*; |
7 | +import com.lyms.talkonlineweb.util.Constant; | |
7 | 8 | import com.lyms.talkonlineweb.util.DateUtil; |
9 | +import com.lyms.talkonlineweb.util.StringUtil; | |
10 | +import com.lyms.talkonlineweb.util.WeiXinUtil; | |
8 | 11 | import lombok.extern.log4j.Log4j2; |
9 | 12 | import org.springframework.beans.BeanUtils; |
10 | 13 | import org.springframework.beans.BeansException; |
... | ... | @@ -31,25 +34,7 @@ |
31 | 34 | public class PushIllnessTypeTask { |
32 | 35 | |
33 | 36 | @Autowired |
34 | - private LymsArticleService lymsArticleService; | |
35 | - @Autowired | |
36 | - private PatientInfoService patientInfoService; | |
37 | - @Autowired | |
38 | - private LymsPushedartService lymsPushedartService;//推送的历史记录 | |
39 | - @Autowired | |
40 | - private PushArticleService pushArticleService;//推送文章新逻辑shiy改 | |
41 | - @Autowired | |
42 | - LymsPushMessagesService lymsPushMessagesService; | |
43 | - @Autowired | |
44 | - private LymsDictService lymsDictService; | |
45 | - @Autowired | |
46 | - public PushArticleTask pushArticleTask; | |
47 | - @Autowired | |
48 | - public LymsPushAttentionRecordService lymsPushAttentionRecordService; | |
49 | - @Autowired | |
50 | - private LymsPatientAttentionService lymsPatientAttentionService; | |
51 | - @Autowired | |
52 | - private LymsPatientService lymsPatientService;//患者 | |
37 | + private LymsPushIllnessMsgService lymsPushIllnessMsgService; | |
53 | 38 | |
54 | 39 | |
55 | 40 | |
56 | 41 | |
57 | 42 | |
58 | 43 | |
... | ... | @@ -57,10 +42,58 @@ |
57 | 42 | * 每天下18:30点执行-要推送的公众号信息 |
58 | 43 | */ |
59 | 44 | // @Scheduled(cron = "0 30 18 * * ?") |
60 | - @Transactional(rollbackFor = Exception.class) | |
61 | 45 | public void PushIllnessTypeTask(){ |
46 | + Map param=new HashMap<>(); | |
47 | + param.put("push_type", 0); | |
48 | + final List<LymsPushIllnessMsg> list = lymsPushIllnessMsgService.listByMap(param); | |
49 | + if(CollectionUtils.isEmpty(list)){ | |
50 | + log.info("没有要推送的文章。>>>>>>"); | |
51 | + return; | |
52 | + } | |
53 | + for (LymsPushIllnessMsg lymsPushIllnessMsg : list) { | |
54 | + try { | |
55 | + //推送微信公众号消息 | |
56 | + Map<String,Object> map=new HashMap<>(); | |
57 | + map.put("first",new DataEntity(lymsPushIllnessMsg.getContent(),"#173177")); | |
58 | + map.put("keyword1",new DataEntity(lymsPushIllnessMsg.getPname(),"#173177")); | |
59 | + map.put("keyword2",new DataEntity(lymsPushIllnessMsg.getHname(),"#173177")); | |
60 | + map.put("keyword3",new DataEntity(lymsPushIllnessMsg.getDname(),"#173177")); | |
61 | + map.put("keyword4",new DataEntity(lymsPushIllnessMsg.getDtname(),"#173177")); | |
62 | + map.put("keyword5",new DataEntity(lymsPushIllnessMsg.getValue(),"#173177")); | |
63 | + String illnessType="疾病种类"; | |
64 | + if(null!=lymsPushIllnessMsg.getIllnessType()){ | |
65 | + illnessType=(1==lymsPushIllnessMsg.getIllnessType()?"普通疾病":"慢性病"); | |
66 | + } | |
67 | + map.put("remark",new DataEntity(illnessType+",请遵医嘱及时复诊。","#173177")); | |
68 | + Map<String,Object> mapInfo=new HashMap<>(); | |
69 | + map.put("plogin", StringUtil.isEmpty(lymsPushIllnessMsg.getPhone())?"":lymsPushIllnessMsg.getPhone()); | |
70 | + map.put("passwd", StringUtil.isEmpty(lymsPushIllnessMsg.getPasswd())?"":lymsPushIllnessMsg.getPasswd()); | |
62 | 71 | |
72 | + Integer code= WeiXinUtil.SendWeChatMsg(lymsPushIllnessMsg.getGzopenid(), Constant.GZ_TEMPLATE_ID_RETURN_VISIT,map,mapInfo); | |
73 | + if(null==code||code!=0){ | |
74 | + //更新到 LymsPushIllnessMsg 记录 | |
75 | + lymsPushIllnessMsg.setPushType(2);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) | |
76 | + lymsPushIllnessMsg.setPushResult("推送消息"+illnessType+"失败。。。"+lymsPushIllnessMsg.getPname()+"; code:"+code); | |
77 | + lymsPushIllnessMsg.setPushTime(new Date()); | |
78 | + log.info("推送失败!"+lymsPushIllnessMsg.getPname()+"; code:"+code); | |
79 | + }else { | |
80 | + //更新到 LymsPushIllnessMsg 记录 | |
81 | + lymsPushIllnessMsg.setPushType(1);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) | |
82 | + lymsPushIllnessMsg.setPushResult(lymsPushIllnessMsg.getPname()+"推送消息"+illnessType+"成功。"); | |
83 | + lymsPushIllnessMsg.setPushTime(new Date()); | |
84 | + } | |
85 | + lymsPushIllnessMsgService.updateById(lymsPushIllnessMsg); | |
86 | + } catch (Exception e) { | |
87 | + //出现未知错误也要把需要推送的信息置为失败。保证第二天还可以继续推送。因为构造数据时用0判断的。 | |
88 | + lymsPushIllnessMsg.setPushType(2);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) | |
89 | + lymsPushIllnessMsg.setPushResult("推送消息失败。。。"+lymsPushIllnessMsg.getPname()+"; error:"+e.getMessage()); | |
90 | + lymsPushIllnessMsg.setPushTime(new Date()); | |
91 | + lymsPushIllnessMsgService.updateById(lymsPushIllnessMsg); | |
92 | + log.info(e.getMessage()); | |
93 | + e.printStackTrace(); | |
94 | + } | |
63 | 95 | |
96 | + } | |
64 | 97 | } |
65 | 98 | |
66 | 99 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java
View file @
25ae910
... | ... | @@ -46,9 +46,14 @@ |
46 | 46 | */ |
47 | 47 | public static final String WX_SECRET = "005ab68859ca2504b7217dac4c903cd2"; |
48 | 48 | /** |
49 | - * 公众号发送消息模板 | |
49 | + * 公众号发送消息模板-疾病文章短消息 | |
50 | 50 | */ |
51 | 51 | public static final String GZ_TEMPLATE_ID ="ZDxcRDJ3okC9Lbzpfhr_v4e8W1VWrho-f5uHW_VZHTg"; |
52 | + | |
53 | + /** | |
54 | + * 公众号发送消息模板-复诊提醒消息 | |
55 | + */ | |
56 | + public static final String GZ_TEMPLATE_ID_RETURN_VISIT =""; | |
52 | 57 | /** |
53 | 58 | * 公众号的appid |
54 | 59 | */ |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/DateUtil.java
View file @
25ae910
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | import java.text.DateFormat; |
6 | 6 | import java.text.ParsePosition; |
7 | 7 | import java.text.SimpleDateFormat; |
8 | +import java.util.Calendar; | |
8 | 9 | import java.util.Date; |
9 | 10 | import java.util.concurrent.ConcurrentHashMap; |
10 | 11 | import java.util.concurrent.locks.Lock; |
... | ... | @@ -28,6 +29,32 @@ |
28 | 29 | |
29 | 30 | public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; |
30 | 31 | public static final String YYYY_MM_DD = "yyyy-MM-dd"; |
32 | + public static SimpleDateFormat dd = new SimpleDateFormat("dd"); | |
33 | + public static SimpleDateFormat yyyy = new SimpleDateFormat("yyyy"); | |
34 | + public static SimpleDateFormat yyyyMM = new SimpleDateFormat("yyyyMM"); | |
35 | + public static SimpleDateFormat ymd = new SimpleDateFormat("yyyyMMdd"); | |
36 | + public static SimpleDateFormat y_m_d = new SimpleDateFormat("yyyy-MM-dd"); | |
37 | + public static SimpleDateFormat y_m = new SimpleDateFormat("yyyy年MM月"); | |
38 | + | |
39 | + public static SimpleDateFormat y_m_d1 = new SimpleDateFormat("yyyy年MM月dd日"); | |
40 | + public static SimpleDateFormat md = new SimpleDateFormat("MM-dd"); | |
41 | + public static SimpleDateFormat m_d = new SimpleDateFormat("MM/dd"); | |
42 | + public static SimpleDateFormat y_m_d_h_m_s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
43 | + public static SimpleDateFormat y_m_d_h_m1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
44 | + public static SimpleDateFormat y_m_d_h = new SimpleDateFormat("yyyy-MM-dd HH"); | |
45 | + public static String[] parsePatterns = {"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", | |
46 | + "yyyy/MM/dd HH:mm"}; | |
47 | + | |
48 | + public static SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyyMMddHH:mm:ss"); | |
49 | + | |
50 | + public static SimpleDateFormat yyyy_mm = new SimpleDateFormat("yyyy-MM"); | |
51 | + | |
52 | + public static SimpleDateFormat y_m_d_h_m = new SimpleDateFormat("yyyyyMMddHHmm"); | |
53 | + public static SimpleDateFormat yyyyMMddHHmmssSSS = new SimpleDateFormat("yyyyMMddHHmmssSSS"); | |
54 | + public static final int DAY_SECONDS = 86399; | |
55 | + public static final int DAY_FULL_SECONDS = 86400; | |
56 | + | |
57 | + | |
31 | 58 | /** |
32 | 59 | * 私有构造方法,禁止对该类进行实例化 |
33 | 60 | */ |
... | ... | @@ -77,5 +104,37 @@ |
77 | 104 | return fm.format(new Date()); |
78 | 105 | } |
79 | 106 | |
107 | + /** | |
108 | + * 时分秒清 yyyy-MM-dd 00:00:00 | |
109 | + * @param date | |
110 | + * @return | |
111 | + */ | |
112 | + public static Date getYmdDate(Date date) { | |
113 | + try { | |
114 | + date.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(y_m_d.format(date)).getTime()); | |
115 | + } catch (Exception e) { | |
116 | + e.printStackTrace(); | |
117 | + } | |
118 | + return date; | |
119 | + } | |
120 | + | |
121 | + /** | |
122 | + * 传入时间,增加天数 | |
123 | + * @param srcDate | |
124 | + * @param days | |
125 | + * @return | |
126 | + */ | |
127 | + public static Date addDay(Date srcDate, int days) { | |
128 | + lock.lock(); | |
129 | + try { | |
130 | + | |
131 | + Calendar rightNow = Calendar.getInstance(); | |
132 | + rightNow.setTime(srcDate); | |
133 | + rightNow.add(Calendar.DAY_OF_YEAR, days); | |
134 | + return rightNow.getTime(); | |
135 | + } finally { | |
136 | + lock.unlock(); | |
137 | + } | |
138 | + } | |
80 | 139 | } |
talkonlineweb/src/main/resources/application-dev.yml
View file @
25ae910
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | datasource: |
5 | 5 | driver-class-name: com.p6spy.engine.spy.P6SpyDriver |
6 | 6 | url: jdbc:p6spy:mysql://119.90.57.26:3307/talkonline?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 |
7 | +# url: jdbc:p6spy:mysql://119.90.43.68:3308/talkonline?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 | |
7 | 8 | username: platform |
8 | 9 | password: Platform@123 |
9 | 10 | uploadPath: /data/talkonline/upload/ |
... | ... | @@ -35,4 +36,18 @@ |
35 | 36 | |
36 | 37 | proxyIP: |
37 | 38 | proxyPort: |
39 | + | |
40 | +#获取医院患者信息配置 | |
41 | +patient: | |
42 | + #医院接口地址(String) | |
43 | + url: https://rp-zk-api.healthbaby.com.cn:8094/his/zkfy/getZkfyPatientList | |
44 | + #需要预建医院获得医院名称(String) | |
45 | + hospitalName: 石家庄第一医院 | |
46 | + #需要预建医院获得id(Integer) | |
47 | + hospital: 11 | |
48 | + | |
49 | +#微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突) | |
50 | +getAccessToken: | |
51 | + #on/off 会转义boolean | |
52 | + on_off: off |
talkonlineweb/src/main/resources/application-prod.yml
View file @
25ae910
talkonlineweb/src/main/resources/application.yml
View file @
25ae910
... | ... | @@ -16,13 +16,4 @@ |
16 | 16 | config: classpath:logback-spring.xml |
17 | 17 | |
18 | 18 | excludePath: login,test1,test2 |
19 | - | |
20 | -#获取医院患者信息配置 | |
21 | -patient: | |
22 | - #医院接口地址(String) | |
23 | - url: https://rp-zk-api.healthbaby.com.cn:8094/his/zkfy/getZkfyPatientList | |
24 | - #需要预建医院获得医院名称(String) | |
25 | - hospitalName: 石家庄第一医院 | |
26 | - #需要预建医院获得id(Integer) | |
27 | - hospital: 11 |
talkonlineweb/src/main/resources/mapper/LymsPushIllnessMsgMapper.xml
View file @
25ae910
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE mapper | |
3 | + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
4 | + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
5 | +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsPushIllnessMsgMapper"> | |
6 | + | |
7 | + <select id="getPatientIllenssType" resultType="com.lyms.talkonlineweb.result.PushIllnessTypeDataResult"> | |
8 | + SELECT | |
9 | + p.id, | |
10 | + IF | |
11 | + ( p.enrolment_phone IS NULL, pc.mobile, p.enrolment_phone ) AS phone, | |
12 | + p.ppasswd AS passwd, | |
13 | + p.gzopenid AS gzopenid, | |
14 | + p.pname, | |
15 | + pc.pcid, | |
16 | + pc.hname, | |
17 | + pc.dname, | |
18 | + pc.dtname, | |
19 | + d.`code`, | |
20 | + d.`value`, | |
21 | + d.illness_type AS illnessType, | |
22 | + m.illness_type AS pushIllness, | |
23 | + m.push_count AS pushCount, | |
24 | + m.push_type AS pushType, | |
25 | + pc.createdtime AS createdtime, | |
26 | + m.id AS mid | |
27 | + FROM | |
28 | + lyms_patient p | |
29 | + LEFT JOIN lyms_pcase pc ON pc.pid = p.id | |
30 | + LEFT JOIN lyms_illness i ON i.pcid = pc.pcid | |
31 | + LEFT JOIN lyms_dict d ON d.`code` = i.iid | |
32 | + AND d.vtype = 3 | |
33 | + LEFT JOIN lyms_push_illness_msg m ON m.pcid = pc.pcid | |
34 | + WHERE | |
35 | + d.illness_type IS NOT NULL | |
36 | + AND | |
37 | + IF | |
38 | + ( | |
39 | + ( m.illness_type = 2 AND m.push_type = 1 AND m.push_count = 2 ) | |
40 | + OR ( m.illness_type = 1 AND m.push_type = 1 ), | |
41 | + m.pcid IS NULL, | |
42 | + 1 = 1 | |
43 | + ) | |
44 | + GROUP BY | |
45 | + id, | |
46 | + pcid | |
47 | + ORDER BY | |
48 | + id | |
49 | + </select> | |
50 | +</mapper> |