|
@ -18,6 +18,7 @@ |
|
|
package com.epmet.modules.partymember.service.impl; |
|
|
package com.epmet.modules.partymember.service.impl; |
|
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
@ -109,6 +110,7 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
item.setGridName(gridInfo.getGridName()); |
|
|
item.setGridName(gridInfo.getGridName()); |
|
|
|
|
|
//导出时新增分类名称
|
|
|
IcPartymemberStyleCategoryDictEntity dict = icPartymemberStyleCategoryDictService.get(item.getCategoryId()); |
|
|
IcPartymemberStyleCategoryDictEntity dict = icPartymemberStyleCategoryDictService.get(item.getCategoryId()); |
|
|
item.setCategoryName(null == dict ? StrConstant.EPMETY_STR : dict.getCategoryName()); |
|
|
item.setCategoryName(null == dict ? StrConstant.EPMETY_STR : dict.getCategoryName()); |
|
|
} |
|
|
} |
|
@ -228,7 +230,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException { |
|
|
public Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException { |
|
|
ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); |
|
|
ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); |
|
|
|
|
|
|
|
|
List<IcPartymemberStyleImportExcel> failList = importResult.getFailList(); |
|
|
List<IcPartymemberStyleImportExcel> failList = importResult.getFailList(); |
|
|
|
|
|
log.info("excel中的数据校验失败:"+JSON.toJSONString(failList,true)); |
|
|
//存放错误数据行号
|
|
|
//存放错误数据行号
|
|
|
List<Integer> numList = new ArrayList<>(); |
|
|
List<Integer> numList = new ArrayList<>(); |
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(failList)) { |
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(failList)) { |
|
@ -249,8 +253,10 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember |
|
|
throw new EpmetException(gridOptionResult.getCode(), gridOptionResult.getMsg()); |
|
|
throw new EpmetException(gridOptionResult.getCode(), gridOptionResult.getMsg()); |
|
|
} |
|
|
} |
|
|
Map<String, String> gridMap = gridOptionResult.getData().stream().collect(Collectors.toMap(CustomerGridDTO::getGridName, CustomerGridDTO::getId)); |
|
|
Map<String, String> gridMap = gridOptionResult.getData().stream().collect(Collectors.toMap(CustomerGridDTO::getGridName, CustomerGridDTO::getId)); |
|
|
|
|
|
//获取党员风采所有分类:key:分类名称;
|
|
|
|
|
|
Map<String,IcPartymemberStyleCategoryDictEntity> categoryDictMap=icPartymemberStyleCategoryDictService.getCategoryDictMap(tokenDto.getCustomerId()); |
|
|
//1.数据校验 只允许导入当前组织下的网格的数据
|
|
|
//1.数据校验 只允许导入当前组织下的网格的数据
|
|
|
//网格名称不一样的数据舍弃
|
|
|
//网格名称不一样的数据舍弃或者分类名称不存在也舍弃
|
|
|
Iterator<IcPartymemberStyleImportExcel> iterator = result.iterator(); |
|
|
Iterator<IcPartymemberStyleImportExcel> iterator = result.iterator(); |
|
|
while (iterator.hasNext()) { |
|
|
while (iterator.hasNext()) { |
|
|
IcPartymemberStyleImportExcel obj = iterator.next(); |
|
|
IcPartymemberStyleImportExcel obj = iterator.next(); |
|
@ -258,6 +264,12 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember |
|
|
numList.add(obj.getRowNum()); |
|
|
numList.add(obj.getRowNum()); |
|
|
log.warn(String.format("不是当前组织下可导入的数据,网格名称->%s,行号->%s", obj.getGridName(), obj.getRowNum())); |
|
|
log.warn(String.format("不是当前组织下可导入的数据,网格名称->%s,行号->%s", obj.getGridName(), obj.getRowNum())); |
|
|
iterator.remove(); |
|
|
iterator.remove(); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if (null == categoryDictMap.get(obj.getCategoryName().trim())) { |
|
|
|
|
|
numList.add(obj.getRowNum()); |
|
|
|
|
|
log.warn(String.format("分类名称【%s】不存在,不可导入,行号->%s", obj.getCategoryName(), obj.getRowNum())); |
|
|
|
|
|
iterator.remove(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (CollectionUtils.isEmpty(result)) { |
|
|
if (CollectionUtils.isEmpty(result)) { |
|
@ -274,7 +286,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember |
|
|
entity.setGridId(gridMap.get(item.getGridName())); |
|
|
entity.setGridId(gridMap.get(item.getGridName())); |
|
|
entity.setName(item.getName()); |
|
|
entity.setName(item.getName()); |
|
|
entity.setMainDeed(item.getMainDeed()); |
|
|
entity.setMainDeed(item.getMainDeed()); |
|
|
|
|
|
IcPartymemberStyleCategoryDictEntity dictEntity=categoryDictMap.get(item.getCategoryName()); |
|
|
|
|
|
entity.setCategoryId(null == dictEntity ? StrConstant.EPMETY_STR : dictEntity.getId()); |
|
|
|
|
|
entity.setCategoryCode(null == dictEntity ? StrConstant.EPMETY_STR : dictEntity.getCategoryCode()); |
|
|
AtomicInteger i = new AtomicInteger(); |
|
|
AtomicInteger i = new AtomicInteger(); |
|
|
if (StringUtils.isNotBlank(item.getImageUrl())) { |
|
|
if (StringUtils.isNotBlank(item.getImageUrl())) { |
|
|
Arrays.asList(item.getImageUrl().split(StrConstant.COMMA)).forEach(url -> { |
|
|
Arrays.asList(item.getImageUrl().split(StrConstant.COMMA)).forEach(url -> { |
|
|