|
@@ -5,10 +5,15 @@ import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.huimv.eartag2.manage2.config.WebSocket;
|
|
|
import com.huimv.eartag2.manage2.pojo.EartagDeviceRegister;
|
|
|
import com.huimv.eartag2.manage2.pojo.EartagEartagRegister;
|
|
|
+import com.huimv.eartag2.manage2.pojo.PliersDemo;
|
|
|
+import com.huimv.eartag2.manage2.pojo.StationLib;
|
|
|
import com.huimv.eartag2.manage2.service.IEartagDeviceRegisterService;
|
|
|
import com.huimv.eartag2.manage2.service.IEartagEartagRegisterService;
|
|
|
+import com.huimv.eartag2.manage2.service.IPliersDemoService;
|
|
|
+import com.huimv.eartag2.manage2.service.IStationLibService;
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
import io.netty.buffer.Unpooled;
|
|
|
import io.netty.channel.ChannelHandler;
|
|
@@ -44,6 +49,12 @@ private IEartagEartagRegisterService eartagRegisterService;
|
|
|
private IEartagDeviceRegisterService deviceRegisterService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private IStationLibService stationLibService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPliersDemoService pliersDemoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private RestTemplate restTemplate ;
|
|
|
//
|
|
|
public void appendClientAsk(String text){
|
|
@@ -121,6 +132,88 @@ private IEartagEartagRegisterService eartagRegisterService;
|
|
|
eartagEartagRegister.setCreateDate(new Date());
|
|
|
|
|
|
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;
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+ JSONObject body = forEntity.getBody();
|
|
|
+ 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;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ lat = stationLib.getLat();
|
|
|
+ lon = stationLib.getLon();
|
|
|
+ address = stationLib.getAddress();
|
|
|
+ isNew = true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+// 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");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
ctx.writeAndFlush(Unpooled.copiedBuffer("hm+7+8+end".getBytes()));
|
|
|
}
|
|
|
|