| | |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.modules.category.entity.CategoryEntity; |
| | | import org.springblade.modules.category.service.ICategoryService; |
| | |
| | | placeVO.setIsScene(2); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 房屋绑定处理 |
| | | * @param placeEntity |
| | | */ |
| | | public void houseCodeBindHandle(PlaceEntity placeEntity) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(placeEntity.getId()); |
| | | placeVO.setHouseCodeBinds(placeEntity.getHouseCodeBinds()); |
| | | // 绑定 |
| | | houseCodeBindHandle(placeVO); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void importPlace(List<PlaceExcel> data, Boolean isCovered) { |
| | | for (PlaceExcel placeExcel : data) { |
| | | PlaceEntity placeEntity = Objects.requireNonNull(BeanUtil.copy(placeExcel, PlaceEntity.class)); |
| | | // 判断是否存在,不存在则插入,否则不操作 |
| | | QueryWrapper<PlaceEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("house_code", placeExcel.getHouseCode()); |
| | | PlaceEntity one = getOne(wrapper); |
| | | if (null == one) { |
| | | Long userId = updateUser(placeExcel); |
| | | if (null == one) { |
| | | // 插入场所 |
| | | PlaceVO placeEntity = new PlaceVO(); |
| | | String[] split = placeExcel.getHouseCode().split(","); |
| | | placeEntity.setHouseCode(split[0]); |
| | | placeEntity.setHouseCodeBinds(placeExcel.getHouseCode()); |
| | | placeEntity.setPrincipalUserId(userId); |
| | | placeEntity.setPrincipal(placeExcel.getName()); |
| | | placeEntity.setPrincipalPhone(placeExcel.getPhoneNumber()); |
| | | placeEntity.setCreateTime(new Date()); |
| | | placeEntity.setCreateUser(AuthUtil.getUserId()); |
| | | placeEntity.setUpdateTime(new Date()); |
| | | placeEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | // 默认为未完善 |
| | | placeEntity.setStatus(1); |
| | | // 是否现场采集 1:是 2:否 |
| | | placeEntity.setIsScene(1); |
| | | // 来源 1:地址总表 2:国控采集 3:商超 |
| | | if (!Strings.isBlank(placeExcel.getHouseCode())) { |
| | | placeEntity.setSource(1); |
| | | } else { |
| | | placeEntity.setSource(2); |
| | | // 并生成36位的houseCode |
| | | placeEntity.setHouseCode(IdUtils.getIdBy36()); |
| | | } |
| | | // houseCode 关联处理 来源 1:地址总表 2:国控采集 3:商超 |
| | | houseCodeHandle(placeExcel, placeEntity); |
| | | // 九小场所类型处理 |
| | | if (!Strings.isBlank(placeExcel.getNineType())) { |
| | | placeEntity.setIsNine(1); |
| | |
| | | // 新增 |
| | | save(placeEntity); |
| | | // 保存详情 |
| | | savePlaceExtAndTaskInfo(placeEntity); |
| | | savePlaceExt(placeEntity,placeExcel); |
| | | // 场所标签信息处理 |
| | | if (!Strings.isBlank(placeExcel.getLabelCode())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | |
| | | // 房屋编号绑定处理 |
| | | houseCodeBindHandle(placeEntity); |
| | | } else { |
| | | // 更新 |
| | | Long userId = updateUser(placeExcel); |
| | | // 插入场所 |
| | | PlaceVO placeEntity = new PlaceVO(); |
| | | placeEntity.setId(one.getId()); |
| | | placeEntity.setHouseCode(placeExcel.getHouseCode()); |
| | | placeEntity.setHouseCodeBinds(placeExcel.getHouseCode()); |
| | | placeEntity.setPrincipalUserId(userId); |
| | | placeEntity.setPrincipal(placeExcel.getName()); |
| | | placeEntity.setPrincipalPhone(placeExcel.getPhoneNumber()); |
| | | placeEntity.setCreateTime(new Date()); |
| | | placeEntity.setCreateUser(AuthUtil.getUserId()); |
| | | placeEntity.setUpdateTime(new Date()); |
| | | placeEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | // 更新场所 |
| | | one.setPrincipalUserId(userId); |
| | | one.setPrincipal(placeExcel.getPrincipal()); |
| | | one.setPrincipalPhone(placeExcel.getPrincipalPhone()); |
| | | // 默认为未完善 |
| | | placeEntity.setStatus(1); |
| | | one.setStatus(1); |
| | | // 是否现场采集 1:是 2:否 |
| | | placeEntity.setIsScene(1); |
| | | one.setIsScene(1); |
| | | // 来源 1:地址总表 2:国控采集 3:商超 |
| | | placeEntity.setSource(1); |
| | | one.setSource(1); |
| | | // 九小场所类型处理 |
| | | if (!Strings.isBlank(placeExcel.getNineType())) { |
| | | placeEntity.setIsNine(1); |
| | | placeEntity.setNineType(Integer.parseInt(placeExcel.getNineType())); |
| | | one.setIsNine(1); |
| | | one.setNineType(Integer.parseInt(placeExcel.getNineType())); |
| | | } |
| | | // 网格绑定处理 |
| | | importGridHandle(placeExcel, placeEntity); |
| | | importGridHandle(placeExcel, one); |
| | | // 更新 |
| | | updateById(placeEntity); |
| | | updateById(one); |
| | | // 场所标签信息处理 |
| | | if (!Strings.isBlank(placeExcel.getLabelCode())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(placeEntity.getId()); |
| | | placeVO.setId(one.getId()); |
| | | placeVO.setLabel(placeExcel.getLabelCode()); |
| | | // 处理 |
| | | placeLabelBind(placeVO); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 保存场所详情信息 |
| | | * @param placeEntity |
| | | * @param placeExcel |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void savePlaceExt(PlaceEntity placeEntity,PlaceExcel placeExcel) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(placeEntity.getId()); |
| | | PlaceExtEntity placeExtEntity = new PlaceExtEntity(); |
| | | placeExtEntity.setLegalPerson(placeExcel.getLegalPerson()); |
| | | placeExtEntity.setLegalTel(placeExcel.getLegalTel()); |
| | | placeExtEntity.setLegalIdCard(placeExcel.getLegalIdCard()); |
| | | // 设置详情 |
| | | placeVO.setPlaceExtEntity(placeExtEntity); |
| | | // 保存详情 |
| | | savePlaceExtAndTaskInfo(placeVO); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param placeExcel |
| | | * @param placeEntity |
| | | */ |
| | | public void houseCodeHandle(PlaceExcel placeExcel, PlaceEntity placeEntity) { |
| | | if (!Strings.isBlank(placeExcel.getHouseCode())) { |
| | | placeEntity.setSource(1); |
| | | // 设置经纬度及地址 |
| | | DoorplateAddressEntity doorplateAddressEntity |
| | | = doorplateAddressService.getOne(Wrappers.<DoorplateAddressEntity>lambdaQuery().eq(DoorplateAddressEntity::getAddressCode, placeExcel.getHouseCode())); |
| | | if (null!=doorplateAddressEntity){ |
| | | placeEntity.setLng(doorplateAddressEntity.getX()); |
| | | placeEntity.setLat(doorplateAddressEntity.getY()); |
| | | placeEntity.setLocation(doorplateAddressEntity.getAddressName()); |
| | | placeEntity.setBuildingCode(doorplateAddressEntity.getBuildingCode()); |
| | | placeEntity.setAoiCode(doorplateAddressEntity.getAoiCode()); |
| | | } |
| | | } else { |
| | | placeEntity.setSource(2); |
| | | // 并生成36位的houseCode |
| | | placeEntity.setHouseCode(IdUtils.getIdBy36()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导入是网格数据绑定处理 |
| | | * |
| | | * @param placeExcel |
| | | * @param placeEntity |
| | | */ |
| | | private void importGridHandle(PlaceExcel placeExcel, PlaceVO placeEntity) { |
| | | private void importGridHandle(PlaceExcel placeExcel, PlaceEntity placeEntity) { |
| | | if (!Strings.isBlank(placeExcel.getCommunityName()) && |
| | | !Strings.isBlank(placeExcel.getGridName())) { |
| | | // 查询对应的网格信息 |
| | |
| | | * @return |
| | | */ |
| | | public Long updateUser(PlaceExcel placeExcel) { |
| | | if (!Strings.isBlank(placeExcel.getPhoneNumber()) && |
| | | !Strings.isBlank(placeExcel.getName())) { |
| | | if (!Strings.isBlank(placeExcel.getPrincipal()) && |
| | | !Strings.isBlank(placeExcel.getPrincipalPhone())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setPrincipal(placeExcel.getPhoneNumber()); |
| | | placeVO.setPrincipalPhone(placeExcel.getName()); |
| | | placeVO.setPrincipal(placeExcel.getPrincipal()); |
| | | placeVO.setPrincipalPhone(placeExcel.getPrincipalPhone()); |
| | | // 更新场所负责人 |
| | | User user = bindUserHandle(placeVO); |
| | | // 返回 |