diff --git a/xinnengyuan/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/coryUtils/ExcelReader.java b/xinnengyuan/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/coryUtils/ExcelReader.java index ded3f0a4..d9d8689b 100644 --- a/xinnengyuan/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/coryUtils/ExcelReader.java +++ b/xinnengyuan/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/coryUtils/ExcelReader.java @@ -140,29 +140,44 @@ public class ExcelReader { isFirstRow = false; continue; } + if(hasValidData(row)){ + List rowData = new ArrayList<>(); + // 读取A到E列(索引0到4) + for (int cellIndex = 0; cellIndex < 6; cellIndex++) { + Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); + rowData.add(getCellValue(cell)); + } - List rowData = new ArrayList<>(); - // 读取A到E列(索引0到4) - for (int cellIndex = 0; cellIndex < 6; cellIndex++) { - Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); - rowData.add(getCellValue(cell)); + // 检查是否找到中文数字开头的行 + String aColumnValue = rowData.get(0).trim(); + if (aColumnValue.matches(CHINESE_NUMBERS_REGEX)) { + foundChineseStart = true; + } + + // 只有找到中文数字开头的行之后,才开始收集数据 + if (foundChineseStart) { + data.add(rowData); + } } - // 检查是否找到中文数字开头的行 - String aColumnValue = rowData.get(0).trim(); - if (aColumnValue.matches(CHINESE_NUMBERS_REGEX)) { - foundChineseStart = true; - } - - // 只有找到中文数字开头的行之后,才开始收集数据 - if (foundChineseStart) { - data.add(rowData); - } } sheetData.setData(data); } + private static boolean hasValidData(Row row) { + // 遍历行中的所有单元格 + for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) { + Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); + String cellValue = getCellValue(cell).trim(); + + // 只要有一个单元格有非空值,就认为是有效行 + if (!cellValue.isEmpty()) { + return true; + } + } + return false; + } /** * 根据数据构建树形结构 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/controller/TenderSupplierInputController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/controller/TenderSupplierInputController.java index 2dd2006e..a5229138 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/controller/TenderSupplierInputController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/controller/TenderSupplierInputController.java @@ -87,16 +87,8 @@ public class TenderSupplierInputController extends BaseController { @PostMapping("/import") public R importData(Long projectId,@RequestParam("file")MultipartFile file) throws IOException { List tenderSupplierInputVos = ExcelUtil.importExcel(file.getInputStream(), TenderSupplierInputVo.class); - List tenderSupplierInputs = new ArrayList<>(); - for (TenderSupplierInputVo tenderSupplierInputVo : tenderSupplierInputVos) { - TenderSupplierInput newTenderSupplierInput = new TenderSupplierInput(); - BeanUtils.copyProperties(tenderSupplierInputVo, newTenderSupplierInput); - newTenderSupplierInput.setProjectId(projectId); - newTenderSupplierInput.setState("draft"); - tenderSupplierInputs.add(newTenderSupplierInput); - } - return toAjax(tenderSupplierInputService.saveOrUpdateBatch(tenderSupplierInputs)); + return toAjax(tenderSupplierInputService.importData(tenderSupplierInputVos,projectId)); } /** diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/service/ITenderSupplierInputService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/service/ITenderSupplierInputService.java index 09746cde..e4e43bd2 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/service/ITenderSupplierInputService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/service/ITenderSupplierInputService.java @@ -72,4 +72,6 @@ ITenderSupplierInputService extends IService{ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); List getList(TenderSupplierInputBo bo); + + boolean importData(List tenderSupplierInputVos, Long projectId); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/service/impl/TenderSupplierInputServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/service/impl/TenderSupplierInputServiceImpl.java index 5dceb8ea..a5ac83dc 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/service/impl/TenderSupplierInputServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/tender/service/impl/TenderSupplierInputServiceImpl.java @@ -3,11 +3,9 @@ package org.dromara.tender.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.dromara.cailiaoshebei.controller.constant; -import org.dromara.cailiaoshebei.domain.BusCailiaoshebeiPici; import org.dromara.common.core.domain.event.ProcessEvent; import org.dromara.common.core.enums.BusinessStatusEnum; import org.dromara.common.core.exception.ServiceException; -import org.dromara.common.core.service.OssService; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.TableDataInfo; @@ -16,11 +14,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; -import org.dromara.formalities.enums.FormalitiesStatusEnum; -import org.dromara.system.domain.vo.SysOssUploadVo; import org.dromara.system.domain.vo.SysOssVo; import org.dromara.system.service.ISysOssService; -import org.dromara.tender.domain.BusBiddingPlan; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.dromara.tender.domain.bo.TenderSupplierInputBo; @@ -35,7 +31,6 @@ import java.util.List; import java.util.Map; import java.util.Collection; -import static org.dromara.common.constant.MinioPathConstant.ContactNoticeTemplate; import static org.dromara.common.constant.MinioPathConstant.SupplierInput; /** @@ -222,6 +217,24 @@ public class TenderSupplierInputServiceImpl extends ServiceImpl tenderSupplierInputVos, Long projectId) { + List tenderSupplierInputs = new ArrayList<>(); + for (TenderSupplierInputVo tenderSupplierInputVo : tenderSupplierInputVos) { + Long count = baseMapper.selectCount(new LambdaQueryWrapper().eq(TenderSupplierInput::getSupplierCode, tenderSupplierInputVo.getSupplierCode())); + if (count > 0) { + continue; + } + TenderSupplierInput newTenderSupplierInput = new TenderSupplierInput(); + BeanUtils.copyProperties(tenderSupplierInputVo, newTenderSupplierInput); + newTenderSupplierInput.setProjectId(projectId); + newTenderSupplierInput.setState("draft"); + tenderSupplierInputs.add(newTenderSupplierInput); + } + + return baseMapper.insertBatch(tenderSupplierInputs); + } + /** * 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)