吉安感知网项目-后端
rain
2026-01-09 209afc32f9e3fd1932dc77457905f52518745bfc
防区、场景详情页面增加返回参数
11 files modified
393 ■■■■■ changed files
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/controller/FwDefenseZoneController.java 10 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/dto/FwDefenseZoneDTO.java 36 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml 4 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseSceneMapper.xml 2 ●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseZoneMapper.java 11 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseZoneMapper.xml 28 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/IFwDefenseZoneService.java 11 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseSceneServiceImpl.java 122 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java 149 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/vo/FwDefenseSceneVO.java 10 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/vo/FwDefenseZoneVO.java 10 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/controller/FwDefenseZoneController.java
@@ -37,7 +37,6 @@
import org.sxkj.fw.area.entity.FwDefenseZoneEntity;
import org.sxkj.fw.area.vo.FwDefenseZoneVO;
import org.sxkj.fw.area.excel.FwDefenseZoneExcel;
import org.sxkj.fw.area.wrapper.FwDefenseZoneWrapper;
import org.sxkj.fw.area.service.IFwDefenseZoneService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.utils.DateUtil;
@@ -73,8 +72,11 @@
        if (id == null) {
            return R.fail("主键不能为空");
        }
        FwDefenseZoneEntity detail = fwDefenseZoneService.getById(id);
        return R.data(FwDefenseZoneWrapper.build().entityVO(detail));
        FwDefenseZoneVO detail = fwDefenseZoneService.selectFwDefenseZoneDetail(id);
        if (detail == null) {
            return R.fail("数据不存在");
        }
        return R.data(detail);
    }
//    /**
//     * 防区管理表 分页
@@ -93,7 +95,7 @@
    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入fwDefenseZone")
    public R<IPage<FwDefenseZoneVO>> page(FwDefenseZoneVO fwDefenseZone, Query query) {
    public R<IPage<FwDefenseZoneVO>> page(FwDefenseZoneDTO fwDefenseZone, Query query) {
        IPage<FwDefenseZoneVO> pages = fwDefenseZoneService.selectFwDefenseZonePage(Condition.getPage(query), fwDefenseZone);
        return R.data(pages);
    }
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/dto/FwDefenseZoneDTO.java
@@ -21,6 +21,7 @@
import org.sxkj.fw.area.entity.FwDefenseZoneEntity;
import java.math.BigDecimal;
import java.util.Date;
/**
 * 防区管理表 数据传输对象实体类
@@ -69,4 +70,39 @@
     */
    @ApiModelProperty(value = "区域编码")
    private String areaCode;
    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    private Long createUser;
    /**
     * 创建部门
     */
    @ApiModelProperty(value = "创建部门")
    private Long createDept;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人")
    private Long updateUser;
    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
    /**
     * 状态(0正常 1停用)
     */
    @ApiModelProperty(value = "状态(0正常 1停用)")
    private Integer status;
    /**
     * 删除标志(0存在 1删除)
     */
    @ApiModelProperty(value = "删除标志(0存在 1删除)")
    private Integer isDeleted;
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
@@ -242,8 +242,8 @@
            #{createTime},
            #{updateUser},
            #{updateTime},
            #{status},
            #{isDeleted}
            IFNULL(#{status}, '0'),
            IFNULL(#{isDeleted}, 0)
        )
    </insert>
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseSceneMapper.xml
@@ -3,7 +3,7 @@
<mapper namespace="org.sxkj.fw.area.mapper.FwDefenseSceneMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="fwDefenseSceneResultMap" type="org.sxkj.fw.area.entity.FwDefenseSceneEntity">
    <resultMap id="fwDefenseSceneResultMap" type="org.sxkj.fw.area.vo.FwDefenseSceneVO">
        <result column="id" property="id"/>
        <result column="scene_name" property="sceneName"/>
        <result column="scene_type" property="sceneType"/>
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseZoneMapper.java
@@ -17,6 +17,7 @@
package org.sxkj.fw.area.mapper;
import org.sxkj.fw.area.entity.FwDefenseZoneEntity;
import org.sxkj.fw.area.dto.FwDefenseZoneDTO;
import org.sxkj.fw.area.vo.FwDefenseZoneVO;
import org.sxkj.fw.area.excel.FwDefenseZoneExcel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -40,7 +41,15 @@
     * @param fwDefenseZone
     * @return
     */
    List<FwDefenseZoneVO> selectFwDefenseZonePage(IPage page, FwDefenseZoneVO fwDefenseZone);
    List<FwDefenseZoneVO> selectFwDefenseZonePage(IPage page, FwDefenseZoneDTO fwDefenseZone);
    /**
     * 详情
     *
     * @param id
     * @return
     */
    FwDefenseZoneVO selectFwDefenseZoneDetail(@Param("id") Long id);
    /**
     * 新增(几何字段使用文本入库)
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseZoneMapper.xml
@@ -3,7 +3,7 @@
<mapper namespace="org.sxkj.fw.area.mapper.FwDefenseZoneMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="fwDefenseZoneResultMap" type="org.sxkj.fw.area.entity.FwDefenseZoneEntity">
    <resultMap id="fwDefenseZoneResultMap" type="org.sxkj.fw.area.vo.FwDefenseZoneVO">
        <result column="id" property="id"/>
        <result column="zone_name" property="zoneName"/>
        <result column="zone_area" property="zoneArea"/>
@@ -95,6 +95,28 @@
        </where>
    </select>
    <select id="selectFwDefenseZoneDetail" resultMap="fwDefenseZoneResultMap">
        select
        id,
        zone_name,
        zone_area,
        defense_scene_ids,
        area_divide_ids,
        device_ids,
        concat(ST_AsText(geom), ' | ', ST_SRID(geom)) as geom,
        area_code,
        create_user,
        create_dept,
        create_time,
        update_user,
        update_time,
        status,
        is_deleted
        from ja_fw_defense_zone
        where is_deleted = 0
          and id = #{id}
    </select>
    <select id="exportFwDefenseZone" resultType="org.sxkj.fw.area.excel.FwDefenseZoneExcel">
        SELECT
@@ -157,8 +179,8 @@
            #{createTime},
            #{updateUser},
            #{updateTime},
            #{status},
            #{isDeleted}
            IFNULL(#{status}, '0'),
            IFNULL(#{isDeleted}, 0)
        )
    </insert>
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/IFwDefenseZoneService.java
@@ -17,6 +17,7 @@
package org.sxkj.fw.area.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.sxkj.fw.area.dto.FwDefenseZoneDTO;
import org.sxkj.fw.area.entity.FwDefenseZoneEntity;
import org.sxkj.fw.area.vo.FwDefenseZoneVO;
import org.sxkj.fw.area.excel.FwDefenseZoneExcel;
@@ -38,7 +39,15 @@
     * @param fwDefenseZone
     * @return
     */
    IPage<FwDefenseZoneVO> selectFwDefenseZonePage(IPage<FwDefenseZoneVO> page, FwDefenseZoneVO fwDefenseZone);
    IPage<FwDefenseZoneVO> selectFwDefenseZonePage(IPage<FwDefenseZoneVO> page, FwDefenseZoneDTO fwDefenseZone);
    /**
     * 详情
     *
     * @param id
     * @return
     */
    FwDefenseZoneVO selectFwDefenseZoneDetail(Long id);
    /**
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseSceneServiceImpl.java
@@ -18,17 +18,31 @@
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.sxkj.common.utils.HeaderUtils;
import org.sxkj.fw.area.entity.FwAreaDivideEntity;
import org.sxkj.fw.area.entity.FwDefenseSceneEntity;
import org.sxkj.fw.area.vo.FwDefenseSceneVO;
import org.sxkj.fw.area.excel.FwDefenseSceneExcel;
import org.sxkj.fw.area.mapper.FwDefenseSceneMapper;
import org.sxkj.fw.area.service.IFwAreaDivideService;
import org.sxkj.fw.area.service.IFwDefenseSceneService;
import org.sxkj.fw.device.entity.FwDeviceEntity;
import org.sxkj.fw.device.service.IFwDeviceService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Date;
/**
@@ -40,9 +54,115 @@
@Service
public class FwDefenseSceneServiceImpl extends BaseServiceImpl<FwDefenseSceneMapper, FwDefenseSceneEntity> implements IFwDefenseSceneService {
    private static final BigDecimal AREA_SIZE_FACTOR = new BigDecimal("1000000");
    @Autowired
    private IFwAreaDivideService fwAreaDivideService;
    @Autowired
    private IFwDeviceService fwDeviceService;
    @Override
    public IPage<FwDefenseSceneVO> selectFwDefenseScenePage(IPage<FwDefenseSceneVO> page, FwDefenseSceneVO fwDefenseScene) {
        return page.setRecords(baseMapper.selectFwDefenseScenePage(page, fwDefenseScene));
        IPage<FwDefenseSceneVO> result = page.setRecords(baseMapper.selectFwDefenseScenePage(page, fwDefenseScene));
        List<FwDefenseSceneVO> records = result.getRecords();
        if (records == null || records.isEmpty()) {
            return result;
        }
        Set<Long> areaIdSet = new HashSet<>();
        Set<Long> deviceIdSet = new HashSet<>();
        for (FwDefenseSceneVO record : records) {
            areaIdSet.addAll(parseIdList(record.getAreaDivideIds()));
            deviceIdSet.addAll(parseIdList(record.getDeviceIds()));
        }
        Map<Long, BigDecimal> areaSizeMap = new HashMap<>();
        if (!areaIdSet.isEmpty()) {
            List<FwAreaDivideEntity> areaList = fwAreaDivideService.listByIds(areaIdSet);
            for (FwAreaDivideEntity area : areaList) {
                if (area == null || area.getId() == null) {
                    continue;
                }
                areaSizeMap.put(area.getId(), area.getAreaSize());
            }
        }
        Map<Long, String> deviceTypeMap = new HashMap<>();
        if (!deviceIdSet.isEmpty()) {
            List<FwDeviceEntity> deviceList = fwDeviceService.listByIds(deviceIdSet);
            for (FwDeviceEntity device : deviceList) {
                if (device == null || device.getId() == null) {
                    continue;
                }
                deviceTypeMap.put(device.getId(), device.getDeviceType());
            }
        }
        for (FwDefenseSceneVO record : records) {
            List<Long> areaIds = parseIdList(record.getAreaDivideIds());
            record.setAreaCount(areaIds.size());
            record.setDefenseArea(sumDefenseArea(areaIds, areaSizeMap));
            List<Long> deviceIds = parseIdList(record.getDeviceIds());
            int detectCount = 0;
            int counterCount = 0;
            for (Long deviceId : deviceIds) {
                String deviceType = deviceTypeMap.get(deviceId);
                if ("1".equals(deviceType)) {
                    detectCount++;
                    counterCount++;
                } else if ("2".equals(deviceType)) {
                    detectCount++;
                } else if ("3".equals(deviceType)) {
                    counterCount++;
                }
            }
            record.setDetectDeviceCount(detectCount);
            record.setCounterDeviceCount(counterCount);
        }
        return result;
    }
    private List<Long> parseIdList(String ids) {
        if (StringUtil.isBlank(ids)) {
            return Collections.emptyList();
        }
        String[] idArray = ids.split(",");
        List<Long> idList = new ArrayList<>(idArray.length);
        for (String item : idArray) {
            if (item == null) {
                continue;
            }
            String value = item.trim();
            if (StringUtil.isBlank(value)) {
                continue;
            }
            try {
                idList.add(Long.valueOf(value));
            } catch (NumberFormatException ignored) {
            }
        }
        return idList;
    }
    private Integer sumDefenseArea(List<Long> areaIds, Map<Long, BigDecimal> areaSizeMap) {
        if (areaIds == null || areaIds.isEmpty()) {
            return 0;
        }
        BigDecimal total = BigDecimal.ZERO;
        for (Long areaId : areaIds) {
            BigDecimal areaSize = areaSizeMap.get(areaId);
            if (areaSize != null) {
                total = total.add(areaSize);
            }
        }
        if (BigDecimal.ZERO.compareTo(total) == 0) {
            return 0;
        }
        BigDecimal totalArea = total.multiply(AREA_SIZE_FACTOR);
        return totalArea.setScale(0, RoundingMode.HALF_UP).intValue();
    }
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java
@@ -19,16 +19,30 @@
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.sxkj.common.utils.HeaderUtils;
import org.sxkj.fw.area.dto.FwDefenseZoneDTO;
import org.sxkj.fw.area.entity.FwAreaDivideEntity;
import org.sxkj.fw.area.entity.FwDefenseSceneEntity;
import org.sxkj.fw.area.entity.FwDefenseZoneEntity;
import org.sxkj.fw.area.vo.FwDefenseZoneVO;
import org.sxkj.fw.area.excel.FwDefenseZoneExcel;
import org.sxkj.fw.area.mapper.FwDefenseZoneMapper;
import org.sxkj.fw.area.service.IFwAreaDivideService;
import org.sxkj.fw.area.service.IFwDefenseSceneService;
import org.sxkj.fw.area.service.IFwDefenseZoneService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Date;
/**
@@ -40,9 +54,140 @@
@Service
public class FwDefenseZoneServiceImpl extends BaseServiceImpl<FwDefenseZoneMapper, FwDefenseZoneEntity> implements IFwDefenseZoneService {
    @Resource
    private IFwDefenseSceneService fwDefenseSceneService;
    @Resource
    private IFwAreaDivideService fwAreaDivideService;
    @Override
    public IPage<FwDefenseZoneVO> selectFwDefenseZonePage(IPage<FwDefenseZoneVO> page, FwDefenseZoneVO fwDefenseZone) {
        return page.setRecords(baseMapper.selectFwDefenseZonePage(page, fwDefenseZone));
    public IPage<FwDefenseZoneVO> selectFwDefenseZonePage(IPage<FwDefenseZoneVO> page, FwDefenseZoneDTO fwDefenseZone) {
        IPage<FwDefenseZoneVO> result = page.setRecords(baseMapper.selectFwDefenseZonePage(page, fwDefenseZone));
        fillDefenseZoneStatistics(result.getRecords());
        return result;
    }
    @Override
    public FwDefenseZoneVO selectFwDefenseZoneDetail(Long id) {
        FwDefenseZoneVO detail = baseMapper.selectFwDefenseZoneDetail(id);
        if (detail != null) {
            fillDefenseZoneStatistics(Collections.singletonList(detail));
        }
        return detail;
    }
    private void fillDefenseZoneStatistics(List<FwDefenseZoneVO> records) {
        if (records == null || records.isEmpty()) {
            return;
        }
        Set<Long> sceneIdSet = new HashSet<>();
        Set<Long> areaIdSet = new HashSet<>();
        Map<Long, List<Long>> zoneSceneMap = new HashMap<>();
        Map<Long, List<Long>> zoneAreaMap = new HashMap<>();
        for (FwDefenseZoneVO record : records) {
            List<Long> sceneIds = parseIdList(record.getDefenseSceneIds());
            if (record.getId() != null) {
                zoneSceneMap.put(record.getId(), sceneIds);
            }
            sceneIdSet.addAll(sceneIds);
            List<Long> areaIds = parseIdList(record.getAreaDivideIds());
            if (record.getId() != null) {
                zoneAreaMap.put(record.getId(), areaIds);
            }
            areaIdSet.addAll(areaIds);
        }
        if (sceneIdSet.isEmpty() && areaIdSet.isEmpty()) {
            for (FwDefenseZoneVO record : records) {
                record.setSceneCount(0);
                record.setDeviceCount(0);
                record.setAreaCount(0);
                record.setZoneArea(BigDecimal.ZERO);
            }
            return;
        }
        Map<Long, List<Long>> sceneDeviceMap = new HashMap<>();
        if (!sceneIdSet.isEmpty()) {
            List<FwDefenseSceneEntity> sceneList = fwDefenseSceneService.listByIds(sceneIdSet);
            for (FwDefenseSceneEntity scene : sceneList) {
                if (scene == null || scene.getId() == null) {
                    continue;
                }
                sceneDeviceMap.put(scene.getId(), parseIdList(scene.getDeviceIds()));
            }
        }
        Map<Long, BigDecimal> areaSizeMap = new HashMap<>();
        if (!areaIdSet.isEmpty()) {
            List<FwAreaDivideEntity> areaList = fwAreaDivideService.listByIds(areaIdSet);
            for (FwAreaDivideEntity area : areaList) {
                if (area == null || area.getId() == null) {
                    continue;
                }
                areaSizeMap.put(area.getId(), area.getAreaSize());
            }
        }
        for (FwDefenseZoneVO record : records) {
            List<Long> sceneIds = zoneSceneMap.get(record.getId());
            if (sceneIds == null) {
                sceneIds = Collections.emptyList();
            }
            Set<Long> uniqueSceneIds = new HashSet<>(sceneIds);
            record.setSceneCount(uniqueSceneIds.size());
            List<Long> zoneAreaIds = zoneAreaMap.get(record.getId());
            if (zoneAreaIds == null) {
                zoneAreaIds = Collections.emptyList();
            }
            Set<Long> areaIds = new HashSet<>(zoneAreaIds);
            Set<Long> deviceIds = new HashSet<>();
            for (Long sceneId : uniqueSceneIds) {
                List<Long> sceneDeviceIds = sceneDeviceMap.get(sceneId);
                if (sceneDeviceIds != null) {
                    deviceIds.addAll(sceneDeviceIds);
                }
            }
            record.setAreaCount(areaIds.size());
            record.setDeviceCount(deviceIds.size());
            record.setZoneArea(sumAreaSize(areaIds, areaSizeMap));
        }
    }
    private List<Long> parseIdList(String ids) {
        if (StringUtil.isBlank(ids)) {
            return Collections.emptyList();
        }
        String[] idArray = ids.split(",");
        List<Long> idList = new ArrayList<>(idArray.length);
        for (String item : idArray) {
            if (item == null) {
                continue;
            }
            String value = item.trim();
            if (StringUtil.isBlank(value)) {
                continue;
            }
            try {
                idList.add(Long.valueOf(value));
            } catch (NumberFormatException ignored) {
            }
        }
        return idList;
    }
    private BigDecimal sumAreaSize(Set<Long> areaIds, Map<Long, BigDecimal> areaSizeMap) {
        if (areaIds == null || areaIds.isEmpty()) {
            return BigDecimal.ZERO;
        }
        BigDecimal total = BigDecimal.ZERO;
        for (Long areaId : areaIds) {
            BigDecimal areaSize = areaSizeMap.get(areaId);
            if (areaSize != null) {
                total = total.add(areaSize);
            }
        }
        if (BigDecimal.ZERO.compareTo(total) == 0) {
            return BigDecimal.ZERO;
        }
        return total.setScale(2, RoundingMode.HALF_UP);
    }
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/vo/FwDefenseSceneVO.java
@@ -16,6 +16,7 @@
 */
package org.sxkj.fw.area.vo;
import io.swagger.annotations.ApiModelProperty;
import org.sxkj.fw.area.entity.FwDefenseSceneEntity;
import org.springblade.core.tool.node.INode;
import lombok.Data;
@@ -32,4 +33,13 @@
public class FwDefenseSceneVO extends FwDefenseSceneEntity {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "区域数量")
    private Integer areaCount;
    @ApiModelProperty(value = "探测设备数量")
    private Integer detectDeviceCount;
    @ApiModelProperty(value = "反制设备数量")
    private Integer counterDeviceCount;
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/vo/FwDefenseZoneVO.java
@@ -16,6 +16,7 @@
 */
package org.sxkj.fw.area.vo;
import io.swagger.annotations.ApiModelProperty;
import org.sxkj.fw.area.entity.FwDefenseZoneEntity;
import org.springblade.core.tool.node.INode;
import lombok.Data;
@@ -32,4 +33,13 @@
public class FwDefenseZoneVO extends FwDefenseZoneEntity {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "场景数量")
    private Integer sceneCount;
    @ApiModelProperty(value = "设备数量")
    private Integer deviceCount;
    @ApiModelProperty(value = "区域数量")
    private Integer areaCount;
}