|
@@ -1,5 +1,8 @@
|
|
package com.fdkankan.indoor.core.service.impl;
|
|
package com.fdkankan.indoor.core.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.indoor.base.constant.MsgCode;
|
|
import com.fdkankan.indoor.base.constant.MsgCode;
|
|
import com.fdkankan.indoor.base.exception.BaseRuntimeException;
|
|
import com.fdkankan.indoor.base.exception.BaseRuntimeException;
|
|
@@ -20,7 +23,9 @@ import org.springframework.data.mongodb.core.query.Criteria;
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
import org.springframework.data.mongodb.core.query.Update;
|
|
import org.springframework.data.mongodb.core.query.Update;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -60,6 +65,33 @@ public class PoiServiceImpl extends IBaseServiceImpl implements PoiService {
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Result upload(String sceneCode, MultipartFile file) {
|
|
|
|
+ if (file == null) {
|
|
|
|
+ throw new RuntimeException("文件为空");
|
|
|
|
+ }
|
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
|
+ String suffix = StrUtil.subAfter(originalFilename, ".", true);
|
|
|
|
+
|
|
|
|
+// String newName = DateUtil.format(LocalDateTime.now(), "yyyyMMdd_HHmmssSSS");
|
|
|
|
+ UUID uuid = UUID.randomUUID();
|
|
|
|
+ String newName = "poi-" + uuid + "." + suffix;
|
|
|
|
+
|
|
|
|
+ String urlPath = "/" + sceneCode + "/poi/image/" + newName;
|
|
|
|
+ String savePath = configConstant.serverBasePath + urlPath;
|
|
|
|
+ log.info("保存图片路径:{}", savePath);
|
|
|
|
+ try {
|
|
|
|
+ FileUtil.writeFromStream(file.getInputStream(), savePath);
|
|
|
|
+
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ HashMap<Object, Object> result = new HashMap<>();
|
|
|
|
+ result.put("url", newName);
|
|
|
|
+ return Result.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result findBySceneCodeAndId(String code, Integer id) {
|
|
public Result findBySceneCodeAndId(String code, Integer id) {
|
|
@@ -138,7 +170,7 @@ public class PoiServiceImpl extends IBaseServiceImpl implements PoiService {
|
|
dto.setId(maxId);
|
|
dto.setId(maxId);
|
|
}
|
|
}
|
|
|
|
|
|
- // 通过poi_type_id 去poi_type表找对应icon
|
|
|
|
|
|
+ // 通过poi_type_id 去poi_type表找id对应icon
|
|
if (dto.getIcon() == null) {
|
|
if (dto.getIcon() == null) {
|
|
dto.setIcon(getIcon(sceneCode, dto.getPoi_type_id()));
|
|
dto.setIcon(getIcon(sceneCode, dto.getPoi_type_id()));
|
|
log.info("设置图标:{}", dto.getIcon());
|
|
log.info("设置图标:{}", dto.getIcon());
|
|
@@ -170,7 +202,12 @@ public class PoiServiceImpl extends IBaseServiceImpl implements PoiService {
|
|
|
|
|
|
private String getIcon(String sceneCode, Integer poiTypeId){
|
|
private String getIcon(String sceneCode, Integer poiTypeId){
|
|
PoiTypeDto dto = poiTypeService.findBySceneCodeAndPoiTypeId(sceneCode, poiTypeId);
|
|
PoiTypeDto dto = poiTypeService.findBySceneCodeAndPoiTypeId(sceneCode, poiTypeId);
|
|
- return dto.getIcon();
|
|
|
|
|
|
+ if (dto != null) {
|
|
|
|
+ return dto.getIcon();
|
|
|
|
+ }
|
|
|
|
+ log.warn("没有找到对应热点分类信息, 默认icon为空");
|
|
|
|
+ // 没有返回空
|
|
|
|
+ return "";
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -248,6 +285,7 @@ public class PoiServiceImpl extends IBaseServiceImpl implements PoiService {
|
|
//// System.out.println("列表中最小的数 : " + stats.getMin());
|
|
//// System.out.println("列表中最小的数 : " + stats.getMin());
|
|
//// System.out.println("所有数之和 : " + stats.getSum());
|
|
//// System.out.println("所有数之和 : " + stats.getSum());
|
|
//// System.out.println("平均数 : " + stats.getAverage());
|
|
//// System.out.println("平均数 : " + stats.getAverage());
|
|
|
|
+ System.out.println(UUID.randomUUID());
|
|
|
|
|
|
numbers.stream().peek(System.out::println).count();
|
|
numbers.stream().peek(System.out::println).count();
|
|
}
|
|
}
|