CommonController.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.zoniot.ccrc.controller.common;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.zoniot.ccrc.commom.model.AjaxMessage;
  4. import com.zoniot.ccrc.commom.model.ResultStatus;
  5. import com.zoniot.ccrc.commom.utils.TreeUtil;
  6. import com.zoniot.ccrc.dao.AreaMapper;
  7. import com.zoniot.ccrc.dto.AreaDto;
  8. import com.zoniot.ccrc.dto.DeviceMeasuringPointDto;
  9. import com.zoniot.ccrc.dto.DeviceTypeDto;
  10. import com.zoniot.ccrc.dto.TreeDataDto;
  11. import com.zoniot.ccrc.service.DeviceTypeService;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import io.swagger.annotations.ApiParam;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.format.annotation.DateTimeFormat;
  17. import org.springframework.stereotype.Controller;
  18. import org.springframework.web.bind.annotation.GetMapping;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestParam;
  21. import org.springframework.web.bind.annotation.ResponseBody;
  22. import java.time.LocalDateTime;
  23. import java.util.List;
  24. @Controller
  25. @ResponseBody
  26. @RequestMapping("common")
  27. @Api(tags = "公共模块")
  28. public class CommonController {
  29. @Autowired
  30. private DeviceTypeService deviceTypeService;
  31. @Autowired
  32. private AreaMapper areaMapper;
  33. @GetMapping("/getDeviceTypeList")
  34. @ApiOperation(value = "获取系列(设备类型)列表")
  35. public AjaxMessage<List<DeviceTypeDto>> getDeviceTypeList(
  36. @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
  37. @ApiParam(value = "设备类型 1:传感器 2;网关设备 3:集中器 4:采集器", required = false) @RequestParam(required = false) Integer type
  38. ) {
  39. List<DeviceTypeDto> list = deviceTypeService.getDeviceTypeList(sysId, type);
  40. return new AjaxMessage<>(ResultStatus.OK, list);
  41. }
  42. @GetMapping("/getTreeData")
  43. @ApiOperation(value = "获取厂商/系列/型号树形数据")
  44. public AjaxMessage<List<TreeDataDto>> getTreeData(
  45. @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
  46. @ApiParam(value = "类型 1:传感器 2;网关设备 3:集中器 4:采集器", required = false) @RequestParam(required = false) Integer type
  47. ) {
  48. List<TreeDataDto> list = deviceTypeService.getTreeData(sysId, type);
  49. return new AjaxMessage<>(ResultStatus.OK, list);
  50. }
  51. @GetMapping("/getAllArea")
  52. @ApiOperation(value = "获取所有的省市区")
  53. public AjaxMessage<List<AreaDto>> getAllArea(
  54. ) {
  55. List<AreaDto> list = areaMapper.getAllArea();
  56. return new AjaxMessage<>(ResultStatus.OK, TreeUtil.getArea(list, 100000, 1));
  57. }
  58. }