| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * 指标信息Controller |
| | | * |
| | | * @author fanxinfu |
| | | * @date 2020-02-14 |
| | | * 指标信息控制器 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/basicsetting/energyindex") |
| | |
| | | private IEnergyIndexService energyIndexService; |
| | | |
| | | /** |
| | | * 查询指标信息列表 |
| | | * 分页查询指标信息 |
| | | * @param energyIndex 查询条件 |
| | | * @param pageNum 当前页码 |
| | | * @param pageSize 页面大小 |
| | | * @return 分页数据 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('energyindex:energyindex:query')") |
| | | @GetMapping("/list") |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询指标信息列表 |
| | | * 条件查询指标信息(不带分页) |
| | | * @param query 查询条件 |
| | | * @return 指标列表 |
| | | */ |
| | | @GetMapping("/filter") |
| | | public AjaxResult filter(EnergyIndexQuery query) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询指标信息列表 |
| | | * 查询采集指标列表(用于设备关联) |
| | | * @param deviceId 设备ID |
| | | * @return 分页数据 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('energyindex:energyindex:query')") |
| | | @GetMapping("/collectIndex") |
| | |
| | | @Log(title = "指标信息", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{indexIds}") |
| | | public AjaxResult remove(@PathVariable String[] indexIds) { |
| | | // 步骤1: 参数校验 |
| | | if (ObjectUtils.isEmpty(indexIds)) return AjaxResult.success(); |
| | | |
| | | List<String> indexIdList = Arrays.asList(indexIds); |
| | | if (ObjectUtils.isEmpty(indexIdList)) { |
| | | return AjaxResult.success(); |
| | | } |
| | | // 查询模型节点点位信息 |
| | | // 步骤2: 检查是否被模型关联 |
| | | List<ModelNodeIndexInfo> modelNodeIndexInfoList = energyIndexService.getModelNodeIndexInfoListByIndexIds(indexIds); |
| | | if (ObjectUtils.isNotEmpty(modelNodeIndexInfoList)) { |
| | | ModelNodeIndexInfo modelNodeIndexInfo = modelNodeIndexInfoList.stream().findFirst().get(); |
| | | return AjaxResult.error("采集指标 " + modelNodeIndexInfo.getIndexName() + " 已被模型 " + modelNodeIndexInfo.getModelName() + " 关联,不能删除!"); |
| | | if (!modelNodeIndexInfoList.isEmpty()) { |
| | | // 存在关联关系返回错误 |
| | | ModelNodeIndexInfo firstItem = modelNodeIndexInfoList.get(0); |
| | | return AjaxResult.error("指标 " + firstItem.getIndexName() + " 已被模型 " + firstItem.getModelName() + " 关联,不能删除!"); |
| | | } |
| | | |
| | | energyIndexService.removeEnergyIndex(indexIdList); |
| | | |
| | | // 步骤3: 执行删除 |
| | | energyIndexService.removeEnergyIndex(Arrays.asList(indexIds)); |
| | | return AjaxResult.success(); |
| | | } |
| | | |