| | |
| | | */ |
| | | package org.springblade.modules.place.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.node.TreeNode; |
| | |
| | | * @param placeVO |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void bindUserHandle(PlaceVO placeVO) { |
| | | public User bindUserHandle(PlaceVO placeVO) { |
| | | User newUser = new User(); |
| | | if (null!=placeVO.getPhone() && !placeVO.getPhone().equals("")) { |
| | | //根据手机号查询库里的数据 |
| | | User userParams = new User(); |
| | |
| | | if (user != null) { |
| | | //如果用户存在,则该用户id绑定场所 |
| | | placeVO.setPrincipalUserId(user.getId()); |
| | | return user; |
| | | } else { |
| | | //如果用户不存在,则新增一个用户 |
| | | User newUser = new User(); |
| | | newUser.setAccount(placeVO.getPhone()); |
| | | newUser.setPhone(placeVO.getPhone()); |
| | | newUser.setName(placeVO.getUsername()); |
| | |
| | | //绑定id |
| | | placeVO.setPrincipalUserId(newUser.getId()); |
| | | //给人员打上场所负责人的标签 |
| | | |
| | | baseMapper.saveUserLabel(newUser.getId(),1002); |
| | | // 用户插入后同时给场所详情表插入一条该场所信息 |
| | | if (submit){ |
| | | PlaceExtEntity placeExtEntity = new PlaceExtEntity(); |
| | | placeExtEntity.setPlaceId(placeVO.getId()); |
| | | //新增 |
| | | placeExtService.savePlaceExt(placeExtEntity); |
| | | // 判断是否已存在,已存在则不新增 |
| | | QueryWrapper<PlaceExtEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0) |
| | | .eq("place_id",placeVO.getId()); |
| | | PlaceExtEntity one = placeExtService.getOne(wrapper); |
| | | if (null == one) { |
| | | //新增 |
| | | placeExtService.savePlaceExt(placeExtEntity); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return newUser; |
| | | } |
| | | |
| | | /** |
| | | * 历史场所挂接处理-临时 |
| | | * @param place |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object historyPlaceHandle(PlaceVO place) { |
| | | // 查询所有的场所(手机号不为空) |
| | | List<PlaceVO> list = baseMapper.getPlaceNotNullPhone(); |
| | | // 遍历 |
| | | for (PlaceVO placeVO : list) { |
| | | User user = bindUserHandle(placeVO); |
| | | if (null!=user){ |
| | | placeVO.setPrincipalUserId(user.getId()); |
| | | //更新场所用户id绑定 |
| | | baseMapper.updatePlaceEntity(placeVO); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 历史场所标签挂接处理-临时 |
| | | * @param place |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public Object historyPlaceLabelHandle(PlaceVO place) { |
| | | // 查询所有的场所 |
| | | List<PlaceVO> list = baseMapper.getAllHistoryPlace(); |
| | | // 遍历 |
| | | for (PlaceVO placeVO : list) { |
| | | if (null!=placeVO.getLabel()){ |
| | | String[] split = placeVO.getLabel().split(","); |
| | | for (String s : split) { |
| | | PlacePoiLabel placePoiLabel = new PlacePoiLabel(); |
| | | placePoiLabel.setPlaceId(placeVO.getId()); |
| | | placePoiLabel.setPoiCode(Integer.parseInt(s)); |
| | | placePoiLabelService.save(placePoiLabel); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |