| | |
| | | import com.gps31.push.netty.client.TcpClient; |
| | | import com.gps31.push.util.MapUtil; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.sy.domain.ArdOilWall; |
| | | import com.ruoyi.sy.service.impl.ArdOilWallServiceImpl; |
| | | import com.ruoyi.sy.service.impl.ArdSyCarDayServiceImpl; |
| | | import com.ruoyi.sy.service.impl.ArdSyCarServiceImpl; |
| | | import com.ruoyi.utils.gps.GeoTools; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.awt.geom.Point2D; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p>Description: </p> |
| | |
| | | Map<String,Object> gpsMap = pushMsg.getJsonMap(); |
| | | /*String carName = MapUtil.getStrVal(gpsMap, "carName","");//获取车牌号 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | System.out.println(sdf.format(new Date())); |
| | | log.error(String.format(" ---->收到定位数据:%s",JSON.toJSONString(gpsMap)));*/ |
| | | System.out.println(sdf.format(new Date()));*/ |
| | | // log.error(String.format(" ---->收到定位数据:%s",JSON.toJSONString(gpsMap))); |
| | | String carId = (String)gpsMap.get("carId"); |
| | | ((ArdSyCarDayServiceImpl)SpringUtils.getBean("ardSyCarDayServiceImpl")).insertArdSyCarDay(carId);//新增车辆上报时间 |
| | | Map<String,Object> result = ((ArdSyCarServiceImpl)SpringUtils.getBean("ardSyCarServiceImpl")).getArdSyCarAndDeptByCarId(carId);//查询车辆及部门 |
| | | // log.error("---------------------"+result); |
| | | if(result != null){ |
| | | //清淤定位 |
| | | String lng = (String) gpsMap.get("lng");//获取经度 |
| | | String lat = (String) gpsMap.get("lat");//获取纬度 |
| | | String carName = (String) gpsMap.get("carName");//获取车牌号 |
| | | String time = (String) gpsMap.get("result");//定位时间 |
| | | String deptNum = (String) result.get("deptId");//获取部门ID |
| | | String deptName = (String) result.get("deptName");//获取部门名称 |
| | | //定义2维空间 |
| | | Point2D.Double point = new Point2D.Double(Double.parseDouble(lng), Double.parseDouble(lat)); |
| | | List<Point2D.Double> pts = new ArrayList<Point2D.Double>(); |
| | | //匹配全部围栏 |
| | | List<ArdOilWall> ardOilWalls = ((ArdOilWallServiceImpl)SpringUtils.getBean("ArdOilWallServiceImpl")).all(); |
| | | for (int i = 0; i < ardOilWalls.size(); i++) { |
| | | pts.clear(); |
| | | ArdOilWall ardOilWall = ardOilWalls.get(i); |
| | | String[] coord = ardOilWall.getCoord().split(","); |
| | | for (int j = 0; j < coord.length; j = j + 3) { |
| | | pts.add(new Point2D.Double(Double.parseDouble(coord[j]), Double.parseDouble(coord[j+1]))); |
| | | } |
| | | if(GeoTools.IsPtInPoly(point, pts)){ |
| | | //进入了围栏入库 |
| | | |
| | | } |
| | | } |
| | | gpsMap.putAll(result); |
| | | String ancestors = (String) gpsMap.get("ancestors");//获取父级部门 |
| | | String[] ancestorsArray = ancestors.split(","); |
| | |
| | | } |
| | | } |
| | | } |
| | | //存入用户容器 |
| | | if(PositionContainer.getUserPositionMap().size() != 0){ |
| | | for(String userId : PositionContainer.getUserPositionMap().keySet()){ |
| | | Map<String,Map<String,Object>> carIdCarMap = PositionContainer.getUserPositionMap().get(userId); |
| | | if(carIdCarMap != null){ |
| | | if(carIdCarMap.keySet().contains(carId)){ |
| | | PositionContainer.getUserPositionMap().get(userId).put(carId,gpsMap); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * |