Kaynağa Gözat

增加热点与素材的关联,删除文件夹同步删除子文件夹以及里面的素材,修改查询历史数据 文件夹里面的素材不被查询

xiewj 2 yıl önce
ebeveyn
işleme
f4f120556a

+ 2 - 2
720yun_fd_manage/gis_application/src/main/resources/application-dev.properties

@@ -31,9 +31,9 @@ spring.datasource.druid.stat-view-servlet.enabled=true
 
 
 # redis \uFFFD\u05B2\uFFFD\u02BD\uFFFD\uFFFD
-spring.redis.cluster.nodes=127.0.0.1:6379
+spring.redis.cluster.nodes=8.135.106.227:6379
 spring.redis.database=0
-spring.redis.password=
+spring.redis.password=bgh0cae240
 spring.redis.timeout=3000ms
 spring.redis.jedis.pool.max-idle=8
 spring.redis.jedis.pool.min-idle=0

+ 3 - 3
720yun_fd_manage/gis_application/src/main/resources/application-locSit.properties

@@ -42,11 +42,11 @@ spring.datasource.druid.stat-view-servlet.enabled=true
 
 # Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
 spring.redis.database=0
-spring.redis.host=127.0.0.1
-#spring.redis.host=120.25.146.52
+#spring.redis.host=127.0.0.1
+spring.redis.host=120.24.144.164
 
 spring.redis.port=6379
-spring.redis.password=
+spring.redis.password=bgh0cae240
 # \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4 \u5355\u4F4D ms\uFF08\u6BEB\u79D2\uFF09
 spring.redis.timeout=3000ms
 # \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F8\u3002

+ 28 - 0
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/entity/WorkHotsFodderEntity.java

@@ -0,0 +1,28 @@
+package com.gis.domain.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * 作品表
+ */
+@Data
+@Entity
+@Table(name = "tb_work_hots_fodder")
+public class WorkHotsFodderEntity extends BaseEntity implements Serializable {
+
+        private String WorkId;
+        private String title;
+        private String name;
+
+        private Long FodderId;
+
+        private String sceneCode;
+
+
+}

+ 25 - 0
720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/WorkHotsFodderMapper.java

@@ -0,0 +1,25 @@
+package com.gis.mapper;
+
+
+import com.gis.common.mapper.provider.BaseProvider;
+import com.gis.domain.dto.FodderPageDto;
+import com.gis.domain.entity.FodderEntity;
+import com.gis.domain.entity.WorkHotsFodderEntity;
+import com.gis.domain.vo.FodderVo;
+import com.gis.mapper.provider.FodderProvider;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+@Component
+@Mapper
+public interface WorkHotsFodderMapper extends IBaseMapper<WorkHotsFodderEntity, Long> {
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    Integer getCountStr(String sqlStr);
+
+}

+ 1 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/FodderService.java

@@ -42,6 +42,7 @@ public interface FodderService extends IBaseService<FodderEntity, Long> {
     Result listAndDir(FodderPageDto param);
 
     void updateDirId(Long parentId, String fodderIds);
+    void removeByDirIds(String dirs);
 
     List<String> getSceneCodeByParentIds(String dirs);
 

+ 19 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/WorkHotsFodderService.java

@@ -0,0 +1,19 @@
+package com.gis.service;
+
+
+import com.gis.domain.entity.WorkHotsFodderEntity;
+
+import java.util.List;
+
+
+/**
+ * Created by owen on 2020/3/11 0011 16:14
+ */
+public interface WorkHotsFodderService extends IBaseService<WorkHotsFodderEntity, Long> {
+
+    WorkHotsFodderEntity findBySceneCodeAndWorkIdAndTitleAndNameAndFodderId(String sceneCode, String workId, String hotspotTitle,String name,long FodderId);
+
+
+    boolean getCountByDirId(String dirIds);
+
+}

+ 11 - 1
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/DirServiceImpl.java

@@ -38,6 +38,10 @@ public class DirServiceImpl extends IBaseServiceImpl<DirEntity, Long> implements
     @Autowired
     WorkService workService;
 
+    @Autowired
+    WorkHotsFodderServiceImpl workHotsFodderService;
+
+
     @Override
     public IBaseMapper<DirEntity, Long> getBaseMapper() {
         return this.entityMapper;
@@ -105,7 +109,10 @@ public class DirServiceImpl extends IBaseServiceImpl<DirEntity, Long> implements
 
         } else {
             // 子目录跟子素材没有进行递归删除
-            this.deleteById(id);
+            //20230420 增加删除子目录
+            String dirs = getChildIdById(id);
+            this.deleteByIds(dirs);
+            fodderService.removeByDirIds(dirs);
         }
 
         return Result.success();
@@ -140,6 +147,9 @@ public class DirServiceImpl extends IBaseServiceImpl<DirEntity, Long> implements
         }
         // 查找该用户的作品
         boolean works = workService.getUserWorkCountBySceneCodes(sceneCodes);
+        if (works){
+            works=workHotsFodderService.getCountByDirId(dirs);
+        }
         // 匹配场景码
 //        log.error("此场景:{} 被该作品:{} 引用", works);
 

+ 10 - 5
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -421,7 +421,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         builder.append("select a.id,a.create_time,a.update_time,a.name, a.status,a.type,a.user_id, a.icon,a.preview_icon, a.file_name, " +
                 "a.file_size, a.oss_path, a.scene_code,a.dpi,a.temp_id, a.dir_id, b.name as dirName, if(a.id=0, 2, 2) as sortType," +
                 " null as  ancestors " +
-                "from tb_fodder a left join tb_dir b on b.id=a.dir_id where a.is_delete=0");
+                "from tb_fodder a left join tb_dir b on b.id=a.dir_id where a.is_delete=0 and b.is_delete=0");
 
 
         builder.append(" and a.user_id='").append(userName).append("'");
@@ -482,6 +482,11 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
     }
 
     @Override
+    public void removeByDirIds(String dirs) {
+        entityMapper.updateDirId(StrUtil.format("update tb_fodder set is_delete=1 where is_delete=0 and id in ({})  ", dirs));
+    }
+
+    @Override
     public List<String> getSceneCodeByParentIds(String dirs) {
         if (StrUtil.isNotBlank(dirs)){
             return entityMapper.getListStr(StrUtil.format("select scene_code from tb_fodder " +
@@ -604,7 +609,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
 
         // 写入文件
         String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSS");
-        String dir = "/temp/" + time;
+        String dir = "temp/" + time;
         Map<String, Object> uploadMap = fileUtils.uploadMap(file, dir, false);
         String filePath = uploadMap.get("filePath").toString();
         filePath = configConstant.serverBasePath + filePath;
@@ -612,11 +617,11 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         String thumbPath = configConstant.serverBasePath + thumbName;
 
         // 缩略图
-        String ossKey = configConstant.ossBasePath + "/fodder/thumb/thumb_" + time + ".jpg";
+        String ossKey = configConstant.ossBasePath + "fodder/thumb/thumb_" + time + ".jpg";
         String iconPath = configConstant.ossDomain + ossKey;
 
-        // asw 环境需要使用ffmpeg 截图视频第一帧
-        if (configConstant.active.contains("Aws") && "video".equals(type)){
+        // asw 环境需要使用ffmpeg 截图视频第一帧  修改为无论什么环境都使用ffmpeg
+        if (/*configConstant.active.contains("Aws")&&  */"video".equals(type)){
             log.info("aws 截取视频第一帧");
             String cmd = CmdConstant.FFMPEG_FIRST;
             cmd = cmd.replaceAll("@inPath", filePath);

+ 85 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/WorkHotsFodderServiceImpl.java

@@ -0,0 +1,85 @@
+package com.gis.service.impl;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.gis.common.constant.ConfigConstant;
+import com.gis.common.constant.ErrorEnum;
+import com.gis.common.constant.RedisConstant;
+import com.gis.common.exception.BaseRuntimeException;
+import com.gis.common.util.*;
+import com.gis.domain.dto.*;
+import com.gis.domain.entity.FodderEntity;
+import com.gis.domain.entity.WorkEntity;
+import com.gis.domain.entity.WorkHotsFodderEntity;
+import com.gis.domain.vo.ReportWorkVo;
+import com.gis.mapper.IBaseMapper;
+import com.gis.mapper.IBaseStrMapper;
+import com.gis.mapper.WorkHotsFodderMapper;
+import com.gis.mapper.WorkMapper;
+import com.gis.oss.util.FileAndOssUtil;
+import com.gis.oss.util.FileUtils;
+import com.gis.oss.util.QrCodeUtils;
+import com.gis.service.FodderService;
+import com.gis.service.WorkHotsFodderService;
+import com.gis.service.WorkService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
+import org.junit.Test;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import tk.mybatis.mapper.entity.Condition;
+
+import java.io.IOException;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * Created by owen on 2020/3/11 0011 16:16
+ */
+@Slf4j
+@Service
+public class WorkHotsFodderServiceImpl extends IBaseServiceImpl<WorkHotsFodderEntity, Long> implements WorkHotsFodderService {
+
+    @Autowired
+    WorkHotsFodderMapper workHotsFodderMapper;
+
+
+    @Override
+    public IBaseMapper<WorkHotsFodderEntity, Long> getBaseMapper() {
+        return this.workHotsFodderMapper;
+    }
+
+    @Override
+    public WorkHotsFodderEntity findBySceneCodeAndWorkIdAndTitleAndNameAndFodderId(String sceneCode, String workId, String hotspotTitle,String name,long fodderId) {
+        WorkHotsFodderEntity one=new WorkHotsFodderEntity();
+        one.setSceneCode(sceneCode);
+        one.setWorkId(workId);
+        one.setTitle(hotspotTitle);
+        one.setName(name);
+        one.setFodderId(fodderId);
+        one.setIsDelete(0);
+        return getBaseMapper().selectOne(one);
+    }
+
+    @Override
+    public boolean getCountByDirId(String dirIds) {
+        String format = StrUtil.format(" SELECT a.* FROM tb_work_hots_fodder a LEFT JOIN  tb_fodder b on a.fodder_id =b.id WHERE a.is_delete=0 and b.is_delete=0 b.dir_id in ({})",
+                    1, dirIds);
+            Integer count = workHotsFodderMapper.getCountStr(format);
+        return count > 0;
+    }
+}

+ 78 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/WorkServiceImpl.java

@@ -1,6 +1,7 @@
 package com.gis.service.impl;
 
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -12,12 +13,14 @@ import com.gis.common.util.*;
 import com.gis.domain.dto.*;
 import com.gis.domain.entity.FodderEntity;
 import com.gis.domain.entity.WorkEntity;
+import com.gis.domain.entity.WorkHotsFodderEntity;
 import com.gis.domain.vo.ReportWorkVo;
 import com.gis.mapper.*;
 import com.gis.oss.util.FileAndOssUtil;
 import com.gis.oss.util.FileUtils;
 import com.gis.oss.util.QrCodeUtils;
 import com.gis.service.FodderService;
+import com.gis.service.WorkHotsFodderService;
 import com.gis.service.WorkService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -69,6 +72,8 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
     @Autowired
     FileAndOssUtil fileAndOssUtil;
 
+    @Autowired
+    WorkHotsFodderService workHotsFodderService;
 
 
 
@@ -496,6 +501,8 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
 
         String scenes = someDataJson.getString("scenes");
         String sceneCodes = getSceneCodes(scenes);
+        //保存热点的素材到表里面
+        saveHotsFodderId(scenes,entity.getId());
         entity.setSceneCodes(sceneCodes);
         // 2022-12-19 作品类型
         String type = getTypeBySceneCodes(sceneCodes);
@@ -539,7 +546,54 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
         String join = StringUtils.join(list, ",");
         return join;
     }
+    /**
+     * 保存当前作品引用的素材
+     * @param param
+     */
+    private void saveHotsFodderId(String param,String workId){
+        JSONArray array = JSONArray.parseArray(param);
+        for (Object o : array) {
+            JSONObject parse = JSONObject.parseObject(o.toString());
+            if (parse.containsKey("someData")) {
+                JSONObject someData = parse.getJSONObject("someData");
+                String sceneCode= parse.getString("sceneCode");
+                log.info("素材包含someData,进行热点处理");
+                    if (someData.containsKey("hotspots")){
+                        JSONArray hotspots = someData.getJSONArray("hotspots");
+                        for (Object hotspot : hotspots) {
+                            JSONObject hotspotJson = JSONObject.parseObject(hotspot.toString());
+                            JSONArray fodderId = hotspotJson.getJSONArray("fodderId");
+                            String hotspotTitle = hotspotJson.getString("hotspotTitle");
+                            String name = hotspotJson.getString("name");
+                            for (Object id : fodderId) {
+                                WorkHotsFodderEntity entity= workHotsFodderService.findBySceneCodeAndWorkIdAndTitleAndNameAndFodderId(sceneCode,workId,hotspotTitle,name,Long.valueOf(String.valueOf(id)));
+                                if (ObjectUtil.isNotNull(entity)){
+                                    entity.setSceneCode(sceneCode);
+                                    entity.setFodderId(Long.valueOf(String.valueOf(id)));
+                                    entity.setWorkId(workId);
+                                    entity.setTitle(hotspotTitle);
+                                    entity.setName(name);
+                                    workHotsFodderService.update(entity);
+                                }else {
+                                    entity=new WorkHotsFodderEntity();
+                                    entity.setSceneCode(sceneCode);
+                                    entity.setFodderId(Long.valueOf(String.valueOf(id)));
+                                    entity.setWorkId(workId);
+                                    entity.setTitle(hotspotTitle);
+                                    entity.setName(name);
+                                    workHotsFodderService.save(entity);
+
+                                }
+
+
+                            }
+
+                        }
+                }
+            }
 
+        }
+    }
     /**
      * 2022-12-19
      * 获取作品类型
@@ -586,7 +640,31 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
         }
         return list;
     }
+    /**
+     * 场景码字符串转list
+     * @param param
+     * @return
+     */
+    private List<String> getFodderIdList(String param){
+        JSONArray array = JSONArray.parseArray(param);
+        List<String> list = new ArrayList<>();
+        for (Object o : array) {
+            JSONObject parse = JSONObject.parseObject(o.toString());
+            JSONArray someData = parse.getJSONArray("someData");
+            for (Object someDatum : someData) {
+                JSONObject someDataJson = JSONObject.parseObject(someDatum.toString());
+                if (someDataJson.containsKey("hotspots")){
+                    JSONArray hotspots = someDataJson.getJSONArray("hotspots");
+                    for (Object hotspot : hotspots) {
+                        JSONObject hotspotJson = JSONObject.parseObject(hotspot.toString());
+
+                    }
+                }
+            }
 
+        }
+        return list;
+    }
     /**
      * 更新二维码
      */