| 
					
				 | 
			
			
				@ -55,7 +55,6 @@ import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.io.InputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.nio.charset.Charset; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1404,6 +1403,20 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        else if(type == WlyyDoorServiceOrderDO.CancelType.patient.getType()){                   //居民取消,消息列表也应该不显示 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            List<Message> messages = messageDao.queryByRelationCodeAndTypeIn(orderId,new Integer[]{402,403}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if(CollectionUtils.isEmpty(messages)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                logger.error("当前工单没有系统消息!!orderId:" + orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                messages.forEach( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        message -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            message.setOver("0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            messageDao.save(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //如果是调度员取消,推送IM取消工单json消息, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/*        if(type == WlyyDoorServiceOrderDO.CancelType.dispatcher.getType()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject content = this.queryOrderCardInfo(orderDO); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1825,6 +1838,24 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if (StringUtils.isNoneBlank(phone)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            buffer.append(" AND o.`proxy_patient_phone` like '%"+phone+"%'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String applicationSql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientTypeTemp = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("1".equals(isApplication)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            applicationSql +=                 " JOIN ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "         select a.patient, group_concat(v.type) as type " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "         from wlyy_door_service_voucher v " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                  JOIN (select t.id, t.patient, max(t.create_time) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                        from wlyy_door_service_application t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                        where t.status in (2, 3) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                        group by t.patient) as a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                       on a.id = v.service_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "         where v.status = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "         group by a.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "        ) as t1 on o.patient = t1.patient" ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientTypeTemp = " ,t1.`type` as patientType "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  p.name AS patientName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  p.photo AS photo, " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1844,23 +1875,12 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.serve_lat as lat, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.`status` as status, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.`dispatcher_name` as dispatcherName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  concat( o.patient,'_' ,c.id, '_',o.`number`,'_11' ) as sessionId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   t1.`type` as patientType " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  concat( o.patient,'_' ,c.id, '_',o.`number`,'_11' ) as sessionId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientTypeTemp + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( wlyy_door_service_order o " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_patient p ON o.patient = p.id ) LEFT JOIN wlyy_consult c on o.id = c.relation_code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         select a.patient, group_concat(v.type) as type " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         from wlyy_door_service_voucher v " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                  JOIN (select t.id, t.patient, max(t.create_time) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        from wlyy_door_service_application t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        where t.status in (2, 3) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        group by t.patient) as a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                       on a.id = v.service_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         where v.status = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         group by a.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        ) as t1 on o.patient = t1.patient" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_patient p ON o.patient = p.id ) LEFT JOIN wlyy_consult c on o.id = c.relation_code"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                applicationSql+" WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.hospital = '{hospital}' and o.type != 3 " +buffer+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND ( o.`status` = {status} OR -100 = {status} ) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ORDER BY o.create_time desc " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1877,17 +1897,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   wlyy_door_service_order o  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_patient p ON o.patient = p.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN  ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         select a.patient, group_concat(v.type) as type " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         from wlyy_door_service_voucher v " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                  JOIN (select t.id, t.patient, max(t.create_time) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        from wlyy_door_service_application t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        where t.status in (2, 3) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        group by t.patient) as a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                       on a.id = v.service_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         where v.status = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         group by a.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        ) as t1 on o.patient = t1.patient" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                applicationSql + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.hospital = '{hospital}' " +buffer+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND (o.`status` = {status} or -100 = {status})"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1932,7 +1942,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray parArray = imUtill.getParticipants(sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    parArray.forEach( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            oneParObj -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                org.json.JSONObject oneParJson = (org.json.JSONObject)oneParObj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                JSONObject oneParJson = (com.alibaba.fastjson.JSONObject)oneParObj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if(StringUtils.equalsIgnoreCase(oneParJson.getString("id"),dispatcher)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    oneMap.put("isInSession",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2126,7 +2136,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int start = 0 == page ? page++ : (page - 1) * size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int end = 0 == size ? 15 : page * size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select ds.doctor,d.name, d.job_name as jobName, 1 as sortFlag " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select ds.doctor,d.name, d.job_title_name as jobName, 1 as sortFlag " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_door_doctor_status ds " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        JOIN (select b.* from base_doctor b,base_doctor_hospital dh where b.id=dh.doctor_code and dh.del = 1 and dh.org_code='" + hospital + "')  d on ds.doctor = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where ds.status in (1,2,3,4)" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2134,7 +2144,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String countSql = "select count(ds.id) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "from wlyy_door_doctor_status ds " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         JOIN (select b.* from base_doctor b,base_doctor_hospital dh where b.id=dh.doctor_code and dh.del = 1 and dh.org_code= '" + hospital + "') d on ds.doctor = d.code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         JOIN (select b.* from base_doctor b,base_doctor_hospital dh where b.id=dh.doctor_code and dh.del = 1 and dh.org_code= '" + hospital + "') d on ds.doctor = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where ds.status in (1,2,3,4)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> doctorList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2479,8 +2489,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        messageDO.setReceiverName(ReceiverName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        net.sf.json.JSONObject data = new net.sf.json.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("name", ReceiverName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("age", IdCardUtil.getAgeForIdcard(idCard)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("age", IdCardUtil.getAgeForIdcard(idCard)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("gender", IdCardUtil.getSexForIdcard(idCard)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2630,6 +2640,26 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return res; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 互联网医院开方后 关联上门工单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param orderId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param prescriptionCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void savePrescription(String orderId,String prescriptionCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyDoorServiceOrderDO orderDO = wlyyDoorServiceOrderDao.findOne(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setPrescriptionCode(prescriptionCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setPrescriptionTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setPrescriptionStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        wlyyDoorServiceOrderDao.save(orderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //非代预约才发送im消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(orderDO.getType() != null && orderDO.getType() != 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //发送 预约卡片信息(2101类型) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orderInfoContent.put("re_msg_type", 2);//开方完成消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            this.qucikSendIM(orderDO.getId(), orderDO.getDispatcher(), "智能助手", "2101", orderInfoContent.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *  更新医生地理位置状态 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2754,15 +2784,6 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //判断工单是否已存在,新建或者编辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isBlank(orderDO.getId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/*            SignFamily signFamily = signFamilyDao.findSignFamilyByPatient(orderDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (signFamily == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.put(ResponseContant.resultFlag, ResponseContant.fail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String failMsg = "当前服务对象未完成家庭医生签约,请完成签约后再预约上门服务!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.put(ResponseContant.resultMsg, failMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.error(failMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //已取消的订单也可以申请 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            boolean bool = wlyyDoorServiceOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    new Integer[]{WlyyDoorServiceOrderDO.Status.waitForAccept.getType(), 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2818,9 +2839,6 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and d.id = '"+orderDO.getDoctor()+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Map<String,Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/*                BaseDoctorDO doctor = doctorDao.findById(orderDO.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Hospital hospital = hospitalDao.findByCode(doctor.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doorOrderService.acceptOrder1(orderDO.getId(), doctor.getJob(), doctor.getJobName(), hospital.getLevel());*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doorOrderService.acceptOrder1(orderDO.getId(), list.get(0).get("job_title_code").toString(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        list.get(0).get("job_title_name").toString(), Integer.valueOf(list.get(0).get("org_level").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }catch (Exception e){ 
			 |