Просмотр исходного кода

新增 获取地块列表接口

zhaiyifei 10 месяцев назад
Родитель
Сommit
2fd6cc6639

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

@@ -7,7 +7,9 @@ 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.FmsBlockListByDeviceBindResVo;
 import com.yunfeiyun.agmp.iotm.web.domain.resvo.FmsLandListByDeviceBindResVo;
+import com.yunfeiyun.agmp.iotm.web.service.FmsBlockService;
 import com.yunfeiyun.agmp.iotm.web.service.FmsLandService;
 import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceBindService;
 import lombok.extern.slf4j.Slf4j;
@@ -35,6 +37,9 @@ public class IotDeviceBindController extends BaseController {
     @Autowired
     private FmsLandService fmsLandService;
 
+    @Autowired
+    private FmsBlockService fmsBlockService;
+
     /**
      * 查询基地列表
      */
@@ -44,6 +49,16 @@ public class IotDeviceBindController extends BaseController {
         return getDataTable(fmsLandListByDeviceBindResVoList);
     }
 
+
+    /**
+     * 查询地块列表
+     */
+    @GetMapping("/block/list")
+    public TableDataInfo blockList(String landId) {
+        List<FmsBlockListByDeviceBindResVo> fmsBlockListByDeviceBindResVoList = fmsBlockService.selectFmsBlockListByDeviceBind(landId);
+        return getDataTable(fmsBlockListByDeviceBindResVoList);
+    }
+
     /**
      * 查询设备绑定列表
      */
@@ -131,4 +146,5 @@ public class IotDeviceBindController extends BaseController {
 
         return getDataTable(iotDeviceBindVoList);
     }
+
 }

+ 21 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/resvo/FmsBlockListByDeviceBindResVo.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 FmsBlockListByDeviceBindResVo {
+    private static final long serialVersionUID = 1L;
+
+    /** 地块标识 */
+    private String blockId;
+
+    /** 基地名称 */
+    @Excel(name = "地块名称")
+    private String blockName;
+
+    /**
+     * 绑定设备数量
+     */
+    private int devNum;
+}

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

@@ -0,0 +1,42 @@
+package com.yunfeiyun.agmp.iotm.web.mapper;
+
+
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.FmsBlockListByDeviceBindResVo;
+
+import java.util.List;
+
+/**
+ * 地块Mapper接口
+ *
+ * @author 杨晓辉
+ * @date 2023-05-15
+ */
+public interface FmsBlockMapper
+{
+
+    public List<FmsBlockListByDeviceBindResVo> selectFmsBlockListByDeviceBind(String landId);
+//
+//    public List<FmsBlock> selectFmsBlockBaseDataList(FmsLandBlockTreeReqVo fmsLandBlockTreeReqVo);
+//
+//
+//    public List<FmsBlockListWithDeviceResVo> selectFmsBlockListWithDevice(FmsLandBlockReqVo reqVo);
+//
+//    int selectFmsBlockNum(String landId);
+//
+//    Map<String,Integer> selectFmsBlockPlans(String landId);
+//
+//    /**
+//     * 查询地块
+//     *
+//     * @param blockId 地块主键
+//     * @return 地块
+//     */
+//    public FmsBlock selectFmsBlockByBlockId(String blockId);
+//
+//    List<FmsBlock> selectFmsBlockList(String blockName);
+//    /**
+//     * 查询地块列表
+//     * */
+//    List<FmsBlockIrrigateResVo> selectFmsBlockListByLandId(String landId);
+
+}

+ 44 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/FmsBlockService.java

@@ -0,0 +1,44 @@
+package com.yunfeiyun.agmp.iotm.web.service;
+
+
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.FmsBlockListByDeviceBindResVo;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 地块Mapper接口
+ *
+ * @author 杨晓辉
+ * @date 2023-05-15
+ */
+
+public interface FmsBlockService
+{
+
+    public List<FmsBlockListByDeviceBindResVo> selectFmsBlockListByDeviceBind(String landId);
+//
+//    public List<FmsBlock> selectFmsBlockBaseDataList(FmsLandBlockTreeReqVo fmsLandBlockTreeReqVo);
+//
+//
+//    public List<FmsBlockListWithDeviceResVo> selectFmsBlockListWithDevice(FmsLandBlockReqVo reqVo);
+//
+//    int selectFmsBlockNum(String landId);
+//
+//    Map<String,Integer> selectFmsBlockPlans(String landId);
+//
+//    /**
+//     * 查询地块
+//     *
+//     * @param blockId 地块主键
+//     * @return 地块
+//     */
+//    public FmsBlock selectFmsBlockByBlockId(String blockId);
+//
+//    List<FmsBlock> selectFmsBlockList(String blockName);
+//    /**
+//     * 查询地块列表
+//     * */
+//    List<FmsBlockIrrigateResVo> selectFmsBlockListByLandId(String landId);
+
+}

+ 21 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/FmsBlockServiceImpl.java

@@ -0,0 +1,21 @@
+package com.yunfeiyun.agmp.iotm.web.service.impl;
+
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.FmsBlockListByDeviceBindResVo;
+import com.yunfeiyun.agmp.iotm.web.mapper.FmsBlockMapper;
+import com.yunfeiyun.agmp.iotm.web.service.FmsBlockService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class FmsBlockServiceImpl implements FmsBlockService {
+
+    @Autowired
+    private FmsBlockMapper fmsBlockMapper;
+
+    @Override
+    public List<FmsBlockListByDeviceBindResVo> selectFmsBlockListByDeviceBind(String landId) {
+        return fmsBlockMapper.selectFmsBlockListByDeviceBind(landId);
+    }
+}

+ 166 - 0
src/main/resources/mapper/FmsBlockMapper.xml

@@ -0,0 +1,166 @@
+<?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.FmsBlockMapper">
+
+    <resultMap type="FmsBlock" id="FmsBlockResult">
+        <result property="blockId"    column="blockId"    />
+        <result property="landId"    column="landId"    />
+        <result property="blockName"    column="blockName"    />
+        <result property="blockType"    column="blockType"    />
+        <result property="blockManager"    column="blockManager"    />
+        <result property="blockManagername"    column="blockManagername"    />
+        <result property="blockArea"    column="blockArea"    />
+        <result property="blockAreaplant"    column="blockAreaplant"    />
+        <result property="blockLngrange"    column="blockLngrange"    />
+        <result property="blockColor"    column="blockColor"    />
+        <result property="blockRemark"    column="blockRemark"    />
+        <result property="blockPreview"    column="blockPreview"    />
+        <result property="blockSeq" column="blockSeq"/>
+        <result property="blockIcon" column="blockIcon"/>
+    </resultMap>
+
+    <select id="selectFmsBlockListByDeviceBind" resultType="FmsBlockListByDeviceBindResVo" parameterType="String">
+        SELECT fb.blockId, fb.blockName,  IFNULL(f2.devNum, 0) AS devNum, fb.blockSeq
+        FROM FmsBlock AS fb
+        LEFT JOIN (
+        SELECT f.blockId, f.blockName, COUNT(*) AS devNum, f.blockSeq
+        FROM (
+        SELECT fb.blockId, fb.blockName, td.landId, fb.blockSeq
+        FROM FmsBlock AS fb
+        LEFT JOIN TmnBlock AS tb ON tb.blockId = fb.blockId
+        LEFT JOIN TmnLand AS td ON td.tmnId = tb.tmnId
+        LEFT JOIN IotDevice AS d ON d.devBid = tb.tmnId
+        WHERE fb.landId = #{landId} AND d.devDelstatus = '0' AND (td.landId IS NOT NULL)
+        GROUP BY fb.blockId, tb.tmnId
+        ) AS f
+        GROUP BY f.blockId
+        ) AS f2 ON fb.blockId = f2.blockId
+        WHERE fb.landId = #{landId}
+        ORDER BY fb.blockSeq
+    </select>
+
+
+<!--    <sql id="selectFmsBlockVo">-->
+<!--        select blockId, landId, blockName, blockType, blockManager, blockManagername, blockArea, blockAreaplant,blockSeq,blockIcon,-->
+<!--        blockLngrange, blockColor, blockRemark from FmsBlock-->
+<!--    </sql>-->
+
+<!--    <select id="selectFmsBlockByBlockId" parameterType="String" resultMap="FmsBlockResult">-->
+<!--        <include refid="selectFmsBlockVo"/>-->
+<!--        where blockId = #{blockId}-->
+<!--    </select>-->
+
+<!--    <select id="selectFmsBlockBaseDataList" resultType="FmsBlock">-->
+<!--        <include refid="selectFmsBlockVo"/>-->
+<!--        <where>-->
+<!--            <if test="landId != null  and landId != ''"> and landId = #{landId}</if>-->
+<!--            <if test="blockName != null  and blockName != ''"> and blockName like concat('%', #{blockName}, '%')</if>-->
+<!--            <if test="blockNameEq != null  and blockNameEq != ''"> and blockName = #{blockNameEq}</if>-->
+<!--            <if test="blockType != null  and blockType != ''"> and blockType = #{blockType}</if>-->
+<!--            <if test="blockManager != null  and blockManager != ''"> and blockManager = #{blockManager}</if>-->
+<!--            <if test="blockManagername != null  and blockManagername != ''"> and blockManagername like concat('%', #{blockManagername}, '%')</if>-->
+<!--            <if test="blockArea != null "> and blockArea = #{blockArea}</if>-->
+<!--            <if test="blockAreaplant != null "> and blockAreaplant = #{blockAreaplant}</if>-->
+<!--            <if test="blockLngrange != null  and blockLngrange != ''"> and blockLngrange = #{blockLngrange}</if>-->
+<!--            <if test="blockColor != null  and blockColor != ''"> and blockColor = #{blockColor}</if>-->
+<!--            <if test="blockRemark != null  and blockRemark != ''"> and blockRemark = #{blockRemark}</if>-->
+<!--            <if test="blockId != null and blockId != ''">-->
+<!--                and blockId = #{blockId}-->
+<!--            </if>-->
+<!--            <if test="dataFilter == true and blockIds !=null and blockIds.size()>0">-->
+<!--                and b.blockId in-->
+<!--                <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">-->
+<!--                    #{blockId}-->
+<!--                </foreach>-->
+<!--            </if>-->
+<!--            <if test="landIds != null and landIds.size()!=0">-->
+<!--                and landId in-->
+<!--                <foreach collection="landIds" item="item" index="index" open="(" separator="," close=")">-->
+<!--                    #{item}-->
+<!--                </foreach>-->
+<!--            </if>-->
+<!--        </where>-->
+<!--    </select>-->
+<!--    -->
+
+
+<!--    <select id="selectFmsBlockListWithDevice" resultType="FmsBlockListWithDeviceResVo">-->
+<!--        SELECT FmsBlock.*-->
+<!--        ,FmsLand.landName-->
+<!--        ,IotDevice.devBid,IotDevice.devName,IotDevice.devStatus,IotDevice.devUpdateddate-->
+<!--        ,IotDevicetype.devtypePid,IotDevicetype.devtypeName-->
+<!--        ,(select GROUP_CONCAT(resUrl) from SysRes where SysRes.resBusId = FmsBlock.blockId) blockPreview-->
+<!--        ,SysUser.userMobile-->
+<!--        FROM FmsBlock-->
+
+<!--        left join TmnBlock on TmnBlock.blockId=FmsBlock.blockId-->
+<!--        left join IotDevice on IotDevice.devBid= TmnBlock.tmnId-->
+<!--        left join IotDevicetype on IotDevicetype.devtypeBid = IotDevice.devtypeBid-->
+<!--        left join FmsLand on FmsLand.landId = FmsBlock.landId-->
+<!--        left join SysUser on SysUser.userId = FmsBlock.blockManager-->
+
+<!--        <where>-->
+<!--            <if test="devtypePid != null  and devtypePid != ''">and IotDevicetype.devtypePid = #{devtypePid}</if>-->
+<!--            <if test="landId != null  and landId != ''">and FmsLand.landId = #{landId}</if>-->
+<!--            <if test="landName != null  and landName != ''">and FmsLand.landName like concat('%', #{landName}, '%')</if>-->
+<!--            <if test="blockName != null  and blockName != ''">and FmsBlock.blockName like concat('%', #{blockName}, '%')</if>-->
+<!--            <if test="blockManagername != null  and blockManagername != ''">and FmsBlock.blockManagername like concat('%', #{blockManagername}, '%')</if>-->
+<!--            <if test="userMobile != null  and userMobile != ''">and SysUser.userMobile like concat('%', #{userMobile}, '%')</if>-->
+<!--            <if test="blockId != null and blockId != ''">and FmsBlock.blockId = #{blockId}</if>-->
+<!--            <if test="devBid != null and devBid != ''">-->
+<!--                and IotDevice.devBid = #{devBid}-->
+<!--            </if>-->
+<!--        </where>-->
+
+<!--        group by blockId-->
+<!--    </select>-->
+<!--    <select id="selectFmsBlockNum" resultType="java.lang.Integer">-->
+<!--        select count(1) from FmsBlock-->
+<!--        <where>-->
+<!--            <if test="landId != null and landId != ''">-->
+<!--                landId = #{landId}-->
+<!--            </if>-->
+<!--        </where>-->
+<!--    </select>-->
+<!--    <select id="selectFmsBlockPlans" resultType="java.util.Map">-->
+<!--        select count(1) as plantNum,sum(planArea) as planAreaNum from FmsPlan where planStatus = '1'-->
+<!--        <where>-->
+<!--            <if test="landId != null and landId != ''">-->
+<!--                and landId = #{landId}-->
+<!--            </if>-->
+<!--        </where>-->
+<!--    </select>-->
+<!--    <select id="selectFmsBlockList"-->
+<!--            resultType="com.yunfeiyun.agmp.iot.common.domain.FmsBlock">-->
+<!--        select  * from FmsBlock where 1=1-->
+<!--        <if test="blockName != null  and blockName != ''">-->
+<!--            and FmsBlock.blockName like concat('%', #{blockName}, '%')-->
+<!--        </if>-->
+<!--        order  by  blockSeq-->
+<!--    </select>-->
+<!--    <select id="selectFmsBlockListByLandId" resultType="com.yunfeiyun.agmp.iotm.device.domain.resvo.FmsBlockIrrigateResVo">-->
+<!--        SELECT-->
+<!--        fpp.resUrl as cropPreview,-->
+<!--        fb.*-->
+<!--        FROM-->
+<!--        FmsBlock fb-->
+<!--        LEFT JOIN (-->
+<!--        SELECT-->
+<!--        fp.blockId,-->
+<!--        sr.resUrl-->
+<!--        FROM-->
+<!--        FmsPlan fp-->
+<!--        LEFT JOIN FmsCrop fc ON fp.cropId = fc.cropId-->
+<!--        LEFT JOIN SysRes sr ON sr.resBusId = fc.cropId-->
+<!--        ) fpp ON fpp.blockId = fb.blockId-->
+<!--        <where>-->
+<!--            <if test="landId != null and landId != ''">-->
+<!--            and fb.landId = #{landId}-->
+<!--            </if>-->
+<!--        </where>-->
+<!--        GROUP BY-->
+<!--        fb.blockId-->
+<!--    </select>-->
+</mapper>