|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.example.demo.config;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.example.demo.domain.Geoname;
|
|
|
|
|
import com.example.demo.domain.Gps;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -26,43 +27,59 @@ public class ReadTxt {
|
|
|
|
|
File f = new File(imgfilepath);
|
|
|
|
|
File fs=null;
|
|
|
|
|
int row=0;
|
|
|
|
|
String count=null;
|
|
|
|
|
String jsonresult=null;
|
|
|
|
|
if (!f.exists()) {
|
|
|
|
|
// System.out.println(path + " not exists");
|
|
|
|
|
}
|
|
|
|
|
/*获取返回的row*/
|
|
|
|
|
String count= ToInterface.sendGet(url1+"/wujiangGps/getrow",null);
|
|
|
|
|
try{
|
|
|
|
|
BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
|
|
|
|
|
String s = null;
|
|
|
|
|
while((s = br.readLine())!=null){//使用readLine方法,一次读一行
|
|
|
|
|
row=row+1;
|
|
|
|
|
if(row >Integer.parseInt(count)){
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String format = sdf.format(System.currentTimeMillis());
|
|
|
|
|
String[] sz = s.split("#");
|
|
|
|
|
g.setBegaintime(sz[0]);
|
|
|
|
|
g.setNumber(Integer.valueOf(sz[1]));
|
|
|
|
|
g.setLng(sz[2]);
|
|
|
|
|
g.setLat(sz[3]);
|
|
|
|
|
g.setAngle(sz[4]);
|
|
|
|
|
g.setSpeed(sz[5]);
|
|
|
|
|
g.setCar_no(chepai);
|
|
|
|
|
g.setRowa(String.valueOf(row));
|
|
|
|
|
g.setFilename(filename);
|
|
|
|
|
g.setCreate_time(format);
|
|
|
|
|
long date_temp = Long.valueOf(g.getBegaintime());
|
|
|
|
|
String begain_time = sdf.format(new Date(date_temp * 1000L));
|
|
|
|
|
g.setBegain_time(begain_time);
|
|
|
|
|
result=JSON.toJSONString(g);
|
|
|
|
|
ToInterface.interfaceUtil(url1+"/wujiangGps",result,"POST");
|
|
|
|
|
|
|
|
|
|
jsonresult= ToInterface.sendGet(url1+"/wujiangGps/getrow",null);
|
|
|
|
|
|
|
|
|
|
JSONObject object= JSONObject.parseObject(jsonresult);
|
|
|
|
|
String code= String.valueOf(object.get("code"));
|
|
|
|
|
count=String.valueOf(object.get("data"));
|
|
|
|
|
if (code.equals("200")){
|
|
|
|
|
try{
|
|
|
|
|
BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
|
|
|
|
|
String s = null;
|
|
|
|
|
while((s = br.readLine())!=null){//使用readLine方法,一次读一行
|
|
|
|
|
row=row+1;
|
|
|
|
|
if(row >Integer.parseInt(count)){
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String format = sdf.format(System.currentTimeMillis());
|
|
|
|
|
String[] sz = s.split("#");
|
|
|
|
|
g.setBegaintime(sz[0]);
|
|
|
|
|
g.setNumber(Integer.valueOf(sz[1]));
|
|
|
|
|
g.setLng(sz[2]);
|
|
|
|
|
g.setLat(sz[3]);
|
|
|
|
|
g.setAngle(sz[4]);
|
|
|
|
|
g.setSpeed(sz[5]);
|
|
|
|
|
g.setCar_no(chepai);
|
|
|
|
|
g.setRowa(String.valueOf(row));
|
|
|
|
|
g.setFilename(filename);
|
|
|
|
|
g.setCreate_time(format);
|
|
|
|
|
long date_temp = Long.valueOf(g.getBegaintime());
|
|
|
|
|
String begain_time = sdf.format(new Date(date_temp * 1000L));
|
|
|
|
|
g.setBegain_time(begain_time);
|
|
|
|
|
result=JSON.toJSONString(g);
|
|
|
|
|
String sbresult= ToInterface.interfaceUtil(url1+"/wujiangGps",result,"POST");
|
|
|
|
|
log.info("count"+count+"上传gps"+String.valueOf(row));
|
|
|
|
|
JSONObject sbobject= JSONObject.parseObject(sbresult);
|
|
|
|
|
String sbcount= String.valueOf(sbobject.get("code"));
|
|
|
|
|
if (!sbcount.equals("200")){
|
|
|
|
|
br.close();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
br.close();
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
br.close();
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|