AdmEquipmentController.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package com.persagy.proxy.adm.controller;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.persagy.proxy.adm.model.AdmEquipment;
  5. import com.persagy.proxy.adm.request.AdmCreateRequest;
  6. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  7. import com.persagy.proxy.adm.request.AdmResponse;
  8. import com.persagy.proxy.adm.service.IAdmEquipmentService;
  9. import com.persagy.proxy.adm.utils.AdmContextUtil;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.List;
  13. /**
  14. * Adm 楼层 API
  15. * @author lvxy
  16. * @date 2021/8/16
  17. */
  18. @RestController
  19. @RequestMapping("/object/equip")
  20. public class AdmEquipmentController {
  21. @Autowired
  22. private IAdmEquipmentService service;
  23. /**
  24. * 统计
  25. *
  26. * @param request
  27. * @return
  28. * @throws Exception
  29. */
  30. @PostMapping("/count")
  31. public AdmResponse count(
  32. @RequestBody AdmQueryCriteria request) throws Exception {
  33. request.setName(AdmEquipment.OBJ_TYPE);
  34. request.setOnlyCount(true);
  35. return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
  36. }
  37. /**
  38. * 创建
  39. * @param createRequest
  40. * @return
  41. * @throws Exception
  42. */
  43. @PostMapping("/create")
  44. public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
  45. List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
  46. vos = service.doInsertEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
  47. return AdmResponse.success(vos);
  48. }
  49. /**
  50. * 根据ID删除
  51. * @param vos
  52. * @return
  53. * @throws Exception
  54. */
  55. @PostMapping("/delete")
  56. public AdmResponse delete( @RequestBody List<AdmEquipment> vos) throws Exception {
  57. // 组装上下文条件
  58. service.doDelete(AdmContextUtil.toDmpContext(), vos);
  59. return AdmResponse.success();
  60. }
  61. /**
  62. * 更新
  63. * @param createRequest
  64. * @return
  65. * @throws Exception
  66. */
  67. @PostMapping("/update")
  68. public AdmResponse update(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
  69. List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
  70. //vos = service.doUpdateEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
  71. vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
  72. return AdmResponse.success(vos);
  73. }
  74. /**
  75. * 查询
  76. *
  77. * @param request
  78. * @return
  79. * @throws Exception
  80. */
  81. @PostMapping("/query")
  82. public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
  83. // 组装上下文条件
  84. request.setName(AdmEquipment.OBJ_TYPE);
  85. return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
  86. }
  87. /**
  88. * 设备绑定的动态信息点或静态信息点
  89. * @param admEquipment
  90. * @return
  91. * @throws Exception
  92. */
  93. @GetMapping("/export")
  94. public AdmResponse exportInfos(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
  95. List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
  96. vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
  97. return AdmResponse.success(vos);
  98. }
  99. /**
  100. * 设备上传excel识别静态信息点
  101. * @param admEquipment
  102. * @return
  103. * @throws Exception
  104. */
  105. @PostMapping("/import")
  106. public AdmResponse importInfos(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
  107. List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
  108. vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
  109. return AdmResponse.success(vos);
  110. }
  111. /**
  112. * 根据项目id查询所有的设备和部件
  113. *
  114. * @param request
  115. * @return
  116. * @throws Exception
  117. */
  118. @GetMapping("/query-equip")
  119. public AdmResponse queryEquip(
  120. @RequestBody AdmQueryCriteria request) throws Exception {
  121. //request.setName("equipment");
  122. if(StrUtil.isNotEmpty(request.getFilters())){
  123. request.setFilters(String.join(";",request.getFilters(),"objType in ['equipment','component']"));
  124. }else{
  125. request.setFilters("objType in ['equipment','component']");
  126. }
  127. return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
  128. }
  129. /**
  130. * 批量创建设备同时创建资产、创建设备和系统的关系
  131. * @param admEquipment
  132. * @return
  133. * @throws Exception
  134. */
  135. @PostMapping("/creat-equip-pro")
  136. public AdmResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
  137. List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
  138. vos = service.doInsertExt(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
  139. return AdmResponse.success(vos);
  140. }
  141. }