...
|
...
|
@@ -13,6 +13,7 @@ import com.monitor.cmdb.service.IMObjectInfoService; |
|
|
import com.monitor.cmdb.service.ITypeInfoService;
|
|
|
import com.monitor.model.domain.MObjectHostInfoModel;
|
|
|
import com.monitor.model.domain.MObjectModel;
|
|
|
import com.monitor.model.domain.PageBean;
|
|
|
import com.monitor.model.page.PageResponse;
|
|
|
import com.monitor.model.request.DependencyRequest;
|
|
|
import com.monitor.model.request.HostInfoReq;
|
...
|
...
|
@@ -28,6 +29,7 @@ import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.xml.ws.Response;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -160,36 +162,41 @@ public class MObjectInfoCtrl { |
|
|
|
|
|
|
|
|
public BaseResponse queryMObjectByType(MObjectInfoReq request) {
|
|
|
|
|
|
DEBUG.debug("Query mobjects by typeIds: {}", request.getTypeIds());
|
|
|
|
|
|
List<MObjectInfo> moListByType = new ArrayList<>();
|
|
|
|
|
|
BaseResponse response = null;
|
|
|
|
|
|
String[] typeIds = StringUtils.split(request.getTypeIds(), SPLITOP);
|
|
|
|
|
|
try {
|
|
|
for (String typeId : typeIds) {
|
|
|
|
|
|
if (StringUtils.isNotBlank(typeId)) {
|
|
|
|
|
|
moListByType.addAll(mobjectService.queryMObjectsInfoByType(Integer.parseInt(typeId)));
|
|
|
}
|
|
|
}
|
|
|
if (null != moListByType) {
|
|
|
|
|
|
response = buildPageResponse(request, buildMObjectModelList(moListByType));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
DEBUG.error("Failed to query mobjects by typeIds: {} , eror: {} ", request.getTypeIds(), e);
|
|
|
|
|
|
response = new BaseResponse(400, e.getMessage());
|
|
|
BaseResponse response = new BaseResponse();
|
|
|
DEBUG.info("Query mobjects ,typeIds is {} , and searchHostIps is {}", request.getTypeIds(), request.getHostIps());
|
|
|
//设置分页查询参数
|
|
|
PageBean pageBean = PageBean.initPageInfo(request.getCurrentPage(),request.getPageSize(),null);
|
|
|
//设置查询参数 --typeIds and hostIds
|
|
|
String typeIdsStr = request.getTypeIds();
|
|
|
String hostIdsStr = request.getSearchHostIps();
|
|
|
Map<String,Object> paramMap = new HashMap<>();
|
|
|
if(StringUtils.isNotBlank(typeIdsStr) && !StringUtils.equals("0",typeIdsStr)){
|
|
|
List<String> typeIdList = Arrays.asList(StringUtils.split(typeIdsStr, ","));
|
|
|
paramMap.put("typeIdList", typeIdList);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(hostIdsStr)){
|
|
|
List<String> hostIpList = Arrays.asList(StringUtils.split(hostIdsStr, ","));
|
|
|
paramMap.put("hostIpList" ,hostIpList);
|
|
|
}
|
|
|
pageBean.setParams(paramMap);
|
|
|
try{
|
|
|
int totalCount = mobjectService.countByCondition(pageBean);
|
|
|
List<MObjectInfo> moListByType = mobjectService.selectPageByCondition(pageBean);
|
|
|
List<MObjectModel> resultList = buildMObjectModelList(moListByType);
|
|
|
PageResponse pageResponse = new PageResponse();
|
|
|
pageResponse.setCurrentPage(request.getCurrentPage());
|
|
|
pageResponse.setPageSize(request.getPageSize());
|
|
|
pageResponse.setTotal(totalCount);
|
|
|
pageResponse.setRows(resultList);
|
|
|
response.setData(pageResponse);
|
|
|
response.setCode(200);
|
|
|
return response;
|
|
|
}catch (Exception e){
|
|
|
DEBUG.error("Query mobjects ,typeIds is {} , and searchHostIps is {}", request.getTypeIds(), request.getHostIps());
|
|
|
response.setCode(200);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|