lhh 6 päivää sitten
vanhempi
commit
71e763a7b0

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

@ -33,6 +33,7 @@ import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.SignGenerator;
import com.yihu.jw.utils.YkyySMSService;
import oracle.sql.DATE;
import org.apache.commons.lang3.StringUtils;
@ -40,14 +41,13 @@ 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.ApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Component
@ -108,34 +108,20 @@ public class TimeoutOverDueService {
    private YkyySMSService ykyySMSService;
    @Autowired
    private BaseDoctorDao doctorDao;
    /**
     *  取消未结束门诊
     */
    public void cancelOutPatientOver(){
            logger.info("进入结束超时未接诊的门诊");
            List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
            timeout = timeout.stream().filter(item -> {
                long currentTime = new Date().getTime();
                long outpatientTime = item.getRegisterDate().getTime();
                if(currentTime-outpatientTime<24*60*60*1000 && currentTime-outpatientTime>23*60*60*1000) {
                    return true;
                } else {
                    return false;
                }
            }).collect(Collectors.toList());
            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.getRegisterDate().getTime();
                        if (currentTime-outpatientTime>24*60*60*1000){
                            logger.info("时间满足条件");
                            String outPatientId = wlyyOutpatientDO.getId();
                            String consultCode ="";
                            try {
    @Autowired
    private ApplicationContext applicationContext;
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void consumerCancelOutPatientOver(WlyyOutpatientDO wlyyOutpatientDO,String cancelValue,String cancelRemark) {
        try {
            long currentTime = new Date().getTime();
            long outpatientTime = wlyyOutpatientDO.getRegisterDate().getTime();
            if (currentTime-outpatientTime>24*60*60*1000){
                logger.info("时间满足条件"+wlyyOutpatientDO.getDoctor()+"-"+wlyyOutpatientDO.getId());
                String outPatientId = wlyyOutpatientDO.getId();
                String consultCode ="";
                try {
                                    /*//医生未回复可以退费
                                    businessOrderService.consultRefund(consultCode,wechatId);
                                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
@ -145,139 +131,210 @@ public class TimeoutOverDueService {
                                    wlyyOutpatientDO.setOperator("system");
                                    outpatientDao.save(wlyyOutpatientDO);
                                    logger.info(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("consumerName",wlyyOutpatientDO.getConsumerName());
                                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());
                                }
                                //删除门诊号源
                                List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                                if (list != null && list.size() > 0) {
                                    patientRegisterTimeDao.delete(list);
                    //判断医生是否接诊
                    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("consumerName",wlyyOutpatientDO.getConsumerName());
                    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());
                    }
                    //删除门诊号源
                    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")) {
                        if (businessOrderDO.getStatus()==1){
                            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")) {
                        WlyyHospitalSysDictDO hospitalSysDictDO =  hospitalSysDictDao.findById("isCloseRefund");
                        if (hospitalSysDictDO!=null&&hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                            try {
                                if (businessOrderDO.getStatus()==1&&StringUtils.isNoneBlank(businessOrderDO.getTraceNo())){
                                    entranceService.hisRefund(outPatientId);
                                }
                                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                                if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                    if (businessOrderDO.getStatus()==1){
                                        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")) {
                                    WlyyHospitalSysDictDO hospitalSysDictDO =  hospitalSysDictDao.findById("isCloseRefund");
                                    if (hospitalSysDictDO!=null&&hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                                        try {
                                            if (businessOrderDO.getStatus()==1&&StringUtils.isNoneBlank(businessOrderDO.getTraceNo())){
                                                entranceService.hisRefund(outPatientId);
                                            }
                                        }catch (Exception e){
                                            e.printStackTrace();
                                        }
                            }catch (Exception e){
                                e.printStackTrace();
                            }
                                    }
                        }
    /*
                        businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
    */
                                }
                                outpatientDao.save(wlyyOutpatientDO);
                                logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                                consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
                                logger.info("consultCode"+consultCode);
                                if(StringUtils.isNoneBlank(consultCode)) {
                                    imService.cancelRevisit(consultCode, "admin", 2);
                                }
                                if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
                                    String msgUrl="https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId="+wlyyOutpatientDO.getId();
                                    prescriptionService.sendZsMsgFlow("OL_WZCS_CANCEL",wlyyOutpatientDO.getId(),"",msgUrl,"24 时未接诊,问诊超时取消");
                                }
                                }catch(Exception e)  {
                                    e.printStackTrace();
                                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                                }
                    }
                    if("ff80808199e1e6650199e76d0f6c10a5".equals(wlyyOutpatientDO.getId())) {
                        Map<String, Object> entry2 = jdbcTemplate.queryForMap("SELECT id,status,DOCTOR_CANCEL_REMARK,DOCTOR_CANCEL_TYPE,DOCTOR_CANCEL_VALUE,end_time,OPERATOR FROM \"WLYY_OUTPATIENT\" WHERE id='ff80808199e1e6650199e76d0f6c10a5'");
                        logger.info("entry2"+JSON.toJSONString(entry2));
                    }
                    logger.info("保存"+wlyyOutpatientDO.getDoctor()+"-"+wlyyOutpatientDO.getId()+":"+JSON.toJSONString(wlyyOutpatientDO));
                    wlyyOutpatientDO = outpatientDao.save(wlyyOutpatientDO);
                    logger.info("保存2"+wlyyOutpatientDO.getDoctor()+"-"+wlyyOutpatientDO.getId()+":"+JSON.toJSONString(wlyyOutpatientDO));
                            } else if(currentTime-outpatientTime>23*60*60*1000) {
                                String doctor = wlyyOutpatientDO.getDoctor();
                                if("4028a14770a41b240170a4bbb4da0090".equals(doctor)) {
                                    //系统消息
                                    SystemMessageDO messageDO = new SystemMessageDO();
                                    messageDO.setTitle("待回复提醒");
                                    messageDO.setType("144");
                                    messageDO.setSender(wlyyOutpatientDO.getPatient());
                                    messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                                    messageDO.setRelationCode(wlyyOutpatientDO.getId());
                                    messageDO.setReceiver(wlyyOutpatientDO.getDoctor());
                                    messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                                    net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                                    data.put("name", wlyyOutpatientDO.getPatientName());
                                    data.put("consumerName",wlyyOutpatientDO.getConsumerName());
                                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                                    data.put("question", wlyyOutpatientDO.getIcd10Name());
                                    data.put("type","nnn");
                                    data.put("msg", "您当前的订单尚未回复,1 小时后系统将自动关闭,请留意处理。");
                                    messageDO.setData(data.toString());
                                    System.out.println(JSON.toJSONString(messageDO));
                                    systemMessageService.saveMessage(messageDO);
                                    outpatientDao.save(wlyyOutpatientDO);
                                }
                            }
                    } catch (Exception e) {
                        e.printStackTrace();
                        logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");
                    if("ff80808199e1e6650199e76d0f6c10a5".equals(wlyyOutpatientDO.getId())) {
                        Map<String, Object> entry3 = jdbcTemplate.queryForMap("SELECT id,status,DOCTOR_CANCEL_REMARK,DOCTOR_CANCEL_TYPE,DOCTOR_CANCEL_VALUE,end_time,OPERATOR FROM \"WLYY_OUTPATIENT\" WHERE id='ff80808199e1e6650199e76d0f6c10a5'");
                        logger.info("entry3"+JSON.toJSONString(entry3));
                    }
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                    consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
                    logger.info("consultCode"+consultCode);
                    if(StringUtils.isNoneBlank(consultCode)) {
                        imService.cancelRevisit(consultCode, "admin", 2);
                    }
                    if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
                        String msgUrl="https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId="+wlyyOutpatientDO.getId();
                        prescriptionService.sendZsMsgFlow("OL_WZCS_CANCEL",wlyyOutpatientDO.getId(),"",msgUrl,"24 时未接诊,问诊超时取消");
                    }
                }catch(Exception e)  {
                    e.printStackTrace();
                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                }
                if("ff80808199e1e6650199e76d0f6c10a5".equals(wlyyOutpatientDO.getId())) {
                    Map<String, Object> entry4 = jdbcTemplate.queryForMap("SELECT id,status,DOCTOR_CANCEL_REMARK,DOCTOR_CANCEL_TYPE,DOCTOR_CANCEL_VALUE,end_time,OPERATOR FROM \"WLYY_OUTPATIENT\" WHERE id='ff80808199e1e6650199e76d0f6c10a5'");
                    logger.info("entry4"+JSON.toJSONString(entry4));
                }
            } else if(1==2 && currentTime-outpatientTime>23*60*60*1000 && !"1".equals(wlyyOutpatientDO.getHasRemind())) {
                String doctor = wlyyOutpatientDO.getDoctor();
                String question = wlyyOutpatientDO.getIcd10Name();
                if("4028a14770a41b240170a4bbb4da0090".equals(doctor)) {
                    //系统消息
                    SystemMessageDO messageDO = new SystemMessageDO();
                    messageDO.setTitle("待回复提醒");
                    messageDO.setType("144");
                    messageDO.setSender(wlyyOutpatientDO.getPatient());
                    messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                    messageDO.setRelationCode(wlyyOutpatientDO.getId());
                    messageDO.setReceiver(wlyyOutpatientDO.getDoctor());
                    messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                    net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                    data.put("name", wlyyOutpatientDO.getPatientName());
                    data.put("consumerName",wlyyOutpatientDO.getConsumerName());
                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("question", question);
                    data.put("type","nnn");
                    data.put("msg", "您当前的订单尚未回复,1 小时后系统将自动关闭,请留意处理。");
                    messageDO.setData(data.toString());
                    BaseDoctorDO doctorDO = doctorDao.findById(doctor);
                    Map<String,Object> params = new HashMap<>();
                    params.put("mobile",doctorDO.getMobile());
                    params.put("scene","EXT_APPOINT_CANCEL");
                    Map<String,Object> msg = new HashMap<>();
                    msg.put("PATIENTNAME","TEST");
                    msg.put("HOSPNAME","TEST");
                    msg.put("DEPTNAME","TEST");
                    msg.put("DOCTORNAME","TEST");
                    msg.put("CANCELREASON","TEST");
                    msg.put("CANCELDESC","TEST");
                    msg.put("RXNO","TEST");
                    params.put("params",msg);
                    //                                    SignGenerator.requestYkt(params,"https://huaxia.yanketong.com/api/ext/ykt/open/sms/promotion/send");
                    String patientName = wlyyOutpatientDO.getPatientName();
                    String idcard = wlyyOutpatientDO.getIdcard();
                    int patientAge = IdCardUtil.getAgeForIdcard(idcard);
                    String patientSex = IdCardUtil.getSexForIdcard(idcard);
                    System.out.println(JSON.toJSONString(messageDO));
                    systemMessageService.saveMessage(messageDO);
                    wlyyOutpatientDO.setHasRemind("1");
                    outpatientDao.save(wlyyOutpatientDO);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");
        }
    }
    /**
     *  取消未结束门诊
     */
    public void cancelOutPatientOver(){
        logger.info("进入结束超时未接诊的门诊");
        Map<String, Object> entry = jdbcTemplate.queryForMap("SELECT id,status,DOCTOR_CANCEL_REMARK,DOCTOR_CANCEL_TYPE,DOCTOR_CANCEL_VALUE,end_time,OPERATOR FROM \"WLYY_OUTPATIENT\" WHERE id='ff80808199e1e6650199e76d0f6c10a5'");
        logger.info("entry1"+JSON.toJSONString(entry));
        List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
            timeout.stream().filter(item -> {
                if("4028a14770a41b240170a4bbb4da0090".equals(item.getDoctor())) {
                    return true;
                } else {
                    return false;
                }
            }).forEach(item -> {
                System.out.println(JSON.toJSONString(item));
            });
            if (null!=timeout&&timeout.size()>0){
                logger.info("开始结束超时未接诊的门诊");
                String cancelValue = "超时订单系统自动取消";
                String cancelRemark = "当天未接诊的门诊订单自动取消";
                TimeoutOverDueService proxy = applicationContext.getBean(TimeoutOverDueService.class);
                for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                    proxy.consumerCancelOutPatientOver(wlyyOutpatientDO,cancelValue,cancelRemark);
                }
            }
        }

+ 21 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultStatisticsEndpoint.java

@ -132,6 +132,12 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "orgId",required = false) String orgId,
			@ApiParam(name = "deptId", value = "科室id")
			@RequestParam(value = "deptId",required = false) String deptId,
			@ApiParam(name = "roleType", value = "1专科医生 2管理员")
			@RequestParam(value = "roleType",required = true) String roleType,
			@ApiParam(name = "userOrgId", value = "医生所属机构id")
			@RequestParam(value = "userOrgId",required = true) String userOrgId,
			@ApiParam(name = "userId", value = "医生id(当前登录用户)")
			@RequestParam(value = "userId",required = true) String userId,
			@ApiParam(name = "pageNum", value = "pageNum")
			@RequestParam(value = "pageNum",required = true) Integer pageNum,
			@ApiParam(name = "pageSize", value = "pageSize")
@ -192,6 +198,14 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
				}
			}
			if("1".equals(roleType)) { // 专科医生
				filterSql += " AND op.doctor = '" + userId + "' ";
			} else if("2".equals(roleType)) { // 管理员
				filterSql += " AND dh.org_code = '" + userOrgId + "' ";
			} else {
				throw new ServiceException("角色类型有误");
			}
			selectSql += filterSql;
			selectSql += groupSql;
@ -327,10 +341,16 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "orgId",required = false) String orgId,
			@ApiParam(name = "deptId", value = "科室id")
			@RequestParam(value = "deptId",required = false) String deptId,
			@ApiParam(name = "roleType", value = "1专科医生 2管理员")
			@RequestParam(value = "roleType",required = true) String roleType,
			@ApiParam(name = "userOrgId", value = "医生所属机构id")
			@RequestParam(value = "userOrgId",required = true) String userOrgId,
			@ApiParam(name = "userId", value = "医生id(当前登录用户)")
			@RequestParam(value = "userId",required = true) String userId,
			HttpServletResponse response) {
		try {
			ObjEnvelop envelop = this.statisticsData(mediaType, aggField, startTime, endTime, orgId, deptId, 1, 20000);
			ObjEnvelop envelop = this.statisticsData(mediaType, aggField, startTime, endTime, orgId, deptId, roleType,userOrgId, userId, 1, 20000);
			Object list = ((JSONObject) (envelop.getObj())).get("list");
			response.setContentType("octets/stream");
			response.setHeader("Content-Disposition", "attachment; filename=" + new String("searchRecordWrite.xls"));