wl
2022-10-21 201ea73fb531ee30fd57465e210bd523eb10c95d
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.ycl.controller.carManage;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.annotation.LogSave;
import com.ycl.api.CommonResult;
import com.ycl.controller.BaseController;
import com.ycl.entity.carManage.CarEnforcecar;
import com.ycl.entity.carManage.CarSlagcar;
import com.ycl.enums.common.ResultCode;
import com.ycl.exception.ApiException;
import com.ycl.service.carManage.ICarEnforcecarService;
import com.ycl.service.carManage.ICarSlagcarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
/**
 * <p>
 * 执法车列表(对接执法车GPS) 前端控制器
 * </p>
 *
 * @author zhanghua
 * @since 2022-10-08
 */
@RestController
@Api(tags = "车辆管理")
@RequestMapping("/car_Manage")
public class CarManageController extends BaseController {
 
    @Autowired
    ICarEnforcecarService iCarEnforcecarService;
    @Autowired
    ICarSlagcarService iCarSlagcarService;
 
    @ApiOperation(value = "查询执法车")
    @GetMapping("/query_enforce")
    public CommonResult searchEnforceCar(@RequestParam(required = false) String carNum,
                                         @RequestParam Integer size,
                                         @RequestParam Integer current) {
        Page<CarEnforcecar> carEnforcecarPage = new Page<>();
        carEnforcecarPage.setSize(size);
        carEnforcecarPage.setCurrent(current);
        return CommonResult.success(iCarEnforcecarService
                .page(carEnforcecarPage, new LambdaQueryWrapper<CarEnforcecar>()
                        .like(StringUtils.isNotBlank(carNum), CarEnforcecar::getCarNumber, carNum)));
    }
 
    @ApiOperation(value = "查询渣土车")
    @GetMapping("/query_slag")
    public CommonResult searchSlagCar(@RequestParam(required = false) String carNum,
                                      @RequestParam Integer size,
                                      @RequestParam Integer current) {
        Page<CarSlagcar> carSlagcarPage = new Page<>();
        carSlagcarPage.setSize(size);
        carSlagcarPage.setCurrent(current);
        return CommonResult.success(iCarSlagcarService
                .page(carSlagcarPage, new LambdaQueryWrapper<CarSlagcar>()
                        .like(StringUtils.isNotBlank(carNum), CarSlagcar::getCarNumber, carNum)));
    }
 
 
    @ApiOperation(value = "查看详情执法车")
    @GetMapping("/query_enforce_one")
    public CommonResult searchEnforceCar(@RequestParam Integer id) {
        return CommonResult.success(iCarEnforcecarService
                .getOne(new LambdaQueryWrapper<CarEnforcecar>()
                        .eq(CarEnforcecar::getId, id)));
    }
 
    @ApiOperation(value = "查看详情渣土车")
    @GetMapping("/query_slag_one")
    public CommonResult searchSlagCar(@RequestParam Integer id) {
        return CommonResult.success(iCarSlagcarService
                .getOne(new LambdaQueryWrapper<CarSlagcar>()
                        .eq(CarSlagcar::getId, id)));
    }
 
    @ApiOperation("修改执法车")
    @PutMapping("/modification_enforce")
    public CommonResult modify(@RequestBody CarEnforcecar carEnforcecar) {
        return CommonResult.success(iCarEnforcecarService.updateById(carEnforcecar));
    }
 
    @ApiOperation("修改渣土车")
    @PutMapping("/modification_slag")
    public CommonResult modify(@RequestBody CarSlagcar carSlagcar) {
        return CommonResult.success(iCarSlagcarService.updateById(carSlagcar));
    }
 
    @ApiOperation("添加执法车")
    @PostMapping("/addition_enforce")
    @LogSave(operationType = "车俩管理", contain = "添加执法车")
    public CommonResult addEnforceCar(@RequestBody CarEnforcecar carEnforcecar) {
        CarEnforcecar enforceCar = iCarEnforcecarService
                .getOne(new LambdaQueryWrapper<CarEnforcecar>()
                        .eq(CarEnforcecar::getCarNumber, carEnforcecar.getCarNumber()));
        if (enforceCar != null && StringUtils.isNotBlank(enforceCar.getCarNumber())) {
            throw new ApiException(ResultCode.CAR_NUMBER_REPETITION.getMessage());
        }
        return CommonResult.success(iCarEnforcecarService.save(carEnforcecar));
    }
 
    @ApiOperation("添加渣土车")
    @PostMapping("/addition_slag")
    @LogSave(operationType = "车俩管理", contain = "添加渣土车")
    public CommonResult addSlagCar(@RequestBody CarSlagcar carSlagcar) {
        CarSlagcar slagCar = iCarSlagcarService
                .getOne(new LambdaQueryWrapper<CarSlagcar>()
                        .eq(CarSlagcar::getCarNumber, carSlagcar.getCarNumber()));
        if (slagCar != null && StringUtils.isNotBlank(slagCar.getCarNumber())) {
            throw new ApiException(ResultCode.CAR_NUMBER_REPETITION.getMessage());
        }
        return CommonResult.success(iCarSlagcarService.save(carSlagcar));
    }
 
    @ApiOperation("删除执法车")
    @DeleteMapping("/deletion_enforce")
    @LogSave(operationType = "车俩管理", contain = "删除执法车")
    public CommonResult deleteEnforceCar(@RequestParam Integer id) {
        return CommonResult.success(iCarEnforcecarService.removeById(id));
    }
 
    @ApiOperation("删除渣土车")
    @DeleteMapping("/deletion_slag")
    @LogSave(operationType = "车俩管理", contain = "删除渣土车")
    public CommonResult deleteSlagCar(@RequestParam Integer id) {
        return CommonResult.success(iCarSlagcarService.removeById(id));
    }
}