Quellcode durchsuchen

fix findRunningLigth bug

xiewenjie vor 3 Jahren
Ursprung
Commit
cb9742ad24

+ 4 - 0
sxz-application/src/main/resources/application-dev.properties

@@ -86,3 +86,7 @@ max.obj.url=http://192.168.0.75:8080/
 dingding.warning.address=https://oapi.dingtalk.com/robot/send?access_token=13ae02d6821a56ce86c3e6ad98d0260896eba5888a9bd18aed141c39f11299a8
 #缓存接口日志时间(单位小时)
 logsTimeOut=4
+
+
+ws.port=8889
+

+ 1 - 0
sxz-application/src/main/resources/application-devuat.properties

@@ -85,3 +85,4 @@ max.obj.url=http://192.168.0.75:8080/
 dingding.warning.address=https://oapi.dingtalk.com/robot/send?access_token=13ae02d6821a56ce86c3e6ad98d0260896eba5888a9bd18aed141c39f11299a8
 #缓存接口日志时间(单位小时)
 logsTimeOut=4
+ws.port=8889

+ 1 - 0
sxz-application/src/main/resources/application-prod.properties

@@ -85,3 +85,4 @@ model.build.url=http://101.66.188.5:8100/
 max.obj.url=http://120.78.65.189:8080/
 #缓存接口日志时间(单位小时)
 logsTimeOut=4
+ws.port=8889

+ 1 - 0
sxz-application/src/main/resources/application-uat.properties

@@ -85,3 +85,4 @@ max.obj.url=http://192.168.0.75:8080/
 dingding.warning.address=https://oapi.dingtalk.com/robot/send?access_token=13ae02d6821a56ce86c3e6ad98d0260896eba5888a9bd18aed141c39f11299a8
 #缓存接口日志时间(单位小时)
 logsTimeOut=4
+ws.port=8889

+ 3 - 7
sxz-core/src/main/java/com/fdkk/sxz/other/listener/RunBuild.java

@@ -3,8 +3,6 @@ package com.fdkk.sxz.other.listener;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.file.FileReader;
-import cn.hutool.core.io.file.FileWriter;
-import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
@@ -15,7 +13,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fdkk.sxz.constant.ConstantFileName;
 import com.fdkk.sxz.constant.ConstantFilePath;
 import com.fdkk.sxz.entity.*;
-import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
+import com.fdkk.sxz.enums.ModelUploadType;
 import com.fdkk.sxz.other.mq.TopicRabbitConfig;
 import com.fdkk.sxz.webApi.service.*;
 import com.fdkk.sxz.util.*;
@@ -31,7 +29,6 @@ import org.springframework.util.CollectionUtils;
 
 import java.io.File;
 import java.io.IOException;
-import java.net.URI;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
@@ -1074,7 +1071,7 @@ public class RunBuild {
 //                    componentModelUploadEntity.setImgPath(objPath.replace(buildPath, "").replace(".obj", "") + ".jpg");
                         componentModelUploadEntity.setObjPath(objPath.replace(buildPath, ""));
                         componentModelUploadService.updateById(componentModelUploadEntity);
-                        redisUtil.setEx("componetUploadStatus::id::"+componentModelUploadEntity.getId(),"done",30,TimeUnit.MINUTES);
+                        redisUtil.setEx("componentUploadStatus:id:"+componentModelUploadEntity.getId(),"done",30,TimeUnit.MINUTES);
                         break;
 
                     default:
@@ -1219,7 +1216,6 @@ public class RunBuild {
 
         String path = buildPath + "upload";
         String filePath = path + File.separator + fileId + File.separator;
-
         switch (uploadType){
             case "1":
                 endProductHandler(fileId, userId, modelId, dataJson, taskType, uploadType, filePath);
@@ -1413,7 +1409,7 @@ public class RunBuild {
                 }
 
                 if (objectJson.containsKey("progress")) {
-                    if (uploadType.equals("3")){
+                    if (uploadType.equals(ModelUploadType.COMPONENT.getValue())){
                         ComponentModelUploadEntity  componentModelUploadEntity = new ComponentModelUploadEntity();
                         componentModelUploadEntity.setId(Long.valueOf(modelId));
                         componentModelUploadEntity.setProgress(objectJson.getInteger("progress"));

+ 1 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/SceneStyleController.java

@@ -307,6 +307,7 @@ public class SceneStyleController extends BaseController {
         }
         LambdaQueryWrapper<SceneLightEntity> wrapper1 = Wrappers.lambdaQuery();
         wrapper1.eq(SceneLightEntity::getSceneStyleId, sceneStyleEntity.getId())
+                .eq(SceneLightEntity::getStatus, 0)
                 .orderByDesc(SceneLightEntity::getId);
         List<SceneLightEntity> lightEntityList = sceneLightService.list(wrapper1);
         SceneLightEntity sceneLightEntity = null;

+ 1 - 1
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/custom/ComponetManagerController.java

@@ -285,7 +285,7 @@ public class ComponetManagerController extends BaseController {
 
         rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.MODEL, componentModelUploadEntity.getId() + ":;" + fileId + ":;" + userId + ":;" + modelType + ":;" + "false"+":;" +"3");
 
-        cacheChannel.set("componetUploadStatus","id"+componentModelUploadEntity.getId(),"running");
+        cacheChannel.set("componentUploadStatus","id"+componentModelUploadEntity.getId(),"running");
         return Result.success(componentModelUploadEntity);
     }
 

+ 1 - 1
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/testController.java

@@ -56,7 +56,7 @@ public class testController extends BaseController {
             @ApiImplicitParam(name = "val", value = "val", dataType = "String")})
     @RequestMapping(value = "/redis", method = RequestMethod.POST)
     public Result redis(String key, String val) {
-        redisUtil.setEx("componetUploadStatus::id::"+key,val,30, TimeUnit.MINUTES);
+        redisUtil.setEx("componentUploadStatus:id:"+key,val,30, TimeUnit.MINUTES);
         return success(redisUtil.get(key));
     }
     /**

+ 5 - 5
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/impl/CustomProductFirstclassifyServiceImpl.java

@@ -54,7 +54,7 @@ public class CustomProductFirstclassifyServiceImpl extends BaseServiceImpl<ICust
     public boolean removeById(Long id) {
         boolean removeById=super.removeById(id);
         if (removeById){
-            cacheChannel.evict("CustomProductFirstclassifyEntity","id::"+id);
+            cacheChannel.evict("CustomProductFirstclassifyEntity","id:"+id);
         }
         return removeById;
     }
@@ -62,13 +62,13 @@ public class CustomProductFirstclassifyServiceImpl extends BaseServiceImpl<ICust
     @Override
     public CustomProductFirstclassifyEntity findById(Long id) {
         CustomProductFirstclassifyEntity entity=null;
-        if (cacheChannel.check("CustomProductFirstclassifyEntity","id::"+id) >0){
-            CacheObject cache= cacheChannel.get("CustomProductFirstclassifyEntity","id::"+id);
+        if (cacheChannel.check("CustomProductFirstclassifyEntity","id:"+id) >0){
+            CacheObject cache= cacheChannel.get("CustomProductFirstclassifyEntity","id:"+id);
             entity= BeanUtil.toBean(cache.getValue(),CustomProductFirstclassifyEntity.class);
         }else {
             entity=super.findById(id);
             if (ObjectUtil.isNotNull(entity)){
-                cacheChannel.set("CustomProductFirstclassifyEntity","id::"+entity.getId(),entity,1800);
+                cacheChannel.set("CustomProductFirstclassifyEntity","id:"+entity.getId(),entity,1800);
             }
         }
         return entity;
@@ -78,7 +78,7 @@ public class CustomProductFirstclassifyServiceImpl extends BaseServiceImpl<ICust
     public boolean updateById(CustomProductFirstclassifyEntity entity) {
         boolean updateById=super.updateById(entity);
         if (updateById){
-            cacheChannel.set("CustomProductFirstclassifyEntity","id::"+entity.getId(),entity,60*30  );
+            cacheChannel.set("CustomProductFirstclassifyEntity","id:"+entity.getId(),entity,60*30  );
         }
         return updateById;
     }

+ 6 - 6
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/ModelUploadServiceImpl.java

@@ -88,8 +88,8 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
     public boolean removeById(Long id) {
         boolean removeById=super.removeById(id);
         if (removeById){
-            cacheChannel.evict("ModelUploadEntity","id::"+id);
-            cacheChannel.evict("ModelUploadEntity","fileId::"+id);
+            cacheChannel.evict("ModelUploadEntity","id:"+id);
+            cacheChannel.evict("ModelUploadEntity","fileId:"+id);
         }
         return removeById;
     }
@@ -98,7 +98,7 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
     public ModelUploadEntity findById(Long id) {
         ModelUploadEntity entity=super.findById(id);
         if (ObjectUtil.isNotNull(entity)){
-            cacheChannel.set("ModelUploadEntity","id::"+entity.getId(),entity,60*30 );
+            cacheChannel.set("ModelUploadEntity","id:"+entity.getId(),entity,60*30 );
         }
         return super.findById(id);
     }
@@ -107,8 +107,8 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
     public boolean updateById(ModelUploadEntity entity) {
         boolean updateById=super.updateById(entity);
         if (updateById){
-            cacheChannel.set("ModelUploadEntity","id::"+entity.getId(),entity,60*30  );
-            cacheChannel.set("ModelUploadEntity","fileId::"+entity.getFileId(),entity,60*30 );
+            cacheChannel.set("ModelUploadEntity","id:"+entity.getId(),entity,60*30  );
+            cacheChannel.set("ModelUploadEntity","fileId:"+entity.getFileId(),entity,60*30 );
         }
         return updateById;
     }
@@ -294,7 +294,7 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
     public ModelUploadEntity findByFileId(String fileId) {
         ModelUploadEntity entity=modelUploadMapper.findByFileId(fileId);
         if (ObjectUtil.isNotNull(entity)){
-            cacheChannel.set("ModelUploadEntity","fileId::"+fileId,entity,60*30 );
+            cacheChannel.set("ModelUploadEntity","fileId:"+fileId,entity,60*30 );
         }
         return entity;
     }

+ 12 - 26
sxz-core/src/main/java/com/fdkk/sxz/webApi/socketController/ComponentSocket.java

@@ -1,45 +1,30 @@
 package com.fdkk.sxz.webApi.socketController;
 
 
-import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.fdkk.sxz.entity.ComponentModelUploadEntity;
-import com.fdkk.sxz.util.OkHttpUtils;
 import com.fdkk.sxz.util.RedisUtil;
 import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
 import io.netty.handler.codec.http.HttpHeaders;
 import io.netty.handler.timeout.IdleStateEvent;
-import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
-import net.oschina.j2cache.CacheChannel;
-import net.oschina.j2cache.CacheObject;
-import net.oschina.j2cache.CacheProviderHolder;
-import net.oschina.j2cache.Command;
-import net.oschina.j2cache.cluster.ClusterPolicy;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-import org.springframework.util.MultiValueMap;
 import org.yeauty.annotation.*;
 import org.yeauty.pojo.Session;
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
 
 /**
  * @author XieWj
  */
-@ServerEndpoint(path = "/wss/componentWSS/", port = "8889")
+@ServerEndpoint(path = "/wss/componentWSS/", port = "${ws.port}")
 @Slf4j
 public class ComponentSocket {
 
@@ -47,7 +32,7 @@ public class ComponentSocket {
     private String mainUrl;
 
 
-    private static Map<String, ComponentSocket> ComponentSocketMap = new ConcurrentHashMap<>();
+    private static Map<String, ComponentSocket> componentSocketMap = new ConcurrentHashMap<>();
 
     @Autowired
     private RedisUtil redisUtil;
@@ -79,7 +64,6 @@ public class ComponentSocket {
     @OnOpen
     public void onOpen(Session session, HttpHeaders headers, @PathVariable Map pathMap) {
         log.info("new connection, sessionId-{},Host-{}", session.id(), headers.get("Host"));
-        isStop = true;
     }
 
     @OnClose
@@ -94,7 +78,9 @@ public class ComponentSocket {
     @OnError
     public void onError(Session session, Throwable throwable) {
         throwable.printStackTrace();
-        thread.interrupt();
+        if (thread != null) {
+            thread.interrupt();
+        }
     }
 
     public void toDo(Session session, String message) throws InterruptedException {
@@ -106,8 +92,8 @@ public class ComponentSocket {
             if (session.isOpen()) {
                 String status = data.getStr("status");
                 if (StrUtil.equals(status, "query")) {
-                    if (redisUtil.hasKey("componetUploadStatus::id::" + id)) {
-                        String ObjStatus = redisUtil.get("componetUploadStatus::id::" + id);
+                    if (redisUtil.hasKey("componentUploadStatus:id:" + id)) {
+                        String ObjStatus = redisUtil.get("componentUploadStatus:id:" + id);
                         if (StrUtil.equals(ObjStatus, "done")) {
                             extracted(session, data, id);
                             return;
@@ -125,14 +111,14 @@ public class ComponentSocket {
                     }
 
                     if (Thread.currentThread().isInterrupted()) {
-                        log.info("i has interputed");
+                        log.info("i has isInterrupted");
                         return;
                     }
                 }
             } else {
                 //连接关闭直接return
                 isStop = false;
-                ComponentSocketMap.remove("id" + data.getInt("id") + "session" + session.id());
+                componentSocketMap.remove("id" + data.getInt("id") + "session" + session.id());
                 return;
             }
         }
@@ -148,7 +134,7 @@ public class ComponentSocket {
         res.set("code", 0);
         session.sendText(res.toString());
         //连接关闭直接return
-        ComponentSocketMap.remove("id" + data.getInt("id") + "session" + session.id());
+        componentSocketMap.remove("id" + data.getInt("id") + "session" + session.id());
         Thread.yield();
     }
 
@@ -162,8 +148,8 @@ public class ComponentSocket {
             JSONObject data = JSONUtil.parseObj(message);
             res.set("msg", "is Json");
             isStop = true;
-            if (!ComponentSocketMap.containsKey("id" + data.getInt("id") + "session" + session.id())) {
-                ComponentSocketMap.put("id" + data.getInt("id") + "session" + session.id(), this);
+            if (!componentSocketMap.containsKey("id" + data.getInt("id") + "session" + session.id())) {
+                componentSocketMap.put("id" + data.getInt("id") + "session" + session.id(), this);
                 thread = new Thread(() -> {
                     try {
                         toDo(session, message);

+ 23 - 0
sxz-modules/src/main/java/com/fdkk/sxz/enums/ModelUploadType.java

@@ -0,0 +1,23 @@
+package com.fdkk.sxz.enums;
+
+import lombok.*;
+
+
+/**
+ * @author Xiwj
+ */
+
+@Getter
+@AllArgsConstructor
+public enum ModelUploadType {
+
+    END_PRODUCT("1", "成品"),
+    CUSTOM("2", "定制"),
+    COMPONENT("3", "组件");
+
+    private String value;
+    private String label;
+
+
+}
+