lyhzzz пре 4 месеци
родитељ
комит
a0532a1dc5

+ 1 - 1
README.md

@@ -85,5 +85,5 @@ fd_fusion_xj-init.sql
     3.searchType  0场景列表,1场景共享,2全部
     4.新增cameraType  入参下拉框为  /fusion/cameraType/allList GET 
 二. 设置场景分享,见接口文档
-    
+    http://120.25.146.52:3090/project/193/interface/api/10963
 ~~~~

+ 6 - 0
src/main/java/com/fdkankan/fusion/controller/CaseFusionController.java

@@ -7,6 +7,7 @@ import com.fdkankan.fusion.common.ResultData;
 import com.fdkankan.fusion.common.util.FileWriterUtil;
 import com.fdkankan.fusion.entity.*;
 import com.fdkankan.fusion.exception.BusinessException;
+import com.fdkankan.fusion.request.FusionPageParam;
 import com.fdkankan.fusion.request.FusionParam;
 import com.fdkankan.fusion.service.*;
 import org.apache.commons.lang3.StringUtils;
@@ -51,6 +52,11 @@ public class CaseFusionController extends BaseController{
         return ResultData.ok(caseFusionService.getSceneListVo(fusionId));
     }
 
+    @PostMapping("/pageList")
+    public ResultData pageList(@RequestBody FusionPageParam param) {
+
+        return ResultData.ok(caseFusionService.pageList(param));
+    }
 
     @GetMapping("/info")
     public ResultData info(@RequestParam(required = false) Integer fusionId){

+ 3 - 3
src/main/java/com/fdkankan/fusion/entity/CaseFusion.java

@@ -37,11 +37,11 @@ public class CaseFusion implements Serializable {
     @TableField("fusion_title")
     private String fusionTitle;
 
-    @TableField("platform_id")
-    private Integer platformId;
+    @TableField("case_id")
+    private Integer caseId;
 
     @TableField("sys_user_id")
-    private Integer sysUserId;
+    private String sysUserId;
 
     @TableField("lat_and_long")
     private String latAndLong;

+ 2 - 1
src/main/java/com/fdkankan/fusion/entity/SceneDeptShare.java

@@ -53,5 +53,6 @@ public class SceneDeptShare implements Serializable {
     @TableField("update_time")
     private Date updateTime;
 
-
+    @TableField("fusion_id")
+    private Integer fusionId;
 }

+ 3 - 0
src/main/java/com/fdkankan/fusion/mapper/ICaseFusionMapper.java

@@ -1,7 +1,9 @@
 package com.fdkankan.fusion.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.fusion.entity.CaseFusion;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fdkankan.fusion.request.FusionPageParam;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -15,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface ICaseFusionMapper extends BaseMapper<CaseFusion> {
 
+    Page<CaseFusion> pageList(Page<Object> objectPage, FusionPageParam param);
 }

+ 16 - 0
src/main/java/com/fdkankan/fusion/request/FusionPageParam.java

@@ -0,0 +1,16 @@
+package com.fdkankan.fusion.request;
+
+import com.fdkankan.fusion.common.RequestBase;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+public class FusionPageParam extends RequestBase {
+    private String fusionTitle;
+    private Integer searchType = 0 ; //0列表,1共享,2全部
+    private List<String> deptIds = new ArrayList<>();
+    private String deptId ;
+    private List<Integer> fusionIds = new ArrayList<>();
+}

+ 3 - 0
src/main/java/com/fdkankan/fusion/service/ICaseFusionService.java

@@ -2,6 +2,7 @@ package com.fdkankan.fusion.service;
 
 import com.fdkankan.fusion.entity.CaseFusion;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.fusion.request.FusionPageParam;
 import com.fdkankan.fusion.response.FusionNumVo;
 
 import java.util.List;
@@ -21,4 +22,6 @@ public interface ICaseFusionService extends IService<CaseFusion> {
     void addFusionIds(List<Integer> fusionIds, Integer caseId);
 
     List<FusionNumVo> getSceneListVo(Integer fusionId);
+
+    Object pageList(FusionPageParam param);
 }

+ 2 - 2
src/main/java/com/fdkankan/fusion/service/ICasePathService.java

@@ -15,7 +15,7 @@ import java.util.List;
  */
 public interface ICasePathService extends IService<CasePath> {
 
-    Object getByCaseId(Integer caseId);
+    List<CasePath>  getByCaseId(Integer caseId);
 
-    Object getByFusionId(Integer fusionId);
+    List<CasePath> getByFusionId(Integer fusionId);
 }

+ 2 - 0
src/main/java/com/fdkankan/fusion/service/ISceneDeptShareService.java

@@ -18,4 +18,6 @@ public interface ISceneDeptShareService extends IService<SceneDeptShare> {
     void share(SceneDeptShare param);
 
     List<String> getNumListByDeptId(String deptId, Integer isObj);
+
+    List<Integer> getFusionIdsListByDeptId(String deptId);
 }

+ 38 - 8
src/main/java/com/fdkankan/fusion/service/impl/CaseFusionServiceImpl.java

@@ -1,19 +1,24 @@
 package com.fdkankan.fusion.service.impl;
 
+import cn.dev33.satoken.stp.StpUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fdkankan.fusion.common.PageInfo;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.util.CameraUtil;
 import com.fdkankan.fusion.entity.*;
 import com.fdkankan.fusion.entity.jsonEntity.Transform;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.mapper.ICaseFusionMapper;
+import com.fdkankan.fusion.request.FusionPageParam;
 import com.fdkankan.fusion.response.CaseFusionVo;
 import com.fdkankan.fusion.response.FusionNumVo;
 import com.fdkankan.fusion.response.SceneVo;
 import com.fdkankan.fusion.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -36,6 +41,18 @@ public class CaseFusionServiceImpl extends ServiceImpl<ICaseFusionMapper, CaseFu
 
     @Autowired
     ICaseFusionRelationService caseFusionRelationService;
+    @Autowired
+    IFusionNumService fusionNumService;
+    @Autowired
+    IModelService modelService;
+    @Autowired
+    IScenePlusService scenePlusService;
+    @Autowired
+    IScenePlusExtService scenePlusExtService;
+    @Autowired
+    ITmDepartmentService departmentService;
+    @Autowired
+    ISceneDeptShareService sceneDeptShareService;
 
     @Override
     public List<CaseFusion> getListByCaseId(Integer caseId) {
@@ -57,14 +74,7 @@ public class CaseFusionServiceImpl extends ServiceImpl<ICaseFusionMapper, CaseFu
         caseFusionRelationService.addFusionIds(fusionIds,caseId);
     }
 
-    @Autowired
-    IFusionNumService fusionNumService;
-    @Autowired
-    IModelService modelService;
-    @Autowired
-    IScenePlusService scenePlusService;
-    @Autowired
-    IScenePlusExtService scenePlusExtService;
+
 
     @Override
     public List<FusionNumVo> getSceneListVo(Integer fusionId) {
@@ -122,4 +132,24 @@ public class CaseFusionServiceImpl extends ServiceImpl<ICaseFusionMapper, CaseFu
 
         return sceneVos;
     }
+
+    @Override
+    public Object pageList(FusionPageParam param) {
+
+        String deptId = departmentService.getDeptId();
+        if(param.getSearchType() == 0){
+            param.getDeptIds().add(deptId);
+        }
+        if(param.getSearchType() == 1){  //下级共享给上级场景
+            List<Integer> fusionIds =  sceneDeptShareService.getFusionIdsListByDeptId(deptId);
+            param.setFusionIds(fusionIds);
+        }
+        if(param.getSearchType() == 2){  //当前组织及下级组织的数据
+            List<TmDepartment> sonByDeptId = departmentService.getSonByDeptId(deptId);
+            param.getDeptIds().add(deptId);
+            param.getDeptIds().addAll(sonByDeptId.stream().map(TmDepartment::getId).collect(Collectors.toList()));
+        }
+        Page<CaseFusion> page = this.getBaseMapper().pageList(new Page<>(param.getPageNum(), param.getPageSize()), param);
+        return PageInfo.PageInfo(page);
+    }
 }

+ 2 - 2
src/main/java/com/fdkankan/fusion/service/impl/CasePathServiceImpl.java

@@ -21,14 +21,14 @@ import java.util.List;
 public class CasePathServiceImpl extends ServiceImpl<ICasePathMapper, CasePath> implements ICasePathService {
 
     @Override
-    public Object getByCaseId(Integer caseId) {
+    public  List<CasePath>  getByCaseId(Integer caseId) {
         LambdaQueryWrapper<CasePath> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(CasePath::getCaseId,caseId);
         return this.list(wrapper);
     }
 
     @Override
-    public Object getByFusionId(Integer fusionId) {
+    public List<CasePath> getByFusionId(Integer fusionId) {
         LambdaQueryWrapper<CasePath> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(CasePath::getFusionId,fusionId);
         return this.list(wrapper);

+ 17 - 3
src/main/java/com/fdkankan/fusion/service/impl/SceneDeptShareServiceImpl.java

@@ -27,12 +27,17 @@ public class SceneDeptShareServiceImpl extends ServiceImpl<ISceneDeptShareMapper
 
     @Override
     public void share(SceneDeptShare param) {
-        if(StringUtils.isBlank(param.getNum()) || param.getIsObj() == null || StringUtils.isBlank(param.getDeptId()) || param.getIsAuth() == null){
+        if(((StringUtils.isBlank(param.getNum()) || param.getIsObj() == null) && param.getFusionId() == null)
+                || StringUtils.isBlank(param.getDeptId()) || param.getIsAuth() == null){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         LambdaQueryWrapper<SceneDeptShare> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(SceneDeptShare::getNum,param.getNum());
-        wrapper.eq(SceneDeptShare::getIsObj,param.getIsObj());
+        if(StringUtils.isNotBlank(param.getNum())){
+            wrapper.eq(SceneDeptShare::getNum,param.getNum());
+            wrapper.eq(SceneDeptShare::getIsObj,param.getIsObj());
+        }else {
+            wrapper.eq(SceneDeptShare::getFusionId,param.getFusionId());
+        }
         wrapper.eq(SceneDeptShare::getDeptId,param.getDeptId());
         List<SceneDeptShare> list = this.list(wrapper);
         if(list.isEmpty()){
@@ -56,4 +61,13 @@ public class SceneDeptShareServiceImpl extends ServiceImpl<ISceneDeptShareMapper
         List<SceneDeptShare> list = this.list(wrapper);
         return list.stream().map(SceneDeptShare::getNum).collect(Collectors.toList());
     }
+
+    @Override
+    public List<Integer> getFusionIdsListByDeptId(String deptId) {
+        LambdaQueryWrapper<SceneDeptShare> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SceneDeptShare::getDeptId,deptId);
+        wrapper.ne(SceneDeptShare::getIsAuth,0);
+        List<SceneDeptShare> list = this.list(wrapper);
+        return list.stream().map(SceneDeptShare::getFusionId).collect(Collectors.toList());
+    }
 }

+ 130 - 54
src/main/java/com/fdkankan/fusion/task/TaskService.java

@@ -4,38 +4,44 @@ import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.unit.DataSizeUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.fusion.common.util.DateUtils;
 import com.fdkankan.fusion.entity.*;
 import com.fdkankan.fusion.service.*;
 import com.fdkankan.redis.util.RedisUtil;
+import io.netty.util.internal.UnstableApi;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.PostMapping;
 
+import javax.annotation.Detainted;
 import javax.annotation.PostConstruct;
+import java.io.File;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import static com.fdkankan.fusion.down.CaseDownService.downProcessKey;
 
 @Service
+@Slf4j
 public class TaskService {
 
     @Autowired
     ICaseLiveService caseLiveService;
+    @Autowired
+    ICaseSettingsService caseSettingsService;
+    @Autowired
+    ICaseFusionService caseFusionService;
+    @Autowired
+    ICaseService caseService;
+    @Autowired
+    ITmUserService tmUserService;
 
-    @Scheduled(initialDelay = 2000, fixedDelay = 1000 * 60)
-    public void run() {
-        List<CaseLive> list = caseLiveService.list();
-        for (CaseLive caseLive : list) {
-            Date hoursTime = DateUtils.getHoursTime(caseLive.getCreateTime());
-            if(hoursTime.getTime() <= new Date().getTime()){
-                caseLiveService.removeById(caseLive);
-            }
-        }
-    }
 
     @Autowired
     RedisUtil redisUtil;
@@ -48,65 +54,135 @@ public class TaskService {
                 redisUtil.del(key);
             }
         }
-        //modelToMedia();
+
+        updateFusion();
+        updateCaseSetting();
+        updateHotIcon();
+        updateCaseTag();
+        updateGuide();
+        updatePath();
+        updateAnimation();
+    }
+
+    private void updateFusion(){
+        List<CaseFusion> list = caseFusionService.list();
+        List<CaseFusion> collect = list.stream().filter(e -> e.getSysUserId() == null).collect(Collectors.toList());
+        for (CaseFusion caseFusion : collect) {
+            CaseEntity caseEntity = caseService.getById(caseFusion.getCaseId());
+            if(caseEntity != null){
+                caseFusion.setFusionTitle(caseEntity.getCaseTitle());
+                caseFusion.setLatAndLong(caseEntity.getLatAndLong());
+                TmUser tmUser = tmUserService.getByUserName(caseEntity.getUserName());
+                if(tmUser != null){
+                    caseFusion.setSysUserId(tmUser.getId());
+                }
+                caseFusionService.updateById(caseFusion);
+            }
+        }
     }
 
     @Autowired
-    IModelService modelService;
+    ICaseFilesTypeService caseFilesTypeService;
+    @Autowired
+    IHotIconService hotIconService;
+    @Autowired
+    IDictService dictService;
     @Autowired
     ICommonUploadService commonUploadService;
     @Autowired
     IDictFileService dictFileService;
-    @Autowired
-    ITmUserService tmUserService;
 
-    public void modelToMedia(){
-        LambdaQueryWrapper<Model> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(Model::getType,3);
-        wrapper.eq(Model::getCreateStatus,1);
-        wrapper.isNotNull(Model::getModelGlbUrl);
-        wrapper.isNotNull(Model::getUserName);
-        List<Model> list = modelService.list(wrapper);
 
+    private void updateCaseSetting() {
+        List<CaseSettings> list = caseSettingsService.list();
+        List<CaseSettings> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
+        for (CaseSettings caseSettings : collect) {
+            List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(caseSettings.getCaseId());
+            if(!listByCaseId.isEmpty()){
+                LambdaUpdateWrapper<CaseSettings> wrapper = new LambdaUpdateWrapper<>();
+                wrapper.eq(CaseSettings::getSettingsId,caseSettings.getSettingsId());
+                wrapper.set(CaseSettings::getFusionId,listByCaseId.get(0).getFusionId());
+                caseSettingsService.update(wrapper);
+            }
+        }
+    }
+
+    private void updateHotIcon() {
+        List<HotIcon> list = hotIconService.list();
+        List<HotIcon> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
+        for (HotIcon entity : collect) {
+            List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
+            if(!listByCaseId.isEmpty()){
+                LambdaUpdateWrapper<HotIcon> wrapper = new LambdaUpdateWrapper<>();
+                wrapper.eq(HotIcon::getIconId,entity.getIconId());
+                wrapper.set(HotIcon::getFusionId,listByCaseId.get(0).getFusionId());
+                hotIconService.update(wrapper);
+            }
+        }
+    }
+    @Autowired
+    ICaseTagService caseTagService;
+    private void updateCaseTag() {
+        List<CaseTag> list = caseTagService.list();
+        List<CaseTag> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
+        for (CaseTag entity : collect) {
+            List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
+            if(!listByCaseId.isEmpty()){
+                LambdaUpdateWrapper<CaseTag> wrapper = new LambdaUpdateWrapper<>();
+                wrapper.eq(CaseTag::getTagId,entity.getTagId());
+                wrapper.set(CaseTag::getFusionId,listByCaseId.get(0).getFusionId());
+                caseTagService.update(wrapper);
+            }
+        }
+    }
 
-        for (Model model : list) {
-            TmUser tmUser = tmUserService.getByUserName(model.getUserName());
-            if(tmUser == null){
-                continue;
+    @Autowired
+    IFusionGuideService fusionGuideService;
+    private void updateGuide() {
+        List<FusionGuide> list = fusionGuideService.list();
+        List<FusionGuide> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
+        for (FusionGuide entity : collect) {
+            List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
+            if(!listByCaseId.isEmpty()){
+                LambdaUpdateWrapper<FusionGuide> wrapper = new LambdaUpdateWrapper<>();
+                wrapper.eq(FusionGuide::getFusionGuideId,entity.getFusionGuideId());
+                wrapper.set(FusionGuide::getFusionId,listByCaseId.get(0).getFusionId());
+                fusionGuideService.update(wrapper);
             }
+        }
+    }
 
-            String modelGlbUrl = model.getModelGlbUrl();
-            JSONArray jsonArray = JSONArray.parseArray(modelGlbUrl);
-            String fileUrl = (String) jsonArray.get(0);
 
-            LambdaQueryWrapper<CommonUpload> wrapper1 = new LambdaQueryWrapper<>();
-            wrapper1.eq(CommonUpload::getFileUrl,fileUrl);
-            List<CommonUpload> list1 = commonUploadService.list(wrapper1);
-            if(!list1.isEmpty()){
-                continue;
+    @Autowired
+    ICasePathService casePathService;
+    private void updatePath() {
+        List<CasePath> list = casePathService.list();
+        List<CasePath> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
+        for (CasePath entity : collect) {
+            List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
+            if(!listByCaseId.isEmpty()){
+                LambdaUpdateWrapper<CasePath> wrapper = new LambdaUpdateWrapper<>();
+                wrapper.eq(CasePath::getId,entity.getId());
+                wrapper.set(CasePath::getFusionId,listByCaseId.get(0).getFusionId());
+                casePathService.update(wrapper);
             }
+        }
+    }
 
-            CommonUpload commonUpload = new CommonUpload();
-            commonUpload.setFileName(model.getModelTitle());
-            commonUpload.setFileUrl(fileUrl);
-            commonUpload.setFileSize(String.valueOf(DataSizeUtil.parse(model.getModelSize())));
-            commonUpload.setNewFileName(model.getModelTitle());
-            commonUpload.setFileType(3);
-            commonUpload.setFileTypeStr("模型");
-            commonUpload.setFileFormat(model.getModelDateType());
-            commonUpload.setResultFileFormat(model.getModelType());
-            commonUpload.setStatus(1);
-            commonUpload.setUseType("ordinary");
-            commonUploadService.save(commonUpload);
-
-            DictFile dictFile = new DictFile();
-            dictFile.setName(model.getModelTitle());
-            dictFile.setTypeKey("media-library");
-            dictFile.setSysUserId(tmUser.getId());
-            dictFile.setUploadId(commonUpload.getId());
-            dictFile.setUseType("ordinary");
-            dictFileService.save(dictFile);
+    @Autowired
+    ICaseAnimationService caseAnimationService;
+    private void updateAnimation() {
+        List<CaseAnimation> list = caseAnimationService.list();
+        List<CaseAnimation> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
+        for (CaseAnimation entity : collect) {
+            List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
+            if(!listByCaseId.isEmpty()){
+                LambdaUpdateWrapper<CaseAnimation> wrapper = new LambdaUpdateWrapper<>();
+                wrapper.eq(CaseAnimation::getId,entity.getId());
+                wrapper.set(CaseAnimation::getFusionId,listByCaseId.get(0).getFusionId());
+                caseAnimationService.update(wrapper);
+            }
         }
     }
 
-}
+}

+ 29 - 0
src/main/resources/mapper/fusion/CaseFusionMapper.xml

@@ -2,4 +2,33 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fdkankan.fusion.mapper.ICaseFusionMapper">
 
+    <select id="pageList" resultType="com.fdkankan.fusion.entity.CaseFusion">
+        select * from t_case_fusion f
+            left join tm_user u on f.sys_user_id = u.id
+        where f.tb_status = 0
+
+        <if test="param.fusionTitle != null and param.fusionTitle !=''">
+            and f.fusion_title  concat ('%',#{param.fusionTitle},'%')
+        </if>
+
+        <if test="param.deptIds!= null and param.deptIds.size >0">
+            and u.dept_id in
+            <foreach item="deptId" collection="param.deptIds" open="(" separator="," close=")">
+                #{deptId}
+            </foreach>
+        </if>
+
+        <if test="param.fusionIds!= null and param.fusionIds.size >0">
+            and f.fusion_id in
+            <foreach item="fusionId" collection="param.fusionIds" open="(" separator="," close=")">
+                #{fusionId}
+            </foreach>
+        </if>
+
+
+        <if test="param.deptId != null and param.deptId !=''">
+            and u.dept_id = #{param.deptId}
+        </if>
+        order by fusion_id desc
+    </select>
 </mapper>