瀏覽代碼

智能选址

zhao 6 月之前
父節點
當前提交
2554db6628

+ 1 - 2
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/SellBuildController.java

@@ -1,7 +1,6 @@
 package com.example.nngkxxdp.controller;
 
 import com.example.nngkxxdp.entity.SellBuild;
-import com.example.nngkxxdp.query.SelectionAddrQuery;
 import com.example.nngkxxdp.query.SellBuildQuery;
 import com.example.nngkxxdp.query.pageResult;
 import com.example.nngkxxdp.service.SellBuildService;
@@ -57,7 +56,7 @@ public class SellBuildController {
 
     //智能选址分页
     @PostMapping("/queryPageByAddr")
-    public pageResult<SellBuild> queryPageByAddr(@RequestBody SelectionAddrQuery query){
+    public pageResult<SellBuild> queryPageByAddr(@RequestBody SellBuildQuery query){
         return sellBuildService.queryPageByAddr(query);
     }
 

+ 1 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/HandleMattersDao.java

@@ -24,7 +24,7 @@ public interface HandleMattersDao {
 
     List<HandleMatters> findByIdByKey(@Param("deptId") Long deptId, @Param("keyword") String keyword);
 
- int findByIdByKeyCount(@Param("deptId") Long deptId, @Param("keyword") String keyword);
+     int findByIdByKeyCount(@Param("deptId") Long deptId, @Param("keyword") String keyword);
 }
 
 

+ 2 - 3
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/SellBuildDao.java

@@ -1,7 +1,6 @@
 package com.example.nngkxxdp.dao;
 
 import com.example.nngkxxdp.entity.SellBuild;
-import com.example.nngkxxdp.query.SelectionAddrQuery;
 import com.example.nngkxxdp.query.SellBuildQuery;
 
 import java.util.List;
@@ -31,9 +30,9 @@ public interface SellBuildDao {
     Integer queryCount(SellBuildQuery query);
     List<SellBuild> queryData(SellBuildQuery query);
 
-    Integer queryCountByAddr(SelectionAddrQuery query);
+    Integer queryCountByAddr(SellBuildQuery query);
 
-    List<SellBuild> queryDataByAddr(SelectionAddrQuery query);
+    List<SellBuild> queryDataByAddr(SellBuildQuery query);
 }
 
 

+ 0 - 7
nngkxxdp/src/main/java/com/example/nngkxxdp/query/SelectionAddrQuery.java

@@ -6,13 +6,6 @@ import lombok.Data;
 @Data
 public class SelectionAddrQuery extends BaseQuery {
     private Long parkId;
-    //服务行业
-    private String productModule;
-    //载体类型
-    private String application;
-    //租赁情况
-    //所属园区
-    private String belong;
 
 
 }

+ 13 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/query/SellBuildQuery.java

@@ -3,6 +3,8 @@ package com.example.nngkxxdp.query;
 import com.example.nngkxxdp.base.BaseQuery;
 import lombok.Data;
 
+import java.util.List;
+
 @Data
 public class SellBuildQuery extends BaseQuery {
     //所属园区
@@ -14,4 +16,15 @@ public class SellBuildQuery extends BaseQuery {
     private Float spaceMax;
     private Float spaceMin;
     private String space1;
+    //服务行业
+    private String productModule;
+    //租赁情况
+    private String rent;
+    //所属园区string
+    private String belong;
+
+    private List<Long> belongs;
+    private List<String> applications;
+    private List<String> productModules;
+
 }

+ 1 - 2
nngkxxdp/src/main/java/com/example/nngkxxdp/service/SellBuildService.java

@@ -1,7 +1,6 @@
 package com.example.nngkxxdp.service;
 
 import com.example.nngkxxdp.entity.SellBuild;
-import com.example.nngkxxdp.query.SelectionAddrQuery;
 import com.example.nngkxxdp.query.SellBuildQuery;
 import com.example.nngkxxdp.query.pageResult;
 
@@ -30,5 +29,5 @@ public interface SellBuildService {
 
     pageResult<SellBuild>queryPage(SellBuildQuery query);
 
-    pageResult<SellBuild> queryPageByAddr(SelectionAddrQuery query);
+    pageResult<SellBuild> queryPageByAddr(SellBuildQuery query);
 }

+ 10 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/HandleBusinessServiceImpl.java

@@ -113,9 +113,18 @@ public class HandleBusinessServiceImpl implements HandleBusinessService{
             handleMatter.addAll(HandleMatters);
             total += handleMattersDao.findByIdByKeyCount(handleDept.getId(), query.getKeyword());
         }
+
+        // 计算分页参数
+        int offset = (query.getCurrentPage() - 1) * query.getPageSize();
+        List<Object> ss = new ArrayList<>();
+        if (offset < handleMatter.size()) {
+            int toIndex = Math.min(offset + query.getPageSize(), handleMatter.size());
+            ss = handleMatter.subList(offset, toIndex);
+        }
         // 计算总页数
         int totalPages = (int) Math.ceil((double) total / query.getPageSize());
-        map.put("handleMatters", handleMatter);
+
+        map.put("handleMatters", ss);
         map.put("handleBusiness", handleBusiness);
         map.put("handleDepts", handleDepts);
         map.put("total", total);

+ 26 - 2
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/SellBuildServiceImpl.java

@@ -3,15 +3,17 @@ package com.example.nngkxxdp.service.impl;
 import com.example.nngkxxdp.base.BusinessException;
 import com.example.nngkxxdp.dao.SellBuildDao;
 import com.example.nngkxxdp.entity.SellBuild;
-import com.example.nngkxxdp.query.SelectionAddrQuery;
 import com.example.nngkxxdp.query.SellBuildQuery;
 import com.example.nngkxxdp.query.pageResult;
 import com.example.nngkxxdp.service.SellBuildService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
 * @author zhao
@@ -90,7 +92,29 @@ public class SellBuildServiceImpl implements SellBuildService{
     }
 
     @Override
-    public pageResult<SellBuild> queryPageByAddr(SelectionAddrQuery query) {
+    public pageResult<SellBuild> queryPageByAddr(SellBuildQuery query) {
+        //String[] applications = query.getApplication().split(",");
+        //分割application
+        String applicationsStr  = query.getApplication();
+        if (applicationsStr != null && !applicationsStr.isEmpty()) {
+            String[] applications = applicationsStr.split(",");
+            List<String> applicationList = new ArrayList<>(Arrays.asList(applications));
+            query.setApplications(applicationList);
+        }
+        //分割productModule
+        String productModuleStr = query.getProductModule();
+        if (productModuleStr != null && !productModuleStr.isEmpty()) {
+            String[] productModules = productModuleStr.split(",");
+            List<String> productModuleList = new ArrayList<>(Arrays.asList(productModules));
+            query.setProductModules(productModuleList);
+        }
+        //分割多个园区
+        String parkIdsStr = query.getBelong();
+        if (parkIdsStr != null && !parkIdsStr.isEmpty()) {
+            String[] belongs = parkIdsStr.split(",");
+            List<String> belongList = new ArrayList<>(Arrays.asList(belongs));
+            query.setBelongs(belongList.stream().map(Long::valueOf).collect(Collectors.toList()));
+        }
         Integer totals = sellBuildDao.queryCountByAddr(query);
         List<SellBuild> list = sellBuildDao.queryDataByAddr(query);
         return new pageResult<>(totals,list);

+ 8 - 2
nngkxxdp/src/main/resources/mapper/HandleMattersDao.xml

@@ -51,11 +51,17 @@
     </select>
     <select id="findByIdByKey" resultType="com.example.nngkxxdp.entity.HandleMatters">
         select * from t_handle_matters
-        where deptId=#{deptId} and matters_name like concat('%',#{keyword},'%')
+        where deptId=#{deptId}
+        <if test="keyword != null and keyword != ''">
+            and matters_name like concat('%', #{keyword}, '%')
+        </if>
     </select>
     <select id="findByIdByKeyCount" resultType="java.lang.Integer">
         select count(*) from t_handle_matters
-        where deptId=#{deptId} and matters_name like concat('%',#{keyword},'%')
+        where deptId=#{deptId}
+        <if test="keyword != null and keyword != ''">
+            and matters_name like concat('%', #{keyword}, '%')
+        </if>
     </select>
 
 </mapper>

+ 50 - 22
nngkxxdp/src/main/resources/mapper/SellBuildDao.xml

@@ -109,43 +109,71 @@
         from t_sell_build sb
         left join t_park_data pd on pd.id = sb.belong
         <where>
-            <if test="productModule != null and productModule != ''">
-                and product_module like concat('%', #{productModule}, '%')
-            </if>
-            <if test="belong != null and belong != ''">
-                and belong like concat('%', #{belong}, '%')
+            <if test="parkId != null">
+                and sb.belong = #{parkId}
             </if>
             <if test="application != null and application != ''">
-                and application like concat('%', #{application}, '%')
+                and sb.application like  concat('%', #{application}, '%')
+            </if>
+            <if test="spaceMin != null and spaceMin != '' and spaceMax != null and spaceMax != ''">
+                and sb.space &gt;= #{spaceMin} and sb.space &lt;= #{spaceMax}
             </if>
         </where>
         limit #{begin}, #{pageSize}
     </select>
-    <select id="queryCountByAddr" resultType="java.lang.Integer">
-        select count(*) from t_sell_build
+    <select id="queryCountByAddr" resultType="java.lang.Integer" >
+        select count(*)
+        from t_sell_build sb
+        left join t_park_data pd on pd.id = sb.belong
         <where>
-            <if test="productModule != null and productModule != ''">
-                and product_module like concat('%', #{productModule}, '%')
+            <if test="belongs != null and !belongs.isEmpty()">
+                and (
+                <foreach collection="belongs" item="belong" separator=" or ">
+                    sb.belong = #{belong}
+                </foreach>
+                )
             </if>
-            <if test="belong != null and belong != ''">
-                and belong like concat('%', #{belong}, '%')
+            <if test="applications != null and !applications.isEmpty()">
+                and (
+                <foreach collection="applications" item="app" separator=" or ">
+                    sb.application like concat('%', #{app}, '%')
+                </foreach>
+                )
             </if>
-            <if test="application != null and application != ''">
-                and application like concat('%', #{application}, '%')
+            <if test="productModules != null and !productModules.isEmpty()">
+                and (
+                <foreach collection="productModules" item="pro" separator=" or ">
+                    sb.product_module like concat('%', #{pro}, '%')
+                </foreach>
+                )
             </if>
         </where>
     </select>
-    <select id="queryDataByAddr" resultType="com.example.nngkxxdp.entity.SellBuild">
-        select * from t_sell_build
+    <select id="queryDataByAddr" resultType="com.example.nngkxxdp.entity.SellBuild" resultMap="BaseResultMap">
+        select sb.*, sb.addr as landAddr, pd.title, pd.industry, pd.addr as parkAddr
+        from t_sell_build sb
+        left join t_park_data pd on pd.id = sb.belong
         <where>
-            <if test="productModule != null and productModule != ''">
-                and product_module like concat('%', #{productModule}, '%')
+            <if test="belongs != null and !belongs.isEmpty()">
+                and (
+                <foreach collection="belongs" item="belong" separator=" or ">
+                    sb.belong = #{belong}
+                </foreach>
+                )
             </if>
-            <if test="belong != null and belong != ''">
-                and belong like concat('%', #{belong}, '%')
+            <if test="applications != null and !applications.isEmpty()">
+                and (
+                <foreach collection="applications" item="app" separator=" or ">
+                    sb.application like concat('%', #{app}, '%')
+                </foreach>
+                )
             </if>
-            <if test="application != null and application != ''">
-                and application like concat('%', #{application}, '%')
+            <if test="productModules != null and !productModules.isEmpty()">
+                and (
+                <foreach collection="productModules" item="pro" separator=" or ">
+                    sb.product_module like concat('%', #{pro}, '%')
+                </foreach>
+                )
             </if>
         </where>
         limit #{begin}, #{pageSize}