guyue
2025-08-12 ff1fec7eae681e89e607fd441d2597ab67b5ed2a
修改查看时间和删除关键词
5个文件已修改
50 ■■■■■ 已修改文件
src/main/java/com/linghu/controller/KeywordController.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/entity/KeywordTask.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/model/vo/GetTimeVO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/service/impl/CollectionServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/service/impl/KeywordServiceImpl.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/linghu/controller/KeywordController.java
@@ -1,6 +1,7 @@
package com.linghu.controller;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linghu.config.FinalStatus;
import com.linghu.listener.KeywordExcelListener;
import com.linghu.model.common.ResponseResult;
@@ -18,6 +19,7 @@
import com.linghu.model.vo.ResultListVO;
import com.linghu.service.KeywordService;
import com.linghu.service.OrderService;
import com.linghu.service.ReferenceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -47,6 +49,9 @@
    @Autowired
    private ReferenceService referenceService;
    @Autowired
    private OrderService orderService;
    /**
     * 关键词统计 EChart图
@@ -211,7 +216,17 @@
        if(FinalStatus.SUBMITTED.getValue().equals(keyword.getStatus())){
            return ResponseResult.error("关键词已开始采集或不允许删除!");
        }
        keywordService.removeById(keywordId);
        //找到订单
        Orders order = orderService.getById(keyword.getOrder_id());
        //更新关键词数量
        LambdaQueryWrapper<Keyword> queryKeywordsQueryWrapper =  new LambdaQueryWrapper<>();
        queryKeywordsQueryWrapper.eq(Keyword::getOrder_id, keyword.getOrder_id());
        int count1 = (int) keywordService.count(queryKeywordsQueryWrapper);
        order.setKeyword_num(count1);
        orderService.updateById(order);
        return ResponseResult.success("删除成功");
    }
src/main/java/com/linghu/model/entity/KeywordTask.java
@@ -5,6 +5,8 @@
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@@ -32,6 +34,7 @@
    private String status;
    private Integer num;
    private String error;
    private Date create_time;
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
src/main/java/com/linghu/model/vo/GetTimeVO.java
@@ -7,15 +7,16 @@
import java.time.LocalDateTime;
import java.util.Date;
@Data
public class GetTimeVO {
    @ApiModelProperty("本次采集时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime now;
    private Date now;
    @ApiModelProperty("首次采集时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime first;
    private Date first;
}
src/main/java/com/linghu/service/impl/CollectionServiceImpl.java
@@ -396,6 +396,7 @@
            KeywordTask keywordTask = new KeywordTask();
            keywordTask.setKeyword_id(keywordId);
            keywordTask.setTask_id(null);  // 任务ID为空
            keywordTask.setCreate_time(new Date());
            keywordTask.setNum(keyword.getNum());
            keywordTaskService.save(keywordTask);  // 保存 KeywordTask
src/main/java/com/linghu/service/impl/KeywordServiceImpl.java
@@ -16,6 +16,7 @@
import com.linghu.model.dto.ExportGetResultDTO;
import com.linghu.model.dto.ExportStaticsDTO;
import com.linghu.model.entity.Keyword;
import com.linghu.model.entity.KeywordTask;
import com.linghu.model.entity.Platform;
import com.linghu.model.entity.Reference;
import com.linghu.model.excel.FeedExportExcel;
@@ -25,6 +26,7 @@
import com.linghu.service.KeywordService;
import com.linghu.mapper.KeywordMapper;
import com.linghu.service.KeywordTaskService;
import com.linghu.service.PlatformService;
import com.linghu.service.ReferenceService;
import org.apache.poi.ss.usermodel.DataValidation;
@@ -67,6 +69,8 @@
    private ReferenceMapper referenceMapper;
    @Autowired
    private PlatformService platformService;
    @Autowired
    private KeywordTaskService keywordTaskService;
    @Override
    public ResponseResult<KeywordStaticsListVO> statics(Integer keywordId, Integer questionId) {
@@ -137,26 +141,20 @@
        GetTimeVO vo = new GetTimeVO();
        Keyword keyword = this.getById(keywordId);
        LambdaQueryWrapper<Reference> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Reference::getKeyword_id, keywordId);
        if (questionId != null) {
            queryWrapper.eq(Reference::getQuestion_id, questionId);
        }
        queryWrapper.eq(Reference::getNum,keyword.getNum());
        LambdaQueryWrapper<KeywordTask> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(KeywordTask::getKeyword_id, keywordId);
        queryWrapper.eq(KeywordTask::getNum,keyword.getNum());
        List<Reference> list = referenceService.list(queryWrapper);
        List<KeywordTask> list = keywordTaskService.list(queryWrapper);
        if (null != list && !list.isEmpty()) {
            vo.setNow(list.get(0).getCreate_time());
        }
        //首次
        LambdaQueryWrapper<Reference> queryWrapper2 = new LambdaQueryWrapper<>();
        queryWrapper2.eq(Reference::getKeyword_id, keywordId);
        if (questionId != null) {
            queryWrapper2.eq(Reference::getQuestion_id, questionId);
        }
        queryWrapper2.eq(Reference::getNum,1);
        LambdaQueryWrapper<KeywordTask> queryWrapper2 = new LambdaQueryWrapper<>();
        queryWrapper2.eq(KeywordTask::getKeyword_id, keywordId);
        queryWrapper2.eq(KeywordTask::getNum,1);
        List<Reference> list2 = referenceService.list(queryWrapper2);
        List<KeywordTask> list2 = keywordTaskService.list(queryWrapper2);
        if (null != list2 && !list2.isEmpty()) {
            vo.setFirst(list2.get(0).getCreate_time());
        }