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 com.ruoyi.task.DataAssembleUtil;
|
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));
|
}
|
}
|