|
@@ -110,14 +110,21 @@ private IEartagEartagRegister2Service eartagRegisterService;
|
|
|
}
|
|
|
|
|
|
if ("7".equals(split[1])){
|
|
|
-
|
|
|
-
|
|
|
- //hm+7+868977051335099+122083123610011+22450+184902913+0+end
|
|
|
- String eartag = split[3];
|
|
|
+ ctx.writeAndFlush(Unpooled.copiedBuffer("hm+7+8+end".getBytes()));
|
|
|
String device = split[2];
|
|
|
+ String eartag = split[3];
|
|
|
EartagDeviceRegister deviceRegister = deviceRegisterService.getOne(new QueryWrapper<EartagDeviceRegister>().eq("chip_id", device));
|
|
|
+
|
|
|
if(ObjectUtil.isNotEmpty(deviceRegister)){
|
|
|
|
|
|
+ Integer upgrade = deviceRegister.getUpgrade();
|
|
|
+ if (upgrade ==1){
|
|
|
+ saveMoneyData(split,deviceRegister.getImei());
|
|
|
+ }else {
|
|
|
+ saveData(split);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
EartagEartagRegister2 eartagRegister = eartagRegisterService.getOne(new QueryWrapper<EartagEartagRegister2>().eq("earmark", eartag));
|
|
|
if (ObjectUtil.isNotEmpty(eartagRegister)){
|
|
|
eartagRegister.setEarmark(eartag);
|
|
@@ -140,92 +147,156 @@ private IEartagEartagRegister2Service eartagRegisterService;
|
|
|
eartagRegisterService.save(eartagEartagRegister);
|
|
|
}
|
|
|
|
|
|
- //耳标记录,加上webSoket
|
|
|
- //hm+7+868977051335099+122083123610011+22450+184902913+0+end
|
|
|
- String lac = split[4];
|
|
|
- String ci = split[5];
|
|
|
- String pliersId = split[2];
|
|
|
- StationLib stationLib = stationLibService.getOne(new QueryWrapper<StationLib>().eq("ci", ci).eq("lac", lac));
|
|
|
- String lat ="";
|
|
|
- String lon ="";
|
|
|
- String address ="";
|
|
|
-
|
|
|
- Boolean isNew =false;
|
|
|
-
|
|
|
- JSONObject body= new JSONObject();
|
|
|
- if (ObjectUtil.isEmpty(stationLib)){
|
|
|
- try {
|
|
|
- ResponseEntity<JSONObject> forEntity = restTemplate.getForEntity("http://api.cellocation.com:82/cell/?mcc=460&mnc=1&lac="+lac+"&ci="+ci+"&output=json", JSONObject.class);
|
|
|
- System.out.println("forEntity"+forEntity);
|
|
|
- body = forEntity.getBody();
|
|
|
- }catch (Exception e){
|
|
|
- System.out.println(e);
|
|
|
- }
|
|
|
-
|
|
|
- lat = (String)body.get("lat");
|
|
|
- lon = (String)body.get("lon");
|
|
|
- address = (String)body.get("address");
|
|
|
- String radius = (String)body.get("radius");
|
|
|
- Integer errcode = (Integer)body.get("errcode");
|
|
|
- if (errcode == 0){
|
|
|
- StationLib stationLib1 = new StationLib();
|
|
|
- stationLib1.setAddress(address);
|
|
|
- stationLib1.setCi(ci);
|
|
|
- stationLib1.setErrcode(errcode+"");
|
|
|
- stationLib1.setLac(lac);
|
|
|
- stationLib1.setLat(lat);
|
|
|
- stationLib1.setLon(lon);
|
|
|
- stationLib1.setRadius(Integer.parseInt(radius));
|
|
|
-
|
|
|
- stationLibService.save(stationLib1);
|
|
|
- isNew = true;
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- if (errcode == 10001){
|
|
|
- StationLib id = stationLibService.getOne(new QueryWrapper<StationLib>().orderByDesc("id").last("limit 1"));
|
|
|
- lat = id.getLat();
|
|
|
- lon = id.getLon();
|
|
|
- address = id.getAddress();
|
|
|
- isNew = true;
|
|
|
-
|
|
|
- }
|
|
|
+ WebSocket.sendMessage("true");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ private final String URL = "http://apilocate.amap.com/position";
|
|
|
+ private final String KEY = "9ccbad3db267cd800084179fe58c5ce9";
|
|
|
+
|
|
|
+ private void saveMoneyData(String[] split,String imei ) {
|
|
|
+ String eartag = split[3];
|
|
|
+ String device = split[2];
|
|
|
+ String lac = split[4];
|
|
|
+ String ci = split[5];
|
|
|
+ StationLib stationLib = stationLibService.getOne(new QueryWrapper<StationLib>().eq("ci", ci).eq("lac", lac));
|
|
|
+ String lat ="";
|
|
|
+ String lon ="";
|
|
|
+ String address ="";
|
|
|
+ JSONObject body= new JSONObject();
|
|
|
+ if (ObjectUtil.isEmpty(stationLib)){
|
|
|
+ try {
|
|
|
+ ResponseEntity<JSONObject> forEntity = restTemplate.getForEntity(URL+"?accesstype=0&imei="+imei+"&cdma=0&bts=460,0,"+lac+","+ci+",-30&output=json&key="+KEY+"&network=GSM", JSONObject.class);
|
|
|
+ System.out.println("forEntity" + forEntity);
|
|
|
+ body = forEntity.getBody();
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println(e);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(body)){
|
|
|
+ Object infocode = body.get("infocode");
|
|
|
+ if ("10000".equals(infocode)){
|
|
|
+ JSONObject result = (JSONObject)body.get("result");
|
|
|
+ address = (String) result.get("desc");
|
|
|
+ Integer radius = (Integer) result.get("radius");
|
|
|
+ String locations = (String) result.get("location");
|
|
|
+ String[] location = locations.split(",");
|
|
|
+
|
|
|
+ StationLib stationLib1 = new StationLib();
|
|
|
+ stationLib1.setAddress(address);
|
|
|
+ stationLib1.setCi(ci);
|
|
|
+ stationLib1.setLac(lac);
|
|
|
+ stationLib1.setLat(location[1]);
|
|
|
+ stationLib1.setLon(location[0]);
|
|
|
+ stationLib1.setRadius(radius);
|
|
|
+
|
|
|
+ stationLibService.save(stationLib1);
|
|
|
+
|
|
|
}else {
|
|
|
- lat = stationLib.getLat();
|
|
|
- lon = stationLib.getLon();
|
|
|
- address = stationLib.getAddress();
|
|
|
- isNew = true;
|
|
|
+ StationLib id = stationLibService.getOne(new QueryWrapper<StationLib>().orderByDesc("id").last("limit 1"));
|
|
|
+ lat = id.getLat();
|
|
|
+ lon = id.getLon();
|
|
|
+ address = id.getAddress();
|
|
|
+ System.out.println(body);
|
|
|
+ System.out.println("高德接口出错,取上一个记录接口");
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ }else {
|
|
|
+ lat = stationLib.getLat();
|
|
|
+ lon = stationLib.getLon();
|
|
|
+ address = stationLib.getAddress();
|
|
|
+ }
|
|
|
|
|
|
- if (isNew ){
|
|
|
- int countEarmark = (int)pliersDemoService.count(new QueryWrapper<PliersDemo>().eq("earmark", eartag));
|
|
|
- PliersDemo pliersDemo = new PliersDemo();
|
|
|
- pliersDemo.setEarmark(eartag);
|
|
|
- pliersDemo.setPliersId(pliersId);
|
|
|
- pliersDemo.setUpdateTime(new Date());
|
|
|
- pliersDemo.setUsegeTimes(1+countEarmark);
|
|
|
|
|
|
|
|
|
- pliersDemo.setLat(lat);
|
|
|
- pliersDemo.setLon(lon);
|
|
|
- pliersDemo.setAddress(address);
|
|
|
- pliersDemoService.save(pliersDemo);
|
|
|
- }
|
|
|
+ int countEarmark = (int)pliersDemoService.count(new QueryWrapper<PliersDemo>().eq("earmark", eartag));
|
|
|
+ PliersDemo pliersDemo = new PliersDemo();
|
|
|
+ pliersDemo.setEarmark(eartag);
|
|
|
+ pliersDemo.setPliersId(device);
|
|
|
+ pliersDemo.setUpdateTime(new Date());
|
|
|
+ pliersDemo.setUsegeTimes(1+countEarmark);
|
|
|
|
|
|
-// List<PliersDemo> id = pliersDemoService.list(new QueryWrapper<PliersDemo>().eq("pliers_id",pliersId).orderByDesc("id").last("limit 50"));
|
|
|
-// String resultJson= new ObjectMapper().writeValueAsString(true);
|
|
|
- WebSocket.sendMessage("true");
|
|
|
+ pliersDemo.setLat(lat);
|
|
|
+ pliersDemo.setLon(lon);
|
|
|
+ pliersDemo.setAddress(address);
|
|
|
+ pliersDemoService.save(pliersDemo);
|
|
|
+ }
|
|
|
|
|
|
+ private void saveData( String[] split ) {
|
|
|
|
|
|
+ //耳标记录,加上webSoket
|
|
|
+ //hm+7+868977051335099+122083123610011+22450+184902913+0+end
|
|
|
+ String eartag = split[3];
|
|
|
+ String lac = split[4];
|
|
|
+ String ci = split[5];
|
|
|
+ String pliersId = split[2];
|
|
|
+ StationLib stationLib = stationLibService.getOne(new QueryWrapper<StationLib>().eq("ci", ci).eq("lac", lac));
|
|
|
+ String lat ="";
|
|
|
+ String lon ="";
|
|
|
+ String address ="";
|
|
|
+
|
|
|
+ JSONObject body= new JSONObject();
|
|
|
+ if (ObjectUtil.isEmpty(stationLib)){
|
|
|
+ try {
|
|
|
+ ResponseEntity<JSONObject> forEntity = restTemplate.getForEntity("http://api.cellocation.com:82/cell/?mcc=460&mnc=1&lac="+lac+"&ci="+ci+"&output=json", JSONObject.class);
|
|
|
+ System.out.println("forEntity"+forEntity);
|
|
|
+ body = forEntity.getBody();
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ lat = (String)body.get("lat");
|
|
|
+ lon = (String)body.get("lon");
|
|
|
+ address = (String)body.get("address");
|
|
|
+ String radius = (String)body.get("radius");
|
|
|
+ Integer errcode = (Integer)body.get("errcode");
|
|
|
+ if (errcode == 0){
|
|
|
+ StationLib stationLib1 = new StationLib();
|
|
|
+ stationLib1.setAddress(address);
|
|
|
+ stationLib1.setCi(ci);
|
|
|
+ stationLib1.setErrcode(errcode+"");
|
|
|
+ stationLib1.setLac(lac);
|
|
|
+ stationLib1.setLat(lat);
|
|
|
+ stationLib1.setLon(lon);
|
|
|
+ stationLib1.setRadius(Integer.parseInt(radius));
|
|
|
+
|
|
|
+ stationLibService.save(stationLib1);
|
|
|
+ }
|
|
|
+ if (errcode == 10001){
|
|
|
+ StationLib id = stationLibService.getOne(new QueryWrapper<StationLib>().orderByDesc("id").last("limit 1"));
|
|
|
+ lat = id.getLat();
|
|
|
+ lon = id.getLon();
|
|
|
+ address = id.getAddress();
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ lat = stationLib.getLat();
|
|
|
+ lon = stationLib.getLon();
|
|
|
+ address = stationLib.getAddress();
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- ctx.writeAndFlush(Unpooled.copiedBuffer("hm+7+8+end".getBytes()));
|
|
|
+
|
|
|
+ int countEarmark = (int)pliersDemoService.count(new QueryWrapper<PliersDemo>().eq("earmark", eartag));
|
|
|
+ PliersDemo pliersDemo = new PliersDemo();
|
|
|
+ pliersDemo.setEarmark(eartag);
|
|
|
+ pliersDemo.setPliersId(pliersId);
|
|
|
+ pliersDemo.setUpdateTime(new Date());
|
|
|
+ pliersDemo.setUsegeTimes(1+countEarmark);
|
|
|
+
|
|
|
+
|
|
|
+ pliersDemo.setLat(lat);
|
|
|
+ pliersDemo.setLon(lon);
|
|
|
+ pliersDemo.setAddress(address);
|
|
|
+ pliersDemoService.save(pliersDemo);
|
|
|
+
|
|
|
+// List<PliersDemo> id = pliersDemoService.list(new QueryWrapper<PliersDemo>().eq("pliers_id",pliersId).orderByDesc("id").last("limit 50"));
|
|
|
+// String resultJson= new ObjectMapper().writeValueAsString(true);
|
|
|
|
|
|
|
|
|
}
|