Bladeren bron

lsyd导入zip

liutao 1 week geleden
bovenliggende
commit
890dfed23b

+ 35 - 23
YHYZT/server/src/main/java/com/zjugis/yzt/controller/PewgController.java

@@ -11,6 +11,8 @@ import com.zjugis.yzt.beans.entity.Pewg;
 import org.springframework.beans.BeanUtils;
 
 import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
 
 
 @RestController
@@ -27,37 +29,47 @@ public class PewgController extends BaseRestController {
     public IPage<PewgVO> getPewgListWithArea(
             @RequestParam(defaultValue = "1") Integer current,
             @RequestParam(defaultValue = "10") Integer size,
-            @RequestParam(required = false) String dkMc,      // 项目名称
-            @RequestParam(required = false) String xzqmc,      // 乡镇街道
-            @RequestParam(required = false) String pcbh,      // 批次名称
-            @RequestParam(required = false) String lx,        // 类型
-            @RequestParam(required = false) String ghyt,        // 规划用途
-            @RequestParam(required = false) String wgyy      // 未供原因
+            @RequestParam(required = false) String pch,        // 批次名称
+            @RequestParam(required = false) String dkMc,       // 项目名称
+            @RequestParam(required = false) Double minArea,    // 剩余面积最小值(平方米)
+            @RequestParam(required = false) Double maxArea,    // 剩余面积最大值(平方米)
+            @RequestParam(required = false) String xzz,        // 乡镇街道
+            @RequestParam(required = false) String dkYt,       // 土地用途
+            @RequestParam(required = false) String lx,         // 类型
+            @RequestParam(required = false) String wgyy        // 未供原因
     ) {
 
-        QueryWrapper<Pewg> queryWrapper = new QueryWrapper<>();
-
-        if (pcbh != null && !pcbh.isEmpty()) {
-            queryWrapper.like("pcbh", pcbh);
+        Page<Pewg> page = new Page<>(current, size);
+        
+        // 构建查询参数
+        Map<String, Object> params = new HashMap<>();
+        if (pch != null && !pch.isEmpty()) {
+            params.put("pch", pch);
         }
-        if (lx != null && !lx.isEmpty()) {
-            queryWrapper.like("fwlx", lx);
+        if (dkMc != null && !dkMc.isEmpty()) {
+            params.put("dkMc", dkMc);
         }
-        if (wgyy != null && !wgyy.isEmpty()) {
-            queryWrapper.like("wgyy", wgyy);
+        if (minArea != null) {
+            params.put("minArea", minArea);
         }
-        if (dkMc != null && !dkMc.isEmpty()) {
-            queryWrapper.like("dk_mc", dkMc);
+        if (maxArea != null) {
+            params.put("maxArea", maxArea);
         }
-        if (xzqmc != null && !xzqmc.isEmpty()) {
-            queryWrapper.like("xzqmc", xzqmc);
+        if (xzz != null && !xzz.isEmpty()) {
+            params.put("xzz", xzz);
         }
-        if (ghyt != null && !ghyt.isEmpty()) {
-            queryWrapper.like("ghyt", ghyt);
+        if (dkYt != null && !dkYt.isEmpty()) {
+            params.put("dkYt", dkYt);
         }
-        Page<Pewg> page = new Page<>(current, size);
-        // 使用新的SQL查询方法,包含面积计算
-        IPage<Pewg> pewgPage = pewgService.pageWithArea(page, queryWrapper);
+        if (lx != null && !lx.isEmpty()) {
+            params.put("lx", lx);
+        }
+        if (wgyy != null && !wgyy.isEmpty()) {
+            params.put("wgyy", wgyy);
+        }
+        
+        // 使用自定义分页查询方法
+        IPage<Pewg> pewgPage = pewgService.pageWithAreaCustom(page, params);
 
         return pewgPage.convert(this::convertToVO);
     }

+ 11 - 46
YHYZT/server/src/main/java/com/zjugis/yzt/dao/PewgMapper.java

@@ -23,58 +23,23 @@ public interface PewgMapper extends BaseMapper<Pewg> {
     int updateShapeById(Integer id, String shape, int wkid);
 
     /**
-     * 根据objectid查询shape的面积(平方米)
-     * @param objectid 对象ID
-     * @return 面积
-     */
-    Double selectAreaById(Integer objectid);
-
-    /**
-     * 使用SQL查询pewg表,包含所有字段和面积计算(分页)
-     * @param page 分页对象
-     * @param queryWrapper 查询条件
-     * @return 分页结果
-     */
-    IPage<Pewg> selectPewgWithArea(Page<Pewg> page, @Param("ew") Object queryWrapper);
-
-    /**
-     * 使用SQL查询pewg表,包含所有字段和面积计算(不分页)
-     * @param queryWrapper 查询条件
-     * @return 结果列表
-     */
-    List<Pewg> selectPewgListWithArea(@Param("ew") Object queryWrapper);
-
-    /**
-     * 根据条件查询pewg列表(包含面积)
-     * @param params 查询参数
-     * @return 结果列表
-     */
-    List<Pewg> selectPewgListByCondition(Map<String, Object> params);
-
-    /**
-     * 根据ID查询pewg详情(包含面积)
-     * @param objectid 对象ID
+     * 根据ID查询pewg详情,返回所有字段和面积
+     * @param id 对象ID
      * @return pewg对象
      */
-    Pewg selectPewgByIdWithArea(Integer objectid);
-
-    /**
-     * 统计pewg总面积
-     * @return 总面积
-     */
-    Double selectTotalArea();
+    Pewg selectByIdWithArea(Integer id);
 
     /**
-     * 根据批次统计面积
-     * @param pcbh 批次编号
-     * @return 面积
+     * 自定义分页查询pewg表,包含所有字段和面积计算
+     * @param params 查询参数,包含分页参数和查询条件
+     * @return pewg列表
      */
-    Double selectAreaByPcbh(String pcbh);
+    List<Pewg> selectPewgPageWithArea(Map<String, Object> params);
 
     /**
-     * 根据ID查询pewg详情,返回所有字段和面积
-     * @param id 对象ID
-     * @return pewg对象
+     * 统计符合条件的记录总数
+     * @param params 查询条件
+     * @return 记录总数
      */
-    Pewg selectByIdWithArea(Integer id);
+    Long countPewgWithCondition(Map<String, Object> params);
 } 

+ 4 - 5
YHYZT/server/src/main/java/com/zjugis/yzt/service/PewgService.java

@@ -15,14 +15,13 @@ public interface PewgService extends IService<Pewg> {
      */
     void importFromNzydkByPcbh(String pcbh);
 
-    /**
-     * 使用SQL查询pewg表,包含所有字段和面积计算(分页)
-     */
-    IPage<Pewg> pageWithArea(Page<Pewg> page, Wrapper<Pewg> queryWrapper);
-
     /**
      * 根据ID查询pewg详情(包含面积)
      */
     Pewg getByIdWithArea(Integer objectid);
 
+    /**
+     * 自定义分页查询pewg表,包含所有字段和面积计算
+     */
+    IPage<Pewg> pageWithAreaCustom(Page<Pewg> page, Map<String, Object> params);
 } 

+ 23 - 5
YHYZT/server/src/main/java/com/zjugis/yzt/service/impl/PewgServiceImpl.java

@@ -85,15 +85,33 @@ public class PewgServiceImpl extends ServiceImpl<PewgMapper, Pewg> implements Pe
         }
     }
 
-    @Override
-    public IPage<Pewg> pageWithArea(Page<Pewg> page, Wrapper<Pewg> queryWrapper) {
-        return pewgMapper.selectPewgWithArea(page, queryWrapper);
-    }
-
     @Override
     public Pewg getByIdWithArea(Integer id) {
         return pewgMapper.selectByIdWithArea(id);
     }
 
+    @Override
+    public IPage<Pewg> pageWithAreaCustom(Page<Pewg> page, Map<String, Object> params) {
+        // 计算分页参数
+        int current = (int) page.getCurrent();
+        int size = (int) page.getSize();
+        int offset = (current - 1) * size;
+        
+        // 添加分页参数
+        params.put("offset", offset);
+        params.put("size", size);
+        
+        // 查询总数
+        Long total = pewgMapper.countPewgWithCondition(params);
+        
+        // 查询数据
+        List<Pewg> records = pewgMapper.selectPewgPageWithArea(params);
+        
+        // 设置分页结果
+        page.setTotal(total);
+        page.setRecords(records);
+        
+        return page;
+    }
 
 }

+ 49 - 59
YHYZT/server/src/main/resources/mapper/PewgMapper.xml

@@ -7,97 +7,87 @@
         UPDATE pewg SET shape = st_geometry(#{shape}, #{wkid}) WHERE objectid = #{id}
     </update>
 
-    <!-- 根据objectid查询shape的面积(平方米) -->
-    <select id="selectAreaById" parameterType="java.lang.Integer" resultType="java.lang.Double">
-        SELECT st_area(shape) FROM sde.pewg WHERE objectid = #{objectid}
-    </select>
-
-    <!-- 使用SQL查询pewg表,包含所有字段和面积计算(分页) -->
-    <select id="selectPewgWithArea" resultType="com.zjugis.yzt.beans.entity.Pewg">
+    <!-- 根据ID查询pewg详情,返回所有字段和面积 -->
+    <select id="selectByIdWithArea" parameterType="java.lang.Integer" resultType="com.zjugis.yzt.beans.entity.Pewg">
         SELECT 
             objectid, pcbh, pch, dk_bh, dk_mc, xzz, dk_yt, td_zl, dk_mj, dk_qs, lx, pwh, pzrq, pz_mj, nmjf, bz, wgyy, lyjz, nczfs, nczsj,
             st_astext(shape) as shape,
             st_area(shape) as area
-        FROM sde.pewg
-        <where>
-            <if test="ew != null">
-                ${ew.sqlSegment}
-            </if>
-        </where>
+        FROM sde.pewg 
+        WHERE objectid = #{id}
     </select>
 
-    <!-- 使用SQL查询pewg表,包含所有字段和面积计算(不分页) -->
-    <select id="selectPewgListWithArea" resultType="com.zjugis.yzt.beans.entity.Pewg">
+    <!-- 自定义分页查询pewg表,包含所有字段和面积计算 -->
+    <select id="selectPewgPageWithArea" parameterType="java.util.Map" resultType="com.zjugis.yzt.beans.entity.Pewg">
+        <![CDATA[
         SELECT 
             objectid, pcbh, pch, dk_bh, dk_mc, xzz, dk_yt, td_zl, dk_mj, dk_qs, lx, pwh, pzrq, pz_mj, nmjf, bz, wgyy, lyjz, nczfs, nczsj,
             st_astext(shape) as shape,
             st_area(shape) as area
         FROM sde.pewg
+        ]]>
         <where>
-            <if test="ew != null">
-                ${ew.sqlSegment}
+            <if test="pch != null and pch != ''">
+                AND pch LIKE '%' || #{pch} || '%'
+            </if>
+            <if test="dkMc != null and dkMc != ''">
+                AND dk_mc LIKE '%' || #{dkMc} || '%'
+            </if>
+            <if test="minArea != null">
+                <![CDATA[ AND st_area(shape) >= #{minArea} ]]>
+            </if>
+            <if test="maxArea != null">
+                <![CDATA[ AND st_area(shape) <= #{maxArea} ]]>
+            </if>
+            <if test="xzz != null and xzz != ''">
+                AND xzz LIKE '%' || #{xzz} || '%'
+            </if>
+            <if test="dkYt != null and dkYt != ''">
+                AND dk_yt LIKE '%' || #{dkYt} || '%'
+            </if>
+            <if test="lx != null and lx != ''">
+                AND lx LIKE '%' || #{lx} || '%'
+            </if>
+            <if test="wgyy != null and wgyy != ''">
+                AND wgyy LIKE '%' || #{wgyy} || '%'
             </if>
         </where>
+        <![CDATA[ ORDER BY objectid DESC ]]>
+        LIMIT #{size} OFFSET #{offset}
     </select>
 
-    <!-- 根据条件查询pewg列表(包含面积) -->
-    <select id="selectPewgListByCondition" parameterType="java.util.Map" resultType="com.zjugis.yzt.beans.entity.Pewg">
-        SELECT 
-            objectid, pcbh, pch, dk_bh, dk_mc, xzz, dk_yt, td_zl, dk_mj, dk_qs, lx, pwh, pzrq, pz_mj, nmjf, bz, wgyy, lyjz, nczfs, nczsj,
-            st_astext(shape) as shape,
-            st_area(shape) as area
+    <!-- 统计符合条件的记录总数 -->
+    <select id="countPewgWithCondition" parameterType="java.util.Map" resultType="java.lang.Long">
+        <![CDATA[
+        SELECT COUNT(*)
         FROM sde.pewg
+        ]]>
         <where>
-            <if test="pcbh != null and pcbh != ''">
-                AND pcbh LIKE '%' || #{pcbh} || '%'
+            <if test="pch != null and pch != ''">
+                AND pch LIKE '%' || #{pch} || '%'
             </if>
             <if test="dkMc != null and dkMc != ''">
                 AND dk_mc LIKE '%' || #{dkMc} || '%'
             </if>
+            <if test="minArea != null">
+                <![CDATA[ AND st_area(shape) >= #{minArea} ]]>
+            </if>
+            <if test="maxArea != null">
+                <![CDATA[ AND st_area(shape) <= #{maxArea} ]]>
+            </if>
             <if test="xzz != null and xzz != ''">
                 AND xzz LIKE '%' || #{xzz} || '%'
             </if>
             <if test="dkYt != null and dkYt != ''">
                 AND dk_yt LIKE '%' || #{dkYt} || '%'
             </if>
-            <if test="wgyy != null and wgyy != ''">
-                AND wgyy LIKE '%' || #{wgyy} || '%'
-            </if>
             <if test="lx != null and lx != ''">
                 AND lx LIKE '%' || #{lx} || '%'
             </if>
+            <if test="wgyy != null and wgyy != ''">
+                AND wgyy LIKE '%' || #{wgyy} || '%'
+            </if>
         </where>
-        ORDER BY objectid DESC
-    </select>
-
-    <!-- 根据ID查询pewg详情(包含面积) -->
-    <select id="selectPewgByIdWithArea" parameterType="java.lang.Integer" resultType="com.zjugis.yzt.beans.entity.Pewg">
-        SELECT 
-            objectid, pcbh, pch, dk_bh, dk_mc, xzz, dk_yt, td_zl, dk_mj, dk_qs, lx, pwh, pzrq, pz_mj, nmjf, bz, wgyy, lyjz, nczfs, nczsj,
-            st_astext(shape) as shape,
-            st_area(shape) as area
-        FROM sde.pewg 
-        WHERE objectid = #{objectid}
-    </select>
-
-    <!-- 统计pewg总面积 -->
-    <select id="selectTotalArea" resultType="java.lang.Double">
-        SELECT SUM(st_area(shape)) FROM sde.pewg
-    </select>
-
-    <!-- 根据批次统计面积 -->
-    <select id="selectAreaByPcbh" parameterType="java.lang.String" resultType="java.lang.Double">
-        SELECT SUM(st_area(shape)) FROM sde.pewg WHERE pcbh = #{pcbh}
-    </select>
-
-    <!-- 根据ID查询pewg详情,返回所有字段和面积 -->
-    <select id="selectByIdWithArea" parameterType="java.lang.Integer" resultType="com.zjugis.yzt.beans.entity.Pewg">
-        SELECT 
-            objectid, pcbh, pch, dk_bh, dk_mc, xzz, dk_yt, td_zl, dk_mj, dk_qs, lx, pwh, pzrq, pz_mj, nmjf, bz, wgyy, lyjz, nczfs, nczsj,
-            st_astext(shape) as shape,
-            st_area(shape) as area
-        FROM sde.pewg 
-        WHERE objectid = #{id}
     </select>
 
 </mapper>