| | |
| | | package com.ruoyi.sy.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.annotation.PostConstruct; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | 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.gps31.PushClientImplPosition; |
| | | import com.ruoyi.sy.service.IArdSyUserService; |
| | | import com.ruoyi.sy.service.SysParaService; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.utils.httpclient.SYCarClient; |
| | |
| | | |
| | | @Autowired |
| | | private ISysConfigService sysConfigService; |
| | | |
| | | private Map<Integer,Map<String,String>> logInMap = new HashMap(); |
| | | |
| | | @Autowired |
| | | private SysParaService sysParaService; |
| | | |
| | | @Autowired |
| | | private IArdSyUserService iArdSyUserService; |
| | | |
| | | private ArdSyCarController ardSyCarController; |
| | | |
| | | @PostConstruct |
| | | public void init(){ |
| | | ardSyCarController = this; |
| | | ardSyCarController.sysConfigService = this.sysConfigService; |
| | | ardSyCarController.iArdSyUserService = this.iArdSyUserService; |
| | | |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigKey("syCarPT"); |
| | | List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config); |
| | | String syURL = ""; |
| | | if(sysConfigResult.size() == 0){ |
| | | return; |
| | | }else{ |
| | | syURL = sysConfigResult.get(0).getConfigValue(); |
| | | } |
| | | String ip = syURL.split(":")[1].replace("//", ""); |
| | | List<ArdSyUser> ardSyUserList = iArdSyUserService.selectSyUser(); |
| | | //车辆实时位置线程 |
| | | PushClientImplPosition pushClientImplPosition = new PushClientImplPosition(ip,ardSyUserList.get(0).getUserId(),ardSyUserList.get(0).getPassword()); |
| | | Thread pushClientImplPositionThread = new Thread(pushClientImplPosition); |
| | | pushClientImplPositionThread.start(); |
| | | } |
| | | |
| | | /** |
| | | * 查询三一车辆列表 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取全部的三一车辆 |
| | | */ |
| | | @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 = sysParaService.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:carListById')") |
| | | @GetMapping("carListById") |
| | | @ApiOperation("根据车辆ID获取车辆列表") |
| | | public List<ArdSyCar> carListById(String id){ |
| | | return ardSyCarService.carListById(id); |
| | | } |
| | | } |