Browse Source

整合工作台:完成网点关注展示(v3.0)

JensionDzero 1 year ago
parent
commit
fcbc367e9e

+ 39 - 0
benyun-core/src/main/java/com/benyun/core/controller/ChannelMapController.java

@@ -1,8 +1,12 @@
 package com.benyun.core.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.benyun.core.constant.RedisContant;
+import com.benyun.core.dao.AttentionPoolDao;
+import com.benyun.core.entity.AttentionPool;
 import com.benyun.core.entity.bo.WdCount;
 import com.benyun.core.entity.WdInfo;
+import com.benyun.core.entity.bo.WdTopologicalInfoBo;
 import com.benyun.core.entity.vo.ChannelMapAceeptVo;
 import com.benyun.core.service.ChannelMapService;
 import com.benyun.core.valida.ChannelAreaGroup;
@@ -18,7 +22,9 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 
 @RestController
@@ -30,6 +36,9 @@ public class ChannelMapController {
     @Autowired
     private RedisTemplate redisTemplate;
 
+    @Autowired
+    AttentionPoolDao attentionPoolDao;
+
     @RequestMapping("/getArea")
     public R area(@Validated(value={ChannelAreaGroup.class}) ChannelMapAceeptVo channel) {
         String md5 = channel.getHash();
@@ -58,6 +67,9 @@ public class ChannelMapController {
         String md5 = channel.getHash();
         HashMap pageInfo = (HashMap) redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_LIST).get(md5);
         if(pageInfo != null){
+            List<WdTopologicalInfoBo> data = (List<WdTopologicalInfoBo>) pageInfo.get("data");
+            attention(data);
+            pageInfo.put("data",data);
             return R.ok(pageInfo);
         }
 
@@ -66,6 +78,9 @@ public class ChannelMapController {
             return R.fail("请求参数错误");
 
         //4.保存到redis中
+        List<WdTopologicalInfoBo> data = (List<WdTopologicalInfoBo>) hashMap.get("data");
+        attention(data);
+        hashMap.put("data",data);
         redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_LIST).put(md5,hashMap);
         redisTemplate.expire(RedisContant.CHANNEL_MAP_LIST,RedisContant.CHANNEL_MAP_LIST_TIME, TimeUnit.MINUTES); //30分钟
         return R.ok(hashMap);
@@ -89,4 +104,28 @@ public class ChannelMapController {
         return R.ok(point);
     }
 
+    //Todo 标记网点关注
+    public void attention(List<WdTopologicalInfoBo> wdTopologicalInfoBos){
+        List<String> collect = wdTopologicalInfoBos.stream().map(wdTopologicalInfoBo -> {
+            return wdTopologicalInfoBo.getCenterWdId();
+        }).collect(Collectors.toList());
+
+        //标志是否关注
+        QueryWrapper<AttentionPool> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.select("wd_id");
+        queryWrapper1.in("wd_id",collect);
+        List<AttentionPool> attentionPools = attentionPoolDao.selectList(queryWrapper1);
+        List<String> collect1 = attentionPools.stream().map(attentionPool -> {
+            return attentionPool.getWdId();
+        }).collect(Collectors.toList());
+
+        for (WdTopologicalInfoBo wdTopologicalInfoBo : wdTopologicalInfoBos) {
+            boolean contains = collect1.contains(wdTopologicalInfoBo.getCenterWdId());
+            if (contains)
+                wdTopologicalInfoBo.setAttention(1);
+            else
+                wdTopologicalInfoBo.setAttention(0);
+        }
+    }
+
 }

+ 2 - 1
benyun-core/src/main/java/com/benyun/core/entity/AttentionPool.java

@@ -2,13 +2,14 @@ package com.benyun.core.entity;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import lombok.Data;
 
 import java.util.Date;
 
 @Data
 @TableName("bl_attention_pool")
-public class AttentionPool {
+public class AttentionPool{
     @TableField("attention_id")
     private String attentionId;
     @TableField("contact")

+ 2 - 2
benyun-core/src/main/java/com/benyun/core/entity/WdInfo.java

@@ -80,6 +80,6 @@ public class WdInfo {
     @TableField("geo_hash")
     private String geoHash;
 
-    @TableField("show")
-    private int show;
+    @TableField("show_delete")
+    private int showDelete;
 }

+ 3 - 3
benyun-core/src/main/java/com/benyun/core/entity/vo/WdInfoVo.java

@@ -45,8 +45,8 @@ public class WdInfoVo {
     @JsonDeserialize(using = LocalDateTimeDeserializer.class)
     private LocalDateTime collectTime;
 
-    @TableField("show")
-    private int show;
+    @TableField("show_delete")
+    private int showDelete;
 
     int pageNum = 1;
 
@@ -69,7 +69,7 @@ public class WdInfoVo {
         this.collectUserId = wdInfo.getCollectUserId();
         this.collectPerson = wdInfo.getCollectPerson();
         this.collectTime = wdInfo.getCollectTime();
-        this.show = wdInfo.getShow();
+        this.showDelete = wdInfo.getShowDelete();
     }
 
     public WdInfoVo() {

+ 6 - 1
benyun-core/src/main/java/com/benyun/core/service/impl/ChannelMapServiceImpl.java

@@ -2,9 +2,11 @@ package com.benyun.core.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.benyun.core.dao.AddrCategoryDao;
+import com.benyun.core.dao.AttentionPoolDao;
 import com.benyun.core.dao.WdInfoDao;
 import com.benyun.core.dao.WdTopologicalInfoDao;
 import com.benyun.core.entity.AddrCategory;
+import com.benyun.core.entity.AttentionPool;
 import com.benyun.core.entity.WdTopologicalInfo;
 import com.benyun.core.entity.bo.WdCount;
 import com.benyun.core.entity.bo.WdCountBody;
@@ -44,6 +46,9 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     @Qualifier("typeByMap")
     private HashMap<String,String> typeByMap;
 
+    @Autowired
+    AttentionPoolDao attentionPoolDao;
+
     @Override
     public WdCount area(List<String> channel, String rankType, String searchText, String[] addrCode) {
         long start = System.currentTimeMillis();
@@ -209,7 +214,6 @@ public class ChannelMapServiceImpl implements ChannelMapService {
         List<WdTopologicalInfo> originWdInfos = wdTopologicalInfoDao.selectList(queryWrapper);
         PageInfo<WdTopologicalInfo> PageInfo = new PageInfo<>(originWdInfos);
 
-        List<String> id = new ArrayList<>();
 
         //组装
         List<WdTopologicalInfoBo> collect = PageInfo.getList().stream().map(wdTopologicalInfo -> {
@@ -237,6 +241,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             return wdTopologicalInfoBo;
         }).collect(Collectors.toList());
 
+
         PageInfo.setList(null);
         HashMap result = new HashMap();
         result.put("data",collect);

+ 1 - 1
benyun-core/src/main/resources/application.yaml

@@ -24,7 +24,7 @@ mybatis-plus:
   global-config:
     db-config:
       id-type: ASSIGN_ID
-      logic-delete-field: show # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2)
+      logic-delete-field: show_delete # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2)
       logic-delete-value: 1 # 逻辑已删除值(默认为 1)
       logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
 

+ 2 - 2
benyun-core/src/main/resources/mapper/WdInfoMapper.xml

@@ -88,8 +88,8 @@
             <if test="addrCode != null and addrCode != ''">
                 and addr_code = #{addrCode}
             </if>
-            <if test="show != null">
-                and ddt_wd_info.show = #{show}
+            <if test="showDelete != null">
+                and show_delete = #{showDelete}
             </if>
         </where>
     </select>