admin
2024-04-11 a2e67e004a5b908cb2b5eeda53101befb0d9578f
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
172
173
174
175
176
177
178
179
180
181
182
package com.ruoyi.camera.controller;
 
import java.io.File;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.task.CameraAssembleUtil;
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.camera.domain.CameraShipingsb;
import com.ruoyi.camera.service.ICameraShipingsbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
 
/**
 * 摄像头视频识别Controller
 *
 * @author ruoyi
 * @date 2023-09-14
 */
@RestController
@RequestMapping("/camera/shipingsb")
public class CameraShipingsbController extends BaseController
{
    @Autowired
    private ICameraShipingsbService cameraShipingsbService;
 
    /**
     * 查询摄像头视频识别列表
     */
    @PreAuthorize("@ss.hasPermi('camera:shipingsb:list')")
    @GetMapping("/list")
    public TableDataInfo list(CameraShipingsb cameraShipingsb)
    {
        startPage();
        List<CameraShipingsb> list = cameraShipingsbService.selectCameraShipingsbList(cameraShipingsb);
        return getDataTable(list);
    }
 
 
    @PostMapping("/fileReceive")
    @ResponseBody
    public Boolean fileInteraction(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Boolean result = false;
 
 
        Map<String, String> param = new HashMap<String, String>();
        Enumeration<String> enumer = request.getParameterNames();
        StringBuffer info = new StringBuffer();
        info.append("收到数据:\r\n");
        while (enumer.hasMoreElements()) {
            String key = enumer.nextElement();
            String value = request.getParameter(key);
            info.append("\t参数名[" + key + "] >>>> 参数值[" + value + "]\r\n");
            if (StringUtils.isEmpty(value)) {
                continue;
            }
            param.put(key, value);
        }
        System.out.println("收到附件接口信息:"+info.toString());
 
        MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
        //解析request,将结果放置在list中
        Map<String, List<MultipartFile>> fileMap = multiRequest.getMultiFileMap();
        for (String key : fileMap.keySet()) {
            List<MultipartFile> files = fileMap.get(key);
            for (MultipartFile file : files) {
                if (!file.isEmpty()) {
                    String fileNamePath = file.getOriginalFilename();
                    String[] params = fileNamePath.split("\\.");
                    String filename = "";
                    int i = 0;
                    for (String str : params) {
                        i = i + 1;
                        if (StringUtils.isNotEmpty(filename)) {
                            if (i==params.length) {
                                filename = filename + "." + str;
                            }else{
                                filename = filename + "/" + str;
                            }
                        }else{
                            filename = str;
                        }
                    }
                    // 文件保存路径
                    String filePath = RuoYiConfig.getProfile() + "/upload/wxfile/" + filename;
                    System.out.println(filePath);
                    File iFile = new File(filePath);
                    File iFileParent = iFile.getParentFile();
                    if(!iFileParent.exists()){
                        iFileParent.mkdirs();
                    }
                    // 转存文件
                    file.transferTo(new File(filePath));
                    result = true;
 
                }
            }
        }
        return result;
    }
 
 
    /**
     * 发送摄像头详细信息
     */
    @PreAuthorize("@ss.hasPermi('camera:shipingsb:query')")
    @GetMapping(value = "/faSong")
    public AjaxResult faSong(){
        CameraAssembleUtil.cameraInfo();//摄像头信息
        return success();
    }
 
    /**
     * 导出摄像头视频识别列表
     */
    @PreAuthorize("@ss.hasPermi('camera:shipingsb:export')")
    @Log(title = "摄像头视频识别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CameraShipingsb cameraShipingsb)
    {
        List<CameraShipingsb> list = cameraShipingsbService.selectCameraShipingsbList(cameraShipingsb);
        ExcelUtil<CameraShipingsb> util = new ExcelUtil<CameraShipingsb>(CameraShipingsb.class);
        util.exportExcel(response, list, "摄像头视频识别数据");
    }
 
    /**
     * 获取摄像头视频识别详细信息
     */
    @PreAuthorize("@ss.hasPermi('camera:shipingsb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cameraShipingsbService.selectCameraShipingsbById(id));
    }
 
    /**
     * 新增摄像头视频识别
     */
    @PreAuthorize("@ss.hasPermi('camera:shipingsb:add')")
    @Log(title = "摄像头视频识别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CameraShipingsb cameraShipingsb)
    {
        return toAjax(cameraShipingsbService.insertCameraShipingsb(cameraShipingsb));
    }
 
    /**
     * 修改摄像头视频识别
     */
    @PreAuthorize("@ss.hasPermi('camera:shipingsb:edit')")
    @Log(title = "摄像头视频识别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CameraShipingsb cameraShipingsb)
    {
        return toAjax(cameraShipingsbService.updateCameraShipingsb(cameraShipingsb));
    }
 
    /**
     * 删除摄像头视频识别
     */
    @PreAuthorize("@ss.hasPermi('camera:shipingsb:remove')")
    @Log(title = "摄像头视频识别", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cameraShipingsbService.deleteCameraShipingsbByIds(ids));
    }
}