|
@@ -1,133 +1,133 @@
|
|
|
-package com.yunfeiyun.agmp.iotm.web.controller;
|
|
|
|
|
-
|
|
|
|
|
-import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
-import com.yunfeiyun.agmp.common.annotation.Log;
|
|
|
|
|
-import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
|
|
-import com.yunfeiyun.agmp.common.core.controller.BaseController;
|
|
|
|
|
-import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
|
|
|
|
|
-import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
|
|
|
|
|
-import com.yunfeiyun.agmp.common.enums.BusinessType;
|
|
|
|
|
-import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
|
|
-import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
|
|
|
|
|
-import com.yunfeiyun.agmp.iot.common.domain.IotDeviceconfig;
|
|
|
|
|
-import com.yunfeiyun.agmp.iot.common.util.tmn.CustomerIdUtil;
|
|
|
|
|
-import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceconfigService;
|
|
|
|
|
-import org.apache.http.util.TextUtils;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
-
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * 设备配置Controller
|
|
|
|
|
- *
|
|
|
|
|
- * @author 杨晓辉
|
|
|
|
|
- * @date 2024-01-04
|
|
|
|
|
- */
|
|
|
|
|
-@RestController
|
|
|
|
|
-@RequestMapping("/iot/deviceconfig")
|
|
|
|
|
-public class IotDeviceconfigController extends BaseController {
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private IIotDeviceconfigService iotDeviceconfigService;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 查询设备配置列表
|
|
|
|
|
- */
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:deviceconfig:list')")
|
|
|
|
|
- @GetMapping("/list")
|
|
|
|
|
- public TableDataInfo list(IotDeviceconfig iotDeviceconfig) {
|
|
|
|
|
- startPage();
|
|
|
|
|
- List<IotDeviceconfig> list = iotDeviceconfigService.selectIotDeviceconfigList(iotDeviceconfig);
|
|
|
|
|
- return getDataTable(list);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 查询设备配置列表
|
|
|
|
|
- */
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:deviceconfig:info')")
|
|
|
|
|
- @GetMapping("/info")
|
|
|
|
|
- public AjaxResult info(@RequestParam("devBid") String devBid) {
|
|
|
|
|
- if (StringUtils.isBlank(devBid)) {
|
|
|
|
|
- return error(ErrorCode.INVALID_PARAMETER.getCode(), ErrorCode.INVALID_PARAMETER.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- IotDeviceconfig iotDeviceconfig = new IotDeviceconfig();
|
|
|
|
|
- iotDeviceconfig.setDevBid(devBid);
|
|
|
|
|
- List<IotDeviceconfig> list = iotDeviceconfigService.selectIotDeviceconfigList(iotDeviceconfig);
|
|
|
|
|
- if (list.isEmpty()) {
|
|
|
|
|
- return success();
|
|
|
|
|
- } else {
|
|
|
|
|
- return success(JSONObject.parseObject(list.get(0).getDevcfgContext()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 导出设备配置列表
|
|
|
|
|
- */
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:deviceconfig:export')")
|
|
|
|
|
- @Log(title = "设备配置", businessType = BusinessType.EXPORT)
|
|
|
|
|
- @PostMapping("/export")
|
|
|
|
|
- public void export(HttpServletResponse response, IotDeviceconfig iotDeviceconfig) {
|
|
|
|
|
- List<IotDeviceconfig> list = iotDeviceconfigService.selectIotDeviceconfigList(iotDeviceconfig);
|
|
|
|
|
- ExcelUtil<IotDeviceconfig> util = new ExcelUtil<IotDeviceconfig>(IotDeviceconfig.class);
|
|
|
|
|
- util.exportExcel(response, list, "设备配置数据");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 新增设备配置
|
|
|
|
|
- */
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:deviceconfig:add')")
|
|
|
|
|
- @Log(title = "设备配置", businessType = BusinessType.INSERT)
|
|
|
|
|
- @PostMapping("/add")
|
|
|
|
|
- public AjaxResult add(@RequestBody IotDeviceconfig iotDeviceconfig) {
|
|
|
|
|
- return toAjax(iotDeviceconfigService.insertIotDeviceconfig(iotDeviceconfig));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 修改设备配置(新建也调此接口)
|
|
|
|
|
- */
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:deviceconfig:edit')")
|
|
|
|
|
- @Log(title = "设备配置", businessType = BusinessType.UPDATE)
|
|
|
|
|
- @PutMapping("/edit")
|
|
|
|
|
- public AjaxResult edit(@RequestBody IotDeviceconfig iotDeviceconfig)
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- if(iotDeviceconfig==null ||TextUtils.isEmpty(iotDeviceconfig.getDevBid())){
|
|
|
|
|
- return error(ErrorCode.INVALID_PARAMETER.getCode());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- IotDeviceconfig findItem = iotDeviceconfigService.selectIotDeviceConfigByDevBid(iotDeviceconfig.getDevBid());
|
|
|
|
|
- if(null == findItem){
|
|
|
|
|
- // 如果配置为空,则新增配置
|
|
|
|
|
- IotDeviceconfig newItem = new IotDeviceconfig();
|
|
|
|
|
- newItem.setDevcfgBid(iotDeviceconfig.getUUId());
|
|
|
|
|
- newItem.setTid(CustomerIdUtil.getCustomerId());
|
|
|
|
|
- newItem.setDevBid(iotDeviceconfig.getDevBid());
|
|
|
|
|
- newItem.setDevcfgContext(iotDeviceconfig.getDevcfgContext());
|
|
|
|
|
- newItem.setDevcfgDelstatus("0");
|
|
|
|
|
- iotDeviceconfigService.insertIotDeviceconfig(newItem);
|
|
|
|
|
- }else {
|
|
|
|
|
- // 如果配置不为空,则更新配置
|
|
|
|
|
- findItem.setDevcfgContext(iotDeviceconfig.getDevcfgContext());
|
|
|
|
|
- iotDeviceconfigService.updateIotDeviceconfig(findItem);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- logger.debug("不真正发送指令!");
|
|
|
|
|
- iotDeviceconfigService.sendConfig(iotDeviceconfig);
|
|
|
|
|
-
|
|
|
|
|
- return toAjax(1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 删除设备配置
|
|
|
|
|
- */
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:deviceconfig:remove')")
|
|
|
|
|
- @Log(title = "设备配置", businessType = BusinessType.DELETE)
|
|
|
|
|
- @DeleteMapping("/delete")
|
|
|
|
|
- public AjaxResult remove(@RequestParam("ids") Long[] ids) {
|
|
|
|
|
- return toAjax(iotDeviceconfigService.deleteIotDeviceconfigByIds(ids));
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+//package com.yunfeiyun.agmp.iotm.web.controller;
|
|
|
|
|
+//
|
|
|
|
|
+//import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
+//import com.yunfeiyun.agmp.common.annotation.Log;
|
|
|
|
|
+//import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
|
|
+//import com.yunfeiyun.agmp.common.core.controller.BaseController;
|
|
|
|
|
+//import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
|
|
|
|
|
+//import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
|
|
|
|
|
+//import com.yunfeiyun.agmp.common.enums.BusinessType;
|
|
|
|
|
+//import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
|
|
+//import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
|
|
|
|
|
+//import com.yunfeiyun.agmp.iot.common.domain.IotDeviceconfig;
|
|
|
|
|
+//import com.yunfeiyun.agmp.iot.common.util.tmn.CustomerIdUtil;
|
|
|
|
|
+//import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceconfigService;
|
|
|
|
|
+//import org.apache.http.util.TextUtils;
|
|
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+//import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
+//import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+//
|
|
|
|
|
+//import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+//import java.util.List;
|
|
|
|
|
+//
|
|
|
|
|
+///**
|
|
|
|
|
+// * 设备配置Controller
|
|
|
|
|
+// *
|
|
|
|
|
+// * @author 杨晓辉
|
|
|
|
|
+// * @date 2024-01-04
|
|
|
|
|
+// */
|
|
|
|
|
+//@RestController
|
|
|
|
|
+//@RequestMapping("/iot/deviceconfig")
|
|
|
|
|
+//public class IotDeviceconfigController extends BaseController {
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// private IIotDeviceconfigService iotDeviceconfigService;
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 查询设备配置列表
|
|
|
|
|
+// */
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:deviceconfig:list')")
|
|
|
|
|
+// @GetMapping("/list")
|
|
|
|
|
+// public TableDataInfo list(IotDeviceconfig iotDeviceconfig) {
|
|
|
|
|
+// startPage();
|
|
|
|
|
+// List<IotDeviceconfig> list = iotDeviceconfigService.selectIotDeviceconfigList(iotDeviceconfig);
|
|
|
|
|
+// return getDataTable(list);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 查询设备配置列表
|
|
|
|
|
+// */
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:deviceconfig:info')")
|
|
|
|
|
+// @GetMapping("/info")
|
|
|
|
|
+// public AjaxResult info(@RequestParam("devBid") String devBid) {
|
|
|
|
|
+// if (StringUtils.isBlank(devBid)) {
|
|
|
|
|
+// return error(ErrorCode.INVALID_PARAMETER.getCode(), ErrorCode.INVALID_PARAMETER.getMessage());
|
|
|
|
|
+// }
|
|
|
|
|
+// IotDeviceconfig iotDeviceconfig = new IotDeviceconfig();
|
|
|
|
|
+// iotDeviceconfig.setDevBid(devBid);
|
|
|
|
|
+// List<IotDeviceconfig> list = iotDeviceconfigService.selectIotDeviceconfigList(iotDeviceconfig);
|
|
|
|
|
+// if (list.isEmpty()) {
|
|
|
|
|
+// return success();
|
|
|
|
|
+// } else {
|
|
|
|
|
+// return success(JSONObject.parseObject(list.get(0).getDevcfgContext()));
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 导出设备配置列表
|
|
|
|
|
+// */
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:deviceconfig:export')")
|
|
|
|
|
+// @Log(title = "设备配置", businessType = BusinessType.EXPORT)
|
|
|
|
|
+// @PostMapping("/export")
|
|
|
|
|
+// public void export(HttpServletResponse response, IotDeviceconfig iotDeviceconfig) {
|
|
|
|
|
+// List<IotDeviceconfig> list = iotDeviceconfigService.selectIotDeviceconfigList(iotDeviceconfig);
|
|
|
|
|
+// ExcelUtil<IotDeviceconfig> util = new ExcelUtil<IotDeviceconfig>(IotDeviceconfig.class);
|
|
|
|
|
+// util.exportExcel(response, list, "设备配置数据");
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 新增设备配置
|
|
|
|
|
+// */
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:deviceconfig:add')")
|
|
|
|
|
+// @Log(title = "设备配置", businessType = BusinessType.INSERT)
|
|
|
|
|
+// @PostMapping("/add")
|
|
|
|
|
+// public AjaxResult add(@RequestBody IotDeviceconfig iotDeviceconfig) {
|
|
|
|
|
+// return toAjax(iotDeviceconfigService.insertIotDeviceconfig(iotDeviceconfig));
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 修改设备配置(新建也调此接口)
|
|
|
|
|
+// */
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:deviceconfig:edit')")
|
|
|
|
|
+// @Log(title = "设备配置", businessType = BusinessType.UPDATE)
|
|
|
|
|
+// @PutMapping("/edit")
|
|
|
|
|
+// public AjaxResult edit(@RequestBody IotDeviceconfig iotDeviceconfig)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// if(iotDeviceconfig==null ||TextUtils.isEmpty(iotDeviceconfig.getDevBid())){
|
|
|
|
|
+// return error(ErrorCode.INVALID_PARAMETER.getCode());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// IotDeviceconfig findItem = iotDeviceconfigService.selectIotDeviceConfigByDevBid(iotDeviceconfig.getDevBid());
|
|
|
|
|
+// if(null == findItem){
|
|
|
|
|
+// // 如果配置为空,则新增配置
|
|
|
|
|
+// IotDeviceconfig newItem = new IotDeviceconfig();
|
|
|
|
|
+// newItem.setDevcfgBid(iotDeviceconfig.getUUId());
|
|
|
|
|
+// newItem.setTid(CustomerIdUtil.getCustomerId());
|
|
|
|
|
+// newItem.setDevBid(iotDeviceconfig.getDevBid());
|
|
|
|
|
+// newItem.setDevcfgContext(iotDeviceconfig.getDevcfgContext());
|
|
|
|
|
+// newItem.setDevcfgDelstatus("0");
|
|
|
|
|
+// iotDeviceconfigService.insertIotDeviceconfig(newItem);
|
|
|
|
|
+// }else {
|
|
|
|
|
+// // 如果配置不为空,则更新配置
|
|
|
|
|
+// findItem.setDevcfgContext(iotDeviceconfig.getDevcfgContext());
|
|
|
|
|
+// iotDeviceconfigService.updateIotDeviceconfig(findItem);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// logger.debug("不真正发送指令!");
|
|
|
|
|
+// iotDeviceconfigService.sendConfig(iotDeviceconfig);
|
|
|
|
|
+//
|
|
|
|
|
+// return toAjax(1);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 删除设备配置
|
|
|
|
|
+// */
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:deviceconfig:remove')")
|
|
|
|
|
+// @Log(title = "设备配置", businessType = BusinessType.DELETE)
|
|
|
|
|
+// @DeleteMapping("/delete")
|
|
|
|
|
+// public AjaxResult remove(@RequestParam("ids") Long[] ids) {
|
|
|
|
|
+// return toAjax(iotDeviceconfigService.deleteIotDeviceconfigByIds(ids));
|
|
|
|
|
+// }
|
|
|
|
|
+//}
|