Browse Source

Merge remote-tracking branch 'remotes/origin/dev'

master
jianjun 3 years ago
parent
commit
a7421195f3
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OptionResultDTO.java
  2. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java
  3. 28
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java
  4. 32
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java
  5. 22
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java
  6. 31
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  7. 1
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java
  8. 198
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OptionResultDTO.java

@ -14,6 +14,7 @@ import java.util.List;
public class OptionResultDTO implements Serializable {
private static final long serialVersionUID = 8618231166600518980L;
private String label;
private String code;
private String value;
private String pValue;
private String sysDictDataId;

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java

@ -9,14 +9,16 @@ public interface ImportErrorMsgConstants {
String EXIST_ERROR = "数据已存在";
String HOUSE_ERROR = "所属组织、所属网格、所属小区、所属楼栋、单元号、房屋类型、房屋用途、出租的值未填写,或者所填写信息在系统中未找到";
String DOCUMENT_EXIST_ERROR = "文件中存在重复数据";
String BUILDING_ERROR = "所属组织、所属网格、所属小区、楼栋类型、单元数的值未填写或者所填写信息在系统中未找到";
String BELONG_GRID_ERROR = "所属网格的值未填写或者所填写信息在系统中未找到";
String NEIGHBOR_HOOD_ERROR = "所属组织、所属网格、详细地址的值未填写或者所填写信息在系统中未找到";
String BELONG_AGENCY_ERROR = "所属组织的值未填写或者所填写信息在系统中未找到";
String HOUSE_ERROR_NAME = "导入失败的列表-房屋";
String BUILDING_ERROR_NAME = "导入失败的列表-楼宇";
String NEIGHBORHOOD_ERROR_NAME = "导入失败的列表-小区";
String HOUSE_TYPE_ERROR = "房屋类型的值未填写或者所填写信息在系统中未找到";
String BUILDING_TYPE_ERROR = "楼栋类型的值未填写或者所填写信息在系统中未找到";
String NEIGHBORHOOD_TYPE_ERROR = "小区名称的值未填写或者所填写信息在系统中未找到";
}

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

@ -30,6 +30,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.epmet.constant.ImportErrorMsgConstants.*;
/**
* @Author zxc
* @DateTime 2022/2/15 10:06 上午
@ -117,7 +119,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
// 应产品要求添加
if (StringUtils.isNotBlank(dto.getType()) && (!dto.getType().equals("商品房") && !dto.getType().equals("自建房")) && !dto.getType().equals("别墅")){
nums.add(num);
disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info, BUILDING_TYPE_ERROR);
return;
}
dto.setType(BuildingTypeEnums.getKeyByValue(dto.getType()));
@ -150,7 +152,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
// 集合里重复的
nums.add(r.getNum());
BuildingInfoModel buildingInfoModel = ConvertUtils.sourceToTarget(r, BuildingInfoModel.class);
disposeErrorMsg(buildingInfoModel,ImportErrorMsgConstants.EXIST_ERROR);
disposeErrorMsg(buildingInfoModel,DOCUMENT_EXIST_ERROR);
r.setExistStatus(true);
r.setAddStatus(true);
}
@ -231,19 +233,19 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
//排除不是本小区的
if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info,"所属小区的值未填写或者所填写信息在系统中未找到");
}else {
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId());
if (null == gridInfo){
nums.add(num);
disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info, BELONG_GRID_ERROR);
return;
}
// 1.排除网格名不一样但小区名一样 2.排除组织不一样,网格一样,小区一样
if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) ||
(!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
dto.setNeighborHoodId(formDTO.getOrgId());
@ -252,7 +254,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info, BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());
@ -273,13 +275,13 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId());
if (null == gridInfo){
nums.add(num);
disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info, BELONG_GRID_ERROR);
return;
}
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
}else {
//
dto.setGridId(formDTO.getOrgId());
@ -287,7 +289,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info, BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());
@ -308,21 +310,21 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
//排除不是本组织的
if (!dto.getAgencyName().equals(agencyName)){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info,BELONG_AGENCY_ERROR);
}else {
// 根据组织查询出所有网格,甩出不是本组织下的网格
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos;
if (null == gridInfos){
// 组织下确实不存在网格
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName());
if (null == cacheGridName){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
dto.setGridId(cacheGridName.toString());
@ -330,7 +332,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR);
disposeErrorMsg(info, BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());

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

@ -36,6 +36,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.epmet.constant.ImportErrorMsgConstants.*;
/**
* @Author zxc
* @DateTime 2022/2/13 1:25 下午
@ -163,7 +165,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
if (StringUtils.isNotBlank(dto.getHouseType()) ){
if( !"楼房".equals(dto.getHouseType()) && !dto.getHouseType().equals("平房") && !dto.getHouseType().equals("别墅") ){
nums.add(num);
disposeErrorMsg(info,"房屋类型的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info,HOUSE_TYPE_ERROR);
return;
}
}
@ -229,7 +231,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
if (!r.getAddStatus()){
nums.add(r.getNum());
info = ConvertUtils.sourceToTarget(r,HouseInfoModel.class);
disposeErrorMsg(info,"文件中存在重复数据");
disposeErrorMsg(info,DOCUMENT_EXIST_ERROR);
r.setExistStatus(true);
r.setAddStatus(true);
}
@ -302,7 +304,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(buildingGeneralDTO.getGridId());
if (null == gridInfo){
nums.add(num);
disposeErrorMsg(info, "所属网格的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info, BELONG_GRID_ERROR);
return;
}
// 排除 1、小区名不一样&&楼栋名一样 2、网格名不一样&&小区名一样&&楼名一样 3、组织名不一样&&网格名一样&&小区名一样&&楼名一样
@ -310,7 +312,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
|| (!gridInfo.getGridName().equals(dto.getGridName())&&buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName()))
|| (!gridInfo.getAgencyName().equals(dto.getAgencyName())&&gridInfo.getGridName().equals(dto.getGridName())&&buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName()))){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
dto.setBuildingId(formDTO.getOrgId());
@ -320,7 +322,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info, "所属组织的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info, BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());
@ -358,14 +360,14 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId());
if (null == gridInfo){
nums.add(num);
disposeErrorMsg(info, "所属网格的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info, BELONG_GRID_ERROR);
return;
}
// 1.排除网格名不一样但小区名一样 2.排除组织不一样,网格一样,小区一样
if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) ||
(!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
dto.setNeighborHoodId(formDTO.getOrgId());
@ -374,7 +376,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info, "所属组织的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info, BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());
@ -395,13 +397,13 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId());
if (null == gridInfo){
nums.add(num);
disposeErrorMsg(info, "所属网格的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info, BELONG_GRID_ERROR);
return;
}
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
}else {
//
dto.setGridId(formDTO.getOrgId());
@ -409,7 +411,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info, "所属组织的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info, BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());
@ -430,21 +432,21 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
//排除不是本组织的
if (!dto.getAgencyName().equals(agencyName)){
nums.add(num);
disposeErrorMsg(info,"所属组织的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info,BELONG_AGENCY_ERROR);
}else {
// 根据组织查询出所有网格,甩出不是本组织下的网格
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos;
if (null == gridInfos){
// 组织下确实不存在网格
nums.add(num);
disposeErrorMsg(info,"所属网格的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName());
if (null == cacheGridName){
nums.add(num);
disposeErrorMsg(info,"所属网格的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
dto.setGridId(cacheGridName.toString());
@ -452,7 +454,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info, "所属组织的值未填写或者所填写信息在系统中未找到");
disposeErrorMsg(info, BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());

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

@ -33,6 +33,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.epmet.constant.ImportErrorMsgConstants.*;
/**
* @Author zxc
* @DateTime 2022/2/15 2:16 下午
@ -84,11 +86,10 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
}
info = data;
num = num + NumConstant.ONE;
log.info("读数据"+num);
if (StringUtils.isBlank(data.getNeighborHoodName()) ||
StringUtils.isBlank(data.getGridName()) || StringUtils.isBlank(data.getAgencyName()) || StringUtils.isBlank(data.getAddress())){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
disposeErrorMsg(info,NEIGHBORHOOD_TYPE_ERROR);
return;
}
if(StringUtils.isBlank(data.getAgencyName())){
@ -123,7 +124,6 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
if (num%NumConstant.ONE_HUNDRED == NumConstant.ZERO){
finalDispose();
}
log.info("读数据"+num+"完毕");
}
public void finalDispose(){
@ -140,7 +140,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
// 集合里重复的
nums.add(r.getNum());
NeighborHoodInfoModel neighborHoodInfoModel = ConvertUtils.sourceToTarget(r, NeighborHoodInfoModel.class);
disposeErrorMsg(neighborHoodInfoModel, ImportErrorMsgConstants.EXIST_ERROR);
disposeErrorMsg(neighborHoodInfoModel, DOCUMENT_EXIST_ERROR);
r.setExistStatus(true);
r.setAddStatus(true);
}
@ -219,13 +219,13 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId());
if (null == gridInfo){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
}else {
//
dto.setGridId(formDTO.getOrgId());
@ -233,7 +233,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
disposeErrorMsg(info,BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());
@ -253,21 +253,21 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
//排除不是本组织的
if (!dto.getAgencyName().equals(agencyName)){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
disposeErrorMsg(info,BELONG_AGENCY_ERROR);
}else {
// 根据组织查询出所有网格,甩出不是本组织下的网格
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos;
if (null == gridInfos){
// 组织下确实不存在网格
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName());
if (null == cacheGridName){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
disposeErrorMsg(info,BELONG_GRID_ERROR);
return;
}
dto.setGridId(cacheGridName.toString());
@ -275,7 +275,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
if (null == agencyInfo){
nums.add(num);
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
disposeErrorMsg(info,BELONG_AGENCY_ERROR);
return;
}
dto.setPid(agencyInfo.getPid());

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

@ -12,7 +12,9 @@ import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -535,25 +537,26 @@ public class BuildingServiceImpl implements BuildingService {
//如果楼宇单元大于之前的楼宇单元,新增单元
Integer nowUnit= formDTO.getTotalUnitNum();
Integer unit = icBuilding.getTotalUnitNum();
if(nowUnit>=unit){
//新增单元
List<IcBuildingUnitEntity> unitList = new ArrayList<>();
for(int i =unit ;i<nowUnit;i++){
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity();
if(nowUnit<unit){
//如果小于,判断是否存在房屋,如果存在就提示不能更改
throw new EpmetException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(),EpmetErrorCode.ORG_EDIT_FAILED.getMsg(),"暂不支持单元号减小");
}
//新增单元
List<OptionResultDTO> units = icBuildingUnitService.getUnitOptions(icBuilding.getId());
Map<String, String> unitMap = units.stream().collect(Collectors.toMap(OptionResultDTO::getCode, OptionResultDTO::getLabel));
List<IcBuildingUnitEntity> unitList = new ArrayList<>();
for (int i = 1; i <= nowUnit; i++) {
String unitNum = String.valueOf(i);
if (!unitMap.containsKey(unitNum)) {
IcBuildingUnitEntity icBuildingUnit = new IcBuildingUnitEntity();
icBuildingUnit.setBuildingId(icBuilding.getId());
icBuildingUnit.setCustomerId(customerId);
icBuildingUnit.setUnitName((i + 1) +"单元");
icBuildingUnit.setUnitNum(String.valueOf(i+1));
icBuildingUnit.setUnitName(unitNum + "单元");
icBuildingUnit.setUnitNum(unitNum);
unitList.add(icBuildingUnit);
}
icBuildingUnitService.insertBatch(unitList);
}else{
//如果小于,判断是否存在房屋,如果存在就提示不能更改
throw new RenException(EpmetErrorCode.ORG_EDIT_FAILED.getCode(),"楼宇单元下存在房屋,无法更新");
}
icBuildingUnitService.insertBatch(unitList);
}
/**

1
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java

@ -128,6 +128,7 @@ public class IcBuildingUnitServiceImpl extends BaseServiceImpl<IcBuildingUnitDao
return list.stream().map(item -> {
OptionResultDTO dto = new OptionResultDTO();
dto.setValue(item.getId());
dto.setCode(item.getUnitNum());
dto.setLabel(item.getUnitName());
return dto;
}).collect(Collectors.toList());

198
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java

@ -75,10 +75,17 @@ import java.util.stream.Collectors;
@Service
public class IcResiUserImportServiceImpl implements IcResiUserImportService, ResultDataResolver {
public static final List<String> controlGroup1 = Arrays.asList("input", "textarea", "datepicker", "daterange");
public static final List<String> controlGroup2 = Arrays.asList("select", "radio");
/**
* 身份证号列序号
*/
public static final Integer ID_CARD_COLUMN_NO = 9;
/**
* 姓名列序号
*/
public static final Integer ID_NAME_COLUMN_NO = 6;
// 错误和跳过excel行暂存
public static final ThreadLocal<Map<String, List<ErrorRow>>> errorRows = new ThreadLocal<>();
@ -163,9 +170,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
private Integer required;
private List<Integer> colIndex;
//private List<String> colContents;
// 单元格内容
// 单元格内容。多选框没有该列,因为多选框对应着excel的多列
private String cellContent;
// 数据库中列的
// 单元格内容对应的数据库中值
private String colValue;
// key:label,value:value
@ -425,11 +432,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
try {
convertColumnWrappers2Map4Persist(itemIdAndColumnWrapper, row, currUserAgencyId, checkBoxOptionColumnIdxAndLabel, columnAndValues, true);
String idCard = columnAndValues.get("ID_CARD");
// 执行指定的检查
specifiedCheck(columnAndValues);
String idCard = columnAndValues.get("ID_CARD");
Map<String, String> existingResiMap = icResiUserDao.selectResiInfoMap(idCard, null);
if (existingResiMap == null) {
@ -596,7 +602,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
if (resiName == null) {
resiName = "";
}
throw new RenException(EpmetErrorCode.IDCARDNO_ERROR.getCode(), String.format("用户【%s】身份证号未填写或格式错误", resiName));
throw new RenException(EpmetErrorCode.IDCARDNO_ERROR.getCode(), String.format("居民【%s】身份证号未填写或格式错误", resiName));
}
// 检查用户是否存在
@ -719,111 +725,195 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
/**
* 将当前行数据转化成LinkedHashMap供后续插入
* @param itemIdAndColumnWrappers 当前行的ColumnWrapper每一个ColumnWrapper元素都是当前行中的一个列,key:itemId
* @param dbMetadataItemIdAndColumnWrappers 当前行的ColumnWrapper每一条都是数据库中的一个列的源数据对应到excel中可能是多个列多选每一个ColumnWrapper元素都是当前行中的一个列,key:itemId
* @param row 当前行数据
* @param currUserAgencyId 当前用户所属机构ID
* @param checkBoxOptionColumnIdxAndLabel 复选框options列表key:列号value复选框中文
* @param target 要将数据放到哪个对象中
* @param target2Insert 要用来insert到db的数据
* @param isPrimaryTable 是否是主表
*/
private void convertColumnWrappers2Map4Persist(Map<String, ColumnWrapper> itemIdAndColumnWrappers, Map<Integer, String> row,
private void convertColumnWrappers2Map4Persist(Map<String, ColumnWrapper> dbMetadataItemIdAndColumnWrappers, Map<Integer, String> row,
String currUserAgencyId, Map<Integer, String> checkBoxOptionColumnIdxAndLabel,
LinkedHashMap<String, String> target, boolean isPrimaryTable) {
LinkedHashMap<String, String> target2Insert, boolean isPrimaryTable) {
boolean interupt = false;
// 本行中是否有必填但未填,或者填了但填错了系统中找不到的列,那后面的数据可能就没办法通过前面填写的值去关联查询,因此只做必填检查,提示出来就行了,仁至义尽
boolean hasError = false;
List<String> errorColumnNames = new LinkedList<>();
String notFoundColumnName = null;
List<String> emptyColumnNames = new ArrayList<>();
for (Map.Entry<String, ColumnWrapper> itemIdAndColumnWrapper : itemIdAndColumnWrappers.entrySet()) {
// 这两列要提前放进去,因为有的列未填写的话,会抛异常出去,需要用这两列来做描述
target2Insert.put("ID_CARD", row.get(ID_CARD_COLUMN_NO));
target2Insert.put("NAME", row.get(ID_NAME_COLUMN_NO));
String itemId = itemIdAndColumnWrapper.getKey();
ColumnWrapper columnWrapper = itemIdAndColumnWrapper.getValue();
for (Map.Entry<String, ColumnWrapper> dbColumnMetadata : dbMetadataItemIdAndColumnWrappers.entrySet()) {
if ("input".equals(columnWrapper.getItemType())
|| "textarea".equals(columnWrapper.getItemType())
|| "datepicker".equals(columnWrapper.getItemType())
|| "daterange".equals(columnWrapper.getItemType())
) {
String currentItemId = dbColumnMetadata.getKey();
ColumnWrapper columnWrapper = dbColumnMetadata.getValue();
// "input", "textarea", "datepicker", "daterange"
if (controlGroup1.contains(columnWrapper.getItemType())) {
// 输入的控件,不会横跨多个单元格,所以只取一列就可以了
String cellContent = row.get(columnWrapper.getColIndex().get(0));
columnWrapper.setCellContent(cellContent);
columnWrapper.setColValue(cellContent);
} else if ("select".equals(columnWrapper.getItemType())
|| "radio".equals(columnWrapper.getItemType())){
// 必填检查
boolean hasEmptyError = requiredButEmptyCheck(isPrimaryTable, columnWrapper);
if (hasEmptyError) {
emptyColumnNames.add(columnWrapper.combinedLabel);
hasError = true;
continue;
}
if (hasError) {
continue;
}
// "select", "radio"
} else if (controlGroup2.contains(columnWrapper.getItemType())){
String optionSourceType = columnWrapper.getOptionSourceType();
// 取单元格的内容
String cellContent = row.get(columnWrapper.getColIndex().get(0));
columnWrapper.setCellContent(cellContent);
if ("local".equals(optionSourceType)) {
// 必填检查
boolean hasEmptyError = requiredButEmptyCheck(isPrimaryTable, columnWrapper);
if (hasEmptyError) {
emptyColumnNames.add(columnWrapper.combinedLabel);
hasError = true;
continue;
}
if (hasError) {
continue;
}
if ("local".equals(columnWrapper.getOptionSourceType())) {
// 根据单元格内容,取到指定的option
Map<String, String> options = columnWrapper.getOptions();
String colValue = options.get(cellContent);
Map<String, String> itemOptions = columnWrapper.getOptions();
String colValue = itemOptions.get(cellContent);
columnWrapper.setColValue(colValue);
} else {
// remote类型。优先从缓存取
String fullUri = columnWrapper.getOptionSourceValue();
String[] uriParts = splitOptionSourceUrl(fullUri);
String pureUri = uriParts[0];
String superItemId = uriParts[1];
String superColumValue;
String superColumnValue;
// 获取父item的值
if (StringUtils.isNotBlank(superItemId)) {
superColumValue = itemIdAndColumnWrappers.get(superItemId).getColValue();
superColumnValue = dbMetadataItemIdAndColumnWrappers.get(superItemId).getColValue();
} else {
superColumValue = "-";
superColumnValue = "-";
}
Map<String, Map<String, String>> superOptions = itemIdAndOptionsCache.getIfPresent(itemId);
// 通过接口调用,计算出colValue,放到columnWrapper中
Map<String, Map<String, String>> superOptions = itemIdAndOptionsCache.getIfPresent(currentItemId);
if (superOptions != null && superOptions.size() > 0) {
Map<String, String> options = superOptions.get(superColumValue);
Map<String, String> options = superOptions.get(superColumnValue);
if (options == null || options.size() == 0) {
options = listRemoteOptions(pureUri, superItemId, itemIdAndColumnWrappers, currUserAgencyId, "saveorupdate");
superOptions.put(superColumValue, options);
options = listRemoteOptions(pureUri, superItemId, dbMetadataItemIdAndColumnWrappers, currUserAgencyId, "saveorupdate");
superOptions.put(superColumnValue, options);
}
String colValue = options.get(cellContent);
columnWrapper.setColValue(colValue);
} else {
Map<String, String> options = listRemoteOptions(pureUri, superItemId, itemIdAndColumnWrappers, currUserAgencyId, "saveorupdate");
// 父item的options。例如当前遍历的是小区列,那查出来的就是网格下的小区
// 然后把 <currentItemId:<superItem:usperOptions>> 放到缓存里
Map<String, String> options = listRemoteOptions(pureUri, superItemId, dbMetadataItemIdAndColumnWrappers, currUserAgencyId, "saveorupdate");
superOptions = new HashMap<>();
superOptions.put(superColumValue, options);
itemIdAndOptionsCache.put(itemId, superOptions);
superOptions.put(superColumnValue, options);
itemIdAndOptionsCache.put(currentItemId, superOptions);
String colValue = options.get(cellContent);
columnWrapper.setColValue(colValue);
}
}
} else if ("checkbox".equals(columnWrapper.getItemType())) {
//多选框没有具体的cellContent,因为多选框对应着excel的多列。并且复选框,为空就是否,所以不需要做必填检查
String checkBoxColValue = getCheckBoxColValue(columnWrapper, row, checkBoxOptionColumnIdxAndLabel);
columnWrapper.setColValue(checkBoxColValue);
}
// requiredColumns中的值不在排除字段中 && 是必填 && 未填写
if (isPrimaryTable) {
// 主表没有需要排除的列
if (columnWrapper.getRequired() == 1 && StringUtils.isBlank(columnWrapper.colValue)) {
interupt = true;
errorColumnNames.add(columnWrapper.combinedLabel);
}
} else {
// 从表需要排除掉一些不必要校验的列
if (!subTableNeedlessColumns.contains(columnWrapper.columnName)
&& columnWrapper.getRequired() == 1
&& StringUtils.isBlank(columnWrapper.colValue)) {
interupt = true;
errorColumnNames.add(columnWrapper.combinedLabel);
if (hasError) {
continue;
}
}
target.put(columnWrapper.columnName, columnWrapper.colValue);
// 填了,但找不到对应数据的检查
boolean hasNotFoundError = notFoundCheck(isPrimaryTable, columnWrapper);
if (hasNotFoundError) {
notFoundColumnName = columnWrapper.combinedLabel;
hasError = true;
}
target2Insert.put(columnWrapper.columnName, columnWrapper.colValue);
}
if (hasError) {
StringBuilder sb = new StringBuilder();
// 组织报错信息
if (CollectionUtils.isNotEmpty(emptyColumnNames)) {
sb.append(String.join(",", emptyColumnNames)).append("的值未填写;");
}
if (StringUtils.isNotBlank(notFoundColumnName)) {
sb.append(notFoundColumnName).append("填写的值在系统中未找到");
}
throw new EpmetException(sb.toString());
}
}
/**
* 必填但是用户没填的放到list中
* @param isPrimaryTable 是否是主表true是主表false从表
* @param columnWrapper 数据库列包装对象
*/
public boolean requiredButEmptyCheck(Boolean isPrimaryTable, ColumnWrapper columnWrapper) {
// requiredColumns中的值不在排除字段中 && 是必填 && 未填写
if (isPrimaryTable) {
// 主表没有需要排除的列
if (columnWrapper.getRequired() == 1 && StringUtils.isBlank(columnWrapper.cellContent)) {
return true;
}
} else {
// 从表需要排除掉一些不必要校验的列
if (!subTableNeedlessColumns.contains(columnWrapper.columnName)
&& columnWrapper.getRequired() == 1
&& StringUtils.isBlank(columnWrapper.cellContent)) {
return true;
}
}
if (interupt) {
throw new RenException(String.join(",", errorColumnNames) + "的值未填写,或者所填写信息在系统中未找到");
return false;
}
/**
* 必填并且在系统中没找到值的放到list中
* @param isPrimaryTable 是否是主表true是主表false从表
* @param columnWrapper 数据库列包装对象
*/
public boolean notFoundCheck(Boolean isPrimaryTable, ColumnWrapper columnWrapper) {
// requiredColumns中的值不在排除字段中 && 是必填 && 未填写
if (isPrimaryTable) {
// 主表没有需要排除的列
if (columnWrapper.getRequired() == 1 && StringUtils.isBlank(columnWrapper.colValue)) {
return true;
}
} else {
// 从表需要排除掉一些不必要校验的列
if (!subTableNeedlessColumns.contains(columnWrapper.columnName)
&& columnWrapper.getRequired() == 1
&& StringUtils.isBlank(columnWrapper.colValue)) {
return true;
}
}
return false;
}
/**

Loading…
Cancel
Save