From 79346987951cbfe8ba8a8e417da5214047479f8c Mon Sep 17 00:00:00 2001 From: XMnhwj_BackTechnologyDevelopment <3512363680@qq.com> Date: Fri, 12 May 2023 18:05:58 +0800 Subject: [PATCH] =?UTF-8?q?2023-05-12=2016:02:05=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=89=80=E5=B1=9E=E7=AD=96=E7=95=A5=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/psdc/mapper/PsdcSceneMapper.java | 11 +++- .../com/psdc/service/IPsdcSceneService.java | 9 ++- .../service/impl/PsdcDeviceServiceImpl.java | 7 --- .../service/impl/PsdcSceneServiceImpl.java | 17 +++++- .../mapper/business/PsdcSceneMapper.xml | 19 ++++++ .../manager/PsdcSceneController.java | 58 +++++++++++++++++++ 6 files changed, 107 insertions(+), 14 deletions(-) create mode 100644 psdc-web/src/main/java/com/psdc/controller/manager/PsdcSceneController.java diff --git a/psdc-business/src/main/java/com/psdc/mapper/PsdcSceneMapper.java b/psdc-business/src/main/java/com/psdc/mapper/PsdcSceneMapper.java index ace9d22..3733012 100644 --- a/psdc-business/src/main/java/com/psdc/mapper/PsdcSceneMapper.java +++ b/psdc-business/src/main/java/com/psdc/mapper/PsdcSceneMapper.java @@ -17,11 +17,13 @@ public interface PsdcSceneMapper{ /** * 通过ID查询单条数据 * - * @param undefinedId 主键 + * @param sceneId 主键 * @return 实例对象 */ PsdcScene queryById(Integer sceneId); + List sceneList(@Param(value = "userId") Long userId); + /** * 新增数据 @@ -41,7 +43,7 @@ public interface PsdcSceneMapper{ /** * 通过主键删除数据 * - * @param undefinedId 主键 + * @param sceneId 主键 * @return 影响行数 */ int deleteById(Integer sceneId); @@ -76,7 +78,7 @@ public interface PsdcSceneMapper{ * @return */ List querySceneByDeviceIdAndSceneName(@Param(value = "userId") Long userId, - @Param(value = "deviceId") Integer deviceId, + @Param(value = "deviceId") Integer deviceId, @Param(value = "sceneName") String sceneName); /** @@ -85,4 +87,7 @@ public interface PsdcSceneMapper{ * @return */ List queryBySceneName(String sceneName); + + List findSceneByUserAndSceneName(@Param(value = "userId") Long userId, + @Param(value = "sceneName") String sceneName); } \ No newline at end of file diff --git a/psdc-business/src/main/java/com/psdc/service/IPsdcSceneService.java b/psdc-business/src/main/java/com/psdc/service/IPsdcSceneService.java index eec088b..7462bab 100644 --- a/psdc-business/src/main/java/com/psdc/service/IPsdcSceneService.java +++ b/psdc-business/src/main/java/com/psdc/service/IPsdcSceneService.java @@ -14,7 +14,7 @@ public interface IPsdcSceneService { /** * 通过ID查询单条数据 * - * @param undefinedId 主键 + * @param sceneId 主键 * @return 实例对象 */ PsdcScene queryById(Integer sceneId); @@ -26,6 +26,9 @@ public interface IPsdcSceneService { * @return 实例对象 */ PsdcScene insert(PsdcScene psdcScene); + + List sceneList(); + /** * 更新数据 * @@ -36,10 +39,12 @@ public interface IPsdcSceneService { /** * 通过主键删除数据 * - * @param undefinedId 主键 + * @param sceneId 主键 * @return 是否成功 */ boolean deleteById(Integer sceneId); List> getStrategyList(); + + List findSceneByUserAndSceneName(Integer sceneId); } \ No newline at end of file diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java index 1504c3c..7920364 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java @@ -159,16 +159,9 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { /** * 控制设备启动停止 -<<<<<<< HEAD - * @param deviceId 主键 - * @param runStatus 状态 - * @return 条数 -======= - * * @param deviceId * @param runStatus * @return ->>>>>>> e7257650302fdf30d685bfae8df3cc0405bb51f6 */ @Override public int controlDeviceStartAndStop(Integer deviceId, Integer runStatus, String controlBy, Integer controlMethod) { diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java index 781def8..e6ffde5 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java @@ -43,7 +43,13 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService { psdcSceneMapper.insert(psdcScene); return psdcScene; } - + + @Override + public List sceneList() { + Long userId = SecurityUtils.getUserId(); + return psdcSceneMapper.sceneList(userId); + } + /** * 更新数据 * @@ -58,7 +64,7 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService { /** * 通过主键删除数据 * - * @param undefinedId 主键 + * @param sceneId 主键 * @return 是否成功 */ public boolean deleteById(Integer sceneId){ @@ -93,4 +99,11 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService { .collect(Collectors.toList()); return collectList; } + + @Override + public List findSceneByUserAndSceneName(Integer sceneId) { + Long userId = SecurityUtils.getUserId(); + String sceneName = psdcSceneMapper.queryById(sceneId).getSceneName(); + return psdcSceneMapper.findSceneByUserAndSceneName(userId, sceneName); + } } \ No newline at end of file diff --git a/psdc-business/src/main/resources/mapper/business/PsdcSceneMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcSceneMapper.xml index 5187978..0e38726 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcSceneMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcSceneMapper.xml @@ -31,6 +31,10 @@ where scene_id = #{sceneId} + + insert into psdc_scene(scene_name,user_id,device_id,device_sn,scene_context,scene_key,scene_value) @@ -108,4 +112,19 @@ from psdc_scene ps left join psdc_device pd on ps.device_id = pd.device_id where ps.scene_name like concat('%', #{sceneName}, '%') + + \ No newline at end of file diff --git a/psdc-web/src/main/java/com/psdc/controller/manager/PsdcSceneController.java b/psdc-web/src/main/java/com/psdc/controller/manager/PsdcSceneController.java new file mode 100644 index 0000000..7e690fc --- /dev/null +++ b/psdc-web/src/main/java/com/psdc/controller/manager/PsdcSceneController.java @@ -0,0 +1,58 @@ +package com.psdc.controller.manager; + +import com.psdc.core.controller.BaseController; +import com.psdc.core.domain.AjaxResult; +import com.psdc.core.page.TableDataInfo; +import com.psdc.entity.PsdcScene; +import com.psdc.entity.vo.SceneVo; +import com.psdc.service.IPsdcSceneService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * @Author:戴仕崑 + * @Project:psdc + * @Filename:PsdcSceneCobtroller + * @Date:2023/5/12 16:25 + * @Version 1.0 + */ +@RestController +@RequestMapping("/system/cl/index") +public class PsdcSceneController extends BaseController { + + @Autowired + IPsdcSceneService psdcSceneService; + + @PreAuthorize("@ss.hasPermi('system:cl:list')") + @RequestMapping(value = "/selMyscene", method = RequestMethod.GET) + public AjaxResult selMyscene() { + List maps = new ArrayList<>(); + List list = psdcSceneService.sceneList(); + for (PsdcScene dd : list){ + Map map = new HashMap<>(); + map.put("label", dd.getSceneName()); + map.put("value", dd.getSceneId()); + maps.add(map); + } + return AjaxResult.success("用户所属策略列表", maps); + } + + @PreAuthorize("@ss.hasPermi('system:cl:list')") + @RequestMapping(value = "/list/{sceneId}", method = RequestMethod.GET) + public TableDataInfo list(@PathVariable(value = "sceneId", required = false) Integer sceneId) { + startPage(); + List list = psdcSceneService.findSceneByUserAndSceneName(sceneId); + return getDataTable(list); + } + +}