| | |
| | | res = HttpReqUtil.getInstance().doPost(url, params, null); |
| | | String a = "[" + res + "]"; |
| | | JSONArray jsonArray = JSONArray.fromObject(a); |
| | | String data = jsonArray.getJSONObject(0).get("data").toString(); |
| | | String b = "[" + data + "]"; |
| | | JSONArray jsonArrayb = JSONArray.fromObject(b); |
| | | String x = jsonArrayb.getJSONObject(0).get("x").toString(); |
| | | String y = jsonArrayb.getJSONObject(0).get("y").toString(); |
| | | String timestamp = jsonArrayb.getJSONObject(0).get("timestamp").toString(); |
| | | //实时位置实体类 |
| | | LiveLocation liveLocation = new LiveLocation(); |
| | | liveLocation.setType(2); |
| | | String carnumber = maps.get(i).get("carnumber").toString(); |
| | | liveLocation.setWorkerId(carnumber); |
| | | //经度 |
| | | liveLocation.setLongitude(x); |
| | | //纬度 |
| | | liveLocation.setLatitude(y); |
| | | Date date = timeStamp2Date(timestamp); |
| | | liveLocation.setRecordTime(date); |
| | | //先查询是否已有实时位置信息,如果有,则更新,没有则插入 |
| | | LiveLocation liveLocationInfo = liveLocationService.getLiveLocationInfo(liveLocation); |
| | | boolean status = false; |
| | | if (null == liveLocationInfo) { |
| | | //新增 |
| | | status = liveLocationService.save(liveLocation); |
| | | //数据推送 |
| | | String s1 = |
| | | "insert into sys_live_location(id,type,worker_id,longitude,latitude,record_time) " + |
| | | "values(" + "'" + liveLocation.getId() + "'" + "," + |
| | | "'" + liveLocation.getType() + "'" + "," + |
| | | "'" + liveLocation.getWorkerId() + "'" + "," + |
| | | "'" + liveLocation.getLongitude() + "'" + "," + |
| | | "'" + liveLocation.getLatitude() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | } else { |
| | | status = liveLocationService.updateById(liveLocationInfo); |
| | | //内网同步 |
| | | String s1 = |
| | | "update sys_live_location set type = " + "'" + liveLocationInfo.getType() + "'" + |
| | | ",worker_id = " + "'" + liveLocationInfo.getWorkerId() + "'" + |
| | | ",longitude = " + "'" + liveLocationInfo.getLongitude() + "'" + |
| | | ",latitude = " + "'" + liveLocationInfo.getLatitude() + "'" + |
| | | ",record_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocationInfo.getRecordTime()) + "'" + |
| | | " " + "where id = " + "'" + liveLocationInfo.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | String code = jsonArray.getJSONObject(0).get("code").toString(); |
| | | if (Integer.parseInt(code)==200) { |
| | | String data = jsonArray.getJSONObject(0).get("data").toString(); |
| | | String b = "[" + data + "]"; |
| | | JSONArray jsonArrayb = JSONArray.fromObject(b); |
| | | String x = jsonArrayb.getJSONObject(0).get("x").toString(); |
| | | String y = jsonArrayb.getJSONObject(0).get("y").toString(); |
| | | String timestamp = jsonArrayb.getJSONObject(0).get("timestamp").toString(); |
| | | //实时位置实体类 |
| | | LiveLocation liveLocation = new LiveLocation(); |
| | | liveLocation.setType(2); |
| | | String carnumber = maps.get(i).get("carnumber").toString(); |
| | | liveLocation.setWorkerId(carnumber); |
| | | //经度 |
| | | liveLocation.setLongitude(x); |
| | | //纬度 |
| | | liveLocation.setLatitude(y); |
| | | Date date = timeStamp2Date(timestamp); |
| | | liveLocation.setRecordTime(date); |
| | | //先查询是否已有实时位置信息,如果有,则更新,没有则插入 |
| | | LiveLocation liveLocationInfo = liveLocationService.getLiveLocationInfo(liveLocation); |
| | | boolean status = false; |
| | | if (null == liveLocationInfo) { |
| | | //新增 |
| | | status = liveLocationService.save(liveLocation); |
| | | //数据推送 |
| | | String s1 = |
| | | "insert into sys_live_location(id,type,worker_id,longitude,latitude,record_time) " + |
| | | "values(" + "'" + liveLocation.getId() + "'" + "," + |
| | | "'" + liveLocation.getType() + "'" + "," + |
| | | "'" + liveLocation.getWorkerId() + "'" + "," + |
| | | "'" + liveLocation.getLongitude() + "'" + "," + |
| | | "'" + liveLocation.getLatitude() + "'" + "," + |
| | | "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | } else { |
| | | status = liveLocationService.updateById(liveLocationInfo); |
| | | //内网同步 |
| | | String s1 = |
| | | "update sys_live_location set type = " + "'" + liveLocationInfo.getType() + "'" + |
| | | ",worker_id = " + "'" + liveLocationInfo.getWorkerId() + "'" + |
| | | ",longitude = " + "'" + liveLocationInfo.getLongitude() + "'" + |
| | | ",latitude = " + "'" + liveLocationInfo.getLatitude() + "'" + |
| | | ",record_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocationInfo.getRecordTime()) + "'" + |
| | | " " + "where id = " + "'" + liveLocationInfo.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |