Browse Source

补充设备分类接口

lv.wenbin 10 months ago
parent
commit
2aa6ae9fc9

+ 10 - 6
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/DeviceController.java

@@ -60,9 +60,9 @@ public class DeviceController extends BaseController {
      */
     @RequiresPermissions("ems:device:list")
     @GetMapping("/list")
-    public TableDataInfo list(EmsDevice emsDevice) {
+    public TableDataInfo list(QueryDevice queryDevice) {
         startPage();
-        List<EmsDevice> list = deviceService.selectEmsDeviceList(emsDevice);
+        List<EmsDevice> list = deviceService.selectEmsDeviceList(queryDevice);
         return getDataTable(list);
     }
 
@@ -111,8 +111,12 @@ public class DeviceController extends BaseController {
      */
     @RequiresPermissions("basecfg:device:list")
     @GetMapping("/getTreeByFacs")
-    public AjaxResult getTreeByFacs(@RequestParam(value = "areaCode", required = false) String areaCode) {
-        return success(deviceService.getTreeByFacs(areaCode));
+    public AjaxResult getTreeByFacs(@RequestParam(value = "areaCode", required = false) String areaCode,
+        @RequestParam(value = "deviceCategory", required = false) String deviceCategory) {
+        QueryDevice queryDevice = new QueryDevice();
+        queryDevice.setRefArea(areaCode);
+        queryDevice.setDeviceCategory(deviceCategory);
+        return success(deviceService.getTreeByFacs(queryDevice));
     }
 
     /**
@@ -121,8 +125,8 @@ public class DeviceController extends BaseController {
     @RequiresPermissions("ems:device:export")
     @Log(title = "能源设备", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, EmsDevice emsDevice) {
-        List<EmsDevice> list = deviceService.selectEmsDeviceList(emsDevice);
+    public void export(HttpServletResponse response, QueryDevice queryDevice) {
+        List<EmsDevice> list = deviceService.selectEmsDeviceList(queryDevice);
         ExcelUtil<EmsDevice> util = new ExcelUtil<EmsDevice>(EmsDevice.class);
         util.exportExcel(response, list, "能源设备数据");
     }

+ 20 - 16
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/FacsCategoryController.java

@@ -18,6 +18,7 @@ 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.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
@@ -25,15 +26,14 @@ import java.util.List;
 
 /**
  * 能源设施/系统类别Controller
- * 
+ *
  * @author ruoyi
  * @date 2024-07-11
  */
 @RestController
 @RequestMapping("/basecfg/facsCategory")
 @Api(value = "FacsCategoryController", description = "设施类别管理")
-public class FacsCategoryController extends BaseController
-{
+public class FacsCategoryController extends BaseController {
     @Autowired
     private IFacsCategoryService facsCategoryService;
 
@@ -42,8 +42,7 @@ public class FacsCategoryController extends BaseController
      */
     @RequiresPermissions("basecfg:facscategory:list")
     @GetMapping("/list")
-    public TableDataInfo list(FacsCategory category)
-    {
+    public TableDataInfo list(FacsCategory category) {
         startPage();
         List<FacsCategory> list = facsCategoryService.selectCategoryList(category);
         return getDataTable(list);
@@ -51,6 +50,7 @@ public class FacsCategoryController extends BaseController
 
     /**
      * 获取所有能源设施/系统分类
+     *
      * @return 能源设施/系统分类列表
      */
     @GetMapping("/listall")
@@ -65,8 +65,7 @@ public class FacsCategoryController extends BaseController
     @RequiresPermissions("basecfg:facscategory:export")
     @Log(title = "能源设施/系统分类", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, FacsCategory category)
-    {
+    public void export(HttpServletResponse response, FacsCategory category) {
         List<FacsCategory> list = facsCategoryService.selectCategoryList(category);
         ExcelUtil<FacsCategory> util = new ExcelUtil<FacsCategory>(FacsCategory.class);
         util.exportExcel(response, list, "能源设施/系统分类数据");
@@ -77,19 +76,26 @@ public class FacsCategoryController extends BaseController
      */
     @RequiresPermissions("basecfg:facscategory:query")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(facsCategoryService.selectCategoryById(id));
     }
 
     /**
+     * 获取能源设施/系统分类详细信息
+     */
+    @RequiresPermissions("basecfg:facscategory:query")
+    @GetMapping(value = "/getByCode")
+    public AjaxResult getByCode(@RequestParam(name = "code") String code) {
+        return success(facsCategoryService.selectCategoryByCode(code));
+    }
+
+    /**
      * 新增能源设施/系统分类
      */
     @RequiresPermissions("basecfg:facscategory:add")
     @Log(title = "能源设施/系统分类", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody FacsCategory category)
-    {
+    public AjaxResult add(@RequestBody FacsCategory category) {
         return toAjax(facsCategoryService.insertCategory(category));
     }
 
@@ -99,8 +105,7 @@ public class FacsCategoryController extends BaseController
     @RequiresPermissions("basecfg:facscategory:edit")
     @Log(title = "能源设施/系统分类", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody FacsCategory category)
-    {
+    public AjaxResult edit(@RequestBody FacsCategory category) {
         return toAjax(facsCategoryService.updateCategory(category));
     }
 
@@ -109,9 +114,8 @@ public class FacsCategoryController extends BaseController
      */
     @RequiresPermissions("basecfg:facscategory:remove")
     @Log(title = "能源设施/系统分类", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(facsCategoryService.deleteCategoryByIds(ids));
     }
 }

+ 10 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/vo/QueryDevice.java

@@ -48,6 +48,8 @@ public class QueryDevice {
     /** 设备工艺标识编码 */
     private String psCode;
 
+    private Long deviceStatus;
+
     /** 所属子系统 */
     private String subsystemCode;
 
@@ -150,4 +152,12 @@ public class QueryDevice {
     public void setZoningCodes(List<String> zoningCodes) {
         this.zoningCodes = zoningCodes;
     }
+
+    public Long getDeviceStatus() {
+        return deviceStatus;
+    }
+
+    public void setDeviceStatus(Long deviceStatus) {
+        this.deviceStatus = deviceStatus;
+    }
 }

+ 1 - 1
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/EmsDeviceMapper.java

@@ -37,7 +37,7 @@ public interface EmsDeviceMapper {
      * @param emsDevice 能源设备
      * @return 能源设备集合
      */
-    List<EmsDevice> selectEmsDeviceList(EmsDevice emsDevice);
+    List<EmsDevice> selectEmsDeviceList(QueryDevice emsDevice);
 
     /**
      * 根据区域树递归查询设备

+ 8 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/FacsCategoryMapper.java

@@ -20,6 +20,14 @@ public interface FacsCategoryMapper {
     FacsCategory selectCategoryById(Long id);
 
     /**
+     * 查询能源设施/系统分类
+     *
+     * @param code code
+     * @return 能源设施/系统分类
+     */
+    FacsCategory selectCategoryByCode(String code);
+
+    /**
      * 查询能源设施/系统分类列表
      *
      * @param category 能源设施/系统分类

+ 5 - 5
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IEmsDeviceService.java

@@ -35,22 +35,22 @@ public interface IEmsDeviceService {
      * @param queryDevice 能源设备
      * @return 能源设备集合
      */
-    List<EmsDevice> selectEmsDeviceList(EmsDevice queryDevice);
+    List<EmsDevice> selectEmsDeviceList(QueryDevice queryDevice);
 
     /**
      * 查询能源设备列表
      *
-     * @param emsDevice 能源设备
+     * @param queryDevice 查询参数
      * @return 能源设备集合
      */
-    List<EmsDevice> selectByAreaTree(QueryDevice emsDevice);
+    List<EmsDevice> selectByAreaTree(QueryDevice queryDevice);
 
     /**
      * 根据设施获取设备树结构
-     * @param areaCode 区域编码
+     * @param queryDevice 查询参数
      * @return 设备树结构
      */
-    List<TreeEntity> getTreeByFacs(String areaCode);
+    List<TreeEntity> getTreeByFacs(QueryDevice queryDevice);
 
     /**
      * 新增能源设备

+ 8 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IFacsCategoryService.java

@@ -19,6 +19,14 @@ public interface IFacsCategoryService {
     FacsCategory selectCategoryById(Long id);
 
     /**
+     * 查询能源设施/系统分类
+     *
+     * @param code code
+     * @return 能源设施/系统分类
+     */
+    FacsCategory selectCategoryByCode(String code);
+
+    /**
      * 查询能源设施/系统分类列表
      *
      * @param emsCategory 能源设施/系统分类

+ 12 - 13
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/EmsDeviceServiceImpl.java

@@ -81,12 +81,12 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
     /**
      * 查询能源设备列表
      *
-     * @param emsDevice 能源设备
+     * @param queryDevice 查询条件
      * @return 能源设备
      */
     @Override
-    public List<EmsDevice> selectEmsDeviceList(EmsDevice emsDevice) {
-        List<EmsDevice> list = emsDeviceMapper.selectEmsDeviceList(emsDevice);
+    public List<EmsDevice> selectEmsDeviceList(QueryDevice queryDevice) {
+        List<EmsDevice> list = emsDeviceMapper.selectEmsDeviceList(queryDevice);
 
         if (CollectionUtils.isNotEmpty(list)) {
             for (EmsDevice device : list) {
@@ -119,17 +119,17 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
     /**
      * 根据设施获取设备树结构
      *
-     * @param areaCode 区域编码
+     * @param queryDevice 查询条件
      * @return 设备树结构
      */
     @Override
-    public List<TreeEntity> getTreeByFacs(String areaCode) {
+    public List<TreeEntity> getTreeByFacs(QueryDevice queryDevice) {
         List<TreeEntity> retList = new ArrayList<>();
         List<Area> areas = areaService.selectAreaList(new Area());
         List<AreaBuilding> buildings = buildingService.selectAreaBuildingList(new AreaBuilding());
         List<AreaBuildingZoning> zonings = zoningService.selectAreaBuildingZoningList(new AreaBuildingZoning());
 
-        if (StringUtils.isEmpty(areaCode)) {
+        if (StringUtils.isEmpty(queryDevice.getRefArea())) {
             if (CollectionUtils.isNotEmpty(areas)) {
                 for (Area area : areas) {
                     List<EmsFacs> facsList = facsService.selectFacsByArea(area.getAreaCode());
@@ -137,14 +137,14 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
                     TreeEntity entity = new TreeEntity();
                     entity.setId(area.getAreaCode());
                     entity.setLabel(area.getAreaName());
-                    entity.setChildren(buildFacsDevSub(facsList, areas, buildings, zonings));
+                    entity.setChildren(buildFacsDevSub(queryDevice, facsList, areas, buildings, zonings));
                     entity.setTier("Area");
                     retList.add(entity);
                 }
             }
         }
         else {
-            Area area = areaService.selectAreaByCode(areaCode);
+            Area area = areaService.selectAreaByCode(queryDevice.getRefArea());
 
             if (null != area) {
                 List<EmsFacs> facsList = facsService.selectFacsByArea(area.getAreaCode());
@@ -152,7 +152,7 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
                 TreeEntity entity = new TreeEntity();
                 entity.setId(area.getAreaCode());
                 entity.setLabel(area.getAreaName());
-                entity.setChildren(buildFacsDevSub(facsList, areas, buildings, zonings));
+                entity.setChildren(buildFacsDevSub(queryDevice, facsList, areas, buildings, zonings));
                 entity.setTier("Area");
                 retList.add(entity);
             }
@@ -161,7 +161,7 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
         return retList;
     }
 
-    private List<TreeEntity> buildFacsDevSub(List<EmsFacs> facsList, List<Area> areas, List<AreaBuilding> buildings,
+    private List<TreeEntity> buildFacsDevSub(QueryDevice queryParam, List<EmsFacs> facsList, List<Area> areas, List<AreaBuilding> buildings,
         List<AreaBuildingZoning> zonings) {
         List<TreeEntity> retList = new ArrayList<>();
         Map<String, Area> areaMap = areas.stream().collect(Collectors.toMap(Area::getAreaCode, Function.identity()));
@@ -174,9 +174,8 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
             boolean hasSub = false;
             List<TreeEntity> subList = new ArrayList<>();
 
-            EmsDevice param = new EmsDevice();
-            param.setRefFacs(facs.getFacsCode());
-            List<EmsDevice> devices = emsDeviceMapper.selectEmsDeviceList(param);
+            queryParam.setRefFacs(facs.getFacsCode());
+            List<EmsDevice> devices = emsDeviceMapper.selectEmsDeviceList(queryParam);
 
             for (EmsDevice device : devices) {
                 hasSub = true;

+ 13 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/FacsCategoryServiceImpl.java

@@ -44,6 +44,19 @@ public class FacsCategoryServiceImpl implements IFacsCategoryService {
         return category;
     }
 
+    @Override
+    public FacsCategory selectCategoryByCode(String code) {
+        // 查询主分类
+        FacsCategory category = categoryMapper.selectCategoryByCode(code);
+
+        // 查询子分类
+        if (null != category) {
+            category.setSubtypeList(getFacsSubtypes(category));
+        }
+
+        return category;
+    }
+
     /**
      * 查询能源设施/系统分类列表
      *

+ 2 - 2
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/EmsDeviceMapper.xml

@@ -42,12 +42,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             LEFT JOIN adm_ems_facs f ON d.`ref_facs` = f.`facs_code`
     </sql>
 
-    <select id="selectEmsDeviceList" parameterType="com.ruoyi.ems.domain.EmsDevice" resultMap="EmsDeviceResult">
+    <select id="selectEmsDeviceList" parameterType="com.ruoyi.ems.domain.vo.QueryDevice" resultMap="EmsDeviceResult">
         <include refid="selectEmsDeviceVo"/>
         <where>
             <if test="deviceCode != null  and deviceCode != ''"> and d.`device_code` = #{deviceCode}</if>
             <if test="deviceName != null  and deviceName != ''"> and d.`device_name` like concat('%', #{deviceName}, '%')</if>
-            <if test="deviceCategory != null and deviceCategory !=''"> and d.`device_category` = #{deviceCategory}</if>
+            <if test="deviceCategory != null and deviceCategory !=''"> and sc.`parent_code` = #{deviceCategory}</if>
             <if test="deviceStatus != null "> and d.`device_status` = #{deviceStatus}</if>
             <if test="areaType != null and areaType != ''"> and d.`area_type` = #{areaType}</if>
             <if test="refArea != null  and refArea != ''"> and d.`ref_area` = #{refArea}</if>

+ 6 - 1
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/FacsCategoryMapper.xml

@@ -30,7 +30,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectCategoryVo"/>
         where id = #{id}
     </select>
-        
+
+    <select id="selectCategoryByCode" parameterType="String" resultMap="FacsCategoryResult">
+        <include refid="selectCategoryVo"/>
+        where code = #{code}
+    </select>
+
     <insert id="insertCategory" parameterType="com.ruoyi.ems.domain.FacsCategory" useGeneratedKeys="true" keyProperty="id">
         insert into dim_ems_facs_category
         <trim prefix="(" suffix=")" suffixOverrides=",">