Parcourir la source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangzhinan il y a 4 ans
Parent
commit
771b735abb

+ 145 - 241
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java

@ -351,105 +351,6 @@ public class PrescriptionStatusUpdateService {
                logger.info("setOutPatientOver count :"+0);
            }
            logger.info("setOutPatientOver end ");
            logger.info("进入结束超时未接诊的门诊");
            List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
            if (null!=timeout&&timeout.size()>0){
                logger.info("开始结束超时未接诊的门诊");
                String cancelValue = "超时订单系统自动取消";
                String cancelRemark = "当天未接诊的门诊订单自动取消";
                for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                    String outPatientId = wlyyOutpatientDO.getId();
                    //判断医生是否接诊
                    List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                    if (roomDOs != null && roomDOs.size() > 0) {
                        for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                            if (roomDO.getVisitStatus() == 2) {
                                logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                            } else {
                                roomDO.setVisitStatus(-1);
                                logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                hospitalWaitingRoomDao.save(roomDO);
                            }
                        }
                    }
                    //更改门诊状态
                    wlyyOutpatientDO.setStatus("-1");
                    String description = null;
                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                    wlyyOutpatientDO.setDoctorCancelType("6");
                    wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                    wlyyOutpatientDO.setEndTime(new Date());
                    wlyyOutpatientDO.setOperator("system");
                    description = cancelValue;
                    //系统消息
                    SystemMessageDO messageDO = new SystemMessageDO();
                    messageDO.setTitle("超时订单系统自动取消");
                    messageDO.setType("13");
                    messageDO.setSender(wlyyOutpatientDO.getDoctor());
                    messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                    messageDO.setRelationCode(wlyyOutpatientDO.getId());
                    messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                    messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                    net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                    try {
                        data.put("name", wlyyOutpatientDO.getPatientName());
                        data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("question", wlyyOutpatientDO.getIcd10Name());
                        String msg = "";
                        if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                            data.put("type", "9");
                            msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                            prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                        }
                        if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                            data.put("type", "16");
                            msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                            prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                        }
                        data.put("msg", msg);
                        messageDO.setData(data.toString());
                        systemMessageService.saveMessage(messageDO);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    //推送消息到眼科通
                    BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                    if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                        logger.info("推送消息到眼科通");
                        ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                    }
                    outpatientDao.save(wlyyOutpatientDO);
                    logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                    //删除门诊号源
                    List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                    if (list != null && list.size() > 0) {
                        patientRegisterTimeDao.delete(list);
                    }
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                    try {
                        if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                            businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                        //眼科接诊时更新眼科通状态
                        if (businessOrderDO!=null){
                            ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                        }
                        } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
    /*
                        businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
    */
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                }
            }
        }
    }
@ -508,94 +409,99 @@ public class PrescriptionStatusUpdateService {
            String cancelValue = "超时订单系统自动取消";
            String cancelRemark = "当天未接诊的门诊订单自动取消";
            String outPatientId = wlyyOutpatientDO.getId();
            //判断医生是否接诊
            List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
            if (roomDOs != null && roomDOs.size() > 0) {
                for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                    if (roomDO.getVisitStatus() == 2) {
                        logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                    } else {
                        roomDO.setVisitStatus(-1);
                        logger.info("修改候诊室状态,将候诊病人移除候诊室");
                        hospitalWaitingRoomDao.save(roomDO);
            long currentTime = new Date().getTime();
            long outpatientTime = wlyyOutpatientDO.getCreateTime().getTime();
            if (currentTime-outpatientTime>24*60*60*1000) {
                logger.info("时间满足条件");
                //判断医生是否接诊
                List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                if (roomDOs != null && roomDOs.size() > 0) {
                    for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                        if (roomDO.getVisitStatus() == 2) {
                            logger.info("id为:" + outPatientId + "的门诊已被医生接诊");
                        } else {
                            roomDO.setVisitStatus(-1);
                            logger.info("修改候诊室状态,将候诊病人移除候诊室");
                            hospitalWaitingRoomDao.save(roomDO);
                        }
                    }
                }
            }
            //更改门诊状态
            wlyyOutpatientDO.setStatus("-1");
            String description = null;
            wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
            wlyyOutpatientDO.setDoctorCancelType("6");
            wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
            wlyyOutpatientDO.setEndTime(new Date());
            wlyyOutpatientDO.setOperator("system");
            description = cancelValue;
            //系统消息
            SystemMessageDO messageDO = new SystemMessageDO();
            messageDO.setTitle("超时订单系统自动取消");
            messageDO.setType("13");
            messageDO.setSender(wlyyOutpatientDO.getDoctor());
            messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
            messageDO.setRelationCode(wlyyOutpatientDO.getId());
            messageDO.setReceiver(wlyyOutpatientDO.getPatient());
            messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
            net.sf.json.JSONObject data = new net.sf.json.JSONObject();
            try {
                data.put("name", wlyyOutpatientDO.getPatientName());
                data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                data.put("question", wlyyOutpatientDO.getIcd10Name());
                String msg = "";
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                    data.put("type", "9");
                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                    prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                //更改门诊状态
                wlyyOutpatientDO.setStatus("-1");
                String description = null;
                wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                wlyyOutpatientDO.setDoctorCancelType("6");
                wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                wlyyOutpatientDO.setEndTime(new Date());
                wlyyOutpatientDO.setOperator("system");
                description = cancelValue;
                //系统消息
                SystemMessageDO messageDO = new SystemMessageDO();
                messageDO.setTitle("超时订单系统自动取消");
                messageDO.setType("13");
                messageDO.setSender(wlyyOutpatientDO.getDoctor());
                messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                messageDO.setRelationCode(wlyyOutpatientDO.getId());
                messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                try {
                    data.put("name", wlyyOutpatientDO.getPatientName());
                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("question", wlyyOutpatientDO.getIcd10Name());
                    String msg = "";
                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "9");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(), null, "9", "systemCancelRemind", cancelRemark);
                    }
                    if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "16");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(), null, "16", "systemCancelRemind", cancelRemark);
                    }
                    data.put("msg", msg);
                    messageDO.setData(data.toString());
                    systemMessageService.saveMessage(messageDO);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                    data.put("type", "16");
                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                    prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                //推送消息到眼科通
                BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                    logger.info("推送消息到眼科通");
                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                }
                data.put("msg", msg);
                messageDO.setData(data.toString());
                systemMessageService.saveMessage(messageDO);
            } catch (Exception e) {
                e.printStackTrace();
            }
            //推送消息到眼科通
            BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                logger.info("推送消息到眼科通");
                ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
            }
            outpatientDao.save(wlyyOutpatientDO);
            logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                outpatientDao.save(wlyyOutpatientDO);
                logger.info("修改保存的门诊记录:" + wlyyOutpatientDO.getId());
            //删除门诊号源
            List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
            if (list != null && list.size() > 0) {
                patientRegisterTimeDao.delete(list);
            }
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
            try {
                if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                    businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                    //眼科接诊时更新眼科通状态
                    if (businessOrderDO!=null){
                        ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                    }
                } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                //删除门诊号源
                List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                if (list != null && list.size() > 0) {
                    patientRegisterTimeDao.delete(list);
                }
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                try {
                    if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                        businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                        //眼科接诊时更新眼科通状态
                        if (businessOrderDO != null) {
                            ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(), "2");
                        }
                    } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
/*
                    businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
*/
                    }
                    msgReturn = "success";
                } catch (Exception e) {
                    e.printStackTrace();
                    msgReturn = "failed";
                }
                msgReturn = "success";
            } catch (Exception e) {
                e.printStackTrace();
                msgReturn = "failed";
            }
            logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
        }
@ -604,47 +510,50 @@ public class PrescriptionStatusUpdateService {
    public String  cancelAll(){
        logger.info("进入结束超时未接诊的门诊");
        List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
        String msgReturn="";
        try {
            if (null!=timeout&&timeout.size()>0){
                logger.info("开始结束超时未接诊的门诊");
                String cancelValue = "超时订单系统自动取消";
                String cancelRemark = "当天未接诊的门诊订单自动取消";
                for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                    String outPatientId = wlyyOutpatientDO.getId();
                    //判断医生是否接诊
                    List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                    if (roomDOs != null && roomDOs.size() > 0) {
                        for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                            if (roomDO.getVisitStatus() == 2) {
                                logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                            } else {
                                roomDO.setVisitStatus(-1);
                                logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                hospitalWaitingRoomDao.save(roomDO);
        String msgReurn = "";
        if (null!=timeout&&timeout.size()>0){
            logger.info("开始结束超时未接诊的门诊");
            String cancelValue = "超时订单系统自动取消";
            String cancelRemark = "当天未接诊的门诊订单自动取消";
            for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                try {
                    long currentTime = new Date().getTime();
                    long outpatientTime = wlyyOutpatientDO.getCreateTime().getTime();
                    if (currentTime-outpatientTime>24*60*60*1000){
                        logger.info("时间满足条件");
                        String outPatientId = wlyyOutpatientDO.getId();
                        //判断医生是否接诊
                        List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                        if (roomDOs != null && roomDOs.size() > 0) {
                            for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                if (roomDO.getVisitStatus() == 2) {
                                    logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                } else {
                                    roomDO.setVisitStatus(-1);
                                    logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                    hospitalWaitingRoomDao.save(roomDO);
                                }
                            }
                        }
                    }
                    //更改门诊状态
                    wlyyOutpatientDO.setStatus("-1");
                    String description = null;
                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                    wlyyOutpatientDO.setDoctorCancelType("6");
                    wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                    wlyyOutpatientDO.setEndTime(new Date());
                    wlyyOutpatientDO.setOperator("system");
                    description = cancelValue;
                    //系统消息
                    SystemMessageDO messageDO = new SystemMessageDO();
                    messageDO.setTitle("超时订单系统自动取消");
                    messageDO.setType("13");
                    messageDO.setSender(wlyyOutpatientDO.getDoctor());
                    messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                    messageDO.setRelationCode(wlyyOutpatientDO.getId());
                    messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                    messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                    net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                    try {
                        //更改门诊状态
                        wlyyOutpatientDO.setStatus("-1");
                        String description = null;
                        wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                        wlyyOutpatientDO.setDoctorCancelType("6");
                        wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                        wlyyOutpatientDO.setEndTime(new Date());
                        wlyyOutpatientDO.setOperator("system");
                        description = cancelValue;
                        //系统消息
                        SystemMessageDO messageDO = new SystemMessageDO();
                        messageDO.setTitle("超时订单系统自动取消");
                        messageDO.setType("13");
                        messageDO.setSender(wlyyOutpatientDO.getDoctor());
                        messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                        messageDO.setRelationCode(wlyyOutpatientDO.getId());
                        messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                        messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                        data.put("name", wlyyOutpatientDO.getPatientName());
                        data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
@ -663,25 +572,19 @@ public class PrescriptionStatusUpdateService {
                        data.put("msg", msg);
                        messageDO.setData(data.toString());
                        systemMessageService.saveMessage(messageDO);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    //推送消息到眼科通
                    BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                    if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                        logger.info("推送消息到眼科通");
                        ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                    }
                    outpatientDao.save(wlyyOutpatientDO);
                    logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                    //删除门诊号源
                    List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                    if (list != null && list.size() > 0) {
                        patientRegisterTimeDao.delete(list);
                    }
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                        //推送消息到眼科通
                        BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                            logger.info("推送消息到眼科通");
                            ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                        }
                        logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                        //删除门诊号源
                        List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                        if (list != null && list.size() > 0) {
                            patientRegisterTimeDao.delete(list);
                        }
                        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                        if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                            businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                            //眼科接诊时更新眼科通状态
@ -689,21 +592,22 @@ public class PrescriptionStatusUpdateService {
                                ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                            }
                        } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
        /*
                            businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
        */
                        }
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        outpatientDao.save(wlyyOutpatientDO);
                        logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        msgReurn="success";
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");
                    msgReurn="faild";
                }
            }
            msgReturn="success";
        } catch (Exception e) {
            e.printStackTrace();
            msgReturn="success";
        }
       return  msgReturn;
        return msgReurn;
    }
    public void cancelRecieve(){

+ 177 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java

@ -0,0 +1,177 @@
package com.yihu.jw.service.channel;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import org.apache.commons.lang3.StringUtils;
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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Component
@Transactional
public class TimeoutOverDueService {
    private static Logger logger = LoggerFactory.getLogger(TimeoutOverDueService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${wechat.ids}")
    private String wechatId;
    @Value("${hlwyyEntrance.url}")
    private String hlwyyEntranceUrl;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private ImService imService;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private HospitalWaitingRoomDao hospitalWaitingRoomDao;
    @Autowired
    private PatientRegisterTimeDao patientRegisterTimeDao;
    @Autowired
    private YkyyService ykyyService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private SystemMessageService systemMessageService;
    /**
     *  取消未结束门诊
     */
    public void cancelOutPatientOver(){
            logger.info("进入结束超时未接诊的门诊");
            List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
            if (null!=timeout&&timeout.size()>0){
                logger.info("开始结束超时未接诊的门诊");
                String cancelValue = "超时订单系统自动取消";
                String cancelRemark = "当天未接诊的门诊订单自动取消";
                for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                    try {
                        long currentTime = new Date().getTime();
                        long outpatientTime = wlyyOutpatientDO.getCreateTime().getTime();
                        if (currentTime-outpatientTime>24*60*60*1000){
                            logger.info("时间满足条件");
                            String outPatientId = wlyyOutpatientDO.getId();
                            //判断医生是否接诊
                            List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                            if (roomDOs != null && roomDOs.size() > 0) {
                                for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                    if (roomDO.getVisitStatus() == 2) {
                                        logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                    } else {
                                        roomDO.setVisitStatus(-1);
                                        logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                        hospitalWaitingRoomDao.save(roomDO);
                                    }
                                }
                            }
                            //更改门诊状态
                            wlyyOutpatientDO.setStatus("-1");
                            String description = null;
                            wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                            wlyyOutpatientDO.setDoctorCancelType("6");
                            wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                            wlyyOutpatientDO.setEndTime(new Date());
                            wlyyOutpatientDO.setOperator("system");
                            description = cancelValue;
                            //系统消息
                            SystemMessageDO messageDO = new SystemMessageDO();
                            messageDO.setTitle("超时订单系统自动取消");
                            messageDO.setType("13");
                            messageDO.setSender(wlyyOutpatientDO.getDoctor());
                            messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                            messageDO.setRelationCode(wlyyOutpatientDO.getId());
                            messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                            messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                            net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                            data.put("name", wlyyOutpatientDO.getPatientName());
                            data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                            data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                            data.put("question", wlyyOutpatientDO.getIcd10Name());
                            String msg = "";
                            if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                data.put("type", "9");
                                msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                            }
                            if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                data.put("type", "16");
                                msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                            }
                            data.put("msg", msg);
                            messageDO.setData(data.toString());
                            systemMessageService.saveMessage(messageDO);
                            //推送消息到眼科通
                            BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                                logger.info("推送消息到眼科通");
                                ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                            }
                            logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                            //删除门诊号源
                            List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                            if (list != null && list.size() > 0) {
                                patientRegisterTimeDao.delete(list);
                            }
                            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                                //眼科接诊时更新眼科通状态
                                if (businessOrderDO!=null){
                                    ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                                }
                            } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
        /*
                            businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
        */
                            }
                            outpatientDao.save(wlyyOutpatientDO);
                            logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");
                    }
                }
            }
        }
    }

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

@ -0,0 +1,63 @@
package com.yihu.jw.util;
import com.yihu.jw.service.channel.PrescriptionStatusUpdateService;
import com.yihu.jw.service.channel.TimeoutOverDueService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import java.util.Date;
@Lazy(false)
@Component
@EnableScheduling
public class TimeoutOverDueJob implements SchedulingConfigurer {
    private static final Logger logger = LoggerFactory.getLogger(TimeoutOverDueJob.class);
    private static String cron = "0 */5 * * * ?";
    public TimeoutOverDueJob(){
        cron="0 */5 * * * ?";
        System.out.println("TimeoutOverDueJob初始化时的corn"+cron);
    }
    @Autowired
    private TimeoutOverDueService TimeoutOverDueService;
    public String change(String corIn) {
        if (StringUtils.isNotBlank(corIn)) {
            cron = corIn;
        }
        return cron;
    }
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.addTriggerTask(new Runnable() {
            @Override
            public void run() {
                logger.info("START========TimeoutOverDueJob========");
                try {
                    TimeoutOverDueService.cancelOutPatientOver();
                    logger.info("END========TimeoutOverDueJob========");
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("END===ERROE===TimeoutOverDueJob,message:"+e.getMessage());
                }
            }
        }, new Trigger() {
            @Override
            public Date nextExecutionTime(TriggerContext triggerContext) {
                // 任务触发,可修改任务的执行周期
                CronTrigger trigger = new CronTrigger(cron);
                System.out.println("TimeoutOverDueJobc,可修改任务的执行周期"+cron);
                Date nextExec = trigger.nextExecutionTime(triggerContext);
                return nextExec;
            }
        });
    }
}

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

@ -18,6 +18,7 @@ import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.AutoTimeOutRemind;
import com.yihu.jw.util.OverdueJob;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.util.TimeoutOverDueJob;
import com.yihu.jw.web.BaseController;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
@ -634,6 +635,13 @@ public class JobController extends BaseController {
        return autoTimeOutRemind.change(corn);
    }
    @RequestMapping(value = "changeCancelTime", method = RequestMethod.GET)
    public String changeCancelTime(String corn){
        TimeoutOverDueJob cancel = new TimeoutOverDueJob();
        return cancel.change(corn);
    }
    @RequestMapping(value = "cancelSinglePre", method = RequestMethod.GET)
    @ApiOperation("取消未接诊")