浏览代码

三位模型编辑器

dengsixing 1 月之前
父节点
当前提交
2a35c26b9d

+ 7 - 0
pom.xml

@@ -170,6 +170,13 @@
             <version>3.0.0-SNAPSHOT</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.opencsv</groupId>
+            <artifactId>opencsv</artifactId>
+            <version>5.7.1</version>
+        </dependency>
+
+
     </dependencies>
 
     <dependencyManagement>

+ 15 - 3
src/main/java/com/fdkankan/scene/controller/NjsSceneBoxModelController.java

@@ -1,6 +1,7 @@
 package com.fdkankan.scene.controller;
 
 
+import com.fdkankan.scene.dto.ExportBoxModelDTO;
 import com.fdkankan.scene.dto.NjsBoxModelDTO;
 import com.fdkankan.scene.dto.SaveBoxModelDTO;
 import com.fdkankan.scene.mapper.INjsSceneBoxModelMapper;
@@ -51,9 +52,9 @@ public class NjsSceneBoxModelController {
      * @param param
      * @return
      */
-    @PostMapping("batchDisplay")
-    public ResultData<Void> batchDisplay(@RequestBody @Valid BathUpdateNjsBoxModelParamVO param){
-        sceneBoxModelService.batchDisplay(param);
+    @PostMapping("batchVisible")
+    public ResultData<Void> batchVisible(@RequestBody @Valid BathUpdateNjsBoxModelParamVO param){
+        sceneBoxModelService.batchVisible(param);
         return ResultData.ok();
     }
 
@@ -68,6 +69,17 @@ public class NjsSceneBoxModelController {
         return ResultData.ok();
     }
 
+    /**
+     * 批量修改 是否显示或显示尺寸
+     * @param param
+     * @return
+     */
+    @PostMapping("export")
+    public ResultData<Void> export(@RequestBody @Valid ExportBoxModelDTO dto) throws IOException {
+        sceneBoxModelService.export(dto);
+        return ResultData.ok();
+    }
+
 
 
 

+ 19 - 0
src/main/java/com/fdkankan/scene/dto/ExportBoxModelDTO.java

@@ -0,0 +1,19 @@
+package com.fdkankan.scene.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.scene.vo.BaseSceneParamVO;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class ExportBoxModelDTO extends BaseSceneParamVO {
+
+    private String modelName;
+
+    private String colour;
+
+    private  String shape;
+
+}

+ 4 - 2
src/main/java/com/fdkankan/scene/dto/NjsBoxModelDTO.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.opencsv.bean.CsvBindByPosition;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -38,6 +39,7 @@ public class NjsBoxModelDTO {
     /**
      * 名称哦
      */
+    @CsvBindByPosition(position = 0)
     private String modelName;
 
     /**
@@ -63,9 +65,9 @@ public class NjsBoxModelDTO {
 
     private Integer loaded;
 
-    private Integer display;
+    private Integer visible;
 
-    private Integer displaySize;
+    private Integer visibleSize;
 
     private Date createTime;
 

+ 3 - 0
src/main/java/com/fdkankan/scene/dto/SaveBoxModelDTO.java

@@ -30,6 +30,9 @@ public class SaveBoxModelDTO extends BaseSceneParamVO {
     @NotNull
     private JSONObject info;
 
+    @NotBlank
+    private String sid;
+
 
 
 

+ 4 - 4
src/main/java/com/fdkankan/scene/entity/NjsSceneBoxModel.java

@@ -98,11 +98,11 @@ public class NjsSceneBoxModel implements Serializable {
     @TableLogic(value = "A", delval = "I")
     private String recStatus;
 
-    @TableField("display")
-    private Integer display;
+    @TableField("visible")
+    private Integer visible;
 
-    @TableField("display_size")
-    private Integer displaySize;
+    @TableField("visible_size")
+    private Integer visibleSize;
 
     @TableField("reason")
     private String reason;

+ 5 - 1
src/main/java/com/fdkankan/scene/service/INjsSceneBoxModelService.java

@@ -1,12 +1,14 @@
 package com.fdkankan.scene.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.scene.dto.ExportBoxModelDTO;
 import com.fdkankan.scene.dto.NjsBoxModelDTO;
 import com.fdkankan.scene.dto.SaveBoxModelDTO;
 import com.fdkankan.scene.entity.NjsSceneBoxModel;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.scene.vo.BaseSceneParamVO;
 import com.fdkankan.scene.vo.BathUpdateNjsBoxModelParamVO;
+import com.fdkankan.scene.vo.DeleteSidListParamVO;
 
 import javax.validation.Valid;
 import java.io.IOException;
@@ -26,11 +28,13 @@ public interface INjsSceneBoxModelService extends IService<NjsSceneBoxModel> {
 
     List<NjsBoxModelDTO> listNjsBoxModel(@Valid BaseSceneParamVO param);
 
-    void batchDisplay(@Valid BathUpdateNjsBoxModelParamVO param);
+    void batchVisible(@Valid BathUpdateNjsBoxModelParamVO param);
 
     void batchDelete(@Valid BathUpdateNjsBoxModelParamVO param) throws IOException;
 
     void objToGlb(JSONObject param) throws Exception;
 
     void publicNjsSceneBoxModel(String num) throws IOException;
+
+    void export(@Valid ExportBoxModelDTO param);
 }

+ 70 - 6
src/main/java/com/fdkankan/scene/service/impl/NjsSceneBoxModelServiceImpl.java

@@ -11,6 +11,7 @@ import cn.hutool.core.util.ZipUtil;
 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.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.CommonSuccessStatus;
@@ -25,6 +26,7 @@ import com.fdkankan.model.utils.ComputerUtil;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.scene.constant.BoxModelType;
 import com.fdkankan.scene.constant.NjsErrorCode;
+import com.fdkankan.scene.dto.ExportBoxModelDTO;
 import com.fdkankan.scene.dto.NjsBoxModelDTO;
 import com.fdkankan.scene.dto.SaveBoxModelDTO;
 import com.fdkankan.scene.entity.NjsSceneBoxModel;
@@ -37,6 +39,7 @@ import com.fdkankan.scene.service.ISceneEditInfoService;
 import com.fdkankan.scene.service.IScenePlusService;
 import com.fdkankan.scene.vo.BaseSceneParamVO;
 import com.fdkankan.scene.vo.BathUpdateNjsBoxModelParamVO;
+import com.fdkankan.scene.vo.DeleteSidListParamVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -130,7 +133,6 @@ public class NjsSceneBoxModelServiceImpl extends ServiceImpl<INjsSceneBoxModelMa
             bean.setLoaded(CommonStatus.YES.code().intValue());
             bean.setStatus(CommonSuccessStatus.SUCCESS.code());
         }
-        bean.setSid(bean.getInfo().getString("sid"));
         this.save(bean);
 
         //如果是上转本地obj的方式,需要将obj转glb
@@ -158,9 +160,11 @@ public class NjsSceneBoxModelServiceImpl extends ServiceImpl<INjsSceneBoxModelMa
             List<NjsBoxModelDTO> collect = boxModels.stream().map(m -> {
                 JSONObject boxModel = JSON.parseObject(JSON.toJSONString(m));
                 Long createTime = boxModel.getLong("createTime");
+                boolean visible = boxModel.getBooleanValue("visible");
                 return NjsBoxModelDTO.builder()
                         .modelName(boxModel.getString("zipName"))
                         .sourceType("mesh")
+                        .visible(visible ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code())
                         .createTime(createTime == null ? null : DateExtUtil.date(createTime))
                         .build();
             }).collect(Collectors.toList());
@@ -180,15 +184,15 @@ public class NjsSceneBoxModelServiceImpl extends ServiceImpl<INjsSceneBoxModelMa
     }
 
     @Override
-    public void batchDisplay(BathUpdateNjsBoxModelParamVO param) {
+    public void batchVisible(BathUpdateNjsBoxModelParamVO param) {
         LambdaUpdateWrapper<NjsSceneBoxModel> wrapper = new LambdaUpdateWrapper();
         wrapper.eq(NjsSceneBoxModel::getNum, param.getNum());
         wrapper.in(NjsSceneBoxModel::getId, param.getIdList());
-        if(param.getDisplay() != null){
-            wrapper.set(NjsSceneBoxModel::getDisplay, param.getDisplay());
+        if(param.getVisible() != null){
+            wrapper.set(NjsSceneBoxModel::getVisible, param.getVisible());
         }
-        if(param.getDisplaySize() != null){
-            wrapper.set(NjsSceneBoxModel::getDisplaySize, param.getDisplaySize());
+        if(param.getVisibleSize() != null){
+            wrapper.set(NjsSceneBoxModel::getVisibleSize, param.getVisibleSize());
         }
         this.update(wrapper);
     }
@@ -282,4 +286,64 @@ public class NjsSceneBoxModelServiceImpl extends ServiceImpl<INjsSceneBoxModelMa
     public static void main(String[] args) {
         System.out.println(Instant.EPOCH.toEpochMilli());
     }
+
+    @Override
+    public void export(ExportBoxModelDTO param) {
+        LambdaQueryWrapper<NjsSceneBoxModel> wrapper = new LambdaQueryWrapper();
+        wrapper.eq(NjsSceneBoxModel::getNum, param.getNum());
+        boolean queryMeshModel = true;//因为meshmodel没有颜色和形状,所以这里,只要颜色和形状有入参,就可以不用去查meshmodel了
+        if(StrUtil.isNotEmpty(param.getColour())){
+            wrapper.eq(NjsSceneBoxModel::getColour, param.getColour());
+            queryMeshModel = false;
+        }
+        if(StrUtil.isNotEmpty(param.getShape())){
+            wrapper.eq(NjsSceneBoxModel::getShape, param.getShape());
+            queryMeshModel = false;
+        }
+        List<NjsBoxModelDTO> results = new ArrayList<>();
+
+        //先查询mesh编辑器model
+        if(queryMeshModel){
+            ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
+            SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+            if(StrUtil.isNotEmpty(sceneEditInfo.getBoxModels())){
+                JSONArray boxModels = JSON.parseArray(sceneEditInfo.getBoxModels());
+                List<NjsBoxModelDTO> collect = boxModels.stream().map(m -> {
+                    JSONObject boxModel = JSON.parseObject(JSON.toJSONString(m));
+                    Long createTime = boxModel.getLong("createTime");
+                    return NjsBoxModelDTO.builder()
+                            .modelName(boxModel.getString("zipName"))
+                            .sourceType("mesh")
+                            .createTime(createTime == null ? null : DateExtUtil.date(createTime))
+                            .build();
+                }).collect(Collectors.toList());
+                results.addAll(collect);
+            }
+        }
+        if(StrUtil.isNotEmpty(param.getModelName())){
+            wrapper.like(NjsSceneBoxModel::getModelName, param.getModelName());
+            //如果名称入参不为空,需要过滤meshboxmodel
+            if(!results.isEmpty()){
+                results = results.stream().filter(v->v.getModelName().contains(param.getModelName())).collect(Collectors.toList());
+            }
+
+
+        }
+        List<NjsSceneBoxModel> list = this.list(wrapper);
+
+        if(!list.isEmpty()){
+            List<NjsBoxModelDTO> njsBoxModelDTOS = BeanUtil.copyToList(list, NjsBoxModelDTO.class);
+            njsBoxModelDTOS.stream().forEach(v->v.setSourceType("model"));
+            results.addAll(njsBoxModelDTOS);
+        }
+
+        results.stream()
+            .sorted(
+                    Comparator.comparing(
+                            NjsBoxModelDTO::getCreateTime,
+                            Comparator.nullsLast(Date::compareTo)
+                    ).reversed()
+            ).collect(Collectors.toList());
+
+    }
 }

+ 2 - 2
src/main/java/com/fdkankan/scene/vo/BathUpdateNjsBoxModelParamVO.java

@@ -19,8 +19,8 @@ public class BathUpdateNjsBoxModelParamVO extends BaseSceneParamVO{
     @NotEmpty(message = "idList不能为空")
     private List<Long> idList;
 
-    private Integer display;
+    private Integer visible;
 
-    private Integer displaySize;
+    private Integer visibleSize;
 
 }