wangjun 4 лет назад
Родитель
Сommit
7b25ec202a

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java

@ -41,8 +41,8 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    @Query("select count(id) from  WlyyOutpatientDO a where a.outpatientType = ?1 and a.doctor = ?2 and a.admDate >=?3 and a.admDate <=?4")
    @Query("select count(id) from  WlyyOutpatientDO a where a.outpatientType = ?1 and a.doctor = ?2 and a.admDate >=?3 and a.admDate <=?4")
    Integer countByTime(String type,String doctor,Date startTime,Date endTime);
    Integer countByTime(String type,String doctor,Date startTime,Date endTime);
    @Query("from WlyyOutpatientDO a where a.status = 0 and a.payStatus = 1")
    List<WlyyOutpatientDO> findWaitingOutpatient();
    @Query("from WlyyOutpatientDO a where a.status = 0 and a.payStatus = 1 and (a.remindCount<=?1 or a.remindCount=null)")
    List<WlyyOutpatientDO> findWaitingOutpatient(Integer remindCount);
    /*@Query("from WlyyOutpatientDO a where a.patient = ?1 and a.outpatientType = 1")
    /*@Query("from WlyyOutpatientDO a where a.patient = ?1 and a.outpatientType = 1")
    List<WlyyOutpatientDO> findOutpatientByPatientAndStatus(String patient);*/
    List<WlyyOutpatientDO> findOutpatientByPatientAndStatus(String patient);*/

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java

@ -234,7 +234,18 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
    private String  operator;
    private String  operator;
    private String source;//来源
    private String source;//来源
    /*
    *提醒次数
     */
    private Integer remindCount;
    @Column(name = "remind_count")
    public Integer getRemindCount() {
        return remindCount;
    }
    public void setRemindCount(Integer remindCount) {
        this.remindCount = remindCount;
    }
    @Column(name = "operator")
    @Column(name = "operator")
    public String getOperator() {
    public String getOperator() {
        return operator;
        return operator;

+ 1 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/DoctorTimeOutTipsJob.java

@ -37,7 +37,7 @@ public class DoctorTimeOutTipsJob implements Job {
        logger.info("启动发送超时提示消息开始");
        logger.info("启动发送超时提示消息开始");
        System.out.println(wxId);
        System.out.println(wxId);
        System.out.println("启动发送超时提示消息开始");
        System.out.println("启动发送超时提示消息开始");
        List<WlyyOutpatientDO> wlyyOutpatientDOS= outpatientDao.findWaitingOutpatient();
        List<WlyyOutpatientDO> wlyyOutpatientDOS= outpatientDao.findWaitingOutpatient(5);
        String senderId ="";
        String senderId ="";
        String reciverId = "";
        String reciverId = "";
        long timeCount = 0l;
        long timeCount = 0l;

+ 127 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/AutoTimeOutRemind.java

@ -0,0 +1,127 @@
package com.yihu.jw.util;
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.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.asn1.cmp.CertOrEncCert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Lazy(false)
@Component
@EnableScheduling
public class AutoTimeOutRemind implements SchedulingConfigurer {
    private static final Logger logger = LoggerFactory.getLogger(AutoTimeOutRemind.class);
    private static String cron;
    private static String dictName = "remind_patient_job";
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    public ImUtil imUtil;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private PrescriptionService prescriptionService;
    @Value("${wechat.ids}")
    private String wxId;
    public AutoTimeOutRemind() {
      cron = "0 /5 * * * ?";
        System.out.println("创建时的corn"+cron);
    }
    public String change(String corIn){
        if (StringUtils.isNotBlank(corIn)){
            cron = corIn;
        }else {
            List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDO =wlyyHospitalSysDictDao.findByDictName(dictName);
            if (wlyyHospitalSysDictDO.size()>0){
                cron = wlyyHospitalSysDictDO.get(0).getDictValue();
                System.out.println("dict"+ cron);
            }
        }
        System.out.println(cron);
        return "success";
    }
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.addTriggerTask(new Runnable() {
            @Override
            public void run() {
                logger.info("启动发送超时提示消息开始");
                System.out.println(wxId);
                System.out.println("启动发送超时提示消息开始");
                Integer remindCount = 5;
                List<WlyyHospitalSysDictDO> countList = wlyyHospitalSysDictDao.findByDictName("remind_count");
                if (countList.size()>0){
                    remindCount= null!=countList.get(0).getDictValue()?Integer.parseInt(countList.get(0).getDictValue()):5;
                }
                List<WlyyOutpatientDO> wlyyOutpatientDOS= outpatientDao.findWaitingOutpatient(remindCount);
                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();
                        Integer currentRemindCount = wlyyOutpatientDO.getRemindCount();
                        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","");
                            wlyyOutpatientDO.setRemindCount(currentRemindCount+1);
                            outpatientDao.save(wlyyOutpatientDO);
                        }
                    }
                }
            }
        }, new Trigger() {
            @Override
            public Date nextExecutionTime(TriggerContext triggerContext) {
                // 任务触发,可修改任务的执行周期
                CronTrigger trigger = new CronTrigger(cron);
                System.out.println("任务触发,可修改任务的执行周期"+cron);
                Date nextExec = trigger.nextExecutionTime(triggerContext);
                return nextExec;
            }
        });
    }
}

+ 0 - 73
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/DoctorTimeOutRemind.java

@ -1,73 +0,0 @@
package com.yihu.jw.util;
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.util.ImUtil;
import com.yihu.jw.job.DoctorTimeOutTipsJob;
import com.yihu.jw.util.date.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Component
public class DoctorTimeOutRemind {
    private static final Logger logger = LoggerFactory.getLogger(DoctorTimeOutRemind.class);
    @Autowired
    public ImUtil imUtil;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Value("${wechat.ids}")
    private String wxId;
    @Scheduled(cron = "${jobs.schedule}")
    public void remind(){
        logger.info("启动发送超时提示消息开始");
        System.out.println(wxId);
        System.out.println("启动发送超时提示消息开始");
        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","");
                }
            }
        }
    }
}

+ 9 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -15,6 +15,7 @@ import com.yihu.jw.job.ykyy.YkyyDataUploadJob;
import com.yihu.jw.repository.job.QuartzJobConfigDao;
import com.yihu.jw.repository.job.QuartzJobConfigDao;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.AutoTimeOutRemind;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.web.BaseController;
import com.yihu.jw.web.BaseController;
import com.yihu.jw.wechat.service.WxTemplateService;
import com.yihu.jw.wechat.service.WxTemplateService;
@ -196,7 +197,6 @@ public class JobController extends BaseController {
                    }
                    }
                    break;
                    break;
                case "CSTXJOB" :
                case "CSTXJOB" :
                    //互联网医院 待结算消息推送
                    if (!quartzHelper.isExistJob("CSTXJOB")) {
                    if (!quartzHelper.isExistJob("CSTXJOB")) {
                        System.out.println("id"+taskId);
                        System.out.println("id"+taskId);
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("CSTXJOB");
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("CSTXJOB");
@ -614,4 +614,12 @@ public class JobController extends BaseController {
    }
    }
    @RequestMapping(value = "changeDoctorRemindTimeOut", method = RequestMethod.GET)
    public String changeDoctorRemindTimeOut(String corn){
        AutoTimeOutRemind autoTimeOutRemind = new AutoTimeOutRemind();
        return autoTimeOutRemind.change(corn);
    }
}
}

+ 3 - 2
svr/svr-internet-hospital-job/src/main/resources/application.yml

@ -130,7 +130,8 @@ express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
jobs:
  schedule: 0 */1 * * * ?
---
---
spring:
spring:
  profiles: jwOracleTest
  profiles: jwOracleTest
@ -257,7 +258,7 @@ express:
  sf_code: WH000091
  sf_code: WH000091
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
jobs:
jobs:
  schedule: 0 */1 * * * ?
  schedule: 0 */30 * * * ?
---
---
spring:
spring: