Bladeren bron

根据搜索的结果,只返回对应的树形结构

LiRong 3 maanden geleden
bovenliggende
commit
bb9b30e2f0

+ 13 - 0
leromro-core/src/main/java/com/leromro/core/controller/VolunteerInfoController.java

@@ -16,6 +16,7 @@ import com.leromro.core.domain.VolunteerInfo;
 import com.leromro.core.domain.dto.ConversationMsgDTO;
 import com.leromro.core.domain.dto.VolunteerInfoDTO;
 import com.leromro.core.domain.dto.VolunteerListDTO;
+import com.leromro.core.domain.vo.BusinessManagementVO;
 import com.leromro.core.domain.vo.VolunteerInfoDetailVO;
 import com.leromro.core.domain.vo.VolunteerInfoVO;
 import com.leromro.core.service.IConversationRecordService;
@@ -136,6 +137,18 @@ public class VolunteerInfoController extends BaseController {
         return getDataTable(list);
     }
 
+
+    /**
+     * 获取志愿者搜索返回分类
+     * 已测试
+     */
+    @ApiOperation(value = "(小程序)获取志愿者搜索结果的分类", notes = "和普通列表传入数据相同")
+    @GetMapping("/searchBusinessTypeList")
+    public R<List<BusinessManagementVO>> searchBusinessTypeList(VolunteerListDTO volunteerInfo) {
+        List<BusinessManagementVO> list = volunteerInfoService.searchBusinessTypeList(volunteerInfo);
+        return R.ok(list);
+    }
+
     /**
      * 获取志愿者信息详细信息
      * 已测试

+ 3 - 0
leromro-core/src/main/java/com/leromro/core/domain/vo/BusinessManagementVO.java

@@ -64,6 +64,9 @@ public class BusinessManagementVO implements INode<BusinessManagementVO> {
     @ApiModelProperty("最高价格")
     private String maxPrice;
 
+    @ApiModelProperty("二级分类名称")
+    private String projectTypeName;
+
 
 
 }

+ 15 - 0
leromro-core/src/main/java/com/leromro/core/domain/vo/VolunteerInfoVO.java

@@ -1,5 +1,8 @@
 package com.leromro.core.domain.vo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.leromro.common.config.serializer.BigDecimalSerializer;
 import com.leromro.core.domain.VolunteerInfo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -18,6 +21,9 @@ public class VolunteerInfoVO {
     @ApiModelProperty(value = "志愿者姓名")
     private String name;
 
+    @ApiModelProperty(value = "志愿者年龄")
+    private String age;
+
     @ApiModelProperty(value = "志愿者照片")
     private String volunteerPicture;
 
@@ -38,4 +44,13 @@ public class VolunteerInfoVO {
 
     @ApiModelProperty(value = "大类别")
     private Long serviceCategory;
+
+    @ApiModelProperty("业务价格")
+    @JsonSerialize(using = BigDecimalSerializer.class)
+    private BigDecimal businessPrice;
+
+    @TableField("business_unit")
+    @ApiModelProperty("购买单位")
+    private String  businessUnit;
+
 }

+ 3 - 0
leromro-core/src/main/java/com/leromro/core/mapper/VolunteerInfoMapper.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.leromro.core.domain.dto.HomePageDTO;
 import com.leromro.core.domain.dto.VolunteerInfoDTO;
 import com.leromro.core.domain.dto.VolunteerListDTO;
+import com.leromro.core.domain.vo.BusinessManagementVO;
 import com.leromro.core.domain.vo.VolunteerInfoVO;
 import org.apache.ibatis.annotations.Param;
 
@@ -34,4 +35,6 @@ public interface VolunteerInfoMapper extends BaseMapper<VolunteerInfo> {
     List<VolunteerInfo> selectVolunteerGroupByUserId(ListPermission listPermission,@Param("user") SysUser sysUser);
 
     List<String> selectVolunteerPictureList(Long userId);
+
+    List<BusinessManagementVO> searchBusinessTypeList(@Param("info") VolunteerListDTO volunteerInfo);
 }

+ 3 - 0
leromro-core/src/main/java/com/leromro/core/service/IVolunteerInfoService.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.leromro.core.domain.dto.HomePageDTO;
 import com.leromro.core.domain.dto.VolunteerInfoDTO;
 import com.leromro.core.domain.dto.VolunteerListDTO;
+import com.leromro.core.domain.vo.BusinessManagementVO;
 import com.leromro.core.domain.vo.VolunteerInfoDetailVO;
 import com.leromro.core.domain.vo.VolunteerInfoVO;
 
@@ -46,4 +47,6 @@ public interface IVolunteerInfoService extends IService<VolunteerInfo> {
     List<String> getVolunteerPicture(Long userId);
 
     R updateVolunteerInfoById(VolunteerInfoDTO volunteerInfoDTO);
+
+    List<BusinessManagementVO> searchBusinessTypeList(VolunteerListDTO volunteerInfo);
 }

+ 18 - 2
leromro-core/src/main/java/com/leromro/core/service/impl/VolunteerInfoServiceImpl.java

@@ -24,11 +24,13 @@ import com.leromro.core.domain.dto.ConversationMsgDTO;
 import com.leromro.core.domain.dto.HomePageDTO;
 import com.leromro.core.domain.dto.VolunteerInfoDTO;
 import com.leromro.core.domain.dto.VolunteerListDTO;
+import com.leromro.core.domain.vo.BusinessManagementVO;
 import com.leromro.core.domain.vo.VolunteerInfoDetailVO;
 import com.leromro.core.domain.vo.VolunteerInfoVO;
 import com.leromro.core.mapper.VolunteerInfoMapper;
 import com.leromro.core.service.*;
 import com.leromro.core.utils.DateTimeUtil;
+import com.leromro.core.utils.ForestNodeMerger;
 import com.leromro.core.utils.SendSmsUtil;
 import com.leromro.framework.config.ConstantsConfig;
 import com.leromro.system.service.ISysConfigService;
@@ -79,6 +81,8 @@ public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, V
     private ISecondOrderService iSecondOrderService;
     @Autowired
     private ISysUserService iSysUserService;
+    @Autowired
+    private IBusinessManagementService iBusinessManagementService;
 
     @Autowired
     private IConversationRecordService conversationRecordService;
@@ -188,13 +192,13 @@ public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, V
         redisTemplate.opsForZSet().add(CacheConstants.SEARCH_HISTORY_KEY + userId, volunteerInfo.getBusinessTierName(), System.currentTimeMillis());
         insertSearchSort(CacheConstants.SEARCH_HISTORY_KEY + userId, volunteerInfo.getBusinessTierName());
         //查询出所有服务名称
-        Map<Long, String> idMapTierName = businessManagementService.list().stream().collect(Collectors.toMap(BusinessManagement::getBusinessManagementId, BusinessManagement::getBusinessTierName));
+       /* Map<Long, String> idMapTierName = businessManagementService.list().stream().collect(Collectors.toMap(BusinessManagement::getBusinessManagementId, BusinessManagement::getBusinessTierName));
         if (ObjectUtil.isNotEmpty(infos)){
             infos.forEach(info -> {
 
                 info.setBusinessTierName(idMapTierName.get(info.getBusinessManagementId()));
             });
-        }
+        }*/
         return infos;
     }
 
@@ -304,6 +308,18 @@ public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, V
         return R.ok();
     }
 
+    /**
+     * @param volunteerInfo
+     * @return
+     */
+    @Override
+    public  List<BusinessManagementVO> searchBusinessTypeList(VolunteerListDTO volunteerInfo) {
+        List<BusinessManagementVO> list = volunteerInfoMapper.searchBusinessTypeList(volunteerInfo);
+        List<BusinessManagementVO> treeList = iBusinessManagementService.getTreeList(0L).getData();
+        list = ForestNodeMerger.nbMerge(list,treeList);
+        return list;
+    }
+
     /**
      * 用户成为志愿者积分处理
      */

+ 46 - 0
leromro-core/src/main/java/com/leromro/core/utils/ForestNodeMerger.java

@@ -2,7 +2,10 @@ package com.leromro.core.utils;
 
 
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  *  树工具
@@ -24,6 +27,49 @@ public class ForestNodeMerger {
         return forestNodeManager.getRoot();
     }
 
+// 首先获取全部的树,然后遍历全部的数,根据传入的结果,删掉两个树中数据不匹配的父节点及其父节点。
+
+    public static <T extends INode<T>> List<T> nbMerge(List<T> items, List<T> allItems) {
+        // 1. 从allItems构建完整树
+        List<T> fullTree = merge(allItems);
+
+        // 2. 获取items中的所有叶子节点ID
+        Set<Long> leafIds = items.stream()
+                .map(INode::getId)
+                .collect(Collectors.toSet());
+
+        // 3. 过滤完整树,只保留包含叶子节点的分支
+        return fullTree.stream()
+                .map(tree -> pruneTree(tree, leafIds))
+                .filter(tree -> tree != null)
+                .collect(Collectors.toList());
+    }
+
+    private static <T extends INode<T>> T pruneTree(T node, Set<Long> leafIds) {
+        // 处理子节点
+        List<T> children = node.getChildren();
+        if (children != null && !children.isEmpty()) {
+            List<T> prunedChildren = new ArrayList<>();
+            for (T child : children) {
+                T prunedChild = pruneTree(child, leafIds);
+                if (prunedChild != null) {
+                    prunedChildren.add(prunedChild);
+                }
+            }
+            node.getChildren().clear();
+            node.getChildren().addAll(prunedChildren);
+        }
+
+        // 判断是否保留当前节点
+        if (leafIds.contains(node.getId()) ||
+                (node.getChildren() != null && !node.getChildren().isEmpty())) {
+            return node;
+        }
+        return null;
+    }
+
+
+
     public static <T extends INode<T>> void getTreeList(T tree, List<T> nodes) {
         if (tree == null) {
             return;

+ 38 - 7
leromro-core/src/main/resources/mapper/core/VolunteerInfoMapper.xml

@@ -50,7 +50,8 @@
     </select>
 
     <select id="selectVolunteerInfoSimple" resultType="com.leromro.core.domain.vo.VolunteerInfoVO">
-        select volunteer_id, skill_describe,age ,service_category,name,volunteer_picture,score,business_management_id ,business_price,business_tier_name , business_unit,business_describe,business_describe
+        select volunteer_id, skill_describe,age ,service_category,name,volunteer_picture,score,business_management_id ,
+               business_price,business_tier_name , business_unit,business_describe
         from l_volunteer_info lvi
         where app_status = 2
         AND EXISTS (
@@ -65,10 +66,14 @@
         <if test="info.score != null "> and lvi.score = #{info.score}</if>
         <if test="info.serviceCategory != null and info.serviceCategory != ''"> and lvi.service_category = #{info.serviceCategory}</if>
         <if test="info.skillDescribe != null  and info.skillDescribe != ''"> and lvi.skill_describe = #{info.skillDescribe}</if>
-<!--        <if test="info.provinceCode != null and info.provinceCode != ''">and lvi.province_code = #{info.provinceCode}</if>-->
-<!--        <if test="info.cityCode != null and info.cityCode != ''">and lvi.city_code = #{info.cityCode}</if>-->
-<!--        <if test="info.districtCode != null and info.districtCode != ''">and lvi.district_code = #{info.districtCode}</if>-->
-        <if test="info.businessTierName != null and info.businessTierName != ''">and lvi.business_tier_name like concat('%', #{info.businessTierName}, '%')</if>
+    <!-- <if test="info.provinceCode != null and info.provinceCode != ''">and lvi.province_code = #{info.provinceCode}</if>-->
+    <!-- <if test="info.cityCode != null and info.cityCode != ''">and lvi.city_code = #{info.cityCode}</if>-->
+    <!-- <if test="info.districtCode != null and info.districtCode != ''">and lvi.district_code = #{info.districtCode}</if>-->
+        <if test="info.businessTierName != null and info.businessTierName != ''">
+        and lvi.business_tier_name like concat('%', #{info.businessTierName}, '%') or
+        lvi.name like concat('%', #{info.businessTierName}, '%') or
+        lvi.business_describe like concat('%', #{info.businessTierName}, '%')
+        </if>
     </select>
 
     <select id="getCurrentOrgVolunteerList" resultType="com.leromro.core.domain.VolunteerInfo">
@@ -77,12 +82,38 @@
     </select>
     <select id="selectVolunteerGroupByUserId" resultType="com.leromro.core.domain.VolunteerInfo">
         select lvi.volunteer_id ,s.create_time  from sys_user s left join l_volunteer_info lvi on s.user_id = lvi.volunteer_id
-        where s.del_flag = 0 and s.user_platform = 0 and lvi.volunteer_id
+        where s.del_flag = 0 and s.user_platform = 0 and lvi.volunteer_id and s.service_centre_id = #{user.serviceCentreId}
         group by lvi.volunteer_id
     </select>
     <select id="selectVolunteerPictureList" resultType="java.lang.String" parameterType="java.lang.Long">
         select volunteer_picture from l_volunteer_info where volunteer_id = #{userId}
     </select>
-
+    <select id="searchBusinessTypeList" resultType="com.leromro.core.domain.vo.BusinessManagementVO"
+            parameterType="com.leromro.core.domain.dto.VolunteerListDTO">
+        select  lbm2.business_management_id as id,lbm2.parent_id,lbm2.business_name,lbm2.business_tier_name,lbm2.business_icon,lvi.project_type_name
+        from l_volunteer_info lvi left join l_business_management  lbm2 on lvi.business_management_id = lbm2.business_management_id
+        where lvi.app_status = 2  and lvi.name like '%刘%'
+        AND EXISTS (
+        SELECT 1
+        FROM l_volunteer_work_date lvw
+        WHERE lvw.volunteer_id = lvi.volunteer_id
+        and lvw.work_date >= curdate()
+        )
+        and lvi.business_management_id in (select lbm.business_management_id from l_business_management lbm
+        where find_in_set(#{info.businessManagementId},lbm.ancestors) or lbm.business_management_id = #{info.businessManagementId})
+        <if test="info.name != null  and info.name != ''"> and lvi.name like concat('%', #{info.name}, '%')</if>
+        <if test="info.score != null "> and lvi.score = #{info.score}</if>
+        <if test="info.serviceCategory != null and info.serviceCategory != ''"> and lvi.service_category = #{info.serviceCategory}</if>
+        <if test="info.skillDescribe != null  and info.skillDescribe != ''"> and lvi.skill_describe = #{info.skillDescribe}</if>
+        <if test="info.businessTierName != null and info.businessTierName != ''">
+            and lvi.business_tier_name like concat('%', #{info.businessTierName}, '%') or
+            lvi.name like concat('%', #{info.businessTierName}, '%') or
+            lvi.business_describe like concat('%', #{info.businessTierName}, '%')
+        </if>
+        group by lbm2.business_tier_name
+        <!--        <if test="info.provinceCode != null and info.provinceCode != ''">and lvi.province_code = #{info.provinceCode}</if>-->
+        <!--        <if test="info.cityCode != null and info.cityCode != ''">and lvi.city_code = #{info.cityCode}</if>-->
+        <!--        <if test="info.districtCode != null and info.districtCode != ''">and lvi.district_code = #{info.districtCode}</if>-->
+    </select>
 
 </mapper>

+ 1 - 2
leromro-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -180,8 +180,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		where user_id = #{userId}
 	</select>
 	<select id="selectClientList" resultType="com.leromro.common.core.domain.entity.SysUser">
-		select * from sys_user where  user_open_id is not null and  user_platform = 0 and del_flag = 0;
-		<if test="user.serviceCentreId != null and user.serviceCentreId != ''"> and service_center_id =#{user.serviceCentreId}</if>
+		select * from sys_user where  user_open_id is not null and  user_platform = 0 and del_flag = 0 and service_centre_id =#{user.deptId}
 	</select>
 
 	<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">