aijinhui
2023-10-18 cb77a6b162f59b6664e10bdfc26463fc909f4c22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.ruoyi.sy.controller;
 
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.sy.domain.ArdSyCarLock;
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.vo.CarVo;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.utils.result.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@RestController
@RequestMapping("syLock")
@Api(tags = "车辆锁管理")
public class ArdSyCarLockController {
 
    @Autowired
    private IArdSyUserService iArdSyUserService;
    @Autowired
    private ISysConfigService sysConfigService;
    @Autowired
    private IArdSyCarService ardSyCarService;
    @Autowired
    private ArdSyCarLockService ardSyCarLockService;
 
    @GetMapping("/car")
    @ApiOperation("查询所有未挂锁的车辆")
    public Results car(){
        List<CarVo> list = ardSyCarLockService.car();
        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");
            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 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));
    }
 
    @GetMapping("/query")
    @ApiOperation("查询所有rtu挂载的车辆")
    public Results query(){
        return Results.succeed(ardSyCarLockService.carList());
    }
 
    @GetMapping("/addLock")
    @ApiOperation("添加修改锁")
    public Results addLock(@RequestBody List<ArdSyCarLock> locks){
        return Results.succeed(ardSyCarLockService.addUpdLock(locks));
    }
 
 
}