Bladeren bron

实现供地数据报表统计功能

chenendian 1 maand geleden
bovenliggende
commit
7f2e31f8b2

+ 31 - 49
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/cadastre/SupplyController.java

@@ -1,6 +1,8 @@
 package com.siwei.apply.controller.cadastre;
 
+import com.siwei.apply.domain.cadastre.LandSupplyReportDTO;
 import com.siwei.apply.domain.res.*;
+import com.siwei.apply.service.cadastre.ISupplyService;
 import com.siwei.apply.service.cadastre.IZymlService;
 import com.siwei.common.core.domain.R;
 import com.siwei.common.core.web.controller.BaseController;
@@ -29,6 +31,16 @@ public class SupplyController extends BaseController {
     private final LinkedHashMap<String, OGRVectorTiler> m_TilerMap = new LinkedHashMap<String, OGRVectorTiler>();
 
 
+
+    @Autowired
+    private ISupplyService supplyService;
+
+
+
+
+
+
+
     /**
      *
      * 年度统计
@@ -244,59 +256,29 @@ public class SupplyController extends BaseController {
 
 
 
-
-
-    /**
-     * 获取资源目录列表
-     *
-     * @param param 预留
-     * @return
-     *//*
-     *
-     * @GetMapping("/GetList")
-     * public R GetList(String param) {
-     * R list = zymlService.GetList(param);
-     * return list;
-     * }
-     *
-     */
     /**
-     * 获取资源目录列表
-     *
-     * @param param 预留
-     * @return
-     *//*
      *
-     * @GetMapping("/GetTree")
-     * public R GetTree(String param) {
-     * R list = zymlService.GetTree(param);
-     * return list;
-     * }
+     * 根据时间范围查询土地供应统计报表数据
+     * 土地供应统计报表
      *
      */
+    @GetMapping("/report/progress")
+    public R<LandSupplyReportDTO> getTdgyReport(@RequestParam String startTime, @RequestParam String endTime) {
+        try {
+            //todo 调用相关方法,获取数据,封装成LandSupplyReportDTO对象
+            LandSupplyReportDTO res =  supplyService.getTdgyReport(startTime,endTime);
+            return R.ok(res);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+
+
+
+
+
+
 
-    // /**
-    // * 根据标识码获取资源详情
-    // *
-    // * @param bsm
-    // * @return
-    // */
-    // @RequestMapping("/GetByBsm")
-    // public R GetByBsm(String bsm) {
-    // R list = zymlService.GetByBsm(bsm);
-    // return list;
-    // }
-    //
-    // /**
-    // * 获取我收藏的资源列表
-    // *
-    // * @param param 预留
-    // * @return
-    // */
-    // @GetMapping("/GetMyCollect")
-    // public R GetMyCollect(String param) {
-    // R list = zymlService.GetMyCollect(param);
-    // return list;
-    // }
 
 }

+ 32 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/GongdiJihua.java

@@ -0,0 +1,32 @@
+package com.siwei.apply.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class GongdiJihua {
+
+    private Integer gid;
+
+    private Integer fid;
+
+    private BigDecimal mjPfm;
+
+    private BigDecimal mjMu;
+
+    private String xmmc;
+
+    private String tdyt;
+
+    private String gyfs;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date gysj;
+
+    private String bz;
+
+    private String geom;
+}

+ 53 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/cadastre/LandSupplyReportDTO.java

@@ -0,0 +1,53 @@
+package com.siwei.apply.domain.cadastre;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class LandSupplyReportDTO {
+    private String title;
+    private String statTimeRange;
+    private SummaryDTO summary;
+    private List<DetailDTO> details;
+
+    @Data
+    public static class SummaryDTO {
+        private TotalDTO total;
+    }
+
+    @Data
+    public static class TotalDTO {
+        private String supplyRate;
+        private PlanDTO plan;
+        private CompletedDTO completed;
+    }
+
+    @Data
+    public static class DetailDTO {
+        private String category;
+        private String supplyRate;
+        private PlanDTO plan;
+        private CompletedDTO completed;
+    }
+
+    @Data
+    public static class PlanDTO {
+        private Double area;
+        private Integer count;
+        /** 供地方式(出让)的数据 */
+        private Double transfer;
+        /** 供地方式(划拨)数据 */
+        private Double allocation;
+        private Double other;
+    }
+
+    @Data
+    public static class CompletedDTO {
+        private Double area;
+        private Integer count;
+        private Double transfer;
+        private Double allocation;
+        private Double other;
+    }
+}

+ 40 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/cadastre/LandUseReportDTO.java

@@ -0,0 +1,40 @@
+package com.siwei.apply.domain.cadastre;
+
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class LandUseReportDTO {
+    private String title;
+    private String statTimeRange;
+    private List<Integer> years;
+    private SummaryDTO summary;
+    private List<DetailDTO> details;
+
+    @Data
+    public static class SummaryDTO {
+        private YearDataDTO total;
+        private YearDataDTO transfer;
+    }
+
+    @Data
+    public static class DetailDTO {
+        private String category;
+        private StatDTO total;
+        private Map<String, StatDTO> byYear;
+    }
+
+    @Data
+    public static class YearDataDTO {
+        private StatDTO total;
+        private Map<String, StatDTO> byYear;
+    }
+
+    @Data
+    public static class StatDTO {
+        private Double area;
+        private Integer count;
+    }
+}

+ 25 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/GongdiJihuaFilterVo.java

@@ -0,0 +1,25 @@
+package com.siwei.apply.domain.vo;
+
+import lombok.Data;
+
+@Data
+public class GongdiJihuaFilterVo {
+
+    private String xmmc;
+
+    private String tdyt;
+
+    private String gyfs;
+
+    private String startDate;
+
+    private String endDate;
+
+    private Integer pageNum = 1;
+
+    private Integer pageSize = 10;
+
+    public Integer getOffset() {
+        return (pageNum - 1) * pageSize;
+    }
+}

+ 2 - 4
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/enums/DecisionType.java

@@ -78,10 +78,8 @@ public enum DecisionType {
     /**
      * 通过 code 获取对应的表名
      *
-     *
-     *
-     *
-     *
+     * @param code 决策类型编码(如"4"、"5"、"6"、"7"等)
+     * @return 对应的表名,如果未找到则返回空字符串
      */
     public static String getTableNameByCode(String code) {
         DecisionType type = getByCode(code);

+ 33 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/GongdiJihuaMapper.java

@@ -0,0 +1,33 @@
+package com.siwei.apply.mapper;
+
+import com.siwei.apply.domain.GongdiJihua;
+import com.siwei.apply.domain.vo.GongdiJihuaFilterVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface GongdiJihuaMapper {
+
+    void add(GongdiJihua gongdiJihua);
+
+    GongdiJihua get(@Param("gid") Integer gid);
+
+    List<GongdiJihua> getList(GongdiJihuaFilterVo filterVo);
+
+    Integer getCount(GongdiJihuaFilterVo filterVo);
+
+    void update(GongdiJihua gongdiJihua);
+
+    void batchDelete(@Param("gids") List<Integer> gids);
+
+    List<GongdiJihua> getByGeomIntersects(@Param("ewkt") String ewkt);
+
+    Map<String, Object> getPlanSummaryByTimeRange(@Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    List<Map<String, Object>> getPlanStatsByLandType(@Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    List<Map<String, Object>> getPlanStatsBySupplyMode(@Param("startTime") String startTime, @Param("endTime") String endTime);
+}

+ 15 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/ISupplyService.java

@@ -0,0 +1,15 @@
+package com.siwei.apply.service.cadastre;
+
+
+import com.siwei.apply.domain.cadastre.LandSupplyReportDTO;
+import com.siwei.common.core.domain.R;
+
+
+public interface ISupplyService {
+    Object GetList(String param);
+
+    LandSupplyReportDTO getTdgyReport(String startTime,String endTime); //  supplyService.getTdgyReport(startTime,endTime);
+
+
+
+}

+ 115 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/SupplyServiceImpl.java

@@ -0,0 +1,115 @@
+package com.siwei.apply.service.cadastre.impl;
+
+import com.siwei.apply.domain.cadastre.*;
+import com.siwei.apply.mapper.GongdiJihuaMapper;
+import com.siwei.apply.service.cadastre.ISupplyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+
+@Service
+public class SupplyServiceImpl implements ISupplyService {
+
+    @Autowired
+    private GongdiJihuaMapper gongdiJihuaMapper;
+
+    @Override
+    public Object GetList(String param) {
+        return null;
+    }
+
+    @Override
+    public LandSupplyReportDTO getTdgyReport(String startTime, String endTime) {
+        LandSupplyReportDTO report = new LandSupplyReportDTO();
+        report.setTitle("土地供应统计报表");
+        report.setStatTimeRange(startTime + " 至 " + endTime);
+
+        Map<String, Object> planSummary = gongdiJihuaMapper.getPlanSummaryByTimeRange(startTime, endTime);
+        List<Map<String, Object>> planStatsByLandType = gongdiJihuaMapper.getPlanStatsByLandType(startTime, endTime);
+        List<Map<String, Object>> planStatsBySupplyMode = gongdiJihuaMapper.getPlanStatsBySupplyMode(startTime, endTime);
+
+        LandSupplyReportDTO.SummaryDTO summary = new LandSupplyReportDTO.SummaryDTO();
+        LandSupplyReportDTO.TotalDTO total = buildTotalDTO(planSummary);
+        summary.setTotal(total);
+        report.setSummary(summary);
+
+        List<LandSupplyReportDTO.DetailDTO> details = new ArrayList<>();
+        for (Map<String, Object> landTypeStat : planStatsByLandType) {
+            LandSupplyReportDTO.DetailDTO detail = new LandSupplyReportDTO.DetailDTO();
+            detail.setCategory(convertCategory((String) landTypeStat.get("category")));
+            detail.setSupplyRate("0%");
+            detail.setPlan(buildPlanDTO(landTypeStat));
+            detail.setCompleted(new LandSupplyReportDTO.CompletedDTO());
+            details.add(detail);
+        }
+        report.setDetails(details);
+
+        return report;
+    }
+
+    private LandSupplyReportDTO.TotalDTO buildTotalDTO(Map<String, Object> summary) {
+        LandSupplyReportDTO.TotalDTO total = new LandSupplyReportDTO.TotalDTO();
+        total.setSupplyRate("0%");
+
+        LandSupplyReportDTO.PlanDTO plan = new LandSupplyReportDTO.PlanDTO();
+        plan.setArea(toDouble(summary.get("planmu")));
+        plan.setCount(toInteger(summary.get("plancount")));
+        plan.setTransfer(toDouble(summary.get("plantransfer")));
+        plan.setAllocation(toDouble(summary.get("planallocation")));
+        plan.setOther(toDouble(summary.get("planother")));
+        total.setPlan(plan);
+
+        LandSupplyReportDTO.CompletedDTO completed = new LandSupplyReportDTO.CompletedDTO();
+        completed.setArea(0.0);
+        completed.setCount(0);
+        completed.setTransfer(0.0);
+        completed.setAllocation(0.0);
+        completed.setOther(0.0);
+        total.setCompleted(completed);
+
+        return total;
+    }
+
+    private LandSupplyReportDTO.PlanDTO buildPlanDTO(Map<String, Object> stat) {
+        LandSupplyReportDTO.PlanDTO plan = new LandSupplyReportDTO.PlanDTO();
+        plan.setArea(toDouble(stat.get("planmu")));
+        plan.setCount(toInteger(stat.get("plancount")));
+        plan.setTransfer(toDouble(stat.get("plantransfer")));
+        plan.setAllocation(toDouble(stat.get("planallocation")));
+        plan.setOther(toDouble(stat.get("planother")));
+        return plan;
+    }
+
+    private String convertCategory(String category) {
+        if (category == null || category.equals("未知")) {
+            return "其他";
+        }
+        return category;
+    }
+
+    private Double toDouble(Object value) {
+        if (value == null) {
+            return 0.0;
+        }
+        if (value instanceof Number) {
+            return ((Number) value).doubleValue();
+        }
+        return 0.0;
+    }
+
+    private Integer toInteger(Object value) {
+        if (value == null) {
+            return 0;
+        }
+        if (value instanceof Number) {
+            return ((Number) value).intValue();
+        }
+        return 0;
+    }
+}

+ 172 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/GongdiJihuaMapper.xml

@@ -0,0 +1,172 @@
+<?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.siwei.apply.mapper.GongdiJihuaMapper">
+
+    <resultMap id="gongdiJihuaMap" type="com.siwei.apply.domain.GongdiJihua">
+        <id column="gid" property="gid"/>
+        <result column="fid" property="fid"/>
+        <result column="mj_pfm" property="mjPfm"/>
+        <result column="mj_mu" property="mjMu"/>
+        <result column="xmmc" property="xmmc"/>
+        <result column="tdyt" property="tdyt"/>
+        <result column="gyfs" property="gyfs"/>
+        <result column="gysj" property="gysj"/>
+        <result column="bz" property="bz"/>
+        <result column="geom" property="geom"/>
+    </resultMap>
+
+    <insert id="add" parameterType="com.siwei.apply.domain.GongdiJihua">
+        INSERT INTO vector.gj_gongdi_jihua (fid, mj_pfm, mj_mu, xmmc, tdyt, gyfs, gysj, bz, geom)
+        VALUES (#{fid}, #{mjPfm}, #{mjMu}, #{xmmc}, #{tdyt}, #{gyfs}, #{gysj}, #{bz}, ST_GeomFromEWKT(#{geom}))
+    </insert>
+
+    <select id="get" resultMap="gongdiJihuaMap">
+        SELECT gid, fid, mj_pfm, mj_mu, xmmc, tdyt, gyfs, gysj, bz, ST_AsEWKT(geom) as geom
+        FROM vector.gj_gongdi_jihua
+        WHERE gid = #{gid}
+    </select>
+
+    <select id="getList" parameterType="com.siwei.apply.domain.vo.GongdiJihuaFilterVo" resultMap="gongdiJihuaMap">
+        SELECT gid, fid, mj_pfm, mj_mu, xmmc, tdyt, gyfs, gysj, bz, ST_AsEWKT(geom) as geom
+        FROM vector.gj_gongdi_jihua
+        <where>
+            <if test="xmmc != null and xmmc != ''">
+                AND xmmc LIKE CONCAT('%', #{xmmc}, '%')
+            </if>
+            <if test="tdyt != null and tdyt != ''">
+                AND tdyt = #{tdyt}
+            </if>
+            <if test="gyfs != null and gyfs != ''">
+                AND gyfs = #{gyfs}
+            </if>
+            <if test="startDate != null and startDate != ''">
+                AND gysj &gt;= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != ''">
+                AND gysj &lt;= #{endDate}
+            </if>
+        </where>
+        ORDER BY gid DESC
+        LIMIT #{pageSize} OFFSET #{offset}
+    </select>
+
+    <select id="getCount" parameterType="com.siwei.apply.domain.vo.GongdiJihuaFilterVo" resultType="int">
+        SELECT COUNT(*)
+        FROM vector.gj_gongdi_jihua
+        <where>
+            <if test="xmmc != null and xmmc != ''">
+                AND xmmc LIKE CONCAT('%', #{xmmc}, '%')
+            </if>
+            <if test="tdyt != null and tdyt != ''">
+                AND tdyt = #{tdyt}
+            </if>
+            <if test="gyfs != null and gyfs != ''">
+                AND gyfs = #{gyfs}
+            </if>
+            <if test="startDate != null and startDate != ''">
+                AND gysj &gt;= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != ''">
+                AND gysj &lt;= #{endDate}
+            </if>
+        </where>
+    </select>
+
+    <update id="update" parameterType="com.siwei.apply.domain.GongdiJihua">
+        UPDATE vector.gj_gongdi_jihua
+        <set>
+            <if test="fid != null">fid = #{fid},</if>
+            <if test="mjPfm != null">mj_pfm = #{mjPfm},</if>
+            <if test="mjMu != null">mj_mu = #{mjMu},</if>
+            <if test="xmmc != null">xmmc = #{xmmc},</if>
+            <if test="tdyt != null">tdyt = #{tdyt},</if>
+            <if test="gyfs != null">gyfs = #{gyfs},</if>
+            <if test="gysj != null">gysj = #{gysj},</if>
+            <if test="bz != null">bz = #{bz},</if>
+            <if test="geom != null">geom = ST_GeomFromEWKT(#{geom}),</if>
+        </set>
+        WHERE gid = #{gid}
+    </update>
+
+    <delete id="batchDelete">
+        DELETE FROM vector.gj_gongdi_jihua
+        WHERE gid IN
+        <foreach collection="gids" item="gid" open="(" separator="," close=")">
+            #{gid}
+        </foreach>
+    </delete>
+
+    <select id="getByGeomIntersects" resultMap="gongdiJihuaMap">
+        SELECT gid, fid, mj_pfm, mj_mu, xmmc, tdyt, gyfs, gysj, bz, ST_AsEWKT(geom) as geom
+        FROM vector.gj_gongdi_jihua
+        WHERE public.ST_Intersects(geom, public.ST_GeomFromEWKT(#{ewkt}))
+    </select>
+
+    <select id="getPlanSummaryByTimeRange" resultType="map">
+        SELECT
+            COALESCE(SUM(mj_pfm), 0) AS planarea,
+            COALESCE(SUM(mj_mu), 0) AS planmu,
+            COUNT(*) AS plancount,
+            COALESCE(SUM(CASE WHEN gyfs = '出让' THEN 1 ELSE 0 END), 0) AS plantransfer,
+            COALESCE(SUM(CASE WHEN gyfs = '划拨' THEN 1 ELSE 0 END), 0) AS planallocation,
+            COALESCE(SUM(CASE WHEN gyfs IS NULL OR gyfs NOT IN ('出让', '划拨') THEN 1 ELSE 0 END), 0) AS planother
+        FROM vector.gj_gongdi_jihua
+        <where>
+            <if test="startTime != null and startTime != ''">
+                AND gysj &gt;= #{startTime}::date
+            </if>
+            <if test="endTime != null and endTime != ''">
+                AND gysj &lt;= #{endTime}::date
+            </if>
+        </where>
+    </select>
+
+    <select id="getPlanStatsByLandType" resultType="map">
+        SELECT
+            COALESCE(tdyt, '未知') AS category,
+            COALESCE(SUM(mj_pfm), 0) AS planarea,
+            COALESCE(SUM(mj_mu), 0) AS planmu,
+            COUNT(*) AS plancount,
+            COALESCE(SUM(CASE WHEN gyfs = '出让' THEN 1 ELSE 0 END), 0) AS plantransfer,
+            COALESCE(SUM(CASE WHEN gyfs = '划拨' THEN 1 ELSE 0 END), 0) AS planallocation,
+            COALESCE(SUM(CASE WHEN gyfs IS NULL OR gyfs NOT IN ('出让', '划拨') THEN 1 ELSE 0 END), 0) AS planother,
+            '0%' AS supplyrate
+        FROM vector.gj_gongdi_jihua
+        <where>
+            <if test="startTime != null and startTime != ''">
+                AND gysj &gt;= #{startTime}::date
+            </if>
+            <if test="endTime != null and endTime != ''">
+                AND gysj &lt;= #{endTime}::date
+            </if>
+        </where>
+        GROUP BY tdyt
+        ORDER BY planarea DESC
+    </select>
+
+    <select id="getPlanStatsBySupplyMode" resultType="map">
+        SELECT
+            COALESCE(gyfs, '未知') AS category,
+            COALESCE(SUM(mj_pfm), 0) AS planarea,
+            COALESCE(SUM(mj_mu), 0) AS planmu,
+            COUNT(*) AS plancount,
+            COALESCE(SUM(CASE WHEN gyfs = '出让' THEN 1 ELSE 0 END), 0) AS plantransfer,
+            COALESCE(SUM(CASE WHEN gyfs = '划拨' THEN 1 ELSE 0 END), 0) AS planallocation,
+            COALESCE(SUM(CASE WHEN gyfs IS NULL OR gyfs NOT IN ('出让', '划拨') THEN 1 ELSE 0 END), 0) AS planother,
+            '0%' AS supplyrate
+        FROM vector.gj_gongdi_jihua
+        <where>
+            <if test="startTime != null and startTime != ''">
+                AND gysj &gt;= #{startTime}::date
+            </if>
+            <if test="endTime != null and endTime != ''">
+                AND gysj &lt;= #{endTime}::date
+            </if>
+        </where>
+        GROUP BY gyfs
+        ORDER BY planarea DESC
+    </select>
+
+</mapper>