| | |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserRoleClient; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2024/8/7 19:54 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class SiteServiceImpl extends ServiceImpl<SiteMapper, Site> implements ISiteService { |
| | | |
| | | static final int SITE_IMPORT_TITLE_ROWS = 1; |
| | | |
| | | @Resource |
| | | private TChargingGunService chargingGunService; |
| | |
| | | ExcelUtil<SiteExcelDTO> util = new ExcelUtil<>(SiteExcelDTO.class); |
| | | List<SiteExcelDTO> rows; |
| | | try (InputStream inputStream = file.getInputStream()) { |
| | | rows = util.importExcel(inputStream, 0); |
| | | rows = util.importExcel(inputStream, SITE_IMPORT_TITLE_ROWS); |
| | | } catch (Exception e) { |
| | | throw new ServiceException("Excel文件已损坏或格式不正确,请重新下载站点导入模板后填写") |
| | | log.error("站点Excel解析失败,fileName={},size={}", file.getOriginalFilename(), file.getSize(), e); |
| | | ServiceException exception = new ServiceException("Excel文件已损坏或格式不正确,请重新下载站点导入模板后填写") |
| | | .setDetailMessage(e.getMessage()); |
| | | exception.initCause(e); |
| | | throw exception; |
| | | } |
| | | if (rows == null || rows.isEmpty()) { |
| | | throw new ServiceException("导入文件没有数据"); |
| | |
| | | Set<String> duplicateCodes = new LinkedHashSet<>(); |
| | | for (int i = 0; i < rows.size(); i++) { |
| | | SiteExcelDTO row = rows.get(i); |
| | | int rowNum = i + 2; |
| | | int rowNum = i + SITE_IMPORT_TITLE_ROWS + 2; |
| | | List<String> errors = validateSiteImportRow(row, partnerMap, strategyMap, regionByCode, regionById, |
| | | roleType, objectId, fileCodes); |
| | | String code = row == null ? null : normalizeImportValue(row.getCode()); |