zhongrj
2024-05-11 d689bfe3c6eb74384ea8cf3b5db3e924f05d5677
场所信息导入修改
3 files modified
167 ■■■■■ changed files
src/main/java/org/springblade/modules/place/excel/PlaceExcel.java 42 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java 123 ●●●●● patch | view | raw | blame | history
src/main/resources/application-test.yml 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/place/excel/PlaceExcel.java
@@ -39,21 +39,51 @@
    @ExcelProperty( "网格名称")
    private String gridName;
    /** 经营者 */
    /** 场所负责人 */
    @ColumnWidth(15)
    @ExcelProperty( "经营者")
    private String name;
    @ExcelProperty( "场所负责人")
    private String principal;
    /** 联系电话 */
    /** 场所负责人联系电话 */
    @ColumnWidth(15)
    @ExcelProperty( "联系电话")
    private String phoneNumber;
    @ExcelProperty( "场所负责人联系电话")
    private String principalPhone;
    /** 企业法定代表 */
    @ColumnWidth(15)
    @ExcelProperty( "企业法定代表")
    private String legalPerson;
    /** 法定代表联系电话 */
    @ColumnWidth(15)
    @ExcelProperty( "法定代表联系电话")
    private String legalTel;
    /** 企业法定代表身份证号码 */
    @ColumnWidth(15)
    @ExcelProperty( "企业法定代表身份证号码")
    private String legalIdCard;
    /** 企业(店铺)名称 */
    @ColumnWidth(25)
    @ExcelProperty( "企业(店铺)名称")
    private String placeName;
    /** 地址 */
    @ColumnWidth(25)
    @ExcelProperty( "地址")
    private String location;
    /** 经度 */
    @ColumnWidth(25)
    @ExcelProperty( "经度")
    private String lng;
    /** 纬度 */
    @ColumnWidth(25)
    @ExcelProperty( "纬度")
    private String lat;
    /** 九小场所类型 */
    @ExcelProperty( value = "九小场所类型",converter = ExcelDictConverter.class)
    @ExcelDictItemLabel(type = "nineType")
src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java
@@ -32,6 +32,7 @@
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;
@@ -353,6 +354,18 @@
                placeVO.setIsScene(2);
            }
        }
    }
    /**
     * 房屋绑定处理
     * @param placeEntity
     */
    public void houseCodeBindHandle(PlaceEntity placeEntity) {
        PlaceVO placeVO = new PlaceVO();
        placeVO.setId(placeEntity.getId());
        placeVO.setHouseCodeBinds(placeEntity.getHouseCodeBinds());
        // 绑定
        houseCodeBindHandle(placeVO);
    }
    /**
@@ -998,37 +1011,25 @@
    @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);
            Long userId = updateUser(placeExcel);
            if (null == one) {
                Long userId = updateUser(placeExcel);
                // 插入场所
                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);
@@ -1039,7 +1040,7 @@
                // 新增
                save(placeEntity);
                // 保存详情
                savePlaceExtAndTaskInfo(placeEntity);
                savePlaceExt(placeEntity,placeExcel);
                // 场所标签信息处理
                if (!Strings.isBlank(placeExcel.getLabelCode())) {
                    PlaceVO placeVO = new PlaceVO();
@@ -1051,39 +1052,29 @@
                // 房屋编号绑定处理
                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);
@@ -1093,12 +1084,56 @@
    }
    /**
     * 保存场所详情信息
     * @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())) {
            // 查询对应的网格信息
@@ -1126,11 +1161,11 @@
     * @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);
            // 返回
src/main/resources/application-test.yml
@@ -76,5 +76,5 @@
elasticsearch:
  enabled: false
  host: 127.0.0.1
  sync: true
  sync: false
  indexName: test