| | |
| | | package com.ruoyi.sy.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.sy.domain.ArdAccessFence; |
| | | import com.ruoyi.sy.domain.ArdSyCarLock; |
| | | import com.ruoyi.sy.domain.ArdSyCarRtu; |
| | | import com.ruoyi.sy.domain.ArdSyUser; |
| | | import com.ruoyi.sy.service.ArdSyCarLockService; |
| | | import com.ruoyi.sy.service.IArdSyCarService; |
| | | import com.ruoyi.sy.service.IArdSyUserService; |
| | | import com.ruoyi.sy.mapper.ArdAccessFenceMapper; |
| | | import com.ruoyi.sy.param.*; |
| | | import com.ruoyi.sy.service.*; |
| | | import com.ruoyi.sy.service.impl.ArdSyCarRtuServiceImpl; |
| | | import com.ruoyi.sy.vo.CarLockVo; |
| | | import com.ruoyi.sy.vo.CarVo; |
| | | import com.ruoyi.sy.vo.RtuVo; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.utils.mqtt.MqttConsumer; |
| | | import com.ruoyi.utils.result.Results; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.eclipse.paho.client.mqttv3.MqttException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private IArdSyCarService ardSyCarService; |
| | | @Autowired |
| | | private ArdSyCarLockService ardSyCarLockService; |
| | | @Autowired |
| | | private ArdAccessFenceService ardAccessFenceService; |
| | | @Autowired |
| | | private ArdSyCarRtuService ardSyCarRtuService; |
| | | |
| | | @GetMapping("/car") |
| | | @ApiOperation("查询所有未挂锁的车辆") |
| | | public Results car(){ |
| | | public AjaxResult car(){ |
| | | List<CarVo> list = ardSyCarLockService.car(); |
| | | analysis(list); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @GetMapping("/carAddOne") |
| | | @ApiOperation("查询所有未挂锁的车辆加本车辆信息") |
| | | public AjaxResult carAddOne(String carId){ |
| | | List<CarVo> list = ardSyCarLockService.carAddOne(carId); |
| | | analysis(list); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @ApiOperation("添加rtu") |
| | | public AjaxResult add(@RequestBody AddRtuParam addRtuParam){ |
| | | return AjaxResult.success("成功添加"+ardSyCarLockService.addRtu(addRtuParam)+"条数据,订阅车辆"+addRtuParam.getCarId()+"成功"); |
| | | } |
| | | |
| | | @DeleteMapping("/del") |
| | | @ApiOperation("删除rtu") |
| | | public AjaxResult del(String id){ |
| | | return AjaxResult.success("成功删除"+ardSyCarLockService.delCar(id)+"条数据"); |
| | | } |
| | | |
| | | @GetMapping("/one") |
| | | @ApiOperation("查询一条rtu及锁") |
| | | public AjaxResult one(String carId){ |
| | | CarLockVo carLockVo = new CarLockVo(); |
| | | CarVo carVo = ardSyCarLockService.carOne(carId); |
| | | String usersId = SecurityUtils.getUserId(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CarVo carVo = list.get(i); |
| | | String carId = carVo.getCarId(); |
| | | Results results = ardSyCarService.getCarGPSBycarId(usersId,carId,syURL,ardSyUser); |
| | | Map<String,Object> map = (Map<String, Object>) results.getData(); |
| | | List list1 = (List) map.get("list"); |
| | | Map<String,Object> map = ardSyCarService.getCarGPSBycarId(usersId,carId,syURL,ardSyUser); |
| | | List list1 = (List) map.get("list"); |
| | | if(list1.size()>0){ |
| | | JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(list1.get(0))); |
| | | String carPlate = (String) jsonObject.get("carPlate"); |
| | | carVo.setCarPlate(carPlate); |
| | |
| | | String drvPhone = (String) jsonObject.get("drvPhone"); |
| | | carVo.setDrvPhone(drvPhone); |
| | | } |
| | | return Results.succeed(list); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @ApiOperation("添加rtu") |
| | | public Results add(String carId){ |
| | | return Results.succeed("成功添加"+ardSyCarLockService.addRtu(carId)+"条数据"); |
| | | } |
| | | |
| | | @DeleteMapping("/del") |
| | | @ApiOperation("删除rtu") |
| | | public Results del(String carId){ |
| | | return Results.succeed("成功删除"+ardSyCarLockService.delCar(carId)+"条数据"); |
| | | } |
| | | |
| | | @GetMapping("/one") |
| | | @ApiOperation("查询一条rtu及锁") |
| | | public Results one(String carId){ |
| | | return Results.succeed(ardSyCarLockService.carLock(carId)); |
| | | String rtu = carVo.getRtu(); |
| | | carLockVo.setCarLockList(ardSyCarLockService.carLock(rtu)); |
| | | ArdSyCarRtu ardSyCarRtu = ardSyCarRtuService.one(carId); |
| | | carVo.setInstallType(ardSyCarRtu.getInstallType()); |
| | | carVo.setUnloadType(ardSyCarRtu.getUnloadType()); |
| | | carLockVo.setCar(carVo); |
| | | return AjaxResult.success(carLockVo); |
| | | } |
| | | |
| | | @GetMapping("/query") |
| | | @ApiOperation("查询所有rtu挂载的车辆") |
| | | public Results query(){ |
| | | return Results.succeed(ardSyCarLockService.carList()); |
| | | public Results query(LockPageParam lockPageParam){ |
| | | List<CarVo> list = ardSyCarLockService.carList(); |
| | | analysis(list); |
| | | List<CarVo> newList = new ArrayList<>(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | String plate = list.get(i).getCarPlate(); |
| | | if(lockPageParam.getCarPlate()!=null){ |
| | | if(plate.contains(lockPageParam.getCarPlate())){ |
| | | newList.add(list.get(i)); |
| | | } |
| | | } |
| | | } |
| | | PageHelper.startPage(lockPageParam.getPageNum(),lockPageParam.getPageSize()); |
| | | if(lockPageParam.getCarPlate()!=null){ |
| | | return Results.succeed(new PageInfo<>(newList)); |
| | | }else { |
| | | return Results.succeed(new PageInfo<>(list)); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/addLock") |
| | | @PostMapping("/addLock") |
| | | @ApiOperation("添加修改锁") |
| | | public Results addLock(@RequestBody List<ArdSyCarLock> locks){ |
| | | return Results.succeed(ardSyCarLockService.addUpdLock(locks)); |
| | | return Results.succeed("成功添加/修改"+ardSyCarLockService.addUpdLock(locks)+"条数据"); |
| | | } |
| | | |
| | | @GetMapping("/oneRtu") |
| | | @ApiOperation("更改Rtu前查询") |
| | | public Results oneRtu(String carId){ |
| | | RtuVo rtuVo = ardSyCarLockService.updRtu(carId); |
| | | String usersId = SecurityUtils.getUserId(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | Map<String,Object> map = ardSyCarService.getCarGPSBycarId(usersId,carId,syURL,ardSyUser); |
| | | List list1 = (List) map.get("list"); |
| | | JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(list1.get(0))); |
| | | String carPlate = (String) jsonObject.get("carPlate"); |
| | | rtuVo.setCarPlate(carPlate); |
| | | String drvName = (String) jsonObject.get("drvName"); |
| | | rtuVo.setDrvName(drvName); |
| | | String drvPhone = (String) jsonObject.get("drvPhone"); |
| | | rtuVo.setDrvPhone(drvPhone); |
| | | return Results.succeed(rtuVo); |
| | | } |
| | | |
| | | @PutMapping("/updRtu") |
| | | @ApiOperation("更改Rtu") |
| | | public Results updRtu(@RequestBody ArdSyCarRtu ardSyCarRtu){ |
| | | return Results.succeed("成功修改"+ardSyCarLockService.updRtuCar(ardSyCarRtu)+"条数据"); |
| | | } |
| | | |
| | | @GetMapping("/queryCar") |
| | | @ApiOperation("清淤手动添加车辆查询") |
| | | public AjaxResult queryCar(){ |
| | | String url = sysConfigService.selectConfigByKey("minioIn")+"/"; |
| | | List<ArdAccessFence> ardAccessFences = ardAccessFenceService.all(url); |
| | | List<String> carIdList = new ArrayList<>(); |
| | | for (int i = 0; i < ardAccessFences.size(); i++) { |
| | | String carId = ardAccessFences.get(i).getCarId(); |
| | | carIdList.add(carId); |
| | | } |
| | | List<CarVo> list = ardSyCarLockService.queryCar(carIdList); |
| | | analysis(list); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/addCar") |
| | | @ApiOperation("清淤手动添加车辆保存") |
| | | public AjaxResult addCar(@RequestBody AddCarParam addCarParam){ |
| | | List<CarVo> list = ardSyCarLockService.addCarBefore(addCarParam.getCarId()); |
| | | analysis(list); |
| | | if(list.size()>0){ |
| | | String usersId = SecurityUtils.getUserId(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | Map<String, Object> map = ardSyCarService.getCarGPSBycarId(usersId,addCarParam.getCarId(),syURL,ardSyUser); |
| | | List list1 = (List) map.get("list"); |
| | | JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(list1.get(0))); |
| | | String lng = (String) jsonObject.get("lng"); |
| | | String lat = (String) jsonObject.get("lat"); |
| | | return AjaxResult.success(ardAccessFenceService.addCar(list.get(0),addCarParam.getIsAlarm(),lng,lat)); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/delCar") |
| | | @ApiOperation("清淤手动添加车辆删除") |
| | | public AjaxResult delCar(String id){ |
| | | return AjaxResult.success(ardAccessFenceService.delCar(id)); |
| | | } |
| | | |
| | | @PutMapping("/cleanAlarm") |
| | | @ApiOperation("清空报警") |
| | | public AjaxResult updCarAlarm(String id){ |
| | | return AjaxResult.success(ardAccessFenceService.updCarAlarm(id)); |
| | | } |
| | | |
| | | @PostMapping("/onOff") |
| | | @ApiOperation("远程开锁") |
| | | public AjaxResult onOff(@RequestBody LockTypeParam lockTypeParam) throws MqttException { |
| | | return ardSyCarLockService.onOff(lockTypeParam); |
| | | } |
| | | |
| | | @PostMapping("/seal") |
| | | @ApiOperation("远程封印") |
| | | public AjaxResult seal(@RequestBody RtuTypeParam rtuTypeParam) { |
| | | return ardSyCarLockService.seal(rtuTypeParam); |
| | | } |
| | | |
| | | @GetMapping("/lockIng") |
| | | @ApiOperation("实时锁状态") |
| | | public AjaxResult lockIng(String carId) { |
| | | return ardSyCarLockService.lockIng(carId); |
| | | } |
| | | |
| | | |
| | | //获取31车辆车牌号驾驶员和电话 |
| | | public List<CarVo> analysis(List<CarVo> list){ |
| | | String usersId = SecurityUtils.getUserId(); |
| | | ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); |
| | | String syURL = sysConfigService.getSYURL(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CarVo carVo = list.get(i); |
| | | String carId = carVo.getCarId(); |
| | | Map<String,Object> map = ardSyCarService.getCarGPSBycarId(usersId,carId,syURL,ardSyUser); |
| | | List list1 = (List) map.get("list"); |
| | | if(list1.size()>0){ |
| | | JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(list1.get(0))); |
| | | String carPlate = (String) jsonObject.get("carPlate"); |
| | | carVo.setCarPlate(carPlate); |
| | | String drvName = (String) jsonObject.get("drvName"); |
| | | carVo.setDrvName(drvName); |
| | | String drvPhone = (String) jsonObject.get("drvPhone"); |
| | | carVo.setDrvPhone(drvPhone); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |