123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package com.yihu.jw.job;
- import com.alibaba.fastjson.JSONObject;
- import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
- import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
- import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
- import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
- import com.yihu.jw.hospital.prescription.service.PrescriptionService;
- import com.yihu.jw.im.service.ImService;
- import com.yihu.jw.im.util.ImUtil;
- import com.yihu.jw.util.date.DateUtil;
- import org.quartz.Job;
- import org.quartz.JobExecutionContext;
- import org.quartz.JobExecutionException;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import java.util.Date;
- import java.util.List;
- /**
- * Created by Trick on 2020/3/11
- */
- public class OutPatientRemindJob implements Job {
- private static final Logger logger = LoggerFactory.getLogger(OutPatientRemindJob.class);
- @Autowired
- public ImUtil imUtil;
- @Autowired
- private OutpatientDao outpatientDao;
- @Autowired
- private PrescriptionService prescriptionService;
- @Autowired
- private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
- @Value("${wechat.id}")
- private String wxId;
- @Override
- public void execute(JobExecutionContext context) throws JobExecutionException {
- List<WlyyOutpatientDO> wlyyOutpatientDOS= outpatientDao.findWaitingOutpatient();
- String senderId ="";
- String reciverId = "";
- long timeCount = 0l;
- String content = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
- JSONObject object = new JSONObject();
- object.put("socket_sms_type",14);
- object.put("msg",content);
- object.put("msg_time", DateUtil.dateToStrLong(new Date()));
- if (null!=wlyyOutpatientDOS){
- for (WlyyOutpatientDO wlyyOutpatientDO:wlyyOutpatientDOS){
- long patientTime = wlyyOutpatientDO.getCreateTime().getTime();
- logger.info("接诊创建时间="+patientTime);
- List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDOS = wlyyHospitalSysDictDao.findByDictName("outpatient_timeout_remind");
- if (wlyyHospitalSysDictDOS.size()>0){
- timeCount = Long.valueOf(wlyyHospitalSysDictDOS.get(0).getDictValue());
- }
- long currentTime = new Date().getTime();
- logger.info("当前时间="+currentTime);
- logger.info("数据库配置时间=0"+timeCount);
- if (currentTime-patientTime>timeCount*60*1000){
- logger.info("--便利发送消息");
- reciverId = wlyyOutpatientDO.getPatient();
- logger.info("---发送人id"+senderId);
- senderId= wlyyOutpatientDO.getDoctor();
- logger.info("---接受人Id"+reciverId);
- imUtil.sendMessage(senderId,reciverId,"1",object.toString());
- logger.info("--发送结束");
- logger.info("--模板发送开始");
- prescriptionService.sendWxTemplateMsg(wxId,wlyyOutpatientDO.getId(),null,null,"outPatientTimeOutRemind","");
- }
- }
- }
- }
- }
|