package com.hxzkoa.udp; import java.awt.geom.Point2D; import java.io.Console; import java.util.Iterator; import java.util.List; import com.hxzkoa.json.tb_fence; import com.hxzkoa.json.tb_map; import com.hxzkoa.json.tb_person; import com.hxzkoa.json.tb_realinwarning; import com.hxzkoa.json.tb_realkaoqing; import com.hxzkoa.json.tb_system; import com.hxzkoa.json.tb_tag; import com.hxzkoa.json.tb_track; import com.hxzkoa.json.tb_warning; import com.hxzkoa.json.tb_xunjianbaobiao; import com.hxzkoa.json.tb_xunjianset; import com.hxzkoa.util.Config; import com.hxzkoa.util.HttpUtil; import com.hxzkoa.util.IsInStartAndEndTime; import com.hxzkoa.util.IsPtInPoly; import com.hxzkoa.util.ModifyConfig; import com.hxzkoa.util.Shi_jian_cha; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class Dell_display { static /* * 1.标签实时位置display UWB标签上传的位置报文 * display,[lenth],[tagid],[baoxu],[timestamp],[layer],[x],[y],[z], * [vbat],[state],[sos],[mark] */ Music musi; static String postUrl = Config.getPostUrl(); static String url_tag_bw = postUrl + "labelManagement_search.do"; static String url_warning_bw = postUrl + "warningSummary_search.do"; static String url_realTimeWarning_bw = postUrl + "realTimeWarning_search.do"; static String url_person_bw = postUrl + "personManagement_search.do"; static String url_realAttendance_bw = postUrl + "realAttendance_search.do"; static String url_sysSetting_bw = postUrl + "sysSetting_bw.do"; static String url_label_bw_power = postUrl + "label_bw_power.do"; static String url_fenceList_bw = postUrl + "fenceList_bw.do"; static String url_xunjiansetList_bw = postUrl + "xunjiansetList_bw.do"; static String url_warning_bw_add = postUrl + "warning_bw_add.do"; static String url_realinwarning_bw_add = postUrl + "realinwarning_bw_add.do"; static String url_realinwarning_bw_remove = postUrl + "realinwarning_bw_remove.do"; static String url_track_bw_add = postUrl + "track_bw_add.do"; static String url_realAttendance_bw_add = postUrl + "realAttendance_bw_add.do"; static String url_xunjianbaobiaoList_bw = postUrl + "xunjianbaobiaoList_bw.do"; static String url_xunjianbaobiao_bw_add = postUrl + "xunjianbaobiao_bw_add.do"; static String url_xunjianbaobiao_bw_modify = postUrl + "xunjianbaobiao_bw_modify.do"; static String url_person_bw_kaoqin = postUrl + "person_bw_kaoqin.do"; static String url_person_bw_warning = postUrl + "person_bw_warning.do"; static String url_map_bw_floor = postUrl + "map_bw_floor.do"; public static String gettagid(String rees) { String[] dis = rees.split(","); // 3[tagid] :标签的ID号,唯一编号 String tagid1 = dis[2]; return tagid1; } public static void display(String message) { String[] dis = message.split(","); // 3[tagid] :标签的ID号,唯一编号 String tagid = dis[2]; System.out.print("dis:"+dis); // 4包序(0~255循环) String baoxu = dis[3]; // 5时间戳(这条报文发出的时间) String timestamp = dis[4]; // 6标签所在的层 String layer = dis[5]; // 7[x] :标签的X坐标,单位厘米 String x = dis[6].replace(".", ""); // 8[y] :标签的Y坐标,单位厘米 String y = dis[7].replace(".", ""); // 9[z] :标签的Z坐标,单位厘米 String z = dis[8]; // 10[vbat] :标签的电量信息,(0~100) String vbat = dis[9]; // 11[state] :标签的状态,静止为1,运动为0 String state = dis[10]; // 12[sos] :标签的SOS按键状态,按下为1,没有按下为0 String sos = dis[11]; // 13[mark] :标志位,区别从哪个引擎上传数据,适用于多个项目传入一个平台,默认为0 String mark = dis[12]; tb_tag tag = new tb_tag(); tag.setTag_id(tagid); tag.setPower(vbat); tag.setState(state); // 更改标签的状态和电量信息 // Tag_Dell.set_tagpower(tagid, "100"); JSONObject tagobject = JSONObject.fromObject(tag); HttpUtil.doPost(url_label_bw_power, tagobject.toString(), Config.getCharset()); // JSONObject jsonObject = JSONObject.fromObject(tag); JSONObject re_tag_bw = HttpUtil.doPost(url_tag_bw, jsonObject.toString(), Config.getCharset()); tb_tag re_tag = (tb_tag) JSONObject.toBean(JSONObject.fromObject(re_tag_bw.get("result").toString()), tb_tag.class); // tb_tag re_tag = null; JSONObject re_warning_bw = HttpUtil.doPost(url_warning_bw, jsonObject.toString(), Config.getCharset()); tb_warning re_warning = (tb_warning) JSONObject .toBean(JSONObject.fromObject(re_warning_bw.get("result").toString()), tb_warning.class); // 判断标签是否存在 System.out.print("re_warning"+re_warning); tb_warning warning = new tb_warning(); if (re_tag != null) { int powerint = Integer.parseInt(tag.getPower()); if (powerint <= 5 && re_warning == null) {// 如果标签电量小于5% warning.setType("低电量告警"); warning.setObjectid(tag.getTag_id()); warning.setStatus("未处理"); jsonObject = JSONObject.fromObject(warning); HttpUtil.doPost(url_warning_bw_add, jsonObject.toString(), Config.getCharset()); } } String filePath = Config.getBaowenConfig(); String debugSwitch = ModifyConfig.readData(filePath,"debugSwitch").toString();//调试页面打开 if (debugSwitch.contentEquals("1")) { //调试 // String debugUrl=postUrl+"debugMessage.do"; String messageJson = GetNowTime.timestamp2()+ " 收:"+message; /* Udp_Receive.debugMessage.add(messageJson); */ } // 取person // person_Dell.alert_sos(tagid,"100"); JSONObject re_person_bw = HttpUtil.doPost(url_person_bw, jsonObject.toString(), Config.getCharset()); tb_person re_person = (tb_person) JSONObject.toBean(JSONObject.fromObject(re_person_bw.get("result").toString()), tb_person.class); //修改标签的人员的SOS状态 tb_person person = new tb_person(); person.setP_tagid(tagid); person.setP_power(vbat); person.setP_sos(state); person.setP_x(x); person.setP_y(y); person.setP_floor(layer); String url_person_bw_SOS = postUrl + "person_bw_power.do"; JSONObject personObject = JSONObject.fromObject(person); HttpUtil.doPost(url_person_bw_SOS, personObject.toString(), Config.getCharset()); // 通过标签id找到某个人员对象 if (re_person != null) { // 如果sos为1需要触发语音并记录到告警数据库中 if (sos.equals("1") && re_person.getP_sos().equals("0")) { // person.setP_sos("1");// SOS告警未处理 // new PopTiP(get_Person(tagid).getP_name()+"标签id:"+tagid+" 在 // "+GetNowTime.now()+"按下SOS! ");//右下角提示弹窗信息 // new Music("systemFiles/voice/sos.wav").start();// 调用音频文件 warning.setType("SOS"); warning.setObjectid(tag.getTag_id()); warning.setStatus("未处理"); jsonObject = JSONObject.fromObject(warning); HttpUtil.doPost(url_warning_bw_add, jsonObject.toString(), Config.getCharset()); // Tb_Warnig_Dell.add_tb_warning("SOS", tagid, // "未处理",GetNowTime.now()); } } // 修改人员的电量信息, // person_Dell.alert_person_power(tagid,"100"); JSONObject personPowerObject = JSONObject.fromObject(person); String url_person_bw_power = postUrl + "person_bw_power.do"; if (re_person != null) { HttpUtil.doPost(url_person_bw_power, personPowerObject.toString(), Config.getCharset()); } // HaveOkPosDo.do_something(tagid, baoxu, disx, disy,floor, disz); // 修改标签的XY和楼层信息 // Tag_Dell.alert_xy_and_floor(tagid, x, y, floor); //tag 无xyfloor // 修改考勤中人员的xy // RealKaoqings.alert_xy(tagid, x, y); // String url_kaoqin_bw_XY = postUrl + "kaoqin_bw_XY.do"; // if (person != null) { // HttpUtil.doPost(url_kaoqin_bw_XY, personObject.toString(), Config.getCharset()); // } // 修改人员的x,y和楼层信息 // person_Dell.alert_person_xyfpo(tagid, x, y, floor, GetNowTime.sss()); String url_person_bw_XYF = postUrl + "person_bw_XYF.do"; if (re_person != null) { HttpUtil.doPost(url_person_bw_XYF, personObject.toString(), Config.getCharset()); } //取tag jsonObject = JSONObject.fromObject(tag); JSONObject re_sysSetting_bw = HttpUtil.doPost(url_sysSetting_bw, jsonObject.toString(), Config.getCharset()); tb_system system = (tb_system) JSONObject .toBean(JSONObject.fromObject(re_sysSetting_bw.get("result").toString()), tb_system.class); // 将位置信息存入历史轨迹数据库 if (system.getGuiji_sava().equals("1")) { tb_track track = new tb_track(); track.setLayer(layer); track.setTagid(tagid); track.setX(x); track.setY(y); track.setZ(z); // PutPosInHistoryDataBase.putInHistory(tagid, // String.valueOf(x),String.valueOf(y), tagheight, // floor,GetNowTime.timestamp2()); jsonObject = JSONObject.fromObject(track); HttpUtil.doPost(url_track_bw_add, jsonObject.toString(), Config.getCharset()); } // 将位置信息放入轨迹集合,如果不是不显示实时轨迹 // if (Systems.get_real_track_time() != 0) { // Dell_ReallPoint.insertpoid(tagid, x, y, floor); // } JSONObject re_fenceList_bw = HttpUtil.doPost(url_fenceList_bw, "", "utf-8"); JSONArray jsonarray = JSONArray.fromObject(re_fenceList_bw.get("result").toString()); @SuppressWarnings("unchecked") List tb_fenceList = (List)JSONArray.toCollection(jsonarray, tb_fence.class); // @SuppressWarnings("unchecked") // List tb_fenceList = (List) JSONObject.toBean(JSONObject.fromObject(re_fenceList_bw.get("result").toString()), tb_fence.class); // 如果围栏存在 if (tb_fenceList.size() != 0) { tb_map map = new tb_map(); String floor = layer; map.setFloor(floor); jsonObject = JSONObject.fromObject(map); JSONObject re_map_bw_floor = HttpUtil.doPost(url_map_bw_floor, jsonObject.toString(), Config.getCharset()); map = (tb_map) JSONObject.toBean(JSONObject.fromObject(re_map_bw_floor.get("result").toString()), tb_map.class); if (map != null) { // 地图的偏移量 String x0 = map.getX0_length(); String y0 = map.getY0_width(); Point2D.Double point = new Point2D.Double(Integer.parseInt(x) - Integer.parseInt(x0), Integer.parseInt(y) - Integer.parseInt(y0)); // PointIsInKaoQing piikq = // PointIsInKaoQing.get_PointIsInKaoQing(); // PointISInWarning point_is_in_warning = // PointISInWarning.get_point_is_inwaring(); jsonObject = JSONObject.fromObject(tag); JSONObject re_realAttendance_bw = HttpUtil.doPost(url_realAttendance_bw, jsonObject.toString(), Config.getCharset()); System.out.print(re_realAttendance_bw); if (re_realAttendance_bw!=null){ tb_realkaoqing realkaoqing = (tb_realkaoqing) JSONObject.toBean( JSONObject.fromObject(re_realAttendance_bw.get("result").toString()), tb_realkaoqing.class); // 判断标签是否在考勤区域 is_in_kaoqing_fence(tb_fenceList, realkaoqing, person, tagid, GetNowTime.timestamp2(), point); } JSONObject re_realTimeWarning_bw = HttpUtil.doPost(url_realTimeWarning_bw, jsonObject.toString(), Config.getCharset()); if (re_realTimeWarning_bw!=null){ tb_realinwarning realinwarning = (tb_realinwarning) JSONObject.toBean( JSONObject.fromObject(re_realTimeWarning_bw.get("result").toString()), tb_realinwarning.class); // 判断标签是否在告警区域 is_in_warning_fence(tb_fenceList, realinwarning, person, tagid, GetNowTime.timestamp2(), point, floor); } JSONObject re_xunjiansetList_bw = HttpUtil.doPost(url_xunjiansetList_bw, "", Config.getCharset()); if(re_xunjiansetList_bw!=null){ JSONArray xunjianArray = JSONArray.fromObject(re_xunjiansetList_bw.get("result").toString()); @SuppressWarnings("unchecked") List tb_xunjiansetList = (List)JSONArray.toCollection(xunjianArray, tb_xunjianset.class); // 判断标签是否再巡检区域 tag_is_in_xunjianfence(tb_fenceList, tb_xunjiansetList, person, tagid, GetNowTime.timestamp2(), point, floor); } // point = null; // piikq = null; // point_is_in_warning = null; } // else { // if (ok) { // ShowMessage.zidingyi_24("地图" + floor + "层不存在!"); // ok = false; // } // } } /** 处理轨迹点 */ // Have_55AA01_do.dell_gui(); } public static void is_in_kaoqing_fence(List tb_fenceList, tb_realkaoqing realkaoqing, tb_person person, String tagid, String intime, Point2D.Double point) { if (tb_fenceList.size() != 0) {// 如果围栏区域存在则执行 Iterator it = tb_fenceList.iterator(); // int jishu = 0; JSONObject jsonObject = new JSONObject(); while (it.hasNext()) { tb_fence fence = it.next(); String startime = fence.getStart();// 围栏生效开始时间 String stoptime = fence.getStop();// 围栏生效结束时间 String name = fence.getName(); // 只有在生效时间内才判断点在不在区域内 boolean zai = IsInStartAndEndTime.belongCalendar(intime, startime, stoptime);// 判断是否在围栏生效的时间内 // 在围栏生效时间内 if (zai) { boolean ispoly = IsPtInPoly.inPoly(point, fence.getPts());// 判断ID坐标是否在围栏区域内 // 如果在考勤区域内 if (ispoly) { // 判断在不在实时考勤集合中,如果不在则需要添加一条记录 // if(!RealKaoqings.isIn_kaoqing(tagid)) { if (realkaoqing == null) { String bumen = "未绑定"; String tag_name = "未绑定"; String phone = "未绑定"; int x = 0; int y = 0; if (person != null) { tag_name = person.getP_name(); bumen = person.getP_department(); phone = person.getP_phone(); x = Integer.parseInt(person.getP_x()); y = Integer.parseInt(person.getP_y()); } // 实时考勤集合中添加一个记录 // 向实时考勤集合添加一条考勤数据 realkaoqing = new tb_realkaoqing(); realkaoqing.setArea(name); realkaoqing.setName(tag_name); realkaoqing.setBumen(bumen); realkaoqing.setTagid(tagid); realkaoqing.setBeizhu(phone); jsonObject = JSONObject.fromObject(realkaoqing); HttpUtil.doPost(url_realAttendance_bw_add, jsonObject.toString(), Config.getCharset()); // new_real_kao_qing.setX(x); // new_real_kao_qing.setY(y); // RealKaoqings.add_real_kaoqing(name, tag_name, // bumen, tagid, intime, phone, x, y); // 数据库中添加一条记录 // jishu++; // suffix.append("(default,'"+name+"','"+tag_name+"','"+bumen+"','"+tagid+"','"+intime+"','"+phone+"'),"); // if (jishu == 1) { // StringBuffer sql =new StringBuffer(prefix + // suffix.substring(0, suffix.length() - 1)) ; // // 构建完整sql // DatabaseManagement.insert_fast(sql.toString()); // suffix = new StringBuffer(); // 清空上一次添加的数据 // jishu = 0; // } // 标签进入考勤区域将实时位置中考勤状态修改为1 person.setP_tagid(tagid); person.setP_kaoqing("1"); jsonObject = JSONObject.fromObject(person); HttpUtil.doPost(url_person_bw_kaoqin, jsonObject.toString(), Config.getCharset()); // person_Dell.alert_kaoqing(tagid, "1"); } } else {// 如果不在考勤区域内 // 如果在实时考勤集合中存在 // TbRealKaoQing // tbkq=RealKaoqings.get_real_kaoqing(tagid,name); if (realkaoqing != null) { String in = realkaoqing.getIntime(); String alltime = Shi_jian_cha.getAllTime(in, intime); // suffix2.append("('" + tbkq.getArea() + "','" + // tbkq.getName() + "','" + tbkq.getBumen() // + "','" + tbkq.getTagid() + "','" + in + "','" + // intime + "','" + alltime + "'),"); // if (jishu == 1) { // StringBuffer sql = new StringBuffer(prefix + // suffix.substring(0, suffix.length() - 1)); // // 构建完整sql // DatabaseManagement.insert_fast(sql.toString()); // System.out.println(sql.toString()); // suffix2 = null; // 清空上一次添加的数据 // } // 删除实时告警数据中的记录 tb_realinwarning realinwarning = new tb_realinwarning(); realinwarning.setTagid(tagid); jsonObject = JSONObject.fromObject(realinwarning); HttpUtil.doPost(url_realinwarning_bw_remove, jsonObject.toString(), Config.getCharset()); // RealKaoqings.remove_real_kaoqing(tagid); // 标签出考勤区域将实时位置中考勤状态修改为0 person.setP_tagid(tagid); person.setP_kaoqing("0"); jsonObject = JSONObject.fromObject(person); HttpUtil.doPost(url_person_bw_kaoqin, jsonObject.toString(), Config.getCharset()); // person_Dell.alert_kaoqing(tagid, "0"); // deletesql = null; } } } } } } public static void is_in_warning_fence(List tb_fenceList, tb_realinwarning realinwarning, tb_person person, String tagid, String intime, Point2D.Double point, String floor) { if (person != null) {// 如果标签存在 if (tb_fenceList.size() != 0) {// 如果围栏区域存在则执行 Iterator it = tb_fenceList.iterator(); JSONObject jsonObject = new JSONObject(); while (it.hasNext()) { tb_fence fence = it.next(); String startime = fence.getStart();// 围栏生效开始时间 String stoptime = fence.getStop();// 围栏生效结束时间 String area = fence.getName();// 区域名称 // 只有在生效时间内才判断点在不在区域内 boolean zai = IsInStartAndEndTime.belongCalendar(intime, startime, stoptime);// 判断是否在围栏生效的时间内 // 在围栏生效时间内 if (zai) { boolean ispoly = IsPtInPoly.inPoly(point, fence.getPts());// 判断ID坐标是否在围栏区域内 // 如果在告警区域内 if (ispoly) { // 判断在不在实时告警集合中,如果不在则需要添加一条记录 if (realinwarning == null) { String bumen = person.getP_department(); if(bumen==null){ bumen = "系统默认"; } String name = person.getP_name(); if(name==null){ name = "未绑定"; } String alltime = ""; String outtime = ""; String phone = person.getP_phone(); tb_realinwarning new_real_warning = new tb_realinwarning(); new_real_warning.setArea(area); new_real_warning.setTagid(tagid); new_real_warning.setIntime(intime); new_real_warning.setBumen(bumen); new_real_warning.setName(name); // 实时告警集合中添加一个记录 jsonObject = JSONObject.fromObject(new_real_warning); HttpUtil.doPost(url_realinwarning_bw_add, jsonObject.toString(), Config.getCharset()); // RealWarnings.set_real_warning(new_real_warning); // 数据库中添加一条记录 // String sql = "INSERT tb_historyinwarning (" + // "id," + "area," + "name," + "bumen," // + "tagid," + "intime," + "outtime," + // "alltime) VALUES " + "(default,'" + area // + "','" + name + "','" + bumen + "','" + // tagid + "','" + intime + "','" // + outtime + "','" + alltime + "')"; // if (DatabaseManagement.update(sql) != 0) { // InsertData.sosInsertTbWarning(tagid, area, // "未处理", intime); // String sql2 = "INSERT tb_realinwarning (" + // "id," + "area," + "name," + "bumen," // + "tagid," + "intime) VALUES " + "(default,'" // + area + "','" + name + "','" // + bumen + "','" + tagid + "','" + intime + // "')"; // DatabaseManagement.update(sql2); // } // pop = new PopTiP(name + "-" + tagid + "进入" + // area + "! " + intime);// 右下角提示弹窗信息 musi = new Music("systemFiles/voice/warning.wav");// 调用音频文件 musi.start(); // 数据转发 // Warnig.in_warning(tagid, area, "RGN_IN", // floor); // 标签进入告警区域将实时位置中告警状态修改为1 person.setP_tagid(tagid); person.setP_sos("1"); jsonObject = JSONObject.fromObject(person); HttpUtil.doPost(url_person_bw_warning, jsonObject.toString(), Config.getCharset()); // person_Dell.alert_isin_fence(tagid, "1"); // new_real_warning = null; } } else {// 如果不在告警区域内 // 如果在实时告警集合中存在 // TbRealInWarning tbwn = // RealWarnings.get_real_warning(tagid, area); if (realinwarning != null) { String in = realinwarning.getIntime(); String alltime = Shi_jian_cha.getAllTime(in, intime); String sql = "INSERT tb_historyinwarning (" + "id," + "area," + "name," + "bumen," + "tagid," + "intime," + "outtime," + "alltime) VALUES " + "(default,'" + realinwarning.getArea() + "','" + realinwarning.getName() + "','" + realinwarning.getBumen() + "','" + realinwarning.getTagid() + "','" + in + "','" + intime + "','" + alltime + "')"; // DatabaseManagement.update(sql); // deleteRealkq = new StringBuffer("Delete from // tb_realinwarning where tagid='" + tagid // + "'and area='" + area + "'"); // DatabaseManagement.update(deleteRealkq.toString());// // 删除实时告警数据中的记录 realinwarning.setTagid(tagid); jsonObject = JSONObject.fromObject(realinwarning); HttpUtil.doPost(url_realinwarning_bw_remove, jsonObject.toString(), Config.getCharset()); // RealWarnings.remove_real_warning(tbwn); // // 标签出告警区域将实时位置中告警状态修改为0 person.setP_tagid(tagid); person.setP_sos("0"); jsonObject = JSONObject.fromObject(person); HttpUtil.doPost(url_person_bw_warning, jsonObject.toString(), Config.getCharset()); // person_Dell.alert_isin_fence(tagid, "0"); // 数据转发 // Warnig.in_warning(tagid, area, "RGN_OUT", // floor); // deleteRealkq = null; } } } } } } } /** 标签是否在巡检区域内 */ @SuppressWarnings("unused") public static void tag_is_in_xunjianfence(List tb_fenceList, List tb_xunjiansetList, tb_person person, String tagid, String intime, Point2D.Double point, String floor) { // 如果巡检区域存在 if (tb_fenceList.size() != 0) { JSONObject jsonObject = new JSONObject(); // 遍历围栏对象 /** 获取所有巡检区域电子围栏 */ tb_xunjianset xunjianset = null; for (int i = 0; i < tb_fenceList.size(); i++) { String type = tb_fenceList.get(i).getType(); if (type.equals("巡检区域")) { // 围栏生效开始时间 String startime = tb_fenceList.get(i).getStart(); // 围栏生效结束时间 String stoptime = tb_fenceList.get(i).getStop(); // 是否在围栏生效时间内 boolean timeisok = IsInStartAndEndTime.belongCalendar(intime, startime, stoptime); // 如果是在围栏生效时间内则执行 if (timeisok) { // 区域名称 String area = tb_fenceList.get(i).getName(); //生成巡检报表对象 tb_xunjianbaobiao xunjianbaobiao = new tb_xunjianbaobiao(); // 判断标签坐标是否在生效的围栏区域内如果在则执行 if (IsPtInPoly.inPoly(point, tb_fenceList.get(i).getPts())) { // 通过区域名称找到该巡检区域对象 // Tb_xunjianset xjs = // Dell_xunjianset.get_xjst(area); // 该巡检区域指定的巡检人员 for (int j = 0; j < tb_xunjiansetList.size(); j++) { tb_xunjianset tb_xunjianset = tb_xunjiansetList.get(j); if (area.equals(tb_xunjianset.getQuyu())) { xunjianset = tb_xunjianset; } } String tagid1 = xunjianset.getTagid(); // 如果该标签id等于巡检区域指定的标签ID或者巡检区域没有指定巡检标签ID则继续执行 if (tagid1.equals("所有标签") || tagid1.equals(tagid)) { // 如果标签没有在巡检记录中存在 for (int j = 0; j < tb_xunjiansetList.size(); j++) { tb_xunjianset tb_xunjianset = tb_xunjiansetList.get(j); if (tagid1.equals(tb_xunjianset.getTagid())) { xunjianset = tb_xunjianset; } } if (xunjianset == null) { String name = person.getP_name(); xunjianbaobiao.setName(name); xunjianbaobiao.setTagid(tagid1); xunjianbaobiao.setQuyu(area); xunjianbaobiao.setBianhao(xunjianset.getXunshu()); // 插入一条巡检记录 jsonObject = JSONObject.fromObject(xunjianbaobiao); HttpUtil.doPost(url_xunjianbaobiao_bw_add, jsonObject.toString(), Config.getCharset()); // Dell_xunjianbaobiao.insert(name, tagid, // area, //xjs.getXunshu()); } } // 如果不在生效的区域内 } else { // 如果在巡检记录中有记录说明出了巡检区域 for (int j = 0; j < tb_xunjiansetList.size(); j++) { tb_xunjianset tb_xunjianset = tb_xunjiansetList.get(j); if (area.equals(tb_xunjianset.getQuyu())) { xunjianset = tb_xunjianset; } } if (xunjianset != null) { String tagid1 = xunjianset.getTagid(); xunjianbaobiao.setQuyu(area); xunjianbaobiao.setTagid(tagid); jsonObject = JSONObject.fromObject(xunjianbaobiao); JSONObject re_xunjianbaobiaoList_bw = HttpUtil.doPost(url_xunjianbaobiaoList_bw,jsonObject.toString(), Config.getCharset()); if (re_xunjianbaobiaoList_bw!=null){ tb_xunjianbaobiao re_xunjianbaobiao = (tb_xunjianbaobiao) JSONObject.toBean(JSONObject.fromObject(re_xunjianbaobiaoList_bw.get("result").toString()), tb_xunjianbaobiao.class); if (re_xunjianbaobiao!=null){ // 生成一条巡检记录 String baobiaointime=re_xunjianbaobiao.getIntime(); String outtime=GetNowTime.now(); String alltime=String.valueOf(TiemDell.getTimeDelta(outtime, baobiaointime)); int cha=TiemDell.getTimeDelta(outtime, baobiaointime); int nedstoptime=Integer.parseInt(xunjianset.getNeedstoptime()); //要求巡检的时间段 String needintime=xunjianset.getStartime(); //是否在要求巡检的时间段巡检 boolean inyaoqiushijian=true; //有要求巡检时间段 //判断现在时间和要求的最晚巡检时间的差,如果现在的时间大于要求的巡检时间 int cha1=Shi_jian_cha_sss.get_time_cha_HMS(GetNowTime.HH_MM_SS(), needintime); String succ="0"; if(cha>nedstoptime) { succ="1"; } if(inyaoqiushijian && succ.equals("1")) { succ="2"; } String name = person.getP_name(); xunjianbaobiao.setName(name); xunjianbaobiao.setTagid(tagid1); xunjianbaobiao.setQuyu(type); xunjianbaobiao.setBianhao(re_xunjianbaobiao.getBianhao()); xunjianbaobiao.setSucc(succ); xunjianbaobiao.setOuttime(outtime); xunjianbaobiao.setAlltime(alltime); jsonObject = JSONObject.fromObject(xunjianset); HttpUtil.doPost(url_xunjianbaobiao_bw_modify, jsonObject.toString(), Config.getCharset()); } } // Dell_xunjianbaobiao.alert(tagid, area); } } } } } } } }