AdmDictController.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. package com.persagy.proxy.adm.controller;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.persagy.dmp.define.entity.ObjectInfoCollect;
  4. import com.persagy.proxy.adm.constant.AdmDictConstant;
  5. import com.persagy.proxy.adm.constant.enums.AdmDictCategoryEnum;
  6. import com.persagy.proxy.adm.model.*;
  7. import com.persagy.proxy.adm.request.AdmCreateRequest;
  8. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  9. import com.persagy.proxy.adm.request.AdmResponse;
  10. import com.persagy.proxy.adm.service.IAdmDictService;
  11. import com.persagy.proxy.adm.utils.AdmContextUtil;
  12. import com.persagy.proxy.common.entity.InstanceUrlParam;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.apache.commons.lang.StringUtils;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. /**
  20. * @ClassName AdmDictController
  21. * @Description: 字典查询
  22. * @Author linhuili
  23. * @Date 2021/8/31 18:21
  24. * @Version V1.0
  25. **/
  26. @RestController
  27. @RequestMapping("/dict")
  28. @Slf4j
  29. public class AdmDictController {
  30. @Autowired
  31. private IAdmDictService service;
  32. /**
  33. * 字典类型查询:所有设备类型、部件类型、系统类型、专业类型
  34. * @param projectId
  35. * @param request
  36. * @return
  37. * @throws Exception
  38. */
  39. @PostMapping("/category")
  40. public AdmResponse queryCategory(@RequestBody AdmDict request) throws Exception {
  41. // 组装上下文条件
  42. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  43. if(StringUtils.isEmpty(request.getType())){
  44. throw new Exception("type不能为空");
  45. }
  46. return service.queryCategory(context,request,AdmObjectType.class);
  47. }
  48. /**
  49. * 批量处理字典信息操作:方案设定(BDTP暂不支持)
  50. * @param projectId
  51. * @param request
  52. * @return
  53. * @throws Exception
  54. */
  55. @PostMapping("/dict-batch")
  56. public AdmResponse dictBatch( @RequestBody AdmCreateRequest<AdmDictBatch> request) throws Exception {
  57. // 组装上下文条件
  58. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  59. //方案设定:方案id :全新设定(schemeZero)、方案1(schemeOne)、方案2(schemeTwo),
  60. //"注意SchemeId为必填字段 ,优先级在列表中[R,S,M] ,一级标签[技术参数,基本参数] 列表为String类型
  61. return AdmResponse.success(new ArrayList<>());
  62. }
  63. /**
  64. * 查询项目下类型的信息点
  65. * @param projectId
  66. * @param request
  67. * @return
  68. * @throws Exception
  69. */
  70. @PostMapping("/query")
  71. public AdmResponse query(@RequestBody AdmDictQueryCriteria request) throws Exception {
  72. // 组装上下文条件
  73. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  74. request.setName(request.getType());
  75. return service.query(context, request, AdmDictConstant.CLASS_CODE, AdmObjectInfo.class);
  76. }
  77. /**
  78. * 查询设备对应的设备族(废弃)
  79. * @param projectId
  80. * @param request
  81. * @return
  82. * @throws Exception
  83. */
  84. @PostMapping("/family/query")
  85. @Deprecated
  86. public AdmResponse familyQuery(@RequestBody AdmQueryCriteria request) throws Exception {
  87. // 组装上下文条件
  88. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  89. return AdmResponse.success(new ArrayList<>());
  90. }
  91. /**
  92. * 重置项目下所有得定制信息点
  93. * @param projectId
  94. * @param request
  95. * @return
  96. * @throws Exception
  97. */
  98. @PostMapping("/reset-dic")
  99. public AdmResponse resetDic(@RequestBody AdmDictQueryCriteria request) throws Exception {
  100. // 组装上下文条件
  101. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  102. return service.resetDic(context,request,null,AdmObjectInfo.class);
  103. }
  104. /**
  105. * 根据类型,项目id重置信息点
  106. * @param projectId
  107. * @param request
  108. * @return
  109. * @throws Exception
  110. */
  111. @PostMapping("/reset-type")
  112. public AdmResponse resetType(@RequestBody AdmDictQueryCriteria request) throws Exception {
  113. // 组装上下文条件
  114. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  115. if(StringUtils.isEmpty(request.getType())){
  116. throw new Exception("type不能为空");
  117. }
  118. request.setName(request.getType());
  119. return service.resetDic(context,request,AdmDictConstant.CLASS_CODE,AdmObjectInfo.class);
  120. }
  121. /**
  122. * 设置-项目定制化字典
  123. * @param projectId
  124. * @param request
  125. * @return
  126. * @throws Exception
  127. */
  128. @PostMapping("/setting-dic-project")
  129. public AdmResponse settingDicProject(@RequestBody AdmCreateRequest<AdmDefFuncIdGather> request) throws Exception {
  130. // 组装上下文条件
  131. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  132. return service.settingDicProject(context,request, ObjectInfoCollect.class);
  133. }
  134. /**
  135. * 查询项目下已有的设备类型带系统
  136. * @param projectId
  137. * @param request
  138. * @return
  139. * @throws Exception
  140. */
  141. @PostMapping("/system/equip/category")
  142. @Deprecated
  143. public AdmResponse querySystemEquipCategory(@RequestBody AdmDict request) throws Exception {
  144. // 组装上下文条件
  145. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  146. request.setType(AdmDictCategoryEnum.SYSTEM_EQUIP.getValue());
  147. return service.queryCategory(context,request,AdmObjectType.class);
  148. }
  149. /**
  150. * 查询类型下所有字典信息 M 和 L 类型,包括自定义信息点
  151. * @param projectId
  152. * @param dictTypeList
  153. * @return
  154. * @throws Exception
  155. */
  156. @PostMapping("/morl/query")
  157. @Deprecated
  158. public AdmResponse queryMorlDict(@RequestBody List<String> dictTypeList) throws Exception {
  159. // 组装上下文条件
  160. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  161. if(CollUtil.isEmpty(dictTypeList)){
  162. return AdmResponse.success(new ArrayList<>());
  163. }
  164. //查询指定类型下的信息点
  165. return service.queryMorlDict(context,dictTypeList);
  166. }
  167. /**
  168. * 获取不能同步到物理世界对象的数量
  169. * @param request
  170. * @return
  171. * @throws Exception
  172. */
  173. @PostMapping("/data-count")
  174. @Deprecated
  175. public AdmResponse queryNotSyncDmpObjects(@RequestBody AdmDictQueryCriteria request) throws Exception {
  176. return AdmResponse.success(new ArrayList<>());
  177. }
  178. /**
  179. * 需采集信息同步到所有项目
  180. * @return
  181. * @throws Exception
  182. */
  183. @GetMapping("/syn-dic-project")
  184. @Deprecated
  185. public AdmResponse syncProjectObjectInfo() throws Exception {
  186. return AdmResponse.success(new ArrayList<>());
  187. }
  188. }