修改物资设备清单导入修改
This commit is contained in:
		| @ -140,7 +140,7 @@ public class ExcelReader { | |||||||
|                 isFirstRow = false; |                 isFirstRow = false; | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|  |             if(hasValidData(row)){ | ||||||
|                 List<String> rowData = new ArrayList<>(); |                 List<String> rowData = new ArrayList<>(); | ||||||
|                 // 读取A到E列(索引0到4) |                 // 读取A到E列(索引0到4) | ||||||
|                 for (int cellIndex = 0; cellIndex < 6; cellIndex++) { |                 for (int cellIndex = 0; cellIndex < 6; cellIndex++) { | ||||||
| @ -160,9 +160,24 @@ public class ExcelReader { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |  | ||||||
|         sheetData.setData(data); |         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; | ||||||
|  |     } | ||||||
|     /** |     /** | ||||||
|      * 根据数据构建树形结构 |      * 根据数据构建树形结构 | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -87,16 +87,8 @@ public class TenderSupplierInputController extends BaseController { | |||||||
|     @PostMapping("/import") |     @PostMapping("/import") | ||||||
|     public R<Void> importData(Long projectId,@RequestParam("file")MultipartFile file) throws IOException { |     public R<Void> importData(Long projectId,@RequestParam("file")MultipartFile file) throws IOException { | ||||||
|         List<TenderSupplierInputVo> tenderSupplierInputVos = ExcelUtil.importExcel(file.getInputStream(), TenderSupplierInputVo.class); |         List<TenderSupplierInputVo> tenderSupplierInputVos = ExcelUtil.importExcel(file.getInputStream(), TenderSupplierInputVo.class); | ||||||
|         List<TenderSupplierInput> tenderSupplierInputs = new ArrayList<>(); |  | ||||||
|  |  | ||||||
|         for (TenderSupplierInputVo tenderSupplierInputVo : tenderSupplierInputVos) { |         return toAjax(tenderSupplierInputService.importData(tenderSupplierInputVos,projectId)); | ||||||
|             TenderSupplierInput newTenderSupplierInput = new TenderSupplierInput(); |  | ||||||
|             BeanUtils.copyProperties(tenderSupplierInputVo, newTenderSupplierInput); |  | ||||||
|             newTenderSupplierInput.setProjectId(projectId); |  | ||||||
|             newTenderSupplierInput.setState("draft"); |  | ||||||
|             tenderSupplierInputs.add(newTenderSupplierInput); |  | ||||||
|         } |  | ||||||
|         return toAjax(tenderSupplierInputService.saveOrUpdateBatch(tenderSupplierInputs)); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -72,4 +72,6 @@ ITenderSupplierInputService extends IService<TenderSupplierInput>{ | |||||||
|     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); | ||||||
|  |  | ||||||
|     List<TenderSupplierInputVo> getList(TenderSupplierInputBo bo); |     List<TenderSupplierInputVo> getList(TenderSupplierInputBo bo); | ||||||
|  |  | ||||||
|  |     boolean importData(List<TenderSupplierInputVo> tenderSupplierInputVos, Long projectId); | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,11 +3,9 @@ package org.dromara.tender.service.impl; | |||||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
| import org.dromara.cailiaoshebei.controller.constant; | 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.domain.event.ProcessEvent; | ||||||
| import org.dromara.common.core.enums.BusinessStatusEnum; | import org.dromara.common.core.enums.BusinessStatusEnum; | ||||||
| import org.dromara.common.core.exception.ServiceException; | 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.MapstructUtils; | ||||||
| import org.dromara.common.core.utils.StringUtils; | import org.dromara.common.core.utils.StringUtils; | ||||||
| import org.dromara.common.mybatis.core.page.TableDataInfo; | 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.conditions.query.LambdaQueryWrapper; | ||||||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||||
| import lombok.RequiredArgsConstructor; | 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.domain.vo.SysOssVo; | ||||||
| import org.dromara.system.service.ISysOssService; | 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.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import org.dromara.tender.domain.bo.TenderSupplierInputBo; | import org.dromara.tender.domain.bo.TenderSupplierInputBo; | ||||||
| @ -35,7 +31,6 @@ import java.util.List; | |||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
|  |  | ||||||
| import static org.dromara.common.constant.MinioPathConstant.ContactNoticeTemplate; |  | ||||||
| import static org.dromara.common.constant.MinioPathConstant.SupplierInput; | import static org.dromara.common.constant.MinioPathConstant.SupplierInput; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @ -222,6 +217,24 @@ public class TenderSupplierInputServiceImpl extends ServiceImpl<TenderSupplierIn | |||||||
|         return list; |         return list; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean importData(List<TenderSupplierInputVo> tenderSupplierInputVos, Long projectId) { | ||||||
|  |         List<TenderSupplierInput> tenderSupplierInputs = new ArrayList<>(); | ||||||
|  |         for (TenderSupplierInputVo tenderSupplierInputVo : tenderSupplierInputVos) { | ||||||
|  |             Long count = baseMapper.selectCount(new LambdaQueryWrapper<TenderSupplierInput>().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); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等) |      * 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user