From 5798cc736c2ed2d49fbcdf22c92ff79caf3a7f50 Mon Sep 17 00:00:00 2001 From: 21819 Date: Fri, 23 Feb 2024 15:06:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=A1=E4=BB=B6=E6=A0=B8=E5=AF=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/biutag/lan/controller/work/WorkController.java | 4 +++- .../src/main/java/com/biutag/lan/service/ExcelService.java | 6 ++++-- .../main/java/com/biutag/lan/service/MailSourceService.java | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java index 66e8eea..7ffaf57 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/work/WorkController.java @@ -49,7 +49,9 @@ public class WorkController { @Transactional(rollbackFor = Exception.class) public AjaxResult importExcel(@RequestBody String workVoList) { List data = JSON.parseArray(workVoList, WorkVo.class); - return workService.saveExcelBatch(data) && mailSourceService.saveExcelBatch(data) ? AjaxResult.success() : AjaxResult.failed("导入失败"); + workService.saveExcelBatch(data); + mailSourceService.saveExcelBatch(data); + return AjaxResult.success(); } @NotPower diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java index 02ee12f..78d2e53 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/ExcelService.java @@ -39,11 +39,13 @@ public class ExcelService implements ReadListener { .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 (WorkVo workVo : excelDatalist) { + 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); - break; + i--; // 减去索引以补偿移除的元素 + break; // 一旦找到匹配并移除,跳出内循环 } } } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailSourceService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailSourceService.java index 3d48320..19e6aa1 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailSourceService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailSourceService.java @@ -48,6 +48,9 @@ public class MailSourceService extends ServiceImpl List list = mailSources.stream().map(mail -> { MailSource mail1 = new MailSource(); BeanUtils.copyProperties(mail, mail1); + mail1.setId(mail.getMailId()) + .setState(mail.getMailState()); + return mail1; }).filter(mail -> { QueryWrapper queryWrapper = new QueryWrapper()