Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

liuyaowen 1 vuosi sitten
vanhempi
commit
d40b33cab6

+ 4 - 4
src/main/java/com/yunfeiyun/agmp/iotm/device/qxz/service/impl/IotYfQxzServiceImpl.java

@@ -50,14 +50,14 @@ public class IotYfQxzServiceImpl extends IotDeviceBaseServiceImpl implements Iot
     private RedisCacheManager redisCacheManager;
     private RedisCacheManager redisCacheManager;
 
 
     public TableDataInfo dataList(IotDeviceQxzDataListReqVo reqVo) throws ParseException {
     public TableDataInfo dataList(IotDeviceQxzDataListReqVo reqVo) throws ParseException {
-        return dataList(reqVo, true);
+        return dataList(reqVo, true, false);
     }
     }
 
 
     /**
     /**
      * 获取数据列表接口
      * 获取数据列表接口
      * @param reqVo
      * @param reqVo
      */
      */
-    public TableDataInfo dataList(IotDeviceQxzDataListReqVo reqVo, boolean isNow) throws ParseException {
+    public TableDataInfo dataList(IotDeviceQxzDataListReqVo reqVo, boolean isNow, boolean isDisable) throws ParseException {
         TableDataInfo rspData = new TableDataInfo();
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(ErrorCode.SUCCESS.getCode());
         rspData.setCode(ErrorCode.SUCCESS.getCode());
         rspData.setMsg(ErrorCode.SUCCESS.getMessage());
         rspData.setMsg(ErrorCode.SUCCESS.getMessage());
@@ -112,7 +112,7 @@ public class IotYfQxzServiceImpl extends IotDeviceBaseServiceImpl implements Iot
         List<List<IotQxzDataListRseVo>> rest = new ArrayList<>();
         List<List<IotQxzDataListRseVo>> rest = new ArrayList<>();
         for(QxzDataListDto item: qxzDataListDtoIPage.getRecords()){
         for(QxzDataListDto item: qxzDataListDtoIPage.getRecords()){
             List<QxzDataDto> dataList = item.getDataList();
             List<QxzDataDto> dataList = item.getDataList();
-            List<IotQxzDataListRseVo> iotQxzDataListRseVoList = ElementFactorUtil.qxzListProcessData(dataList, factorList, findDevice, false);
+            List<IotQxzDataListRseVo> iotQxzDataListRseVoList = ElementFactorUtil.qxzListProcessData(dataList, factorList, findDevice, isDisable);
             rest.add(iotQxzDataListRseVoList);
             rest.add(iotQxzDataListRseVoList);
         }
         }
         rspData.setData(rest);
         rspData.setData(rest);
@@ -307,7 +307,7 @@ public class IotYfQxzServiceImpl extends IotDeviceBaseServiceImpl implements Iot
         String devBid = reqVo.getDevBid();
         String devBid = reqVo.getDevBid();
 
 
         IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
         IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
-        TableDataInfo tableDataInfo = dataList(reqVo, false);
+        TableDataInfo tableDataInfo = dataList(reqVo, false, true);
         List<List<IotQxzDataListRseVo>> rest = (List<List<IotQxzDataListRseVo>>) tableDataInfo.getData();
         List<List<IotQxzDataListRseVo>> rest = (List<List<IotQxzDataListRseVo>>) tableDataInfo.getData();
         if(rest == null || rest.isEmpty()){
         if(rest == null || rest.isEmpty()){
             log.info("devBid:{},【最近数据】empty",devBid);
             log.info("devBid:{},【最近数据】empty",devBid);

+ 117 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/sqz/controller/IotDeviceSqzController.java

@@ -0,0 +1,117 @@
+package com.yunfeiyun.agmp.iotm.device.sqz.controller;
+
+import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
+import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
+import com.yunfeiyun.agmp.iotm.common.controller.BaseController;
+import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceBaseFunReqVo;
+import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceCommonService;
+import com.yunfeiyun.agmp.iotm.device.qxz.domain.IotDeviceQxzDataListReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListResVo;
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 墒情站设备控制器
+ * 云飞墒情站和云飞气象站共用一个impl
+ */
+@RestController
+@RequestMapping("/iot/device/sqz")
+@Slf4j
+public class IotDeviceSqzController extends BaseController {
+
+    @Autowired
+    private IIotDeviceService iIotDeviceService;
+
+    @Resource
+    private IotDeviceCommonService iotDeviceCommonService;
+
+
+    /**
+     * 数据列表
+     * @param reqVo
+     * @return
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(IotDeviceListReqVo reqVo) {
+        startPage();
+        String[] devTypeList = new String[]{IotDeviceDictConst.TYPE_YF_SQZ};
+        reqVo.setDevtypeBidList(Arrays.asList(devTypeList));
+
+        List<IotDeviceListResVo> list = iIotDeviceService.selectIotDeviceListByType(reqVo);
+        return getDataTable(list);
+    }
+
+    /**
+     * 气象数据列表
+     * @param reqVo
+     * @return
+     */
+    @GetMapping("/data/list")
+    public TableDataInfo dataList(IotDeviceQxzDataListReqVo reqVo) {
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("dataList");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        return iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+    }
+
+    /**
+     * 气象数据折线图列表
+     * @param reqVo
+     * @return
+     */
+    @GetMapping("/chart/list")
+    public AjaxResult chartList(IotDeviceQxzDataListReqVo reqVo) {
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("chartList");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        List<IotDeviceListResVo> list = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * 气象数据24小时列表
+     * @param
+     * @return
+     */
+    @GetMapping("/data/last24h/{devBid}")
+    public AjaxResult dataList24h(@PathVariable("devBid") String devBid) {
+        IotDeviceQxzDataListReqVo reqVo = new IotDeviceQxzDataListReqVo();
+        reqVo.setDevBid(devBid);
+
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("dataList24h");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        return AjaxResult.success(iotDeviceCommonService.func(iotDeviceBaseFunReqVo));
+    }
+
+    /**
+     * 获取最近数据列表接口
+     * @param
+     * @return
+     */
+    @GetMapping("/data/dataLatest/{devBid}")
+    public AjaxResult dataLatest(@PathVariable("devBid") String devBid) {
+        IotDeviceQxzDataListReqVo reqVo = new IotDeviceQxzDataListReqVo();
+        reqVo.setDevBid(devBid);
+
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("dataLatest");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        return AjaxResult.success(iotDeviceCommonService.func(iotDeviceBaseFunReqVo));
+    }
+}

+ 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 结果
      * @return 结果
      */
      */
     @Override
     @Override
-    public int insertIotDevicefactor(IotDevicefactor iotDevicefactor)
-    {
+    public int insertIotDevicefactor(IotDevicefactor iotDevicefactor) {
+        iotDevicefactor.setTid(SecurityUtils.getTid());
         return iotDevicefactorMapper.insertIotDevicefactor(iotDevicefactor);
         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="dfCreator"    column="dfCreator"    />
         <result property="dfModifieddate"    column="dfModifieddate"    />
         <result property="dfModifieddate"    column="dfModifieddate"    />
         <result property="dfModifier"    column="dfModifier"    />
         <result property="dfModifier"    column="dfModifier"    />
+        <result property="tid"    column="tid"    />
     </resultMap>
     </resultMap>
 
 
     <sql id="selectIotDevicefactorVo">
     <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>
     </sql>
 
 
     <select id="selectIotDevicefactorList" parameterType="IotDevicefactor" resultMap="IotDevicefactorResult">
     <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 id="insertIotDevicefactor" parameterType="IotDevicefactor" useGeneratedKeys="true" keyProperty="id">
         insert into IotDevicefactor
         insert into IotDevicefactor
         <trim prefix="(" suffix=")" suffixOverrides=",">
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            tid,
             <if test="dfBid != null">dfBid,</if>
             <if test="dfBid != null">dfBid,</if>
             <if test="devBid != null">devBid,</if>
             <if test="devBid != null">devBid,</if>
             <if test="dfCode != null">dfCode,</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>
             <if test="dfModifier != null">dfModifier,</if>
          </trim>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            #{tid},
             <if test="dfBid != null">#{dfBid},</if>
             <if test="dfBid != null">#{dfBid},</if>
             <if test="devBid != null">#{devBid},</if>
             <if test="devBid != null">#{devBid},</if>
             <if test="dfCode != null">#{dfCode},</if>
             <if test="dfCode != null">#{dfCode},</if>