소스 검색

未接诊订单自动取消

wangjun 4 년 전
부모
커밋
9e7a8f9a83

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

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

+ 14 - 6
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -3679,12 +3679,14 @@ public class StatisticsEsService {
                object.put("totalData",array);//新增量
                JSONArray array1 = dateTotalStatistics2(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL,null);//未接诊
                object.put("noReceiveData",array1);//未接诊
                JSONArray array2 = dateTotalStatistics2(startDate,endDate,area,level,index1,"1,2",SaveModel.timeLevel_ZL,null);//已接诊
                JSONArray array2 = dateTotalStatistics2(startDate,endDate,area,level,index,"1,2,3",SaveModel.timeLevel_ZL,null);//已接诊
                object.put("haveReceiveData",array2);//已接诊
                JSONArray array3 = dateTotalStatistics2(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL,null);//患者取消
                object.put("concleData",array3);//患者取消
                JSONArray array4 = dateTotalStatistics2(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL,null);//已结束
                object.put("endData",array4);//已结束
                array2.addAll(array4);
                object.put("receiveEndData",array2);//已接诊+结束
            }
        }else if (interval==2){
@ -3704,12 +3706,14 @@ public class StatisticsEsService {
                object.put("totalData",array);//新增量
                JSONArray array1 = weekTotalStatistics(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL);//未接诊
                object.put("noReceiveData",array1);;//未接诊
                JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,index1,"1,2",SaveModel.timeLevel_ZL);//已接诊
                JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,index,"1,2,3",SaveModel.timeLevel_ZL);//已接诊
                object.put("haveReceiveData",array2);//已接诊
                JSONArray array3 = weekTotalStatistics(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL);//患者取消
                object.put("concleData",array3);//患者取消
                JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL);//已结束
                object.put("endData",array3);//已结束
                object.put("endData",array4);//已结束
                array2.addAll(array4);
                object.put("receiveEndData",array2);//已接诊+结束
            }
        }else if (interval==3){
@ -3729,12 +3733,14 @@ public class StatisticsEsService {
                object.put("totalData",array);
                JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL,null);
                object.put("noReceiveData",array1);
                JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,index1,"1,2",SaveModel.timeLevel_ZL,null);
                JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,index,"1,2,3",SaveModel.timeLevel_ZL,null);
                object.put("haveReceiveData",array2);
                JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL,null);
                object.put("concleData",array3);
                JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL,null);
                object.put("endData",array4);
                array2.addAll(array4);
                object.put("receiveEndData",array2);//已接诊+结束
            }
        }
@ -3777,11 +3783,11 @@ public class StatisticsEsService {
            //咨询总数
            List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel0(startTime, endTime, area, level, index1, SaveModel.timeLevel_ZL, lowLevel);
            //已接诊
            List<SaveModel> haveReceiveTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"1,2");
            List<SaveModel> haveReceiveTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"1,2,3");
            //未接诊
            List<SaveModel> noReceiveTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"0");
            result.put("resultList", getCoutListPC1(level, lowLevel, endTotal, total, haveReceiveTotal,noReceiveTotal,concleTotal));
        }
    }
        return result;
@ -3892,6 +3898,7 @@ public class StatisticsEsService {
            rs.put("total", totalNm);
            rs.put("noReceiveCount", noReceiveNm);
            rs.put("haveReceiveCount", haveReceiveNm);
            rs.put("endAndReciveCount",endNm+haveReceiveNm);
            rs.put("code", key);
            resultMaps.add(rs);
        }
@ -4455,4 +4462,5 @@ public JSONObject changePrescriptionLineOnlyTop(String startDate, String endDate
    }
    return null;
}*/
}

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

@ -2,20 +2,33 @@ package com.yihu.jw.service.channel;
import com.fasterxml.jackson.databind.ObjectMapper;
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.*;
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.*;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
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.repository.job.QuartzJobLogDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.status.EnvelopStatus;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -63,7 +76,17 @@ public class PrescriptionStatusUpdateService {
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;
    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 autoPush() throws Exception {
@ -323,6 +346,102 @@ 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("6");
                wlyyOutpatientDO.setDoctorCancelType(cancelValue);
                wlyyOutpatientDO.setDoctorCancelValue(cancelRemark);
                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", "doctorRefuseRemind", cancelRemark);
                    }
                    if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "16");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        //prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", 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(wxId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
*/
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
            }
            outpatientDao.save(outpatientDOs);
        }
    }
@ -369,6 +488,7 @@ public class PrescriptionStatusUpdateService {
            logger.info("setOutPatientOver Time is not up ");
        }
        logger.info("setOutPatientOver end ");
        Set set = new HashSet();
    }