|
@@ -1,13 +1,18 @@
|
|
|
package com.persagy.proxy.dictionary.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
+import com.persagy.proxy.object.model.AdmEquipment;
|
|
|
import com.persagy.proxy.object.model.AdmObjectInfo;
|
|
|
import com.persagy.proxy.dictionary.model.AdmObjectType;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
+import com.persagy.proxy.object.service.IAdmEquipmentService;
|
|
|
import com.persagy.proxy.report.service.IAdmLabslService;
|
|
|
import com.persagy.proxy.adm.utils.AdmContextUtil;
|
|
|
import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -16,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -36,7 +42,10 @@ public class AdmLabslController {
|
|
|
private IAdmLabslService service;
|
|
|
|
|
|
@Value("${middleware.group.code}")
|
|
|
- private String groupCode;
|
|
|
+ private String groupCode ="XG";
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAdmEquipmentService iAdmEquipmentService;
|
|
|
|
|
|
/**
|
|
|
* 查询项目下的设备类型
|
|
@@ -46,6 +55,9 @@ public class AdmLabslController {
|
|
|
@PostMapping("/category")
|
|
|
public AdmResponse queryCategory() throws Exception {
|
|
|
InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
+ if(StringUtils.isEmpty(context.getGroupCode())){
|
|
|
+ context.setGroupCode(groupCode);
|
|
|
+ }
|
|
|
return service.queryCategory(context, AdmObjectInfo.class);
|
|
|
}
|
|
|
|
|
@@ -58,6 +70,9 @@ public class AdmLabslController {
|
|
|
@PostMapping("/zone/type")
|
|
|
public AdmResponse queryZoneType() throws Exception {
|
|
|
InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
+ if(StringUtils.isEmpty(context.getGroupCode())){
|
|
|
+ context.setGroupCode(groupCode);
|
|
|
+ }
|
|
|
return service.queryZoneType(context, AdmObjectInfo.class);
|
|
|
}
|
|
|
|
|
@@ -69,21 +84,59 @@ public class AdmLabslController {
|
|
|
@PostMapping("/building/floor")
|
|
|
public AdmResponse queryBuildFloor(@QueryParam("projectId") String projectId) throws Exception {
|
|
|
InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
+ if(StringUtils.isEmpty(context.getGroupCode())){
|
|
|
+ context.setGroupCode(groupCode);
|
|
|
+ }
|
|
|
return service.queryBuildFloor(context, AdmObjectInfo.class);
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /* *//**
|
|
|
+ * 查询设备包含设备类型
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ *//*
|
|
|
+ @PostMapping("/query/equip")
|
|
|
+ public AdmResponse queryEquipType(@QueryParam("projectId") AdmQueryCriteria request) throws Exception {
|
|
|
+ InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
+ return iAdmEquipmentService.doQuery(context, AdmObjectInfo.class);
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询设备包含设备类型
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/query/equip")
|
|
|
- public AdmResponse queryEquipType(@QueryParam("projectId") String projectId) throws Exception {
|
|
|
+ public AdmResponse queryEquipType(@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
- return service.queryBuildFloor(context, AdmObjectInfo.class);
|
|
|
- }
|
|
|
+ if(StringUtils.isEmpty(context.getGroupCode())){
|
|
|
+ context.setGroupCode(groupCode);
|
|
|
+ }
|
|
|
+ // 组装上下文条件
|
|
|
+ request.setName(AdmEquipment.OBJ_TYPE);
|
|
|
+ //过滤条件处理
|
|
|
+ String filters = request.getFilters();
|
|
|
|
|
|
+ StringBuilder newFilters = new StringBuilder();
|
|
|
+ if(StringUtils.isNotEmpty(filters)){
|
|
|
+ String[] filter = filters.split(";");
|
|
|
+ for(int i =0 ;i< filter.length;i++){
|
|
|
+ if(filter[i].contains("not")){
|
|
|
+ String[] param = filter[i].split(" ");
|
|
|
+ filter[i] = StrUtil.format("{} $notcontains {}",param[1],param[3]);
|
|
|
+ }
|
|
|
+ newFilters.append(filter[i]);
|
|
|
+ if(i != filter.length -1){
|
|
|
+ newFilters.append(" ; ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ request.setFilters(newFilters.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return iAdmEquipmentService.doQuery(context, request, AdmEquipment.class);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 根据设备id统计设备所属的专业
|
|
@@ -94,12 +147,15 @@ public class AdmLabslController {
|
|
|
public AdmResponse queryMajorCategory(@QueryParam("projectId") String projectId,
|
|
|
@RequestBody List<String> ids) throws Exception {
|
|
|
InstanceUrlParam context = AdmContextUtil.toDmpContext();
|
|
|
+ if(StringUtils.isEmpty(context.getGroupCode())){
|
|
|
+ context.setGroupCode(groupCode);
|
|
|
+ }
|
|
|
if(CollUtil.isEmpty(ids)){
|
|
|
- return AdmResponse.failure("项目下没有设备类型");
|
|
|
+ return AdmResponse.success(new ArrayList<>());
|
|
|
}
|
|
|
- List<String> newIds = ids.stream().filter(id->"fisnull".equals(id)).collect(Collectors.toList());
|
|
|
+ List<String> newIds = ids.stream().filter(id->!"fisnull".equals(id)).collect(Collectors.toList());
|
|
|
if(CollUtil.isEmpty(newIds)){
|
|
|
- return AdmResponse.failure("项目下没有设备类型");
|
|
|
+ return AdmResponse.success(new ArrayList<>());
|
|
|
}
|
|
|
return service.queryMajorCategory(context, newIds , AdmObjectType.class);
|
|
|
}
|