Browse Source

楼栋信息导入 按需求变更修改【需求:只能导入当前登录人所属组织下数据,匹配不上的数据舍弃,将匹配不上的数据给到前端提示 如南宁社区不存在】

master
sunyuchao 4 years ago
parent
commit
436504300e
  1. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
  2. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
  3. 28
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java

@ -188,8 +188,7 @@ public class BuildingController {
}
List<IcBuildingExcel> result =importResult.getList();
buildingService.importExcel(customerId,result);
return new Result().ok("导入成功");
return new Result().ok(buildingService.importExcel(customerId,result,tokenDTO.getUserId()));
}
/**

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java

@ -17,13 +17,13 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcNeighborHoodExcel;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -53,7 +53,7 @@ public interface BuildingService {
List<BuildingTreeLevelDTO> treeList(String customerId);
void importExcel(String customerId, List<IcBuildingExcel> list);
Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId);
IcNeighborHoodResultDTO listBuilding(ListIcNeighborHoodFormDTO formDTO);

28
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java

@ -4,9 +4,12 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.*;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.CustomerStaffAgencyDTO;
@ -207,10 +210,23 @@ public class BuildingServiceImpl implements BuildingService {
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcel(String customerId, List<IcBuildingExcel> list) {
public Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId) {
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
Iterator<IcBuildingExcel> iterator = list.iterator();
while (iterator.hasNext()) {
IcBuildingExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return ;
return new Result();
}
//查询所有组织和网格根据名字
@ -235,6 +251,10 @@ public class BuildingServiceImpl implements BuildingService {
entity.setId(uuid);
entity.setCustomerId(customerId);
entity.setNeighborHoodId(Optional.ofNullable(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName())).map(u->u.getId()).orElse(""));//neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId()
if ("".equals(entity.getNeighborHoodId())) {
str.append("".equals(str) ? icBuildingExcel.getNeighborHoodName() : str.append("、").append(icBuildingExcel.getNeighborHoodName()));
continue;
}
entity.setBuildingName(icBuildingExcel.getBuildingName());
entity.setType(BuildingTypeEnums.getKeyByValue(icBuildingExcel.getType()));
entity.setSort(0);
@ -266,6 +286,10 @@ public class BuildingServiceImpl implements BuildingService {
icBuildingService.insertBatch(buildingEntityList);
icBuildingUnitService.insertBatch(icBuildingUnitEntityList);
if(!"".equals(str)){
return new Result().error(9999, str.append("不存在").toString());
}
return new Result();
}
@Override

Loading…
Cancel
Save