| | |
| | | |
| | | @Override |
| | | public String importExcel(List<RsSceneryOperationData> list) { |
| | | List<String> sceneryInfoNames = new ArrayList<>(); |
| | | Set<String> sceneryInfoNames = new HashSet<>(); |
| | | // 查询数据库是否存在导入的景区 |
| | | Map<String, RsSceneryInfo> sceneryInfoMap = sceneryInfoMapper.selectList().stream() |
| | | .collect(Collectors.toMap(RsSceneryInfo::getSceneryName, Function.identity())); |
| | | for (RsSceneryOperationData operationData : list) { |
| | | String sceneryName = operationData.getSceneryInfoName(); |
| | | RsSceneryInfo sceneryInfo = sceneryInfoMap.get(sceneryName); |
| | | // 景区已存在,正常导入 |
| | | if (sceneryInfo != null) { |
| | | operationData.setSceneryInfoId(sceneryInfo.getId()); |
| | | operationData.setPeriod(operationData.getPeriodDate().length() > 4 ? 1L : 2L); |
| | | operationData.setCreateTime(new Date()); |
| | | operationData.setStatus(1L); |
| | | } else { |
| | | sceneryInfoNames.add(operationData.getSceneryInfoName()); |
| | | } |
| | | } |
| | | if (!sceneryInfoNames.isEmpty()) { |
| | | return "很抱歉,导入失败!" + String.join("、", sceneryInfoNames) + "景区不存在,请前往【景区配置】添加后重试!"; |
| | | return "很抱歉,导入失败!" + String.join("、", "<" + sceneryInfoNames + ">") + "景区不存在,请前往【景区配置】添加后重试!"; |
| | | } |
| | | // // 其余数据禁用 |
| | | // LambdaUpdateWrapper<RsSceneryOperationData> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | // updateWrapper.ne(RsSceneryOperationData::getId, operationData.getId()).eq(RsSceneryOperationData::getSceneryInfoId, operationData.getSceneryInfoId()).set(RsSceneryOperationData::getStatus, 2); |
| | | // baseMapper.update(updateWrapper); |
| | | baseMapper.insertBatch(list); |
| | | return "恭喜您,数据已全部导入成功!共" + list.size() + "条!"; |
| | | } |