| | |
| | | package com.ruoyi.sy.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.sy.domain.ArdSyUser; |
| | | import com.ruoyi.sy.gps31.PushClientImplAlarm; |
| | | import com.ruoyi.sy.gps31.PushClientImplPosition; |
| | | 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.system.service.ISysDeptService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.utils.forest.SYClient; |
| | | import com.ruoyi.utils.result.Results; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.bytedeco.javacv.CanvasFrame; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | @Autowired |
| | | private ISysConfigService sysConfigService; |
| | | |
| | | private Map<Integer,Map<String,String>> logInMap = new HashMap(); |
| | | |
| | | |
| | | @Autowired |
| | | private IArdSyUserService iArdSyUserService; |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | |
| | | @Autowired |
| | | private ISysDeptService sysDeptService; |
| | | |
| | | @Resource |
| | | private SYClient sYClient; |
| | | |
| | | 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(); |
| | | |
| | | Date date = new Date(); |
| | | Timer carPositionTimer = new Timer();//定时推送实时位置 |
| | | TimerTask carPositionTask =new TimerTask(){ |
| | | @Override |
| | | public void run(){ |
| | | ardSyCarService.sendArdSyCarPosition(); |
| | | } |
| | | }; |
| | | carPositionTimer.scheduleAtFixedRate(carPositionTask,date,3*1000);//启用 |
| | | |
| | | //车辆实时位置线程 |
| | | PushClientImplAlarm pushClientImplAlarm = new PushClientImplAlarm(ip,ardSyUserList.get(0).getUserId(),ardSyUserList.get(0).getPassword()); |
| | | Thread pushClientImplAlarmThread = new Thread(pushClientImplAlarm); |
| | | pushClientImplAlarmThread.start(); |
| | | } |
| | | |
| | | /** |
| | | * 查询三一车辆列表 |
| | |
| | | @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)); |
| | |
| | | return error("三一车辆url没有录入"); |
| | | }else{ |
| | | syURL = sysConfigResult.get(0).getConfigValue(); |
| | | Map<String,Object> result = SYCarClient.logIn(syURL,userId, password); |
| | | //Map<String,Object> result = SYCarClient.logIn(syURL,userId, password); |
| | | String passwordMd5 = DigestUtils.md5Hex(password); |
| | | Map<String,Object> result = sYClient.logIn(syURL,passwordMd5,userId); |
| | | return success(result); |
| | | } |
| | | } |
| | |
| | | public Map<String,Object> getArdSyCarNoRight(){ |
| | | String userId = SecurityUtils.getUserId(); |
| | | Map<String,Object> result = ardSyCarService.getArdSyCarNoRight(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: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")){ |
| | |
| | | @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); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | return ardSyCarService.allListByUser(ardSyUser,syURL,usersId); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:carList')") |
| | | @PostMapping("carList") |
| | | @ApiOperation("根据teamId获取车辆列表") |
| | | public Results getCarList(@RequestBody Map<String,String> map){ |
| | | String usersId = SecurityUtils.getUserId(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | String teamId = map.get("teamId"); |
| | | //判断关联表是否有数据 |
| | | if(ardSyUser!=null) { |
| | | //查询出31的车辆数据 |
| | | List<Map<String,String>> list = ardSyCarService.getCarList(ardSyUser,syURL,usersId,teamId); |
| | | //根据userId查询部门Id |
| | | SysUser sysUser = sysUserService.selectUserById(usersId); |
| | | //根据当前deptId或者当前及所属下级的所有deptId |
| | | List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId()); |
| | | //根据dept集合查询出所有对应的车辆列表并赋值 |
| | | return Results.succeed(ardSyCarService.carIdByDeptList(deptList,list)); |
| | | }else { |
| | | return Results.error("列表为空!无关联账号!"); |
| | | } |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:carListById')") |
| | | @PostMapping("/carListById/{id}") |
| | | @ApiOperation("根据车辆ID获取车辆列表") |
| | | public Results carListById(@PathVariable String id){ |
| | | return ardSyCarService.carListById(id); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:getCarGPSHistory')") |
| | | @PostMapping("getCarGPSHistory") |
| | | @ApiOperation("根据车辆ID获取历史轨迹") |
| | | public Results getCarGPSTrack(@RequestBody Map<String,String> map) { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | return ardSyCarService.getCarGPSTrack(map,syURL, ardSyUser); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('sy:syCar:getArdSyUserByUsersId')") |
| | | @PostMapping("getArdSyUserByUsersId") |
| | | @ApiOperation("获取三一平台对应用户名密码") |
| | | public Results getArdSyUserByUsersId(@RequestBody Map<String,String> map) { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | return Results.succeed(ardSyUser); |
| | | } |
| | | } |