| | |
| | | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.dto.operation.PointAddDto; |
| | |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.evi.oss.service.AliOssService; |
| | | import com.xiaopeng.map.constant.I18nKeyConstant; |
| | | import com.xiaopeng.map.dto.NearestDto; |
| | | import com.xiaopeng.map.mapper.XpPointMapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | | |
| | | @Autowired |
| | | private AliOssService aliOssService; |
| | | |
| | | @Override |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | |
| | | if (pointAddDto.getElectronicAreaId() == null) { |
| | | throw new ServiceException("运营区域ID不能为空", I18nKeyConstant.POINT_ELECTRONIC_AREA_ID_EMPTY); |
| | | } |
| | | validatePointNameUnique(pointAddDto.getPointName(), null); |
| | | |
| | | String cityPrefix = buildCityPrefix(pointAddDto.getElectronicAreaId()); |
| | | String lockKey = buildPointNumberLockKey(cityPrefix, POINT_BIZ_TYPE); |
| | |
| | | xpPoint.setPointNumber(pointNumber); |
| | | this.save(xpPoint); |
| | | return xpPoint; |
| | | } |
| | | |
| | | @Override |
| | | public void validatePointNameUnique(String pointName, Long excludeId) { |
| | | if (!StringUtils.hasText(pointName)) { |
| | | return; |
| | | } |
| | | long count = this.lambdaQuery() |
| | | .eq(XpPoint::getPointName, pointName) |
| | | .ne(excludeId != null, XpPoint::getId, excludeId) |
| | | .count(); |
| | | if (count > 0) { |
| | | throw new ServiceException("点位名称已存在", I18nKeyConstant.POINT_NAME_EXISTS); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public List<XpPoint> listAll(PointListQuery query) { |
| | | List<XpPoint> list = this.baseMapper.listAll(query); |
| | | for (XpPoint xpPoint : list) { |
| | | String pointPictures = xpPoint.getPointPictures(); |
| | | log.info("pointPictures:{}", pointPictures); |
| | | if (StringUtils.isNotBlank(pointPictures)) { |
| | | log.info("pointPictures进入处理:{}", pointPictures); |
| | | |
| | | JSONArray jsonArray = JSONArray.parseArray(pointPictures); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl =""; |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | log.info("downloadUrl:{}", downloadUrl); |
| | | } catch (UnsupportedEncodingException e) { |
| | | log.error("获取图片下载地址失败", e); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | log.info("jsonArray:{}", jsonArray); |
| | | xpPoint.setPointPictures(JSONArray.toJSONString(jsonArray)); |
| | | log.info("xpPoint:{}", xpPoint.getPointPictures()); |
| | | } |
| | | |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |