吉安感知网项目-后端
rain
2026-01-13 2ba9230d91a80e81d8fa594b82bf886a4ed902f1
防区优化
2 files modified
62 ■■■■■ changed files
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseZoneMapper.xml 38 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java 24 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseZoneMapper.xml
@@ -30,7 +30,11 @@
        defense_scene_ids,
        area_divide_ids,
        device_ids,
        concat(ST_AsText(geom), ' | ', ST_SRID(geom)) as geom,
        case
            when geom is null then null
            when ST_SRID(geom) is null or ST_SRID(geom) = 0 then ST_AsText(geom)
            else concat(ST_AsText(ST_SwapXY(geom)), ' | ', ST_SRID(geom))
        end as geom,
        area_code,
        create_user,
        create_dept,
@@ -103,7 +107,11 @@
        defense_scene_ids,
        area_divide_ids,
        device_ids,
        concat(ST_AsText(geom), ' | ', ST_SRID(geom)) as geom,
        case
            when geom is null then null
            when ST_SRID(geom) is null or ST_SRID(geom) = 0 then ST_AsText(geom)
            else concat(ST_AsText(ST_SwapXY(geom)), ' | ', ST_SRID(geom))
        end as geom,
        area_code,
        create_user,
        create_dept,
@@ -164,12 +172,13 @@
            #{deviceIds},
            <choose>
                <when test="geom != null and geom != ''">
                    ST_SRID(
                        ST_GeomFromText(
                            trim(case when instr(#{geom}, '|') &gt; 0 then substring_index(#{geom}, '|', 1) else #{geom} end)
                        ),
                        case when instr(#{geom}, '|') &gt; 0 then cast(trim(substring_index(#{geom}, '|', -1)) as unsigned) else 4326 end
                    )
                    case
                        when instr(#{geom}, '|') &gt; 0 then ST_GeomFromText(
                            trim(substring_index(#{geom}, '|', 1)),
                            cast(trim(substring_index(#{geom}, '|', -1)) as unsigned)
                        )
                        else ST_GeomFromText(trim(#{geom}))
                    end
                </when>
                <otherwise>null</otherwise>
            </choose>,
@@ -193,12 +202,13 @@
            <if test="areaDivideIds != null">area_divide_ids = #{areaDivideIds},</if>
            <if test="deviceIds != null">device_ids = #{deviceIds},</if>
            <if test="geom != null and geom != ''">
                geom = ST_SRID(
                    ST_GeomFromText(
                        trim(case when instr(#{geom}, '|') &gt; 0 then substring_index(#{geom}, '|', 1) else #{geom} end)
                    ),
                    case when instr(#{geom}, '|') &gt; 0 then cast(trim(substring_index(#{geom}, '|', -1)) as unsigned) else 4326 end
                ),
                geom = case
                    when instr(#{geom}, '|') &gt; 0 then ST_GeomFromText(
                        trim(substring_index(#{geom}, '|', 1)),
                        cast(trim(substring_index(#{geom}, '|', -1)) as unsigned)
                    )
                    else ST_GeomFromText(trim(#{geom}))
                end,
            </if>
            <if test="areaCode != null">area_code = #{areaCode},</if>
            <if test="createUser != null">create_user = #{createUser},</if>
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwDefenseZoneServiceImpl.java
@@ -32,8 +32,6 @@
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;
@@ -96,11 +94,9 @@
                record.setSceneCount(0);
                record.setDeviceCount(0);
                record.setAreaCount(0);
                record.setZoneArea(BigDecimal.ZERO);
            }
            return;
        }
        Map<Long, BigDecimal> areaSizeMap = new HashMap<>();
        Map<Long, List<Long>> areaDeviceMap = new HashMap<>();
        if (!areaIdSet.isEmpty()) {
            List<FwAreaDivideEntity> areaList = fwAreaDivideService.listByIds(areaIdSet);
@@ -108,7 +104,6 @@
                if (area == null || area.getId() == null) {
                    continue;
                }
                areaSizeMap.put(area.getId(), area.getAreaSize());
                areaDeviceMap.put(area.getId(), parseIdList(area.getDeviceIds()));
            }
        }
@@ -134,7 +129,6 @@
            }
            record.setAreaCount(areaIds.size());
            record.setDeviceCount(deviceIds.size());
            record.setZoneArea(sumAreaSize(areaIds, areaSizeMap));
        }
    }
@@ -159,24 +153,6 @@
        }
        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);
    }
    @Override
    public List<FwDefenseZoneExcel> exportFwDefenseZone(Wrapper<FwDefenseZoneEntity> queryWrapper) {