|
@@ -1,16 +1,23 @@
|
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.net.multipart.UploadFile;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.db.response.PageInfo;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.scene.bean.IconBean;
|
|
|
import com.fdkankan.scene.entity.*;
|
|
|
+import com.fdkankan.scene.httpclient.ManageHttpClient;
|
|
|
import com.fdkankan.scene.mapper.ISceneEvidenceMapper;
|
|
|
import com.fdkankan.scene.service.ISceneEditInfoService;
|
|
|
import com.fdkankan.scene.service.ISceneEvidenceService;
|
|
@@ -23,6 +30,7 @@ import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -43,6 +51,10 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
private ISceneEditInfoService sceneEditInfoService;
|
|
|
@Autowired
|
|
|
private ISceneIconService sceneIconService;
|
|
|
+ @Resource
|
|
|
+ private ManageHttpClient manageHttpClient;
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
|
|
|
@Override
|
|
|
public void saveEvidence(SaveEvidenceParamVO param) throws Exception {
|
|
@@ -179,4 +191,85 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
.eq(SceneIcon::getNum, param.getNum())
|
|
|
.in(SceneIcon::getFileName, param.getFileNameList()));
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData<List<JSONObject>> traceEvidenceList(JSONObject param) {
|
|
|
+ ResultData<List<JSONObject>> resultData = manageHttpClient.traceEvidenceList(param);
|
|
|
+ return resultData;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData traceEvidenceInfoList(TraceEvidenceInfoListParamVo param) {
|
|
|
+ if(StrUtil.isEmpty(param.getKno())){
|
|
|
+ return ResultData.ok(new PageInfo<>());
|
|
|
+ }
|
|
|
+ return manageHttpClient.traceEvidenceInfoList(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData refreshTraceEvidenceInfoList(String kno) {
|
|
|
+ return manageHttpClient.refreshTraceEvidenceInfoList(kno);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData syncTraceEvidence(SaveEvidenceParamVO param) throws Exception {
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
|
+ if (scenePlus == null)
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+
|
|
|
+ List<JSONObject> collect = param.getDataList().stream().map(v -> {
|
|
|
+ JSONObject data = v.getData();
|
|
|
+ JSONArray medias = data.getJSONArray("media");
|
|
|
+ if (CollUtil.isNotEmpty(medias)) {
|
|
|
+ medias.stream().forEach(m -> {
|
|
|
+ JSONObject media = (JSONObject) m;
|
|
|
+ String path = media.getString("path");
|
|
|
+ String fileName = FileUtil.getName(path);
|
|
|
+ String newFileName = UUID.randomUUID().toString() + "." + FileUtil.extName(fileName);
|
|
|
+ String meshKey = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + newFileName;
|
|
|
+ fYunFileServiceInterface.copyFileInBucket(path, meshKey);
|
|
|
+ media.put("src", newFileName);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ this.saveEvidence(param);
|
|
|
+
|
|
|
+ return ResultData.ok(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ JSONObject test = new JSONObject();
|
|
|
+ JSONArray medias = new JSONArray();
|
|
|
+ JSONObject media = new JSONObject();
|
|
|
+ media.put("src","name");
|
|
|
+ media.put("type","image");
|
|
|
+ JSONObject media2 = new JSONObject();
|
|
|
+ media2.put("src","name2");
|
|
|
+ media2.put("type","image2");
|
|
|
+ medias.add(media);
|
|
|
+ medias.add(media2);
|
|
|
+ test.put("media", medias);
|
|
|
+ System.out.println(test.toJSONString());
|
|
|
+
|
|
|
+ JSONObject data = JSON.parseObject(test.toJSONString());
|
|
|
+
|
|
|
+ JSONArray mediaList = data.getJSONArray("media");
|
|
|
+ if(CollUtil.isNotEmpty(mediaList)){
|
|
|
+ mediaList.stream().forEach(m->{
|
|
|
+ JSONObject media3 = (JSONObject) m;
|
|
|
+ String path = media3.getString("path");
|
|
|
+ String fileName = FileUtil.getName(path);
|
|
|
+ String newFileName = UUID.randomUUID().toString() + "." + FileUtil.extName(fileName);
|
|
|
+// String meshKey = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + newFileName;
|
|
|
+// fYunFileServiceInterface.copyFileInBucket(path, meshKey);
|
|
|
+ media3.put("src", newFileName);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println(data.toJSONString());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|