|
|
@@ -0,0 +1,153 @@
|
|
|
+package com.yunfeiyun.agmp.iotm.web.controller;
|
|
|
+
|
|
|
+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.enums.BusinessType;
|
|
|
+import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
+import com.yunfeiyun.agmp.common.utils.uuid.UUID;
|
|
|
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotDevicefactor;
|
|
|
+import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceFactorBatchEditReqVo;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.IIotDevicefactorService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设备要素Controller
|
|
|
+ *
|
|
|
+ * @author 杨晓辉
|
|
|
+ * @date 2024-02-22
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/iot/device/factor")
|
|
|
+public class IotDevicefactorController extends BaseController
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private IIotDevicefactorService iotDevicefactorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IIotDeviceService iotDeviceService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量修改设备要素
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('yunfeiyun:IotDevicefactor:batchedit')")
|
|
|
+ @Log(title = "设备要素", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/batchedit")
|
|
|
+ public AjaxResult batchedit(@RequestBody IotDeviceFactorBatchEditReqVo reqVo)
|
|
|
+ {
|
|
|
+
|
|
|
+ String devBid = reqVo.getDevBid();
|
|
|
+ //先删除所有,然后遍历,一个一个插入
|
|
|
+ iotDevicefactorService.deleteIotDevicefactorByDevBid(devBid);
|
|
|
+ IotDevice iotDevice = iotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
+ if(iotDevice == null){
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备不存在");
|
|
|
+ }
|
|
|
+ String devtypeBid = iotDevice.getDevtypeBid();
|
|
|
+
|
|
|
+ List<IotDevicefactor> factorList = reqVo.getFactorList();
|
|
|
+ if(factorList == null){
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "请选择要编辑的设备要素");
|
|
|
+ }
|
|
|
+ for(IotDevicefactor item: factorList){
|
|
|
+ item.setDevBid(reqVo.getDevBid());
|
|
|
+ item.setDfBid(UUID.fastUUID().toString());
|
|
|
+ item.setDfCreatedDate(DateUtils.dateTimeNow());
|
|
|
+
|
|
|
+ if(Objects.equals(iotDevice.getDevtypeBid(), IotDeviceDictConst.TYPE_XPH_GSSQ)
|
|
|
+ || Objects.equals(devtypeBid, IotDeviceDictConst.TYPE_XPH_SZZX_JC)
|
|
|
+ || Objects.equals(devtypeBid, IotDeviceDictConst.TYPE_XPH_LDSW_JC)
|
|
|
+ || Objects.equals(devtypeBid, IotDeviceDictConst.TYPE_XPH_WSHJ_JC)
|
|
|
+ || Objects.equals(devtypeBid, IotDeviceDictConst.TYPE_XPH_TRSH_CL)
|
|
|
+ || Objects.equals(devtypeBid, IotDeviceDictConst.TYPE_XPH_GP_QXZ)
|
|
|
+ ){
|
|
|
+ item.setDfName(item.getDfAddress());
|
|
|
+ item.setDfAddress(null);
|
|
|
+ }
|
|
|
+ iotDevicefactorService.insertIotDevicefactor(item);
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 查询设备要素列表
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('yunfeiyun:IotDevicefactor:list')")
|
|
|
+// @GetMapping("/list")
|
|
|
+// public TableDataInfo list(IotDevicefactor iotDevicefactor)
|
|
|
+// {
|
|
|
+// startPage();
|
|
|
+// List<IotDevicefactor> list = iotDevicefactorService.selectIotDevicefactorList(iotDevicefactor);
|
|
|
+// return getDataTable(list);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 导出设备要素列表
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('yunfeiyun:IotDevicefactor:export')")
|
|
|
+// @Log(title = "设备要素", businessType = BusinessType.EXPORT)
|
|
|
+// @PostMapping("/export")
|
|
|
+// public void export(HttpServletResponse response, IotDevicefactor iotDevicefactor)
|
|
|
+// {
|
|
|
+// List<IotDevicefactor> list = iotDevicefactorService.selectIotDevicefactorList(iotDevicefactor);
|
|
|
+// ExcelUtil<IotDevicefactor> util = new ExcelUtil<IotDevicefactor>(IotDevicefactor.class);
|
|
|
+// util.exportExcel(response, list, "设备要素数据");
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 获取设备要素详细信息
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('yunfeiyun:IotDevicefactor:query')")
|
|
|
+// @GetMapping(value = "/info/{id}")
|
|
|
+// public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
+// {
|
|
|
+// return success(iotDevicefactorService.selectIotDevicefactorById(id));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 新增设备要素
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('yunfeiyun:IotDevicefactor:add')")
|
|
|
+// @Log(title = "设备要素", businessType = BusinessType.INSERT)
|
|
|
+// @PostMapping("/add")
|
|
|
+// public AjaxResult add(@RequestBody IotDevicefactor iotDevicefactor)
|
|
|
+// {
|
|
|
+// return toAjax(iotDevicefactorService.insertIotDevicefactor(iotDevicefactor));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 修改设备要素
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('yunfeiyun:IotDevicefactor:edit')")
|
|
|
+// @Log(title = "设备要素", businessType = BusinessType.UPDATE)
|
|
|
+// @PutMapping("/edit")
|
|
|
+// public AjaxResult edit(@RequestBody IotDevicefactor iotDevicefactor)
|
|
|
+// {
|
|
|
+// return toAjax(iotDevicefactorService.updateIotDevicefactor(iotDevicefactor));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 删除设备要素
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('yunfeiyun:IotDevicefactor:remove')")
|
|
|
+// @Log(title = "设备要素", businessType = BusinessType.DELETE)
|
|
|
+// @DeleteMapping("/delete/{ids}")
|
|
|
+// public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
+// {
|
|
|
+// return toAjax(iotDevicefactorService.deleteIotDevicefactorByIds(ids));
|
|
|
+// }
|
|
|
+}
|