| 
					
				 | 
			
			
				@ -21,6 +21,7 @@ import com.yihu.jw.entity.hospital.message.SystemMessageDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.im.dao.ConsultDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.im.util.ImUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.emergency.EmergencyOrderVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.GpsUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.MessageUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.dao.BaseDoctorDao; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -215,7 +216,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getSecurityOrderDetail(String orderID){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getSecurityOrderDetail(String orderID,String doctor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        EmergencyOrderVO emergencyOrderVO = new EmergencyOrderVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderID); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -226,6 +227,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.error(failMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        emergencyOrderVO.setId(orderDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = basePatientDao.findById(orderDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer statustemp = Integer.valueOf(orderDO.getStatus()+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String statusName = ""; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -295,10 +297,14 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> tmp = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmp.put("name","系统预警"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmp.put("status",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmp.put(statusName,"未读"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SystemMessageDO messageDO = systemMessageDao.findByRelationCodeAndReceiver(orderDO.getId(),patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (messageDO != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNotBlank(messageDO.getIsRead())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmp.put("status",Integer.parseInt(messageDO.getIsRead())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (Integer.parseInt(messageDO.getIsRead())==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put(statusName,"已读"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            arr.add(tmp); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -327,8 +333,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> tmp = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmp.put("name","系统预警"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmp.put("status",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmp.put("statusName","未响应"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doc.getId(),orderDO.getId())!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmp.put("status",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmp.put("statusName","已响应"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                arr.add(tmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                noticeObj.put("response",arr); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -357,9 +365,20 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null != consult) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sessionId = orderDO.getPatient() + "_" + consult.getId() + "_" + consult.getType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("sessionId",sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (1==orderDO.getStatus()&&StringUtils.isNotBlank(doctor)){//查询未读数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer count = imUtil.UserSessionsUnreadMessageCount(sessionId,doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("UnRead",count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("sessionId",sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("UnRead",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("sessionId",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("UnRead",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("resultFlag", 1); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -387,34 +406,38 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setEmergencyCancel(emergencyCancel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        securityMonitoringOrderDao.save(orderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result = getSecurityOrderDetail(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result = getSecurityOrderDetail(orderId,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray getSecurityOrderList(String doctor,String serverDoctor,String patientName, String patient, String status, Integer page, Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop getSecurityOrderList(String doctor, String serverDoctor, String patientName, String patient, String status, Integer page, Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlCount = "select count(ord.id) from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String fliter = "  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select p.id patientCode,p.name,p.sex,p.photo,p.idcard,ord.id orderId,ord.number,ord.serve_desc,ord.create_time,ord.`status`,ord.doctor," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter+=" and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "base_team_member m " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(serverDoctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql +=" and ord.doctor = '"+serverDoctor+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter +=" and ord.doctor = '"+serverDoctor+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(patientName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and (ord.patient_name like '%"+patientName+"%' or p.idcard='"+patientName+"')  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter+=" and (ord.patient_name like '%"+patientName+"%' or p.idcard='"+patientName+"')  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and ord.patient='"+patient+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter+=" and ord.patient='"+patient+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and ord.status='"+Integer.parseInt(status)+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            fliter+=" and ord.status='"+Integer.parseInt(status)+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql+=" order by ord.create_time desc limit " + (page*pageSize) + "," + pageSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long count = jdbcTemplate.queryForObject(sqlCount+fliter,Long.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        fliter+=" order by ord.create_time desc limit " + (page*pageSize) + "," + pageSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql+fliter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray result = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String,Object>one:sqlResult){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -462,7 +485,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmp.put("deviceFlag","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("success",result,page,pageSize,count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>> getSecurityOrderUnCompleteList(String doctor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> result = new ArrayList<>(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -638,7 +661,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //  待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        messageUtil.createMessage("医生接单","634",doorServiceOrder.getPatient(),doorServiceOrder.getPatientName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                doorServiceOrder.getId(), doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName() ,null, doorServiceOrder.getDoctorName() + "接受了服务工单"+ doorServiceOrder.getNumber()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -721,7 +744,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result = getSecurityOrderDetail(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result = getSecurityOrderDetail(orderId,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -763,7 +786,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return getSecurityOrderDetail(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -825,7 +848,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());//已完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        one.setConclusionStatus(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        securityMonitoringOrderDao.save(one); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -846,7 +869,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception(failMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        securityMonitoringOrderDao.updateConclusionStatus(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -901,7 +924,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        // 发送微信通知  待付款 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        BasePatientDO patient = basePatientDao.findById(one.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return getSecurityOrderDetail(orderId,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 |