From 25ae910c061426cef06e582b5dc344b2a1f4b7a0 Mon Sep 17 00:00:00 2001 From: shiyang <316555390@qq.com> Date: Thu, 21 Apr 2022 15:28:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E8=8E=B7=E5=8F=96ac?= =?UTF-8?q?cess=5Ftoken=20=E6=94=BE=E5=85=A5=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E3=80=82=20=E7=96=BE=E7=97=85=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=8E=A8=E9=80=81=20=E6=85=A2=E6=80=A7=E7=97=85?= =?UTF-8?q?=EF=BC=9A=E7=A1=AE=E8=AF=8A=E5=90=8E=E7=AC=AC30=E5=A4=A9?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E4=B8=80=E6=AC=A1=EF=BC=8C=E9=97=B4=E9=9A=94?= =?UTF-8?q?90=E5=A4=A9=E8=BF=9B=E8=A1=8C=E7=AC=AC=E4=BA=8C=E6=AC=A1?= =?UTF-8?q?=E6=8E=A8=E9=80=81=20=E6=99=AE=E9=80=9A=E7=96=BE=E7=97=85?= =?UTF-8?q?=EF=BC=9A=E7=A1=AE=E8=AF=8A15=E5=A4=A9=E5=90=8E=20=E6=8E=A8?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LymsHisInfoController.java | 2 +- .../talkonlineweb/controller/TestController.java | 19 +++- .../mapper/LymsPushIllnessMsgMapper.java | 21 ++++ .../result/PushIllnessTypeDataResult.java | 79 +++++++++++++++ .../service/LymsPushIllnessMsgService.java | 15 +++ .../impl/LymsPushIllnessMsgServiceImpl.java | 31 ++++++ .../talkonlineweb/task/AccessTokenServlet.java | 21 ++-- .../talkonlineweb/task/PushIllnessTypeData.java | 108 +++++++++++++++++---- .../talkonlineweb/task/PushIllnessTypeTask.java | 73 ++++++++++---- .../java/com/lyms/talkonlineweb/util/Constant.java | 7 +- .../java/com/lyms/talkonlineweb/util/DateUtil.java | 59 +++++++++++ .../src/main/resources/application-dev.yml | 17 +++- .../src/main/resources/application-prod.yml | 6 +- talkonlineweb/src/main/resources/application.yml | 9 -- .../resources/mapper/LymsPushIllnessMsgMapper.xml | 50 ++++++++++ 15 files changed, 455 insertions(+), 62 deletions(-) create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushIllnessMsgMapper.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushIllnessTypeDataResult.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushIllnessMsgService.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushIllnessMsgServiceImpl.java create mode 100644 talkonlineweb/src/main/resources/mapper/LymsPushIllnessMsgMapper.xml diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java index b377a83..b1e1813 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java @@ -50,7 +50,7 @@ public class LymsHisInfoController { if(StringUtil.isNotEmpty(hisInfo.getHospitalId())) { query.eq("hospitalId", hisInfo.getHospitalId()); } - query.orderByDesc("createdtime"); + query.orderByDesc("created"); if(null!=hisInfo.getUpType()){ query.eq("up_type", hisInfo.getUpType()); } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TestController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TestController.java index 1d692cf..772b476 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TestController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TestController.java @@ -5,9 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.lyms.talkonlineweb.annotation.TokenRequired; import com.lyms.talkonlineweb.domain.LymsPcase; import com.lyms.talkonlineweb.service.LymsPcaseService; -import com.lyms.talkonlineweb.task.GetPatientInfoTask; -import com.lyms.talkonlineweb.task.PushArticleTask; -import com.lyms.talkonlineweb.task.PushArticleTaskData; +import com.lyms.talkonlineweb.task.*; import lombok.extern.java.Log; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -28,6 +26,10 @@ public class TestController { public GetPatientInfoTask getPatientInfoTask; @Autowired private LymsPcaseService lymsPcaseService;//病例 + @Autowired + private PushIllnessTypeData pushIllnessTypeData; + @Autowired + private PushIllnessTypeTask pushIllnessTypeTask; @GetMapping("test") @TokenRequired @@ -47,6 +49,17 @@ public class TestController { pushArticleTaskData.pushArtcleData(); } + @GetMapping("test1") + @TokenRequired + public void test1() { + pushIllnessTypeData.PushIllnessTypeData(); + } + @GetMapping("test2") + @TokenRequired + public void test2() { + pushIllnessTypeTask.PushIllnessTypeTask(); + } + // @Autowired // private LymsUserService lymsUserService; diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushIllnessMsgMapper.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushIllnessMsgMapper.java new file mode 100644 index 0000000..299c27a --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushIllnessMsgMapper.java @@ -0,0 +1,21 @@ +package com.lyms.talkonlineweb.mapper; + +import com.lyms.talkonlineweb.domain.LymsPushIllnessMsg; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.lyms.talkonlineweb.result.PushIllnessTypeDataResult; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @Entity com.lyms.talkonlineweb.domain.LymsPushIllnessMsg + */ +@Mapper +public interface LymsPushIllnessMsgMapper extends BaseMapper { + + List getPatientIllenssType(); +} + + + + diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushIllnessTypeDataResult.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushIllnessTypeDataResult.java new file mode 100644 index 0000000..4afa7b4 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushIllnessTypeDataResult.java @@ -0,0 +1,79 @@ +package com.lyms.talkonlineweb.result; + +import lombok.Data; + +import java.util.Date; + +@Data +public class PushIllnessTypeDataResult { + /** + * 患者id + */ + private Integer id; + /** + * 患者手机号/患者小程序登录账号 + */ + private String phone; + /** + * 患者小程序登录密码 + */ + private String passwd; + /** + * 患者公众号id + */ + private String gzopenid; + /** + * 患者姓名 + */ + private String pname; + /** + * 患者病例id + */ + private Integer pcid; + /** + * 就诊医院 + */ + private String hname; + /** + * 就诊科室 + */ + private String dname; + /** + * 就诊医生 + */ + private String dtname; + /** + * 患者疾病id + */ + private Integer code; + /** + * 患者疾病名称 + */ + private String value; + /** + * 患者疾病分类 1普通疾病,2慢性病 + */ + private Integer illnessType; + /** + * 已推送的患者疾病 1普通疾病,2慢性病 + */ + private Integer pushIllness; + /** + * 已推送的 次数 + * 疾病分类推送数据:慢性疾病 确诊后30天推送一次(1),间隔90天进行第二次推送(2)。普通疾病:确诊15天后 推送(1)。 + */ + private Integer pushCount; + /** + * 已推送的结果 + * 推送状态:0待推送。1:成功,2 失败', + */ + private Integer pushType; + /** + * 病例创建时间(用于 推送周期) + */ + private Date createdtime; + /** + * 推送记录id(用于更新推送记录) + */ + private Integer mid; +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushIllnessMsgService.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushIllnessMsgService.java new file mode 100644 index 0000000..f62a25b --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushIllnessMsgService.java @@ -0,0 +1,15 @@ +package com.lyms.talkonlineweb.service; + +import com.lyms.talkonlineweb.domain.LymsPushIllnessMsg; +import com.baomidou.mybatisplus.extension.service.IService; +import com.lyms.talkonlineweb.result.PushIllnessTypeDataResult; + +import java.util.List; + +/** + * + */ +public interface LymsPushIllnessMsgService extends IService { + + List getPatientIllenssType(); +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushIllnessMsgServiceImpl.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushIllnessMsgServiceImpl.java new file mode 100644 index 0000000..0888e55 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushIllnessMsgServiceImpl.java @@ -0,0 +1,31 @@ +package com.lyms.talkonlineweb.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.lyms.talkonlineweb.domain.LymsPushIllnessMsg; +import com.lyms.talkonlineweb.mapper.LymsPatientMapper; +import com.lyms.talkonlineweb.result.PushIllnessTypeDataResult; +import com.lyms.talkonlineweb.service.LymsPushIllnessMsgService; +import com.lyms.talkonlineweb.mapper.LymsPushIllnessMsgMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service +public class LymsPushIllnessMsgServiceImpl extends ServiceImpl + implements LymsPushIllnessMsgService{ + @Autowired + private LymsPushIllnessMsgMapper lymsPushIllnessMsgMapper; + + @Override + public List getPatientIllenssType() { + return lymsPushIllnessMsgMapper.getPatientIllenssType(); + } +} + + + + diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AccessTokenServlet.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AccessTokenServlet.java index d30cd12..8547851 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AccessTokenServlet.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AccessTokenServlet.java @@ -2,9 +2,10 @@ package com.lyms.talkonlineweb.task; import com.alibaba.fastjson.JSONObject; import com.lyms.talkonlineweb.util.Constant; -import com.lyms.talkonlineweb.util.HttpUtil; import com.lyms.talkonlineweb.util.StringUtil; import com.lyms.talkonlineweb.util.WeiXinUtil; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; @@ -17,16 +18,24 @@ import javax.servlet.http.HttpServlet; * (微信公众号规定2小时token失效,每天只能获取2000次。) */ @Component +@Log4j2 public class AccessTokenServlet extends HttpServlet implements Runnable { + @Value("${getAccessToken.on_off}") + public boolean on_off;//配置yml 微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突) + public static String accessToken = null; /** * 启动后开启线程每5分钟获取一次token * @throws ServletException */ -// @PostConstruct//部署时开启注释,启动线程(测试环境部署不要开启。会与线上环境冲突) + @PostConstruct//部署时开启注释,启动线程(测试环境部署不要开启。会与线上环境冲突) public void init() throws ServletException { - new Thread(new AccessTokenServlet()).start(); //启动线程 + if(on_off){ + new Thread(new AccessTokenServlet()).start(); //启动线程 + }else { + log.info("测试环境不予获取access_token"); + } } public void run(){ while (true){ @@ -38,7 +47,7 @@ public class AccessTokenServlet extends HttpServlet implements Runnable { Thread.sleep(1000 * 3); //获取的access_token为空 休眠3秒 } }catch(Exception e){ - System.out.println("发生异常:"+e.getMessage()); + log.info("发生异常:"+e.getMessage()); e.printStackTrace(); try{ Thread.sleep(1000 * 10); //发生异常休眠1秒 @@ -62,12 +71,12 @@ public class AccessTokenServlet extends HttpServlet implements Runnable { + "&secret=" + Constant.GZ_SECRET; String tokenJsonStr = WeiXinUtil.repeatDoGetPost(getTokenApi, "GET", null); if(StringUtil.isEmpty(tokenJsonStr)){ - System.out.println("获取TOKEN :失败,repeatDoGetPost返回值为空>>>>>>>"); + log.info("获取TOKEN :失败,repeatDoGetPost返回值为空>>>>>>>"); return null; } JSONObject tokenJson = JSONObject.parseObject(tokenJsonStr); String token = tokenJson.get("access_token").toString(); - System.out.println("获取到的TOKEN : " + token); + log.info("获取到的TOKEN : " + token); return token; } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeData.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeData.java index b7d7438..2e4cbba 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeData.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeData.java @@ -1,12 +1,23 @@ package com.lyms.talkonlineweb.task; +import com.baomidou.mybatisplus.core.conditions.query.Query; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.lyms.talkonlineweb.domain.LymsPushIllnessMsg; +import com.lyms.talkonlineweb.domain.LymsPushMessages; +import com.lyms.talkonlineweb.result.PushIllnessTypeDataResult; import com.lyms.talkonlineweb.service.*; +import com.lyms.talkonlineweb.util.DateUtil; +import com.lyms.talkonlineweb.util.StringUtil; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.scheduling.annotation.Scheduled; +import java.util.*; + /** * 疾病分类推送数据整理(1普通疾病,2慢性病) * 慢性病:确诊后第一个月推送一次,间隔3个月进行第二次推送 @@ -18,25 +29,7 @@ import org.springframework.scheduling.annotation.Scheduled; public class PushIllnessTypeData { @Autowired - private LymsArticleService lymsArticleService; - @Autowired - private PatientInfoService patientInfoService; - @Autowired - private LymsPushedartService lymsPushedartService;//推送的历史记录 - @Autowired - private PushArticleService pushArticleService;//推送文章新逻辑shiy改 - @Autowired - LymsPushMessagesService lymsPushMessagesService; - @Autowired - private LymsDictService lymsDictService; - @Autowired - public PushArticleTask pushArticleTask; - @Autowired - public LymsPushAttentionRecordService lymsPushAttentionRecordService; - @Autowired - private LymsPatientAttentionService lymsPatientAttentionService; - @Autowired - private LymsPatientService lymsPatientService;//患者 + private LymsPushIllnessMsgService lymsPushIllnessMsgService; @@ -44,9 +37,84 @@ public class PushIllnessTypeData { * 每天00:00点执行-要推送的公众号信息数据整理 */ // @Scheduled(cron = "0 0 0 * * ?") - @Transactional(rollbackFor = Exception.class) public void PushIllnessTypeData(){ + Map param=new HashMap<>(); + param.put("push_type", 0); + final List list = lymsPushIllnessMsgService.listByMap(param); + if(CollectionUtils.isNotEmpty(list)){ + log.info("要推送的文章已存在不需要再次推送>>>>>>"); + return; + } + List result= lymsPushIllnessMsgService.getPatientIllenssType(); + for (PushIllnessTypeDataResult dataResult : result) { + LymsPushIllnessMsg lymsPushIllnessMsg = new LymsPushIllnessMsg(); + try { + if(null!=dataResult.getCreatedtime() && StringUtil.isNotEmpty(dataResult.getGzopenid()) && + StringUtil.isNotEmpty(dataResult.getPhone()) && StringUtil.isNotEmpty(dataResult.getPasswd())) { + + long newDate = DateUtil.getYmdDate(new Date()).getTime(); + long illenssDate_15 = DateUtil.addDay(DateUtil.getYmdDate(dataResult.getCreatedtime()), 15).getTime(); + long illenssDate_30 = DateUtil.addDay(DateUtil.getYmdDate(dataResult.getCreatedtime()), 30).getTime(); + long illenssDate_120 = DateUtil.addDay(DateUtil.getYmdDate(dataResult.getCreatedtime()), 120).getTime(); + + //普通疾病 + if (1== dataResult.getIllnessType() ) { + if(null==dataResult.getPushType()) { + if (newDate >= illenssDate_15) { + continue; + } + } + lymsPushIllnessMsg.setIllnessType(1); + String text = "患者接受治疗疾病症状应逐渐消退,症状减轻后药量需要减少,及时来医院复诊可以让医生调整用药量," + + "如果患者出现症状加重的情况需及时来医院调整药物用量或更换药物种类。" + + "用药请按照医嘱进行,不要自行增加或减少药物用量,症状消失后可来院复诊检查是否需要用药维持"; + lymsPushIllnessMsg.setContent(text); + } + //慢性疾病 + if (2== dataResult.getIllnessType()) { + if(null==dataResult.getPushType()){ + if(newDate >= illenssDate_30){ + continue; + } + dataResult.setPushCount(1); + }else { + if(1==dataResult.getPushType()){ + if(newDate >= illenssDate_120){ + continue; + } + dataResult.setPushCount(2); + } + } + lymsPushIllnessMsg.setIllnessType(2); + lymsPushIllnessMsg.setPushCount(dataResult.getPushCount()); + String text="患者出院后疾病症状应逐渐减轻,如果患者出现症状加重或症状反复,需立即前往医院就诊。" + + "用药请按医嘱服用药物,不要自行增添或减少药物用量,中间不要停药,药物不足时可自行来医院复诊取药。"; + lymsPushIllnessMsg.setContent(text); + } + lymsPushIllnessMsg.setPid(dataResult.getId()); + lymsPushIllnessMsg.setPhone(dataResult.getPhone()); + lymsPushIllnessMsg.setPasswd(dataResult.getPasswd()); + lymsPushIllnessMsg.setGzopenid(dataResult.getGzopenid()); + lymsPushIllnessMsg.setPname(dataResult.getPname()); + lymsPushIllnessMsg.setPcid(dataResult.getPcid()); + lymsPushIllnessMsg.setHname(dataResult.getHname()); + lymsPushIllnessMsg.setDname(dataResult.getDname()); + lymsPushIllnessMsg.setDtname(dataResult.getDtname()); + lymsPushIllnessMsg.setCode(dataResult.getCode()); + lymsPushIllnessMsg.setValue(dataResult.getValue()); + if(null!=dataResult.getMid()){//存在id是要更新推送记录,失败或慢性病第二次推送 + lymsPushIllnessMsg.setId(dataResult.getMid()); + lymsPushIllnessMsg.setPushType(0); + } + lymsPushIllnessMsgService.saveOrUpdate(lymsPushIllnessMsg); + }else { + log.info("推送者数据有空值,不予推送。>>>>>>"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeTask.java index c455805..b392d7b 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeTask.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushIllnessTypeTask.java @@ -4,7 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.lyms.talkonlineweb.domain.*; import com.lyms.talkonlineweb.service.*; +import com.lyms.talkonlineweb.util.Constant; import com.lyms.talkonlineweb.util.DateUtil; +import com.lyms.talkonlineweb.util.StringUtil; +import com.lyms.talkonlineweb.util.WeiXinUtil; import lombok.extern.log4j.Log4j2; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; @@ -31,25 +34,7 @@ import static com.lyms.talkonlineweb.util.DateUtil.YYYY_MM_DD; public class PushIllnessTypeTask { @Autowired - private LymsArticleService lymsArticleService; - @Autowired - private PatientInfoService patientInfoService; - @Autowired - private LymsPushedartService lymsPushedartService;//推送的历史记录 - @Autowired - private PushArticleService pushArticleService;//推送文章新逻辑shiy改 - @Autowired - LymsPushMessagesService lymsPushMessagesService; - @Autowired - private LymsDictService lymsDictService; - @Autowired - public PushArticleTask pushArticleTask; - @Autowired - public LymsPushAttentionRecordService lymsPushAttentionRecordService; - @Autowired - private LymsPatientAttentionService lymsPatientAttentionService; - @Autowired - private LymsPatientService lymsPatientService;//患者 + private LymsPushIllnessMsgService lymsPushIllnessMsgService; @@ -57,10 +42,58 @@ public class PushIllnessTypeTask { * 每天下18:30点执行-要推送的公众号信息 */ // @Scheduled(cron = "0 30 18 * * ?") - @Transactional(rollbackFor = Exception.class) public void PushIllnessTypeTask(){ + Map param=new HashMap<>(); + param.put("push_type", 0); + final List list = lymsPushIllnessMsgService.listByMap(param); + if(CollectionUtils.isEmpty(list)){ + log.info("没有要推送的文章。>>>>>>"); + return; + } + for (LymsPushIllnessMsg lymsPushIllnessMsg : list) { + try { + //推送微信公众号消息 + Map map=new HashMap<>(); + map.put("first",new DataEntity(lymsPushIllnessMsg.getContent(),"#173177")); + map.put("keyword1",new DataEntity(lymsPushIllnessMsg.getPname(),"#173177")); + map.put("keyword2",new DataEntity(lymsPushIllnessMsg.getHname(),"#173177")); + map.put("keyword3",new DataEntity(lymsPushIllnessMsg.getDname(),"#173177")); + map.put("keyword4",new DataEntity(lymsPushIllnessMsg.getDtname(),"#173177")); + map.put("keyword5",new DataEntity(lymsPushIllnessMsg.getValue(),"#173177")); + String illnessType="疾病种类"; + if(null!=lymsPushIllnessMsg.getIllnessType()){ + illnessType=(1==lymsPushIllnessMsg.getIllnessType()?"普通疾病":"慢性病"); + } + map.put("remark",new DataEntity(illnessType+",请遵医嘱及时复诊。","#173177")); + Map mapInfo=new HashMap<>(); + map.put("plogin", StringUtil.isEmpty(lymsPushIllnessMsg.getPhone())?"":lymsPushIllnessMsg.getPhone()); + map.put("passwd", StringUtil.isEmpty(lymsPushIllnessMsg.getPasswd())?"":lymsPushIllnessMsg.getPasswd()); + Integer code= WeiXinUtil.SendWeChatMsg(lymsPushIllnessMsg.getGzopenid(), Constant.GZ_TEMPLATE_ID_RETURN_VISIT,map,mapInfo); + if(null==code||code!=0){ + //更新到 LymsPushIllnessMsg 记录 + lymsPushIllnessMsg.setPushType(2);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) + lymsPushIllnessMsg.setPushResult("推送消息"+illnessType+"失败。。。"+lymsPushIllnessMsg.getPname()+"; code:"+code); + lymsPushIllnessMsg.setPushTime(new Date()); + log.info("推送失败!"+lymsPushIllnessMsg.getPname()+"; code:"+code); + }else { + //更新到 LymsPushIllnessMsg 记录 + lymsPushIllnessMsg.setPushType(1);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) + lymsPushIllnessMsg.setPushResult(lymsPushIllnessMsg.getPname()+"推送消息"+illnessType+"成功。"); + lymsPushIllnessMsg.setPushTime(new Date()); + } + lymsPushIllnessMsgService.updateById(lymsPushIllnessMsg); + } catch (Exception e) { + //出现未知错误也要把需要推送的信息置为失败。保证第二天还可以继续推送。因为构造数据时用0判断的。 + lymsPushIllnessMsg.setPushType(2);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) + lymsPushIllnessMsg.setPushResult("推送消息失败。。。"+lymsPushIllnessMsg.getPname()+"; error:"+e.getMessage()); + lymsPushIllnessMsg.setPushTime(new Date()); + lymsPushIllnessMsgService.updateById(lymsPushIllnessMsg); + log.info(e.getMessage()); + e.printStackTrace(); + } + } } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java index ab28768..6e1fac4 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java @@ -46,9 +46,14 @@ public class Constant { */ public static final String WX_SECRET = "005ab68859ca2504b7217dac4c903cd2"; /** - * 公众号发送消息模板 + * 公众号发送消息模板-疾病文章短消息 */ public static final String GZ_TEMPLATE_ID ="ZDxcRDJ3okC9Lbzpfhr_v4e8W1VWrho-f5uHW_VZHTg"; + + /** + * 公众号发送消息模板-复诊提醒消息 + */ + public static final String GZ_TEMPLATE_ID_RETURN_VISIT =""; /** * 公众号的appid */ diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/DateUtil.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/DateUtil.java index 9316046..935838d 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/DateUtil.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/DateUtil.java @@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j; import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.Lock; @@ -28,6 +29,32 @@ public class DateUtil { public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; public static final String YYYY_MM_DD = "yyyy-MM-dd"; + public static SimpleDateFormat dd = new SimpleDateFormat("dd"); + public static SimpleDateFormat yyyy = new SimpleDateFormat("yyyy"); + public static SimpleDateFormat yyyyMM = new SimpleDateFormat("yyyyMM"); + public static SimpleDateFormat ymd = new SimpleDateFormat("yyyyMMdd"); + public static SimpleDateFormat y_m_d = new SimpleDateFormat("yyyy-MM-dd"); + public static SimpleDateFormat y_m = new SimpleDateFormat("yyyy年MM月"); + + public static SimpleDateFormat y_m_d1 = new SimpleDateFormat("yyyy年MM月dd日"); + public static SimpleDateFormat md = new SimpleDateFormat("MM-dd"); + public static SimpleDateFormat m_d = new SimpleDateFormat("MM/dd"); + public static SimpleDateFormat y_m_d_h_m_s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public static SimpleDateFormat y_m_d_h_m1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + public static SimpleDateFormat y_m_d_h = new SimpleDateFormat("yyyy-MM-dd HH"); + 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", + "yyyy/MM/dd HH:mm"}; + + public static SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyyMMddHH:mm:ss"); + + public static SimpleDateFormat yyyy_mm = new SimpleDateFormat("yyyy-MM"); + + public static SimpleDateFormat y_m_d_h_m = new SimpleDateFormat("yyyyyMMddHHmm"); + public static SimpleDateFormat yyyyMMddHHmmssSSS = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + public static final int DAY_SECONDS = 86399; + public static final int DAY_FULL_SECONDS = 86400; + + /** * 私有构造方法,禁止对该类进行实例化 */ @@ -77,4 +104,36 @@ public class DateUtil { return fm.format(new Date()); } + /** + * 时分秒清 yyyy-MM-dd 00:00:00 + * @param date + * @return + */ + public static Date getYmdDate(Date date) { + try { + date.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(y_m_d.format(date)).getTime()); + } catch (Exception e) { + e.printStackTrace(); + } + return date; + } + + /** + * 传入时间,增加天数 + * @param srcDate + * @param days + * @return + */ + public static Date addDay(Date srcDate, int days) { + lock.lock(); + try { + + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(srcDate); + rightNow.add(Calendar.DAY_OF_YEAR, days); + return rightNow.getTime(); + } finally { + lock.unlock(); + } + } } diff --git a/talkonlineweb/src/main/resources/application-dev.yml b/talkonlineweb/src/main/resources/application-dev.yml index 881fbec..477e5c6 100644 --- a/talkonlineweb/src/main/resources/application-dev.yml +++ b/talkonlineweb/src/main/resources/application-dev.yml @@ -4,6 +4,7 @@ spring: datasource: driver-class-name: com.p6spy.engine.spy.P6SpyDriver url: jdbc:p6spy:mysql://119.90.57.26:3307/talkonline?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 +# url: jdbc:p6spy:mysql://119.90.43.68:3308/talkonline?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 username: platform password: Platform@123 uploadPath: /data/talkonline/upload/ @@ -34,4 +35,18 @@ hx.hxpasswd: passwd notify.url: https://dev-talk-api.healthbaby.com.cn/order/payNotify proxyIP: -proxyPort: \ No newline at end of file +proxyPort: + +#获取医院患者信息配置 +patient: + #医院接口地址(String) + url: https://rp-zk-api.healthbaby.com.cn:8094/his/zkfy/getZkfyPatientList + #需要预建医院获得医院名称(String) + hospitalName: 石家庄第一医院 + #需要预建医院获得id(Integer) + hospital: 11 + +#微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突) +getAccessToken: + #on/off 会转义boolean + on_off: off \ No newline at end of file diff --git a/talkonlineweb/src/main/resources/application-prod.yml b/talkonlineweb/src/main/resources/application-prod.yml index 083eff6..74c441f 100644 --- a/talkonlineweb/src/main/resources/application-prod.yml +++ b/talkonlineweb/src/main/resources/application-prod.yml @@ -40,4 +40,8 @@ patient: #需要预建医院获得医院名称(String) hospitalName: 周口市妇幼保健院 #需要预建医院获得id(Integer) - hospital: 16 \ No newline at end of file + hospital: 16 + +#微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突) +getAccessToken: + on_off: on \ No newline at end of file diff --git a/talkonlineweb/src/main/resources/application.yml b/talkonlineweb/src/main/resources/application.yml index da5b414..0d8f356 100644 --- a/talkonlineweb/src/main/resources/application.yml +++ b/talkonlineweb/src/main/resources/application.yml @@ -16,12 +16,3 @@ logging: config: classpath:logback-spring.xml excludePath: login,test1,test2 - -#获取医院患者信息配置 -patient: - #医院接口地址(String) - url: https://rp-zk-api.healthbaby.com.cn:8094/his/zkfy/getZkfyPatientList - #需要预建医院获得医院名称(String) - hospitalName: 石家庄第一医院 - #需要预建医院获得id(Integer) - hospital: 11 \ No newline at end of file diff --git a/talkonlineweb/src/main/resources/mapper/LymsPushIllnessMsgMapper.xml b/talkonlineweb/src/main/resources/mapper/LymsPushIllnessMsgMapper.xml new file mode 100644 index 0000000..126be1e --- /dev/null +++ b/talkonlineweb/src/main/resources/mapper/LymsPushIllnessMsgMapper.xml @@ -0,0 +1,50 @@ + + + + + + -- 1.8.3.1