10 changed files with 204 additions and 24 deletions
@ -0,0 +1,54 @@
|
||||
package com.biutag.lan.service; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.excel.context.AnalysisContext; |
||||
import com.alibaba.excel.read.listener.ReadListener; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.biutag.lan.domain.Work; |
||||
import com.biutag.lan.domain.bo.MailQuery; |
||||
import com.biutag.lan.domain.vo.WorkVo; |
||||
import com.biutag.lan.mapper.WorkMapper; |
||||
import lombok.Getter; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Getter |
||||
public class ExcelService implements ReadListener<WorkVo> { |
||||
private List<Work> dbDatalist; |
||||
private List<WorkVo> excelDatalist = new ArrayList<>(); |
||||
|
||||
private List<WorkVo> result; |
||||
|
||||
private final WorkMapper workMapper; |
||||
private final MailQuery mailQuery; |
||||
|
||||
public ExcelService(WorkMapper workMapper, MailQuery mailQuery) { |
||||
this.workMapper = workMapper; |
||||
this.mailQuery = mailQuery; |
||||
} |
||||
|
||||
@Override |
||||
public void invoke(WorkVo workVo, AnalysisContext analysisContext) { |
||||
excelDatalist.add(workVo); |
||||
} |
||||
|
||||
@Override |
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
||||
QueryWrapper<Work> queryWrapper = new QueryWrapper<Work>() |
||||
.ge(StrUtil.isNotBlank(mailQuery.getMailTimeStart()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD')", mailQuery.getMailTimeStart()) |
||||
.le(StrUtil.isNotBlank(mailQuery.getMailTimeStartEnd()), "TO_CHAR(m.mail_time, 'YYYY-MM-DD')", mailQuery.getMailTimeStartEnd()); |
||||
dbDatalist = workMapper.selectList(queryWrapper); |
||||
for (int i = 0; i < excelDatalist.size(); i++) { |
||||
WorkVo workVo = excelDatalist.get(i); |
||||
for (Work work : dbDatalist) { |
||||
if (work.getMailId().equals(workVo.getMailId())) { |
||||
excelDatalist.remove(workVo); |
||||
i--; // 减去索引以补偿移除的元素
|
||||
break; // 一旦找到匹配并移除,跳出内循环
|
||||
} |
||||
} |
||||
} |
||||
result = excelDatalist; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue