Commit 4bd1a46c57ae290a8245ec5f2b0ebcd2a04a2f49

Authored by zhangchao
1 parent 9087b5efe7
Exists in dev

#fix 新增查询历史聊天记录接口、问诊卡推送服务接口

Showing 12 changed files with 252 additions and 17 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java View file @ 4bd1a46
... ... @@ -22,6 +22,7 @@
22 22 import lombok.extern.log4j.Log4j2;
23 23 import org.apache.commons.io.IOUtils;
24 24 import org.apache.commons.lang3.StringUtils;
  25 +import org.apache.poi.ss.formula.functions.T;
25 26 import org.springframework.beans.BeanUtils;
26 27 import org.springframework.beans.factory.annotation.Autowired;
27 28 import org.springframework.beans.factory.annotation.Value;
... ... @@ -185,6 +186,32 @@
185 186 message.setYn(1);
186 187 boolean f = lymsMessageService.saveOrUpdate(message);
187 188 baseResponse.setErrorcode(f == true ? 0 : 1);
  189 + return baseResponse;
  190 + }
  191 +
  192 + /**
  193 + * 查询聊天历史记录(本地)
  194 + * @param targetId 分组ID
  195 + * @param current
  196 + * @param size
  197 + * @return
  198 + */
  199 + @GetMapping("getHistoryLogs")
  200 + @TokenRequired
  201 + public BaseResponse getHistoryLogs(String targetId,Integer current, Integer size){
  202 +
  203 + if (StringUtil.isEmpty(targetId)){
  204 + BaseResponse.error("聊天组ID不能为空");
  205 + }
  206 + BaseResponse baseResponse = new BaseResponse();
  207 + Page<LymsMessage> page = new Page(current,size);
  208 + QueryWrapper<LymsMessage> query = new QueryWrapper();
  209 + query.eq("targetid",targetId);
  210 + query.orderByDesc("sendtime");
  211 + page=lymsMessageService.page(page,query);
  212 + baseResponse.setObject(page);
  213 + baseResponse.setErrorcode(0);
  214 + baseResponse.setErrormsg("成功");
188 215 return baseResponse;
189 216 }
190 217  
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsOrderMapper.java View file @ 4bd1a46
... ... @@ -5,6 +5,7 @@
5 5 import com.lyms.talkonlineweb.domain.LymsOrder;
6 6 import com.lyms.talkonlineweb.request.OrderRequest;
7 7 import com.lyms.talkonlineweb.result.OrderListResponse;
  8 +import com.lyms.talkonlineweb.result.PushOrderResult;
8 9 import org.apache.ibatis.annotations.Param;
9 10  
10 11 import java.util.List;
... ... @@ -24,5 +25,8 @@
24 25  
25 26 Page<OrderListResponse> queryOrderList(Page<OrderListResponse> page, @Param("orderRequest") OrderRequest orderRequest);
26 27  
  28 + List<PushOrderResult> selectPushOrder(@Param("pId") Integer pid);
  29 +
  30 + List<PushOrderResult> selectOrderTaskList(@Param("sevenStart")String sevenStart, @Param("sevenEnd")String sevenEnd, @Param("fourteenStart")String fourteenStart, @Param("fourteenEnd")String fourteenEnd);
27 31 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/param/DataEntity.java View file @ 4bd1a46
  1 +package com.lyms.talkonlineweb.param;
  2 +
  3 +import lombok.Data;
  4 +@Data
  5 +public class DataEntity {
  6 + //内容
  7 + private String value;
  8 + //字体颜色
  9 + private String color;
  10 +
  11 + public DataEntity(String value ,String color){
  12 + this.value = value;
  13 + this.color = color;
  14 + }
  15 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushOrderResult.java View file @ 4bd1a46
  1 +package com.lyms.talkonlineweb.result;
  2 +
  3 +import lombok.Data;
  4 +
  5 +@Data
  6 +public class PushOrderResult {
  7 + private Integer id;
  8 + private Integer pid;
  9 + private String gzopenid;
  10 + private String dname;
  11 + private String hname;
  12 + private String pname;
  13 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsOrderService.java View file @ 4bd1a46
... ... @@ -6,6 +6,7 @@
6 6 import com.lyms.talkonlineweb.domain.LymsOrder;
7 7 import com.lyms.talkonlineweb.request.OrderRequest;
8 8 import com.lyms.talkonlineweb.result.OrderListResponse;
  9 +import com.lyms.talkonlineweb.result.PushOrderResult;
9 10  
10 11 import java.util.List;
11 12  
... ... @@ -23,6 +24,10 @@
23 24 boolean handleOrder(LymsOrder lymsOrder,boolean isPayCallBack);
24 25  
25 26 List<OrderListResponse> queryOrderList(OrderRequest orderRequest);
  27 +
  28 + List<PushOrderResult> selectOrderTaskList(String sevenStart, String sevenEnd, String fourteenStart, String fourteenEnd);
  29 +
  30 + List<PushOrderResult> selectPushOrder(Integer pId);
26 31  
27 32 Page<OrderListResponse> queryOrderList(Page<OrderListResponse> page, OrderRequest orderRequest);
28 33 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsUserService.java View file @ 4bd1a46
... ... @@ -15,6 +15,7 @@
15 15 List<LymsPermission> getPermissionByUsername(String username) throws Exception;
16 16  
17 17 LymsUser getUserByToken(String token);
  18 + Map<String,Object> pLoginInfo(Integer pid)
18 19  
19 20 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsHisInfoServiceImpl.java View file @ 4bd1a46
... ... @@ -6,8 +6,10 @@
6 6 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 7 import com.lyms.talkonlineweb.domain.*;
8 8 import com.lyms.talkonlineweb.enums.ChargeWay;
  9 +import com.lyms.talkonlineweb.param.DataEntity;
9 10 import com.lyms.talkonlineweb.result.BaseResponse;
10 11 import com.lyms.talkonlineweb.result.Diagnose;
  12 +import com.lyms.talkonlineweb.result.PushOrderResult;
11 13 import com.lyms.talkonlineweb.service.*;
12 14 import com.lyms.talkonlineweb.mapper.LymsHisInfoMapper;
13 15 import com.lyms.talkonlineweb.util.Constant;
14 16  
15 17  
... ... @@ -15,15 +17,12 @@
15 17 import com.lyms.talkonlineweb.util.StringUtil;
16 18 import com.lyms.talkonlineweb.util.WeiXinUtil;
17 19 import lombok.extern.log4j.Log4j2;
18   -import org.apache.commons.lang3.StringUtils;
19 20 import org.springframework.beans.factory.annotation.Autowired;
20   -import org.springframework.beans.factory.annotation.Value;
21 21 import org.springframework.stereotype.Service;
22 22 import org.springframework.transaction.annotation.Transactional;
23 23 import org.springframework.util.DigestUtils;
24 24  
25 25 import java.util.*;
26   -import java.util.stream.Collectors;
27 26  
28 27 /**
29 28 *
... ... @@ -55,6 +54,8 @@
55 54  
56 55 @Autowired
57 56 private LymsOrderService lymsOrderService;
  57 + @Autowired
  58 + private LymsUserService lymsUserService;
58 59  
59 60  
60 61 @Override
... ... @@ -69,6 +70,50 @@
69 70 //这里想触发事务回滚需抛运行时异常
70 71 throw new Exception("更新HIS患者信息返回值失败状态!");
71 72 }
  73 + new Thread(new Runnable() {
  74 + @Override
  75 + public void run() {
  76 + LymsPatient patient =null;
  77 + String idCard = lymsHisInfo.getIdcard();
  78 + if (StringUtil.isEmpty(idCard)) {
  79 + QueryWrapper<LymsPatient> queryWrapper = new QueryWrapper<>();
  80 + queryWrapper.eq("pname",lymsHisInfo.getName());
  81 + queryWrapper.eq("enrolment_phone",lymsHisInfo.getPhone());
  82 + List<LymsPatient> list = lymsPatientService.list(queryWrapper);
  83 + if(CollectionUtils.isNotEmpty(list)){
  84 + patient=list.get(0);
  85 + }
  86 + }else {
  87 + //判断患者是否存在
  88 + LymsPatient patientQuery = new LymsPatient();
  89 + patientQuery.setIdno(idCard.toLowerCase());
  90 + patient = lymsPatientService.getOne(Wrappers.query(patientQuery));
  91 + }
  92 + if (patient!=null){
  93 + List<PushOrderResult> orderList= lymsOrderService.selectPushOrder(patient.getId());
  94 + if (CollectionUtils.isNotEmpty(orderList)){
  95 + orderList.stream().forEach(order -> {
  96 + //推送微信公众号
  97 + Map<String,Object> map=new HashMap<>();
  98 + map.put("keyword1",new DataEntity(order.getPname(),"#173177"));
  99 + map.put("keyword2",new DataEntity(order.getHname(),"#173177"));
  100 + map.put("keyword3",new DataEntity(order.getDname(),"#173177"));
  101 +
  102 + //公众号跳转小程序需要的登录信息
  103 + Map<String,Object> mapInfo =lymsUserService.pLoginInfo(order.getPid());
  104 + try {
  105 + Integer code= WeiXinUtil.SendWeChatMsg(order.getGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo);
  106 + log.info("SendWeChatMsg--->code, "+code);
  107 + } catch (Exception e) {
  108 + log.error("serviceContent Exception,"+e.getMessage());
  109 + }
  110 + });
  111 + }
  112 + }
  113 +
  114 + }
  115 + }).start();
  116 +
72 117 }
73 118 return result;
74 119 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsOrderServiceImpl.java View file @ 4bd1a46
... ... @@ -15,6 +15,7 @@
15 15 import com.lyms.talkonlineweb.mapper.LymsTcardMapper;
16 16 import com.lyms.talkonlineweb.request.OrderRequest;
17 17 import com.lyms.talkonlineweb.result.OrderListResponse;
  18 +import com.lyms.talkonlineweb.result.PushOrderResult;
18 19 import com.lyms.talkonlineweb.service.LymsAttentionService;
19 20 import com.lyms.talkonlineweb.service.LymsOrderService;
20 21 import com.lyms.talkonlineweb.service.LymsTcardService;
... ... @@ -114,6 +115,16 @@
114 115 @Override
115 116 public List<OrderListResponse> queryOrderList(OrderRequest orderRequest) {
116 117 return lymsOrderMapper.queryOrderList(orderRequest);
  118 + }
  119 +
  120 + @Override
  121 + public List<PushOrderResult> selectOrderTaskList(String sevenStart, String sevenEnd, String fourteenStart, String fourteenEnd) {
  122 + return lymsOrderMapper.selectOrderTaskList( sevenStart, sevenEnd, fourteenStart, fourteenEnd);
  123 + }
  124 +
  125 + @Override
  126 + public List<PushOrderResult> selectPushOrder(Integer pId) {
  127 + return lymsOrderMapper.selectPushOrder(pId);
117 128 }
118 129  
119 130 @Override
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsUserServiceImpl.java View file @ 4bd1a46
1 1 package com.lyms.talkonlineweb.service.impl;
2 2  
  3 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4   -import com.lyms.talkonlineweb.domain.LymsPermission;
5   -import com.lyms.talkonlineweb.domain.LymsRole;
6   -import com.lyms.talkonlineweb.domain.LymsUser;
  5 +import com.lyms.talkonlineweb.domain.*;
7 6 import com.lyms.talkonlineweb.mapper.LymsPermissionMapper;
8 7 import com.lyms.talkonlineweb.mapper.LymsRoleMapper;
  8 +import com.lyms.talkonlineweb.service.LymsPatientService;
9 9 import com.lyms.talkonlineweb.service.LymsUserService;
10 10 import com.lyms.talkonlineweb.mapper.LymsUserMapper;
  11 +import com.lyms.talkonlineweb.service.PatientInfoService;
11 12 import com.lyms.talkonlineweb.util.Constant;
12 13 import com.lyms.talkonlineweb.util.JwtUtils;
  14 +import com.lyms.talkonlineweb.util.StringUtil;
13 15 import io.jsonwebtoken.Claims;
14 16 import lombok.extern.log4j.Log4j2;
15 17 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -91,6 +93,29 @@
91 93 param.put("login",username);
92 94 List<LymsUser> uLst= lymsUserMapper.selectByMap(param);
93 95 return uLst.size()>0?uLst.get(0):null;
  96 + }
  97 +
  98 + @Autowired
  99 + private LymsPatientService lymsPatientService;
  100 + @Autowired
  101 + private PatientInfoService patientInfoService;
  102 + //用户登录id
  103 + public Map<String,Object> pLoginInfo(Integer pid){
  104 + //获取登录信息
  105 + Map<String,Object> map=new HashMap<>();
  106 + String plogin=null;
  107 + LymsPatient lymsPatient = lymsPatientService.getById(pid);
  108 + if(StringUtil.isNotEmpty(lymsPatient.getEnrolmentPhone())){
  109 + plogin=lymsPatient.getEnrolmentPhone();
  110 + }else {
  111 + List<PatientInfo> pLst=patientInfoService.list(new QueryWrapper<PatientInfo>().eq("id", lymsPatient.getId()));
  112 + if(com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(pLst)){
  113 + plogin=pLst.get(0).getMobile();
  114 + }
  115 + }
  116 + map.put("plogin", plogin);
  117 + map.put("passwd", lymsPatient.getPpasswd());
  118 + return map;
94 119 }
95 120  
96 121 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java View file @ 4bd1a46
... ... @@ -3,6 +3,7 @@
3 3 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
5 5 import com.lyms.talkonlineweb.domain.*;
  6 +import com.lyms.talkonlineweb.param.DataEntity;
6 7 import com.lyms.talkonlineweb.result.BaseResponse;
7 8 import com.lyms.talkonlineweb.service.*;
8 9 import com.lyms.talkonlineweb.util.Constant;
... ... @@ -261,18 +262,5 @@
261 262 }
262 263 }
263 264  
264   -}
265   -
266   -@Data
267   -class DataEntity {
268   - //内容
269   - private String value;
270   - //字体颜色
271   - private String color;
272   -
273   - public DataEntity(String value ,String color){
274   - this.value = value;
275   - this.color = color;
276   - }
277 265 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/ServiceContentTask.java View file @ 4bd1a46
  1 +package com.lyms.talkonlineweb.task;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4 +import com.lyms.oss.utils.DateUtils;
  5 +import com.lyms.talkonlineweb.domain.LymsMessage;
  6 +import com.lyms.talkonlineweb.domain.LymsOrder;
  7 +import com.lyms.talkonlineweb.domain.LymsPatient;
  8 +import com.lyms.talkonlineweb.domain.PatientInfo;
  9 +import com.lyms.talkonlineweb.param.DataEntity;
  10 +import com.lyms.talkonlineweb.result.PushOrderResult;
  11 +import com.lyms.talkonlineweb.service.LymsOrderService;
  12 +import com.lyms.talkonlineweb.service.LymsPatientService;
  13 +import com.lyms.talkonlineweb.service.LymsUserService;
  14 +import com.lyms.talkonlineweb.service.PatientInfoService;
  15 +import com.lyms.talkonlineweb.util.Constant;
  16 +import com.lyms.talkonlineweb.util.StringUtil;
  17 +import com.lyms.talkonlineweb.util.WeiXinUtil;
  18 +import lombok.extern.slf4j.Slf4j;
  19 +import org.apache.commons.collections.CollectionUtils;
  20 +import org.springframework.beans.factory.annotation.Autowired;
  21 +import org.springframework.beans.factory.annotation.ParameterResolutionDelegate;
  22 +import org.springframework.scheduling.annotation.Scheduled;
  23 +import org.springframework.stereotype.Component;
  24 +
  25 +import java.util.Date;
  26 +import java.util.HashMap;
  27 +import java.util.List;
  28 +import java.util.Map;
  29 +
  30 +@Component
  31 +@Slf4j
  32 +public class ServiceContentTask {
  33 +
  34 + @Autowired
  35 + private LymsOrderService lymsOrderService;
  36 + @Autowired
  37 + private LymsUserService lymsUserService;
  38 + /**
  39 + * 定时推送
  40 + * 公众号提醒(开通服务后第7天、开通服务后第14天)
  41 + */
  42 + @Scheduled(cron = "0 0 9 * * ?")
  43 + public void serviceContent(){
  44 + log.info("serviceContent startup");
  45 + Date day=new Date();
  46 + String seven= DateUtils.format(DateUtils.addDateDays(day,-7));
  47 + String fourteen= DateUtils.format(DateUtils.addDateDays(day,-14));
  48 + String startStr=" 00:00:00";
  49 + String endStr=" 23:59:59";
  50 + List<PushOrderResult> orderList= lymsOrderService.selectOrderTaskList(
  51 + seven+startStr,seven+endStr,fourteen+startStr,fourteen+endStr);
  52 + if (CollectionUtils.isNotEmpty(orderList)){
  53 + orderList.stream().forEach(order -> {
  54 + //推送微信公众号
  55 + Map<String,Object> map=new HashMap<>();
  56 + map.put("keyword1",new DataEntity(order.getPname(),"#173177"));
  57 + map.put("keyword2",new DataEntity(order.getHname(),"#173177"));
  58 + map.put("keyword3",new DataEntity(order.getDname(),"#173177"));
  59 +
  60 + //公众号跳转小程序需要的登录信息
  61 + Map<String,Object> mapInfo =lymsUserService.pLoginInfo(order.getPid());
  62 + try {
  63 + Integer code= WeiXinUtil.SendWeChatMsg(order.getGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo);
  64 + log.info("SendWeChatMsg--->code, "+code);
  65 + } catch (Exception e) {
  66 + log.error("serviceContent Exception,"+e.getMessage());
  67 + }
  68 + });
  69 + log.info("serviceContent end");
  70 + }
  71 + }
  72 +
  73 +}
talkonlineweb/src/main/resources/mapper/LymsOrderMapper.xml View file @ 4bd1a46
... ... @@ -70,5 +70,31 @@
70 70 order by o.pay_time desc
71 71  
72 72 </select>
  73 + <select id="selectOrderTaskList" resultType="com.lyms.talkonlineweb.result.PushOrderResult">
  74 + SELECT
  75 + o.id,o.pid,pc.dname,pc.hname,p.pname,p.gzopenid
  76 + FROM
  77 + `lyms_order` o
  78 + INNER JOIN lyms_patient p ON o.pid = p.id
  79 + INNER JOIN lyms_pcase pc on pc.pid =o.pid
  80 + WHERE
  81 + ((
  82 + <![CDATA[o.service_start_time >= #{sevenStart}
  83 + AND o.service_start_time <= #{sevenEnd})
  84 + or (o.service_start_time >= #{fourteenStart}
  85 + AND o.service_start_time <= #{fourteenEnd}))]]>
  86 + and `status`=1
  87 + </select>
  88 + <select id="selectPushOrder" resultType="com.lyms.talkonlineweb.result.PushOrderResult">
  89 + SELECT
  90 + o.id,o.pid,pc.dname,pc.hname,p.pname,p.gzopenid
  91 + FROM
  92 + `lyms_order` o
  93 + INNER JOIN lyms_patient p ON o.pid = p.id
  94 + INNER JOIN lyms_pcase pc on pc.pid =o.pid
  95 + WHERE
  96 + o.pid=#{pId}
  97 + and `status`=1
  98 + </select>
73 99 </mapper>