Browse Source

Merge branch 'dev_optimize' of http://git.elinkit.com.cn:7070/r/epmet-cloud into develop

master
jianjun 3 years ago
parent
commit
d843d7622e
  1. 56
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
  2. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  3. 115
      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/model/BuildingErrorInfoModel.java
  5. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java
  6. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java
  7. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java
  8. 1
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java
  9. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java
  10. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java
  11. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java
  12. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
  13. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java
  14. 122
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  15. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java
  16. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java
  17. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  18. 152
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
  19. 4
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml
  20. 3
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
  21. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

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

@ -18,12 +18,10 @@
package com.epmet.controller; package com.epmet.controller;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
@ -34,9 +32,11 @@ import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dto.BuildingTreeLevelDTO; import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcBuildingListResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.entity.IcBuildingUnitEntity; import com.epmet.entity.IcBuildingUnitEntity;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.BuildingService; import com.epmet.service.BuildingService;
import com.epmet.util.ExcelPoiUtils; import com.epmet.util.ExcelPoiUtils;
@ -49,8 +49,9 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.ArrayList;
import java.util.stream.Collectors; import java.util.HashMap;
import java.util.List;
/** /**
@ -134,10 +135,7 @@ public class BuildingController {
@PostMapping("exporttemplate") @PostMapping("exporttemplate")
public void exportTemplate( HttpServletResponse response) throws Exception { public void exportTemplate( HttpServletResponse response) throws Exception {
TemplateExportParams templatePath = new TemplateExportParams("excel/building_template.xlsx"); TemplateExportParams templatePath = new TemplateExportParams("excel/building_template.xlsx");
Map<String,Object> map = new HashMap<>(); ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"楼栋信息录入表",response);
map.put("maplist",new ArrayList<IcBuildingExcel>());
ExcelPoiUtils.exportExcel(templatePath ,map,"楼栋信息录入表",response);
} }
/** /**
* 导出 * 导出
@ -149,7 +147,6 @@ public class BuildingController {
public void exportbuildinginfo(@RequestBody IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception { public void exportbuildinginfo(@RequestBody IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(formDTO); ValidatorUtils.validateEntity(formDTO);
buildingService.exportBuildinginfo(formDTO,response); buildingService.exportBuildinginfo(formDTO,response);
} }
/** /**
@ -166,43 +163,6 @@ public class BuildingController {
} }
/**
* 导入数据
* @param file
* @return
* @throws IOException
*/
@PostMapping("import")
public Result importExcel(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file) throws IOException {
String customerId = tokenDTO.getCustomerId();
// String customerId = "123123";
ExcelImportResult<IcBuildingExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcBuildingExcel.class);
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());
}
List<IcBuildingExcel> result =importResult.getList();
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("、"));
log.warn(str + "第" + subList + "行未成功!");
return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}
/** /**
* @Description 楼宇导入 * @Description 楼宇导入
* @param tokenDTO * @param tokenDTO

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

@ -47,9 +47,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Set;
/** /**
@ -167,7 +165,7 @@ public class HouseController implements ResultDataResolver {
@PostMapping("exporttemplate") @PostMapping("exporttemplate")
public void exportTemplate(HttpServletResponse response) throws Exception { public void exportTemplate(HttpServletResponse response) throws Exception {
TemplateExportParams templatePath = new TemplateExportParams("excel/house_template.xlsx"); TemplateExportParams templatePath = new TemplateExportParams("excel/house_template.xlsx");
ExcelPoiUtils.exportExcel(templatePath, null, "房屋信息录入表", response); ExcelPoiUtils.exportExcel(templatePath, new HashMap<>(), "房屋信息录入表", response);
} }

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

@ -18,12 +18,9 @@
package com.epmet.controller; package com.epmet.controller;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
@ -33,23 +30,20 @@ import com.epmet.dto.form.IcNeighborHoodAddFormDTO;
import com.epmet.dto.form.IcNeighborHoodListFormDTO; import com.epmet.dto.form.IcNeighborHoodListFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.entity.IcBuildingEntity; import com.epmet.entity.IcBuildingEntity;
import com.epmet.excel.IcNeighborHoodExcel;
import com.epmet.service.BuildingService;
import com.epmet.service.HouseService;
import com.epmet.service.IcNeighborHoodService;
import com.epmet.service.NeighborHoodService; import com.epmet.service.NeighborHoodService;
import com.epmet.util.ExcelPoiUtils; import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.util.HashMap;
import java.util.*; import java.util.List;
import java.util.stream.Collectors;
/** /**
@ -63,20 +57,12 @@ import java.util.stream.Collectors;
@RequestMapping("neighborhood") @RequestMapping("neighborhood")
public class NeighborHoodController { public class NeighborHoodController {
@Autowired
private IcNeighborHoodService icNeighborHoodService;
@Autowired @Autowired
private NeighborHoodService neighborHoodService; private NeighborHoodService neighborHoodService;
@Autowired
private BuildingService buildingService;
@Autowired
private HouseService houseService;
@Resource @Resource
private IcBuildingDao icBuildingDao; private IcBuildingDao icBuildingDao;
@PostMapping("neighborhoodlist") @PostMapping("neighborhoodlist")
public Result<IcNeighborHoodResultDTO> neighborhoodlist(@RequestBody IcNeighborHoodListFormDTO formDTO){ public Result<IcNeighborHoodResultDTO> neighborhoodlist(@RequestBody IcNeighborHoodListFormDTO formDTO){
//效验数据 //效验数据
@ -140,94 +126,7 @@ public class NeighborHoodController {
*/ */
@PostMapping("exporttemplate") @PostMapping("exporttemplate")
public void exportTemplate( HttpServletResponse response) throws Exception { public void exportTemplate( HttpServletResponse response) throws Exception {
// ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_template.xlsx"); TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_template.xlsx");
Map<String,Object> map = new HashMap<>(); ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"小区信息录入表",response);
map.put("maplist",new ArrayList<IcNeighborHoodExcel>());
ExcelPoiUtils.exportExcel(templatePath ,map,"小区信息录入表",response);
} }
/**
* 导出模板
* @param response
* @throws Exception
*/
/*@GetMapping("export")
public void export( HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_template.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",new ArrayList<IcNeighborHoodExcel>());
ExcelPoiUtils.exportExcel(templatePath ,map,"小区信息录入表",response);
}*/
/**
* 导出
* @param response
* @throws Exception
*/
/* @RequestMapping("exportinfo")
public void exportinfo(HttpServletResponse response) throws Exception {
ListIcNeighborHoodFormDTO formDTO = new ListIcNeighborHoodFormDTO();
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class);
neighborHoodService.exportNeighborhoodinfo(formDTO,response);
}*/
// /**
// * 导入
// * @param params
// * @param response
// * @throws Exception
// */
// @PostMapping("importneighborhoodinfo")
// public void importneighborhoodinfo(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
// List<IcNeighborHoodDTO> list = icNeighborHoodService.list(params);
// ExcelUtils.exportExcelToTarget(response, "小区信息录入表", list, IcNeighborHoodExcel.class);
//// ExcelUtils.expor
// }
/**
* 导入数据
* @param file
* @return
* @throws IOException
*/
@PostMapping("import")
public Result importExcel(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file) throws IOException {
String customerId = tokenDTO.getCustomerId();
// String customerId = "123123";
ExcelImportResult<IcNeighborHoodExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcNeighborHoodExcel.class);
// 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.warn("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
//return new Result().error(8001,failList.get(0).getErrorMsg());
}
List<IcNeighborHoodExcel> result =importResult.getList();
// log.info(JSON.toJSONString(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("、"));
log.warn(str + "第" + subList + "行未成功!");
return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!");
}
return new Result().ok(str);
}
} }

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java

@ -12,6 +12,9 @@ import lombok.Data;
@Data @Data
public class BuildingErrorInfoModel { public class BuildingErrorInfoModel {
@Excel(name = "行号", width = 20)
private Integer num;
@Excel(name = "小区名称" , width = 20) @Excel(name = "小区名称" , width = 20)
private String neighborHoodName; private String neighborHoodName;

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java

@ -1,5 +1,6 @@
package com.epmet.model; package com.epmet.model;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data; import lombok.Data;
@ -35,4 +36,7 @@ public class BuildingInfoModel {
@ExcelProperty(value = "户数") @ExcelProperty(value = "户数")
private Integer totalHouseNum; private Integer totalHouseNum;
@ExcelIgnore
private Integer num;
} }

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java

@ -13,7 +13,7 @@ import org.hibernate.validator.constraints.Length;
@Data @Data
public class HouseErrorInfoModel { public class HouseErrorInfoModel {
@Excel(name = "行号(不计算表头)", width = 20) @Excel(name = "行号", width = 20)
private Integer num; private Integer num;
@Excel(name = "所属小区", width = 20) @Excel(name = "所属小区", width = 20)

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java

@ -86,6 +86,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class);
dto.setNum(num); dto.setNum(num);
dto.setCustomerId(formDTO.getCustomerId()); dto.setCustomerId(formDTO.getCustomerId());
info.setNum(num);
if(StringUtils.isBlank(data.getAgencyName())){ if(StringUtils.isBlank(data.getAgencyName())){
nums.add(num); nums.add(num);
disposeErrorMsg(info, "所属组织的值未填写"); disposeErrorMsg(info, "所属组织的值未填写");
@ -384,6 +385,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
public void disposeErrorMsg(BuildingInfoModel data,String msg){ public void disposeErrorMsg(BuildingInfoModel data,String msg){
BuildingErrorInfoModel err = ConvertUtils.sourceToTarget(data, BuildingErrorInfoModel.class); BuildingErrorInfoModel err = ConvertUtils.sourceToTarget(data, BuildingErrorInfoModel.class);
err.setErrorMsg(msg); err.setErrorMsg(msg);
err.setNum(err.getNum() + NumConstant.ONE);
errorInfos.add(err); errorInfos.add(err);
} }

1
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java

@ -208,6 +208,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
public void disposeErrorMsg(HouseInfoModel data,String msg){ public void disposeErrorMsg(HouseInfoModel data,String msg){
HouseErrorInfoModel err = ConvertUtils.sourceToTarget(data, HouseErrorInfoModel.class); HouseErrorInfoModel err = ConvertUtils.sourceToTarget(data, HouseErrorInfoModel.class);
err.setErrorMsg(msg); err.setErrorMsg(msg);
err.setNum(err.getNum() + NumConstant.ONE);
errorInfos.add(err); errorInfos.add(err);
} }

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java

@ -86,6 +86,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
} }
info = data; info = data;
num = num + NumConstant.ONE; num = num + NumConstant.ONE;
info.setNum(num);
if (StringUtils.isBlank(data.getNeighborHoodName()) || if (StringUtils.isBlank(data.getNeighborHoodName()) ||
StringUtils.isBlank(data.getGridName()) || StringUtils.isBlank(data.getAgencyName()) || StringUtils.isBlank(data.getAddress())){ StringUtils.isBlank(data.getGridName()) || StringUtils.isBlank(data.getAgencyName()) || StringUtils.isBlank(data.getAddress())){
nums.add(num); nums.add(num);
@ -333,6 +334,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
public void disposeErrorMsg(NeighborHoodInfoModel data,String msg){ public void disposeErrorMsg(NeighborHoodInfoModel data,String msg){
NeighborHoodErrorInfoModel err = ConvertUtils.sourceToTarget(data, NeighborHoodErrorInfoModel.class); NeighborHoodErrorInfoModel err = ConvertUtils.sourceToTarget(data, NeighborHoodErrorInfoModel.class);
err.setErrorMsg(msg); err.setErrorMsg(msg);
err.setNum(err.getNum() + NumConstant.ONE);
errorInfos.add(err); errorInfos.add(err);
} }

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java

@ -12,6 +12,9 @@ import lombok.Data;
@Data @Data
public class NeighborHoodErrorInfoModel { public class NeighborHoodErrorInfoModel {
@Excel(name = "行号", width = 20)
private Integer num;
@Excel(name = "小区名称", width = 20) @Excel(name = "小区名称", width = 20)
private String neighborHoodName; private String neighborHoodName;

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java

@ -1,5 +1,6 @@
package com.epmet.model; package com.epmet.model;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data; import lombok.Data;
@ -29,4 +30,7 @@ public class NeighborHoodInfoModel {
@ExcelProperty(value = "备注") @ExcelProperty(value = "备注")
private String remark; private String remark;
@ExcelIgnore
private Integer num;
} }

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

@ -28,7 +28,6 @@ import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO; import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcBuildingListResultDTO; import com.epmet.dto.result.IcBuildingListResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.excel.IcBuildingExcel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
@ -61,8 +60,6 @@ public interface BuildingService {
List<BuildingTreeLevelDTO> treeList(String customerId, String staffId); List<BuildingTreeLevelDTO> treeList(String customerId, String staffId);
List<String> treeIds(String customerId, String staffId); List<String> treeIds(String customerId, String staffId);
List<Integer> importExcel(String customerId, List<IcBuildingExcel> list, String staffId, List<Integer> numList);
PageData<IcBuildingListResultDTO> listBuilding(IcBuildingListFormDTO formDTO); PageData<IcBuildingListResultDTO> listBuilding(IcBuildingListFormDTO formDTO);
void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception ; void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception ;

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

@ -22,10 +22,8 @@ import com.epmet.dto.form.IcHouseListFormDTO;
import com.epmet.dto.form.IcNeighborHoodAddFormDTO; import com.epmet.dto.form.IcNeighborHoodAddFormDTO;
import com.epmet.dto.form.IcNeighborHoodListFormDTO; import com.epmet.dto.form.IcNeighborHoodListFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcNeighborHoodExcel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* 小区表 * 小区表
@ -53,6 +51,4 @@ public interface NeighborHoodService{
* @param response * @param response
*/ */
void exportNeighborhoodinfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception ; void exportNeighborhoodinfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception ;
List<Integer> importExcel(String customerId, List<IcNeighborHoodExcel> list, String staffId, List<Integer> numList);
} }

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

@ -152,7 +152,6 @@ public class BuildingServiceImpl implements BuildingService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
//2.获取组织所在网格 //2.获取组织所在网格
List<String> agencyIdList = customerAgencyList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList()); List<String> agencyIdList = customerAgencyList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList());
// agencyIdList.add(customerAgency.getId()); // agencyIdList.add(customerAgency.getId());
@ -181,7 +180,7 @@ public class BuildingServiceImpl implements BuildingService {
List<String> gridIdList = customerGridList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList()); List<String> gridIdList = customerGridList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList());
LambdaQueryWrapper<IcNeighborHoodEntity> queryWrapper = new QueryWrapper<IcNeighborHoodEntity>().lambda() LambdaQueryWrapper<IcNeighborHoodEntity> queryWrapper = new QueryWrapper<IcNeighborHoodEntity>().lambda()
.in(IcNeighborHoodEntity::getGridId, gridIdList) .in(IcNeighborHoodEntity::getGridId, gridIdList)
.last("ORDER BY CAST(NEIGHBOR_HOOD_NAME AS SIGNED), CONVERT(NEIGHBOR_HOOD_NAME using gbk)"); .orderByAsc(IcNeighborHoodEntity::getCreatedTime);
List<IcNeighborHoodEntity> icNeighborHoodList = icNeighborHoodDao.selectList(queryWrapper); List<IcNeighborHoodEntity> icNeighborHoodList = icNeighborHoodDao.selectList(queryWrapper);
if (CollectionUtils.isEmpty(icNeighborHoodList)) { if (CollectionUtils.isEmpty(icNeighborHoodList)) {
agencyList.addAll(gridList); agencyList.addAll(gridList);
@ -205,8 +204,7 @@ public class BuildingServiceImpl implements BuildingService {
List<String> neighborHoodIdList = icNeighborHoodList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList()); List<String> neighborHoodIdList = icNeighborHoodList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList());
LambdaQueryWrapper<IcBuildingEntity> buildingQueryWrapper = new QueryWrapper<IcBuildingEntity>().lambda() LambdaQueryWrapper<IcBuildingEntity> buildingQueryWrapper = new QueryWrapper<IcBuildingEntity>().lambda()
.in(IcBuildingEntity::getNeighborHoodId, neighborHoodIdList) .in(IcBuildingEntity::getNeighborHoodId, neighborHoodIdList)
.last("ORDER BY CAST(BUILDING_NAME AS SIGNED), CONVERT(BUILDING_NAME using gbk)"); .orderByAsc(IcBuildingEntity::getCreatedTime, IcBuildingEntity::getBuildingName);
//.orderByAsc(IcBuildingEntity::getCreatedTime,IcBuildingEntity::getBuildingName);
List<IcBuildingEntity> icBuildingList = icBuildingDao.selectList(buildingQueryWrapper); List<IcBuildingEntity> icBuildingList = icBuildingDao.selectList(buildingQueryWrapper);
if (CollectionUtils.isEmpty(neighborHoodIdList)) { if (CollectionUtils.isEmpty(neighborHoodIdList)) {
@ -300,95 +298,6 @@ public class BuildingServiceImpl implements BuildingService {
return result; return result;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public List<Integer> importExcel(String customerId, List<IcBuildingExcel> list, String staffId, List<Integer> numList) {
//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())) {
numList.add(obj.getRowNum());
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
//StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return numList;
}
//查询所有组织和网格根据名字
//获取所有小区 list 根据组织和网格
Set<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet());
Set<String> agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toSet());
Set<String> gridNameList = list.stream().map(item -> item.getGridName()).collect(Collectors.toSet());
List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectListByName(customerId, new ArrayList<String>(neighborNameList),new ArrayList<String>(agencyNameList),new ArrayList<String>(gridNameList));
// List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper<IcNeighborHoodEntity>().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList));
Map<String,IcNeighborHoodEntity> neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1));
//2.获取小区数据
//封装数据
List<IcBuildingEntity> buildingEntityList = new ArrayList<>();
List<IcBuildingUnitEntity> icBuildingUnitEntityList = new ArrayList<>();
Iterator<IcBuildingExcel> iterator1 = list.iterator();
while (iterator1.hasNext()) {
IcBuildingExcel icBuildingExcel = iterator1.next();
IcBuildingEntity entity = new IcBuildingEntity();
String uuid = UUID.randomUUID().toString().replace("-", "");
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()));
numList.add(icBuildingExcel.getRowNum());
iterator1.remove();
continue;
}
entity.setBuildingName(icBuildingExcel.getBuildingName());
entity.setType(BuildingTypeEnums.getKeyByValue(icBuildingExcel.getType()));
entity.setSort(0);
entity.setTotalUnitNum(icBuildingExcel.getTotalUnitNum());
entity.setTotalFloorNum(icBuildingExcel.getTotalFloorNum());
entity.setTotalHouseNum(icBuildingExcel.getTotalHouseNum());
buildingEntityList.add(entity);
Integer totalUnitNum = icBuildingExcel.getTotalUnitNum();
//设置楼宇单元
List<IcBuildingUnitEntity> unitList = new ArrayList<>();
for(int i =0 ;i<totalUnitNum;i++){
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity();
icBuildingUnit.setBuildingId(uuid);
icBuildingUnit.setCustomerId(customerId);
icBuildingUnit.setUnitName((i + 1) +"单元");
icBuildingUnit.setUnitNum(String.valueOf(i+1));
unitList.add(icBuildingUnit);
}
//同一小区下不能存在楼栋名字一样的
Integer count = icBuildingDao.checkBuildName(entity.getNeighborHoodId(),entity.getBuildingName(),null);
if (null != count && count > 0) {
//throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(),EpmetErrorCode.BUILDING_NAME_EXITED.getMsg());
log.error(EpmetErrorCode.BUILDING_NAME_EXITED.getMsg());
numList.add(icBuildingExcel.getRowNum());
iterator1.remove();
continue;
}
icBuildingUnitEntityList.addAll(unitList);
}
//3.保存
//4.新增单元
icBuildingService.insertBatch(buildingEntityList);
icBuildingUnitService.insertBatch(icBuildingUnitEntityList);
return numList;
}
@Override @Override
public PageData<IcBuildingListResultDTO> listBuilding(IcBuildingListFormDTO formDTO) { public PageData<IcBuildingListResultDTO> listBuilding(IcBuildingListFormDTO formDTO) {
PageInfo<IcBuildingListResultDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> icBuildingDao.searchBuildingByPage(formDTO)); PageInfo<IcBuildingListResultDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> icBuildingDao.searchBuildingByPage(formDTO));
@ -408,10 +317,12 @@ public class BuildingServiceImpl implements BuildingService {
ExcelPoiUtils.exportExcel(templatePath, map, "楼栋信息录入表", response); ExcelPoiUtils.exportExcel(templatePath, map, "楼栋信息录入表", response);
return; return;
} }
@Override @Override
public List<BuildingResultDTO> buildingListByIds(List<String> buildingIdList) { public List<BuildingResultDTO> buildingListByIds(List<String> buildingIdList) {
return icBuildingDao.buildingListByIds(buildingIdList); return icBuildingDao.buildingListByIds(buildingIdList);
} }
@Override @Override
public BuildingResultPagedDTO buildinglistbyidsPage(List<String> buildingIdList, Integer pageNo, Integer pageSize) { public BuildingResultPagedDTO buildinglistbyidsPage(List<String> buildingIdList, Integer pageNo, Integer pageSize) {
IPage<IcBuildingEntity> page = new Page<IcBuildingEntity>(pageNo, pageSize); IPage<IcBuildingEntity> page = new Page<IcBuildingEntity>(pageNo, pageSize);
@ -424,14 +335,14 @@ public class BuildingServiceImpl implements BuildingService {
} }
/** /**
* @param formDTO
* @param inputStream
* @Description 楼宇导入 * @Description 楼宇导入
* 根据左侧树选中的层级可导入对应数据 * 根据左侧树选中的层级可导入对应数据
* 1. 选中社区可导入该社区下所有小区信息楼宇信息房屋信息没有匹配的小区楼宇均新增网格没有对应的不新增 * 1. 选中社区可导入该社区下所有小区信息楼宇信息房屋信息没有匹配的小区楼宇均新增网格没有对应的不新增
* 2. 选中网格可导入该网格下所有小区信息楼宇信息房屋信息没有匹配的小区楼宇均新增 * 2. 选中网格可导入该网格下所有小区信息楼宇信息房屋信息没有匹配的小区楼宇均新增
* 3. 选中小区可导入该小区下所有楼宇信息房屋信息没有匹配的楼宇均新增 * 3. 选中小区可导入该小区下所有楼宇信息房屋信息没有匹配的楼宇均新增
* 4. 选中楼宇可导入该楼宇下所有房屋信息 * 4. 选中楼宇可导入该楼宇下所有房屋信息
* @param formDTO
* @param inputStream
* @author zxc * @author zxc
* @date 2022/2/13 10:15 上午 * @date 2022/2/13 10:15 上午
*/ */
@ -462,20 +373,6 @@ public class BuildingServiceImpl implements BuildingService {
} }
private List<IcBuildingExcel> searchAllBuilding(IcHouseListFormDTO formDTO) { private List<IcBuildingExcel> searchAllBuilding(IcHouseListFormDTO formDTO) {
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
// neighborHoodEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getAgencyId()),IcNeighborHoodEntity::getAgencyId,formDTO.getAgencyId())
// .eq(!StringUtils.isEmpty(formDTO.getGridId()),IcNeighborHoodEntity::getId,formDTO.getGridId())
// .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId())
// .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName());
// IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
// QueryWrapper<IcBuildingEntity> buildingEntityQueryWrapper = new QueryWrapper<>();
// buildingEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getBuildingId()),IcBuildingEntity::getId,formDTO.getBuildingId())
// .like(!StringUtils.isEmpty(formDTO.getBuildingName()),IcBuildingEntity::getBuildingName,formDTO.getBuildingName());
// buildingEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class); IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class);
building.setDelFlag("0"); building.setDelFlag("0");
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class); IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
@ -516,9 +413,9 @@ public class BuildingServiceImpl implements BuildingService {
} }
/** /**
* 更新 * 更新
*
* @param customerId * @param customerId
* @param formDTO * @param formDTO
*/ */
@ -539,10 +436,6 @@ public class BuildingServiceImpl implements BuildingService {
if (!CollectionUtils.isEmpty(icHouseEntities)) { if (!CollectionUtils.isEmpty(icHouseEntities)) {
// //
throw new RenException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(), "楼栋单元下存在房屋,无法更新"); throw new RenException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(), "楼栋单元下存在房屋,无法更新");
// icHouseEntities.forEach(item->{
// item.setNeighborHoodId(formDTO.getNeighborHoodId());
// });
// icHouseService.updateBatchById(icHouseEntities);
} }
} }
IcBuildingDTO icBuildingDTO = ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); IcBuildingDTO icBuildingDTO = ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class);
@ -589,6 +482,7 @@ public class BuildingServiceImpl implements BuildingService {
/** /**
* 删除 * 删除
*
* @param buildingId * @param buildingId
*/ */
@Override @Override

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

@ -120,7 +120,7 @@ public class IcBuildingServiceImpl extends BaseServiceImpl<IcBuildingDao, IcBuil
} }
LambdaQueryWrapper<IcBuildingEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IcBuildingEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcBuildingEntity::getNeighborHoodId, neighborHoodId); wrapper.eq(IcBuildingEntity::getNeighborHoodId, neighborHoodId);
wrapper.last("ORDER BY CAST(BUILDING_NAME AS SIGNED),CONVERT ( BUILDING_NAME USING gbk ) ASC"); wrapper.last("ORDER BY CONVERT ( BUILDING_NAME USING gbk ) ASC");
List<IcBuildingEntity> list = baseDao.selectList(wrapper); List<IcBuildingEntity> list = baseDao.selectList(wrapper);
if(CollectionUtils.isEmpty(list)) { if(CollectionUtils.isEmpty(list)) {
return Collections.emptyList(); return Collections.emptyList();

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

@ -118,7 +118,7 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
LambdaQueryWrapper<IcHouseEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IcHouseEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(formDTO.getBuildingId()), IcHouseEntity::getBuildingId, formDTO.getBuildingId()); wrapper.eq(StringUtils.isNotBlank(formDTO.getBuildingId()), IcHouseEntity::getBuildingId, formDTO.getBuildingId());
wrapper.eq(StringUtils.isNotBlank(formDTO.getUnitId()), IcHouseEntity::getBuildingUnitId, formDTO.getUnitId()); wrapper.eq(StringUtils.isNotBlank(formDTO.getUnitId()), IcHouseEntity::getBuildingUnitId, formDTO.getUnitId());
wrapper.last("ORDER BY CAST(DOOR_NAME AS SIGNED), CONVERT (DOOR_NAME USING gbk )"); wrapper.last("ORDER BY CONVERT ( HOUSE_NAME USING gbk ) ASC");
List<IcHouseEntity> list = baseDao.selectList(wrapper); List<IcHouseEntity> list = baseDao.selectList(wrapper);
if(CollectionUtils.isEmpty(list)) { if(CollectionUtils.isEmpty(list)) {
return Collections.emptyList(); return Collections.emptyList();
@ -160,7 +160,7 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
//查询楼栋下房屋列表 //查询楼栋下房屋列表
LambdaQueryWrapper<IcHouseEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IcHouseEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcHouseEntity::getBuildingId, formDTO.getBuildingId()); wrapper.eq(IcHouseEntity::getBuildingId, formDTO.getBuildingId());
wrapper.last("ORDER BY ORDER BY CAST(DOOR_NAME AS SIGNED), CONVERT (DOOR_NAME USING gbk ), CONVERT ( HOUSE_NAME USING gbk ) ASC"); wrapper.last("ORDER BY CONVERT ( HOUSE_NAME USING gbk ) ASC");
List<IcHouseEntity> list = baseDao.selectList(wrapper); List<IcHouseEntity> list = baseDao.selectList(wrapper);
if(CollectionUtils.isEmpty(list)) { if(CollectionUtils.isEmpty(list)) {
return Collections.emptyList(); return Collections.emptyList();

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

@ -195,7 +195,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
LambdaQueryWrapper<IcNeighborHoodEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IcNeighborHoodEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(agencyId),IcNeighborHoodEntity::getAgencyId, agencyId); wrapper.eq(StringUtils.isNotBlank(agencyId),IcNeighborHoodEntity::getAgencyId, agencyId);
wrapper.eq(StringUtils.isNotBlank(gridId), IcNeighborHoodEntity::getGridId, gridId); wrapper.eq(StringUtils.isNotBlank(gridId), IcNeighborHoodEntity::getGridId, gridId);
wrapper.last("ORDER BY CAST(NEIGHBOR_HOOD_NAME AS SIGNED), CONVERT(NEIGHBOR_HOOD_NAME using gbk)"); wrapper.last("ORDER BY CONVERT ( NEIGHBOR_HOOD_NAME USING gbk ) ASC");
List<IcNeighborHoodEntity> list = baseDao.selectList(wrapper); List<IcNeighborHoodEntity> list = baseDao.selectList(wrapper);
if(CollectionUtils.isEmpty(list)) { if(CollectionUtils.isEmpty(list)) {
return Collections.emptyList(); return Collections.emptyList();

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

@ -2,12 +2,10 @@ package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.enums.OrgTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.NeighborhoodConstant; import com.epmet.constant.NeighborhoodConstant;
@ -19,7 +17,9 @@ import com.epmet.dto.form.IcHouseListFormDTO;
import com.epmet.dto.form.IcNeighborHoodAddFormDTO; import com.epmet.dto.form.IcNeighborHoodAddFormDTO;
import com.epmet.dto.form.IcNeighborHoodListFormDTO; import com.epmet.dto.form.IcNeighborHoodListFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.entity.*; import com.epmet.entity.IcHouseEntity;
import com.epmet.entity.IcNeighborHoodEntity;
import com.epmet.entity.IcNeighborHoodPropertyEntity;
import com.epmet.excel.IcNeighborHoodExcel; import com.epmet.excel.IcNeighborHoodExcel;
import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.IcNeighborHoodPropertyService; import com.epmet.service.IcNeighborHoodPropertyService;
@ -32,15 +32,14 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.*; import java.util.HashMap;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.List;
import java.util.function.Function; import java.util.Map;
import java.util.stream.Collectors; import java.util.Optional;
@Slf4j @Slf4j
@Service @Service
@ -48,29 +47,15 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
@Autowired @Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient; private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired @Autowired
private IcNeighborHoodService icNeighborHoodService; private IcNeighborHoodService icNeighborHoodService;
@Autowired @Autowired
private IcNeighborHoodPropertyService icNeighborHoodPropertyService; private IcNeighborHoodPropertyService icNeighborHoodPropertyService;
@Resource @Resource
private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao; private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao;
@Resource @Resource
private IcNeighborHoodDao icNeighborHoodDao; private IcNeighborHoodDao icNeighborHoodDao;
@Resource
private IcBuildingDao icBuildingDao;
@Resource
private IcHouseDao icHouseDao;
@Resource
private CustomerAgencyDao customerAgencyDao;
@Resource
private CustomerGridDao customerGridDao;
@Resource
private IcPropertyManagementDao icPropertyManagementDao;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -168,8 +153,6 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
//更新 //更新
icNeighborHoodPropertyService.updateById(icNeighborHoodProperty); icNeighborHoodPropertyService.updateById(icNeighborHoodProperty);
} }
} }
} }
@ -199,7 +182,6 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
public void exportNeighborhoodinfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception { public void exportNeighborhoodinfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception {
//导出小区 //导出小区
List<IcNeighborHoodExcel> icNeighborHoodExcels = searchAllNeighborhood(formDTO); List<IcNeighborHoodExcel> icNeighborHoodExcels = searchAllNeighborhood(formDTO);
// ExcelUtils.exportExcelToTarget(response, "小区信息录入表", icNeighborHoodExcels, IcNeighborHoodExcel.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_export.xlsx"); TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_export.xlsx");
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
@ -207,119 +189,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
ExcelPoiUtils.exportExcel(templatePath ,map,"小区信息录入表",response); ExcelPoiUtils.exportExcel(templatePath ,map,"小区信息录入表",response);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public List<Integer> importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId, List<Integer> numList) {
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//查询当前组织下网格列表
List<CustomerGridEntity> customerGridList = customerGridDao.selectByPid(staffInfoCache.getAgencyId());
//组织名称不一样的数据舍弃
Iterator<IcNeighborHoodExcel> iterator = list.iterator();
while (iterator.hasNext()) {
IcNeighborHoodExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
numList.add(obj.getRowNum());
iterator.remove();
continue;
}
//当前组织下网格名不存在的也不允许导入
AtomicBoolean br = new AtomicBoolean(true);
customerGridList.forEach(g->{
if(obj.getGridName().trim().equals(g.getGridName())){
br.set(false);
}
});
if(br.get()){
numList.add(obj.getRowNum());
iterator.remove();
}
}
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return numList;
}
//获取所有组织 list
List<String> agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toList());
agencyNameList = agencyNameList.stream().distinct().collect(Collectors.toList());
//获取所有网格 list
//List<String> gridNameList = list.stream().map(item->item.getGridName()).collect(Collectors.toList());
//获取所有物业 list
List<String> propertyNameList = list.stream().map(item->item.getPropertyName()).collect(Collectors.toList());
propertyNameList = propertyNameList.stream().distinct().collect(Collectors.toList());
//查询对应的id
List<CustomerAgencyEntity> customerAgencyList = customerAgencyDao.selectList(new QueryWrapper<CustomerAgencyEntity>().lambda().in(CustomerAgencyEntity::getOrganizationName, agencyNameList));
//List<CustomerGridEntity> customerGridList = customerGridDao.selectList(new QueryWrapper<CustomerGridEntity>().lambda().in(CustomerGridEntity::getGridName, gridNameList));
List<IcPropertyManagementEntity> icPropertyManagementList = icPropertyManagementDao.selectList(new QueryWrapper<IcPropertyManagementEntity>().lambda().in(IcPropertyManagementEntity::getName, propertyNameList));
Map<String,CustomerAgencyEntity> agencyMap = customerAgencyList.stream().collect(Collectors.toMap(CustomerAgencyEntity::getOrganizationName, Function.identity(),(key1, key2)->key1));
Map<String,CustomerGridEntity> gridMap = customerGridList.stream().collect(Collectors.toMap(CustomerGridEntity::getGridName,Function.identity(),(key1,key2)->key1));
Map<String,IcPropertyManagementEntity> propertyMap = icPropertyManagementList.stream().collect(Collectors.toMap(IcPropertyManagementEntity::getName,Function.identity(),(key1,key2)->key1));
//封装数据
List<IcNeighborHoodEntity> neighborHoodEntityList = new ArrayList<>();
List<IcNeighborHoodPropertyEntity> icNeighborHoodPropertyEntityList = new ArrayList<>();
Iterator<IcNeighborHoodExcel> iterator1 = list.iterator();
while (iterator1.hasNext()) {
IcNeighborHoodExcel icNeighborHoodExcel = iterator1.next();
//同一客户下,小区名称唯一
Integer count = icNeighborHoodDao.checkNameUq(customerId,icNeighborHoodExcel.getNeighborHoodName(),null);
if (null != count && count > 0) {
//throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), icNeighborHoodExcel.getNeighborHoodName()+EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg());
log.error(icNeighborHoodExcel.getNeighborHoodName()+EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg());
numList.add(icNeighborHoodExcel.getRowNum());
iterator1.remove();
continue;
}
IcNeighborHoodEntity entity = new IcNeighborHoodEntity();
String uuid =UUID.randomUUID().toString().replace("-", "");
entity.setId(uuid);
entity.setCustomerId(customerId);
entity.setNeighborHoodName(icNeighborHoodExcel.getNeighborHoodName());
entity.setAgencyId(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName().trim())).map(u->u.getId()).orElse("")); // agencyMap.get(icNeighborHoodExcel.getAgencyName()).getId());
entity.setParentAgencyId(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName().trim())).map(u->u.getPid()).orElse(""));//agencyMap.get(icNeighborHoodExcel.getAgencyName()).getPid()
entity.setAgencyPids(Optional.ofNullable(agencyMap.get(icNeighborHoodExcel.getAgencyName().trim())).map(u->u.getPids()).orElse(""));//agencyMap.get(icNeighborHoodExcel.getAgencyName()).getPids()
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());
iterator1.remove();
continue;
}
entity.setAddress(icNeighborHoodExcel.getAddress());
entity.setRemark(icNeighborHoodExcel.getRemark());
neighborHoodEntityList.add(entity);
IcNeighborHoodPropertyEntity entity1 = new IcNeighborHoodPropertyEntity();
entity1.setPropertyId(Optional.ofNullable(propertyMap.get(icNeighborHoodExcel.getPropertyName())).map(u->u.getId()).orElse(""));
entity1.setNeighborHoodId(uuid);
icNeighborHoodPropertyEntityList.add(entity1);
}
// icNeighborHoodDao.
//保存
icNeighborHoodService.insertBatch(neighborHoodEntityList);
icNeighborHoodPropertyService.insertBatch(icNeighborHoodPropertyEntityList);
return numList;
}
private List<IcNeighborHoodExcel> searchAllNeighborhood(IcHouseListFormDTO formDTO) { private List<IcNeighborHoodExcel> searchAllNeighborhood(IcHouseListFormDTO formDTO) {
// QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper = new QueryWrapper<>();
// neighborHoodEntityQueryWrapper.lambda()
// .eq(!StringUtils.isEmpty(formDTO.getAgencyId()),IcNeighborHoodEntity::getAgencyId,formDTO.getAgencyId())
// .eq(!StringUtils.isEmpty(formDTO.getGridId()),IcNeighborHoodEntity::getId,formDTO.getGridId())
// .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId())
// .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName());
// neighborHoodEntityQueryWrapper.eq("a.DEL_FLAG","0");
IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class); IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
neighbor.setDelFlag("0"); neighbor.setDelFlag("0");
if(OrgTypeEnum.GRID.getCode().equals(formDTO.getLevel())){ if(OrgTypeEnum.GRID.getCode().equals(formDTO.getLevel())){
@ -330,10 +200,4 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class); IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
return icNeighborHoodDao.searchAllNeighborhood(neighbor,house); return icNeighborHoodDao.searchAllNeighborhood(neighbor,house);
} }
} }

4
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml

@ -106,9 +106,7 @@
</if> </if>
AND a.DEL_FLAG = '0' AND a.DEL_FLAG = '0'
</where> </where>
order by order by a.CREATED_TIME, a.BUILDING_NAME
CAST(a.BUILDING_NAME AS SIGNED),
CONVERT(a.BUILDING_NAME using gbk)
</select> </select>
<select id="searchAllBuilding" resultType="com.epmet.excel.IcBuildingExcel"> <select id="searchAllBuilding" resultType="com.epmet.excel.IcBuildingExcel">
select select

3
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml

@ -142,8 +142,7 @@
</where> </where>
#排序规则:根据小区、楼栋、单元、门牌号(分别按照数字和中文)分别升序排序 #排序规则:根据小区、楼栋、单元、门牌号(分别按照数字和中文)分别升序排序
ORDER BY CONVERT(c.NEIGHBOR_HOOD_NAME using gbk), ORDER BY CONVERT(c.NEIGHBOR_HOOD_NAME using gbk),
CAST(b.BUILDING_NAME AS SIGNED), CONVERT(b.BUILDING_NAME USING gbk),
CONVERT(b.BUILDING_NAME using gbk),
CONVERT(d.UNIT_NAME USING gbk), CONVERT(d.UNIT_NAME USING gbk),
CAST(a.DOOR_NAME AS SIGNED), CAST(a.DOOR_NAME AS SIGNED),
CONVERT(a.DOOR_NAME using gbk) CONVERT(a.DOOR_NAME using gbk)

3
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -173,7 +173,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
}); });
}); });
if (str.length() > NumConstant.ZERO ) { if (str.length() > NumConstant.ZERO ) {
throw new RenException(String.format("新增居民信息,必要字段值为空,%s值为空", str)); String errorMsg = String.format("新增居民信息,必要字段值为空,%s值为空", str);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
} }
} else { } else {
throw new RenException(String.format("新增居民信息-根据客户Id查询必填信息失败,customerId->%s", tokenDto.getCustomerId())); throw new RenException(String.format("新增居民信息-根据客户Id查询必填信息失败,customerId->%s", tokenDto.getCustomerId()));

Loading…
Cancel
Save