zhangnaisong
2023-07-20 1b5007fd66cb2c56e7b54b793cdd3f29785f5c04
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package com.ruoyi.sy.controller;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.utils.httpclient.SYCarClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.bytedeco.javacv.CanvasFrame;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sy.domain.ArdSyCar;
import com.ruoyi.sy.service.IArdSyCarService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
 
/**
 * 三一车辆Controller
 * 
 * @author ard
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/sy/syCar")
@Api(tags = "三一车辆管理接口")
public class ArdSyCarController extends BaseController
{
    @Autowired
    private IArdSyCarService ardSyCarService;
 
    @Autowired
    private ISysConfigService sysConfigService;
 
    /**
     * 查询三一车辆列表
     */
    @PreAuthorize("@ss.hasPermi('sy:syCar:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArdSyCar ardSyCar)
    {
        startPage();
        List<ArdSyCar> list = ardSyCarService.selectArdSyCarList(ardSyCar);
        return getDataTable(list);
    }
 
    /**
     * 导出三一车辆列表
     */
    @PreAuthorize("@ss.hasPermi('sy:syCar:export')")
    @Log(title = "三一车辆", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArdSyCar ardSyCar)
    {
        List<ArdSyCar> list = ardSyCarService.selectArdSyCarList(ardSyCar);
        ExcelUtil<ArdSyCar> util = new ExcelUtil<ArdSyCar>(ArdSyCar.class);
        util.exportExcel(response, list, "三一车辆数据");
    }
 
    /**
     * 获取三一车辆详细信息
     */
    @PreAuthorize("@ss.hasPermi('sy:syCar:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(ardSyCarService.selectArdSyCarById(id));
    }
 
    /**
     * 新增三一车辆
     */
    @PreAuthorize("@ss.hasPermi('sy:syCar:add')")
    @Log(title = "三一车辆", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArdSyCar ardSyCar)
    {
        return toAjax(ardSyCarService.insertArdSyCar(ardSyCar));
    }
 
    /**
     * 修改三一车辆
     */
    @PreAuthorize("@ss.hasPermi('sy:syCar:edit')")
    @Log(title = "三一车辆", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArdSyCar ardSyCar)
    {
        return toAjax(ardSyCarService.updateArdSyCar(ardSyCar));
    }
 
    /**
     * 删除三一车辆
     */
    @PreAuthorize("@ss.hasPermi('sy:syCar:remove')")
    @Log(title = "三一车辆", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(ardSyCarService.deleteArdSyCarByIds(ids));
    }
 
    /**
     * 获取三一车辆登录信息
     */
    @PreAuthorize("@ss.hasPermi('sy:syCar:loginSY')")
    @PostMapping("/loginSY")
    @ApiOperation("获取三一车辆登录信息")
    public Map<String,Object> loginSY(@RequestBody Map<String,String> map){
        //startPage();
        String userId = map.get("userId");
        String password = map.get("password");
        SysConfig config = new SysConfig();
        config.setConfigKey("syCarPT");
        List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config);
        String syURL = "";
        if(sysConfigResult.size() == 0){
            return error("三一车辆url没有录入");
        }else{
            syURL = sysConfigResult.get(0).getConfigValue();
            Map<String,Object> result = SYCarClient.logIn(syURL,userId, password);
            return success(result);
        }
    }
 
    /**
     * 获取未挂接权限的三一车辆
     */
    @PreAuthorize("@ss.hasPermi('sy:syCar:getArdSyCarNoRight')")
    @PostMapping("/getArdSyCarNoRight")
    @ApiOperation("获取未挂接权限的三一车辆")
    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:getAllCarModel')")
    @PostMapping("/getAllCarModel")
    @ApiOperation("获取全部车辆模型")
    public Map<String,Object> getAllCarModel(){
        try{
            List<Map<String,String>> result = ardSyCarService.getAllCarModel();
            return toAjaxList(result);
        } catch(Exception e){
            return toAjaxList(new ArrayList());
        }
    }
 
}