新增设备获取父类类别的id列表
This commit is contained in:
@ -35,8 +35,6 @@ public class EmsSiteConfigController extends BaseController{
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IEmsDeviceSettingService iEmsDeviceSettingService;
|
private IEmsDeviceSettingService iEmsDeviceSettingService;
|
||||||
@Autowired
|
|
||||||
private EmsPointMatchMapper emsPointMatchMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取站点列表
|
* 获取站点列表
|
||||||
@ -161,4 +159,13 @@ public class EmsSiteConfigController extends BaseController{
|
|||||||
{
|
{
|
||||||
return success(iEmsDeviceSettingService.getSiteAllDeviceCategory(siteId));
|
return success(iEmsDeviceSettingService.getSiteAllDeviceCategory(siteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备类别获取父类的设备id
|
||||||
|
*/
|
||||||
|
@GetMapping("/getParentDeviceId")
|
||||||
|
public AjaxResult getParentDeviceId(@RequestParam String siteId, @RequestParam String deviceCategory)
|
||||||
|
{
|
||||||
|
return success(iEmsSiteService.getParentCategoryDeviceId(siteId, deviceCategory));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.xzzn.common.enums;
|
package com.xzzn.common.enums;
|
||||||
|
|
||||||
|
import org.apache.xmlbeans.impl.common.NameUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -10,24 +12,26 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public enum DeviceCategory
|
public enum DeviceCategory
|
||||||
{
|
{
|
||||||
PCS("PCS", "PCS设备"),
|
PCS("PCS", "PCS设备", null),
|
||||||
BRANCH("BRANCH", "PCS分支设备"),
|
BRANCH("BRANCH", "PCS分支设备", PCS),
|
||||||
STACK("STACK", "电池堆"),
|
STACK("STACK", "电池堆", null),
|
||||||
CLUSTER("CLUSTER", "电池簇"),
|
CLUSTER("CLUSTER", "电池簇", STACK),
|
||||||
BATTERY("BATTERY", "单体电池"),
|
BATTERY("BATTERY", "单体电池", CLUSTER),
|
||||||
AMMETER("AMMETER", "电表"),
|
AMMETER("AMMETER", "电表", null),
|
||||||
COOLING("COOLING", "冷却"),
|
COOLING("COOLING", "冷却", null),
|
||||||
DH("DH", "动环"),
|
DH("DH", "动环", null),
|
||||||
XF("XF", "消防"),
|
XF("XF", "消防", null),
|
||||||
BATTERY_GROUP("BATTERY_GROUP", "电池组");
|
BATTERY_GROUP("BATTERY_GROUP", "电池组", null),;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
private final String info;
|
private final String info;
|
||||||
|
private final DeviceCategory parentCategory;
|
||||||
|
|
||||||
DeviceCategory(String code, String info)
|
DeviceCategory(String code, String info, DeviceCategory parentCategory)
|
||||||
{
|
{
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
|
this.parentCategory = parentCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode()
|
public String getCode()
|
||||||
@ -40,6 +44,10 @@ public enum DeviceCategory
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DeviceCategory getParentCategory()
|
||||||
|
{
|
||||||
|
return parentCategory;
|
||||||
|
}
|
||||||
// 缓存info与code的映射(优化查询效率)
|
// 缓存info与code的映射(优化查询效率)
|
||||||
private static final Map<String, String> INFO_CODE_MAP = new HashMap<>();
|
private static final Map<String, String> INFO_CODE_MAP = new HashMap<>();
|
||||||
|
|
||||||
@ -54,4 +62,15 @@ public enum DeviceCategory
|
|||||||
public static String getCodeByInfo(String info) {
|
public static String getCodeByInfo(String info) {
|
||||||
return INFO_CODE_MAP.get(info); // 从缓存中直接获取,效率高
|
return INFO_CODE_MAP.get(info); // 从缓存中直接获取,效率高
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 通过code获取父类code
|
||||||
|
// 根据字符串编码查找对应的枚举
|
||||||
|
public static DeviceCategory fromCode(String code) {
|
||||||
|
for (DeviceCategory category : values()) {
|
||||||
|
if (category.code.equalsIgnoreCase(code)) { // 忽略大小写,增强兼容性
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,4 +28,6 @@ public interface IEmsSiteService
|
|||||||
public List<SiteDeviceListVo> getAllDeviceList(String siteId);
|
public List<SiteDeviceListVo> getAllDeviceList(String siteId);
|
||||||
|
|
||||||
public List<Map<String,Object>> getAllPcsInfo(String siteId);
|
public List<Map<String,Object>> getAllPcsInfo(String siteId);
|
||||||
|
|
||||||
|
public List<Map<String,Object>> getParentCategoryDeviceId(String siteId, String deviceCategory);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,4 +106,16 @@ public class EmsSiteServiceImpl implements IEmsSiteService
|
|||||||
public List<Map<String, Object>> getAllPcsInfo(String siteId) {
|
public List<Map<String, Object>> getAllPcsInfo(String siteId) {
|
||||||
return emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.PCS.getCode());
|
return emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.PCS.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据设备类别获取父类的设备id
|
||||||
|
@Override
|
||||||
|
public List<Map<String,Object>> getParentCategoryDeviceId(String siteId, String deviceCategory) {
|
||||||
|
DeviceCategory category = DeviceCategory.fromCode(deviceCategory);
|
||||||
|
if(category == null || category.getParentCategory() == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String parentCategory = category.getParentCategory().getCode();
|
||||||
|
List<Map<String,Object>> deviceIdList = emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, parentCategory);
|
||||||
|
return deviceIdList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user