| 
					
				 | 
			
			
				@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.sun.org.apache.xerces.internal.xs.datatypes.ByteList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.DeviceDetailDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.PatientDeviceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.DeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.PatientDeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.sign.ServicePackageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.org.BaseOrgDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DeviceDetail; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -16,6 +18,7 @@ import com.yihu.jw.org.dao.BaseOrgDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.base.BaseRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.models.auth.In; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -29,10 +32,7 @@ import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.DecimalFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/*** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -60,6 +60,11 @@ public class DetectionPlatformService  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DeviceDetailDao deviceDetailDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseOrgDao orgDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DeviceService deviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ServicePackageService servicePackageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 体征监测 安防监护 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -528,4 +533,55 @@ public class DetectionPlatformService  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return object; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object >> findSignOlder(String doctorId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "and m.doctor_code = '"+doctorId+"' and m.del = '1' and  p.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ORDER BY online desc,p.ykt_id desc,signStatus desc "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei,p.residential_area residentialArea  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "and m.doctor_code = '"+doctorId+"' and m.del = '1' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlLife= "SELECT COUNT(*) from base_life_care_order "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlDevice = "SELECT pd.category_code deviceFlag, IFNULL(d.contact_status,0) status from wlyy_patient_device pd,wlyy_devices d"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String,Object> map : list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String paientId = map.get("id").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String idcard = map.get("idcard").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("age", IdCardUtil.getAgeForIdcard(idcard)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //签约医生标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> doctorList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> helperList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("helper", helperList.size()>0?1:0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("doctor", doctorList.size()>0?1:0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String filterDevice = " WHERE pd.device_sn = d.device_code and pd.user = '"+paientId+"' ORDER BY deviceFlag,status desc"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> deviceList = jdbcTemplate.queryForList(sqlDevice+filterDevice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Iterator it = deviceList.listIterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<Object,Object> deviceMap = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            while (it.hasNext()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> tmp = (Map<String,Object>)it.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(deviceMap.containsKey(tmp.get("deviceFlag"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    it.remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    deviceMap.put(tmp.get("deviceFlag"),tmp.get("deviceFlag")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String filter = " where patient = '"+paientId+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("lifeCare",lifeCare); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("emergency",emergency); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("security",security); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("devices",deviceList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |