huliguo
3 天以前 11ec7ac8f4832c4274cf61a19cc35cda3de9e0e5
Merge remote-tracking branch 'origin/master'
1个文件已添加
21个文件已修改
343 ■■■■ 已修改文件
src/main/java/com/linghu/controller/KeywordController.java 151 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/controller/OrderController.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/controller/PlatformController.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/controller/TypeController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/mapper/ReferenceMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/dto/KeywordDto.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/dto/OrderDto.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/entity/Platform.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/entity/Type.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/excel/ReferenceExcel.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/vo/KeywordStaticsVO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/vo/PlatformProportionVO.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/vo/ReferenceVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/vo/ResultListVO.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/service/OrderService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/service/PlatformExcelService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/service/impl/OrderServiceImpl.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/service/impl/TypeServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/PlatformMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ReferenceMapper.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/TypeMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/keywordMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/controller/KeywordController.java
@@ -3,8 +3,10 @@
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linghu.listener.KeywordExcelListener;
import com.linghu.mapper.KeywordMapper;
import com.linghu.mapper.ReferenceMapper;
import com.linghu.model.common.ResponseResult;
import com.linghu.model.dto.ExportFeedDTO;
@@ -31,16 +33,22 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.ValidationException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.time.LocalDateTime;
import java.io.IOException;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/keyword")
@@ -54,6 +62,8 @@
    @Autowired
    private ReferenceService referenceService;
    @Autowired
    private ReferenceMapper referenceMapper;
    /**
     * 关键词统计 EChart图
@@ -90,21 +100,15 @@
     */
    @GetMapping("/getResultByTypeId")
    @ApiOperation(value = "根据类别查看")
    public ResponseResult<ResultByTypeIdVO> getResultByTypeId(@RequestParam("keywordId") Integer keywordId,
    public ResponseResult<List<PlatformProportionVO> > getResultByTypeId(@RequestParam("keywordId") Integer keywordId,
                                                            @RequestParam(value = "questionId", required = false) Integer questionId,
                                                            @RequestParam(value = "typeId", required = false) Integer typeId) {
        ResultByTypeIdVO vo = new ResultByTypeIdVO();
                                                            @RequestParam(value = "typeId", required = false) Integer typeId,
                                                              @RequestParam(value = "isNow") Integer isNow) {
        Keyword keyword = keywordService.getById(keywordId);
        List<PlatformProportionVO> nowList = keywordMapper.getResultByTypeId(keywordId, questionId,
                keyword.getNum(), typeId);
        vo.setNowList(nowList);
        if (keyword.getNum()>1){
            List<PlatformProportionVO> beforeList = keywordMapper.getResultByTypeId(keywordId, questionId,
                    keyword.getNum()-1, typeId);
            vo.setBeforeList(beforeList);
        }
        List<PlatformProportionVO> result = keywordMapper.getResultByTypeId(keywordId, questionId,
                keyword.getNum() - isNow, typeId);
        return ResponseResult.success(vo);
        return ResponseResult.success(result);
    }
    /**
@@ -137,30 +141,22 @@
     */
    @GetMapping("/getResultByPlatformId")
    @ApiOperation(value = "根据平台查看")
    public ResponseResult<ResultByPlatformVO> getResultByPlatformId(@RequestParam("keywordId") Integer keywordId,
    public ResponseResult<List<ResultListVO>> getResultByPlatformId(@RequestParam("keywordId") Integer keywordId,
            @RequestParam(value = "questionId", required = false) Integer questionId,
            @RequestParam(value = "platformId", required = false) Integer platformId) {
        ResultByPlatformVO vo = new ResultByPlatformVO();
            @RequestParam(value = "platformId", required = false) Integer platformId,
            @RequestParam(value = "isNow") Integer isNow) {
        Keyword keyword = keywordService.getById(keywordId);
        List<ResultListVO> nowList = keywordMapper.getResultByPlatformId(keywordId, questionId, keyword.getNum(),
        List<ResultListVO> result = keywordMapper.getResultByPlatformId(keywordId, questionId, keyword.getNum() - isNow,
                platformId);
        vo.setNowList(nowList);
        if (keyword.getNum()>1){
            List<ResultListVO> beforeList = keywordMapper.getResultByPlatformId(keywordId, questionId, keyword.getNum()-1,
                    platformId);
            vo.setBeforeList(beforeList);
        }
        return ResponseResult.success(vo);
        return ResponseResult.success(result);
    }
    /**
     * 根据平台查看 0-当前轮 1-代表前1轮 2-代表前2轮
     */
    @GetMapping("/exportGetResultByPlatformId")
    @ApiOperation(value = "根据平台查看")
    @ApiOperation(value = "导出:根据平台查看")
    public ResponseEntity<byte[]> exportGetResultByPlatformId(@RequestParam("id") Integer keywordId,
            @RequestParam(value = "questionId", required = false) Integer questionId,
            @RequestParam(value = "platformId", required = false) Integer platformId,
@@ -212,7 +208,40 @@
     */
    @PostMapping("/importFeed")
    @ApiOperation("投喂")
    public ResponseResult<List<FeedExportExcel>> importTemplate(@RequestParam("file") MultipartFile file) {
    public ResponseResult<List<FeedExportExcel>> importTemplate(@RequestParam("file") MultipartFile file,@RequestParam("keywordId") Integer keywordId) {
        Keyword keyword = keywordService.getById(keywordId);
        //查找出最近一次的结果
        List<FeedExportExcel> references = referenceMapper.importTemplateList(keywordId,keyword.getNum());
        //平台名称
        Map<String, FeedExportExcel> nameMap = references.stream()
                .collect(Collectors.toMap(
                        FeedExportExcel::getPlatform_name,  // Key映射
                        excel -> excel,  // Value映射
                        (oldValue, newValue) -> oldValue  // 键冲突处理(保留旧值)
                ));
        //URL
        Map<String, FeedExportExcel> urlMap = references.stream()
                .collect(Collectors.toMap(
                        FeedExportExcel::getUrl,  // Key映射
                        excel -> excel,  // Value映射
                        (oldValue, newValue) -> oldValue  // 键冲突处理(保留旧值)
                ));
        //title
        Map<String, FeedExportExcel> titleMap = references.stream()
                .collect(Collectors.toMap(
                        FeedExportExcel::getTitle,  // Key映射
                        excel -> excel,  // Value映射
                        (oldValue, newValue) -> oldValue  // 键冲突处理(保留旧值)
                ));
        //time
        Map<LocalDateTime, FeedExportExcel> timeMap = references.stream()
                .collect(Collectors.toMap(
                        FeedExportExcel::getCreate_time,  // Key映射
                        excel -> excel,  // Value映射
                        (oldValue, newValue) -> oldValue  // 键冲突处理(保留旧值)
                ));
        try {
            // 检查文件是否为空
            if (file.isEmpty()) {
@@ -242,27 +271,87 @@
                    errorMessages.add("发布时间不能为空");
                    continue;
                }
                if (!StringUtils.hasText(excel.getUrl())) {
                    errorMessages.add("发布网址不能为空");
                    continue;
                }
                //todo 查询出当前这次的结果 做出对比
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                LocalDateTime dateTime = LocalDateTime.parse(excel.getCreate_time(), formatter);
                excel.setCreateTimeAsDateTime(dateTime);
                FeedExportExcel feedExportExcel = getFeedExportExcel(excel, nameMap, urlMap, titleMap, timeMap);
                result.add(feedExportExcel);
            }
            // 处理错误
            if (!errorMessages.isEmpty()) {
                return ResponseResult.error("数据验证失败: " + String.join("; ", errorMessages));
            }
            // 返回信息
            return ResponseResult.success(result);
        } catch (Exception e) {
        }catch (DateTimeParseException e) {
            return ResponseResult.error("文件解析失败:发布时间格式输入错误");
        }
        catch (Exception e) {
            // 记录详细异常信息
            return ResponseResult.error("文件解析失败:" + e.getMessage());
        }
    }
    private FeedExportExcel getFeedExportExcel(ReferenceExcel excel, Map<String, FeedExportExcel> nameMap, Map<String, FeedExportExcel> urlMap, Map<String, FeedExportExcel> titleMap, Map<LocalDateTime, FeedExportExcel> timeMap) {
        FeedExportExcel vo=new FeedExportExcel();
        vo.setPlatform_name(excel.getPlatform_name());
        vo.setTitle(excel.getTitle());
        vo.setCreate_time(excel.getCreateTimeAsDateTime());
        vo.setUrl(excel.getUrl());
        vo.setInclusionStatus("未收录");
        vo.setPlatformIs(0);
        vo.setTitleIs(0);
        vo.setUrlIs(0);
        vo.setCreateIs(0);
        //平台名称
        if (nameMap.containsKey(excel.getPlatform_name())) {
            vo.setPlatformIs(1);
            if (urlMap.containsKey(excel.getUrl())) {
                vo.setUrlIs(1);
            }
            if (titleMap.containsKey(excel.getTitle())) {
                vo.setTitleIs(1);
            }
            if (timeMap.containsKey(excel.getCreateTimeAsDateTime())) {
                vo.setCreateIs(1);
            }
            return vo;
        }
        //网站链接
        if (urlMap.containsKey(excel.getUrl())) {
            vo.setUrlIs(1);
            if (titleMap.containsKey(excel.getTitle())) {
                vo.setTitleIs(1);
            }
            if (timeMap.containsKey(excel.getCreateTimeAsDateTime())) {
                vo.setCreateIs(1);
            }
            return vo;
        }
        //标题
        if (titleMap.containsKey(excel.getTitle())) {
            vo.setTitleIs(1);
            if (timeMap.containsKey(excel.getCreateTimeAsDateTime())) {
                vo.setCreateIs(1);
            }
        }
        //时间
        if (timeMap.containsKey(excel.getCreateTimeAsDateTime())) {
            vo.setCreateIs(1);
            return vo;
        }
        return vo;
    }
    /**
     * 导出投喂结果
@@ -332,7 +421,7 @@
    // 下载模板
    @PostMapping("/downloadTemplate")
    @ApiOperation("下载模板")
    @ApiOperation("下载关键词导入模板")
    public ResponseEntity<byte[]> downloadTemplate() throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        EasyExcel.write(out, KeywordExcel.class).sheet("关键词模板").doWrite(new ArrayList<>());
src/main/java/com/linghu/controller/OrderController.java
@@ -5,6 +5,7 @@
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.linghu.model.common.ResponseResult;
import com.linghu.model.entity.Orders;
import com.linghu.model.dto.KeywordDto;
import com.linghu.model.dto.OrderDto;
import com.linghu.service.OrderService;
@@ -136,9 +137,9 @@
     */
    @GetMapping
    @ApiOperation("查询订单列表")
    public ResponseResult<List<Orders>> list(
            @RequestParam(required = false) Integer pageNum,
            @RequestParam(required = false) Integer pageSize,
    public ResponseResult<Page<Orders>> list(
            @RequestParam(required = false,defaultValue = "1") Integer pageNum ,
            @RequestParam(required = false,defaultValue = "10") Integer pageSize ,
            @RequestParam(required = false) String clientName,
            @RequestParam(required = false) Integer status,
            @RequestParam(required = false) String createTime) {
@@ -158,14 +159,15 @@
        }
        // 分页查询
        if (pageNum != null && pageSize != null) {
            Page<Orders> pageInfo = new Page<>(pageNum, pageSize);
            Page<Orders> result = orderService.page(pageInfo, queryWrapper);
            return ResponseResult.success(result.getRecords());
            return ResponseResult.success(result);
        }
        // 不分页
        List<Orders> list = orderService.list(queryWrapper);
        return ResponseResult.success(list);
    @GetMapping("/{orderId}/keywordList")
    @ApiOperation("获取订单关联的关键词及提问词")
    public ResponseResult<List<KeywordDto>> getKeywordList(@PathVariable String orderId) {
        List<KeywordDto> result = orderService.getKeywordListByOrderId(orderId);
        return ResponseResult.success(result);
    }
}
src/main/java/com/linghu/controller/PlatformController.java
@@ -3,8 +3,10 @@
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.linghu.mapper.ReferenceMapper;
import com.linghu.model.common.ResponseResult;
import com.linghu.model.entity.Platform;
import com.linghu.model.entity.Reference;
import com.linghu.model.entity.Type;
import com.linghu.model.excel.PlatformExcel;
import com.linghu.service.PlatformService;
@@ -38,6 +40,8 @@
    private PlatformService platformService;
    @Autowired
    private TypeService typeService;
    @Autowired
    private ReferenceMapper referenceMapper;
    @PostMapping
    @ApiOperation(value = "添加平台")
@@ -60,6 +64,11 @@
    @DeleteMapping("/{platformId}")
    @ApiOperation(value = "删除平台")
    public ResponseResult<Void> delete(@PathVariable Integer platformId) {
        //平台被引用了没
        Integer count = referenceMapper.selectCount(new LambdaQueryWrapper<Reference>().eq(Reference::getPlatform_id, platformId));
        if (count > 0) {
            return ResponseResult.error("该平台被引用中,不能删除");
        }
        boolean success = platformService.removeById(platformId);
        if (success) {
            return ResponseResult.success();
@@ -96,18 +105,15 @@
    }
    @GetMapping("/list")
    @ApiOperation("查询平台列表,不传页数和大小就查全部")
    public ResponseResult<List<Platform>> list(
            @RequestParam(required = false) Integer page,
            @RequestParam(required = false) Integer pageSize) {
        if (page != null && pageSize != null) {
    @ApiOperation("查询平台列表")
    public ResponseResult<Page<Platform>> list(
            @RequestParam(required = false,defaultValue = "1") Integer page,
            @RequestParam(required = false,defaultValue = "10") Integer pageSize) {
            Page<Platform> pageInfo = new Page<>(page, pageSize);
            Page<Platform> result = platformService.page(pageInfo);
            return ResponseResult.success(result.getRecords());
        } else {
            List<Platform> list = platformService.list();
            return ResponseResult.success(list);
        }
            return ResponseResult.success(result);
    }
    @GetMapping("/download")
src/main/java/com/linghu/controller/TypeController.java
@@ -24,7 +24,6 @@
    @PostMapping
    @ApiOperation(value = "添加类型")
    public ResponseResult<Type> add(@RequestBody Type type) {
        type.setDel_flag(0);
        boolean success = typeService.save(type);
        if (success) {
            return ResponseResult.success(type);
@@ -35,8 +34,6 @@
    @PostMapping("/batch")
    @ApiOperation(value = "批量添加类型")
    public ResponseResult<Void> batchAdd(@RequestBody List<Type> types) {
        types.forEach(type -> type.setDel_flag(0));
        boolean success = typeService.saveBatch(types);
        if (success) {
            return ResponseResult.success();
@@ -49,7 +46,6 @@
    public ResponseResult<Void> delete(@PathVariable Integer typeId) {
        Type type = new Type();
        type.setType_id(typeId);
        type.setDel_flag(1);
        boolean success = typeService.updateById(type);
        if (success) {
            return ResponseResult.success();
@@ -81,7 +77,7 @@
    @ApiOperation(value = "根据ID查询类型")
    public ResponseResult<Type> getById(@PathVariable Integer typeId) {
        Type type = typeService.getById(typeId);
        if (type != null && type.getDel_flag() != 1) {
        if (type != null ) {
            return ResponseResult.success(type);
        }
        return ResponseResult.error("类型不存在");
@@ -93,7 +89,6 @@
        List<Type> types = typeIds.stream().map(id -> {
            Type type = new Type();
            type.setType_id(id);
            type.setDel_flag(1);
            return type;
        }).collect(java.util.stream.Collectors.toList());
        boolean success = typeService.updateBatchById(types);
@@ -109,7 +104,6 @@
            @RequestParam(required = false) Integer page,
            @RequestParam(required = false) Integer pageSize) {
        LambdaQueryWrapper<Type> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Type::getDel_flag, 0);
        if (page != null && pageSize != null) {
            Page<Type> pageInfo = new Page<>(page, pageSize);
src/main/java/com/linghu/mapper/ReferenceMapper.java
@@ -2,6 +2,10 @@
import com.linghu.model.entity.Reference;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linghu.model.excel.FeedExportExcel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author xy
@@ -11,6 +15,7 @@
*/
public interface ReferenceMapper extends BaseMapper<Reference> {
    List<FeedExportExcel> importTemplateList(@Param("keywordId") Integer keywordId, @Param("num")Integer num);
}
src/main/java/com/linghu/model/dto/KeywordDto.java
@@ -2,7 +2,11 @@
 
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
import com.linghu.model.entity.Keyword;
import com.linghu.model.entity.Question;
 
@EqualsAndHashCode(callSuper = true)
@Data
@@ -11,4 +15,6 @@
     * 提问词列表,用换行符分隔
     */
    private String questions;
    private List<Question> questionList;
}
src/main/java/com/linghu/model/dto/OrderDto.java
@@ -4,6 +4,8 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
 * 订单数据传输对象,扩展Order实体
 */
@@ -14,4 +16,6 @@
     * 关键词列表,用换行符分隔
     */
    private String keywords;
    private List<KeywordDto> keywordList;
}
src/main/java/com/linghu/model/entity/Platform.java
@@ -7,6 +7,8 @@
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -21,49 +23,52 @@
         * 平台id
         */
        @TableId(type = IdType.AUTO)
        @ApiModelProperty("平台id")
        private Integer platform_id;
        /**
         * 类型id
         */
        @ApiModelProperty("类型id")
        private Integer type_id;
        /**
         * 平台名称
         */
        @ApiModelProperty("平台名称")
        private String platform_name;
        /**
         * 平台域名
         */
        @ApiModelProperty("平台域名")
        private String domain;
        /**
         * 
         */
        @ApiModelProperty("创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS", timezone = "GMT+8")
        private LocalDateTime create_time;
        /**
         * 
         */
        @ApiModelProperty("创建者")
        private String create_by;
        /**
         * 
         */
        @ApiModelProperty("修改时间")
        @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS", timezone = "GMT+8")
        private LocalDateTime update_time;
        /**
         * 
         */
        @ApiModelProperty("创建者")
        private String update_by;
        /**
         * 0-未删除,1-已删除
         */
        private Integer del_flag;
        @TableField(exist = false)
        private static final long serialVersionUID = 1L;
@@ -95,9 +100,7 @@
                                && (this.getUpdate_time() == null ? other.getUpdate_time() == null
                                                : this.getUpdate_time().equals(other.getUpdate_time()))
                                && (this.getUpdate_by() == null ? other.getUpdate_by() == null
                                                : this.getUpdate_by().equals(other.getUpdate_by()))
                                && (this.getDel_flag() == null ? other.getDel_flag() == null
                                                : this.getDel_flag().equals(other.getDel_flag()));
                                                : this.getUpdate_by().equals(other.getUpdate_by()));
        }
        @Override
@@ -112,7 +115,6 @@
                result = prime * result + ((getCreate_by() == null) ? 0 : getCreate_by().hashCode());
                result = prime * result + ((getUpdate_time() == null) ? 0 : getUpdate_time().hashCode());
                result = prime * result + ((getUpdate_by() == null) ? 0 : getUpdate_by().hashCode());
                result = prime * result + ((getDel_flag() == null) ? 0 : getDel_flag().hashCode());
                return result;
        }
@@ -130,7 +132,6 @@
                sb.append(", create_by=").append(create_by);
                sb.append(", update_time=").append(update_time);
                sb.append(", update_by=").append(update_by);
                sb.append(", del_flag=").append(del_flag);
                sb.append(", serialVersionUID=").append(serialVersionUID);
                sb.append("]");
                return sb.toString();
src/main/java/com/linghu/model/entity/Type.java
@@ -25,10 +25,6 @@
     */
    private String type_name;
    /**
     * 0-未删除 1-删除
     */
    private Integer del_flag;
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
@@ -46,8 +42,7 @@
        }
        Type other = (Type) that;
        return (this.getType_id() == null ? other.getType_id() == null : this.getType_id().equals(other.getType_id()))
            && (this.getType_name() == null ? other.getType_name() == null : this.getType_name().equals(other.getType_name()))
            && (this.getDel_flag() == null ? other.getDel_flag() == null : this.getDel_flag().equals(other.getDel_flag()));
            && (this.getType_name() == null ? other.getType_name() == null : this.getType_name().equals(other.getType_name()));
    }
    @Override
@@ -56,7 +51,6 @@
        int result = 1;
        result = prime * result + ((getType_id() == null) ? 0 : getType_id().hashCode());
        result = prime * result + ((getType_name() == null) ? 0 : getType_name().hashCode());
        result = prime * result + ((getDel_flag() == null) ? 0 : getDel_flag().hashCode());
        return result;
    }
@@ -68,7 +62,6 @@
        sb.append("Hash = ").append(hashCode());
        sb.append(", type_id=").append(type_id);
        sb.append(", type_name=").append(type_name);
        sb.append(", del_flag=").append(del_flag);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
src/main/java/com/linghu/model/excel/ReferenceExcel.java
@@ -6,6 +6,7 @@
import java.time.LocalDateTime;
@Data
public class ReferenceExcel {
    @ExcelProperty("平台名称")
@@ -15,9 +16,11 @@
    private String title;
    @ExcelProperty("发布时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime create_time;
    private String create_time;
    @ExcelProperty("发布网址")
    private String url;
    private LocalDateTime createTimeAsDateTime;
}
src/main/java/com/linghu/model/vo/KeywordStaticsVO.java
@@ -12,11 +12,11 @@
public class KeywordStaticsVO {
    @ApiModelProperty("发布平台")
    @ExcelProperty("发布平台")
    private String platformName;
    private String platform_name;
    @ApiModelProperty("重复次数")
    @ExcelProperty("重复次数")
    private Integer totalRepetitions;
    private Integer total_repetitions;
    @ApiModelProperty("平台分布占比")
    @ExcelProperty("平台分布占比")
    private BigDecimal repetitionRatio;
    private BigDecimal repetition_ratio;
}
src/main/java/com/linghu/model/vo/PlatformProportionVO.java
@@ -15,22 +15,22 @@
    @ApiModelProperty("类型名称")
    @ExcelProperty("全部类型")
    private String typeName;
    private String type_name;
    @ApiModelProperty("平台名称")
    @ExcelProperty("平台名称")
    private String platformName;
    private String platform_name;
    @ApiModelProperty("重复次数")
    @ExcelProperty("重复次数")
    private Integer totalRepetitions;
    private Integer total_repetitions;
    @ApiModelProperty("全平台分布占比")
    @ExcelProperty("全平台分布占比")
    private BigDecimal allPlatformRatio;
    private BigDecimal all_platform_ratio;
    @ApiModelProperty("同类平台分布占比")
    @ExcelProperty("同类平台分布占比")
    private BigDecimal sameTypeRatio;
    private BigDecimal same_type_ratio;
}
src/main/java/com/linghu/model/vo/ReferenceVO.java
New file
@@ -0,0 +1,4 @@
package com.linghu.model.vo;
public class ReferenceVO {
}
src/main/java/com/linghu/model/vo/ResultListVO.java
@@ -13,11 +13,11 @@
public class ResultListVO {
    @ApiModelProperty("结果id")
    private Integer referenceId;
    private Integer reference_id;
    @ApiModelProperty("平台名称")
    @ExcelProperty("全部平台")
    private String platformName;
    private String platform_name;
    @ApiModelProperty("标题")
    @ExcelProperty("标题")
@@ -25,12 +25,12 @@
    @ApiModelProperty("重复次数")
    @ExcelProperty("重复次数")
    private Integer repetitionNum;
    private Integer repetition_num;
    @ApiModelProperty("发布时间")
    @ExcelProperty("发布时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    private LocalDateTime create_time;
    @ExcelProperty("发布网址")
    private String url;
}
src/main/java/com/linghu/service/OrderService.java
@@ -1,7 +1,11 @@
package com.linghu.service;
import com.linghu.model.entity.Orders;
import com.linghu.model.dto.KeywordDto;
import com.linghu.model.dto.OrderDto;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@@ -19,4 +23,6 @@
     * @return 是否保存成功
     */
    boolean saveOrderWithKeywords(OrderDto orderDto,String order_id);
    List<KeywordDto> getKeywordListByOrderId(String order_id);
}
src/main/java/com/linghu/service/PlatformExcelService.java
@@ -62,7 +62,6 @@
                platform.setDomain(data.getDomain());
                platform.setType_id(type.getType_id());
                platform.setCreate_time(LocalDateTime.now());
                platform.setDel_flag(0);
                platforms.add(platform);
                // 每100条保存一次
src/main/java/com/linghu/service/impl/OrderServiceImpl.java
@@ -1,12 +1,20 @@
package com.linghu.service.impl;
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.Orders;
import com.linghu.model.entity.Question;
import com.linghu.service.KeywordService;
import com.linghu.service.OrderService;
import com.linghu.mapper.OrderMapper;
import java.util.ArrayList;
import java.util.List;
import com.linghu.service.QuestionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -23,11 +31,12 @@
    @Autowired
    private KeywordService keywordService;
    @Autowired
    private QuestionService questionService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrderWithKeywords(OrderDto orderDto,String order_id) {
        // 如果有关键词,则保存关键词
        if (StringUtils.hasText(orderDto.getKeywords())) {
@@ -82,4 +91,26 @@
        return true;
    }
    @Override
    public List<KeywordDto> getKeywordListByOrderId(String orderId) {
        List<Keyword> keywords = keywordService.lambdaQuery()
                .eq(Keyword::getOrder_id, orderId)
                .list();
        // 遍历关键词,获取每个关键词对应的提问词
        List<KeywordDto> keywordDtos = new ArrayList<>();
        for (Keyword keyword : keywords) {
            KeywordDto dto = new KeywordDto();
            BeanUtils.copyProperties(keyword, dto);
            // 查询该关键词下的所有提问词
            List<Question> questions = questionService.lambdaQuery()
                    .eq(Question::getKeyword_id, keyword.getKeyword_id())
                    .list();
            dto.setQuestionList(questions);
            keywordDtos.add(dto);
        }
        return keywordDtos;
    }
}
src/main/java/com/linghu/service/impl/TypeServiceImpl.java
@@ -25,7 +25,6 @@
        // 查询
        LambdaQueryWrapper<Type> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Type::getType_name, typeName);
        queryWrapper.eq(Type::getDel_flag, 0);
        return typeMapper.selectOne(queryWrapper);
    }
src/main/resources/mapper/PlatformMapper.xml
@@ -13,7 +13,6 @@
            <result property="create_by" column="create_by" jdbcType="VARCHAR"/>
            <result property="update_time" column="update_time" jdbcType="TIMESTAMP"/>
            <result property="update_by" column="update_by" jdbcType="VARCHAR"/>
            <result property="del_flag" column="del_flag" jdbcType="TINYINT"/>
    </resultMap>
    <sql id="Base_Column_List">
src/main/resources/mapper/ReferenceMapper.xml
@@ -23,4 +23,19 @@
        num,url,domain,
        task_id
    </sql>
    <select id="importTemplateList" resultType="com.linghu.model.excel.FeedExportExcel">
        SELECT
            p.platform_name,
            r.title,
                r.create_time,
            r.url
        FROM
            `reference` r
                LEFT JOIN platform p on r.platform_id = p.platform_id
        WHERE
            r.keyword_id = #{keywordId}
        and
            r.num = #{num}
    </select>
</mapper>
src/main/resources/mapper/TypeMapper.xml
@@ -7,7 +7,6 @@
    <resultMap id="BaseResultMap" type="com.linghu.model.entity.Type">
            <id property="type_id" column="type_id" jdbcType="INTEGER"/>
            <result property="type_name" column="type_name" jdbcType="VARCHAR"/>
            <result property="del_flag" column="del_flag" jdbcType="TINYINT"/>
    </resultMap>
    <sql id="Base_Column_List">
src/main/resources/mapper/keywordMapper.xml
@@ -44,7 +44,6 @@
        </if>
        AND r.num = #{num}
        AND p.del_flag = 0
        GROUP BY
        p.platform_id,
        p.platform_name
@@ -93,8 +92,6 @@
            <if test="typeId != null">
                AND p.type_id = #{typeId}
            </if>
            AND p.del_flag = 0
            AND t.del_flag = 0
        GROUP BY
        t.type_id, t.type_name, p.platform_id, p.platform_name
        ORDER BY
@@ -121,7 +118,6 @@
            <if test="platformId != null">
                AND r.platform_id = #{platformId}
            </if>
            AND p.del_flag = 0
        ORDER BY
        r.create_time DESC
    </select>