From 01054ed761beab7feabd4053e95f6c86cb95b533 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 18 Jan 2024 13:45:46 +0800 Subject: [PATCH] =?UTF-8?q?#fix=20=E6=96=B0=E5=A2=9E=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E3=80=81=E4=B8=80=E9=94=AE=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BC=98=E5=8C=96=E9=97=AE=E8=AF=8A?= =?UTF-8?q?=E5=8D=A1=E6=B6=88=E8=80=97=E7=9A=84bug=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ChatGroupController.java | 4 + .../controller/LymsHisInfoController.java | 17 +- .../controller/PatientController.java | 26 ++ .../controller/PushMessageController.java | 71 +++++ .../controller/TkRecordController.java | 3 + .../com/lyms/talkonlineweb/domain/LymsHisInfo.java | 7 +- .../lyms/talkonlineweb/domain/LymsPushMessage.java | 114 ++++++++ .../mapper/LymsPushMessageMapper.java | 7 + .../lyms/talkonlineweb/result/PushOrderResult.java | 6 + .../talkonlineweb/service/LymsHisInfoService.java | 2 + .../service/LymsPushMessageService.java | 7 + .../service/impl/LymsHisInfoServiceImpl.java | 294 ++++++++++++++------- .../service/impl/LymsPushMessageServiceImpl.java | 12 + .../task/HisPatientsAutoUploadTask.java | 21 +- .../talkonlineweb/task/ServiceContentTask.java | 53 ++-- .../java/com/lyms/talkonlineweb/util/Constant.java | 5 + .../src/main/resources/mapper/LymsOrderMapper.xml | 6 +- .../src/main/resources/mapper/LymsTcardMapper.xml | 11 +- 18 files changed, 538 insertions(+), 128 deletions(-) create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PushMessageController.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPushMessage.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushMessageMapper.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushMessageService.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPushMessageServiceImpl.java diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java index 5c42379..7dafea1 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java @@ -274,6 +274,10 @@ public class ChatGroupController { tkrecord.setId((Integer) tmpList.get(0).get("rid")); tkrecord.setStat(0); lymsTkrecordService.updateById(tkrecord); + if (chatgroup.getId()!=null){ + chatgroup.setStat(0); + lymsChatgroupService.updateById(chatgroup); + } tmpList.get(0).put("stat", 0); rs.put("sess", tmpList.get(0)); } 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 31425f8..c7c1e9e 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.lyms.talkonlineweb.annotation.Resubmit; import com.lyms.talkonlineweb.annotation.TokenRequired; import com.lyms.talkonlineweb.domain.LymsDict; import com.lyms.talkonlineweb.domain.LymsHisInfo; @@ -94,7 +95,21 @@ public class LymsHisInfoController { } return baseResponse; } - + /** + * 一键上传his患者信息 + * @param + * @return + */ + @PostMapping("upAllHisInfo") + @TokenRequired + @Resubmit + public BaseResponse upAllHisInfo(){ + BaseResponse baseResponse=new BaseResponse(); + baseResponse.setErrorcode(0); + baseResponse.setErrormsg("一键上传成功"); + lymsHisInfoService.upAllHisInfo(); + return baseResponse; + } /** * 修改his医院患者身份证号码 * @param hisInfo diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java index d908094..e8f5a4b 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.google.common.base.Strings; import com.lyms.talkonlineweb.annotation.TokenRequired; import com.lyms.talkonlineweb.domain.*; import com.lyms.talkonlineweb.request.PatientInfoRequest; @@ -20,6 +21,7 @@ import com.mysql.cj.Query; import lombok.extern.log4j.Log4j2; import org.apache.ibatis.annotations.Delete; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.util.DigestUtils; import org.springframework.util.StringUtils; import org.springframework.validation.BindingResult; @@ -1445,5 +1447,29 @@ public class PatientController { boolean save = lymsPatientService.save(patient); return BaseResponse.ok(); } + /** + * 孕产婴平台地址 + */ + @Value("${platform.url}") + private String platformUrl; + + @GetMapping("/getLastMenses/{idNo}") + @TokenRequired + public BaseResponse getLastMenses(@PathVariable("idNo") String idNo){ + BaseResponse baseResponse=new BaseResponse(); + baseResponse.setErrorcode(0); + baseResponse.setErrormsg("成功"); + try { + String result= HttpUtil.getData(platformUrl+Constant.PLATFORM_LASTMENSES_URL+"?idNo="+idNo); + //log.info("getLastMenses->?result,"+result); + if (!Strings.isNullOrEmpty(result)){ + JSONObject json= JSONObject.parseObject(result); + baseResponse.setObject(json.getInteger("object")); + } + }catch (Exception e){ + log.error("Exception--->"+e.getMessage()); + } + return baseResponse; + } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PushMessageController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PushMessageController.java new file mode 100644 index 0000000..0727df4 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PushMessageController.java @@ -0,0 +1,71 @@ +package com.lyms.talkonlineweb.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.lyms.talkonlineweb.annotation.TokenRequired; +import com.lyms.talkonlineweb.domain.LymsPushMessage; +import com.lyms.talkonlineweb.result.BaseResponse; +import com.lyms.talkonlineweb.service.LymsPushMessageService; +import com.lyms.talkonlineweb.util.StringUtil; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; + +@RestController +@RequiredArgsConstructor(onConstructor =@_(@Autowired)) +public class PushMessageController { + + private final LymsPushMessageService lymsPushMessageService; + + @GetMapping("getPushMessage/{messageType}") + @TokenRequired + public BaseResponse getAllPerm(@PathVariable("messageType") Integer messageType + ,String diagnose,Integer type,Integer status,String cid,Integer isRead + ,String startTime,String endTime,int current,int size){ + if (messageType==null){ + return BaseResponse.error("推送类型不能为空"); + } + QueryWrapper queryWrapper=new QueryWrapper<>(); + List list=new ArrayList<>(); + list.add(messageType); + list.add(3); + queryWrapper.in("message_type",list); + if (cid!=null){ + queryWrapper.eq("cid",cid); + } + if (StringUtil.isNotEmpty(diagnose)){ + queryWrapper.eq("diagnose",diagnose); + } + if (StringUtil.isNotEmpty(startTime)&&StringUtil.isNotEmpty(endTime)){ + queryWrapper.ge("push_time",startTime).le("push_time",endTime); + } + if (type!=null){ + queryWrapper.eq("type",type); + } + if (status!=null){ + queryWrapper.eq("status",status); + } + if (isRead!=null){ + queryWrapper.eq("is_read",isRead); + } + Page page=new Page<>(current,size); + page=lymsPushMessageService.page(page,queryWrapper); + return BaseResponse.ok(page); + } + @GetMapping("readMessage/{id}") + @TokenRequired + public BaseResponse isRead(@PathVariable("id") Integer id){ + LymsPushMessage lymsPushMessage= lymsPushMessageService.getById(id); + if (lymsPushMessage==null){ + return BaseResponse.error("数据异常"); + } + lymsPushMessage.setIsRead(1); + lymsPushMessageService.updateById(lymsPushMessage); + return BaseResponse.ok(); + } +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java index 66ac846..cf98695 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java @@ -9,6 +9,7 @@ import com.lyms.talkonlineweb.domain.*; import com.lyms.talkonlineweb.result.BaseResponse; import com.lyms.talkonlineweb.service.*; import com.lyms.talkonlineweb.util.Constant; +import com.lyms.talkonlineweb.util.DateUtil; import com.lyms.talkonlineweb.util.HXService; import com.lyms.talkonlineweb.util.StringUtil; import lombok.extern.log4j.Log4j2; @@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; @RestController @@ -225,6 +227,7 @@ public class TkRecordController { try { LymsTcard card = new LymsTcard(); card.setPcid(pcid); + card.setOrderNo(DateUtil.getDateTime(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)); Integer count = lymsTcardService.queryUnusedCount(card); baseResponse.setObject(count == null ? 0 : count); baseResponse.setErrormsg("成功"); diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsHisInfo.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsHisInfo.java index 6a2d2d4..76ec495 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsHisInfo.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsHisInfo.java @@ -93,7 +93,7 @@ public class LymsHisInfo implements Serializable { private String hospitalId; /** - * 上传问诊平台状态。0:未上传 1:已上传 + * 上传问诊平台状态。0:未上传 1:已上传 2:上传失败 */ @TableField(value = "up_type") @NotNull(message = "upType不能为空") @@ -120,6 +120,11 @@ public class LymsHisInfo implements Serializable { @TableField(value = "created") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date created; + /** + * 失败原因 + */ + @TableField(value = "remark") + private String remark; /** * 筛选开始时间 diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPushMessage.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPushMessage.java new file mode 100644 index 0000000..872340f --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPushMessage.java @@ -0,0 +1,114 @@ +package com.lyms.talkonlineweb.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 服务推送记录 + * @TableName lyms_push_message + */ +@TableName(value ="lyms_push_message") +@Data +public class LymsPushMessage implements Serializable { + /** + *ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 推送类型 1:问诊 2:公众号 3:全部 + */ + @TableField(value = "message_type") + private Integer messageType; + @TableField(value = "title") + private String title; + + /** + * 医院名称 + */ + @TableField(value = "hospital") + private String hospital; + + /** + * 科室 + */ + @TableField(value = "dept") + private String dept; + + /** + * 患者名称 + */ + @TableField(value = "name") + private String name; + + + + /** + * 患者身份证号码 + */ + @TableField(value = "idno") + private String idno; + + /** + * 疾病 + */ + @TableField(value = "diagnose") + private String diagnose; + /** + * 病例ID + */ + @TableField(value = "cid") + private int cid; + /** + * 类型 0:上传推送 1:7日推送 2:14日推送 + */ + @TableField(value = "type") + private int type; + /** + * 推送类型 1为服务内容推送 + */ + @TableField(value = "push_type") + private int pushType; + + /** + * 1已读 0未读 + */ + @TableField(value = "is_read") + private int isRead; + + /** + * 推送时间 + */ + @TableField(value = "push_time") + private Date pushTime; + /** + * 推送状态 1:成功 0:失败 + */ + @TableField(value = "status") + private int status; + + /** + * 备注 + */ + @TableField(value = "remark") + private String remark; + + /** + * 创建时间 + */ + @TableField(value = "created_time") + private Date createdTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + + + +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushMessageMapper.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushMessageMapper.java new file mode 100644 index 0000000..2676184 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPushMessageMapper.java @@ -0,0 +1,7 @@ +package com.lyms.talkonlineweb.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.lyms.talkonlineweb.domain.LymsPushMessage; + +public interface LymsPushMessageMapper extends BaseMapper { +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushOrderResult.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushOrderResult.java index 9adcfe9..eaf9d05 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushOrderResult.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/result/PushOrderResult.java @@ -2,6 +2,8 @@ package com.lyms.talkonlineweb.result; import lombok.Data; +import java.util.Date; + @Data public class PushOrderResult { private Integer id; @@ -10,4 +12,8 @@ public class PushOrderResult { private String dname; private String hname; private String pname; + private String idno; + private Date service_start_time; + private String iname; + private Integer cid; } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsHisInfoService.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsHisInfoService.java index e5c0a24..ec297bb 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsHisInfoService.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsHisInfoService.java @@ -11,6 +11,8 @@ public interface LymsHisInfoService extends IService { String upHisInfo(LymsHisInfo lymsHisInfo) throws Exception; + void upAllHisInfo(); + /** * 根据疾病名称获取疾病ID * @param diagnoseName diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushMessageService.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushMessageService.java new file mode 100644 index 0000000..3c7f7a7 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPushMessageService.java @@ -0,0 +1,7 @@ +package com.lyms.talkonlineweb.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.lyms.talkonlineweb.domain.LymsPushMessage; + +public interface LymsPushMessageService extends IService { +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsHisInfoServiceImpl.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsHisInfoServiceImpl.java index c0ac50d..d693e9c 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsHisInfoServiceImpl.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsHisInfoServiceImpl.java @@ -1,5 +1,6 @@ package com.lyms.talkonlineweb.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -56,74 +57,124 @@ public class LymsHisInfoServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("pname",lymsHisInfo.getName()); - queryWrapper.eq("enrolment_phone",lymsHisInfo.getPhone()); - List list = lymsPatientService.list(queryWrapper); - if(CollectionUtils.isNotEmpty(list)){ - patient=list.get(0); - } - }else { - //判断患者是否存在 - LymsPatient patientQuery = new LymsPatient(); - patientQuery.setIdno(idCard.toLowerCase()); - patient = lymsPatientService.getOne(Wrappers.query(patientQuery)); - } - if (patient!=null){ - List orderList= lymsOrderService.selectPushOrder(patient.getId()); - log.info("SendWeChatMsg--->orderList,"+orderList.toString()); - if (CollectionUtils.isNotEmpty(orderList)){ - PushOrderResult order= orderList.get(0); - //推送微信公众号 - Map map=new HashMap<>(); - map.put("keyword1",new DataEntity(order.getPname(),"#173177")); - map.put("keyword2",new DataEntity(order.getHname(),"#173177")); - map.put("keyword3",new DataEntity(order.getDname()+"【点击此提醒可查看服务具体内容】","#173177")); - - //公众号跳转小程序需要的登录信息 - Map mapInfo =lymsUserService.pLoginInfo(order.getPid(),3); - try { - log.info("SendWeChatMsg--->startup"); - Integer code= WeiXinUtil.SendWeChatMsg(order.getGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo); - log.info("SendWeChatMsg--->code, "+code); - } catch (Exception e) { - log.error("serviceContent Exception,"+e.getMessage()); - } - } - } - }catch (Exception e){ - log.error("upHisInfo---> Thread Exception"+e.getMessage()); - } - } - }).start(); - + }else { + type=2; } + lymsHisInfo.setUpType(type); + boolean b = updateById(lymsHisInfo); + if(!b){ + //这里想触发事务回滚需抛运行时异常 + throw new Exception("更新HIS患者信息返回值失败状态!"); + } + if (type==1){ + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(3000); + LymsPatient patient =null; + String idCard = lymsHisInfo.getIdcard(); + if (StringUtil.isEmpty(idCard)) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("pname",lymsHisInfo.getName()); + queryWrapper.eq("enrolment_phone",lymsHisInfo.getPhone()); + List list = lymsPatientService.list(queryWrapper); + if(CollectionUtils.isNotEmpty(list)){ + patient=list.get(0); + } + }else { + //判断患者是否存在 + LymsPatient patientQuery = new LymsPatient(); + patientQuery.setIdno(idCard.toLowerCase()); + patient = lymsPatientService.getOne(Wrappers.query(patientQuery)); + } + if (patient!=null){ + List orderList= lymsOrderService.selectPushOrder(patient.getId()); + log.info("SendWeChatMsg--->orderList,"+orderList.toString()); + if (CollectionUtils.isNotEmpty(orderList)){ + LymsPushMessage lymsPushMessage=new LymsPushMessage(); + PushOrderResult order= orderList.get(0); + lymsPushMessage.setIdno(patient.getIdno()); + lymsPushMessage.setHospital(order.getHname()); + lymsPushMessage.setDept(order.getDname()); + lymsPushMessage.setCid(order.getCid()); + lymsPushMessage.setDiagnose(order.getIname()); + lymsPushMessage.setMessageType(3); + lymsPushMessage.setPushType(1); + lymsPushMessage.setTitle("通知:您有一条服务内容推送消息,请点击此处及时查看。"); + lymsPushMessage.setName(patient.getPname()); + lymsPushMessage.setPushTime(new Date()); + lymsPushMessage.setType(0); + //推送微信公众号 + Map map=new HashMap<>(); + map.put("keyword1",new DataEntity(order.getPname(),"#173177")); + map.put("keyword2",new DataEntity(order.getHname(),"#173177")); + map.put("keyword3",new DataEntity(order.getDname()+"【点击此提醒可查看服务具体内容】","#173177")); + + //公众号跳转小程序需要的登录信息 + Map mapInfo =lymsUserService.pLoginInfo(order.getPid(),3); + try { + log.info("SendWeChatMsg--->startup"); + Integer code= WeiXinUtil.SendWeChatMsg(order.getGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo); + log.info("SendWeChatMsg--->code, "+code); + if (null == code || code != 0) { + lymsPushMessage.setStatus(0); + }else { + lymsPushMessage.setStatus(1); + } + lymsPushMessageService.save(lymsPushMessage); + } catch (Exception e) { + log.error("serviceContent Exception,"+e.getMessage()); + } + } + } + }catch (Exception e){ + log.error("upHisInfo---> Thread Exception"+e.getMessage()); + } + } + }).start(); + } return result; } @Override + public void upAllHisInfo() { + LambdaQueryWrapper query = new QueryWrapper() + .lambda().eq(LymsHisInfo::getUpType, 0); + List list = this.list(query); + if (CollectionUtils.isNotEmpty(list)){ + for(LymsHisInfo hisInfo : list){ + try{ + String result = upHisInfo(hisInfo); + if(StringUtil.isNotEmpty(result)){ + log.error("upAllHisInfo--->his患者上传失败,result={},info={}",result,hisInfo); + } + + }catch (Exception e){ + log.error("upAllHisInfo--->his患者信息自动上传任务异常",e); + } + } + } + + } + + @Override public Diagnose getDiagnoseByName(String diagnoseName) { LymsDict dict = new LymsDict(); dict.setVtype(3); @@ -165,8 +216,18 @@ public class LymsHisInfoServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("pname",lymsHisInfo.getName()); + queryWrapper.eq("enrolment_phone",lymsHisInfo.getPhone()); + List list = lymsPatientService.list(queryWrapper); + if(CollectionUtils.isNotEmpty(list)){ + String idno = list.get(0).getIdno(); + lymsHisInfo.setIdcard(idno); + this.updateById(lymsHisInfo); + }else{ + String remark= "患者身份证号不存在,请等待患者注册补全身份证信息后再上传。"; + lymsHisInfo.setRemark(remark); + return remark; + } + } + + //判断患者是否存在 + LymsPatient patientQuery = new LymsPatient(); + patientQuery.setIdno(idCard.toLowerCase()); + LymsPatient patient = lymsPatientService.getOne(Wrappers.query(patientQuery)); + + //判断医院是否平台收费,是否存在订单 + LymsHospital lymsHospital = lymsHospitalService.getById(Integer.valueOf(lymsHisInfo.getHospitalId())); + if(ChargeWay.PLATFORM.getCode()==lymsHospital.getChargeWay()){ + if(patient == null){ + String remark= "患者还没有缴费,暂时不能上传"; + lymsHisInfo.setRemark(remark); + return remark; + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("pid",patient.getId()); + queryWrapper.gt("status",0); + queryWrapper.gt("createdtime", DateUtil.addDay(new Date(),-2)); + List list = lymsOrderService.list(queryWrapper); + if(CollectionUtils.isEmpty(list)){ + String remark= "患者还没有缴费,暂时不能上传"; + lymsHisInfo.setRemark(remark); + return remark; + } + } + //科室 Integer deptId = null;//科室id String deptName = lymsHisInfo.getDept(); @@ -186,7 +300,9 @@ public class LymsHisInfoServiceImpl extends ServiceImpl1){ + String remark= "该患者存在多种疾病,请手动上传"; + lymsHisInfo.setRemark(remark); + return remark; + } /* List diagnoseOrmIds = new ArrayList<>();//疾病映射ids if (null != diagnoses) { @@ -249,47 +374,22 @@ public class LymsHisInfoServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("pname",lymsHisInfo.getName()); - queryWrapper.eq("enrolment_phone",lymsHisInfo.getPhone()); - List list = lymsPatientService.list(queryWrapper); - if(CollectionUtils.isNotEmpty(list)){ - String idno = list.get(0).getIdno(); - lymsHisInfo.setIdcard(idno); - this.updateById(lymsHisInfo); - }else{ - return "患者身份证号不存在,请等待患者注册补全身份证信息后再上传。"; - } - //return "患者身份证号不存在,请等待患者注册补全身份证信息后再上传。"; - //idCard=lymsHisInfo.getVccardno(); + //知识库 + List articleList= articleInfoService.list(new QueryWrapper() + .in("iid",diagnoseIds)); + if (CollectionUtils.isEmpty(articleList)||articleList.size()<18){ + String remark= "该患者疾病文章不足18篇"; + lymsHisInfo.setRemark(remark); + return remark; } - //判断患者是否存在 - LymsPatient patientQuery = new LymsPatient(); - patientQuery.setIdno(idCard.toLowerCase()); - LymsPatient patient = lymsPatientService.getOne(Wrappers.query(patientQuery)); - - //判断医院是否平台收费,是否存在订单 - LymsHospital lymsHospital = lymsHospitalService.getById(Integer.valueOf(lymsHisInfo.getHospitalId())); - if(ChargeWay.PLATFORM.getCode()==lymsHospital.getChargeWay()){ - if(patient == null){ - return "患者还没有缴费,暂时不能上传"; - } - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("pid",patient.getId()); - queryWrapper.gt("status",0); - queryWrapper.gt("createdtime", DateUtil.addDay(new Date(),-2)); - List list = lymsOrderService.list(queryWrapper); - if(CollectionUtils.isEmpty(list)){ - return "患者还没有缴费,暂时不能上传"; - } + //随访 + List chatList= lymsChatInfoService.list(new QueryWrapper().in("illid",diagnoseIds)); + if (CollectionUtils.isEmpty(chatList)){ + String remark= "该患者疾病没有设置回访内容"; + lymsHisInfo.setRemark(remark); + return remark; } - - - if (null != patient) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("pid", patient.getId()); @@ -439,8 +539,6 @@ public class LymsHisInfoServiceImpl extends ServiceImpl + implements LymsPushMessageService { +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HisPatientsAutoUploadTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HisPatientsAutoUploadTask.java index 0ac5003..4398ef5 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HisPatientsAutoUploadTask.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HisPatientsAutoUploadTask.java @@ -2,6 +2,7 @@ package com.lyms.talkonlineweb.task; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.lyms.talkonlineweb.domain.LymsHisInfo; import com.lyms.talkonlineweb.domain.LymsHospital; import com.lyms.talkonlineweb.domain.LymsOrder; @@ -37,7 +38,7 @@ public class HisPatientsAutoUploadTask { @Autowired private LymsHospitalService lymsHospitalService; //医院 - @Scheduled(cron = "0 0 13,21 * * ?") + // @Scheduled(cron = "0 0 13,21 * * ?") public void hisPatientsAutoUploadTask(){ if(!on_off){ return; @@ -49,15 +50,17 @@ public class HisPatientsAutoUploadTask { .ge(LymsHisInfo::getCreatedtime, DateUtil.addDay(new Date(),-3)); List list = lymsHisInfoService.list(query); log.info("his患者信息自动上传任务,size={}",list.size()); - for(LymsHisInfo hisInfo : list){ - try{ - String result = lymsHisInfoService.upHisInfo(hisInfo); - if(StringUtil.isNotEmpty(result)){ - log.error("his患者上传失败,result={},info={}",result,hisInfo); - } + if (CollectionUtils.isNotEmpty(list)){ + for(LymsHisInfo hisInfo : list){ + try{ + String result = lymsHisInfoService.upHisInfo(hisInfo); + if(StringUtil.isNotEmpty(result)){ + log.error("his患者上传失败,result={},info={}",result,hisInfo); + } - }catch (Exception e){ - log.error("his患者信息自动上传任务异常",e); + }catch (Exception e){ + log.error("his患者信息自动上传任务异常",e); + } } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/ServiceContentTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/ServiceContentTask.java index 177e4cd..8795ddb 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/ServiceContentTask.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/ServiceContentTask.java @@ -2,19 +2,15 @@ package com.lyms.talkonlineweb.task; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.lyms.oss.utils.DateUtils; -import com.lyms.talkonlineweb.domain.LymsMessage; -import com.lyms.talkonlineweb.domain.LymsOrder; -import com.lyms.talkonlineweb.domain.LymsPatient; -import com.lyms.talkonlineweb.domain.PatientInfo; +import com.lyms.talkonlineweb.domain.*; import com.lyms.talkonlineweb.param.DataEntity; import com.lyms.talkonlineweb.result.PushOrderResult; -import com.lyms.talkonlineweb.service.LymsOrderService; -import com.lyms.talkonlineweb.service.LymsPatientService; -import com.lyms.talkonlineweb.service.LymsUserService; -import com.lyms.talkonlineweb.service.PatientInfoService; +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.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -22,19 +18,16 @@ import org.springframework.beans.factory.annotation.ParameterResolutionDelegate; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Component @Slf4j +@RequiredArgsConstructor(onConstructor =@_(@Autowired)) public class ServiceContentTask { - @Autowired - private LymsOrderService lymsOrderService; - @Autowired - private LymsUserService lymsUserService; + private final LymsOrderService lymsOrderService; + private final LymsUserService lymsUserService; + private final LymsPushMessageService lymsPushMessageService; /** * 定时推送 * 公众号提醒(开通服务后第7天、开通服务后第14天) @@ -50,7 +43,21 @@ public class ServiceContentTask { List orderList= lymsOrderService.selectOrderTaskList( seven+startStr,seven+endStr,fourteen+startStr,fourteen+endStr); if (CollectionUtils.isNotEmpty(orderList)){ + String fourteenTime=fourteen+endStr; + List list=new ArrayList<>(); orderList.stream().forEach(order -> { + LymsPushMessage lymsPushMessage=new LymsPushMessage(); + lymsPushMessage.setIdno(order.getIdno()); + lymsPushMessage.setHospital(order.getHname()); + lymsPushMessage.setDept(order.getDname()); + lymsPushMessage.setCid(order.getCid()); + lymsPushMessage.setDiagnose(order.getIname()); + lymsPushMessage.setMessageType(3); + lymsPushMessage.setPushType(1); + lymsPushMessage.setTitle("通知:您有一条服务内容推送消息,请点击此处及时查看。"); + lymsPushMessage.setName(order.getPname()); + lymsPushMessage.setPushTime(new Date()); + lymsPushMessage.setType(checkTime(fourteenTime,order.getService_start_time())); //推送微信公众号 Map map=new HashMap<>(); map.put("keyword1",new DataEntity(order.getPname(),"#173177")); @@ -63,12 +70,26 @@ public class ServiceContentTask { log.info("serviceContent-->SendWeChatMsg--->start up"); Integer code= WeiXinUtil.SendWeChatMsg(order.getGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo); log.info("SendWeChatMsg--->code, "+code); + if (null == code || code != 0) { + lymsPushMessage.setStatus(0); + }else { + lymsPushMessage.setStatus(1); + } + list.add(lymsPushMessage); } catch (Exception e) { log.error("serviceContent Exception,"+e.getMessage()); } }); + lymsPushMessageService.saveBatch(list); } log.info("serviceContent end"); } + private int checkTime(String time,Date date){ + Date endTime= DateUtils.parse(time,DateUtil.YYYY_MM_DD_HH_MM_SS); + if (endTime.compareTo(date)<0){ + return 1; + } + return 2; + } } 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 4ea8813..6f64c74 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/Constant.java @@ -101,4 +101,9 @@ public class Constant { * 自动开通孕产婴精准医疗服务和围产小助理服务 */ public static String PLATFORM_AUTO_OPEN_SERVICE_URL = "/yxzh/patSer"; + + /** + * 获取孕产婴精用户孕周 + */ + public static String PLATFORM_LASTMENSES_URL = "/patient/lastMenses"; } diff --git a/talkonlineweb/src/main/resources/mapper/LymsOrderMapper.xml b/talkonlineweb/src/main/resources/mapper/LymsOrderMapper.xml index 7271a27..bdcfafb 100644 --- a/talkonlineweb/src/main/resources/mapper/LymsOrderMapper.xml +++ b/talkonlineweb/src/main/resources/mapper/LymsOrderMapper.xml @@ -72,11 +72,12 @@ -- 1.8.3.1