package jiekou;
|
import java.util.HashMap;
|
import java.util.Map;
|
import java.util.Vector;
|
import com.alibaba.fastjson.JSONObject;
|
import BaoWen.DellMessage;
|
import BaoWen.Udp_Out;
|
import Method.GetNowTime;
|
import person.Person;
|
import person.person_Dell;
|
import static Method.GetNowTime.timestamp;
|
|
public class Custom1 {
|
static String timestamp;
|
/**data_type; Êý¾ÝÀàÐÍString; ˵Ã÷£ºÊý¾ÝÀàÐÍ£¬¶¨Î»Êý¾ÝΪ¡°1¡±
|
* tag_id; Êý¾ÝÀàÐÍString; ˵Ã÷£º¶¨Î»±êÇ©id£¬Ê®Áù½øÖÆ
|
* tag_id_dec; Êý¾ÝÀàÐÍString; ˵Ã÷£º¶¨Î»±êÇ©id£¬Ê®½øÖÆ
|
* x; Êý¾ÝÀàÐÍString; ˵Ã÷£ºX×ø±ê
|
* y; Êý¾ÝÀàÐÍString; ˵Ã÷£ºY×ø±ê
|
* z; Êý¾ÝÀàÐÍString; ˵Ã÷£ºZ×ø±ê£¬Ä¬ÈÏ1. 000000
|
* floor; Êý¾ÝÀàÐÍString; ˵Ã÷£º±êÇ©ËùÔڵIJã
|
* timestamp; Êý¾ÝÀàÐÍString; ˵Ã÷£º¶¨Î»Ê±¼ä´Á£¬µ¥Î»:ºÁÃë
|
* sn; Êý¾ÝÀàÐÍString; ˵Ã÷£º¶¨Î»ÐòºÅ£¬0-255Ò»¸öÖÜÆÚ
|
* battery; Êý¾ÝÀàÐÍString; ˵Ã÷£º±êÇ©µç³ØÊ£Óàµçѹ£¬µ¥Î»£ºV £»-1±íʾ³õʼ»¯£»
|
* heart_rates; Êý¾ÝÀàÐÍString; ˵Ã÷£ºÐÄÂÊÊý¾Ý, heart_rate_val£ºÊý¾ÝÖµ
|
* systolic_val; Êý¾ÝÀàÐÍString; ˵Ã÷£ºÑªÑ¹¸ßÖµ£¨ÊÕËõѹ£©£»-1±íʾ³õʼ»¯£»
|
* diastolic_val; Êý¾ÝÀàÐÍString; ˵Ã÷£ºÑªÑ¹µÍÖµ£¨ÊæÕÅѹ£© £»-1±íʾ³õʼ»¯£»
|
* oxygen_val; Êý¾ÝÀàÐÍString; ˵Ã÷£ºÑªÑõ£¨Î´ÆôÓã© £»-1±íʾ³õʼ»¯£»
|
* temp_val; Êý¾ÝÀàÐÍString; ˵Ã÷£ºÎ¶ȣ¨Î´ÆôÓã© £»-1±íʾ³õʼ»¯£»
|
* anchors Array µ±Ç°¶¨Î»»ùÕ¾£¬Ò»¸ö»òÕß¶à¸ö £»-1±íʾ³õʼ»¯£»
|
* events Array ±êǩʼþ£¬event_typeÒ»¸ö»òÕß¶à¸ö
|
* MOVE ÒÆ¶¯ £»-1±íʾ³õʼ»¯£»0±íʾ¾²Ö¹£¬1±êÇ©ÒÆ¶¯
|
* SOS °´Å¥£»-1±íʾ³õʼ»¯£»0±íʾûÓа´Ï£¬1±íʾ°´ÏÂ
|
* MOTIONLESS ¾²Ö¹ £»-1±íʾ³õʼ»¯£»0±íʾ¾²Ö¹£¬1±íʾδ¾²Ö¹
|
* LOCK Ëø×¡ £»-1±íʾ³õʼ»¯£»0±íʾûÓÐËø×¡£¬1±íÊ¾Ëø×¡
|
* DISMANTLE ²ð³ý£»-1±íʾ³õʼ»¯£»0±íʾ²ð³ý£¬1±íʾûÓвð³ý6
|
* */
|
|
public static void costom1out(String tagid){
|
Person person=person_Dell.get_Person(tagid);
|
if(person==null) {
|
return;
|
}
|
String tag_id_dec=person.getP_tagid();
|
String tag_id=DellMessage.decodeHEX(tag_id_dec)+"";
|
String x=String.valueOf(person.getP_x());
|
String y=String.valueOf(person.getP_y());
|
String z=String.valueOf(person.getP_z());
|
double x1 = Double.parseDouble(x)/100;
|
double y1 = Double.parseDouble(y)/100;
|
double z1 = Double.parseDouble(z)/100;
|
String floor=person.getP_floor();
|
timestamp=String.valueOf(GetNowTime.timestamp2());
|
|
String sn=person.getSn();
|
String battery=person.getP_power();
|
// String MOVE=person.getJingzhi();
|
// String SOS=person.getSos_state();
|
// String MOTIONLESS=person.getSleep();
|
// String LOCK=person.getLOCK();
|
// String DISMANTLE=person.getTagoff();
|
|
JSONObject json = new JSONObject(true);
|
json.put("data_type", "1");
|
json.put("tag_id_dec", tag_id_dec);
|
json.put("tag_id", tag_id);
|
json.put("x", String.valueOf(x1));
|
json.put("y", String.valueOf(y1));
|
json.put("z", String.valueOf(z1));
|
json.put("floor", floor);
|
json.put("timestamp", String.valueOf(timestamp(timestamp)));
|
json.put("sn", sn);
|
json.put("battery",battery);
|
json.put("heart_rates",heart_rate_val(person));
|
json.put("blood_pressure",blood_pressure(person));
|
json.put("blood_oxygen",blood_blood_oxygen( person));
|
json.put("temperature",temperature( person));
|
json.put("anchors",getanchorids(person));
|
json.put("events",getEvents(person));
|
Udp_Out.coustom1_udptcp_out(json.toString(), tag_id_dec);
|
}
|
|
/**»ñÈ¡²â¾à»ùÕ¾µÄ¼¯ºÏ*/
|
public static Object[] getanchorids(Person person){
|
String[] anchorids=person.getAnchors();
|
if(anchorids==null) {
|
return null;
|
}
|
int size=anchorids.length;
|
Object[] bbb = new Object[size];
|
for (int i = 0; i < size; i++) {
|
Map<String, String> hash=new HashMap<String, String>();
|
hash.put("anchar_id", anchorids[i]);
|
bbb[i] = hash;
|
}
|
return bbb;
|
}
|
|
/**»ñµÃ±êǩʼþ**/
|
@SuppressWarnings("rawtypes")
|
public static Object[] getEvents(Person person){
|
|
Vector<Map> vector=new Vector<Map>();
|
Map<String, String> hash=new HashMap<String, String>();
|
Map<String, String> hash1=new HashMap<String, String>();
|
Map<String, String> hash2=new HashMap<String, String>();
|
Map<String, String> hash3=new HashMap<String, String>();
|
if ("0".equals(person.getTagoff())){
|
hash.put("event_type","DISMANTLE");
|
vector.add(hash);
|
}
|
if ("0".equals(person.getJingzhi())){
|
hash1.put("event_type","MOVE");
|
vector.add(hash1);
|
}
|
if ("1".equals(person.getJingzhi())){
|
hash1.put("event_type","MOTIONLESS");
|
vector.add(hash1);
|
}
|
if ("1".equals(person.getP_sos())){
|
hash2.put("event_type","SOS");
|
vector.add(hash2);
|
}
|
if ("1".equals(person.getXiumian())){
|
hash3.put("event_type","LOCK");
|
vector.add(hash3);
|
}
|
Object[] objects=new Object[vector.size()];
|
for (int i = 0; i < vector.size(); i++) {
|
objects[i]=vector.get(i);
|
}
|
|
return objects;
|
}
|
|
/**»ñÈ¡heart_rates¼¯ºÏ*/
|
public static Map<String, String> heart_rate_val(Person person){
|
String heart_rates=person.getBaoliu16();
|
int i = Integer.parseInt(heart_rates);
|
|
if (i<=0){
|
i=70;
|
}
|
Map<String, String> hash=new HashMap<>();
|
hash.put("heart_rate_val", String.valueOf(i));
|
return hash;
|
}
|
|
/**»ñÈ¡blood_pressure¼¯ºÏ*/
|
public static Map<String, String> blood_pressure(Person person){
|
String systolic_val=person.getSystolic_val();
|
int i = Integer.parseInt(systolic_val);
|
if (i<0){
|
i=0;
|
}
|
String diastolic_val=person.getDiastolic_val();
|
int i1 = Integer.parseInt(diastolic_val);
|
if (i1<0){
|
i1=0;
|
}
|
Map<String, String> hash=new HashMap<String, String>();
|
hash.put("systolic_val", String.valueOf(i));
|
hash.put("diastolic_val", String.valueOf(i1));
|
hash.put("timestamp", String.valueOf(timestamp(timestamp)));
|
|
return hash;
|
}
|
|
/**»ñÈ¡blood_oxygen¼¯ºÏ*/
|
public static Map<String, String> blood_blood_oxygen(Person person){
|
String oxygen_val=person.getOxygen_val();
|
int i = Integer.parseInt(oxygen_val);
|
if (i<0){
|
i=0;
|
}
|
Map<String, String> hash=new HashMap<String, String>();
|
hash.put("oxygen_val",String.valueOf(i));
|
hash.put("timestamp", String.valueOf(timestamp(timestamp)));
|
return hash;
|
}
|
|
/**»ñÈ¡temperature¼¯ºÏ*/
|
public static Map<String, String> temperature(Person person){
|
String temp_val=person.getTemp_val();
|
int i1 = Integer.parseInt(temp_val);
|
if (i1<0){
|
i1=0;
|
}
|
Map<String, String> hash=new HashMap<String, String>();
|
hash.put("temp_val",String.valueOf(i1));
|
hash.put("timestamp", String.valueOf(timestamp(timestamp)));
|
|
return hash;
|
}
|
|
|
|
}
|