| | |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.net.UnknownHostException; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * app位置Controller |
| | | * |
| | | * |
| | | * @author ard |
| | | * @date 2023-07-18 |
| | | */ |
| | | @Api(tags = "app位置") |
| | | @RestController |
| | | @RequestMapping("/app/position") |
| | | public class ArdAppPositionController extends BaseController |
| | | { |
| | | public class ArdAppPositionController extends BaseController { |
| | | @Autowired |
| | | private IArdAppPositionService ardAppPositionService; |
| | | @Autowired |
| | |
| | | @ApiOperation("查询app位置列表") |
| | | // @PreAuthorize("@ss.hasPermi('app:position:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(ArdAppPosition ardAppPosition) |
| | | { |
| | | public TableDataInfo list(ArdAppPosition ardAppPosition) { |
| | | startPage(); |
| | | List<ArdAppPosition> list = ardAppPositionService.selectArdAppPositionList(ardAppPosition); |
| | | return getDataTable(list); |
| | |
| | | @PreAuthorize("@ss.hasPermi('app:position:export')") |
| | | @Log(title = "app位置", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ArdAppPosition ardAppPosition) |
| | | { |
| | | public void export(HttpServletResponse response, ArdAppPosition ardAppPosition) { |
| | | List<ArdAppPosition> list = ardAppPositionService.selectArdAppPositionList(ardAppPosition); |
| | | ExcelUtil<ArdAppPosition> util = new ExcelUtil<ArdAppPosition>(ArdAppPosition.class); |
| | | util.exportExcel(response, list, "app位置数据"); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('app:position:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") String id) |
| | | { |
| | | public AjaxResult getInfo(@PathVariable("id") String id) { |
| | | return success(ardAppPositionService.selectArdAppPositionById(id)); |
| | | } |
| | | |
| | |
| | | // @PreAuthorize("@ss.hasPermi('app:position:add')") |
| | | @Log(title = "app位置", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ArdAppPosition ardAppPosition) |
| | | { |
| | | public AjaxResult add(@RequestBody ArdAppPosition ardAppPosition) { |
| | | return AjaxResult.success(ardAppPositionService.insertArdAppPosition(ardAppPosition)); |
| | | } |
| | | |
| | |
| | | @PreAuthorize("@ss.hasPermi('app:position:edit')") |
| | | @Log(title = "app位置", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ArdAppPosition ardAppPosition) |
| | | { |
| | | public AjaxResult edit(@RequestBody ArdAppPosition ardAppPosition) { |
| | | return toAjax(ardAppPositionService.updateArdAppPosition(ardAppPosition)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('app:position:remove')") |
| | | @Log(title = "app位置", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable String[] ids) |
| | | { |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable String[] ids) { |
| | | return toAjax(ardAppPositionService.deleteArdAppPositionByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有用户 |
| | | */ |
| | | @ApiOperation("获取所有用户") |
| | | @GetMapping("/getUserlist") |
| | | public AjaxResult getUserlist(Long deptId) |
| | | { |
| | | SysUser user=new SysUser(); |
| | | public AjaxResult getUserlist(Long deptId) { |
| | | SysUser user = new SysUser(); |
| | | user.setDeptId(deptId); |
| | | List<SysUser> list = sysUserService.selectUserList(user); |
| | | return AjaxResult.success(list); |
| | |
| | | List<SysUser> list = sysUserService.selectAllAppUserList(user); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有app用户 |
| | | */ |
| | | @ApiOperation("获取所有app用户pc") |
| | | @GetMapping("/getAppUserForPclist") |
| | | public AjaxResult getAppUserForPclist(Long deptId) |
| | | { |
| | | SysUser user=new SysUser(); |
| | | public AjaxResult getAppUserForPclist(Long deptId) { |
| | | SysUser user = new SysUser(); |
| | | user.setDeptId(deptId); |
| | | List<SysUser> list = sysUserService.selectAllAppUserList(user); |
| | | List<SysUser> onLineList=new ArrayList<>(); |
| | | List<SysUser> offLineList=new ArrayList<>(); |
| | | for(SysUser sysUser:list) |
| | | { |
| | | List<SysUser> onLineList = new ArrayList<>(); |
| | | List<SysUser> offLineList = new ArrayList<>(); |
| | | for (SysUser sysUser : list) { |
| | | ArdAppPosition ardAppPosition = ardAppPositionService.selectLastArdAppPositionByUserId(sysUser.getUserId()); |
| | | if(ardAppPosition!=null) { |
| | | Map<String, Object> params =new HashMap<>(); |
| | | if (ardAppPosition != null) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("longitude", ardAppPosition.getLongitude()); |
| | | params.put("latitude", ardAppPosition.getLatitude()); |
| | | params.put("altitude", ardAppPosition.getAltitude()); |
| | | params.put("bearing", ardAppPosition.getBearing()); |
| | | sysUser.setParams(params); |
| | | } |
| | | if(StringUtils.isNotNull(sysUser.getAppOnlineState())) |
| | | { |
| | | if(sysUser.getAppOnlineState().equals("1")) |
| | | { |
| | | if (StringUtils.isNotNull(sysUser.getAppOnlineState())) { |
| | | if (sysUser.getAppOnlineState().equals("1")) { |
| | | onLineList.add(sysUser); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | offLineList.add(sysUser); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | offLineList.add(sysUser); |
| | | } |
| | | |
| | | } |
| | | Map<String,Object> onlineMap=new HashMap<>(); |
| | | onlineMap.put("children",onLineList); |
| | | onlineMap.put("name","在线用户("+onLineList.size()+")"); |
| | | onlineMap.put("disabled",true); |
| | | onlineMap.put("id","onLine"); |
| | | Map<String,Object> offlineMap=new HashMap<>(); |
| | | offlineMap.put("children",offLineList); |
| | | offlineMap.put("name","离线用户("+offLineList.size()+")"); |
| | | offlineMap.put("disabled",true); |
| | | offlineMap.put("id","offLine"); |
| | | List< Map<String,Object> > lists = new ArrayList<>(); |
| | | Map<String, Object> onlineMap = new HashMap<>(); |
| | | onlineMap.put("children", onLineList); |
| | | onlineMap.put("name", "在线用户(" + onLineList.size() + ")"); |
| | | onlineMap.put("disabled", true); |
| | | onlineMap.put("id", "onLine"); |
| | | Map<String, Object> offlineMap = new HashMap<>(); |
| | | offlineMap.put("children", offLineList); |
| | | offlineMap.put("name", "离线用户(" + offLineList.size() + ")"); |
| | | offlineMap.put("disabled", true); |
| | | offlineMap.put("id", "offLine"); |
| | | List<Map<String, Object>> lists = new ArrayList<>(); |
| | | lists.add(onlineMap); |
| | | lists.add(offlineMap); |
| | | return AjaxResult.success(lists); |
| | |
| | | */ |
| | | @ApiOperation("获取用户详情") |
| | | @GetMapping("/getUserInfo") |
| | | public AjaxResult getUserInfo(String userId) |
| | | { |
| | | public AjaxResult getUserInfo(String userId) { |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | | return AjaxResult.success(sysUser); |
| | | } |
| | | |
| | | @PostMapping("/uploadFile") |
| | | @ApiOperation("上传文件") |
| | | public AjaxResult uploadFile(MultipartFile file,String type) |
| | | { |
| | | String url = MinioUtil.putObjectAndGetUrl("app",type, file); |
| | | return AjaxResult.success(url); |
| | | public AjaxResult uploadFile(MultipartFile file, String type) throws MalformedURLException, UnknownHostException { |
| | | String urlStr = MinioUtil.putObjectAndGetUrl("app", type, file); |
| | | URL url = new URL(urlStr); |
| | | // 替换 https 为 http,并将主机名和端口号替换为本地地址 |
| | | String serverIpAddress = InetAddress.getLocalHost().getHostAddress(); |
| | | // 构建新的 URL 对象,使用 HTTPS 协议 |
| | | URL httpsUrl = new URL("https", serverIpAddress, url.getPort(), url.getFile()); |
| | | return AjaxResult.success(httpsUrl); |
| | | } |
| | | |
| | | @GetMapping("/getOnlinePCOrCommander") |
| | | @ApiOperation("查询本部门在线PC端及指挥端") |
| | | public AjaxResult getOnlinePCOrCommander() { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | Map<String,List<SysUser>> result = ardAppPositionService.getOnlinePCOrCommander(usersId); |
| | | Map<String, List<SysUser>> result = ardAppPositionService.getOnlinePCOrCommander(usersId); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | @PostMapping("/sendCheckCommandersPosition") |
| | | @ApiOperation("发起查看指挥端位置") |
| | | public AjaxResult sendCheckCommandersPosition(@RequestBody Map<String,Object> para) { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | ardAppPositionService.sendCheckCommandersPosition(usersId,para); |
| | | return AjaxResult.success(); |
| | | }catch(Exception e){ |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/sendCheckSYCarsPosition") |
| | | @ApiOperation("发起查看车辆位置") |
| | | public AjaxResult sendCheckSYCarsPosition(@RequestBody Map<String,Object> para) { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | ardAppPositionService.sendCheckSYCarsPosition(usersId,para); |
| | | return AjaxResult.success(); |
| | | }catch(Exception e){ |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/getCheckCommandersPosition") |
| | | @ApiOperation("指挥端查看指挥端位置申请") |
| | | public AjaxResult getCheckCommandersPosition() {//弃用 |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | List<Map<String,Object>> result = ardAppPositionService.getCheckCommandersPosition(usersId); |
| | | @GetMapping("/getOnlineCommanderPosition") |
| | | @ApiOperation("单兵端查看已通过审批的在线指挥端位置") |
| | | public AjaxResult getOnlineCommanderPosition() { |
| | | String soilderId = SecurityUtils.getUserId(); |
| | | try { |
| | | List<Map<String, Object>> result = ardAppPositionService.getOnlineCommanderPosition(soilderId); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/getCheckSYCarsPosition") |
| | | @ApiOperation("指挥端查看车辆位置申请") |
| | | public AjaxResult getCheckSYCarsPosition() {//弃用 |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | List<Map<String,Object>> result = ardAppPositionService.getCheckSYCarsPosition(usersId); |
| | | @PostMapping("/getAPPPositionByUserIdAndTime") |
| | | @ApiOperation("查看APP历史位置") |
| | | public AjaxResult getAPPPositionByUserIdAndTime(@RequestBody Map<String, String> para) { |
| | | try { |
| | | List<ArdAppPosition> result = ardAppPositionService.getAPPPositionByUserIdAndTime(para); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/getCheckPosition") |
| | | @ApiOperation("指挥端查看位置申请") |
| | | public AjaxResult getCheckPosition() { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | Map<String,List<Map<String,Object>>> result = ardAppPositionService.getCheckPosition(usersId); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | @GetMapping("/getOnlineAPPSoilderByCommanderId") |
| | | public AjaxResult getOnlineAPPSoilderByCommanderId() { |
| | | String userId = SecurityUtils.getUserId(); |
| | | return success(ardAppPositionService.getOnlineAPPSoilderByCommanderId(userId)); |
| | | } |
| | | |
| | | } |