|
|
|
@ -22,9 +22,11 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import sun.misc.BASE64Encoder; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.BufferedOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.io.OutputStream; |
|
|
|
|
import java.util.*; |
|
|
|
@ -116,7 +118,7 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
excel文件的下载 |
|
|
|
|
* excel文件的下载 |
|
|
|
|
*/ |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:device:list')") |
|
|
|
|
@Log(title = "设备管理", businessType = BusinessType.EXPORT) |
|
|
|
@ -132,6 +134,7 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 下载设备信息模板 |
|
|
|
|
* |
|
|
|
|
* @param response |
|
|
|
|
*/ |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:device:list')") |
|
|
|
@ -170,7 +173,7 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
excel文件的读取 |
|
|
|
|
* excel文件的读取 |
|
|
|
|
*/ |
|
|
|
|
@RequestMapping("/daoruDevData") |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:device:list')") |
|
|
|
@ -188,4 +191,33 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
|
return toAjax(psdcDeviceService.upDevUser(query.getUserId(), query.getDeviceIds())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping("/daoruDevTuPian") |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:device:list')") |
|
|
|
|
@Log(title = "设备管理", businessType = BusinessType.IMPORT) |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public AjaxResult addDevicePicture(@RequestPart("file") MultipartFile multipartFile, |
|
|
|
|
@RequestParam("deviceId") Integer deviceId) { |
|
|
|
|
// 图片
|
|
|
|
|
if (multipartFile == null) { |
|
|
|
|
return AjaxResult.error("未检查到上传的文件!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String imageBaseStr = null; |
|
|
|
|
try { |
|
|
|
|
String contentType = multipartFile.getContentType(); |
|
|
|
|
if (!contentType.contains("image")) { |
|
|
|
|
return AjaxResult.error("文件类型不正确!"); |
|
|
|
|
} |
|
|
|
|
byte[] imageBytes = multipartFile.getBytes(); |
|
|
|
|
BASE64Encoder base64Encoder = new BASE64Encoder(); |
|
|
|
|
imageBaseStr = "data:" + contentType + ";base64," + base64Encoder.encode(imageBytes); |
|
|
|
|
imageBaseStr = imageBaseStr.replaceAll("[\\s*\t\n\r]", ""); |
|
|
|
|
return toAjax(psdcDeviceService.daoruDevTuPian(deviceId, imageBaseStr)); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
logger.warn(e.getMessage()); |
|
|
|
|
return AjaxResult.error("图片转换base64异常!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|