From 35e00864296b34cf7c67910069f24a87ba2d2eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Mon, 3 Mar 2025 11:17:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=97=E9=A4=90=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/ss/suit/service/SuitService.java | 13 +++-- .../ss/suit/service/impl/SuitServiceImpl.java | 32 ++++++++---- .../web/controller/ss/SmDeviceController.java | 9 ++-- .../web/controller/ss/SuitController.java | 51 +++++++++++-------- 4 files changed, 68 insertions(+), 37 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/SuitService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/SuitService.java index 9deec04d..389e6fa7 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/SuitService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/SuitService.java @@ -1,14 +1,14 @@ package com.ruoyi.ss.suit.service; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + import com.ruoyi.ss.suit.domain.Suit; import com.ruoyi.ss.suit.domain.SuitBO; import com.ruoyi.ss.suit.domain.SuitQuery; import com.ruoyi.ss.suit.domain.SuitVO; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - /** * 套餐Service接口 * @@ -114,4 +114,9 @@ public interface SuitService * 设置排序 */ int setSort(List list); + + /** + * 根据套餐ID查询套餐列表 + */ + List selectBySuitIds(List ids); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/impl/SuitServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/impl/SuitServiceImpl.java index 59cb27b5..21459f4f 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/impl/SuitServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/impl/SuitServiceImpl.java @@ -1,5 +1,16 @@ package com.ruoyi.ss.suit.service.impl; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.support.TransactionTemplate; + import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; @@ -15,16 +26,6 @@ import com.ruoyi.ss.suit.mapper.SuitMapper; import com.ruoyi.ss.suit.service.SuitConverter; import com.ruoyi.ss.suit.service.SuitService; import com.ruoyi.ss.suit.service.SuitValidator; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.support.TransactionTemplate; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.Function; -import java.util.stream.Collectors; /** * 套餐Service业务层处理 @@ -115,6 +116,17 @@ public class SuitServiceImpl implements SuitService return suitMapper.batchUpdateSort(list); } + + @Override + public List selectBySuitIds(List ids) { + if (CollectionUtils.isEmptyElement(ids)) { + return Collections.emptyList(); + } + SuitQuery query = new SuitQuery(); + query.setSuitIds(ids); + return selectSuitList(query); + } + /** * 插入前操作 */ diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java index 653addf8..04078e3d 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java @@ -2,6 +2,7 @@ package com.ruoyi.web.controller.ss; import java.math.BigDecimal; import java.util.Arrays; +import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -101,8 +102,10 @@ public class SmDeviceController extends BaseController @GetMapping(value = "/{deviceId}") public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) { DeviceVO device = deviceService.selectById(deviceId); - deviceAssembler.assembleRealServiceRate(device); - deviceAssembler.assembleBonusList(device); + List list = Collections.singletonList(device); + deviceAssembler.assembleRealServiceRate(list); + deviceAssembler.assembleBonusList(list); + deviceAssembler.assembleSuitList(list); return success(device); } @@ -276,7 +279,7 @@ public class SmDeviceController extends BaseController public AjaxResult setWxs(@RequestBody @Validated DeviceWxsDTO dto) { return toAjax(deviceService.setWxs(dto.getDeviceId(), dto.getWxs(), "管理员设置电量系数:" + dto.getWxs())); } - + @ApiOperation("设置设备反转参数") @PutMapping("/setSet") public AjaxResult setSet(@RequestBody @Validated DeviceSetDTO dto) { diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SuitController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SuitController.java index a62bbfd1..ca57e01a 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SuitController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SuitController.java @@ -3,35 +3,35 @@ package com.ruoyi.web.controller.ss; import java.util.Arrays; import java.util.Collections; import java.util.List; + import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.ValidGroup; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.ServiceUtil; -import com.ruoyi.ss.device.domain.vo.DeviceVO; -import com.ruoyi.ss.device.service.DeviceService; +import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.ss.suit.domain.SuitBO; import com.ruoyi.ss.suit.domain.SuitQuery; import com.ruoyi.ss.suit.domain.SuitVO; import com.ruoyi.ss.suit.service.SuitAssembler; -import com.ruoyi.ss.suit.service.SuitValidator; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.enums.BusinessType; import com.ruoyi.ss.suit.service.SuitService; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.ss.suit.service.SuitValidator; /** * 套餐Controller @@ -65,6 +65,17 @@ public class SuitController extends BaseController return getDataTable(list); } + /** + * 根据套餐ID查询套餐列表 + */ + @PreAuthorize("@ss.hasPermi('ss:suit:list')") + @GetMapping("/listByIds/{ids}") + public AjaxResult listByIds(@PathVariable List ids) + { + List list = suitService.selectBySuitIds(ids); + return success(list); + } + /** * 导出套餐列表 */