Browse Source

小区、楼宇、房屋导入程序调整

master
sunyuchao 4 years ago
parent
commit
71ad799c19
  1. 22
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
  2. 16
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  3. 22
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
  4. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
  5. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
  6. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java
  7. 17
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  8. 19
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  9. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java

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

@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -47,10 +48,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -180,15 +179,24 @@ public class BuildingController {
List<IcBuildingExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if(!CollectionUtils.isEmpty(failList)){
for ( IcBuildingExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
return new Result().error(8001,failList.get(0).getErrorMsg());
//return new Result().error(8001,failList.get(0).getErrorMsg());
}
List<IcBuildingExcel> result =importResult.getList();
return new Result().ok(buildingService.importExcel(customerId,result,tokenDTO.getUserId()));
List<Integer> resultList = buildingService.importExcel(customerId,result,tokenDTO.getUserId(),numList);
String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size());
if(resultList.size()> NumConstant.ZERO){
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}
/**

16
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java

@ -21,6 +21,7 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -42,6 +43,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -145,15 +147,25 @@ public class HouseController {
List<IcHouseExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if(!CollectionUtils.isEmpty(failList)){
for ( IcHouseExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
return new Result().error(8001,failList.get(0).getErrorMsg());
//return new Result().error(8001,failList.get(0).getErrorMsg());
}
List<IcHouseExcel> result =importResult.getList();
return new Result().ok(houseService.importExcel(customerId,result,tokenDTO.getUserId()));
List<Integer> resultList = houseService.importExcel(customerId,result,tokenDTO.getUserId(),numList);
String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size());
if(resultList.size()> NumConstant.ZERO){
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}
@PostMapping( "queryListHouseInfo")

22
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java

@ -22,6 +22,7 @@ import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -45,10 +46,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -207,16 +206,25 @@ public class NeighborHoodController {
// List<IcNeighborHoodExcel> result = ExcelPoiUtils.importExcel(file, 0, 1, IcNeighborHoodExcel.class);
List<IcNeighborHoodExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if(!CollectionUtils.isEmpty(failList)){
for ( IcNeighborHoodExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
return new Result().error(8001,failList.get(0).getErrorMsg());
//return new Result().error(8001,failList.get(0).getErrorMsg());
}
List<IcNeighborHoodExcel> result =importResult.getList();
// log.info(JSON.toJSONString(result));
neighborHoodService.importExcel(customerId,result,tokenDTO.getUserId());
return new Result();
List<Integer> resultList = neighborHoodService.importExcel(customerId,result,tokenDTO.getUserId(),numList);
String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size());
if(resultList.size()> NumConstant.ZERO){
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}

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

@ -17,7 +17,6 @@
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;
@ -53,7 +52,7 @@ public interface BuildingService {
List<BuildingTreeLevelDTO> treeList(String customerId);
Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId);
List<Integer> importExcel(String customerId, List<IcBuildingExcel> list, String staffId, List<Integer> numList);
IcNeighborHoodResultDTO listBuilding(ListIcNeighborHoodFormDTO formDTO);

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java

@ -17,7 +17,6 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.HouseInfoDTO;
@ -48,7 +47,7 @@ public interface HouseService {
void delHouse(String houseId);
Result importExcel(String customerId, List<IcHouseExcel> list, String staffId);
List<Integer> importExcel(String customerId, List<IcHouseExcel> list, String staffId, List<Integer> numList);
IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO);

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java

@ -52,5 +52,5 @@ public interface NeighborHoodService{
*/
void exportNeighborhoodinfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception ;
void importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId);
List<Integer> importExcel(String customerId, List<IcNeighborHoodExcel> list, String staffId, List<Integer> numList);
}

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

@ -9,7 +9,6 @@ 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;
@ -210,7 +209,7 @@ public class BuildingServiceImpl implements BuildingService {
@Override
@Transactional(rollbackFor = Exception.class)
public Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId) {
public List<Integer> importExcel(String customerId, List<IcBuildingExcel> list, String staffId, List<Integer> numList) {
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
@ -218,15 +217,16 @@ public class BuildingServiceImpl implements BuildingService {
while (iterator.hasNext()) {
IcBuildingExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
numList.add(obj.getRowNum());
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
StringBuffer str = new StringBuffer("");
//StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return new Result();
return numList;
}
//查询所有组织和网格根据名字
@ -252,7 +252,8 @@ public class BuildingServiceImpl implements BuildingService {
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()));
//str.append("".equals(str) ? icBuildingExcel.getNeighborHoodName() : str.append("、").append(icBuildingExcel.getNeighborHoodName()));
numList.add(icBuildingExcel.getRowNum());
continue;
}
entity.setBuildingName(icBuildingExcel.getBuildingName());
@ -286,10 +287,10 @@ public class BuildingServiceImpl implements BuildingService {
icBuildingService.insertBatch(buildingEntityList);
icBuildingUnitService.insertBatch(icBuildingUnitEntityList);
if(!"".equals(str)){
/* if(!"".equals(str)){
return new Result().error(9999, str.append("不存在").toString());
}
return new Result();
}*/
return numList;
}
@Override

19
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java

@ -8,7 +8,6 @@ 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.IcBuildingDao;
import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dao.IcHouseDao;
@ -24,7 +23,6 @@ import com.epmet.entity.IcHouseEntity;
import com.epmet.enums.HousePurposeEnums;
import com.epmet.enums.HouseRentFlagEnums;
import com.epmet.enums.HouseTypeEnums;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcHouseExcel;
import com.epmet.service.HouseService;
import com.epmet.service.IcBuildingService;
@ -123,7 +121,8 @@ public class HouseServiceImpl implements HouseService {
}
@Override
public Result importExcel(String customerId, List<IcHouseExcel> list, String staffId) {
@Transactional(rollbackFor = Exception.class)
public List<Integer> importExcel(String customerId, List<IcHouseExcel> list, String staffId, List<Integer> numList) {
//2021.11.10 需求变更 当前工作人员只能导致自己所属组织下数据,对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
@ -131,15 +130,16 @@ public class HouseServiceImpl implements HouseService {
while (iterator.hasNext()) {
IcHouseExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
numList.add(obj.getRowNum());
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
StringBuffer str = new StringBuffer("");
//StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return new Result();
return numList;
}
//获取所有小区 list
// List<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList());
@ -173,7 +173,8 @@ public class HouseServiceImpl implements HouseService {
entity.setBuildingUnitId(String.valueOf(Optional.ofNullable(item).map(u->u.get("buildingUnitId")).orElse("")));
entity.setHouseName(icHouseExcel.getBuildingName()+"-"+icHouseExcel.getBuildingUnit()+"-"+icHouseExcel.getDoorName());
if ("".equals(entity.getNeighborHoodId()) || "".equals(entity.getBuildingId()) || "".equals(entity.getBuildingUnitId())) {
str.append("".equals(str) ? icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit() : str.append("、").append(icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit()));
//str.append("".equals(str) ? icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit() : str.append("、").append(icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit()));
numList.add(icHouseExcel.getRowNum());
continue;
}
entity.setDoorName(icHouseExcel.getDoorName());
@ -193,10 +194,10 @@ public class HouseServiceImpl implements HouseService {
//3.保存
icHouseService.insertBatch(houseEntityList);
if(!"".equals(str)){
/*if(!"".equals(str)){
return new Result().error(9999, str.append("不存在").toString());
}
return new Result();
}*/
return numList;
}

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java

@ -240,7 +240,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId) {
public List<Integer> importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId, List<Integer> numList) {
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
@ -248,6 +248,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
while (iterator.hasNext()) {
IcNeighborHoodExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
numList.add(obj.getRowNum());
iterator.remove();
}
}
@ -255,7 +256,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
//导入
if(CollectionUtils.isEmpty(list)){
return ;
return numList;
}
//获取所有组织 list
List<String> agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toList());
@ -294,6 +295,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
entity.setGridId(Optional.ofNullable(gridMap.get(icNeighborHoodExcel.getGridName().trim())).map(u->u.getId()).orElse(""));//gridMap.get(icNeighborHoodExcel.getGridName()).getId()
//网格名对应不上的数据舍弃
if ("".equals(entity.getGridId())) {
numList.add(icNeighborHoodExcel.getRowNum());
continue;
}
entity.setAddress(icNeighborHoodExcel.getAddress());
@ -312,6 +314,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
icNeighborHoodService.insertBatch(neighborHoodEntityList);
icNeighborHoodPropertyService.insertBatch(icNeighborHoodPropertyEntityList);
return numList;
}

Loading…
Cancel
Save