|
@@ -12,6 +12,7 @@ import com.ruoyi.ems.domain.AreaBuildingZoning;
|
|
import com.ruoyi.ems.domain.EmsDevice;
|
|
import com.ruoyi.ems.domain.EmsDevice;
|
|
import com.ruoyi.ems.domain.common.AreaTier;
|
|
import com.ruoyi.ems.domain.common.AreaTier;
|
|
import com.ruoyi.ems.domain.vo.QueryDevice;
|
|
import com.ruoyi.ems.domain.vo.QueryDevice;
|
|
|
|
+import com.ruoyi.ems.domain.vo.TreeEntity;
|
|
import com.ruoyi.ems.service.IAreaBuildingService;
|
|
import com.ruoyi.ems.service.IAreaBuildingService;
|
|
import com.ruoyi.ems.service.IAreaBuildingZoningService;
|
|
import com.ruoyi.ems.service.IAreaBuildingZoningService;
|
|
import com.ruoyi.ems.service.IEmsDeviceService;
|
|
import com.ruoyi.ems.service.IEmsDeviceService;
|
|
@@ -25,6 +26,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -34,14 +36,13 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 能源设备Controller
|
|
* 能源设备Controller
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @author ruoyi
|
|
* @author ruoyi
|
|
* @date 2024-07-10
|
|
* @date 2024-07-10
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/device")
|
|
@RequestMapping("/device")
|
|
-public class DeviceController extends BaseController
|
|
|
|
-{
|
|
|
|
|
|
+public class DeviceController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private IEmsDeviceService deviceService;
|
|
private IEmsDeviceService deviceService;
|
|
|
|
|
|
@@ -56,56 +57,43 @@ public class DeviceController extends BaseController
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:device:list")
|
|
@RequiresPermissions("ems:device:list")
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
- public TableDataInfo list(EmsDevice emsDevice)
|
|
|
|
- {
|
|
|
|
|
|
+ public TableDataInfo list(EmsDevice emsDevice) {
|
|
startPage();
|
|
startPage();
|
|
List<EmsDevice> list = deviceService.selectEmsDeviceList(emsDevice);
|
|
List<EmsDevice> list = deviceService.selectEmsDeviceList(emsDevice);
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询能源设备列表
|
|
|
|
|
|
+ * 递归查询 区域/建筑/区块 下的设备(分页)
|
|
*/
|
|
*/
|
|
- //@RequiresPermissions("basecfg:device:list")
|
|
|
|
- @GetMapping("/listByAreaTree")
|
|
|
|
- public TableDataInfo listByAreaTree(QueryDevice queryDevice)
|
|
|
|
- {
|
|
|
|
- // 层级为区域,需要查询下级建筑,以及建筑下级区块
|
|
|
|
|
|
+ @RequiresPermissions("basecfg:device:list")
|
|
|
|
+ @GetMapping("/listRecursionByArea")
|
|
|
|
+ public TableDataInfo listRecursionByArea(QueryDevice queryDevice) {
|
|
|
|
+ // 层级为区域 (建筑->区块)
|
|
if (StringUtils.equals(queryDevice.getAreaType(), AreaTier.Area.name()) && StringUtils.isNotBlank(
|
|
if (StringUtils.equals(queryDevice.getAreaType(), AreaTier.Area.name()) && StringUtils.isNotBlank(
|
|
queryDevice.getRefArea())) {
|
|
queryDevice.getRefArea())) {
|
|
- AreaBuilding param = new AreaBuilding();
|
|
|
|
- param.setAreaCode(queryDevice.getRefArea());
|
|
|
|
- List<AreaBuilding> buildings = buildingService.selectAreaBuildingList(param);
|
|
|
|
|
|
+ List<AreaBuilding> buildings = buildingService.selectBuildingByAreaCode(queryDevice.getRefArea());
|
|
List<String> buildingCodes = buildings.stream().map(AreaBuilding::getBldgCode).collect(Collectors.toList());
|
|
List<String> buildingCodes = buildings.stream().map(AreaBuilding::getBldgCode).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(buildings)) {
|
|
if (CollectionUtils.isNotEmpty(buildings)) {
|
|
|
|
+ // 回填建筑codes
|
|
queryDevice.setBuildingCodes(buildingCodes);
|
|
queryDevice.setBuildingCodes(buildingCodes);
|
|
- List<String> zoningCodes = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- for (String buildCode : buildingCodes) {
|
|
|
|
- AreaBuildingZoning zParam = new AreaBuildingZoning();
|
|
|
|
- zParam.setBldgCode(buildCode);
|
|
|
|
- List<AreaBuildingZoning> list = zoningService.selectAreaBuildingZoningList(zParam);
|
|
|
|
- zoningCodes.addAll(
|
|
|
|
- list.stream().map(AreaBuildingZoning::getZoningCode).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (CollectionUtils.isNotEmpty(zoningCodes)) {
|
|
|
|
- queryDevice.setZoningCodes(zoningCodes);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ List<AreaBuildingZoning> zonings = zoningService.selectZoningByBuildings(buildingCodes);
|
|
|
|
+ List<String> zoningCodes = zonings.stream().map(AreaBuildingZoning::getZoningCode)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ // 回填区块codes
|
|
|
|
+ queryDevice.setZoningCodes(CollectionUtils.isNotEmpty(zoningCodes) ? zoningCodes : null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 层级为建筑 (区块)
|
|
else if (StringUtils.equals(queryDevice.getAreaType(), AreaTier.Building.name()) && StringUtils.isNotBlank(
|
|
else if (StringUtils.equals(queryDevice.getAreaType(), AreaTier.Building.name()) && StringUtils.isNotBlank(
|
|
queryDevice.getRefArea())) {
|
|
queryDevice.getRefArea())) {
|
|
- AreaBuildingZoning zParam = new AreaBuildingZoning();
|
|
|
|
- zParam.setBldgCode(queryDevice.getRefArea());
|
|
|
|
- List<AreaBuildingZoning> list = zoningService.selectAreaBuildingZoningList(zParam);
|
|
|
|
|
|
+ List<AreaBuildingZoning> list = zoningService.selectZoningByBuilding(queryDevice.getRefArea());
|
|
List<String> zoningCodes = list.stream().map(AreaBuildingZoning::getZoningCode)
|
|
List<String> zoningCodes = list.stream().map(AreaBuildingZoning::getZoningCode)
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
-
|
|
|
|
- if (CollectionUtils.isNotEmpty(zoningCodes)) {
|
|
|
|
- queryDevice.setZoningCodes(zoningCodes);
|
|
|
|
- }
|
|
|
|
|
|
+ // 回填区块codes
|
|
|
|
+ queryDevice.setZoningCodes(CollectionUtils.isNotEmpty(zoningCodes) ? zoningCodes : null);
|
|
}
|
|
}
|
|
|
|
|
|
startPage();
|
|
startPage();
|
|
@@ -114,13 +102,23 @@ public class DeviceController extends BaseController
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 根据设施获取设备树结构
|
|
|
|
+ * @param areaCode 区域code
|
|
|
|
+ * @return 树结构
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("basecfg:device:list")
|
|
|
|
+ @GetMapping("/getTreeByFacs")
|
|
|
|
+ public AjaxResult getTreeByFacs(@RequestParam(value = "areaCode", required = false) String areaCode) {
|
|
|
|
+ return success(deviceService.getTreeByFacs(null));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 导出能源设备列表
|
|
* 导出能源设备列表
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:device:export")
|
|
@RequiresPermissions("ems:device:export")
|
|
@Log(title = "能源设备", businessType = BusinessType.EXPORT)
|
|
@Log(title = "能源设备", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
@PostMapping("/export")
|
|
- public void export(HttpServletResponse response, EmsDevice emsDevice)
|
|
|
|
- {
|
|
|
|
|
|
+ public void export(HttpServletResponse response, EmsDevice emsDevice) {
|
|
List<EmsDevice> list = deviceService.selectEmsDeviceList(emsDevice);
|
|
List<EmsDevice> list = deviceService.selectEmsDeviceList(emsDevice);
|
|
ExcelUtil<EmsDevice> util = new ExcelUtil<EmsDevice>(EmsDevice.class);
|
|
ExcelUtil<EmsDevice> util = new ExcelUtil<EmsDevice>(EmsDevice.class);
|
|
util.exportExcel(response, list, "能源设备数据");
|
|
util.exportExcel(response, list, "能源设备数据");
|
|
@@ -131,8 +129,7 @@ public class DeviceController extends BaseController
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:device:query")
|
|
@RequiresPermissions("ems:device:query")
|
|
@GetMapping(value = "/{id}")
|
|
@GetMapping(value = "/{id}")
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
return success(deviceService.selectEmsDeviceById(id));
|
|
return success(deviceService.selectEmsDeviceById(id));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -142,8 +139,7 @@ public class DeviceController extends BaseController
|
|
@RequiresPermissions("ems:device:add")
|
|
@RequiresPermissions("ems:device:add")
|
|
@Log(title = "能源设备", businessType = BusinessType.INSERT)
|
|
@Log(title = "能源设备", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
@PostMapping
|
|
- public AjaxResult add(@RequestBody EmsDevice emsDevice)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody EmsDevice emsDevice) {
|
|
return toAjax(deviceService.insertEmsDevice(emsDevice));
|
|
return toAjax(deviceService.insertEmsDevice(emsDevice));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -153,8 +149,7 @@ public class DeviceController extends BaseController
|
|
@RequiresPermissions("ems:device:edit")
|
|
@RequiresPermissions("ems:device:edit")
|
|
@Log(title = "能源设备", businessType = BusinessType.UPDATE)
|
|
@Log(title = "能源设备", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
@PutMapping
|
|
- public AjaxResult edit(@RequestBody EmsDevice emsDevice)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult edit(@RequestBody EmsDevice emsDevice) {
|
|
return toAjax(deviceService.updateEmsDevice(emsDevice));
|
|
return toAjax(deviceService.updateEmsDevice(emsDevice));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -163,9 +158,8 @@ public class DeviceController extends BaseController
|
|
*/
|
|
*/
|
|
@RequiresPermissions("ems:device:remove")
|
|
@RequiresPermissions("ems:device:remove")
|
|
@Log(title = "能源设备", businessType = BusinessType.DELETE)
|
|
@Log(title = "能源设备", businessType = BusinessType.DELETE)
|
|
- @DeleteMapping("/{ids}")
|
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
- {
|
|
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
return toAjax(deviceService.deleteEmsDeviceByIds(ids));
|
|
return toAjax(deviceService.deleteEmsDeviceByIds(ids));
|
|
}
|
|
}
|
|
}
|
|
}
|