|
|
|
@ -9,6 +9,7 @@ import com.hnac.hzims.common.logs.enums.BusinessType;
|
|
|
|
|
import com.hnac.hzims.common.logs.enums.OperatorType; |
|
|
|
|
import com.hnac.hzims.equipment.dto.DeviceTreeDTO; |
|
|
|
|
import com.hnac.hzims.equipment.entity.EmInfoEntity; |
|
|
|
|
import com.hnac.hzims.equipment.entity.EmTreeEntity; |
|
|
|
|
import com.hnac.hzims.equipment.service.IEmInfoService; |
|
|
|
|
import com.hnac.hzims.equipment.vo.EmInfoAddVo; |
|
|
|
|
import com.hnac.hzims.equipment.vo.EmInfoContentVO; |
|
|
|
@ -35,6 +36,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设备控制器 |
|
|
|
@ -176,6 +178,51 @@ public class EmInfoController extends BladeController {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取所有设备列表(树结构) |
|
|
|
|
* @param refDept 站点机构 |
|
|
|
|
* @param name 设备名称 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@ApiLog |
|
|
|
|
@RequestMapping(value = "/getEmInfoTreeList") |
|
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
|
@ApiOperation(value = "获取所有设备列表(树结构)", notes = "传入设备id") |
|
|
|
|
public R<List<EmInfoEntity>> getEmInfoTreeList(Long refDept, String name) { |
|
|
|
|
List<EmInfoEntity> resultList = new ArrayList<>(); |
|
|
|
|
LambdaQueryWrapper<EmInfoEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
if (Func.isNotEmpty(refDept)) { |
|
|
|
|
wrapper.eq(EmInfoEntity::getDepartment, refDept); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(name)) { |
|
|
|
|
wrapper.like(EmInfoEntity::getName, name); |
|
|
|
|
} |
|
|
|
|
List<EmInfoEntity> list = em_infoService.list(wrapper); |
|
|
|
|
if (Func.isNotEmpty(name)) { |
|
|
|
|
for (EmInfoEntity emInfo : list) { |
|
|
|
|
LambdaQueryWrapper<EmInfoEntity> sonWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
sonWrapper.likeRight(EmInfoEntity::getPath, emInfo.getPath()); |
|
|
|
|
List<EmInfoEntity> sonList = em_infoService.list(sonWrapper); |
|
|
|
|
// 把List结构数据转换成树结构
|
|
|
|
|
Map<Long, List<EmInfoEntity>> emInfoMap = sonList.stream().collect(Collectors.groupingBy(EmInfoEntity::getGpid)); |
|
|
|
|
sonList.forEach(emTree -> { |
|
|
|
|
emTree.setInfoChildren(emInfoMap.get(emTree.getId())); |
|
|
|
|
}); |
|
|
|
|
sonList = sonList.stream().filter(item -> item.getGpid().equals(emInfo.getGpid())).collect(Collectors.toList()); |
|
|
|
|
resultList.addAll(sonList); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 把List结构数据转换成树结构
|
|
|
|
|
Map<Long, List<EmInfoEntity>> emInfoMap = list.stream().collect(Collectors.groupingBy(EmInfoEntity::getGpid)); |
|
|
|
|
list.forEach(emTree -> { |
|
|
|
|
emTree.setInfoChildren(emInfoMap.get(emTree.getId())); |
|
|
|
|
}); |
|
|
|
|
resultList = list.stream().filter(item -> item.getGpid().equals(0L)).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return R.data(resultList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 新增 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/save") |
|
|
|
|