|
|
|
@ -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.*; |
|
|
|
@ -81,7 +83,7 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
|
public AjaxResult selAllUsers() { |
|
|
|
|
List<Map> maps = new ArrayList<>(); |
|
|
|
|
List<SysUser> list = sysUserService.selectUserList(null); |
|
|
|
|
for (SysUser dd : list){ |
|
|
|
|
for (SysUser dd : list) { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("label", dd.getUserName()); |
|
|
|
|
map.put("value", dd.getUserId()); |
|
|
|
@ -95,7 +97,7 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
|
public AjaxResult selAllModels() { |
|
|
|
|
List<Map> maps = new ArrayList<>(); |
|
|
|
|
List<PsdcDevice> list = psdcDeviceService.selalldevModel(); |
|
|
|
|
for (PsdcDevice dd : list){ |
|
|
|
|
for (PsdcDevice dd : list) { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("label", dd.getDeviceModel()); |
|
|
|
|
map.put("value", dd.getDeviceModel()); |
|
|
|
@ -116,14 +118,14 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
excel文件的下载 |
|
|
|
|
* excel文件的下载 |
|
|
|
|
*/ |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:device:list')") |
|
|
|
|
@Log(title = "设备管理", businessType = BusinessType.EXPORT) |
|
|
|
|
@RequestMapping(value = "/daochuDevs", method = RequestMethod.POST) |
|
|
|
|
public void daochuDevDta(HttpServletResponse response, @RequestBody PsdcDevice pd) { |
|
|
|
|
List<PsdcDeviceInfoRes> list = psdcDeviceService.queryAllByLimit(pd); |
|
|
|
|
for (PsdcDeviceInfoRes dev : list){ |
|
|
|
|
for (PsdcDeviceInfoRes dev : list) { |
|
|
|
|
dev.setUserName(sysUserService.selectUserById(Long.valueOf(dev.getUserId())).getUserName()); |
|
|
|
|
} |
|
|
|
|
ExcelUtil<PsdcDeviceInfoRes> util = new ExcelUtil<>(PsdcDeviceInfoRes.class); |
|
|
|
@ -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')") |
|
|
|
@ -184,8 +187,37 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/upDevUser", method = RequestMethod.POST) |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:device:list')") |
|
|
|
|
public AjaxResult upDevStaUser(@RequestBody UpDevUserRequest query){ |
|
|
|
|
public AjaxResult upDevStaUser(@RequestBody UpDevUserRequest query) { |
|
|
|
|
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异常!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|