|
|
@ -39,17 +39,12 @@ import com.epmet.constant.CustomerGridConstant; |
|
|
|
import com.epmet.dao.CustomerGridDao; |
|
|
|
import com.epmet.dao.IcNeighborHoodDao; |
|
|
|
import com.epmet.dao.IcPropertyManagementDao; |
|
|
|
import com.epmet.dto.IcNeighborHoodDTO; |
|
|
|
import com.epmet.dto.NeighborHoodAndManagementDTO; |
|
|
|
import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.ImportInfoFormDTO; |
|
|
|
import com.epmet.dto.result.InfoByNamesResultDTO; |
|
|
|
import com.epmet.entity.IcNeighborHoodEntity; |
|
|
|
import com.epmet.entity.IcNeighborHoodPropertyEntity; |
|
|
|
import com.epmet.entity.IcPropertyManagementEntity; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.excel.IcNeighborHoodExcel; |
|
|
|
import com.epmet.service.IcNeighborHoodPropertyService; |
|
|
|
import com.epmet.service.IcNeighborHoodService; |
|
|
|
import com.epmet.service.IcPropertyManagementService; |
|
|
|
import com.epmet.service.*; |
|
|
|
import com.epmet.util.ExcelPoiUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
@ -60,6 +55,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -82,6 +78,10 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao |
|
|
|
private IcPropertyManagementService propertyManagementService; |
|
|
|
@Autowired |
|
|
|
private IcNeighborHoodPropertyService neighborHoodPropertyService; |
|
|
|
@Resource |
|
|
|
private IcBuildingService icBuildingService; |
|
|
|
@Resource |
|
|
|
private IcBuildingUnitService icBuildingUnitService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcNeighborHoodDTO> page(Map<String, Object> params) { |
|
|
@ -406,4 +406,139 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取导入小区,楼栋,单元ID |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @param list |
|
|
|
* @Param formDTO |
|
|
|
* @Param list |
|
|
|
* @Return {@link List< ImportHouseGeneralDTO >} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/2/14 9:40 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ImportHouseGeneralDTO> getImportInfo(ImportInfoFormDTO formDTO, List<ImportHouseGeneralDTO> list) { |
|
|
|
list.forEach(item -> { |
|
|
|
if (StringUtils.isEmpty(item.getNeighborHoodId())) { |
|
|
|
//1.获取小区ID,判断小区是否存在,不存在则添加小区,存在则直接获取小区ID
|
|
|
|
String neighborHoodId = getNeighborHoodId(formDTO.getCustomerId(), item); |
|
|
|
item.setNeighborHoodId(neighborHoodId); |
|
|
|
//2.获取楼栋ID,判断楼栋是否存在,不存在则添加楼栋,存在则直接获取楼栋ID
|
|
|
|
if (StringUtils.isEmpty(item.getBuildingId())) { |
|
|
|
String buildingId = getBuildingId(formDTO.getCustomerId(), item); |
|
|
|
item.setBuildingId(buildingId); |
|
|
|
} |
|
|
|
//3.获取单元ID,判断单元是否存在,不存在则添加单元,存在则直接获取单元ID
|
|
|
|
if (null != item.getBuildingUnit()) { |
|
|
|
String unitId = getUnitId(formDTO.getCustomerId(), item); |
|
|
|
item.setBuildingUnitId(unitId); |
|
|
|
} |
|
|
|
} else if (StringUtils.isNotEmpty(item.getNeighborHoodId()) && StringUtils.isEmpty(item.getBuildingId())) { |
|
|
|
//获取楼栋ID,判断楼栋是否存在,不存在则添加楼栋,存在则直接获取楼栋ID
|
|
|
|
String buildingId = getBuildingId(formDTO.getCustomerId(), item); |
|
|
|
item.setBuildingId(buildingId); |
|
|
|
//获取单元ID,判断单元是否存在,不存在则添加单元,存在则直接获取单元ID
|
|
|
|
if (null != item.getBuildingUnit()) { |
|
|
|
String unitId = getUnitId(formDTO.getCustomerId(), item); |
|
|
|
item.setBuildingUnitId(unitId); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据小区名获取小区ID,如果没有,先新增小区 |
|
|
|
* @Param gridId |
|
|
|
* @Param name |
|
|
|
* @Return {@link String} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/2/14 9:50 |
|
|
|
*/ |
|
|
|
private String getNeighborHoodId(String customerId, ImportHouseGeneralDTO info) { |
|
|
|
//根据网格ID和小区名获取小区信息
|
|
|
|
LambdaQueryWrapper<IcNeighborHoodEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcNeighborHoodEntity::getGridId, info.getGridId()); |
|
|
|
wrapper.eq(IcNeighborHoodEntity::getNeighborHoodName, info.getNeighborHoodName()); |
|
|
|
IcNeighborHoodEntity entity = baseDao.selectOne(wrapper); |
|
|
|
if (null != entity) { |
|
|
|
return entity.getId(); |
|
|
|
} |
|
|
|
entity = new IcNeighborHoodEntity(); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setAgencyId(info.getAgencyId()); |
|
|
|
entity.setParentAgencyId(info.getPid()); |
|
|
|
entity.setAgencyPids(info.getPids()); |
|
|
|
entity.setGridId(info.getGridId()); |
|
|
|
entity.setNeighborHoodName(info.getNeighborHoodName()); |
|
|
|
baseDao.insert(entity); |
|
|
|
return entity.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取楼栋ID |
|
|
|
* @Param customerId |
|
|
|
* @Param info |
|
|
|
* @Return {@link String} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/2/14 15:36 |
|
|
|
*/ |
|
|
|
private String getBuildingId(String customerId, ImportHouseGeneralDTO info) { |
|
|
|
//根据小区ID和楼栋名获取楼栋信息
|
|
|
|
IcBuildingDTO building = icBuildingService.getBuildingInfo(info.getNeighborHoodId(), info.getBuildingName()); |
|
|
|
if (null != building) { |
|
|
|
return building.getId(); |
|
|
|
} |
|
|
|
IcBuildingEntity buildingEntity = new IcBuildingEntity(); |
|
|
|
buildingEntity.setCustomerId(customerId); |
|
|
|
buildingEntity.setNeighborHoodId(info.getNeighborHoodId()); |
|
|
|
buildingEntity.setBuildingName(info.getBuildingName()); |
|
|
|
buildingEntity.setType(null == info.getType()?NumConstant.ONE_STR:info.getType()); |
|
|
|
buildingEntity.setTotalUnitNum(info.getTotalUnitNum()); |
|
|
|
buildingEntity.setTotalFloorNum(info.getTotalFloorNum()); |
|
|
|
buildingEntity.setTotalHouseNum(info.getTotalHouseNum()); |
|
|
|
icBuildingService.insert(buildingEntity); |
|
|
|
if (null != info.getTotalUnitNum() && info.getTotalUnitNum() > NumConstant.ZERO) { |
|
|
|
//设置楼宇单元
|
|
|
|
List<IcBuildingUnitEntity> unitList = new ArrayList<>(); |
|
|
|
for (int i =0 ; i<info.getTotalUnitNum(); i++){ |
|
|
|
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity(); |
|
|
|
icBuildingUnit.setCustomerId(customerId); |
|
|
|
icBuildingUnit.setBuildingId(buildingEntity.getId()); |
|
|
|
icBuildingUnit.setUnitName((i + 1) +"单元"); |
|
|
|
icBuildingUnit.setUnitNum(String.valueOf(i+1)); |
|
|
|
unitList.add(icBuildingUnit); |
|
|
|
} |
|
|
|
icBuildingUnitService.insertBatch(unitList); |
|
|
|
} |
|
|
|
return buildingEntity.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取单元ID |
|
|
|
* @Param customerId |
|
|
|
* @Param info |
|
|
|
* @Return {@link String} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/2/14 16:01 |
|
|
|
*/ |
|
|
|
private String getUnitId(String customerId, ImportHouseGeneralDTO info) { |
|
|
|
//根据楼栋ID和单元名获取单元信息
|
|
|
|
IcBuildingUnitDTO unit = icBuildingUnitService.getUnitInfo(info.getBuildingId(), String.valueOf(info.getBuildingUnit())); |
|
|
|
if (null != unit) { |
|
|
|
return unit.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
IcBuildingUnitEntity unitEntity = new IcBuildingUnitEntity(); |
|
|
|
unitEntity.setCustomerId(customerId); |
|
|
|
unitEntity.setBuildingId(info.getBuildingId()); |
|
|
|
unitEntity.setUnitName(info.getBuildingUnit() +"单元"); |
|
|
|
unitEntity.setUnitNum(String.valueOf(info.getBuildingUnit())); |
|
|
|
icBuildingUnitService.insert(unitEntity); |
|
|
|
|
|
|
|
return unitEntity.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|