ソースを参照

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

wangzhinan 4 年 前
コミット
9d167b96ba

+ 4 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -3770,12 +3770,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        }else if("systemCancelRemind".equalsIgnoreCase(titelType)){
            if ("9".equals(type)) {
                contentMsg = "系统已自动取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已取消";
                contentMsg = "图文咨询因超时自动取消。您可重新发起。由于订单取消将不做扣费处理。";
                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超时未接诊已取消";
            }
            if ("16".equals(type)) {
                contentMsg = "系统已自动取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已取消";
                contentMsg = "视频咨询因超时自动取消。您可重新发起。由于订单取消将不做扣费处理。";
                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超时未接诊已取消";
            }
            logger.info("系统取消接诊入参:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;

+ 18 - 2
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -3527,7 +3527,7 @@ public class StatisticsEsService {
            //咨询总数
            List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel0(startTime, endTime, area, level, index1, SaveModel.timeLevel_ZL, lowLevel);
            //已结束
            List<SaveModel> endTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"2");
            List<SaveModel> endTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"1,2,3");
            result.put("resultList", getCoutList1(level, lowLevel, endTotal, total, noReceiveTotal));
        }
@ -4319,7 +4319,23 @@ public class StatisticsEsService {
                }
            }
        }
        object.put("excelData",resultArray);
        List<JSONObject> bindArrayResult = JSONArray.parseArray(resultArray.toJSONString(), JSONObject.class);
        System.out.println("排序前:"+bindArrayResult);
        Collections.sort(bindArrayResult, new Comparator<JSONObject>() {
            @Override
            public int compare(JSONObject o1, JSONObject o2) {
                double a = o1.getDouble("specialist");
                double b = o2.getDouble("specialist");
                if (a > b) {
                    return -1;
                } else if(a == b) {
                    return 0;
                } else
                    return 1;
            }
        });
        JSONArray jsonArray = JSONArray.parseArray(bindArrayResult.toString());
        object.put("excelData",jsonArray);
        return object;
    }
    /**

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

@ -302,148 +302,154 @@ public class PrescriptionStatusUpdateService {
     */
    public void setOutPatientOver(){
        logger.info("setOutPatientOver start ");
        //复诊记录状态状态安全锁,每天0~2点才允许触发,避免误调用
        //将所有的已接诊的处方记录
        List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
        if(outpatientDOs!=null&&outpatientDOs.size()>0){
            System.out.println(outpatientDOs.get(0).getId()+"id______-");
            for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                //结束门诊
                outpatientDO.setStatus("3");
                outpatientDO.setEndTime(new Date());
                String consultCode ="";
                try {
                    consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                    logger.info("consultCode"+consultCode);
                    if(StringUtils.isNoneBlank(consultCode)){
                        imService.finish(consultCode,"admin",2);
        //复诊记录状态状态安全锁,每天0点才允许触发,避免误调用
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        int i = calendar.get(Calendar.HOUR_OF_DAY);
        if(i==0){
            //将所有的已接诊的处方记录
            List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
            if(outpatientDOs!=null&&outpatientDOs.size()>0){
                System.out.println(outpatientDOs.get(0).getId()+"id______-");
                for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                    //结束门诊
                    outpatientDO.setStatus("3");
                    outpatientDO.setEndTime(new Date());
                    String consultCode ="";
                    try {
                        consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                        logger.info("consultCode"+consultCode);
                        if(StringUtils.isNoneBlank(consultCode)){
                            imService.finish(consultCode,"admin",2);
                        }
                    }catch(Exception e)  {
                        e.printStackTrace();
                        logger.info("自动结束咨询报错 consultCode: "+consultCode);
                    }
                }catch(Exception e)  {
                    e.printStackTrace();
                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                    logger.info(outpatientDO.getId()+"的处方记录设置为结束");
                }
                logger.info(outpatientDO.getId()+"的处方记录设置为结束");
            }
            outpatientDao.save(outpatientDOs);
            //退费
            for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                try {
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                if (businessOrderDO!=null){
                    if (businessOrderDO.getPayType()==1){
                        businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                    }else if (businessOrderDO.getPayType()==3){
    /*
                        businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
    */
                outpatientDao.save(outpatientDOs);
                //退费
                for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                    try {
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                    if (businessOrderDO!=null){
                        if (businessOrderDO.getPayType()==1){
                            businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                        }else if (businessOrderDO.getPayType()==3){
        /*
                            businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
        */
                        }
                    } } catch (Exception e) {
                        e.printStackTrace();
                    }
                } } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            logger.info("setOutPatientOver count :"+outpatientDOs.size());
        }else {
            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);
                logger.info("setOutPatientOver count :"+outpatientDOs.size());
            }else {
                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("6");
                wlyyOutpatientDO.setDoctorCancelType(cancelValue);
                wlyyOutpatientDO.setDoctorCancelValue(cancelRemark);
                wlyyOutpatientDO.setEndTime(new Date());
                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("6");
                    wlyyOutpatientDO.setDoctorCancelType(cancelValue);
                    wlyyOutpatientDO.setDoctorCancelValue(cancelRemark);
                    wlyyOutpatientDO.setEndTime(new Date());
                    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")) {
*//*
                businessOrderService.ylzOrderRefund(wxId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
*//*
                    //删除门诊号源
                    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")) {
                } catch (Exception e) {
                    e.printStackTrace();
    /*
                        businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
    */
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                }
                logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
            }
            outpatientDao.save(outpatientDOs);
        }*/
        }
    }
@ -492,6 +498,295 @@ public class PrescriptionStatusUpdateService {
        logger.info("setOutPatientOver end ");
        Set set = new HashSet();
    }
    public  String  singelCancel(String outpatientId){
        logger.info("进入结束超时未接诊的门诊");
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
        String msgReturn = "";
        if (null!=wlyyOutpatientDO){
            logger.info("开始结束超时未接诊的门诊");
            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);
                    }
                }
            }
            //更改门诊状态
            wlyyOutpatientDO.setStatus("-1");
            String description = null;
            wlyyOutpatientDO.setDoctorCancelRemark("6");
            wlyyOutpatientDO.setDoctorCancelType(cancelValue);
            wlyyOutpatientDO.setDoctorCancelValue(cancelRemark);
            wlyyOutpatientDO.setEndTime(new Date());
            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);
*/
                }
                msgReturn = "success";
            } catch (Exception e) {
                e.printStackTrace();
                msgReturn = "failed";
            }
            logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
        }
        return msgReturn;
    }
    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);
                            }
                        }
                    }
                    //更改门诊状态
                    wlyyOutpatientDO.setStatus("-1");
                    String description = null;
                    wlyyOutpatientDO.setDoctorCancelRemark("6");
                    wlyyOutpatientDO.setDoctorCancelType(cancelValue);
                    wlyyOutpatientDO.setDoctorCancelValue(cancelRemark);
                    wlyyOutpatientDO.setEndTime(new Date());
                    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);
                        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);
        */
                        }
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                }
            }
            msgReturn="success";
        } catch (Exception e) {
            e.printStackTrace();
            msgReturn="success";
        }
       return  msgReturn;
    }
    public void cancelRecieve(){
        //将所有的已接诊的处方记录
        List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
        if(outpatientDOs!=null&&outpatientDOs.size()>0){
            System.out.println(outpatientDOs.get(0).getId()+"id______-");
            for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                //结束门诊
                outpatientDO.setStatus("3");
                outpatientDO.setEndTime(new Date());
                String consultCode ="";
                try {
                    consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                    logger.info("consultCode"+consultCode);
                    if(StringUtils.isNoneBlank(consultCode)){
                        imService.finish(consultCode,"admin",2);
                    }
                }catch(Exception e)  {
                    e.printStackTrace();
                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                }
                logger.info(outpatientDO.getId()+"的处方记录设置为结束");
            }
            outpatientDao.save(outpatientDOs);
            //退费
            for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                try {
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                    if (businessOrderDO!=null){
                        if (businessOrderDO.getPayType()==1){
                            businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                        }else if (businessOrderDO.getPayType()==3){
        /*
                            businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
        */
                        }
                    } } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            logger.info("setOutPatientOver count :"+outpatientDOs.size());
        }else {
            logger.info("setOutPatientOver count :"+0);
        }
        logger.info("setOutPatientOver end ");
    }
    public void cancelRecieveSingle(String outpatientId){
        //将所有的已接诊的处方记录
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if(outpatientDO!=null){
            System.out.println(outpatientDO.getId()+"id______-");
            //结束门诊
            outpatientDO.setStatus("3");
            outpatientDO.setEndTime(new Date());
            String consultCode ="";
            try {
                consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                logger.info("consultCode"+consultCode);
                if(StringUtils.isNoneBlank(consultCode)){
                    imService.finish(consultCode,"admin",2);
                }
            }catch(Exception e)  {
                e.printStackTrace();
                logger.info("自动结束咨询报错 consultCode: "+consultCode);
            }
            logger.info(outpatientDO.getId()+"的处方记录设置为结束");
            outpatientDao.save(outpatientDO);
            //退费
            try {
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                if (businessOrderDO!=null){
                    if (businessOrderDO.getPayType()==1){
                        businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                    }else if (businessOrderDO.getPayType()==3){
    /*
                        businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
    */
                    }
                } } catch (Exception e) {
                e.printStackTrace();
            }
        }else {
            logger.info("setOutPatientOver count :"+0);
        }
        logger.info("setOutPatientOver end ");
    }
}

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

@ -13,6 +13,7 @@ import com.yihu.jw.job.ykyy.UpdateStatusByPayTimeJob;
import com.yihu.jw.job.ykyy.YkyyDataUploadJob;
import com.yihu.jw.repository.job.QuartzJobConfigDao;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.channel.PrescriptionStatusUpdateService;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.AutoTimeOutRemind;
import com.yihu.jw.util.OverdueJob;
@ -21,6 +22,7 @@ import com.yihu.jw.web.BaseController;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -66,6 +68,8 @@ public class JobController extends BaseController {
    private QuartzJobConfigDao wlyyJobConfigDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private PrescriptionStatusUpdateService prescriptionStatusUpdateService;
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
@ -631,5 +635,25 @@ public class JobController extends BaseController {
        return autoTimeOutRemind.change(corn);
    }
    @RequestMapping(value = "cancelSinglePre", method = RequestMethod.GET)
    @ApiOperation("取消未接诊")
    public String cancelSinglePre(String outpatientId){
        if (StringUtils.isNotBlank(outpatientId)){
            System.out.println(outpatientId);
            return prescriptionStatusUpdateService.singelCancel(outpatientId);
        }else {
            return prescriptionStatusUpdateService.cancelAll();
        }
    }
    @RequestMapping(value = "overRecivePre", method = RequestMethod.GET)
    @ApiOperation("结束接诊")
    public void cancelRecivePre(String outpatientId){
        if (StringUtils.isNotBlank(outpatientId)){
            System.out.println(outpatientId);
            prescriptionStatusUpdateService.cancelRecieveSingle(outpatientId);
        }else {
            prescriptionStatusUpdateService.cancelRecieve();
        }
    }
}