|
|
@ -1,25 +1,34 @@ |
|
|
|
package com.psdc.controller.manager; |
|
|
|
package com.psdc.controller.manager; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.github.pagehelper.page.PageMethod; |
|
|
|
|
|
|
|
import com.psdc.annotation.Log; |
|
|
|
import com.psdc.annotation.Log; |
|
|
|
import com.psdc.core.controller.BaseController; |
|
|
|
import com.psdc.core.controller.BaseController; |
|
|
|
import com.psdc.core.domain.AjaxResult; |
|
|
|
import com.psdc.core.domain.AjaxResult; |
|
|
|
import com.psdc.core.domain.entity.SysUser; |
|
|
|
import com.psdc.core.domain.entity.SysUser; |
|
|
|
import com.psdc.core.page.TableDataInfo; |
|
|
|
import com.psdc.core.page.TableDataInfo; |
|
|
|
import com.psdc.entity.PsdcControlLog; |
|
|
|
|
|
|
|
import com.psdc.entity.PsdcDevice; |
|
|
|
import com.psdc.entity.PsdcDevice; |
|
|
|
import com.psdc.enums.BusinessType; |
|
|
|
import com.psdc.enums.BusinessType; |
|
|
|
import com.psdc.service.IPsdcDeviceService; |
|
|
|
import com.psdc.service.IPsdcDeviceService; |
|
|
|
import com.psdc.service.ISysUserService; |
|
|
|
import com.psdc.service.ISysUserService; |
|
|
|
import com.psdc.utils.SecurityUtils; |
|
|
|
import com.psdc.utils.SecurityUtils; |
|
|
|
import org.apache.commons.lang3.ArrayUtils; |
|
|
|
import com.psdc.utils.poi.ExcelUtil; |
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell; |
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import java.io.BufferedOutputStream; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
import java.io.OutputStream; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -80,11 +89,11 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
map.put("value", dd.getUserId()); |
|
|
|
map.put("value", dd.getUserId()); |
|
|
|
maps.add(map); |
|
|
|
maps.add(map); |
|
|
|
} |
|
|
|
} |
|
|
|
return AjaxResult.success("用户下来列表", maps); |
|
|
|
return AjaxResult.success("用户下拉列表", maps); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('manager:device:list')") |
|
|
|
@PreAuthorize("@ss.hasPermi('manager:device:list')") |
|
|
|
@PostMapping("/devicesList") |
|
|
|
@RequestMapping(value = "/devicesList", method = RequestMethod.POST) |
|
|
|
public TableDataInfo controlLogList(@RequestBody JSONObject jsonObject) { |
|
|
|
public TableDataInfo controlLogList(@RequestBody JSONObject jsonObject) { |
|
|
|
// PageMethod.startPage(jsonObject.getInteger("pageNum"),jsonObject.getInteger("pageSize"));
|
|
|
|
// PageMethod.startPage(jsonObject.getInteger("pageNum"),jsonObject.getInteger("pageSize"));
|
|
|
|
// PsdcDevice deviceVo = JSON.parseObject(String.valueOf(jsonObject), PsdcDevice.class);
|
|
|
|
// PsdcDevice deviceVo = JSON.parseObject(String.valueOf(jsonObject), PsdcDevice.class);
|
|
|
@ -93,4 +102,70 @@ public class PsdcDeviceController extends BaseController { |
|
|
|
return getDataTable(list); |
|
|
|
return getDataTable(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
excel文件的下载 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('manager:device:list')") |
|
|
|
|
|
|
|
@Log(title = "设备管理", businessType = BusinessType.EXPORT) |
|
|
|
|
|
|
|
@RequestMapping(value = "/daochuDevs", method = RequestMethod.POST) |
|
|
|
|
|
|
|
public void daochuDevDta(HttpServletResponse response, @RequestBody PsdcDevice pd) { |
|
|
|
|
|
|
|
List<PsdcDevice> list = psdcDeviceService.queryAllByLimit(pd); |
|
|
|
|
|
|
|
for (PsdcDevice dev : list){ |
|
|
|
|
|
|
|
dev.setUserName(sysUserService.selectUserById(Long.valueOf(dev.getUserId())).getUserName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ExcelUtil<PsdcDevice> util = new ExcelUtil<>(PsdcDevice.class); |
|
|
|
|
|
|
|
util.exportExcel(response, list, "角色数据"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 下载设备信息模板 |
|
|
|
|
|
|
|
* @param response |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('manager:device:list')") |
|
|
|
|
|
|
|
@Log(title = "设备管理", businessType = BusinessType.EXPORT) |
|
|
|
|
|
|
|
@RequestMapping(value = "/downloadDevTemplate", method = RequestMethod.GET) |
|
|
|
|
|
|
|
public void downloadTemplate(HttpServletResponse response) { |
|
|
|
|
|
|
|
// 获取要下载的模板名称
|
|
|
|
|
|
|
|
String fileName = "devTemplate.xlsx"; |
|
|
|
|
|
|
|
// 设置要下载的文件的名称
|
|
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName); |
|
|
|
|
|
|
|
// 通知客服文件的MIME类型
|
|
|
|
|
|
|
|
response.setContentType("application/vnd.ms-template;charset=UTF-8"); |
|
|
|
|
|
|
|
// 获取文件的路径
|
|
|
|
|
|
|
|
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/AllDevicesData.xlsx")) { |
|
|
|
|
|
|
|
//读取excel模板
|
|
|
|
|
|
|
|
XSSFWorkbook wb = new XSSFWorkbook(inputStream); |
|
|
|
|
|
|
|
wb.setSelectedTab(1); |
|
|
|
|
|
|
|
XSSFSheet sheet = wb.createSheet("设备类型表"); |
|
|
|
|
|
|
|
XSSFRow row0 = sheet.createRow(0); |
|
|
|
|
|
|
|
XSSFRow row1 = sheet.createRow(1); |
|
|
|
|
|
|
|
XSSFRow row2 = sheet.createRow(2); |
|
|
|
|
|
|
|
row0.createCell(0).setCellValue("设备类型Id"); |
|
|
|
|
|
|
|
row0.createCell(1).setCellValue("设备类型名称"); |
|
|
|
|
|
|
|
row1.createCell(0).setCellValue("1"); |
|
|
|
|
|
|
|
row1.createCell(1).setCellValue("监测设备"); |
|
|
|
|
|
|
|
row2.createCell(0).setCellValue("2"); |
|
|
|
|
|
|
|
row2.createCell(1).setCellValue("运行设备"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OutputStream os = new BufferedOutputStream(response.getOutputStream()); |
|
|
|
|
|
|
|
wb.write(os); |
|
|
|
|
|
|
|
os.flush(); |
|
|
|
|
|
|
|
os.close(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
throw new RuntimeException("下载设备模板出错"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
excel文件的读取 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@RequestMapping("/daoruDevData") |
|
|
|
|
|
|
|
@PreAuthorize("hasAuthority('addevice')") |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
|
|
public AjaxResult daoruDevData(@RequestPart("file") MultipartFile file) { |
|
|
|
|
|
|
|
return toAjax(psdcDeviceService.daoruDevicesData(file)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|