| 
					
				 | 
			
			
				@ -27,8 +27,10 @@ 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.http.ResponseEntity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.client.RestTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.SimpleDateFormat; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -84,7 +86,8 @@ public class DeviceUploadService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String wxId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientFamilyService patientFamilyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private RestTemplate restTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result uploadDevicesData(String dataJson, HttpServletRequest request)throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ObjectMapper objectMapper = new ObjectMapper(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -163,50 +166,62 @@ public class DeviceUploadService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNotBlank(typeName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setTitle(typeName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setType("42");//42体征设备测量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setSender("system"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setSenderName("养护助手"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setRelationCode(result.getId()+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setReceiver(patientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setReceiverName(patientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setOver("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setCode(type);//与体征类型对应 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray errorIndex = healthIndexUtil.verifyHealthIndex(Integer.parseInt(type),result.getValue1(),result.getValue2(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            result.getValue3(),result.getValue4(),result.getValue5(),result.getValue6(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            result.getValue7()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setData(JSON.toJSONString(errorIndex,SerializerFeature.WriteNullStringAsEmpty)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //推送socket 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("title",typeName2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("code",messageDO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("content",messageDO.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("relation_code",messageDO.getRelationCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("content_type",42); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("content_notice",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String content_notice = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (int i=0;i<errorIndex.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        com.alibaba.fastjson.JSONObject tmp = errorIndex.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (0!=tmp.getInteger("error")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            result.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String sql = "SELECT py_code FROM wlyy_hospital_sys_dict WHERE dict_name = 'pushOnOff' AND dict_code ='"+6+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String onOff= jdbcTemplate.queryForObject(sql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Boolean kg = Boolean.parseBoolean(onOff); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (kg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setTitle(typeName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setType("42");//42体征设备测量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setSender("system"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setSenderName("养护助手"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setRelationCode(result.getId() + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setReceiver(patientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setReceiverName(patientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setOver("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ResponseEntity<String> forEntity = restTemplate.getForEntity("http://svr-cloud-care:10301/common/open/wordToVoice?text={1}", String.class, typeName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(forEntity.getBody()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (jsonObject.getInteger("status") == 200) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            messageDO.setAudioUrl(jsonObject.getString("message")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (1 == tmp.getInteger("error")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            content_notice += tmp.getString("indexName")+"、"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setCode(type);//与体征类型对应 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONArray errorIndex = healthIndexUtil.verifyHealthIndex(Integer.parseInt(type), result.getValue1(), result.getValue2(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                result.getValue3(), result.getValue4(), result.getValue5(), result.getValue6(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                result.getValue7()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setData(JSON.toJSONString(errorIndex, SerializerFeature.WriteNullStringAsEmpty)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //推送socket 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message.put("title", typeName2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message.put("code", messageDO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message.put("content", messageDO.getData()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message.put("relation_code", messageDO.getRelationCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message.put("content_type", 42); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message.put("content_notice", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String content_notice = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (int i = 0; i < errorIndex.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            com.alibaba.fastjson.JSONObject tmp = errorIndex.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (0 != tmp.getInteger("error")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                result.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (1 == tmp.getInteger("error")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                content_notice += tmp.getString("indexName") + "、"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (StringUtils.isNotBlank(content_notice)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            content_notice = content_notice.substring(0, content_notice.length() - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            message.put("content_notice", "您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1", content_notice)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1", content_notice)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            dataPushLogUtil.updContactStatus(deviceSn, 1, true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            dataPushLogUtil.updContactStatus(deviceSn, 1, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        patientHealthIndexDao.save(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        systemMessageDao.save(messageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        imUtil.sendPatientSystemMessage(messageDO.getReceiver(), JSON.toJSONString(message, SerializerFeature.WriteMapNullValue)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank(content_notice)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        content_notice = content_notice.substring(0,content_notice.length()-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dataPushLogUtil.updContactStatus(deviceSn,1,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dataPushLogUtil.updContactStatus(deviceSn,1,false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientHealthIndexDao.save(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    systemMessageDao.save(messageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //发送模板消息通知家属 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<Map<String,Object>> families = patientFamilyService.getPatientFamilyList(patientDO.getId(),"3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (families.size()>0){ 
			 |