|
@@ -1,106 +0,0 @@
|
|
|
-package com.fdkankan.fusion.service.impl;
|
|
|
-
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fdkankan.fusion.common.FilePath;
|
|
|
-import com.fdkankan.fusion.common.util.UploadToOssUtil;
|
|
|
-import com.fdkankan.fusion.laser.entity.PoiEntity;
|
|
|
-import com.fdkankan.fusion.laser.entity.PoiHotDto;
|
|
|
-import com.fdkankan.fusion.laser.entity.PoiTypeEntity;
|
|
|
-import com.fdkankan.fusion.laser.service.PoiService;
|
|
|
-import com.fdkankan.fusion.laser.service.PoiTypeService;
|
|
|
-import com.fdkankan.fusion.response.HotVo;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-@Service
|
|
|
-public class FdHotService {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- UploadToOssUtil uploadToOssUtil;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PoiService poiService;
|
|
|
- @Autowired
|
|
|
- private PoiTypeService poiTypeService;
|
|
|
- /**
|
|
|
- * 获取四维热点数据 to oss
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<HotVo> getHotList(List<String> numList, Integer type){
|
|
|
- if(type == 2){
|
|
|
- return getLaserHot(numList);
|
|
|
- }
|
|
|
- List<HotVo> list = new ArrayList<>();
|
|
|
- for (String num : numList) {
|
|
|
- String ossPath = String.format(FilePath.hotPath, num);
|
|
|
- if(!uploadToOssUtil.existKey(ossPath)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- String hotString = uploadToOssUtil.getObjectContent("4dkankan",ossPath );
|
|
|
- if(StringUtils.isEmpty(hotString)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- JSONArray array = JSONObject.parseArray(hotString);
|
|
|
- for (Object obj : array) {
|
|
|
-
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(obj));
|
|
|
- HotVo hotVo = new HotVo();
|
|
|
- hotVo.setId(jsonObject.getString("sid"));
|
|
|
- hotVo.setTitle(jsonObject.getString("title"));
|
|
|
- hotVo.setNum(num);
|
|
|
- hotVo.setContent(jsonObject.getString("content"));
|
|
|
- hotVo.setNumType(type);
|
|
|
- hotVo.setType(jsonObject.getString("type"));
|
|
|
- String icon = StringUtils.isEmpty(jsonObject.getString("icon") ) ? FilePath.hotIconDefaultPath : jsonObject.getString("icon");
|
|
|
- hotVo.setIcon(icon);
|
|
|
- list.add(hotVo);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取机关热点数据
|
|
|
- */
|
|
|
- private List<HotVo> getLaserHot(List<String> numList){
|
|
|
- List<HotVo> voList = new ArrayList<>();
|
|
|
-
|
|
|
- List<PoiEntity> list = poiService.getHotList(numList);
|
|
|
- List<PoiHotDto> poiHotDtoList = list.stream().map(a -> {
|
|
|
- PoiHotDto dto = new PoiHotDto();
|
|
|
- BeanUtil.copyProperties(a, dto);
|
|
|
- PoiTypeEntity poiType = poiTypeService.findById(a.getPoiStyleId());
|
|
|
- if (ObjectUtil.isNotNull(poiType)) {
|
|
|
- dto.setHotStyleAtom(poiType);
|
|
|
- }
|
|
|
- return dto;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- for (PoiHotDto poiHotDto : poiHotDtoList) {
|
|
|
- HotVo hotVo = new HotVo();
|
|
|
- hotVo.setId(poiHotDto.getId());
|
|
|
- hotVo.setTitle(poiHotDto.getTitle());
|
|
|
- hotVo.setNum(poiHotDto.getSceneCode());
|
|
|
- hotVo.setContent(poiHotDto.getContent());
|
|
|
- hotVo.setNumType(2);
|
|
|
- hotVo.setType(poiHotDto.getType().name());
|
|
|
- String icon = poiHotDto.getHotStyleAtom() == null ? FilePath.hotIconDefaultPath : poiHotDto.getHotStyleAtom().getIcon();
|
|
|
- hotVo.setIcon(icon);
|
|
|
- voList.add(hotVo);
|
|
|
- }
|
|
|
- return voList;
|
|
|
- }
|
|
|
-
|
|
|
-}
|