Browse Source

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

dev
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. 240
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  15. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java
  16. 6
      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;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
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.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
@ -34,9 +32,11 @@ import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dto.BuildingTreeLevelDTO;
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.excel.IcBuildingExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.BuildingService;
import com.epmet.util.ExcelPoiUtils;
@ -49,8 +49,9 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
@ -134,10 +135,7 @@ public class BuildingController {
@PostMapping("exporttemplate")
public void exportTemplate( HttpServletResponse response) throws Exception {
TemplateExportParams templatePath = new TemplateExportParams("excel/building_template.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",new ArrayList<IcBuildingExcel>());
ExcelPoiUtils.exportExcel(templatePath ,map,"楼栋信息录入表",response);
ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"楼栋信息录入表",response);
}
/**
* 导出
@ -149,7 +147,6 @@ public class BuildingController {
public void exportbuildinginfo(@RequestBody IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(formDTO);
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 楼宇导入
* @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 java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.*;
/**
@ -167,7 +165,7 @@ public class HouseController implements ResultDataResolver {
@PostMapping("exporttemplate")
public void exportTemplate(HttpServletResponse response) throws Exception {
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;
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.epmet.commons.tools.annotation.LoginUser;
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.utils.Result;
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.result.IcNeighborHoodResultDTO;
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.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.PostMapping;
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.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.HashMap;
import java.util.List;
/**
@ -63,20 +57,12 @@ import java.util.stream.Collectors;
@RequestMapping("neighborhood")
public class NeighborHoodController {
@Autowired
private IcNeighborHoodService icNeighborHoodService;
@Autowired
private NeighborHoodService neighborHoodService;
@Autowired
private BuildingService buildingService;
@Autowired
private HouseService houseService;
@Resource
private IcBuildingDao icBuildingDao;
@PostMapping("neighborhoodlist")
public Result<IcNeighborHoodResultDTO> neighborhoodlist(@RequestBody IcNeighborHoodListFormDTO formDTO){
//效验数据
@ -140,94 +126,7 @@ public class NeighborHoodController {
*/
@PostMapping("exporttemplate")
public void exportTemplate( 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
*/
/*@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);
ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"小区信息录入表",response);
}
}

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

@ -12,6 +12,9 @@ import lombok.Data;
@Data
public class BuildingErrorInfoModel {
@Excel(name = "行号", width = 20)
private Integer num;
@Excel(name = "小区名称" , width = 20)
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;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@ -35,4 +36,7 @@ public class BuildingInfoModel {
@ExcelProperty(value = "户数")
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
public class HouseErrorInfoModel {
@Excel(name = "行号(不计算表头)", width = 20)
@Excel(name = "行号", width = 20)
private Integer num;
@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);
dto.setNum(num);
dto.setCustomerId(formDTO.getCustomerId());
info.setNum(num);
if(StringUtils.isBlank(data.getAgencyName())){
nums.add(num);
disposeErrorMsg(info, "所属组织的值未填写");
@ -384,6 +385,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
public void disposeErrorMsg(BuildingInfoModel data,String msg){
BuildingErrorInfoModel err = ConvertUtils.sourceToTarget(data, BuildingErrorInfoModel.class);
err.setErrorMsg(msg);
err.setNum(err.getNum() + NumConstant.ONE);
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){
HouseErrorInfoModel err = ConvertUtils.sourceToTarget(data, HouseErrorInfoModel.class);
err.setErrorMsg(msg);
err.setNum(err.getNum() + NumConstant.ONE);
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;
num = num + NumConstant.ONE;
info.setNum(num);
if (StringUtils.isBlank(data.getNeighborHoodName()) ||
StringUtils.isBlank(data.getGridName()) || StringUtils.isBlank(data.getAgencyName()) || StringUtils.isBlank(data.getAddress())){
nums.add(num);
@ -333,6 +334,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
public void disposeErrorMsg(NeighborHoodInfoModel data,String msg){
NeighborHoodErrorInfoModel err = ConvertUtils.sourceToTarget(data, NeighborHoodErrorInfoModel.class);
err.setErrorMsg(msg);
err.setNum(err.getNum() + NumConstant.ONE);
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
public class NeighborHoodErrorInfoModel {
@Excel(name = "行号", width = 20)
private Integer num;
@Excel(name = "小区名称", width = 20)
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;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@ -29,4 +30,7 @@ public class NeighborHoodInfoModel {
@ExcelProperty(value = "备注")
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.IcBuildingListResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.excel.IcBuildingExcel;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -61,8 +60,6 @@ public interface BuildingService {
List<BuildingTreeLevelDTO> treeList(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);
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.IcNeighborHoodListFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcNeighborHoodExcel;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 小区表
@ -53,6 +51,4 @@ public interface NeighborHoodService{
* @param response
*/
void exportNeighborhoodinfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception ;
List<Integer> importExcel(String customerId, List<IcNeighborHoodExcel> list, String staffId, List<Integer> numList);
}

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

@ -94,11 +94,11 @@ public class BuildingServiceImpl implements BuildingService {
@Transactional(rollbackFor = Exception.class)
public void addBuilding(String customerId, IcBulidingAddFormDTO formDTO) {
//同一小区下不能存在楼栋名字一样的
Integer count = icBuildingDao.checkBuildName(formDTO.getNeighborHoodId(),formDTO.getBuildingName(),null);
Integer count = icBuildingDao.checkBuildName(formDTO.getNeighborHoodId(), formDTO.getBuildingName(), null);
if (null != count && count > 0) {
throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(),EpmetErrorCode.BUILDING_NAME_EXITED.getMsg());
throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(), EpmetErrorCode.BUILDING_NAME_EXITED.getMsg());
}
IcBuildingDTO icBuildingDTO= ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class);
IcBuildingDTO icBuildingDTO = ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class);
icBuildingDTO.setCustomerId(customerId);
IcBuildingEntity entity = ConvertUtils.sourceToTarget(icBuildingDTO, IcBuildingEntity.class);
icBuildingDao.insert(entity);
@ -106,12 +106,12 @@ public class BuildingServiceImpl implements BuildingService {
//设置楼宇单元
Integer totalUnitNum = formDTO.getTotalUnitNum();
List<IcBuildingUnitEntity> unitList = new ArrayList<>();
for(int i =0 ;i<totalUnitNum;i++){
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity();
for (int i = 0; i < totalUnitNum; i++) {
IcBuildingUnitEntity icBuildingUnit = new IcBuildingUnitEntity();
icBuildingUnit.setCustomerId(customerId);
icBuildingUnit.setBuildingId(entity.getId());
icBuildingUnit.setUnitName((i + 1) +"单元");
icBuildingUnit.setUnitNum(String.valueOf(i+1));
icBuildingUnit.setUnitName((i + 1) + "单元");
icBuildingUnit.setUnitNum(String.valueOf(i + 1));
unitList.add(icBuildingUnit);
}
icBuildingUnitService.insertBatch(unitList, NumConstant.ONE_HUNDRED);
@ -121,8 +121,8 @@ public class BuildingServiceImpl implements BuildingService {
@Override
public List<BuildingTreeLevelDTO> treeList(String customerId, String staffId) {
CustomerStaffInfoCacheResult agency = CustomerStaffRedis.getStaffInfo(customerId, staffId);
if(null == agency || StringUtils.isBlank(agency.getAgencyId())){
log.error("com.epmet.service.impl.BuildingServiceImpl.treeList,没有找到工作人员所属的机关信息,用户Id:{}",staffId);
if (null == agency || StringUtils.isBlank(agency.getAgencyId())) {
log.error("com.epmet.service.impl.BuildingServiceImpl.treeList,没有找到工作人员所属的机关信息,用户Id:{}", staffId);
return new ArrayList<>();
}
@ -133,7 +133,7 @@ public class BuildingServiceImpl implements BuildingService {
List<CustomerAgencyEntity> customerAgencyList = icBuildingDao.selectAgencyChildrenList(agency.getAgencyId());
customerAgencyList.add(customerAgency);
if(CollectionUtils.isEmpty(customerAgencyList)){
if (CollectionUtils.isEmpty(customerAgencyList)) {
return new ArrayList<>();
}
@ -152,14 +152,13 @@ public class BuildingServiceImpl implements BuildingService {
}).collect(Collectors.toList());
//2.获取组织所在网格
List<String> agencyIdList = customerAgencyList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList());
// agencyIdList.add(customerAgency.getId());
List<CustomerGridEntity> customerGridList = customerGridDao.selectList(new QueryWrapper<CustomerGridEntity>().lambda().in(CustomerGridEntity::getPid, agencyIdList));
if(CollectionUtils.isEmpty(customerGridList)){
return covertToTree(customerAgency,agencyList);
if (CollectionUtils.isEmpty(customerGridList)) {
return covertToTree(customerAgency, agencyList);
}
List<BuildingTreeLevelDTO> gridList = customerGridList.stream().map(item -> {
@ -181,11 +180,11 @@ public class BuildingServiceImpl implements BuildingService {
List<String> gridIdList = customerGridList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList());
LambdaQueryWrapper<IcNeighborHoodEntity> queryWrapper = new QueryWrapper<IcNeighborHoodEntity>().lambda()
.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);
if(CollectionUtils.isEmpty(icNeighborHoodList)){
if (CollectionUtils.isEmpty(icNeighborHoodList)) {
agencyList.addAll(gridList);
return covertToTree(customerAgency,agencyList);
return covertToTree(customerAgency, agencyList);
}
List<BuildingTreeLevelDTO> neighbourHoodList = icNeighborHoodList.stream().map(item -> {
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO();
@ -205,14 +204,13 @@ public class BuildingServiceImpl implements BuildingService {
List<String> neighborHoodIdList = icNeighborHoodList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList());
LambdaQueryWrapper<IcBuildingEntity> buildingQueryWrapper = new QueryWrapper<IcBuildingEntity>().lambda()
.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);
if(CollectionUtils.isEmpty(neighborHoodIdList)){
if (CollectionUtils.isEmpty(neighborHoodIdList)) {
agencyList.addAll(gridList);
agencyList.addAll(neighbourHoodList);
return covertToTree(customerAgency,agencyList);
return covertToTree(customerAgency, agencyList);
}
//获取楼里已经有多少个房屋
LambdaQueryWrapper<IcHouseEntity> icHouseEntityWrapper = new QueryWrapper<IcHouseEntity>().lambda()
@ -246,10 +244,10 @@ public class BuildingServiceImpl implements BuildingService {
// .in(IcHouseEntity::getBuildingId, item.getId());
// int count= icHouseDao.selectCount(icHouseEntityWrapper);
int count = buildingHouseCountMap.getOrDefault(item.getId(), NumConstant.ZERO_L).intValue();
if(NumConstant.ZERO==total){
buildingTreeLevelDTO.setShowNum(String.format("%s/%s",count,count));
}else{
buildingTreeLevelDTO.setShowNum(String.format("%s/%s",count,total));
if (NumConstant.ZERO == total) {
buildingTreeLevelDTO.setShowNum(String.format("%s/%s", count, count));
} else {
buildingTreeLevelDTO.setShowNum(String.format("%s/%s", count, total));
}
return buildingTreeLevelDTO;
}).collect(Collectors.toList());
@ -257,7 +255,7 @@ public class BuildingServiceImpl implements BuildingService {
agencyList.addAll(gridList);
agencyList.addAll(neighbourHoodList);
agencyList.addAll(buildingList);
return covertToTree(customerAgency,agencyList);
return covertToTree(customerAgency, agencyList);
}
@ -265,15 +263,15 @@ public class BuildingServiceImpl implements BuildingService {
public List<String> treeIds(String customerId, String staffId) {
List<String> result = new ArrayList<>();
CustomerStaffInfoCacheResult agency = CustomerStaffRedis.getStaffInfo(customerId, staffId);
if(null == agency || StringUtils.isBlank(agency.getAgencyId())){
log.error("com.epmet.service.impl.BuildingServiceImpl.treeIds,没有找到工作人员所属的机关信息,用户Id:{}",staffId);
if (null == agency || StringUtils.isBlank(agency.getAgencyId())) {
log.error("com.epmet.service.impl.BuildingServiceImpl.treeIds,没有找到工作人员所属的机关信息,用户Id:{}", staffId);
return new ArrayList<>();
}
//1.获取所在组织及下级组织
CustomerAgencyEntity customerAgency = customerAgencyDao.selectById(agency.getAgencyId());
List<CustomerAgencyEntity> customerAgencyList = icBuildingDao.selectAgencyChildrenList(agency.getAgencyId());
customerAgencyList.add(customerAgency);
if(CollectionUtils.isEmpty(customerAgencyList)){
if (CollectionUtils.isEmpty(customerAgencyList)) {
return new ArrayList<>();
}
result.addAll(customerAgencyList.stream().map(m -> m.getId()).collect(Collectors.toList()));
@ -293,128 +291,41 @@ public class BuildingServiceImpl implements BuildingService {
//2.获取组织所在网格
List<String> agencyIdList = customerAgencyList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList());
List<CustomerGridEntity> customerGridList = customerGridDao.selectList(new QueryWrapper<CustomerGridEntity>().lambda().in(CustomerGridEntity::getPid, agencyIdList));
if(CollectionUtils.isEmpty(customerGridList)){
if (CollectionUtils.isEmpty(customerGridList)) {
return result;
}
result.addAll(customerGridList.stream().map(m -> m.getId()).collect(Collectors.toList()));
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
public PageData<IcBuildingListResultDTO> listBuilding(IcBuildingListFormDTO formDTO) {
PageInfo<IcBuildingListResultDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> icBuildingDao.searchBuildingByPage(formDTO));
List<IcBuildingListResultDTO> records = pageInfo.getList();
records.forEach(item-> item.setBuildingType( BuildingTypeEnums.getTypeValue(item.getBuildingTypeKey())));
return new PageData<>(pageInfo.getList(),pageInfo.getTotal());
records.forEach(item -> item.setBuildingType(BuildingTypeEnums.getTypeValue(item.getBuildingTypeKey())));
return new PageData<>(pageInfo.getList(), pageInfo.getTotal());
}
@Override
public void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception {
public void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception {
//如果类型是building 查楼栋
//导出楼栋
List<IcBuildingExcel> icBuildingExcels = searchAllBuilding(formDTO);
TemplateExportParams templatePath = new TemplateExportParams("excel/building_export.xlsx");
Map<String,Object> map = new HashMap<>();
map.put("maplist",icBuildingExcels);
ExcelPoiUtils.exportExcel(templatePath ,map,"楼栋信息录入表",response);
return ;
Map<String, Object> map = new HashMap<>();
map.put("maplist", icBuildingExcels);
ExcelPoiUtils.exportExcel(templatePath, map, "楼栋信息录入表", response);
return;
}
@Override
public List<BuildingResultDTO> buildingListByIds(List<String> buildingIdList) {
return icBuildingDao.buildingListByIds(buildingIdList);
}
@Override
public BuildingResultPagedDTO buildinglistbyidsPage(List<String> buildingIdList,Integer pageNo, Integer pageSize) {
IPage<IcBuildingEntity> page = new Page<IcBuildingEntity>(pageNo,pageSize);
public BuildingResultPagedDTO buildinglistbyidsPage(List<String> buildingIdList, Integer pageNo, Integer pageSize) {
IPage<IcBuildingEntity> page = new Page<IcBuildingEntity>(pageNo, pageSize);
IPage<BuildingResultDTO> buildingResultDTOIPage = icBuildingDao.buildingListByIds(page, buildingIdList);
BuildingResultPagedDTO result = new BuildingResultPagedDTO();
result.setTotal(Long.valueOf(buildingResultDTOIPage.getTotal()).intValue());
@ -424,29 +335,29 @@ public class BuildingServiceImpl implements BuildingService {
}
/**
* @param formDTO
* @param inputStream
* @Description 楼宇导入
* 根据左侧树选中的层级可导入对应数据
* 根据左侧树选中的层级可导入对应数据
* 1. 选中社区可导入该社区下所有小区信息楼宇信息房屋信息没有匹配的小区楼宇均新增网格没有对应的不新增
* 2. 选中网格可导入该网格下所有小区信息楼宇信息房屋信息没有匹配的小区楼宇均新增
* 3. 选中小区可导入该小区下所有楼宇信息房屋信息没有匹配的楼宇均新增
* 4. 选中楼宇可导入该楼宇下所有房屋信息
* @param formDTO
* @param inputStream
* @author zxc
* @date 2022/2/13 10:15 上午
*/
@Override
public Result buildingImportExcel(ImportInfoFormDTO formDTO, InputStream inputStream,Result<ImportTaskCommonResultDTO> importTask) {
public Result buildingImportExcel(ImportInfoFormDTO formDTO, InputStream inputStream, Result<ImportTaskCommonResultDTO> importTask) {
executorService.submit(() -> {
ExcelReader excelReader = null;
try {
excelReader = EasyExcel.read(inputStream).build();
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class)
.registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId()))
.registerReadListener(new ImportBuildingInfoListener(formDTO, icHouseRedis, icBuildingDao, neighborHoodService, epmetCommonServiceOpenFeignClient, importTask.getData().getTaskId()))
.build();
excelReader.read(readSheet);
} catch (Exception e){
} catch (Exception e) {
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(formDTO.getUserId());
input.setTaskId(importTask.getData().getTaskId());
@ -462,32 +373,18 @@ public class BuildingServiceImpl implements BuildingService {
}
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);
building.setDelFlag("0");
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
List<IcBuildingExcel> icBuildingExcels = icBuildingDao.searchAllBuilding(building, house);
icBuildingExcels.forEach(item->{
icBuildingExcels.forEach(item -> {
item.setType(BuildingTypeEnums.getTypeValue(item.getType()));
});
return icBuildingExcels;
}
private List<BuildingTreeLevelDTO> covertToTree(CustomerAgencyEntity customerAgency,List<BuildingTreeLevelDTO> agencyList) {
private List<BuildingTreeLevelDTO> covertToTree(CustomerAgencyEntity customerAgency, List<BuildingTreeLevelDTO> agencyList) {
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO();
buildingTreeLevelDTO.setId(customerAgency.getId());
buildingTreeLevelDTO.setLabel(customerAgency.getOrganizationName());
@ -495,7 +392,7 @@ public class BuildingServiceImpl implements BuildingService {
buildingTreeLevelDTO.setLongitude(customerAgency.getLongitude());
buildingTreeLevelDTO.setLatitude(customerAgency.getLatitude());
buildingTreeLevelDTO.setChildren(new ArrayList<>());
recursionCovertToTree(buildingTreeLevelDTO,agencyList);
recursionCovertToTree(buildingTreeLevelDTO, agencyList);
List<BuildingTreeLevelDTO> result = new ArrayList<>();
result.add(buildingTreeLevelDTO);
return result;
@ -505,20 +402,20 @@ public class BuildingServiceImpl implements BuildingService {
//获取子节点
List<BuildingTreeLevelDTO> subList = customerAgencyList.stream().filter(item -> item.getPId().equals(parent.getId())).collect(Collectors.toList());
for(BuildingTreeLevelDTO agencyEntity :subList){
recursionCovertToTree(agencyEntity,customerAgencyList);
for (BuildingTreeLevelDTO agencyEntity : subList) {
recursionCovertToTree(agencyEntity, customerAgencyList);
}
parent.setChildren(subList);
if(!"building".equals(parent.getLevel())){
if (!"building".equals(parent.getLevel())) {
parent.setShowNum(CollectionUtils.isEmpty(subList) ? NumConstant.ZERO_STR : String.valueOf(subList.size()));
}
parent.setShowName(String.format("%s(%s)",parent.getLabel(),parent.getShowNum()));
parent.setShowName(String.format("%s(%s)", parent.getLabel(), parent.getShowNum()));
}
/**
* 更新
*
* @param customerId
* @param formDTO
*/
@ -526,37 +423,33 @@ public class BuildingServiceImpl implements BuildingService {
@Transactional(rollbackFor = Exception.class)
public void updateBuilding(String customerId, IcBulidingAddFormDTO formDTO) {
//同一小区下不能存在楼栋名字一样的
Integer count = icBuildingDao.checkBuildName(formDTO.getNeighborHoodId(),formDTO.getBuildingName(),formDTO.getBuildingId());
Integer count = icBuildingDao.checkBuildName(formDTO.getNeighborHoodId(), formDTO.getBuildingName(), formDTO.getBuildingId());
if (null != count && count > 0) {
throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(),EpmetErrorCode.BUILDING_NAME_EXITED.getMsg());
throw new RenException(EpmetErrorCode.BUILDING_NAME_EXITED.getCode(), EpmetErrorCode.BUILDING_NAME_EXITED.getMsg());
}
IcBuildingDTO icBuilding= icBuildingService.get(formDTO.getBuildingId());
IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingId());
if(!icBuilding.getNeighborHoodId().equals(formDTO.getNeighborHoodId())){
if (!icBuilding.getNeighborHoodId().equals(formDTO.getNeighborHoodId())) {
//更新对应房屋小区id
List<IcHouseEntity> icHouseEntities = icHouseDao.selectList(new QueryWrapper<IcHouseEntity>().lambda().eq(IcHouseEntity::getBuildingId, formDTO.getBuildingId()));
if(!CollectionUtils.isEmpty(icHouseEntities)){
if (!CollectionUtils.isEmpty(icHouseEntities)) {
//
throw new RenException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(),"楼栋单元下存在房屋,无法更新");
// icHouseEntities.forEach(item->{
// item.setNeighborHoodId(formDTO.getNeighborHoodId());
// });
// icHouseService.updateBatchById(icHouseEntities);
throw new RenException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(), "楼栋单元下存在房屋,无法更新");
}
}
IcBuildingDTO icBuildingDTO= ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class);
IcBuildingDTO icBuildingDTO = ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class);
icBuildingDTO.setId(formDTO.getBuildingId());
icBuildingDTO.setCustomerId(customerId);
icBuildingService.update(icBuildingDTO);
//更新楼宇单元
//如果楼宇单元大于之前的楼宇单元,新增单元
Integer nowUnit= formDTO.getTotalUnitNum();
Integer nowUnit = formDTO.getTotalUnitNum();
Integer unit = icBuilding.getTotalUnitNum();
if(nowUnit<unit){
if (nowUnit < unit) {
//如果小于,判断是否存在房屋,如果存在就提示不能更改
throw new EpmetException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(),EpmetErrorCode.ORG_EDIT_FAILED.getMsg(),"暂不支持单元号减小");
}else{
throw new EpmetException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(), EpmetErrorCode.ORG_EDIT_FAILED.getMsg(), "暂不支持单元号减小");
} else {
//新增单元
List<OptionResultDTO> units = icBuildingUnitService.getUnitOptions(icBuilding.getId());
Map<String, String> unitMap = units.stream().collect(Collectors.toMap(OptionResultDTO::getCode, OptionResultDTO::getLabel));
@ -589,6 +482,7 @@ public class BuildingServiceImpl implements BuildingService {
/**
* 删除
*
* @param buildingId
*/
@Override
@ -596,13 +490,13 @@ public class BuildingServiceImpl implements BuildingService {
public void delBuilding(String buildingId) {
//如果存在房屋,无法删除
List<IcHouseEntity> icHouseEntities = icHouseDao.selectList(new QueryWrapper<IcHouseEntity>().lambda().eq(IcHouseEntity::getBuildingId, buildingId));
if(!CollectionUtils.isEmpty(icHouseEntities)){
throw new RenException(EpmetErrorCode.ORG_DEL_FAILED.getCode(),"楼栋单元下存在房屋,无法删除");
if (!CollectionUtils.isEmpty(icHouseEntities)) {
throw new RenException(EpmetErrorCode.ORG_DEL_FAILED.getCode(), "楼栋单元下存在房屋,无法删除");
}
//删除楼宇
icBuildingService.deleteById(buildingId);
//删除楼宇单元
icBuildingUnitDao.delete(new QueryWrapper<IcBuildingUnitEntity>().lambda().eq(IcBuildingUnitEntity::getBuildingId,buildingId));
icBuildingUnitDao.delete(new QueryWrapper<IcBuildingUnitEntity>().lambda().eq(IcBuildingUnitEntity::getBuildingId, buildingId));
}

4
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<>();
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);
if(CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
@ -153,4 +153,4 @@ public class IcBuildingServiceImpl extends BaseServiceImpl<IcBuildingDao, IcBuil
return ConvertUtils.sourceToTarget(entity, IcBuildingDTO.class);
}
}
}

6
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<>();
wrapper.eq(StringUtils.isNotBlank(formDTO.getBuildingId()), IcHouseEntity::getBuildingId, formDTO.getBuildingId());
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);
if(CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
@ -160,7 +160,7 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
//查询楼栋下房屋列表
LambdaQueryWrapper<IcHouseEntity> wrapper = new LambdaQueryWrapper<>();
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);
if(CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
@ -246,4 +246,4 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
return baseDao.getHousesNameByIdCards(idCards);
}
}
}

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<>();
wrapper.eq(StringUtils.isNotBlank(agencyId),IcNeighborHoodEntity::getAgencyId, agencyId);
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);
if(CollectionUtils.isEmpty(list)) {
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 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.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
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.Result;
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.IcNeighborHoodListFormDTO;
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.feign.GovOrgOpenFeignClient;
import com.epmet.service.IcNeighborHoodPropertyService;
@ -32,15 +32,14 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Slf4j
@Service
@ -48,29 +47,15 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private IcNeighborHoodService icNeighborHoodService;
@Autowired
private IcNeighborHoodPropertyService icNeighborHoodPropertyService;
@Resource
private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao;
@Resource
private IcNeighborHoodDao icNeighborHoodDao;
@Resource
private IcBuildingDao icBuildingDao;
@Resource
private IcHouseDao icHouseDao;
@Resource
private CustomerAgencyDao customerAgencyDao;
@Resource
private CustomerGridDao customerGridDao;
@Resource
private IcPropertyManagementDao icPropertyManagementDao;
@Override
@Transactional(rollbackFor = Exception.class)
@ -168,8 +153,6 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
//更新
icNeighborHoodPropertyService.updateById(icNeighborHoodProperty);
}
}
}
@ -199,7 +182,6 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
public void exportNeighborhoodinfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception {
//导出小区
List<IcNeighborHoodExcel> icNeighborHoodExcels = searchAllNeighborhood(formDTO);
// ExcelUtils.exportExcelToTarget(response, "小区信息录入表", icNeighborHoodExcels, IcNeighborHoodExcel.class);
TemplateExportParams templatePath = new TemplateExportParams("excel/neighbor_export.xlsx");
Map<String,Object> map = new HashMap<>();
@ -207,119 +189,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
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) {
// 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);
neighbor.setDelFlag("0");
if(OrgTypeEnum.GRID.getCode().equals(formDTO.getLevel())){
@ -330,10 +200,4 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class);
return icNeighborHoodDao.searchAllNeighborhood(neighbor,house);
}
}

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

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

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

@ -142,8 +142,7 @@
</where>
#排序规则:根据小区、楼栋、单元、门牌号(分别按照数字和中文)分别升序排序
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),
CAST(a.DOOR_NAME AS SIGNED),
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 ) {
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 {
throw new RenException(String.format("新增居民信息-根据客户Id查询必填信息失败,customerId->%s", tokenDto.getCustomerId()));

Loading…
Cancel
Save