BaseDataController.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.usky.cdi.controller;
  2. import com.usky.cdi.service.impl.BaseDataTransferService;
  3. import com.usky.cdi.service.vo.info.EngineeringBaseVO;
  4. import com.usky.cdi.service.vo.info.FacilityDeviceVO;
  5. import com.usky.cdi.service.vo.info.FloorPlaneVO;
  6. import com.usky.cdi.service.vo.info.ProtectiveUnitVO;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  10. import org.springframework.web.bind.annotation.*;
  11. import java.util.List;
  12. import java.util.Map;
  13. /**
  14. * 基础类数据传输控制器
  15. * 提供基础类数据上报的接口
  16. *
  17. * @author han
  18. * @date 2025/03/20
  19. */
  20. @Slf4j
  21. @RestController
  22. @RequestMapping("/api/base")
  23. @ConditionalOnProperty(prefix = "mqtt", value = {"enabled"}, havingValue = "true")
  24. public class BaseDataController {
  25. @Autowired
  26. private BaseDataTransferService baseDataTransferService;
  27. /**
  28. * 上报人防工程基础信息
  29. */
  30. @PostMapping("/engineering")
  31. public String sendEngineeringBase(@RequestBody EngineeringBaseVO vo) {
  32. boolean success = baseDataTransferService.sendEngineeringBase(vo);
  33. return success ? "上报成功" : "上报失败";
  34. }
  35. /**
  36. * 上报防护单元基础信息
  37. */
  38. @PostMapping("/protectiveUnit")
  39. public String sendProtectiveUnit(@RequestBody ProtectiveUnitVO vo) {
  40. boolean success = baseDataTransferService.sendProtectiveUnit(vo);
  41. return success ? "上报成功" : "上报失败";
  42. }
  43. /**
  44. * 批量上报防护单元基础信息
  45. */
  46. @PostMapping("/protectiveUnits")
  47. public String batchSendProtectiveUnits(@RequestBody List<ProtectiveUnitVO> units) {
  48. int successCount = baseDataTransferService.batchSendProtectiveUnits(units);
  49. return String.format("上报成功 %d/%d", successCount, units.size());
  50. }
  51. /**
  52. * 上报楼层平面图信息
  53. */
  54. @PostMapping("/floorPlane")
  55. public String sendFloorPlane(@RequestBody FloorPlaneVO vo) {
  56. boolean success = baseDataTransferService.sendFloorPlane(vo);
  57. return success ? "上报成功" : "上报失败";
  58. }
  59. /**
  60. * 上报智能监管物联设施信息
  61. */
  62. @PostMapping("/sensorInfo")
  63. public String sendSensorInfo(@RequestBody FacilityDeviceVO vo) {
  64. boolean success = baseDataTransferService.sendSensorInfo(vo);
  65. return success ? "上报成功" : "上报失败";
  66. }
  67. /**
  68. * 批量上报智能监管物联设施信息
  69. */
  70. @GetMapping("/sensorInfos")
  71. public String batchSendSensorInfos(@RequestParam(value = "tenantId",required = false) Integer tenantId) {
  72. Map<String, Integer> map = baseDataTransferService.batchSendSensorInfos(tenantId);
  73. return String.format("上报成功 %d", map.get("success"));
  74. }
  75. }