瀏覽代碼

新增 编辑设备要素接口

zhaiyifei 1 年之前
父節點
當前提交
33b3acbb5f

+ 153 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/controller/IotDevicefactorController.java

@@ -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));
+//    }
+}

+ 25 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/reqvo/IotDeviceFactorBatchEditReqVo.java

@@ -0,0 +1,25 @@
+package com.yunfeiyun.agmp.iotm.web.domain.reqvo;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotDevicefactor;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.util.List;
+
+/**
+ * 批量设置 监测要素 自定义名称
+ * 
+
+ */
+@Data
+public class IotDeviceFactorBatchEditReqVo
+{
+    /** 设备标识 */
+    @NotBlank(message = "设备标识不能为空")
+    private String devBid;
+
+
+    /** 要素信息列表 */
+    private List<IotDevicefactor> factorList;
+
+}

+ 2 - 2
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotDevicefactorServiceImpl.java

@@ -53,8 +53,8 @@ public class IotDevicefactorServiceImpl implements IIotDevicefactorService
      * @return 结果
      */
     @Override
-    public int insertIotDevicefactor(IotDevicefactor iotDevicefactor)
-    {
+    public int insertIotDevicefactor(IotDevicefactor iotDevicefactor) {
+        iotDevicefactor.setTid(SecurityUtils.getTid());
         return iotDevicefactorMapper.insertIotDevicefactor(iotDevicefactor);
     }
 

+ 6 - 1
src/main/resources/mapper/IotDevicefactorMapper.xml

@@ -17,10 +17,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="dfCreator"    column="dfCreator"    />
         <result property="dfModifieddate"    column="dfModifieddate"    />
         <result property="dfModifier"    column="dfModifier"    />
+        <result property="tid"    column="tid"    />
     </resultMap>
 
     <sql id="selectIotDevicefactorVo">
-        select id, dfBid, devBid, dfCode,dfAddress, dfName, dfDisplayname, dfDisable, dfCreatedDate, dfCreator, dfModifieddate, dfModifier from IotDevicefactor
+        select id, dfBid, devBid, dfCode,dfAddress, dfName, dfDisplayname, dfDisable, dfCreatedDate, dfCreator,
+            dfModifieddate, dfModifier, tid
+        from IotDevicefactor
     </sql>
 
     <select id="selectIotDevicefactorList" parameterType="IotDevicefactor" resultMap="IotDevicefactorResult">
@@ -48,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertIotDevicefactor" parameterType="IotDevicefactor" useGeneratedKeys="true" keyProperty="id">
         insert into IotDevicefactor
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            tid,
             <if test="dfBid != null">dfBid,</if>
             <if test="devBid != null">devBid,</if>
             <if test="dfCode != null">dfCode,</if>
@@ -61,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="dfModifier != null">dfModifier,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            #{tid},
             <if test="dfBid != null">#{dfBid},</if>
             <if test="devBid != null">#{devBid},</if>
             <if test="dfCode != null">#{dfCode},</if>