|  |  |  | 
|---|
|  |  |  | //                        if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置 | 
|---|
|  |  |  | //                            processNotifyMobilePosition(evt, itemDevice); | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice); | 
|---|
|  |  |  | DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device); | 
|---|
|  |  |  | deviceChannel.setDeviceId(take.getDevice().getDeviceId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | channelList.add(deviceChannel); | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理设备位置的更新 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param evt, itemDevice | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void processNotifyMobilePosition(RequestEvent evt, Element itemDevice) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 回复 200 OK | 
|---|
|  |  |  | Element rootElement = getRootElement(evt); | 
|---|
|  |  |  | MobilePosition mobilePosition = new MobilePosition(); | 
|---|
|  |  |  | Element deviceIdElement = rootElement.element("DeviceID"); | 
|---|
|  |  |  | String deviceId = deviceIdElement.getTextTrim().toString(); | 
|---|
|  |  |  | Device device = redisCatchStorage.getDevice(deviceId); | 
|---|
|  |  |  | if (device != null) { | 
|---|
|  |  |  | if (!StringUtils.isEmpty(device.getName())) { | 
|---|
|  |  |  | mobilePosition.setDeviceName(device.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String time = XmlUtil.getText(itemDevice, "Time"); | 
|---|
|  |  |  | if(time==null){ | 
|---|
|  |  |  | time =  XmlUtil.getText(itemDevice, "EndTime"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mobilePosition.setTime(time); | 
|---|
|  |  |  | String longitude = XmlUtil.getText(itemDevice, "Longitude"); | 
|---|
|  |  |  | if(longitude!=null) { | 
|---|
|  |  |  | mobilePosition.setLongitude(Double.parseDouble(longitude)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String latitude = XmlUtil.getText(itemDevice, "Latitude"); | 
|---|
|  |  |  | if(latitude!=null) { | 
|---|
|  |  |  | mobilePosition.setLatitude(Double.parseDouble(latitude)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Speed"))) { | 
|---|
|  |  |  | mobilePosition.setSpeed(Double.parseDouble(XmlUtil.getText(itemDevice, "Speed"))); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | mobilePosition.setSpeed(0.0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Direction"))) { | 
|---|
|  |  |  | mobilePosition.setDirection(Double.parseDouble(XmlUtil.getText(itemDevice, "Direction"))); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | mobilePosition.setDirection(0.0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Altitude"))) { | 
|---|
|  |  |  | mobilePosition.setAltitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Altitude"))); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | mobilePosition.setAltitude(0.0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mobilePosition.setReportSource("Mobile Position"); | 
|---|
|  |  |  | // 默认来源坐标系为WGS-84处理 | 
|---|
|  |  |  | Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude()); | 
|---|
|  |  |  | logger.info("GCJ02坐标:" + gcj02Point[0] + ", " + gcj02Point[1]); | 
|---|
|  |  |  | mobilePosition.setGeodeticSystem("GCJ-02"); | 
|---|
|  |  |  | mobilePosition.setCnLng(gcj02Point[0] + ""); | 
|---|
|  |  |  | mobilePosition.setCnLat(gcj02Point[1] + ""); | 
|---|
|  |  |  | if (!userSetting.getSavePositionHistory()) { | 
|---|
|  |  |  | storager.clearMobilePositionsByDeviceId(deviceId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | storager.insertMobilePosition(mobilePosition); | 
|---|
|  |  |  | responseAck(evt, Response.OK); | 
|---|
|  |  |  | } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public SyncStatus getChannelSyncProgress(String deviceId) { | 
|---|