| | |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.house.entity.HouseRentalEntity; |
| | | import org.springblade.modules.house.entity.HouseholdEntity; |
| | | import org.springblade.modules.house.entity.UserHouseLabelEntity; |
| | | import org.springblade.modules.house.excel.ExportHouseholdExcel; |
| | | import org.springblade.modules.house.excel.ImportHouseholdExcel; |
| | | import org.springblade.modules.house.mapper.HouseholdMapper; |
| | | import org.springblade.modules.house.service.IHouseRentalService; |
| | | import org.springblade.modules.house.service.IHouseService; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.house.service.IUserHouseLabelService; |
| | |
| | | |
| | | @Autowired |
| | | private IPlaceService placeService; |
| | | |
| | | @Autowired |
| | | private IHouseRentalService iHouseRentalService; |
| | | |
| | | |
| | | @Override |
| | | public IPage<HouseholdVO> selectHouseholdPage(IPage<HouseholdVO> page, HouseholdVO household) { |
| | |
| | | |
| | | /** |
| | | * 导入住户数据 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String importUserHouseHold(List<ImportHouseholdExcel> data, Boolean isCovered) { |
| | | public String importUserHouseHold(List<ImportHouseholdExcel> data, Boolean isCovered, String isTenant) { |
| | | IHouseService houseService = SpringUtils.getBean(IHouseService.class); |
| | | int totalNum = data.size(); |
| | | int importNum = 0; |
| | |
| | | for (ImportHouseholdExcel houseHoldExcel : data) { |
| | | HouseholdEntity householdEntity = Objects.requireNonNull(BeanUtil.copy(houseHoldExcel, HouseholdEntity.class)); |
| | | // 判断姓名,手机号 |
| | | if (Strings.isBlank(householdEntity.getName()) || Strings.isBlank(householdEntity.getPhoneNumber())){ |
| | | errorNum ++; |
| | | if (Strings.isBlank(householdEntity.getName()) |
| | | || Strings.isBlank(householdEntity.getPhoneNumber()) |
| | | || Strings.isBlank(householdEntity.getHouseCode()) |
| | | ) { |
| | | errorNum++; |
| | | continue; |
| | | } |
| | | // 查询库中是否已存在 |
| | |
| | | // 如果是业主,则需要往用户表插入用户 |
| | | if (householdEntity.getRelationship() == 1) { |
| | | houseService.saveOrUpdateUser(householdEntity); |
| | | } |
| | | } |
| | | // 判断是否租户导入 |
| | | if (StringUtils.isNotBlank(isTenant)) { |
| | | householdEntity.setRelationship(18); |
| | | HouseRentalEntity houseRentalEntity = iHouseRentalService.getOne(Wrappers.<HouseRentalEntity>lambdaQuery() |
| | | .eq(HouseRentalEntity::getHouseCode, householdEntity.getHouseCode())); |
| | | if (houseRentalEntity != null) { |
| | | householdEntity.setHousingRentalId(houseRentalEntity.getId()); |
| | | } else { |
| | | errorNum++; |
| | | continue; |
| | | } |
| | | } |
| | | /// 是否主要联系人 |
| | |
| | | } |
| | | StringBuilder builder = new StringBuilder("导入完成!"); |
| | | builder.append("其中本次表格共有 ").append(totalNum).append(" 条数据,") |
| | | .append("成功导入 ").append(importNum).append(" 条数据,") |
| | | .append("其中有 ").append(updateNum).append(" 条数据已存在。"); |
| | | .append("成功导入 ").append(importNum).append(" 条数据。"); |
| | | if (updateNum>0) { |
| | | builder.append("其中有 ").append(updateNum).append(" 条数据已存在。"); |
| | | } |
| | | if (errorNum>0){ |
| | | builder.append("共有 ").append(errorNum).append(" 条数据由于无姓名或手机号信息未导入!"); |
| | | builder.append("共有 ").append(errorNum).append(" 条数据由于无姓名或手机号或门牌地址编码信息未导入!"); |
| | | } |
| | | return builder.toString(); |
| | | } |