| | |
| | | package com.linghu.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.linghu.model.dto.KeywordDto; |
| | | import com.linghu.model.dto.OrderDto; |
| | | import com.linghu.model.entity.Keyword; |
| | | import com.linghu.model.entity.KeywordTask; |
| | | import com.linghu.model.entity.Orders; |
| | | import com.linghu.model.entity.Question; |
| | | import com.linghu.service.KeywordService; |
| | | import com.linghu.service.KeywordTaskService; |
| | | import com.linghu.service.OrderService; |
| | | import com.linghu.mapper.OrderMapper; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.linghu.service.QuestionService; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | private KeywordService keywordService; |
| | | @Autowired |
| | | private QuestionService questionService; |
| | | @Autowired |
| | | private OrderMapper orderMapper; |
| | | @Autowired |
| | | private KeywordTaskService keywordTaskService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | keywordService.save(keyword); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return true; |
| | |
| | | for (Keyword keyword : keywords) { |
| | | KeywordDto dto = new KeywordDto(); |
| | | BeanUtils.copyProperties(keyword, dto); |
| | | LambdaQueryWrapper<KeywordTask> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(KeywordTask::getKeyword_id, keyword.getKeyword_id()); |
| | | List<KeywordTask> keywordTasks = keywordTaskService.list(queryWrapper); |
| | | |
| | | // 提取 task_id 列表 |
| | | List<String> taskIdList = keywordTasks.stream() |
| | | .map(KeywordTask::getTask_id) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | |
| | | dto.setTaskIdList(taskIdList); // 设置 task_id 列表 |
| | | // 查询该关键词下的所有提问词 |
| | | List<Question> questions = questionService.lambdaQuery() |
| | | .eq(Question::getKeyword_id, keyword.getKeyword_id()) |
| | |
| | | } |
| | | return keywordDtos; |
| | | } |
| | | @Override |
| | | public Page<String> getClientList(String clientName, Integer pageNum, Integer pageSize) { |
| | | Page<Orders> page = new Page<>(pageNum, pageSize); |
| | | |
| | | // 构建查询条件(根据客户名称模糊搜索) |
| | | LambdaQueryWrapper<Orders> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.select(Orders::getClient_name) // 只查询客户名称字段 |
| | | .eq(Orders::getDel_flag, 0) // 只查询未删除的订单 |
| | | .groupBy(Orders::getClient_name); // 按客户名称分组去重 |
| | | |
| | | if (clientName != null && !clientName.isEmpty()) { |
| | | queryWrapper.like(Orders::getClient_name, clientName); |
| | | } |
| | | |
| | | // 执行分页查询 |
| | | IPage<Orders> orderPage = orderMapper.selectPage(page, queryWrapper); |
| | | |
| | | // 转换为客户选项列表(统计每个客户的订单数量) |
| | | List<String> clientOptions = orderPage.getRecords().stream() |
| | | .map(order -> { |
| | | |
| | | |
| | | return order.getClient_name(); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 构建结果分页对象 |
| | | Page<String> resultPage = new Page<>(); |
| | | resultPage.setCurrent(orderPage.getCurrent()); |
| | | resultPage.setSize(orderPage.getSize()); |
| | | resultPage.setTotal(orderPage.getTotal()); |
| | | resultPage.setRecords(clientOptions); |
| | | |
| | | return resultPage; |
| | | |
| | | |
| | | } |
| | | } |