|
@@ -1,218 +0,0 @@
|
|
|
-package com.persagy.proxy.adm.service.impl;
|
|
|
-
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
-import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
-import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
-import com.persagy.proxy.adm.constant.AdmDictConstant;
|
|
|
-import com.persagy.proxy.adm.constant.enums.AdmDictCategoryEnum;
|
|
|
-import com.persagy.proxy.adm.model.*;
|
|
|
-import com.persagy.proxy.adm.request.AdmCreateRequest;
|
|
|
-import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
-import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
-import com.persagy.proxy.adm.service.IAdmBuildingService;
|
|
|
-import com.persagy.proxy.adm.service.IAdmDictService;
|
|
|
-import com.persagy.proxy.adm.service.IAdmEquipmentService;
|
|
|
-import com.persagy.proxy.adm.service.IAdmLabslService;
|
|
|
-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.stereotype.Service;
|
|
|
-
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * @ClassName AdmLabslServiceImpl
|
|
|
- * @Description: 蜡笔森林定制接口
|
|
|
- * @Author linhuili
|
|
|
- * @Date 2021/9/17 20:01
|
|
|
- * @Version V1.0
|
|
|
- **/
|
|
|
-@Service
|
|
|
-@Slf4j
|
|
|
-public class AdmLabslServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> implements IAdmLabslService<T> {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IAdmBuildingService buildingService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IAdmEquipmentService equipmentService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询项目下的设备类型
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @Override
|
|
|
- public AdmResponse queryCategory(InstanceUrlParam context , Class<T> clazz) throws Exception {
|
|
|
-
|
|
|
- List<AdmObjectInfo> result = new ArrayList<>();
|
|
|
- QueryCriteria criteria = new QueryCriteria();
|
|
|
- ObjectNode node = JsonNodeFactory.instance.objectNode();
|
|
|
- //查询所有的专业
|
|
|
- node.put("type",AdmDictCategoryEnum.MAJOR.getValue());
|
|
|
- criteria.setCriteria(node);
|
|
|
- AdmResponse majorResonse = doQueryDictData(context, criteria, clazz);
|
|
|
-
|
|
|
- if(CollUtil.isNotEmpty(majorResonse.getContent())){
|
|
|
- List<AdmObjectInfo> content = (List<AdmObjectInfo>) majorResonse.getContent();
|
|
|
- result.addAll(content);
|
|
|
- }
|
|
|
-
|
|
|
- //查询所有的系统,设备类
|
|
|
- List<String> objTypes = new ArrayList<>();
|
|
|
- objTypes.add(AdmDictCategoryEnum.SYSTEM.getValue());
|
|
|
- objTypes.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
|
|
|
- node.put("objType",objTypes.toString());
|
|
|
- criteria.setCriteria(node);
|
|
|
- AdmResponse equipResponse = doQueryObjectType(context, criteria, clazz);
|
|
|
-
|
|
|
- if(CollUtil.isNotEmpty(equipResponse.getContent())){
|
|
|
- List<AdmObjectInfo> content = (List<AdmObjectInfo>) equipResponse.getContent();
|
|
|
- result.addAll(content);
|
|
|
- }
|
|
|
- return AdmResponse.success(result);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询项目下的空间类型
|
|
|
- * @param context
|
|
|
- * @param clazz
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @Override
|
|
|
- public AdmResponse queryZoneType(InstanceUrlParam context, Class<T> clazz) throws Exception {
|
|
|
- QueryCriteria criteria = new QueryCriteria();
|
|
|
- ObjectNode node = JsonNodeFactory.instance.objectNode();
|
|
|
-
|
|
|
- //查询所有的空间类型
|
|
|
- List<String> objTypes = new ArrayList<>();
|
|
|
- objTypes.add(AdmDictCategoryEnum.SPACE.getValue());
|
|
|
- node.put("objType",objTypes.toString());
|
|
|
- criteria.setCriteria(node);
|
|
|
- AdmResponse response = doQueryObjectType(context, criteria, clazz);
|
|
|
-
|
|
|
- List<AdmObjectInfo> content = (List<AdmObjectInfo>) response.getContent();
|
|
|
- return AdmResponse.success(content);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询项目下的建筑楼层
|
|
|
- * @param context
|
|
|
- * @param clazz
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @Override
|
|
|
- public AdmResponse queryBuildFloor(InstanceUrlParam context, Class<T> clazz) throws Exception {
|
|
|
- List<AdmBuilding> admBuildings = new ArrayList<>();
|
|
|
- //添加未明确建筑
|
|
|
- AdmBuilding admBuilding = new AdmBuilding();
|
|
|
- admBuilding.setId("fisnull");
|
|
|
- admBuilding.setName("未明确建筑");
|
|
|
- admBuilding.setLocalName("未明确建筑");
|
|
|
-
|
|
|
- //添加未明确楼层
|
|
|
- ArrayList<AdmFloor> admFloors = new ArrayList<>();
|
|
|
- AdmFloor admFloor = new AdmFloor();
|
|
|
- admFloor.setId("fisnull");
|
|
|
- admFloor.setName("未明确楼层");
|
|
|
- admFloor.setLocalName("未明确楼层");
|
|
|
- admFloors.add(admFloor);
|
|
|
-
|
|
|
- //获取项目下的建筑,建筑下的楼层
|
|
|
- AdmQueryCriteria request = new AdmQueryCriteria();
|
|
|
- request.setName(AdmBuilding.OBJ_TYPE);
|
|
|
-
|
|
|
- //设置建筑->楼层级联查询参数
|
|
|
- AdmQueryCriteria cascade = new AdmQueryCriteria();
|
|
|
- cascade.setName(AdmFloor.OBJ_TYPE);
|
|
|
- List<AdmQueryCriteria> cascadeList = new ArrayList<>();
|
|
|
- cascadeList.add(cascade);
|
|
|
- request.setCascade(cascadeList);
|
|
|
-
|
|
|
- AdmResponse buildResponse = buildingService.doQuery(context, request, AdmBuilding.class);
|
|
|
- if(CollUtil.isEmpty(buildResponse.getContent())){
|
|
|
- admBuildings.add(admBuilding);
|
|
|
- return AdmResponse.success((List<JSONObject>)admBuilding);
|
|
|
- }
|
|
|
-
|
|
|
- //建筑下的楼层添加默认"未明确楼层"
|
|
|
- List<AdmBuilding> buildContent = (List<AdmBuilding>)buildResponse.getContent();
|
|
|
- buildContent.add(admBuilding);
|
|
|
- for (AdmBuilding building : buildContent) {
|
|
|
- List<AdmFloor> floor = building.getFloor();
|
|
|
- floor.add(admFloor);
|
|
|
- }
|
|
|
- return AdmResponse.success(buildContent);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据设备id统计设备所属的专业
|
|
|
- * @param context
|
|
|
- * @param ids
|
|
|
- * @param clazz
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @Override
|
|
|
- public AdmResponse queryMajorCategory(InstanceUrlParam context, List<String> ids, Class<T> clazz) throws Exception {
|
|
|
-
|
|
|
- //根据id查询对应的设备类型
|
|
|
- AdmQueryCriteria request = new AdmQueryCriteria();
|
|
|
- request.setName(AdmEquipment.OBJ_TYPE);
|
|
|
- request.setFilters("id in " + ids);
|
|
|
- AdmResponse equipResponse = equipmentService.doQuery(context, request, AdmEquipment.class);
|
|
|
- if(CollUtil.isEmpty(equipResponse.getContent())){
|
|
|
- throw new Exception("设备不存在");
|
|
|
- }
|
|
|
- List<AdmEquipment> equipments = (List<AdmEquipment>)equipResponse.getContent();
|
|
|
- Set<String> classCodes = equipments.stream().map(k -> k.getClassCode()).collect(Collectors.toSet());
|
|
|
-
|
|
|
- //根据设备类型查询设备所属专业
|
|
|
- QueryCriteria dictCriteria = new QueryCriteria();
|
|
|
- ObjectNode node = JsonNodeFactory.instance.objectNode();
|
|
|
- node.put("code",classCodes.toString());
|
|
|
- dictCriteria.setCriteria(node);
|
|
|
- AdmResponse dictResponse = doQueryObjectType(context, dictCriteria, clazz);
|
|
|
- if(CollUtil.isEmpty(dictResponse.getContent())){
|
|
|
- throw new Exception("项目下没有设备类型");
|
|
|
- }
|
|
|
-
|
|
|
- //获取设备类对应的专业编码
|
|
|
- List<AdmObjectType> classCodeList = (List<AdmObjectType>)dictResponse.getContent();
|
|
|
- Map<String, List<AdmObjectType>> classCodeMap = classCodeList.stream().collect(Collectors.groupingBy(k->k.getMajorCode()));
|
|
|
-
|
|
|
- Set<String> majors = classCodeList.stream().map(k -> k.getMajorCode()).collect(Collectors.toSet());
|
|
|
- if(CollUtil.isEmpty(majors)){
|
|
|
- return AdmResponse.success(new ArrayList<>());
|
|
|
- }
|
|
|
-
|
|
|
- //查询字典中的专业
|
|
|
- QueryCriteria criteria = new QueryCriteria();
|
|
|
- ObjectNode majorNode = JsonNodeFactory.instance.objectNode();
|
|
|
- majorNode.put("type",AdmDictCategoryEnum.MAJOR.getValue());
|
|
|
- criteria.setCriteria(majorNode);
|
|
|
- AdmResponse majorResonse = doQueryDictData(context, criteria, clazz);
|
|
|
- List<AdmObjectType> dictMajorList = (List<AdmObjectType>)majorResonse.getContent();
|
|
|
- Map<String, List<AdmObjectType>> dictMajorMap = dictMajorList.stream().collect(Collectors.groupingBy(k->k.getCode()));
|
|
|
-
|
|
|
- List<AdmObjectType> result = new ArrayList<>();
|
|
|
- //组装成专业-设备类返回结果
|
|
|
- for (String major : majors) {
|
|
|
- List<AdmObjectType> objectTypes = dictMajorMap.get(major);
|
|
|
- if(CollUtil.isNotEmpty(objectTypes)){
|
|
|
- AdmObjectType objectType = objectTypes.get(0);
|
|
|
- objectType.setChildren(classCodeMap.get(major));
|
|
|
- result.add(objectType);
|
|
|
- }
|
|
|
- }
|
|
|
- return AdmResponse.success(result);
|
|
|
- }
|
|
|
-
|
|
|
-}
|