Kaynağa Gözat

优化代码

xiewenjie 3 yıl önce
ebeveyn
işleme
43a34591e3

+ 164 - 163
sxz-core/src/main/java/com/fdkk/sxz/other/listener/RunBuild.java

@@ -585,203 +585,204 @@ public class RunBuild {
             buildType = datas[7];
         }
 
-        SceneStyleEntity sceneStyleEntity = null;
-
-
-        LambdaQueryWrapper<SceneStyleEntity> wrapper = Wrappers.lambdaQuery();
-        wrapper.eq(SceneStyleEntity::getStyleNum, vrNum);
-
-
-        List<SceneStyleEntity> list = sceneStyleService.list(wrapper);
-        if (list != null && list.size() > 0) {
-            sceneStyleEntity = list.get(0);
-        } else {
-            RunBuild.log.info("场景不存在,出现异常");
-            return;
-        }
 
-        SceneStyleEntity updateSceneStyleEntity = new SceneStyleEntity();
-        updateSceneStyleEntity.setId(sceneStyleEntity.getId());
-
-        try {
-            // run方法具体重写
-            RunBuild.log.info("查询计算服务器状态");
-            JSONObject jsonObject = new JSONObject();
-//            boolean ready = false;
-            if ("".equals(dateType)) {
-                dateType = "day";
+        //上锁保证只有一个在消费,加锁一个钟,成功消费就解锁了
+        String token = RedisUtil.tryLock(taskId, 60 * 60 * 1000);
+        if (token != null) {
+            SceneStyleEntity entity = sceneStyleService.findById(taskId);
+            if (entity == null) {
+                RunBuild.log.info("场景不存在,出现异常");
+                return;
             }
 
-            RunBuild.log.info("调用计算api");
-            jsonObject.put("name", vrNum);
-            jsonObject.put("taskType", buildType);
-            jsonObject.put("map", dateType);
-            jsonObject.put("resolution", Integer.parseInt(type));
-            jsonObject.put("ratio", ratio);
-            jsonObject.put("taskId", taskId);
-            jsonObject.put("quality", Integer.parseInt(quality));
-            int num[] = new int[1];
-            num[0] = -1;
-            jsonObject.put("ids", num);
+            SceneStyleEntity updateSceneStyleEntity = new SceneStyleEntity();
+            updateSceneStyleEntity.setId(entity.getId());
 
-            //调用pro之前等待一秒,需要清理缓存
-            Thread.sleep(1000L);
-            while (true) {
-                String buildResult = OkHttpUtils.httpPostJson(lightBuildUrl + "pro", jsonObject.toJSONString());
-                JSONObject buildJson = JSONObject.parseObject(buildResult);
+            try {
+                // run方法具体重写
+                RunBuild.log.info("查询计算服务器状态");
+                JSONObject jsonObject = new JSONObject();
+//            boolean ready = false;
+                if ("".equals(dateType)) {
+                    dateType = "day";
+                }
 
-                RunBuild.log.info("请求3d场景渲染接口获取接口数据-{}", buildJson);
+                RunBuild.log.info("调用计算api");
+                jsonObject.put("name", vrNum);
+                jsonObject.put("taskType", buildType);
+                jsonObject.put("map", dateType);
+                jsonObject.put("resolution", Integer.parseInt(type));
+                jsonObject.put("ratio", ratio);
+                jsonObject.put("taskId", taskId);
+                jsonObject.put("quality", Integer.parseInt(quality));
+                int num[] = new int[1];
+                num[0] = -1;
+                jsonObject.put("ids", num);
+
+                //调用pro之前等待一秒,需要清理缓存
+                Thread.sleep(1000L);
+                while (true) {
+                    String buildResult = OkHttpUtils.httpPostJson(lightBuildUrl + "pro", jsonObject.toJSONString());
+                    JSONObject buildJson = JSONObject.parseObject(buildResult);
+
+                    RunBuild.log.info("请求3d场景渲染接口获取接口数据-{}", buildJson);
+
+                    if ("isBusy".equals(buildJson.getString("msg"))) {
+                        Thread.sleep(2000L);
+                        continue;
+                    }
 
-                if ("isBusy".equals(buildJson.getString("msg"))) {
-                    Thread.sleep(2000L);
-                    continue;
-                }
+                    if ("error".equals(buildJson.getString("state"))) {
+                        FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-pro.json", buildJson.toJSONString());
+                        throw new RuntimeException(vrNum + ":light方式pro接口返回error错误");
+                    }
 
-                if ("error".equals(buildJson.getString("state"))) {
-                    FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-pro.json", buildJson.toJSONString());
-                    throw new RuntimeException(vrNum + ":light方式pro接口返回error错误");
+                    break;
                 }
 
-                break;
-            }
-
-            //等待3秒后请求check
-            Thread.sleep(3000L);
+                //等待3秒后请求check
+                Thread.sleep(3000L);
 
 //            boolean uploadObj = true;
-            //是否计算结束
-            boolean over = false;
-
-            jsonObject = new JSONObject();
-            jsonObject.put("name", vrNum);
-            jsonObject.put("taskType", buildType);
-            jsonObject.put("taskId", taskId);
-            jsonObject.put("ratio", ratio);
-            int times = 0;
-            while (true) {
-                String checkResult = OkHttpUtils.httpPostJson(lightBuildUrl + "check", jsonObject.toJSONString());
-                JSONObject checkJson = JSONObject.parseObject(checkResult);
-
-                RunBuild.log.info("请求检查3d场景渲染接口获取接口数据-{}", checkJson);
+                //是否计算结束
+                boolean over = false;
 
-                JSONArray checkArray = checkJson.getJSONArray("msg");
+                jsonObject = new JSONObject();
+                jsonObject.put("name", vrNum);
+                jsonObject.put("taskType", buildType);
+                jsonObject.put("taskId", taskId);
+                jsonObject.put("ratio", ratio);
+                int times = 0;
+                while (true) {
+                    String checkResult = OkHttpUtils.httpPostJson(lightBuildUrl + "check", jsonObject.toJSONString());
+                    JSONObject checkJson = JSONObject.parseObject(checkResult);
 
-                if (checkArray.size() == 0) {
-                    FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-check.json", checkJson.toJSONString());
-                    throw new RuntimeException(vrNum + ":light方式check接口返回error错误");
-                }
+                    RunBuild.log.info("请求检查3d场景渲染接口获取接口数据-{}", checkJson);
 
-                for (int i = 0, len = checkArray.size(); i < len; i++) {
-                    JSONObject objectJson = checkArray.getJSONObject(i);
+                    JSONArray checkArray = checkJson.getJSONArray("msg");
 
-                    if ("error".equals(objectJson.getString("state"))) {
+                    if (checkArray.size() == 0) {
                         FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-check.json", checkJson.toJSONString());
                         throw new RuntimeException(vrNum + ":light方式check接口返回error错误");
                     }
 
-                    if (objectJson.containsKey("state") && ("".equals(objectJson.getString("state")) ||
-                            "done".equals(objectJson.getString("state")))) {
-                        over = true;
+                    for (int i = 0, len = checkArray.size(); i < len; i++) {
+                        JSONObject objectJson = checkArray.getJSONObject(i);
+
+                        if ("error".equals(objectJson.getString("state"))) {
+                            FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-check.json", checkJson.toJSONString());
+                            throw new RuntimeException(vrNum + ":light方式check接口返回error错误");
+                        }
+
+                        if (objectJson.containsKey("state") && ("".equals(objectJson.getString("state")) ||
+                                "done".equals(objectJson.getString("state")))) {
+                            over = true;
+                        }
+
+                        if (objectJson.containsKey("progress")) {
+                            Integer progress = objectJson.getInteger("progress");
+                            RunBuild.log.info("第{}次获取渲染进度,进度为{}%", times++, progress);
+                            SceneLightEntity sceneLightEntity = new SceneLightEntity();
+                            sceneLightEntity.setId(Long.valueOf(taskId));
+                            sceneLightEntity.setProgress(progress);
+                            sceneLightService.updateById(sceneLightEntity);
+                        }
                     }
 
-                    if (objectJson.containsKey("progress")) {
-                        Integer progress = objectJson.getInteger("progress");
-                        RunBuild.log.info("第{}次获取渲染进度,进度为{}%", times++, progress);
-                        SceneLightEntity sceneLightEntity = new SceneLightEntity();
-                        sceneLightEntity.setId(Long.valueOf(taskId));
-                        sceneLightEntity.setProgress(progress);
-                        sceneLightService.updateById(sceneLightEntity);
+                    if (over) {
+                        break;
                     }
-                }
 
-                if (over) {
-                    break;
+                    Thread.sleep(500L);
                 }
 
-                Thread.sleep(500L);
-            }
-
-            RunBuild.log.info("计算完成:" + buildPath + "Output/" + vrNum);
-
-            if ("light".equals(buildType)) {
-                updateSceneStyleEntity.setLightStatus(1);
-                updateSceneStyleEntity.setLightVersion(sceneStyleEntity.getLightVersion() + 1);
-            }
+                RunBuild.log.info("计算完成:" + buildPath + "Output/" + vrNum);
 
-            if ("pano".equals(buildType)) {
-                updateSceneStyleEntity.setPanoStatus(1);
-                updateSceneStyleEntity.setPanoVersion(sceneStyleEntity.getPanoVersion() + 1);
-            }
-            updateSceneStyleEntity.setUpdateTime(new Date());
-            sceneStyleService.updateById(updateSceneStyleEntity);
+                if ("light".equals(buildType)) {
+                    updateSceneStyleEntity.setLightStatus(1);
+                    updateSceneStyleEntity.setLightVersion(entity.getLightVersion() + 1);
+                }
 
-            SceneLightEntity sceneLightEntity = new SceneLightEntity();
-            sceneLightEntity.setId(Long.valueOf(taskId));
-            if ("light".equals(buildType)) {
-                sceneLightEntity.setImg("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/preview/" + taskId + "/preview.jpg");
-
-                LambdaQueryWrapper<StatisticsEntity> wrapper1 = Wrappers.lambdaQuery();
-                wrapper1.eq(StatisticsEntity::getStatisticsDate, DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
-                List<StatisticsEntity> statisticsEntityList = statisticsService.list(wrapper1);
-                if (statisticsEntityList.size() > 0) {
-                    StatisticsEntity statisticsEntity = statisticsEntityList.get(0);
-                    statisticsEntity.setLightNum(statisticsEntity.getLightNum() + 1);
-                    statisticsService.updateById(statisticsEntity);
-                } else {
-                    StatisticsEntity statisticsEntity = new StatisticsEntity();
-                    statisticsEntity.setLightNum(1);
-                    statisticsEntity.setStatisticsDate(DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
-                    statisticsService.save(statisticsEntity);
+                if ("pano".equals(buildType)) {
+                    updateSceneStyleEntity.setPanoStatus(1);
+                    updateSceneStyleEntity.setPanoVersion(entity.getPanoVersion() + 1);
                 }
-            }
-            if ("pano".equals(buildType)) {
-                sceneLightEntity.setImg("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/pano/" + taskId + "/pano_sphere.jpg");
-                String panoPath = buildPath + "Output/" + vrNum + "pano";
-
-                FileUtils.deleteDirectory(panoPath);
-                File panoFile = new File(panoPath);
-                if (!panoFile.exists()) {
-                    panoFile.mkdirs();
+                updateSceneStyleEntity.setUpdateTime(new Date());
+                sceneStyleService.updateById(updateSceneStyleEntity);
+
+                SceneLightEntity sceneLightEntity = new SceneLightEntity();
+                sceneLightEntity.setId(Long.valueOf(taskId));
+                if ("light".equals(buildType)) {
+                    sceneLightEntity.setImg("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/preview/" + taskId + "/preview.jpg");
+
+                    LambdaQueryWrapper<StatisticsEntity> wrapper1 = Wrappers.lambdaQuery();
+                    wrapper1.eq(StatisticsEntity::getStatisticsDate, DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
+                    List<StatisticsEntity> statisticsEntityList = statisticsService.list(wrapper1);
+                    if (statisticsEntityList.size() > 0) {
+                        StatisticsEntity statisticsEntity = statisticsEntityList.get(0);
+                        statisticsEntity.setLightNum(statisticsEntity.getLightNum() + 1);
+                        statisticsService.updateById(statisticsEntity);
+                    } else {
+                        StatisticsEntity statisticsEntity = new StatisticsEntity();
+                        statisticsEntity.setLightNum(1);
+                        statisticsEntity.setStatisticsDate(DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
+                        statisticsService.save(statisticsEntity);
+                    }
                 }
-                uploadToOssUtil.download("images/images" + vrNum + "/tiles/pano/" + taskId + "/pano_sphere.jpg", panoPath + "/pano_sphere.jpg");
-                CreateObjUtil.panoCutaway(panoPath + "/pano_sphere.jpg");
+                if ("pano".equals(buildType)) {
+                    sceneLightEntity.setImg("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/pano/" + taskId + "/pano_sphere.jpg");
+                    String panoPath = buildPath + "Output/" + vrNum + "pano";
+
+                    FileUtils.deleteDirectory(panoPath);
+                    File panoFile = new File(panoPath);
+                    if (!panoFile.exists()) {
+                        panoFile.mkdirs();
+                    }
+                    uploadToOssUtil.download("images/images" + vrNum + "/tiles/pano/" + taskId + "/pano_sphere.jpg", panoPath + "/pano_sphere.jpg");
+                    CreateObjUtil.panoCutaway(panoPath + "/pano_sphere.jpg");
+
+                    if (new File(panoPath + "/vtour").exists()) {
+                        CreateObjUtil.ossUploadCommon(panoPath + "/vtour", "4dkankan/images/images" + vrNum + "/tiles/pano/" + taskId + "/vtour");
+                        sceneLightEntity.setFilePath("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/pano/" + taskId + "/vtour/tour.html");
+                    }
 
-                if (new File(panoPath + "/vtour").exists()) {
-                    CreateObjUtil.ossUploadCommon(panoPath + "/vtour", "4dkankan/images/images" + vrNum + "/tiles/pano/" + taskId + "/vtour");
-                    sceneLightEntity.setFilePath("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/pano/" + taskId + "/vtour/tour.html");
+                    LambdaQueryWrapper<StatisticsEntity> wrapper1 = Wrappers.lambdaQuery();
+                    wrapper1.eq(StatisticsEntity::getStatisticsDate, DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
+                    List<StatisticsEntity> statisticsEntityList = statisticsService.list(wrapper1);
+                    if (statisticsEntityList.size() > 0) {
+                        StatisticsEntity statisticsEntity = statisticsEntityList.get(0);
+                        statisticsEntity.setPanoNum(statisticsEntity.getPanoNum() + 1);
+                        statisticsService.updateById(statisticsEntity);
+                    } else {
+                        StatisticsEntity statisticsEntity = new StatisticsEntity();
+                        statisticsEntity.setPanoNum(1);
+                        statisticsEntity.setStatisticsDate(DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
+                        statisticsService.save(statisticsEntity);
+                    }
                 }
+                sceneLightEntity.setStatus(1);
+                sceneLightEntity.setUpdateTime(new Date());
+                sceneLightService.updateById(sceneLightEntity);
+            } catch (Exception e) {
+                //渲染失败,修改风格表和灯光预览相册集
+                updateSceneStyleEntity.setLightStatus(-1);
+                updateSceneStyleEntity.setLightVersion(entity.getLightVersion() + 1);
+                updateSceneStyleEntity.setUpdateTime(new Date());
+                sceneStyleService.updateById(updateSceneStyleEntity);
+
+                SceneLightEntity sceneLightEntity = new SceneLightEntity();
+                sceneLightEntity.setId(Long.valueOf(taskId));
+                sceneLightEntity.setStatus(-1);
+                sceneLightEntity.setUpdateTime(new Date());
+                sceneLightService.updateById(sceneLightEntity);
 
-                LambdaQueryWrapper<StatisticsEntity> wrapper1 = Wrappers.lambdaQuery();
-                wrapper1.eq(StatisticsEntity::getStatisticsDate, DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
-                List<StatisticsEntity> statisticsEntityList = statisticsService.list(wrapper1);
-                if (statisticsEntityList.size() > 0) {
-                    StatisticsEntity statisticsEntity = statisticsEntityList.get(0);
-                    statisticsEntity.setPanoNum(statisticsEntity.getPanoNum() + 1);
-                    statisticsService.updateById(statisticsEntity);
-                } else {
-                    StatisticsEntity statisticsEntity = new StatisticsEntity();
-                    statisticsEntity.setPanoNum(1);
-                    statisticsEntity.setStatisticsDate(DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
-                    statisticsService.save(statisticsEntity);
+                RunBuild.log.error("渲染失败-{}", e);
+            } finally {
+                MDC.clear();
+                if (token != null) {
+                    RedisUtil.unlock(taskId, token);
                 }
             }
-            sceneLightEntity.setStatus(1);
-            sceneLightEntity.setUpdateTime(new Date());
-            sceneLightService.updateById(sceneLightEntity);
-        } catch (Exception e) {
-            //渲染失败,修改风格表和灯光预览相册集
-            updateSceneStyleEntity.setLightStatus(-1);
-            updateSceneStyleEntity.setLightVersion(sceneStyleEntity.getLightVersion() + 1);
-            updateSceneStyleEntity.setUpdateTime(new Date());
-            sceneStyleService.updateById(updateSceneStyleEntity);
-
-            SceneLightEntity sceneLightEntity = new SceneLightEntity();
-            sceneLightEntity.setId(Long.valueOf(taskId));
-            sceneLightEntity.setStatus(-1);
-            sceneLightEntity.setUpdateTime(new Date());
-            sceneLightService.updateById(sceneLightEntity);
-
-            RunBuild.log.error("渲染失败-{}", e);
         }
     }
 

+ 19 - 24
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/ImportDataController.java

@@ -340,21 +340,16 @@ public class ImportDataController extends BaseController {
                 return Result.failure(CodeConstant.FAILURE_CODE_3001, CodeConstant.FAILURE_MSG_3001);
             }
 
-            LambdaQueryWrapper<SceneStyleEntity> wrapper = Wrappers.lambdaQuery();
-            wrapper.eq(SceneStyleEntity::getStyleNum, styleNum);
-            wrapper.orderByDesc(SceneStyleEntity::getNum);
-            List<SceneStyleEntity> list = sceneStyleService.list(wrapper);
+            SceneStyleEntity entity = sceneStyleService.findSceneNum(styleNum);
 
-            SceneStyleEntity sceneStyleEntity = null;
             if (StringUtils.isEmpty(buildType) || "all".equals(buildType)) {
-                if (list != null && list.size() > 0) {
-                    sceneStyleEntity = list.get(0);
-                    if (sceneStyleEntity.getStatus().intValue() == 0) {
+                if (entity != null) {
+                    if (entity.getStatus().intValue() == 0) {
                         return Result.failure(CodeConstant.FAILURE_CODE_4002, CodeConstant.FAILURE_MSG_4002);
                     }
-                    sceneStyleEntity.setStatus(0);
-                    sceneStyleEntity.setProgress(0);
-                    sceneStyleService.updateById(sceneStyleEntity);
+                    entity.setStatus(0);
+                    entity.setProgress(0);
+                    sceneStyleService.updateById(entity);
                 } else {
                     return Result.failure(CodeConstant.FAILURE_CODE_4003, CodeConstant.FAILURE_MSG_4003);
                 }
@@ -363,7 +358,7 @@ public class ImportDataController extends BaseController {
                 map.put("type", "change");
                 map.put("num", styleNum);
                 map.put("oldNum", sceneNum);
-                map.put("sceneName", sceneStyleEntity.getStyleName());
+                map.put("sceneName", entity.getStyleName());
                 map.put("resolution", type);
                 OkHttpUtils.httpPostForm(mainUrl + "api/scene/createChangeScene", map);
 
@@ -391,23 +386,22 @@ public class ImportDataController extends BaseController {
                 }
 
                 SceneLightEntity sceneLightEntity = new SceneLightEntity();
-                if (list != null && list.size() > 0) {
-                    sceneStyleEntity = list.get(0);
+                if (entity != null) {
                     if ("light".equals(buildType)) {
                         ImportDataController.log.info("灯光预览:" + styleNum);
-                        if (sceneStyleEntity.getLightStatus().intValue() == 0) {
-                            return Result.failure(CodeConstant.FAILURE_CODE_4004, CodeConstant.FAILURE_MSG_4004);
-                        }
-                        sceneStyleEntity.setLightStatus(0);
+                        //if (entity.getLightStatus().intValue() == 0) {
+                        //    return Result.failure(CodeConstant.FAILURE_CODE_4004, CodeConstant.FAILURE_MSG_4004);
+                        //}
+                        entity.setLightStatus(0);
                     }
                     if ("pano".equals(buildType)) {
                         ImportDataController.log.info("全景预览:" + styleNum);
-                        if (sceneStyleEntity.getLightStatus().intValue() == 0) {
-                            return Result.failure(CodeConstant.FAILURE_CODE_4016, CodeConstant.FAILURE_MSG_4016);
-                        }
-                        sceneStyleEntity.setPanoStatus(0);
+                        //if (entity.getPanoStatus().intValue() == 0) {
+                        //    return Result.failure(CodeConstant.FAILURE_CODE_4016, CodeConstant.FAILURE_MSG_4016);
+                        //}
+                        entity.setPanoStatus(0);
                     }
-                    sceneStyleService.updateById(sceneStyleEntity);
+                    sceneStyleService.updateById(entity);
 
                     sceneLightEntity.setStatus(0);
                     sceneLightEntity.setProgress(0);
@@ -415,7 +409,7 @@ public class ImportDataController extends BaseController {
                         isShow = "1";
                     }
                     sceneLightEntity.setIsShow(Integer.valueOf(isShow));
-                    sceneLightEntity.setSceneStyleId(sceneStyleEntity.getId());
+                    sceneLightEntity.setSceneStyleId(entity.getId());
                     sceneLightEntity.setPixel(type);
 
                     //数据上传oss,让计算服务器下载资源
@@ -722,6 +716,7 @@ public class ImportDataController extends BaseController {
             return resultJson;
         } catch (Exception e) {
             e.printStackTrace();
+            ImportDataController.log.error("msg{}", e.getMessage());
             resultJson.put("msg", "转换失败");
             return resultJson;
         }

+ 2 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/ISceneStyleService.java

@@ -11,5 +11,7 @@ public interface ISceneStyleService extends IBaseService<SceneStyleEntity> {
 
     Integer findLastNum(String sceneNum);
 
+    SceneStyleEntity findSceneNum(String sceneNum);
+    
     int addVersion(RequestSceneLight style);
 }

+ 12 - 2
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/SceneStyleServiceImpl.java

@@ -1,10 +1,12 @@
 package com.fdkk.sxz.webApi.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
 import com.fdkk.sxz.entity.SceneStyleEntity;
+import com.fdkk.sxz.vo.request.RequestSceneLight;
 import com.fdkk.sxz.webApi.mapper.ISceneStyleMapper;
 import com.fdkk.sxz.webApi.service.ISceneStyleService;
-import com.fdkk.sxz.vo.request.RequestSceneLight;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -12,13 +14,21 @@ import org.springframework.stereotype.Service;
  * Created by Hb_zzZ on 2020/7/14.
  */
 @Service
-public class SceneStyleServiceImpl extends BaseServiceImpl<ISceneStyleMapper , SceneStyleEntity> implements ISceneStyleService{
+public class SceneStyleServiceImpl extends BaseServiceImpl<ISceneStyleMapper, SceneStyleEntity> implements ISceneStyleService {
 
     @Autowired
     private ISceneStyleMapper mapper;
 
 
     @Override
+    public SceneStyleEntity findSceneNum(String sceneNum) {
+        LambdaQueryWrapper<SceneStyleEntity> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(SceneStyleEntity::getStyleNum, sceneNum);
+        wrapper.orderByDesc(SceneStyleEntity::getNum);
+        return getOne(wrapper);
+    }
+
+    @Override
     public Integer findLastNum(String sceneNum) {
         return mapper.findLastNum(sceneNum);
     }