| | |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.function.Predicate; |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dtflys.forest.annotation.Var; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ruoyi.app.application.domain.ArdAppApplication; |
| | | import com.ruoyi.app.application.mapper.ArdAppApplicationMapper; |
| | | import com.ruoyi.app.position.mapper.ArdAppPositionMapper; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.sy.domain.ArdAccessFence; |
| | | import com.ruoyi.sy.param.ArdSyCarParam; |
| | | import com.ruoyi.sy.vo.ArdSyCarVo; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.utils.gis.GisUtil; |
| | | import com.ruoyi.utils.gis.Point; |
| | | import com.ruoyi.scheduling.domian.SchedulingParam; |
| | | import com.ruoyi.sy.domain.ArdSyCarDay; |
| | | import com.ruoyi.sy.mapper.ArdSyCarDayMapper; |
| | | import com.ruoyi.utils.tools.GisTool; |
| | | import com.ruoyi.utils.minio.MinioUtil; |
| | | import com.ruoyi.utils.websocket.util.WebSocketUtils; |
| | | import com.ruoyi.device.hiksdk.config.MinioClientSingleton; |
| | | import com.ruoyi.storage.minio.utils.MinioUtils; |
| | | import com.ruoyi.sy.domain.ArdSyUser; |
| | | import com.ruoyi.sy.gps31.PositionContainer; |
| | | import com.ruoyi.sy.mapper.ArdSyUserMapper; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.common.core.domain.entity.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.utils.forest.SYClient; |
| | | import com.ruoyi.utils.result.Results; |
| | | import io.minio.GetPresignedObjectUrlArgs; |
| | | import io.minio.ListObjectsArgs; |
| | | import io.minio.PutObjectArgs; |
| | | import io.minio.Result; |
| | | import io.minio.http.Method; |
| | | import io.minio.messages.Item; |
| | |
| | | import okhttp3.Response; |
| | | import okhttp3.ResponseBody; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.sy.mapper.ArdSyCarMapper; |
| | | import com.ruoyi.sy.domain.ArdSyCar; |
| | |
| | | @Resource |
| | | private ArdSyCarDayMapper ardSyCarDayMapper; |
| | | |
| | | @Resource |
| | | private ArdAppApplicationMapper ardAppApplicationMapper; |
| | | |
| | | @Resource |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | @Value("${minio.endpoint}") |
| | | private String minioEndpoint; |
| | | |
| | | private Map<Integer, Map<String, String>> logInMap = new HashMap(); |
| | | |
| | | private Map<String, Timer> userCarTimerMap = new HashMap(); |
| | |
| | | @Override |
| | | public List<ArdSyCar> selectArdSyCarList(ArdSyCar ardSyCar) { |
| | | return ardSyCarMapper.selectArdSyCarList(ardSyCar); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult ardSyCarList(ArdSyCarParam ardSyCarParam,Map<String,Object> result) { |
| | | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.like(ardSyCarParam.getCarBrand()!=null,"car_brand",ardSyCarParam.getCarBrand()) |
| | | .like(ardSyCarParam.getCarType()!=null,"car_type",ardSyCarParam.getCarType()); |
| | | List<ArdSyCar> ardSyCars = ardSyCarMapper.selectList(queryWrapper); |
| | | List<ArdSyCarVo> ardSyCarVoList = new ArrayList<>(); |
| | | if(((String)result.get("code")).equals("200")){ |
| | | List<Map<String,Object>> list = (List<Map<String, Object>>) result.get("data"); |
| | | for (int i = 0; i < ardSyCars.size(); i++) { |
| | | ArdSyCar ardSyCar = ardSyCars.get(i); |
| | | String carId = ardSyCar.getCarId(); |
| | | for (int j = 0; j < list.size(); j++) { |
| | | String carId31 = (String) list.get(j).get("carId"); |
| | | if(carId.equals(carId31)){ |
| | | ArdSyCarVo ardSyCarVo = new ArdSyCarVo(); |
| | | ardSyCarVo.setId(ardSyCar.getId()); |
| | | ardSyCarVo.setCarId(carId); |
| | | ardSyCarVo.setCarBrand(ardSyCar.getCarBrand()); |
| | | ardSyCarVo.setCarModel(ardSyCar.getCarModel()); |
| | | ardSyCarVo.setCarPicture(ardSyCar.getCarPicture()); |
| | | ardSyCarVo.setCarType(ardSyCar.getCarType()); |
| | | ardSyCarVo.setDeptId(ardSyCar.getDeptId()); |
| | | ardSyCarVo.setRemark(ardSyCar.getRemark()); |
| | | ardSyCarVo.setCarPlate((String) list.get(j).get("carPlate")); |
| | | ardSyCarVoList.add(ardSyCarVo); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(ardSyCarParam.getCarPlate()!=null){ |
| | | List<ArdSyCarVo> newList = new ArrayList<>(); |
| | | for (int i = 0; i < ardSyCarVoList.size(); i++) { |
| | | String carPlate = ardSyCarVoList.get(i).getCarPlate(); |
| | | if(!carPlate.contains(ardSyCarParam.getCarPlate())){ |
| | | newList.add(ardSyCarVoList.get(i)); |
| | | } |
| | | } |
| | | ardSyCarVoList.removeAll(newList); |
| | | } |
| | | return AjaxResult.success(new PageInfo<>(ardSyCarVoList)); |
| | | }else { |
| | | return AjaxResult.error("31平台连接失败,车牌号获取失败!",new PageInfo<>(ardSyCars)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | objectNames.add(ardSyCar.getCarPicture().split("/sycar/")[1]); |
| | | } |
| | | } |
| | | MinioUtils.removeObjects("sycar", objectNames); |
| | | MinioUtil.removeObjects("sycar", objectNames); |
| | | return ardSyCarMapper.deleteArdSyCarByIds(ids); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<Map<String, String>> getAllCarModel() { |
| | | boolean exsit = MinioUtils.exitsBucket("sycar"); |
| | | boolean exsit = MinioUtil.exitsBucket("system"); |
| | | if (exsit) { |
| | | List<Map<String, String>> listObjetcName = new ArrayList<>(); |
| | | try { |
| | | ListObjectsArgs listObjectsArgs = ListObjectsArgs.builder().prefix("carmodel/").bucket("sycar").build(); |
| | | Iterable<Result<Item>> myObjects = MinioClientSingleton.getMinioClient().listObjects(listObjectsArgs); |
| | | //Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("sycar","carmodel"); |
| | | Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("system","model/car"); |
| | | for (Result<Item> result : myObjects) { |
| | | Item item = result.get(); |
| | | Map<String, String> map = new HashMap(); |
| | | map.put("carModel", "sycar/" + item.objectName()); |
| | | switch (item.objectName()) { |
| | | case "carmodel/aodi.glb": |
| | | map.put("carType", "奥迪"); |
| | | break; |
| | | case "carmodel/baolai.glb": |
| | | map.put("carType", "宝来"); |
| | | break; |
| | | case "carmodel/bieke.glb": |
| | | map.put("carType", "别克"); |
| | | break; |
| | | case "carmodel/bus1.glb": |
| | | map.put("carType", "大客车"); |
| | | break; |
| | | case "carmodel/car.glb": |
| | | map.put("carType", "小型车"); |
| | | break; |
| | | case "carmodel/fire(1).glb": |
| | | map.put("carType", "消防车"); |
| | | break; |
| | | case "carmodel/fute.glb": |
| | | map.put("carType", "福特"); |
| | | break; |
| | | case "carmodel/jingche_a.glb": |
| | | map.put("carType", "警车"); |
| | | break; |
| | | case "carmodel/jiuhu.glb": |
| | | map.put("carType", "救护车"); |
| | | break; |
| | | case "carmodel/oil.glb": |
| | | map.put("carType", "油罐车"); |
| | | break; |
| | | case "carmodel/truck.glb": |
| | | map.put("carType", "工程用车"); |
| | | break; |
| | | case "carmodel/van1.glb": |
| | | map.put("carType", "大货车"); |
| | | break; |
| | | default: |
| | | break; |
| | | String[] strArr = item.objectName().split("/"); |
| | | try{ |
| | | String carType = strArr[2]; |
| | | if(!carType.contains(".")){ |
| | | map.put("carType", carType); |
| | | map.put("carModel", "system/" + item.objectName()); |
| | | listObjetcName.add(map); |
| | | } |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | listObjetcName.add(map); |
| | | } |
| | | return listObjetcName; |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | //log.error("minio获取桶下对象异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | |
| | | if (ardSyCarr.getCarPicture() != null || !ardSyCarr.getCarPicture().equals("")) { |
| | | String objectName = ardSyCarr.getCarPicture().split("/sycar/")[1]; |
| | | objectNames.add(objectName); |
| | | MinioUtils.removeObjects("sycar", objectNames); |
| | | MinioUtil.removeObjects("sycar", objectNames); |
| | | } |
| | | } |
| | | //判断文件是否为空 |
| | | if (null == carPicture || 0 == carPicture.getSize()) { |
| | | return ""; |
| | | } |
| | | boolean exsit = MinioUtils.exitsBucket("sycar"); |
| | | boolean exsit = MinioUtil.exitsBucket("sycar"); |
| | | if (!exsit) { |
| | | boolean bucket = MinioUtils.createBucket("sycar"); |
| | | boolean bucket = MinioUtil.createBucket("sycar"); |
| | | } |
| | | //文件名 |
| | | String originalFilename = carPicture.getOriginalFilename(); |
| | |
| | | try { |
| | | InputStream inputStream = carPicture.getInputStream(); |
| | | /*上传对象*/ |
| | | PutObjectArgs putObjectArgs = PutObjectArgs |
| | | .builder() |
| | | .bucket("sycar") |
| | | .object(fileName) |
| | | .stream(inputStream, carPicture.getSize(), -1) |
| | | .contentType(carPicture.getContentType()) |
| | | .build(); |
| | | MinioClientSingleton.getMinioClient().putObject(putObjectArgs); |
| | | // PutObjectArgs putObjectArgs = PutObjectArgs |
| | | // .builder() |
| | | // .bucket("sycar") |
| | | // .object(fileName) |
| | | // .stream(inputStream, carPicture.getSize(), -1) |
| | | // .contentType(carPicture.getContentType()) |
| | | // .build(); |
| | | // MinioConfig.getMinioClient().putObject(putObjectArgs); |
| | | MinioUtil.uploadObject("sycar",fileName,inputStream,carPicture.getSize(),carPicture.getContentType()); |
| | | inputStream.close(); |
| | | /*获取url*/ |
| | | GetPresignedObjectUrlArgs getPresignedObjectUrlArgs = GetPresignedObjectUrlArgs |
| | |
| | | .object(fileName) |
| | | .method(Method.GET) |
| | | .build(); |
| | | String presignedObjectUrl = MinioClientSingleton.getMinioClient().getPresignedObjectUrl(getPresignedObjectUrlArgs); |
| | | String ObjectUrl = presignedObjectUrl.substring(0, presignedObjectUrl.indexOf("?")); |
| | | //String presignedObjectUrl = MinioConfig.getMinioClient().getPresignedObjectUrl(getPresignedObjectUrlArgs); |
| | | String ObjectUrl = MinioUtil.getBucketObjectUrl("sycar", fileName); |
| | | if (id != null && !id.equals("")) {//id为非必要 |
| | | ArdSyCar ardSyCar = new ArdSyCar(); |
| | | ardSyCar.setId(id); |
| | |
| | | public Map<String, Object> getArdSyCarAndDeptByCarId(String carId) { |
| | | Map<String, Object> result = ardSyCarMapper.getArdSyCarAndDeptByCarId(carId); |
| | | if (result != null) { |
| | | if (result.get("carPicture") != null) { |
| | | /*if (result.get("carPicture") != null) { |
| | | if (!((String) result.get("carPicture")).equals("")) { |
| | | String url = ((String) result.get("carPicture")).split("sycar")[0]; |
| | | String carModel = url + (String) result.get("carModel"); |
| | | String carModel = this.minioEndpoint + "/" + (String) result.get("carModel"); |
| | | result.put("carModel", carModel); |
| | | } |
| | | }*/ |
| | | if(result.get("carModel") != null || "".equals(result.get("carModel"))){ |
| | | String carModel = this.minioEndpoint + "/" + (String) result.get("carModel"); |
| | | result.put("carModel", carModel); |
| | | } |
| | | } |
| | | return result; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Map<String, Object> allListByUser(ArdSyUser ardSyUser, String syURL, String usersId) { |
| | | public Map<String, Object> allListByUser(ArdSyUser ardSyUser, String syURL, String usersId, List<Long> deptList) { |
| | | Map<String, Object> result0 = new HashMap(); |
| | | //判断关联表是否有数据 |
| | | if (ardSyUser != null) { |
| | |
| | | map.put("list", new ArrayList()); |
| | | return map; |
| | | } |
| | | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("dept_id", deptList); |
| | | List<ArdSyCar> carListTable = ardSyCarMapper.selectList(queryWrapper); |
| | | int online = 0; |
| | | for (Map<String, Object> map : (List<Map<String, Object>>) result0.get("list")) { |
| | | Map<String, Object> resultMap = sYClient.getTeamCarList(syURL, (String) map.get("teamId"), result.get("sessionId")); |
| | | List<Map<String, Object>> carList = (List<Map<String, Object>>) resultMap.get("carList"); |
| | | if(carList.size()>0){ |
| | | for (int i = 0; i < carList.size(); i++) { |
| | | String carId = (String) carList.get(i).get("carId"); |
| | | Boolean isCar = false; |
| | | for (int j = 0; j < carListTable.size(); j++) { |
| | | ArdSyCar ardSyCar = carListTable.get(j); |
| | | if (carId.equals(ardSyCar.getCarId())) { |
| | | isCar = true; |
| | | break; |
| | | } |
| | | } |
| | | if(!isCar){ |
| | | carList.remove(carList.get(i)); |
| | | } |
| | | } |
| | | } |
| | | for (Map<String, Object> m : carList) { |
| | | if (((String) m.get("stateCn")).contains("在线")) { |
| | | online = online + 1; |
| | |
| | | continue; |
| | | } |
| | | } |
| | | for (Map<String, Object> m : (List<Map<String, Object>>) result0.get("list")) { |
| | | if (((String) m.get("teamId")).equals(((String) map.get("teamId")))) { |
| | | map.put("count", Integer.parseInt((String) m.get("carNum"))); |
| | | } |
| | | } |
| | | // for (Map<String, Object> m : (List<Map<String, Object>>) result0.get("list")) { |
| | | // if (((String) m.get("teamId")).equals(((String) map.get("teamId")))) { |
| | | // map.put("count", Integer.parseInt((String) m.get("carNum"))); |
| | | // } |
| | | // } |
| | | map.put("count", carList.size()); |
| | | map.put("online", online); |
| | | online = 0; |
| | | } |
| | |
| | | queryWrapper.in("dept_id", deptList); |
| | | List<ArdSyCar> carList = ardSyCarMapper.selectList(queryWrapper); |
| | | //对比把匹配到的数据添加到list中 |
| | | for (Map<String, String> m : list) { |
| | | String carId = m.get("carId"); |
| | | for (int i = 0; i < carList.size(); i++) { |
| | | ArdSyCar ardSyCar = carList.get(i); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | String carId = list.get(i).get("carId"); |
| | | Boolean isCar = false; |
| | | for (int j = 0; j < carList.size(); j++) { |
| | | ArdSyCar ardSyCar = carList.get(j); |
| | | if (carId.equals(ardSyCar.getCarId())) { |
| | | String url = ""; |
| | | /*String url = ""; |
| | | if (ardSyCar.getCarPicture() != null) { |
| | | if (!ardSyCar.getCarPicture().equals("")) { |
| | | url = ardSyCar.getCarPicture().split("sycar")[0]; |
| | | } |
| | | } |
| | | m.put("carModel", url + ardSyCar.getCarModel());//zns |
| | | }*/ |
| | | list.get(i).put("carModel", this.minioEndpoint + "/" + ardSyCar.getCarModel());//zns |
| | | //m.put("carModel",ardSyCar.getCarModel()); |
| | | m.put("carTypeArd", ardSyCar.getCarType()); |
| | | m.put("carBrand", ardSyCar.getCarBrand()); |
| | | m.put("carPicture", ardSyCar.getCarPicture()); |
| | | list.get(i).put("carTypeArd", ardSyCar.getCarType()); |
| | | list.get(i).put("carBrand", ardSyCar.getCarBrand()); |
| | | list.get(i).put("carPicture", ardSyCar.getCarPicture()); |
| | | isCar = true; |
| | | break; |
| | | } |
| | | } |
| | | if(!isCar){ |
| | | list.remove(list.get(i)); |
| | | } |
| | | } |
| | | return list; |
| | |
| | | String passwordMd5 = DigestUtils.md5Hex(password31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | Map<String, Object> result0 = new HashMap(); |
| | | result0 = sYClient.getCarGPSTrack(syURL, carId, startTime, endTime, maxSpeed, (String) result1.get("sessionId")); |
| | | //result0 = sYClient.getCarGPSTrack(syURL, carId, startTime, endTime, maxSpeed, (String) result1.get("sessionId")); |
| | | try { |
| | | result0 = getCarGPSTrack(syURL, carId, startTime, endTime, maxSpeed, (String) result1.get("sessionId")); |
| | | } catch (Exception e) { |
| | | return Results.error("查询历史数据数量过多导致超时,请缩小范围查询!"); |
| | | } |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) result0.get("list"); |
| | | if (list.isEmpty()) { |
| | | return Results.succeed(); |
| | |
| | | m.putAll(sgnMap); |
| | | } |
| | | return Results.succeed(list); |
| | | } |
| | | } |
| | | |
| | | public static Map<String,Object> getCarGPSTrack(String syURL,String carId,String startTime,String endTime,String maxSpeed,String sessionId){ |
| | | OkHttpClient okHttpClient = new OkHttpClient(); |
| | | |
| | | Request request = new Request.Builder() |
| | | .url(syURL + "/gps-web/api/get_gps_h.jsp?carId=" + carId + "&startTime=" + startTime + "&endTime=" + endTime + "&sessionId=" + sessionId) |
| | | .build(); |
| | | |
| | | Response response = null; |
| | | try { |
| | | response = okHttpClient.newCall(request).execute(); |
| | | } catch (IOException e1) { |
| | | // TODO Auto-generated catch block |
| | | e1.printStackTrace(); |
| | | } |
| | | |
| | | response.headers(); //响应头 |
| | | |
| | | ResponseBody responseBody = response.body(); |
| | | |
| | | try { |
| | | String message = responseBody.string();// 响应体 |
| | | Map<String,Object> map = (Map<String, Object>) JSON.parse(message); |
| | | //System.out.println(message); |
| | | return map; |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | return new HashMap(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Results getCarGPSBycarId(String usersId, String carId, String syURL, ArdSyUser ardSyUser) { |
| | | Map<String, String> result = logInMap.get(Integer.parseInt(usersId)); |
| | | public Map<String, Object> getCarGPSBycarId(String usersId, String carId, String syURL, ArdSyUser ardSyUser) { |
| | | // Map<String, String> result = logInMap.get(Integer.parseInt(usersId)); |
| | | //31用户名密码 |
| | | String username31 = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | String passwordMd5 = DigestUtils.md5Hex(password31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | result = new HashMap(); |
| | | Map<String, String> result = new HashMap(); |
| | | result.put("userId", username31); |
| | | result.put("sessionId", (String) result1.get("sessionId")); |
| | | Map<String, Object> result0 = new HashMap(); |
| | | result0 = sYClient.getCarNearPositionByCarId(syURL, carId, result.get("userId"), result.get("sessionId")); |
| | | return Results.succeed(result0); |
| | | return sYClient.getCarNearPositionByCarId(syURL, carId, result.get("userId"), result.get("sessionId")); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getCarPicture(String carId, String syURL, String sessionId) { |
| | | return sYClient.getCarPicture(syURL, carId, sessionId); |
| | | } |
| | | |
| | | @Override |
| | | public String getSessionId(String syURL,ArdSyUser ardSyUser) { |
| | | String username31 = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | String passwordMd5 = DigestUtils.md5Hex(password31); |
| | | System.out.println(passwordMd5); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | return (String) result1.get("sessionId"); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> sendCmd(String userId,String syURL, String sessionId, String carId, List<String> channelList) throws UnsupportedEncodingException { |
| | | // for (int i = 0; i < channelList.size(); i++) { |
| | | Map<String,String> params = new HashMap(); |
| | | params.put("channel", channelList.get(1));//选择通道1 |
| | | params.put("interval", "0");//每隔0s照一次 |
| | | params.put("photoNum", "1");//照1张 |
| | | params.put("action", "0");//上传模式 |
| | | String paramsStr = com.alibaba.fastjson2.JSON.toJSONString(params); |
| | | paramsStr = URLEncoder.encode(paramsStr,"UTF-8"); |
| | | System.out.println("拍照参数:"+paramsStr); |
| | | return sYClient.sendCmd(syURL,userId,carId,301,"MediaTake",paramsStr,sessionId); |
| | | // } |
| | | // return sendCmdMap; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getPhoto(String syURL, String carId, String sessionId,String startTime) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String endTime = sdf.format(new Date()); |
| | | System.out.println("开始时间:"+startTime+" 结束时间:"+endTime); |
| | | return sYClient.getPhoto(syURL,carId,startTime,endTime,sessionId); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getVideo(String syURL,String carId,ArdSyUser ardSyUser) { |
| | | //31用户名密码 |
| | | String username = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | String password = DigestUtils.md5Hex(password31); |
| | | // Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | return sYClient.getVideo(syURL,username,password,"黑E12401",1); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Results chaseCarByCarId(String usersId, String carId, String cycle) { |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | }else{ |
| | | return Results.error("没有挂接三一车辆用户"); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("三一车辆地址未录入"); |
| | | } |
| | | |
| | | String sessionId = ""; |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | if(key.startsWith(usersId + "_")){ |
| | | sessionId = key; |
| | | } |
| | | } |
| | | if(sessionId.equals("")){//没有session就返回失败 |
| | | return Results.error("追踪失败"); |
| | | } |
| | | try { |
| | | /*Map<String,Map<String,Object>> map = new HashMap(); |
| | | map.put(carId,new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId,map);*/ |
| | | if (cycle.equals("0")) { |
| | | if (userCarTimerMap.get(usersId) != null) { |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//停止追踪,改为定时30s推送 |
| | | System.out.println("停止追踪"); |
| | | } |
| | | return Results.succeed("停止追踪"); |
| | | } else { |
| | |
| | | Map<String, Map<String, Object>> map = new HashMap(); |
| | | map.put(carId, new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId, map); |
| | | |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | List<SysConfig> distanceSYResult = sysConfigMapper.selectByType("31time"); |
| | | String time = ""; |
| | | if(distanceSYResult.size() != 0){ |
| | | time = distanceSYResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("三一车辆定时未录入"); |
| | | } |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%22"+time+"%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//开始追踪,改为定时推送 |
| | | |
| | | Map<String, Object> position = PositionContainer.getCarPositionMap().get(carId);//查询当前车辆位置 |
| | | if (position != null) { |
| | | if (position.size() != 0) { |
| | | position.put("elng",position.get("lng")); |
| | | position.put("elat",position.get("lat")); |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | Timer carPositionTimer = new Timer();//定时推送实时位置 |
| | | Timer carPositionTimer = new Timer(sessionId);//定时推送实时位置 |
| | | TimerTask carPositionTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | |
| | | if (position.size() != 0) { |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); |
| | | String sessionId = Thread.currentThread().getName(); |
| | | if(ONLINE_USER_SESSIONS.get(sessionId) == null){//用户离线释放资源 |
| | | if (userCarTimerMap.get(usersId) != null) { |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = ardSyUser.getPassword(); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | } |
| | | if(!userId.equals("") && !password.equals("") && !syURL.equals("")){ |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//停止追踪,改为定时30s |
| | | } |
| | | System.out.println("用户离线,停止追踪"); |
| | | } |
| | | } |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |
| | |
| | | Map<String, Map<String, Object>> map = new HashMap(); |
| | | map.put(carId, new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId, map); |
| | | |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | List<SysConfig> distanceSYResult = sysConfigMapper.selectByType("31time"); |
| | | String time = ""; |
| | | if(distanceSYResult.size() != 0){ |
| | | time = distanceSYResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("三一车辆定时未录入"); |
| | | } |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%22"+time+"%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//开始追踪,改为定时推送 |
| | | |
| | | Map<String, Object> position = PositionContainer.getCarPositionMap().get(carId);//查询当前车辆位置 |
| | | if (position != null) { |
| | | if (position.size() != 0) { |
| | | position.put("elng",position.get("lng")); |
| | | position.put("elat",position.get("lat")); |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | Timer carPositionTimer = new Timer();//定时推送实时位置 |
| | | Timer carPositionTimer = new Timer(sessionId);//定时推送实时位置 |
| | | TimerTask carPositionTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | |
| | | if (position.size() != 0) { |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); |
| | | String sessionId = Thread.currentThread().getName(); |
| | | if(ONLINE_USER_SESSIONS.get(sessionId) == null){//用户离线释放资源 |
| | | if (userCarTimerMap.get(usersId) != null) { |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = ardSyUser.getPassword(); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | } |
| | | if(!userId.equals("") && !password.equals("") && !syURL.equals("")){ |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//停止追踪,改为定时30s |
| | | } |
| | | System.out.println("用户离线,停止追踪"); |
| | | } |
| | | } |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 获取附近范围内的车辆信息 |
| | | */ |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getNearCar(SchedulingParam param) { |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | Integer radius = param.getSealingRadius(); |
| | | if (longitude == null && latitude == null) { |
| | | log.debug("原点坐标为空"); |
| | | return null; |
| | | } |
| | | if (radius == null) { |
| | | log.debug("半径距离为空"); |
| | | return null; |
| | | } |
| | | String userId = SecurityUtils.getUserId(); |
| | | ArdSyUser syUser = new ArdSyUser(); |
| | | syUser.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(syUser); |
| | | if (ardSyUserList.size() == 0) { |
| | | log.debug("用户未挂接三一车辆"); |
| | | return null; |
| | | } |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | String syUrl = redisCache.getCacheObject("sys_config:syCarPT"); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syUrl, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | try { |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | Integer radius = param.getSealingRadius(); |
| | | if (longitude == null && latitude == null) { |
| | | log.debug("原点坐标为空"); |
| | | return null; |
| | | } |
| | | if (radius == null) { |
| | | log.debug("半径距离为空"); |
| | | return null; |
| | | } |
| | | String userId = SecurityUtils.getUserId(); |
| | | ArdSyUser syUser = new ArdSyUser(); |
| | | syUser.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(syUser); |
| | | if (ardSyUserList.size() == 0) { |
| | | log.debug("用户未挂接三一车辆"); |
| | | return null; |
| | | } |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | String syUrl = redisCache.getCacheObject("sys_config:syCarPT"); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syUrl, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | |
| | | Map<String, Object> teamList = sYClient.getTeamList(syUrl, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> listMap = (List<Map<String, Object>>) teamList.get("list"); |
| | | List<Map<String, Object>> allList = new ArrayList<>(); |
| | | for (Map<String, Object> team : listMap) { |
| | | String teamId = (String) team.get("teamId"); |
| | | Map<String, Object> carListMap = sYClient.getCarList1(syUrl, teamId, ardSyUser.getUserId(), sessionId); |
| | | if (((String) carListMap.get("rspCode")).equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list"); |
| | | allList.addAll(list); |
| | | Map<String, Object> teamList = sYClient.getTeamList(syUrl, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> listMap = (List<Map<String, Object>>) teamList.get("list"); |
| | | List<Map<String, Object>> allList = new ArrayList<>(); |
| | | for (Map<String, Object> team : listMap) { |
| | | String teamId = (String) team.get("teamId"); |
| | | Map<String, Object> carListMap = sYClient.getCarList1(syUrl, teamId, ardSyUser.getUserId(), sessionId); |
| | | if (((String) carListMap.get("rspCode")).equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list"); |
| | | allList.addAll(list); |
| | | } |
| | | } |
| | | //过滤在线车辆 |
| | | List<Map<String, Object>> onlineList = allList.stream() |
| | | .filter(map -> !"离线".equals(map.get("stateCn"))) |
| | | .collect(Collectors.toList()); |
| | | List<Map<String, Object>> filteredList = new ArrayList<>(); |
| | | //过滤半径 |
| | | for (Map<String, Object> carMap : onlineList) { |
| | | String carId = (String) carMap.get("carId"); |
| | | Map<String, Object> carGPSTrack = sYClient.getCarNearPositionByCarId(syUrl, carId, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> carGPSMap = (List<Map<String, Object>>) carGPSTrack.get("list"); |
| | | Double lng = Double.valueOf((String) carGPSMap.get(0).get("lng")); |
| | | Double lat = Double.valueOf((String) carGPSMap.get(0).get("lat")); |
| | | double distance = GisUtil.getDistance(new double[]{longitude, latitude}, new double[]{lng, lat}); |
| | | if (distance <= radius) { |
| | | carMap.put("longitude", lng); |
| | | carMap.put("latitude", lat); |
| | | filteredList.add(carMap); // 将满足条件的车辆添加到筛选列表中 |
| | | } |
| | | } |
| | | return filteredList; |
| | | }catch (Exception e) |
| | | { |
| | | log.error("获取附近范围内的车辆信息异常:"+e.getMessage()); |
| | | return null; |
| | | } |
| | | } |
| | | /** |
| | | * 获取范围内的车辆信息(多边形) |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> getNearCarWithPolygon(SchedulingParam param) { |
| | | List<Map<String, Object>> filteredList = new ArrayList<>(); |
| | | try { |
| | | List<Point> partitionLocation = param.getPartitionLocation(); |
| | | if (partitionLocation == null) { |
| | | log.debug("多边形坐标集合为空"); |
| | | return null; |
| | | } |
| | | String userId = SecurityUtils.getUserId(); |
| | | ArdSyUser syUser = new ArdSyUser(); |
| | | syUser.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(syUser); |
| | | if (ardSyUserList.size() == 0) { |
| | | log.debug("用户未挂接三一车辆"); |
| | | return null; |
| | | } |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | String syUrl = redisCache.getCacheObject("sys_config:syCarPT"); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syUrl, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | |
| | | Map<String, Object> teamList = sYClient.getTeamList(syUrl, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> listMap = (List<Map<String, Object>>) teamList.get("list"); |
| | | List<Map<String, Object>> allList = new ArrayList<>(); |
| | | for (Map<String, Object> team : listMap) { |
| | | String teamId = (String) team.get("teamId"); |
| | | Map<String, Object> carListMap = sYClient.getCarList1(syUrl, teamId, ardSyUser.getUserId(), sessionId); |
| | | if (((String) carListMap.get("rspCode")).equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list"); |
| | | allList.addAll(list); |
| | | } |
| | | } |
| | | //过滤在线车辆 |
| | | List<Map<String, Object>> onlineList = allList.stream() |
| | | .filter(map -> !"离线".equals(map.get("stateCn"))) |
| | | .collect(Collectors.toList()); |
| | | |
| | | //过滤半径 |
| | | for (Map<String, Object> carMap : onlineList) { |
| | | String carId = (String) carMap.get("carId"); |
| | | Map<String, Object> carGPSTrack = sYClient.getCarNearPositionByCarId(syUrl, carId, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> carGPSMap = (List<Map<String, Object>>) carGPSTrack.get("list"); |
| | | Double lng = Double.valueOf((String) carGPSMap.get(0).get("lng")); |
| | | Double lat = Double.valueOf((String) carGPSMap.get(0).get("lat")); |
| | | Point point = new Point(lng,lat); |
| | | boolean inPolygon = GisUtil.isInPolygon(point, partitionLocation); |
| | | if (inPolygon) { |
| | | carMap.put("longitude", lng); |
| | | carMap.put("latitude", lat); |
| | | filteredList.add(carMap); // 将满足条件的车辆添加到筛选列表中 |
| | | } |
| | | } |
| | | } |
| | | //过滤在线车辆 |
| | | List<Map<String, Object>> onlineList = allList.stream() |
| | | .filter(map -> !"离线".equals(map.get("stateCn"))) |
| | | .collect(Collectors.toList()); |
| | | List<Map<String, Object>> filteredList = new ArrayList<>(); |
| | | //过滤半径 |
| | | for (Map<String, Object> carMap : onlineList) { |
| | | String carId = (String) carMap.get("carId"); |
| | | Map<String, Object> carGPSTrack = sYClient.getCarNearPositionByCarId(syUrl, carId, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> carGPSMap = (List<Map<String, Object>>) carGPSTrack.get("list"); |
| | | Double lng = Double.valueOf((String) carGPSMap.get(0).get("lng")); |
| | | Double lat = Double.valueOf((String) carGPSMap.get(0).get("lat")); |
| | | double distance = GisTool.getDistance( new double[]{longitude,latitude}, new double[]{lng, lat}); |
| | | if (distance <= radius) { |
| | | filteredList.add(carMap); // 将满足条件的车辆添加到筛选列表中 |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | log.error("获取范围内的车辆信息(多边形)异常:" + ex.getMessage()); |
| | | } |
| | | return filteredList; |
| | | } |
| | | |
| | | @Override |
| | | public List<ArdSyCar> all() { |
| | | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.ne("reserved_1",""); |
| | | return ardSyCarMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getAlarmHPfmCountDetail(String sessionId, String usersId, String carId, String startTime, String endTime, String syURL) { |
| | | // System.out.println("sessionId------"+sessionId+",usersId-----"+usersId+",carId-----"+carId+",startTime----"+startTime+",endTime----"+endTime+",syURL----"+syURL); |
| | | return sYClient.getAlarmHPfmCountDetail(syURL,carId,sessionId,startTime,endTime); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getOnlineSYCarPosition(String soilderId) { |
| | | Map<String,Object> result = new HashMap(); |
| | | ArdSyUser ardSyUserPara = new ArdSyUser(); |
| | | ardSyUserPara.setSysUserId(soilderId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara); |
| | | if(ardSyUserList.size() == 0){ |
| | | result.put("code","0"); |
| | | result.put("msg","登录用户未挂接三一车辆账号"); |
| | | result.put("SYCarPositionList",new ArrayList()); |
| | | return result; |
| | | } |
| | | ArdAppApplication ardAppApplicationPara = new ArdAppApplication(); |
| | | ardAppApplicationPara.setSoilderId(soilderId); |
| | | ardAppApplicationPara.setApplicationType("SYCar"); |
| | | ardAppApplicationPara.setState("1"); |
| | | List<ArdAppApplication> ardAppApplicationList = ardAppApplicationMapper.selectArdAppApplicationList(ardAppApplicationPara); |
| | | if(ardAppApplicationList.size() == 0){ |
| | | result.put("code","0"); |
| | | result.put("msg","登录用户未经指挥端同意"); |
| | | result.put("SYCarPositionList",new ArrayList()); |
| | | return result; |
| | | } |
| | | SysUser sysUser = userMapper.selectUserById(soilderId);//获取系统用户 |
| | | List<Long> deptIdList = new ArrayList(); |
| | | deptIdList.add(sysUser.getDeptId()); |
| | | deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//递归查询下属部门主键 |
| | | List<String> carIdList = ardSyCarMapper.selectArdSyCarByDeptIds(deptIdList); |
| | | String carIds = ""; |
| | | for(String carId : carIdList){ |
| | | carIds = carIds + carId + ","; |
| | | } |
| | | carIds = carIds.substring(0,carIds.length() - 1); |
| | | String syURL = ""; |
| | | List<SysConfig> sysConfigResult = sysConfigMapper.selectByType("syCarPT"); |
| | | if(sysConfigResult.size() > 0){ |
| | | syURL = sysConfigResult.get(0).getConfigValue(); |
| | | }else{ |
| | | result.put("code","0"); |
| | | result.put("msg","三一车辆url没有录入"); |
| | | result.put("SYCarPositionList",new ArrayList()); |
| | | return result; |
| | | } |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUserList.get(0).getPassword()); |
| | | Map<String,Object> syLoginResult = sYClient.logIn(syURL, passwordMd5, ardSyUserList.get(0).getUserId()); |
| | | String sessionId = (String) syLoginResult.get("sessionId"); |
| | | Map<String,Object> carNearPositionResult = sYClient.getCarNearPositionByCarId(syURL, carIds, ardSyUserList.get(0).getUserId(),sessionId); |
| | | if(((String)carNearPositionResult.get("rspCode")).equals("1")){ |
| | | result.put("code","1"); |
| | | result.put("msg","三一车辆查询成功"); |
| | | List<Map<String,Object>> SYCarPositionList = (List<Map<String, Object>>) carNearPositionResult.get("list"); |
| | | //筛选在线 |
| | | SYCarPositionList = SYCarPositionList.stream().filter(map -> ((String)map.get("stateCn")).startsWith("在线")).collect(Collectors.toList()); |
| | | for(Map<String,Object> sycar : SYCarPositionList){ |
| | | Map<String,Object> map = ardSyCarMapper.getArdSyCarAndDeptByCarId((String)sycar.get("carId")); |
| | | sycar.putAll(map); |
| | | } |
| | | result.put("SYCarPositionList",SYCarPositionList); |
| | | return result; |
| | | }else{ |
| | | result.put("code","0"); |
| | | result.put("msg","三一车辆查询失败"); |
| | | result.put("SYCarPositionList",new ArrayList()); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){ |
| | | deptIdListr.addAll(deptIdList); |
| | | List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList); |
| | | if(result.size() != 0){ |
| | | deptIdListr.addAll(result); |
| | | result = getOwnAndChildrenDeptIdList(result,deptIdListr); |
| | | } |
| | | deptIdListr = deptIdListr.stream().distinct().collect(Collectors.toList()); |
| | | return deptIdListr; |
| | | } |
| | | } |