Przeglądaj źródła

新增 获取基地列表接口

zhaiyifei 10 miesięcy temu
rodzic
commit
e2d72041e5

+ 124 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/controller/IotDeviceBindController.java

@@ -1,10 +1,134 @@
 package com.yunfeiyun.agmp.iotm.web.controller;
 
 import com.yunfeiyun.agmp.common.core.controller.BaseController;
+import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
+import com.yunfeiyun.agmp.common.utils.StringUtils;
+import com.yunfeiyun.agmp.iotm.web.domain.IotDeviceBindBlockVo;
+import com.yunfeiyun.agmp.iotm.web.domain.IotDeviceBindLandVo;
+import com.yunfeiyun.agmp.iotm.web.domain.IotDeviceBindVo;
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceBindListReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.FmsLandListByDeviceBindResVo;
+import com.yunfeiyun.agmp.iotm.web.service.FmsLandService;
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceBindService;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 
 /**
  * 设备绑定控制器
  */
+@Slf4j
+@RestController
+@RequestMapping("/iot/devicebind")
 public class IotDeviceBindController extends BaseController {
 
+    @Autowired
+    private IIotDeviceBindService iIotDeviceBindService;
+
+    @Autowired
+    private FmsLandService fmsLandService;
+
+    /**
+     * 查询基地列表
+     */
+    @GetMapping("/land/list")
+    public TableDataInfo landList() {
+        List<FmsLandListByDeviceBindResVo> fmsLandListByDeviceBindResVoList = fmsLandService.selectFmsLandListByDeviceBind();
+        return getDataTable(fmsLandListByDeviceBindResVoList);
+    }
+
+    /**
+     * 查询设备绑定列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(IotDeviceBindListReqVo iotDeviceBindListReqVo) {
+        startPage();
+        List<String> devBidList = new ArrayList<>();
+        iotDeviceBindListReqVo.setGroupBy(true);
+        String reqLandId = iotDeviceBindListReqVo.getLandId();
+        String reqBlockId = iotDeviceBindListReqVo.getBlockId();
+
+        //当作设备号关键字 检索,再 当作 设备名称关键字, 检索,合并两个结果,去重
+
+        List<IotDeviceBindVo> iotDeviceBindVoList = iIotDeviceBindService.selectIotDeviceBindList(iotDeviceBindListReqVo);
+
+        for (IotDeviceBindVo iotDeviceBindVo : iotDeviceBindVoList) {
+            iotDeviceBindVo.setBlockId(null);
+            iotDeviceBindVo.setLandId(null);
+            iotDeviceBindVo.setBlockName(null);
+            iotDeviceBindVo.setLandName(null);
+            iotDeviceBindVo.setTmnlandId(null);
+            iotDeviceBindVo.setTmnblockId(null);
+            if (iotDeviceBindVo.getBlockNum() == 0 && iotDeviceBindVo.getLandNum() == 0) {
+                continue;
+            }
+            devBidList.add(iotDeviceBindVo.getDevBid());
+        }
+
+        IotDeviceBindListReqVo reqVo = new IotDeviceBindListReqVo();
+        reqVo.setDevBidList(devBidList);
+        reqVo.setLandId(reqLandId);
+        reqVo.setBlockId(reqBlockId);
+
+        List<IotDeviceBindVo> resultList = iIotDeviceBindService.selectIotDeviceBindDetailList(reqVo);
+        HashMap<String, HashSet<IotDeviceBindLandVo>> iotDeviceBindLandVoHashMap = new HashMap<>();
+        HashMap<String, HashSet<IotDeviceBindBlockVo>> iotDeviceBindBlockVoHashMap = new HashMap<>();
+
+        for (IotDeviceBindVo iotDeviceBindVo : resultList) {
+            String devBid = iotDeviceBindVo.getDevBid();
+            String blockId = iotDeviceBindVo.getBlockId();
+            String landId = iotDeviceBindVo.getLandId();
+            String landName = iotDeviceBindVo.getLandName();
+            String blockName = iotDeviceBindVo.getBlockName();
+            String tmnlandId = iotDeviceBindVo.getTmnlandId();
+            String tmnblockId = iotDeviceBindVo.getTmnblockId();
+
+            if (landId != null) {
+                IotDeviceBindLandVo iotDeviceBindLandVo = new IotDeviceBindLandVo();
+                iotDeviceBindLandVo.setLandId(landId);
+                iotDeviceBindLandVo.setLandName(landName);
+                iotDeviceBindLandVo.setTmnlandId(tmnlandId);
+                if (!iotDeviceBindLandVoHashMap.containsKey(devBid)) {
+                    iotDeviceBindLandVoHashMap.put(devBid, new HashSet<>());
+                }
+                iotDeviceBindLandVoHashMap.get(devBid).add(iotDeviceBindLandVo);
+            }
+            if (StringUtils.isNotEmpty(reqLandId) && StringUtils.isEmpty(reqBlockId)) {
+                continue;
+            }
+            if (blockId != null) {
+                IotDeviceBindBlockVo iotDeviceBindBlockVo = new IotDeviceBindBlockVo();
+                iotDeviceBindBlockVo.setBlockId(blockId);
+                iotDeviceBindBlockVo.setBlockName(blockName);
+                iotDeviceBindBlockVo.setTmnblockId(tmnblockId);
+                if (!iotDeviceBindBlockVoHashMap.containsKey(devBid)) {
+                    iotDeviceBindBlockVoHashMap.put(devBid, new HashSet<>());
+                }
+                iotDeviceBindBlockVoHashMap.get(devBid).add(iotDeviceBindBlockVo);
+            }
+        }
+
+        for (IotDeviceBindVo iotDeviceBindVo : iotDeviceBindVoList) {
+            String devBid = iotDeviceBindVo.getDevBid();
+            if (iotDeviceBindLandVoHashMap.containsKey(devBid)) {
+                ArrayList<IotDeviceBindLandVo> iotDeviceBindLandVos = new ArrayList<>(iotDeviceBindLandVoHashMap.get(devBid));
+                iotDeviceBindVo.setLandNum(iotDeviceBindLandVos.size());
+                iotDeviceBindVo.setIotDeviceBindLandVoList(iotDeviceBindLandVos);
+            }
+            if (iotDeviceBindBlockVoHashMap.containsKey(devBid)) {
+                ArrayList<IotDeviceBindBlockVo> iotDeviceBindBlockVos = new ArrayList<>(iotDeviceBindBlockVoHashMap.get(devBid));
+                iotDeviceBindVo.setBlockNum(iotDeviceBindBlockVos.size());
+                iotDeviceBindVo.setIotDeviceBindBlockVoList(iotDeviceBindBlockVos);
+            }
+        }
+
+        return getDataTable(iotDeviceBindVoList);
+    }
 }

+ 22 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/IotDeviceBindBlockVo.java

@@ -0,0 +1,22 @@
+package com.yunfeiyun.agmp.iotm.web.domain;
+
+import com.yunfeiyun.agmp.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class IotDeviceBindBlockVo {
+    private static final long serialVersionUID = 1L;
+
+    /** 地块标识 */
+    private String blockId;
+
+    /** 地块名称 */
+    @Excel(name = "地块名称")
+    private String blockName;
+
+    /** 绑定地块数量 */
+    private int blockNum;
+
+    /** 设备地块标识 */
+    private String tmnblockId;
+}

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

@@ -0,0 +1,25 @@
+package com.yunfeiyun.agmp.iotm.web.domain;
+
+import com.yunfeiyun.agmp.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class IotDeviceBindLandVo {
+    private static final long serialVersionUID = 1L;
+
+    /** 基地标识 */
+    private String landId;
+
+    /** 基地名称 */
+    @Excel(name = "基地名称")
+    private String landName;
+
+    /**
+     * 绑定基地数量
+     */
+    private int landNum;
+
+    /** 设备基地标识 */
+    private String tmnlandId;
+
+}

+ 78 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/IotDeviceBindVo.java

@@ -0,0 +1,78 @@
+package com.yunfeiyun.agmp.iotm.web.domain;
+
+import com.yunfeiyun.agmp.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class IotDeviceBindVo {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 自增主键
+     */
+    private Long id;
+
+    /**
+     * 设备业务标识
+     */
+    @Excel(name = "设备业务标识")
+    private String devBid;
+
+    /**
+     * 设备类型标识
+     */
+    @Excel(name = "设备类型标识")
+    private String devtypeBid;
+
+    /**
+     * 设备类型名称
+     */
+    @Excel(name = "设备类型名称")
+    private String devtypeName;
+    /**
+     * 设备id
+     */
+    @Excel(name = "设备id")
+    private String devCode;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称")
+    private String devName;
+
+    /** 设备基地标识 */
+    private String tmnlandId;
+
+    private String landId;
+
+    /** 设备地块标识 */
+    private String tmnblockId;
+
+    private String blockId;
+
+    private String landName;
+
+    private String blockName;
+
+    /** 基地绑定基地数量 */
+    private int landNum;
+
+    /** 地块绑定地块数量 */
+    private int blockNum;
+
+
+    /**
+     * 绑定基地列表
+     */
+    @Excel(name = "绑定基地列表")
+    private List<IotDeviceBindLandVo> iotDeviceBindLandVoList;
+
+    /**
+     * 绑定地块列表
+     */
+    @Excel(name = "绑定地块列表")
+    private List<IotDeviceBindBlockVo> iotDeviceBindBlockVoList;
+}

+ 80 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/reqvo/IotDeviceBindListReqVo.java

@@ -0,0 +1,80 @@
+package com.yunfeiyun.agmp.iotm.web.domain.reqvo;
+
+import com.yunfeiyun.agmp.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class IotDeviceBindListReqVo {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 自增主键
+     */
+    private Long id;
+
+    /**
+     * 设备业务标识
+     */
+    @Excel(name = "设备业务标识")
+    private String devBid;
+
+    /**
+     * 设备业务标识列表
+     */
+    @Excel(name = "设备业务标识列表")
+    private List<String> devBidList;
+
+    /**
+     * 设备类型标识
+     */
+    @Excel(name = "设备类型标识")
+    private String devtypeBid;
+
+    /**
+     * 设备类型名称
+     */
+    @Excel(name = "设备绑定状态")
+    private String devBindStatus;
+    /**
+     * 设备id
+     */
+    @Excel(name = "设备id")
+    private String devCode;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称")
+    private String devName;
+
+    /**
+     * 是否分组,默认分组,false 表示不分组。后端使用
+     */
+    private boolean isGroupBy = true;
+
+    /** 绑定状态 */
+    private String bindStatus;
+
+    private String landId;
+    private String blockId;
+
+    /**
+     * 设备大类标识 列表
+     */
+    private List<String> devtypePidList;
+
+    /**
+     * 设备大类标识
+     */
+    private String devtypePid;
+
+    /** 开始时间 */
+    private String startTime;
+
+    /** 结束时间 */
+    private String endTime;
+
+    private String tid;
+}

+ 21 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/resvo/FmsLandListByDeviceBindResVo.java

@@ -0,0 +1,21 @@
+package com.yunfeiyun.agmp.iotm.web.domain.resvo;
+
+import com.yunfeiyun.agmp.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class FmsLandListByDeviceBindResVo {
+    private static final long serialVersionUID = 1L;
+
+    /** 基地标识 */
+    private String landId;
+
+    /** 基地名称 */
+    @Excel(name = "基地名称")
+    private String landName;
+
+    /**
+     * 绑定设备数量
+     */
+    private int devNum;
+}

+ 29 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/mapper/FmsLandMapper.java

@@ -0,0 +1,29 @@
+package com.yunfeiyun.agmp.iotm.web.mapper;
+
+
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.FmsLandListByDeviceBindResVo;
+
+import java.util.List;
+
+/**
+ * 基地Mapper接口
+ *
+ * @author 杨晓辉
+ * @date 2023-05-15
+ */
+public interface FmsLandMapper {
+
+    public List<FmsLandListByDeviceBindResVo> selectFmsLandListByDeviceBind(String tid);
+
+//    public List<FmsLandTreeResVo> selectFmsLandTreeResVoList(FmsLandBlockTreeReqVo fmsLandBlockTreeReqVo);
+//
+//    public List<FmsLandListByDeviceBindResVo> selectFmsLandListByDeviceBind();
+//
+//    public List<FmsLandListWithDeviceResVo> selectFmsLandListWithDevice(FmsLandBlockReqVo reqVo);
+//
+//    public FmsLand selectFmsLandByLandId(String landId);
+//
+//    int selectLandTotalArea(String landId);
+//
+//    List<FmsLand> selectFmsLandList();
+}

+ 42 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/mapper/IotDeviceBindMapper.java

@@ -0,0 +1,42 @@
+package com.yunfeiyun.agmp.iotm.web.mapper;
+
+import com.yunfeiyun.agmp.iotm.web.domain.IotDeviceBindVo;
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceBindListReqVo;
+
+import java.util.List;
+
+/**
+ * 设备基础Mapper接口
+ *
+ * @author 杨晓辉
+ * @date 2024-01-04
+ */
+public interface IotDeviceBindMapper {
+    /**
+     * 查询出所有设备列表以及基地地块绑定关系
+     *
+     * @param iotDeviceBindListReqVo
+     * @return
+     */
+    public List<IotDeviceBindVo> selectIotDeviceBindList(IotDeviceBindListReqVo iotDeviceBindListReqVo);
+
+    /**
+     * 查询出所有设备列表以及基地详情绑定关系
+     *
+     * @param iotDeviceBindListReqVo
+     * @return
+     */
+    public List<IotDeviceBindVo> selectIotDeviceBindDetailList(IotDeviceBindListReqVo iotDeviceBindListReqVo);
+//
+//    /**
+//     * 获取设备绑定统计信息
+//     *
+//     * @param
+//     * @return
+//     */
+//    public List<IotDeviceBindStatisticVo> selectDeviceBindStatistic();
+//
+//    public List<IotDeviceBindStatisticVo> selectDeviceBindStatisticByLandId(IotDeviceBindListReqVo reqVo);
+//
+//    List<IotDeviceBindVo> selectIotDeviceBindListBylandIdAndBlock(@Param("landId") String landId, @Param("blockId") String blockId);
+}

+ 29 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/FmsLandService.java

@@ -0,0 +1,29 @@
+package com.yunfeiyun.agmp.iotm.web.service;
+
+
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.FmsLandListByDeviceBindResVo;
+
+import java.util.List;
+
+/**
+ * 基地Mapper接口
+ *
+ * @author 杨晓辉
+ * @date 2023-05-15
+ */
+public interface FmsLandService {
+
+    public List<FmsLandListByDeviceBindResVo> selectFmsLandListByDeviceBind();
+
+//    public List<FmsLandTreeResVo> selectFmsLandTreeResVoList(FmsLandBlockTreeReqVo fmsLandBlockTreeReqVo);
+//
+//    public List<FmsLandListByDeviceBindResVo> selectFmsLandListByDeviceBind();
+//
+//    public List<FmsLandListWithDeviceResVo> selectFmsLandListWithDevice(FmsLandBlockReqVo reqVo);
+//
+//    public FmsLand selectFmsLandByLandId(String landId);
+//
+//    int selectLandTotalArea(String landId);
+//
+//    List<FmsLand> selectFmsLandList();
+}

+ 32 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotDeviceBindService.java

@@ -0,0 +1,32 @@
+package com.yunfeiyun.agmp.iotm.web.service;
+
+import com.yunfeiyun.agmp.iotm.web.domain.IotDeviceBindVo;
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceBindListReqVo;
+
+import java.util.List;
+
+public interface IIotDeviceBindService {
+    /**
+     * 查询出所有设备列表以及基地绑定关系
+     */
+    public List<IotDeviceBindVo> selectIotDeviceBindList(IotDeviceBindListReqVo iotDeviceBindListReqVo);
+
+    /**
+     * 查询出所有设备列表以及基地绑定详情关系
+     */
+    public List<IotDeviceBindVo> selectIotDeviceBindDetailList(IotDeviceBindListReqVo iotDeviceBindListReqVo);
+//
+//    /**
+//     * 绑定设备到基地或地块
+//     *
+//     * @return
+//     */
+//    public int iotDeviceBindAdd(IotDeviceBindAddReqVo iotDeviceBindAddReqVo);
+//
+//    public int iotDeviceBindDel(IotDeviceBindDelReqVo iotDeviceBindDelReqVo);
+//
+//    public List<IotDeviceBindStatisticVo> selectDeviceBindStatistic();
+//    public List<IotDeviceBindStatisticVo> selectDeviceBindStatisticByLandId(IotDeviceBindListReqVo reqVo);
+//
+//    List<IotDeviceBindVo> selectIotDeviceBindListBylandIdAndBlock(String landId, String blockId);
+}

+ 23 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/FmsLandServiceImpl.java

@@ -0,0 +1,23 @@
+package com.yunfeiyun.agmp.iotm.web.service.impl;
+
+import com.yunfeiyun.agmp.common.utils.SecurityUtils;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.FmsLandListByDeviceBindResVo;
+import com.yunfeiyun.agmp.iotm.web.mapper.FmsLandMapper;
+import com.yunfeiyun.agmp.iotm.web.service.FmsLandService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class FmsLandServiceImpl implements FmsLandService {
+
+    @Autowired
+    private FmsLandMapper fmsLandMapper;
+
+    @Override
+    public List<FmsLandListByDeviceBindResVo> selectFmsLandListByDeviceBind() {
+        String tid = SecurityUtils.getTid();
+        return fmsLandMapper.selectFmsLandListByDeviceBind(tid);
+    }
+}

+ 167 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotDeviceBindServiceImpl.java

@@ -0,0 +1,167 @@
+package com.yunfeiyun.agmp.iotm.web.service.impl;
+
+import com.yunfeiyun.agmp.common.utils.SecurityUtils;
+import com.yunfeiyun.agmp.iotm.web.domain.IotDeviceBindVo;
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceBindListReqVo;
+import com.yunfeiyun.agmp.iotm.web.mapper.IotDeviceBindMapper;
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceBindService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Slf4j
+@Service
+public class IotDeviceBindServiceImpl implements IIotDeviceBindService {
+
+    @Autowired
+    private IotDeviceBindMapper iotDeviceBindMapper;
+
+//    @Autowired
+//    private ITmnLandService iTmnLandService;
+//
+//    @Autowired
+//    private ITmnBlockService iTmnBlockService;
+//    @Autowired
+//    private FmsBlockMapper fmsBlockMapper;
+    /**
+     * 查询出所有设备列表以及基地地块绑定关系
+     *
+     * @param iotDeviceBindListReqVo
+     */
+    @Override
+    public List<IotDeviceBindVo> selectIotDeviceBindList(IotDeviceBindListReqVo iotDeviceBindListReqVo) {
+        iotDeviceBindListReqVo.setTid(SecurityUtils.getTid());
+        return iotDeviceBindMapper.selectIotDeviceBindList(iotDeviceBindListReqVo);
+    }
+
+    /**
+     * 查询出所有设备列表以及基地绑定详情关系
+     *
+     * @param iotDeviceBindListReqVo
+     */
+    @Override
+    public List<IotDeviceBindVo> selectIotDeviceBindDetailList(IotDeviceBindListReqVo iotDeviceBindListReqVo) {
+        iotDeviceBindListReqVo.setTid(SecurityUtils.getTid());
+        return iotDeviceBindMapper.selectIotDeviceBindDetailList(iotDeviceBindListReqVo);
+    }
+//
+//    /**
+//     * 绑定设备到基地或地块
+//     *
+//     * @param iotDeviceBindAddReqVo
+//     * @return
+//     */
+//    @Override
+//    public int iotDeviceBindAdd(IotDeviceBindAddReqVo iotDeviceBindAddReqVo) {
+//        List<String> devBidList = iotDeviceBindAddReqVo.getDevBidList();
+//        String landId = iotDeviceBindAddReqVo.getLandId();
+//        String blockId = iotDeviceBindAddReqVo.getBlockId();
+//        HashSet<String> tmnIdLandSet = new HashSet<>();
+//        List<TmnLand> tmnLandResultList = iTmnLandService.selectTmnLandByLandId(landId);
+//        if(tmnLandResultList != null){
+//            for(TmnLand tmn: tmnLandResultList){
+//                tmnIdLandSet.add(tmn.getTmnId());
+//            }
+//        }
+//
+//        HashSet<String> tmnIdBlockSet = new HashSet<>();
+//        List<TmnBlock> tmnBlockResultList = iTmnBlockService.selectTmnBlockByBlockId(blockId);
+//        if(tmnBlockResultList != null){
+//            for(TmnBlock tmnB: tmnBlockResultList){
+//                tmnIdBlockSet.add(tmnB.getTmnId());
+//            }
+//        }
+//
+//        List<TmnLand> tmnLandList = new ArrayList<>();
+//        List<TmnBlock> tmnBlockList = new ArrayList<>();
+//        for(String devBid: devBidList){
+//            if(!tmnIdLandSet.contains(devBid)){
+//                TmnLand tmnLand = new TmnLand();
+//                tmnLand.setTmnlandId(tmnLand.getId());
+//                tmnLand.setTmnId(devBid);
+//                tmnLand.setLandId(landId);
+//                tmnLand.setTmnlandAssigndate(DateUtils.dateTimeNow());
+//                tmnLandList.add(tmnLand);
+//            }
+//
+//            if(StringUtils.isNotEmpty(blockId) && !tmnIdBlockSet.contains(devBid)){
+//                TmnBlock tmnBlock = new TmnBlock();
+//                tmnBlock.setTmnblockId(tmnBlock.getId());
+//                tmnBlock.setTmnId(devBid);
+//                tmnBlock.setBlockId(blockId);
+//                tmnBlock.setTmnblockAssigndate(DateUtils.dateTimeNow());
+//                tmnBlockList.add(tmnBlock);
+//            }
+//        }
+//        int status = 0;
+//        if(tmnLandList.size() > 0){
+//            status = iTmnLandService.insertTmnLandBatch(tmnLandList);
+//        }
+//        if(tmnBlockList.size() > 0){
+//            status = iTmnBlockService.insertTmnBlockBatch(tmnBlockList);
+//        }
+//        if(status == 0){
+//            throw new IotBizException(IotErrorCode.BIND_DEVICE_EXIST);
+//        }
+//        return status;
+//    }
+//
+//    /**
+//     * @param iotDeviceBindDelReqVo
+//     * @return
+//     */
+//    @Override
+//    public int iotDeviceBindDel(IotDeviceBindDelReqVo iotDeviceBindDelReqVo) {
+//        String landId = iotDeviceBindDelReqVo.getLandId();
+//        String tmnlandId = iotDeviceBindDelReqVo.getTmnlandId();
+//        String tmnblockId = iotDeviceBindDelReqVo.getTmnblockId();
+//        String devBid = iotDeviceBindDelReqVo.getDevBid();
+//        int status = 0;
+//        if(StringUtils.isNotEmpty(tmnlandId)){
+//            status = iTmnLandService.deleteTmnLandByTmnlandId(tmnlandId);
+//            FmsLandBlockTreeReqVo fmsLandBlockTreeReqVo = new FmsLandBlockTreeReqVo();
+//            fmsLandBlockTreeReqVo.setLandId(landId);
+//            List<FmsBlock> fmsBlockList = fmsBlockMapper.selectFmsBlockBaseDataList(fmsLandBlockTreeReqVo);
+//            List<String> blockIdList = new ArrayList<>();
+//            for(FmsBlock fmsBlock: fmsBlockList){
+//                blockIdList.add(fmsBlock.getBlockId());
+//            }
+//            if(blockIdList.size() > 0){
+//                IotDeviceBindBlockDelVo iotDeviceBindBlockDelVo = new IotDeviceBindBlockDelVo();
+//                iotDeviceBindBlockDelVo.setTmnId(devBid);
+//                iotDeviceBindBlockDelVo.setBlockIdList(blockIdList);
+//                iTmnBlockService.deleteTmnBlockByBlockIdsAndDevBid(iotDeviceBindBlockDelVo);
+//            }
+//        } else if (StringUtils.isNotEmpty(tmnblockId)) {
+//            status = iTmnBlockService.deleteTmnBlockByTmnblockId(tmnblockId);
+//        }
+//        return status;
+//    }
+//
+//    /**
+//     * @param
+//     * @return
+//     */
+//    @Override
+//    public List<IotDeviceBindStatisticVo> selectDeviceBindStatistic() {
+//        return iotDeviceBindMapper.selectDeviceBindStatistic();
+//    }
+//
+//    @Override
+//    public List<IotDeviceBindStatisticVo> selectDeviceBindStatisticByLandId(IotDeviceBindListReqVo reqVo) {
+//        return iotDeviceBindMapper.selectDeviceBindStatisticByLandId(reqVo);
+//    }
+//
+//    @Override
+//    public List<IotDeviceBindVo> selectIotDeviceBindListBylandIdAndBlock(String landId, String blockId) {
+//        return iotDeviceBindMapper.selectIotDeviceBindListBylandIdAndBlock(landId,blockId);
+//    }
+//
+//    private void cleandata(){
+//        //清理 tmnland和tmnblock表
+//
+//        //删除 已 逻辑删除 的设备的关联数据
+//    }
+}

+ 112 - 0
src/main/resources/mapper/FmsLandMapper.xml

@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.yunfeiyun.agmp.iotm.web.mapper.FmsLandMapper">
+
+    <resultMap type="FmsLand" id="FmsLandResult">
+        <result property="landId"    column="landId"    />
+        <result property="landName"    column="landName"    />
+        <result property="landArea"    column="landArea"    />
+        <result property="landBlockcount"    column="landBlockcount"    />
+        <result property="landDevcount"    column="landDevcount"    />
+        <result property="landManager"    column="landManager"    />
+        <result property="landTel"    column="landTel"    />
+        <result property="landLocation"    column="landLocation"    />
+        <result property="landPreview"    column="landPreview"    />
+        <result property="landRemark"    column="landRemark"    />
+        <result property="resIds"    column="resIds"    />
+        <result property="landSeq" column="landSeq"/>
+        <result property="landType" column="landType"/>
+        <result property="landAnnualAveragePM" column="landAnnualAveragePM"/>
+        <result property="landAnnualAverageTemperature" column="landAnnualAverageTemperature"/>
+        <result property="landAnnualAverageSunshineDuration" column="landAnnualAverageSunshineDuration"/>
+        <result property="landAnnualAveragePrecipitation" column="landAnnualAveragePrecipitation"/>
+        <result property="landAnnualAverageWindSpeed" column="landAnnualAverageWindSpeed"/>
+    </resultMap>
+
+    <select id="selectFmsLandListByDeviceBind" parameterType="String" resultType="FmsLandListByDeviceBindResVo">
+        SELECT f.landId, f.landName, COUNT(t.tmnId) as devNum
+        FROM FmsLand AS f
+            LEFT JOIN (
+                SELECT t.tmnId, t.landId
+                FROM TmnLand AS t
+                    LEFT JOIN IotDevice AS d ON d.devBid = t.tmnId
+                WHERE d.devDelstatus = '0' AND d.tid = #{tid}
+                    AND (NOT ((t.landId IS NULL) OR (t.landId = '') OR (d.devBid IS NULL)))
+                GROUP BY t.tmnId, t.landId
+            ) AS t ON f.landId = t.landId
+        WHERE f.tid = #{tid}
+        GROUP BY f.landId
+        ORDER BY CASE WHEN f.landSeq IS NULL THEN 1 ELSE 0 END,f.landSeq
+    </select>
+
+<!--    <sql id="selectFmsLandHasResVo">-->
+<!--        SELECT l.landId, l.landName, l.landArea, l.landBlockcount, l.landManager, l.landTel, l.landLocation,-->
+<!--            l.landRemark, l.landLatitude, l.landLongitude,l.landSeq,l.landType,-->
+<!--        l.landAnnualAveragePM, l.landAnnualAverageTemperature, l.landAnnualAverageSunshineDuration, l.landAnnualAveragePrecipitation,l.landAnnualAverageWindSpeed,-->
+<!--        (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = l.landId) landPreview,-->
+<!--        (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = l.landId) resIds,-->
+<!--        (SELECT COUNT(tmnlandId) FROM TmnLand tl WHERE tl.landId = l.landId) landDevcount,-->
+<!--        (SELECT u.userName FROM SysUser u WHERE u.userId = l.landManager) landManagerName-->
+<!--        from FmsLand l-->
+<!--    </sql>-->
+
+<!--    <select id="selectFmsLandTreeResVoList" resultType="FmsLandTreeResVo">-->
+<!--        <include refid="selectFmsLandHasResVo"/>-->
+<!--        <where>-->
+<!--            <if test="landIds != null and landIds.size() !=0">-->
+<!--                and landId in-->
+<!--                <foreach collection="landIds" open="(" separator="," close=")" item="item" index="index">-->
+<!--                    #{item}-->
+<!--                </foreach>-->
+<!--            </if>-->
+<!--            <if test="landName != null  and landName != ''"> and landName like concat('%', #{landName}, '%')</if>-->
+<!--        </where>-->
+<!--    </select>-->
+
+
+
+<!--    <select id="selectFmsLandListWithDevice" resultType="FmsLandListWithDeviceResVo">-->
+<!--    SELECT FmsLand.*-->
+<!--    ,IotDevice.devBid,IotDevice.devName,IotDevice.devStatus,IotDevice.devUpdateddate-->
+<!--    ,IotDevicetype.devtypePid,IotDevicetype.devtypeName-->
+<!--        ,(select GROUP_CONCAT(resUrl) from SysRes where SysRes.resBusId = FmsLand.landId) landPreview-->
+<!--        ,SysUser.userName landManagerName-->
+<!--        ,SysUser.userMobile-->
+<!--        FROM FmsLand-->
+<!--    left join TmnLand on TmnLand.landId=FmsLand.landId-->
+<!--    left join IotDevice on IotDevice.devBid= TmnLand.tmnId-->
+<!--    left join IotDevicetype on IotDevicetype.devtypeBid = IotDevice.devtypeBid-->
+<!--        left join SysUser on SysUser.userId = FmsLand.landManager-->
+
+<!--        <where>-->
+<!--            <if test="devtypePid != null  and devtypePid != ''">and IotDevicetype.devtypePid = #{devtypePid}</if>-->
+<!--            <if test="landName != null  and landName != ''">and FmsLand.landName like concat('%', #{landName}, '%')</if>-->
+<!--            <if test="landLocation != null  and landLocation != ''">and FmsLand.landLocation like concat('%', #{landLocation}, '%')</if>-->
+<!--            <if test="landManagername != null  and landManagername != ''">and FmsBlock.blockManagername like concat('%', #{blockManagername}, '%')</if>-->
+<!--            <if test="userMobile != null  and userMobile != ''">and SysUser.userMobile like concat('%', #{userMobile}, '%')</if>-->
+
+<!--        </where>-->
+
+<!--        group by landId-->
+<!--    </select>-->
+
+
+<!--    <select id="selectFmsLandByLandId" parameterType="String" resultType="FmsLand">-->
+<!--        SELECT FmsLand.* FROM FmsLand-->
+<!--        where landId = #{landId}-->
+<!--    </select>-->
+<!--    <select id="selectLandTotalArea" resultType="java.lang.Integer">-->
+<!--        SELECT SUM(landArea) FROM FmsLand-->
+<!--        <where>-->
+<!--           <if test="landId != null and landId != ''">-->
+<!--              landId = #{landId}-->
+<!--           </if>-->
+<!--        </where>-->
+<!--    </select>-->
+<!--    <select id="selectFmsLandList" resultType="com.yunfeiyun.agmp.iot.common.domain.FmsLand">-->
+<!--        select * from FmsLand order  by landSeq desc-->
+<!--    </select>-->
+
+</mapper>

+ 139 - 0
src/main/resources/mapper/IotDeviceBindMapper.xml

@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.yunfeiyun.agmp.iotm.web.mapper.IotDeviceBindMapper">
+
+    <select id="selectIotDeviceBindList" parameterType="IotDeviceBindListReqVo" resultType="IotDeviceBindVo">
+        SELECT *, COUNT(f.landId) AS landNum, COUNT(f.blockId) AS blockNum
+        FROM (
+            SELECT d.devBid, d.devtypeBid, dt.devtypeName, d.devCode, d.devName, t.tmnlandId, t.landId, ft.landName,
+                b.tmnblockId, b.blockId, fb.blockName, t.tmnlandAssigndate, b.tmnblockAssigndate
+            FROM IotDevice AS d
+                LEFT JOIN (
+                    SELECT *
+                    FROM TmnLand AS t
+                    WHERE NOT ((t.landId IS NULL) OR (t.landId = ''))
+                ) AS t ON t.tmnId = d.devBid
+                LEFT JOIN IotDevicetype AS dt on dt.devtypeBid = d.devtypeBid
+                LEFT JOIN FmsLand AS ft ON t.landId = ft.landId
+                LEFT JOIN TmnBlock AS b ON d.devBid = b.tmnId
+                LEFT JOIN FmsBlock AS fb ON b.blockId = fb.blockId
+            <where>
+                d.devDelstatus = '0' and tid = #{tid}
+                <if test="devtypeBid != null  and devtypeBid != ''">and d.devtypeBid = #{devtypeBid}</if>
+                <if test="devCode != null  and devCode != ''">
+                    and (
+                        (d.devCode like concat('%', #{devCode}, '%')) or (d.devName like concat('%', #{devCode}, '%'))
+                    )
+                </if>
+                <if test="devName != null  and devName != ''">and d.devName like concat('%', #{devName}, '%')</if>
+                <if test="landId != null  and landId != ''">and t.landId = #{landId}</if>
+                <if test="blockId != null  and blockId != ''">and b.blockId = #{blockId}</if>
+                <if test="bindStatus != null and bindStatus != ''">
+                    <if test="bindStatus == 0">
+                        AND t.landId IS NULL
+                    </if>
+                    <if test="bindStatus == 1">
+                        AND (NOT t.landId IS NULL)
+                    </if>
+                </if>
+                <if test="devtypePidList != null and devtypePidList.size() > 0">
+                    and dt.devtypePid in
+                    <foreach collection="devtypePidList" item="devtypePid" open="(" separator="," close=")">
+                        #{devtypePid}
+                    </foreach>
+                </if>
+            </where>
+            GROUP BY d.devBid, t.landId, b.blockId
+        ) AS f
+        <if test="isGroupBy">
+            GROUP BY f.devBid
+            HAVING NOT (landNum = 0 AND blockNum != 0)
+        </if>
+        ORDER BY f.tmnlandAssigndate DESC, f.tmnblockAssigndate DESC
+    </select>
+
+    <select id="selectIotDeviceBindDetailList" parameterType="IotDeviceBindListReqVo" resultType="IotDeviceBindVo">
+        SELECT d.devBid, d.devtypeBid, d.devCode, d.devName, t.tmnlandId, t.landId, ft.landName,
+            b.tmnblockId, b.blockId, fb.blockName
+        FROM IotDevice AS d
+            LEFT JOIN TmnLand AS t ON d.devBid = t.tmnId
+            LEFT JOIN FmsLand AS ft ON t.landId = ft.landId
+            LEFT JOIN TmnBlock AS b ON d.devBid = b.tmnId
+            LEFT JOIN FmsBlock AS fb ON b.blockId = fb.blockId
+        <where>
+            d.devDelstatus = '0' and tid = #{tid}
+            <if test="devBidList != null and devBidList.size() > 0">
+                and d.devBid in
+                <foreach collection="devBidList" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="landId != null  and landId != ''">and t.landId = #{landId}</if>
+            <if test="blockId != null  and blockId != ''">and b.blockId = #{blockId}</if>
+        </where>
+        GROUP BY d.devBid, t.landId, b.blockId
+    </select>
+
+<!--    <select id="selectDeviceBindStatistic" resultType="IotDeviceBindStatisticVo">-->
+<!--        SELECT dt.devtypeBid, dt.devtypeName, COUNT(*) AS devTypeNum, (-->
+<!--            SELECT count(*) AS bindNum-->
+<!--            FROM (-->
+<!--                SELECT d.devBid, t.landId-->
+<!--                FROM IotDevice AS d-->
+<!--                LEFT JOIN (-->
+<!--                    SELECT *-->
+<!--                    FROM TmnLand AS t-->
+<!--                    WHERE NOT ((t.landId IS NULL) OR (t.landId = ''))-->
+<!--                ) AS t ON t.tmnId = d.devBid-->
+<!--                WHERE d.devDelstatus = '0' AND NOT t.landId IS NULL-->
+<!--                GROUP BY d.devBid-->
+<!--            ) AS df-->
+<!--        ) AS bindNum-->
+<!--        FROM IotDevice AS d-->
+<!--        LEFT JOIN IotDevicetype AS dt ON dt.devtypeBid = d.devtypeBid-->
+<!--        where d.devDelstatus = '0' AND NOT ((dt.devtypeBid IS NULL) OR (dt.devtypeBid = ''))-->
+<!--        GROUP BY dt.devtypeBid-->
+<!--    </select>-->
+
+<!--    <select id="selectDeviceBindStatisticByLandId" parameterType="IotDeviceBindListReqVo"-->
+<!--            resultType="IotDeviceBindStatisticVo">-->
+<!--        SELECT dt.devtypeBid, dt.devtypeName, COUNT(*) AS devTypeNum, (-->
+<!--        SELECT count(*) AS bindNum-->
+<!--        FROM (-->
+<!--        SELECT d.devBid, t.landId-->
+<!--        FROM IotDevice AS d-->
+<!--        LEFT JOIN (-->
+<!--        SELECT *-->
+<!--        FROM TmnLand AS t-->
+<!--        WHERE NOT ((t.landId IS NULL) OR (t.landId = ''))-->
+<!--        ) AS t ON t.tmnId = d.devBid-->
+<!--        WHERE d.devDelstatus = '0' AND NOT t.landId IS NULL-->
+<!--        GROUP BY d.devBid-->
+<!--        ) AS df-->
+<!--        ) AS bindNum-->
+<!--        FROM IotDevice AS d-->
+<!--        LEFT JOIN IotDevicetype AS dt ON dt.devtypeBid = d.devtypeBid-->
+<!--        left join TmnLand on TmnLand.tmnId = d.devBid-->
+<!--        where d.devDelstatus = '0' AND NOT ((dt.devtypeBid IS NULL) OR (dt.devtypeBid = ''))-->
+<!--        <if test="landId != null  and landId != ''">and TmnLand.landId = #{landId}</if>-->
+<!--        GROUP BY dt.devtypeBid-->
+<!--    </select>-->
+
+<!--    <select id="selectIotDeviceBindListBylandIdAndBlock"-->
+<!--            resultType="com.yunfeiyun.agmp.iotm.device.domain.dtovo.IotDeviceBindVo">-->
+
+<!--    SELECT d.devBid, d.devtypeBid, d.devCode, d.devName, fb.landId, fl.landName,-->
+<!--        fb.blockId, fb.blockName,dt.devtypeName  from IotDevice d-->
+<!--        LEFT JOIN TmnBase b ON d.devBid = b.tmnId-->
+<!--        left join  TmnBlock a on a.tmnId=d.devBid-->
+<!--        LEFT JOIN IotDevicetype AS dt ON dt.devtypeBid = d.devtypeBid-->
+<!--        LEFT JOIN FmsBlock AS fb ON a.blockId = fb.blockId-->
+<!--        left join  FmsLand as fl on fl.landId=fb.landId-->
+
+<!--        where d.devDelstatus = '0' and a.blockId  is not null and a.blockId !=''-->
+<!--        and a.blockId = #{blockId}-->
+
+<!--    </select>-->
+</mapper>