| | |
| | | package com.ruoyi.sy.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.text.Collator; |
| | | import java.util.*; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ruoyi.client.ARDCarGPSLogInClient; |
| | | import com.ruoyi.client.ARDCarSYGPSClient; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.sy.domain.ArdSyUser; |
| | | import com.ruoyi.sy.service.IArdSyUserService; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.utils.httpclient.SYCarClient; |
| | | import com.ruoyi.utils.result.Results; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.bytedeco.javacv.CanvasFrame; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import com.ruoyi.sy.service.IArdSyCarService; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private ISysConfigService sysConfigService; |
| | | |
| | | private Map<Integer,Map<String,String>> logInMap = new HashMap(); |
| | | |
| | | |
| | | @Autowired |
| | | private IArdSyUserService iArdSyUserService; |
| | | |
| | | |
| | | /** |
| | | * 查询三一车辆列表 |
| | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:remove')") |
| | | @Log(title = "三一车辆", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | @ApiOperation("删除三一车辆") |
| | | public AjaxResult remove(@PathVariable String[] ids) |
| | | { |
| | | return toAjax(ardSyCarService.deleteArdSyCarByIds(ids)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取全部的三一车辆 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:getArdSyCarAll')") |
| | | @PostMapping("/getArdSyCarAll") |
| | | @ApiOperation("获取全部的三一车辆") |
| | | public Map<String,Object> getArdSyCarAll(){ |
| | | String userId = SecurityUtils.getUserId(); |
| | | Map<String,Object> result = ardSyCarService.getArdSyCarAll(userId); |
| | | if(((String)result.get("code")).equals("500")){ |
| | | return error((String) result.get("data")); |
| | | }else if(((String)result.get("code")).equals("200")){ |
| | | return success(result.get("data")); |
| | | }else{ |
| | | return error(""); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取全部车辆模型 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:getAllCarModel')") |
| | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:uploadCarPicture')") |
| | | @PostMapping("/uploadCarPicture") |
| | | @ApiOperation("上传车辆图片") |
| | | public Map<String,Object> uploadCarPicture(@RequestParam("id") String id,@RequestParam("carPicture") MultipartFile carPicture){ |
| | | public Map<String,Object> uploadCarPicture(@RequestParam(value = "id",required = false,defaultValue = "") String id,@RequestParam("carPicture") MultipartFile carPicture){ |
| | | try{ |
| | | String result = ardSyCarService.uploadCarPicture(id,carPicture); |
| | | return success(result); |
| | |
| | | } |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:allListByUser')") |
| | | @PostMapping("allListByUser") |
| | | @ApiOperation("根据用户获取三一列表") |
| | | public Map<String,Object> allListByUser(){ |
| | | String usersId = SecurityUtils.getUserId(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | Map<String,Object> result0 = new HashMap(); |
| | | //判断关联表是否有数据 |
| | | if(ardSyUser!=null){ |
| | | //31用户名密码 |
| | | String username31 = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | //查询地址 |
| | | Map<String, String> result = logInMap.get(Integer.parseInt(usersId)); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | Map<String, Object> result1 = ARDCarGPSLogInClient.loginIn(syURL,username31, password31); |
| | | result = new HashMap(); |
| | | result.put("userId", username31); |
| | | result.put("sessionId", (String) result1.get("sessionId")); |
| | | try { |
| | | result0 = ARDCarSYGPSClient.getCarGPSTeamList(syURL,result.get("userId"),result.get("sessionId"));// |
| | | } catch (Exception e) { |
| | | Map<String,Object> map = new HashMap(); |
| | | map.put("rspCode", 0); |
| | | map.put("list", new ArrayList()); |
| | | return map; |
| | | } |
| | | int online = 0; |
| | | for(Map<String,Object> map : (List<Map<String,Object>>) result0.get("list")){ |
| | | Map<String,Object> resultMap = (Map<String, Object>) ARDCarSYGPSClient.getCarListByTeamId(syURL,(String)map.get("teamId"),result.get("sessionId")); |
| | | List<Map<String,Object>> carList = (List<Map<String, Object>>) resultMap.get("carList"); |
| | | for(Map<String,Object> m : carList){ |
| | | if(((String) m.get("stateCn")).contains("在线")){ |
| | | online = online + 1; |
| | | }else{ |
| | | 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"))); |
| | | } |
| | | } |
| | | map.put("online", online); |
| | | online = 0; |
| | | } |
| | | }else { |
| | | result0.put("列表为空!","无关联账号!"); |
| | | } |
| | | return result0; |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:carList')") |
| | | @PostMapping("carList") |
| | | @ApiOperation("根据teamId获取车辆列表") |
| | | public Results getCarList(@RequestBody Map<String,String> map){ |
| | | String usersId = SecurityUtils.getUserId(); |
| | | Map<String, String> result = logInMap.get(Integer.parseInt(usersId)); |
| | | String teamId = map.get("teamId"); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | //判断关联表是否有数据 |
| | | if(ardSyUser!=null) { |
| | | //31用户名密码 |
| | | String username31 = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | Map<String, Object> userMap = ARDCarGPSLogInClient.loginIn(syURL,username31, password31); |
| | | result = new HashMap(); |
| | | result.put("userId", username31); |
| | | result.put("sessionId", (String) userMap.get("sessionId")); |
| | | } |
| | | //查询该teamId下的车辆数据 |
| | | Map<String,Object> carList31 = new HashMap(); |
| | | try { |
| | | carList31 = ARDCarSYGPSClient.getCarListByTeamId(syURL,teamId, result.get("userId"),result.get("sessionId")); |
| | | } catch (Exception e) { |
| | | Map<String,Object> m = iArdSyUserService.selectArdSyUserByUsersId(Integer.parseInt(usersId)); |
| | | if(m == null){ |
| | | Results.error("当前登录用户未挂接车辆权限"); |
| | | } |
| | | Map<String,Object> map0 = ARDCarGPSLogInClient.loginIn(syURL,(String) m.get("userId"), (String) m.get("password")); |
| | | carList31 = ARDCarSYGPSClient.getCarListByTeamId(syURL,teamId, (String) m.get("userId"),(String) map0.get("sessionId")); |
| | | } |
| | | //拿到车辆数据 |
| | | List<Map<String,String>> list = (List) carList31.get("list"); |
| | | List<String> carIdList = new ArrayList(); |
| | | //所有carId |
| | | for(Map<String,String> m : list){ |
| | | carIdList.add(m.get("carId")); |
| | | } |
| | | if(carIdList.size() == 0){ |
| | | Map<String,Object> map0 = new HashMap(); |
| | | map0.put("list", new ArrayList()); |
| | | map0.put("rspCode", "1"); |
| | | return Results.succeed(); |
| | | } |
| | | //添加车辆属性 |
| | | for(Map<String,String> m : list){ |
| | | switch (m.get("state")) { |
| | | case "1": |
| | | m.put("carState", "离线-从未报定位");break; |
| | | case "2": |
| | | m.put("carState", "离线-欠费");break; |
| | | case "3": |
| | | m.put("carState", "离线");break; |
| | | case "4": |
| | | m.put("carState", "离线-报警");break; |
| | | case "5": |
| | | m.put("carState", "在线-从未报定位");break; |
| | | case "6": |
| | | m.put("carState", "在线-欠费");break; |
| | | case "7": |
| | | m.put("carState", "在线-行驶");break; |
| | | case "8": |
| | | m.put("carState", "在线-行驶-报警");break; |
| | | case "9": |
| | | m.put("carState", "在线-停车-ACC关");break; |
| | | case "10": |
| | | m.put("carState", "在线-停车-ACC开");break; |
| | | case "11": |
| | | m.put("carState", "在线-停车-ACC关-报警");break; |
| | | case "12": |
| | | m.put("carState", "在线-停车-ACC开-报警");break; |
| | | case "13": |
| | | m.put("carState", "在线-无效定位");break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | // for(Map<String,String> m : list0){ |
| | | // for(Map<String,String> ma : list1){ |
| | | // if(m.get("carId").equals(ma.get("carId"))){ |
| | | // m.put("stateCn", ma.get("carState")); |
| | | // } |
| | | // } |
| | | // } |
| | | // Collections.sort((List)result0.get("list"),new Comparator<Map<String, Object>>() { |
| | | // @Override |
| | | // public int compare(Map<String, Object> o1, Map<String, Object> o2) { |
| | | // Comparator<Object> com = Collator.getInstance(java.util.Locale.CHINA); |
| | | // return com.compare(o2.get("stateCn"), o1.get("stateCn")); |
| | | // } |
| | | // }); |
| | | return Results.succeed(list); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:carListById')") |
| | | @GetMapping("/carListById/{id}") |
| | | @ApiOperation("根据车辆ID获取车辆列表") |
| | | public Results carListById(@PathVariable String id){ |
| | | return ardSyCarService.carListById(id); |
| | | } |
| | | } |