| | |
| | | |
| | | 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; |
| | |
| | | @Resource |
| | | private ArdSyCarDayMapper ardSyCarDayMapper; |
| | | |
| | | @Resource |
| | | private ArdAppApplicationMapper ardAppApplicationMapper; |
| | | |
| | | @Resource |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | @Value("${minio.endpoint}") |
| | | private String minioEndpoint; |
| | | |
| | |
| | | @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)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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 = ""; |
| | | if (ardSyCar.getCarPicture() != null) { |
| | |
| | | url = ardSyCar.getCarPicture().split("sycar")[0]; |
| | | } |
| | | }*/ |
| | | m.put("carModel", this.minioEndpoint + "/" + 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; |
| | |
| | | } |
| | | |
| | | @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 |
| | |
| | | params.put("action", "0");//上传模式 |
| | | String paramsStr = com.alibaba.fastjson2.JSON.toJSONString(params); |
| | | paramsStr = URLEncoder.encode(paramsStr,"UTF-8"); |
| | | System.out.println(paramsStr); |
| | | 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"); |
| | | return sYClient.getPhoto(syURL,carId,startTime,sdf.format(new Date()),sessionId); |
| | | String endTime = sdf.format(new Date()); |
| | | System.out.println("开始时间:"+startTime+" 结束时间:"+endTime); |
| | | return sYClient.getPhoto(syURL,carId,startTime,endTime,sessionId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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)); |
| | | //WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); |
| | | String sessionId = ""; |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | if(key.startsWith(usersId + "_")){ |
| | | sessionId = key; |
| | | } |
| | | } |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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)); |
| | | //WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); |
| | | String sessionId = ""; |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | if(key.startsWith(usersId + "_")){ |
| | | sessionId = key; |
| | | } |
| | | } |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sessionId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |