elber пре 2 година
комит
0a9939dc2f
100 измењених фајлова са 5873 додато и 0 уклоњено
  1. 10 0
      .gitignore
  2. 34 0
      docs/.gitignore
  3. 34 0
      docs/database/.gitignore
  4. 34 0
      docs/other/.gitignore
  5. 34 0
      docs/prototype/.gitignore
  6. 0 0
      sources/.gitignore
  7. 0 0
      sources/client/.gitignore
  8. 0 0
      sources/datasource/.gitignore
  9. 0 0
      sources/server/.gitignore
  10. 134 0
      sources/server/airconditioner-system/pom.xml
  11. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/AirconditionerSystemApplication.java
  12. 133 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Alarm.java
  13. 147 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Company.java
  14. 68 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Device.java
  15. 245 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/DeviceData.java
  16. 161 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/FacilityAlarm.java
  17. 42 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Gateway.java
  18. 101 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Log.java
  19. 26 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/OperationType.java
  20. 58 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Operator.java
  21. 80 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Permission.java
  22. 119 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Project.java
  23. 83 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Role.java
  24. 78 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/RolePermission.java
  25. 46 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Tree.java
  26. 135 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/User.java
  27. 19 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/dto/RolePermissionDTO.java
  28. 52 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/mqtt/MqttCallback.java
  29. 53 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/mqtt/MqttProducer.java
  30. 70 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/ssh/SSHConnection.java
  31. 26 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/CrosConfig.java
  32. 32 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/LocalDateTimeSerializerConfig.java
  33. 108 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/MqttConfig.java
  34. 76 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/MqttInboundConfig.java
  35. 74 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/MqttOutboundConfig.java
  36. 23 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/MyBatisPlusConfig.java
  37. 21 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/WebConfig.java
  38. 95 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/AdminController.java
  39. 165 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/AlarmController.java
  40. 122 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/ClientController.java
  41. 30 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/DeviceController.java
  42. 304 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/FacilityController.java
  43. 211 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/FacilityMobileController.java
  44. 124 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/GatewayController.java
  45. 42 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/LogController.java
  46. 110 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/LoginController.java
  47. 59 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/MqttController.java
  48. 148 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/OperatorController.java
  49. 25 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/OrderController.java
  50. 116 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/PermissionController.java
  51. 134 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/ProjectController.java
  52. 229 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/RoleController.java
  53. 102 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/RolePermissionController.java
  54. 91 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/UserController.java
  55. 109 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/WebController.java
  56. 47 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/enums/AlarmStatusEnum.java
  57. 35 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/enums/CompanyTypeEnum.java
  58. 26 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/interceptor/LoginInterceptor.java
  59. 57 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/interceptor/SSHListener.java
  60. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/AlarmMapper.java
  61. 28 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/CompanyMapper.java
  62. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/DeviceDataMapper.java
  63. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/DeviceMapper.java
  64. 23 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/FacilityAlarmMapper.java
  65. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/GatewayMapper.java
  66. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/LogMapper.java
  67. 16 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/OperatorMapper.java
  68. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/PermissionMapper.java
  69. 20 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/ProjectMapper.java
  70. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/RoleMapper.java
  71. 18 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/RolePermissionMapper.java
  72. 35 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/UserMapper.java
  73. 72 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/result/Result.java
  74. 13 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/AlarmService.java
  75. 56 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/CompanyService.java
  76. 13 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/DeviceDataService.java
  77. 13 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/DeviceService.java
  78. 17 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/FacilityAlarmService.java
  79. 13 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/GatewayService.java
  80. 13 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/LogService.java
  81. 19 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/MqttService.java
  82. 24 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/OperatorService.java
  83. 13 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/PermissionService.java
  84. 16 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/ProjectService.java
  85. 13 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/RolePermissionService.java
  86. 20 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/RoleService.java
  87. 29 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/UserService.java
  88. 22 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/AlarmServiceImpl.java
  89. 52 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/CompanyServiceImpl.java
  90. 22 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/DeviceDataServiceImpl.java
  91. 22 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/DeviceServiceImpl.java
  92. 29 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/FacilityAlarmServiceImpl.java
  93. 22 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/GatewayServiceImpl.java
  94. 22 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/LogServiceImpl.java
  95. 182 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/MqttServiceImpl.java
  96. 60 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/OperatorServiceImpl.java
  97. 22 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/PermissionServiceImpl.java
  98. 31 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/ProjectServiceImpl.java
  99. 22 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/RolePermissionServiceImpl.java
  100. 0 0
      sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/RoleServiceImpl.java

+ 10 - 0
.gitignore

@@ -0,0 +1,10 @@
+*.iml
+.idea
+target
+*.apk
+*.log
+*.ipa
+.DS_Store
+unpackage/dist
+unpackage/resources
+unpackage/debug

+ 34 - 0
docs/.gitignore

@@ -0,0 +1,34 @@
+/sources/server/tourism-drp/.idea
+*.iml
+.idea
+/sources/server/fdeer-impress/*.iml
+qd-auth-cache
+/sources/server/fdeer-impress/mobile-cache
+/sources/server/fdeer-impress/admin-cache
+/sources/server/fdeer-impress/fdeer-impress-admin/target
+/sources/server/fdeer-impress/fdeer-impress-admin/fdeer-impress-admin.iml
+/sources/server/fdeer-impress/fdeer-impress-core-api/target
+/sources/server/fdeer-impress/fdeer-impress-core-service/target
+/sources/server/fdeer-impress/fdeer-impress-image-tools/target
+/sources/server/fdeer-impress/fdeer-impress-core-restful/target
+/sources/server/fdeer-impress/fdeer-impress-mobile/target
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_calib3d341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_core341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_dnn341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_features2d341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_flann341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_highgui341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_imgcodecs341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_imgproc341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_ml341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_objdetect341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_photo341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_shape341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_stitching341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_superres341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_video341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_videoio341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_videostab341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/opencv_ffmpeg341_64.dll
+/sources/server/fdeer-impress/fdeer-impress-produce/target
+/sources/server/fdeer-impress/temp

+ 34 - 0
docs/database/.gitignore

@@ -0,0 +1,34 @@
+/sources/server/tourism-drp/.idea
+*.iml
+.idea
+/sources/server/fdeer-impress/*.iml
+qd-auth-cache
+/sources/server/fdeer-impress/mobile-cache
+/sources/server/fdeer-impress/admin-cache
+/sources/server/fdeer-impress/fdeer-impress-admin/target
+/sources/server/fdeer-impress/fdeer-impress-admin/fdeer-impress-admin.iml
+/sources/server/fdeer-impress/fdeer-impress-core-api/target
+/sources/server/fdeer-impress/fdeer-impress-core-service/target
+/sources/server/fdeer-impress/fdeer-impress-image-tools/target
+/sources/server/fdeer-impress/fdeer-impress-core-restful/target
+/sources/server/fdeer-impress/fdeer-impress-mobile/target
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_calib3d341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_core341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_dnn341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_features2d341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_flann341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_highgui341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_imgcodecs341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_imgproc341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_ml341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_objdetect341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_photo341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_shape341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_stitching341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_superres341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_video341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_videoio341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_videostab341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/opencv_ffmpeg341_64.dll
+/sources/server/fdeer-impress/fdeer-impress-produce/target
+/sources/server/fdeer-impress/temp

+ 34 - 0
docs/other/.gitignore

@@ -0,0 +1,34 @@
+/sources/server/tourism-drp/.idea
+*.iml
+.idea
+/sources/server/fdeer-impress/*.iml
+qd-auth-cache
+/sources/server/fdeer-impress/mobile-cache
+/sources/server/fdeer-impress/admin-cache
+/sources/server/fdeer-impress/fdeer-impress-admin/target
+/sources/server/fdeer-impress/fdeer-impress-admin/fdeer-impress-admin.iml
+/sources/server/fdeer-impress/fdeer-impress-core-api/target
+/sources/server/fdeer-impress/fdeer-impress-core-service/target
+/sources/server/fdeer-impress/fdeer-impress-image-tools/target
+/sources/server/fdeer-impress/fdeer-impress-core-restful/target
+/sources/server/fdeer-impress/fdeer-impress-mobile/target
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_calib3d341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_core341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_dnn341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_features2d341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_flann341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_highgui341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_imgcodecs341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_imgproc341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_ml341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_objdetect341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_photo341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_shape341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_stitching341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_superres341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_video341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_videoio341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_videostab341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/opencv_ffmpeg341_64.dll
+/sources/server/fdeer-impress/fdeer-impress-produce/target
+/sources/server/fdeer-impress/temp

+ 34 - 0
docs/prototype/.gitignore

@@ -0,0 +1,34 @@
+/sources/server/tourism-drp/.idea
+*.iml
+.idea
+/sources/server/fdeer-impress/*.iml
+qd-auth-cache
+/sources/server/fdeer-impress/mobile-cache
+/sources/server/fdeer-impress/admin-cache
+/sources/server/fdeer-impress/fdeer-impress-admin/target
+/sources/server/fdeer-impress/fdeer-impress-admin/fdeer-impress-admin.iml
+/sources/server/fdeer-impress/fdeer-impress-core-api/target
+/sources/server/fdeer-impress/fdeer-impress-core-service/target
+/sources/server/fdeer-impress/fdeer-impress-image-tools/target
+/sources/server/fdeer-impress/fdeer-impress-core-restful/target
+/sources/server/fdeer-impress/fdeer-impress-mobile/target
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_calib3d341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_core341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_dnn341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_features2d341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_flann341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_highgui341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_imgcodecs341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_imgproc341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_ml341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_objdetect341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_photo341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_shape341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_stitching341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_superres341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_video341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_videoio341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/libopencv_videostab341.dll
+/sources/server/fdeer-impress/fdeer-impress-image-tools/src/main/resources/win32-x86-64/opencv_ffmpeg341_64.dll
+/sources/server/fdeer-impress/fdeer-impress-produce/target
+/sources/server/fdeer-impress/temp

+ 0 - 0
sources/.gitignore


+ 0 - 0
sources/client/.gitignore


+ 0 - 0
sources/datasource/.gitignore


+ 0 - 0
sources/server/.gitignore


+ 134 - 0
sources/server/airconditioner-system/pom.xml

@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.6.5</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.yzt</groupId>
+    <artifactId>airconditioner-system</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>airconditioner-system</name>
+    <description>airconditioner-system</description>
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>5.1.47</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+            <version>1.4.2</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.mybatis</groupId>
+                    <artifactId>mybatis-spring</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.mybatis</groupId>
+                    <artifactId>mybatis</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>2.17.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-tomcat</artifactId>
+        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.eclipse.paho</groupId>-->
+<!--            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>-->
+<!--            <version>1.2.5</version>-->
+<!--        </dependency>-->
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-mqtt</artifactId>
+            <version>5.5.11</version>
+        </dependency>
+        <!--mqtt 相关依赖-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-integration</artifactId>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.integration</groupId>-->
+<!--            <artifactId>spring-integration-stream</artifactId>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.integration</groupId>-->
+<!--            <artifactId>spring-integration-mqtt</artifactId>-->
+<!--        </dependency>-->
+        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.6</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.jcraft</groupId>
+            <artifactId>jsch</artifactId>
+            <version>0.1.55</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.rakugakibox.spring.boot</groupId>
+            <artifactId>orika-spring-boot-starter</artifactId>
+            <version>1.9.0</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/AirconditionerSystemApplication.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+@SpringBootApplication
+@MapperScan("com.yzt.airconditionersystem.mapper")
+public class AirconditionerSystemApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(AirconditionerSystemApplication.class, args);
+//        new SpringApplicationBuilder(MqttConfig.class).web(WebApplicationType.NONE).run(args);
+    }
+
+}

+ 133 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Alarm.java

@@ -0,0 +1,133 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.yzt.airconditionersystem.enums.AlarmStatusEnum;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 
+ * @TableName alarm
+ */
+@TableName(value ="alarm")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Alarm implements Serializable {
+    /**
+     * 自增id
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 客户名称
+     */
+    @TableField(value = "client_name")
+    private String clientName;
+
+    /**
+     * 所属运营商id
+     */
+    @TableField(value = "operator_id")
+    private Integer operatorId;
+
+    /**
+     * 所属运营商名称
+     */
+    @TableField(value = "operator_name")
+    private String operatorName;
+
+    /**
+     * 地区
+     */
+    private String district;
+
+    /**
+     * 报警类型
+     */
+    private String type;
+
+    /**
+     * 报警时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime time;
+
+    /**
+     * 状态,0-未处理,1-已处理
+     */
+    @TableField
+    private AlarmStatusEnum status;
+
+    @TableField(exist = false)
+    private FacilityAlarm facilityAlarm;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Alarm other = (Alarm) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getClientName() == null ? other.getClientName() == null : this.getClientName().equals(other.getClientName()))
+            && (this.getOperatorId() == null ? other.getOperatorId() == null : this.getOperatorId().equals(other.getOperatorId()))
+            && (this.getOperatorName() == null ? other.getOperatorName() == null : this.getOperatorName().equals(other.getOperatorName()))
+            && (this.getDistrict() == null ? other.getDistrict() == null : this.getDistrict().equals(other.getDistrict()))
+            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
+            && (this.getTime() == null ? other.getTime() == null : this.getTime().equals(other.getTime()))
+            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getClientName() == null) ? 0 : getClientName().hashCode());
+        result = prime * result + ((getOperatorId() == null) ? 0 : getOperatorId().hashCode());
+        result = prime * result + ((getOperatorName() == null) ? 0 : getOperatorName().hashCode());
+        result = prime * result + ((getDistrict() == null) ? 0 : getDistrict().hashCode());
+        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
+        result = prime * result + ((getTime() == null) ? 0 : getTime().hashCode());
+        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", clientName=").append(clientName);
+        sb.append(", operatorId=").append(operatorId);
+        sb.append(", operatorName=").append(operatorName);
+        sb.append(", district=").append(district);
+        sb.append(", type=").append(type);
+        sb.append(", time=").append(time);
+        sb.append(", status=").append(status);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 147 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Company.java

@@ -0,0 +1,147 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 
+ * @TableName company
+ */
+@TableName(value ="company")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Company implements Serializable {
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 所属运营商id,若公司为运营商,此值为0
+     */
+    @TableField(value = "operator_id")
+    private String operatorId;
+
+    /**
+     * 公司名称
+     */
+    private String name;
+
+    /**
+     * 用户名
+     */
+    private String username;
+
+    /**
+     * 地区
+     */
+    private String district;
+
+    /**
+     * 具体地址
+     */
+    @TableField(value = "detailed_address")
+    private String detailedAddress;
+
+    /**
+     * 联系人
+     */
+    private String contact;
+
+    /**
+     * 联系电话
+     */
+    private String phone;
+
+    /**
+     * 公司类型 1-总部,2-运营商,3-普通客户
+     */
+    private Integer type;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 运营商名称
+     */
+    @TableField(exist = false)
+    private String operatorName;
+
+    @TableField(exist = false)
+    public Company operator;
+
+    public Company(String id, String operatorId, String name, String username, String district, String detailedAddress, String contact, String phone, Integer type) {
+        this.id = id;
+        this.operatorId = operatorId;
+        this.name = name;
+        this.username = username;
+        this.district = district;
+        this.detailedAddress = detailedAddress;
+        this.contact = contact;
+        this.phone = phone;
+        this.type = type;
+    }
+
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Company other = (Company) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
+            && (this.getDistrict() == null ? other.getDistrict() == null : this.getDistrict().equals(other.getDistrict()))
+            && (this.getDetailedAddress() == null ? other.getDetailedAddress() == null : this.getDetailedAddress().equals(other.getDetailedAddress()))
+            && (this.getContact() == null ? other.getContact() == null : this.getContact().equals(other.getContact()))
+            && (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone()))
+            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        result = prime * result + ((getDistrict() == null) ? 0 : getDistrict().hashCode());
+        result = prime * result + ((getDetailedAddress() == null) ? 0 : getDetailedAddress().hashCode());
+        result = prime * result + ((getContact() == null) ? 0 : getContact().hashCode());
+        result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode());
+        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", name=").append(name);
+        sb.append(", district=").append(district);
+        sb.append(", detailedAddress=").append(detailedAddress);
+        sb.append(", contact=").append(contact);
+        sb.append(", phone=").append(phone);
+        sb.append(", type=").append(type);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 68 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Device.java

@@ -0,0 +1,68 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+/**
+ * 
+ * @TableName device
+ */
+@TableName(value ="device")
+@Data
+public class Device implements Serializable {
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 公司名称
+     */
+    @TableField(value = "company_name")
+    private String companyName;
+
+    /**
+     * 网关设备id
+     */
+    @TableField(value = "gateway_id")
+    private String gatewayId;
+
+    /**
+     * 空调名称+从机id,即CK-1_slave1,设备名_从机站号
+     */
+    @TableField(value = "device_id")
+    private String deviceId;
+
+    /**
+     * plc设备的通信状态(zlan网关这里默认为1,云垦科技网关0为未连接通讯,1为连接通讯)
+     */
+    @TableField(value = "device_state")
+    private Integer deviceState;
+
+    /**
+     * 变量前缀
+     */
+    @TableField(value = "prefix")
+    private String prefix;
+
+    /**
+     * 时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime time;
+
+    @TableField(exist = false)
+    private DeviceData deviceData;
+
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 245 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/DeviceData.java

@@ -0,0 +1,245 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+/**
+ * 
+ * @TableName device_data
+ */
+@TableName(value ="device_data")
+@Data
+public class DeviceData implements Serializable {
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 设备主键id(非设备的id)
+     */
+    @TableField(value = "d_id")
+    private String dId;
+
+    /**
+     * 温度,单位℃
+     */
+    private Double Temp_read;
+
+    /**
+     * 湿度,单位%
+     */
+    private Double Humi_read;
+
+    /**
+     * 温度设定值,单位℃
+     */
+    private Double Temp_set;
+
+    /**
+     * 湿度设定值,单位%
+     */
+    private Double Humi_set;
+
+    /**
+     * 温度精度范围,单位℃
+     */
+    private Double Temp_accu;
+
+    /**
+     * 湿度精度范围,单位%
+     */
+    private Double Humi_accu;
+
+    /**
+     * 制冷回路增益
+     */
+    private Double refrigeration_P;
+
+    /**
+     * 制冷积分时间
+     */
+    private Double refrigeration_I;
+
+    /**
+     * 除湿回路增益
+     */
+    private Double dehumidification_P;
+
+    /**
+     * 除湿积分时间
+     */
+    private Double dehumidification_I;
+
+    /**
+     * 加热回路增益
+     */
+    private Double heater_P;
+
+    /**
+     * 加热积分时间
+     */
+    private Double heater_I;
+
+    /**
+     * 加湿回路增益
+     */
+    private Double humidification_P;
+
+    /**
+     * 加湿积分时间
+     */
+    private Double humidification_I;
+
+    /**
+     * 热水阀(开合度)手动设定值,范围0-100,单位%
+     */
+    private Double hot_water_valve_set;
+
+    /**
+     * 冷水阀(开合度)手动设定值,范围0-100,单位%
+     */
+    private Double cold_water_valve_set;
+
+    /**
+     * 加湿器手动设定值,范围0-100,单位%
+     */
+    private Double humidification_set;
+
+    /**
+     * 冷水阀当前值,范围0-100,单位%
+     */
+    private Double cold_water_valve_value;
+
+    /**
+     * 热水阀当前值,范围0-100,单位%
+     */
+    private Double hot_water_valve_value;
+
+    /**
+     * 电加湿当前值,范围0-100,单位%
+     */
+    private Double humidification_value;
+
+    /**
+     * 含湿量设定值,单位g/kg
+     */
+    private Double Moisture_set;
+
+    /**
+     * 含湿量当前值,单位g/kg
+     */
+    private Double Moisture_value;
+
+    /**
+     * 缺风报警延时时间,单位:秒
+     */
+    private Integer delayed_wind_alarm;
+
+    /**
+     * 机组停止延时时间,单位:秒
+     */
+    private Integer unit_delay_stop;
+
+    /**
+     * 送风机延时启动时间,单位:秒
+     */
+    private Integer blower_delay;
+
+    /**
+     * 排风机延时启动时间,单位:秒
+     */
+    private Integer exhaust_fan_delay;
+
+    /**
+     * 定时开机星期
+     */
+    private Integer open_week;
+
+    /**
+     * 定时开机时
+     */
+    private Integer open_hour;
+
+    /**
+     * 定时开机分
+     */
+    private Integer open_min;
+
+    /**
+     * 定时开机秒
+     */
+    private Integer open_sec;
+
+    /**
+     * 定时关机星期
+     */
+    private Integer stop_week;
+
+    /**
+     * 定时关机时
+     */
+    private Integer stop_hour;
+
+    /**
+     * 定时关机分
+     */
+    private Integer stop_min;
+
+    /**
+     * 定时关机秒
+     */
+    private Integer stop_sec;
+
+    /**
+     * 
+     */
+    private Integer M_bit1;
+
+    /**
+     * 
+     */
+    private Integer M_bit2;
+
+    /**
+     * 
+     */
+    private Integer Q_bit3;
+
+    /**
+     * CK2温度数据
+     */
+    private Double Temp;
+
+    /**
+     * CK2湿度数据
+     */
+    private Double Humi;
+
+    @TableField(exist = false)
+    private String M_bit1BinStr;
+
+    @TableField(exist = false)
+    private String M_bit2BinStr;
+
+    @TableField(exist = false)
+    private String Q_bit3BinStr;
+
+    /**
+     * 时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime time;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 161 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/FacilityAlarm.java

@@ -0,0 +1,161 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * 
+ * @TableName facility_alarm
+ */
+@TableName(value ="facility_alarm")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class FacilityAlarm implements Serializable {
+    /**
+     * id
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime time;
+
+    /**
+     * 报警内容
+     */
+    @TableField(value = "alarm_content")
+    private String alarmContent;
+
+    /**
+     * 状态
+     */
+    private String status;
+
+    /**
+     * 网关id
+     */
+    @TableField(value = "gateway_id")
+    private String gatewayId;
+
+    /**
+     * 持续时间
+     */
+    @TableField(value = "lasting_time")
+    private Long lastingTime;
+
+    @TableField(exist = false)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private String startTime;
+
+    @TableField(exist = false)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private String endTime;
+
+    /**
+     * 公司名称
+     */
+    @TableField(exist = false)
+    private String companyName;
+
+    @TableField(exist = false)
+    private String companyId;
+
+    /**
+     * 所属运营商名
+     */
+//    @TableField(exist = false)
+//    private String operatorName;
+
+    /**
+     * 所属运营商id
+     */
+//    @TableField(exist = false)
+//    private String operatorId;
+
+    /**
+     * 地区
+     */
+    @TableField(exist = false)
+    private String district;
+
+    /**
+     * 具体地址
+     */
+    @TableField(exist = false)
+    private String detailedAddress;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    public FacilityAlarm(String id, LocalDateTime time, String alarmContent, String status, String gatewayId, Long lastingTime) {
+        this.id = id;
+        this.time = time;
+        this.alarmContent = alarmContent;
+        this.status = status;
+        this.gatewayId = gatewayId;
+        this.lastingTime = lastingTime;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        FacilityAlarm other = (FacilityAlarm) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getTime() == null ? other.getTime() == null : this.getTime().equals(other.getTime()))
+            && (this.getAlarmContent() == null ? other.getAlarmContent() == null : this.getAlarmContent().equals(other.getAlarmContent()))
+            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
+            && (this.getGatewayId() == null ? other.getGatewayId() == null : this.getGatewayId().equals(other.getGatewayId()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getTime() == null) ? 0 : getTime().hashCode());
+        result = prime * result + ((getAlarmContent() == null) ? 0 : getAlarmContent().hashCode());
+        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
+        result = prime * result + ((getGatewayId() == null) ? 0 : getGatewayId().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", time=").append(time);
+        sb.append(", alarmContent=").append(alarmContent);
+        sb.append(", status=").append(status);
+        sb.append(", gatewayId=").append(gatewayId);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+
+}

+ 42 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Gateway.java

@@ -0,0 +1,42 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import lombok.Data;
+
+/**
+ * 
+ * @TableName gateway
+ */
+@TableName(value ="gateway")
+@Data
+public class Gateway implements Serializable {
+    /**
+     * id
+     */
+    @TableId
+    private String id;
+
+    /**
+     * 公司id
+     */
+    @TableField(value = "company_id")
+    private String companyId;
+
+    /**
+     * 点位名称
+     */
+    private String location;
+
+    /**
+     * 所属公司信息
+     */
+    @TableField(exist = false)
+    private Company company;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 101 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Log.java

@@ -0,0 +1,101 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 
+ * @TableName log
+ */
+@TableName(value ="log")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Log implements Serializable {
+    /**
+     * 自增id
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 操作人id
+     */
+    private String userId;
+
+    /**
+     * 操作内容
+     */
+    private String operateContent;
+
+    /**
+     * 时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime date;
+
+    /**
+     * 操作人
+     */
+    private String username;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Log other = (Log) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
+            && (this.getOperateContent() == null ? other.getOperateContent() == null : this.getOperateContent().equals(other.getOperateContent()))
+            && (this.getDate() == null ? other.getDate() == null : this.getDate().equals(other.getDate()))
+            && (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
+        result = prime * result + ((getOperateContent() == null) ? 0 : getOperateContent().hashCode());
+        result = prime * result + ((getDate() == null) ? 0 : getDate().hashCode());
+        result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", userId=").append(userId);
+        sb.append(", operateContent=").append(operateContent);
+        sb.append(", date=").append(date);
+        sb.append(", username=").append(username);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 26 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/OperationType.java

@@ -0,0 +1,26 @@
+package com.yzt.airconditionersystem.bean;
+
+/**
+ * 与实体操作类型属性关联的枚举
+ * @author TzZach
+ * @since 2022-04-22 22:11
+ */
+public enum OperationType {
+    /**
+     * 操作类型
+     */
+    //新增
+    INSERT,
+    //删除
+    DELETE,
+    //更新
+    UPDATE,
+    //导出
+    EXPORT,
+    //查询
+    SELECT,
+    //登录
+    LOGON,
+    //其他
+    OTHER;
+}

+ 58 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Operator.java

@@ -0,0 +1,58 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 运营商
+ * @author TzZach
+ * @since 2022-04-13 12:00
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Operator {
+
+    /**
+     * 自增id
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 账号
+     */
+    private String username;
+
+    /**
+     * 公司名称
+     */
+    @TableField(value = "company_name")
+    private String companyName;
+
+    /**
+     * 地区
+     */
+    private String district;
+
+    /**
+     * 具体地址
+     */
+    @TableField(value = "detailed_address")
+    private String detailedAddress;
+
+    /**
+     * 联系人
+     */
+    private String contact;
+
+    /**
+     * 联系电话
+     */
+    private String phone;
+
+}

+ 80 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Permission.java

@@ -0,0 +1,80 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.List;
+
+import lombok.Data;
+
+/**
+ * 
+ * @TableName permission
+ */
+@TableName(value ="permission")
+@Data
+public class Permission extends Tree<Permission> implements Serializable {
+    /**
+     * 权限id
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 权限名称
+     */
+    private String name;
+
+    /**
+     * 权限规则
+     */
+    private String rule;
+
+    /**
+     * 父节点id,0代表无父节点
+     */
+    private Integer parentId;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Permission other = (Permission) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", name=").append(name);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 119 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Project.java

@@ -0,0 +1,119 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * 项目类
+ * @author TzZach
+ * @since 2022-04-15 11:58
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Project {
+
+
+    /**
+     * 自增id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 客户名称
+     */
+    @TableField(value = "client_name")
+    private String clientName;
+    /**
+     * 所属运营商id
+     */
+    @TableField(value = "operator_id")
+    private Integer operatorId;
+    /**
+     * 地区
+     */
+    private String district;
+    /**
+     * 具体地址
+     */
+    @TableField(value = "detailed_address")
+    private String detailedAddress;
+
+    @TableField(exist = false)
+    private List<Integer> gatewayId;
+
+    /**
+     * 所属运营商信息
+     */
+    @TableField(exist = false)
+    private Operator operator;
+
+
+    /**
+     * 获取运营商名称
+     * @return
+     */
+    public String getOperatorName() {
+        return operator.getCompanyName();
+    }
+
+    public void setOperatorName(String operatorName) {
+        operator.setCompanyName(operatorName);
+    }
+
+    /**
+     * 获取运营商地区
+     * @return
+     */
+    public String getOperatorDistrict() {
+        return operator.getDistrict();
+    }
+
+    public void setOperatorDistrict(String district) {
+        operator.setDistrict(district);
+    }
+
+    /**
+     * 获取运营商具体地址
+     * @return
+     */
+    public String getOperatorDetailedAddress() {
+        return operator.getDetailedAddress();
+    }
+
+    public void setOperatorDetailedAddress(String detailedAddress) {
+        operator.setDetailedAddress(detailedAddress);
+    }
+
+    /**
+     * 获取运营商联系人
+     * @return
+     */
+    public String getOperatorContact() {
+        return operator.getContact();
+    }
+
+    public void setOperatorContact(String contact) {
+        operator.setContact(contact);
+    }
+
+    /**
+     * 获取运营商联系人联系方式
+     * @return
+     */
+    public String getOperatorPhone() {
+        return operator.getPhone();
+    }
+
+    public void setOperatorPhone(String phone) {
+        operator.setPhone(phone);
+    }
+
+}

+ 83 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Role.java

@@ -0,0 +1,83 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.security.spec.ECField;
+import java.util.List;
+
+import lombok.Data;
+
+/**
+ * 
+ * @TableName role
+ */
+@TableName(value ="role")
+@Data
+public class Role implements Serializable {
+    /**
+     * 角色id
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 角色名称
+     */
+    private String name;
+
+    @TableField(exist = false)
+    private String permissionId;
+
+    @TableField(exist = false)
+    private String permissionName;
+
+    @TableField(exist = false)
+    private List<String> permissionIds;
+
+    @TableField(exist = false)
+    private List<String> permissionNames;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Role other = (Role) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", name=").append(name);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 78 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/RolePermission.java

@@ -0,0 +1,78 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import lombok.Data;
+
+/**
+ * 
+ * @TableName role_permission
+ */
+@TableName(value ="role_permission")
+@Data
+public class RolePermission implements Serializable {
+    /**
+     * 自增id
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 角色id
+     */
+    @TableField(value = "role_id")
+    private Integer roleId;
+
+    /**
+     * 权限id
+     */
+    @TableField(value = "permission_id")
+    private Integer permissionId;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        RolePermission other = (RolePermission) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId()))
+            && (this.getPermissionId() == null ? other.getPermissionId() == null : this.getPermissionId().equals(other.getPermissionId()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode());
+        result = prime * result + ((getPermissionId() == null) ? 0 : getPermissionId().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", roleId=").append(roleId);
+        sb.append(", permissionId=").append(permissionId);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 46 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/Tree.java

@@ -0,0 +1,46 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.sun.org.apache.xpath.internal.operations.Bool;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Layui树组件类
+ * @author TzZach
+ * @since 2022-06-22 22:58
+ */
+@Data
+public class Tree<T> {
+    /**
+     * 无父节点的parentId为0
+     */
+    @TableField(exist = false)
+    public static final Integer NO_PARENT = 0;
+
+    /**
+     * 显示的字
+     */
+    @TableField(exist = false)
+    private String title;
+
+    /**
+     * 是否展开
+     */
+    @TableField(exist = false)
+    private Boolean spread = false;
+
+    /**
+     * 是否被选中
+     */
+    @TableField(exist = false)
+    private Boolean checked;
+
+    /**
+     * 子节点
+     */
+    @TableField(exist = false)
+    private List<T> children;
+
+}

+ 135 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/User.java

@@ -0,0 +1,135 @@
+package com.yzt.airconditionersystem.bean;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 
+ * @TableName user
+ */
+@TableName(value ="user")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class User implements Serializable {
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 用户名
+     */
+    private String username;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 角色id
+     */
+    @TableField(value = "role_id")
+    private Integer roleId;
+
+    /**
+     * 公司id
+     */
+    @TableField(value = "company_id")
+    private String companyId;
+
+    /**
+     * 角色名称
+     */
+    @TableField(exist = false)
+    private String roleName;
+
+    /**
+     * 公司名称
+     */
+    @TableField(exist = false)
+    private String companyName;
+
+    /**
+     * 联系人
+     */
+    @TableField(exist = false)
+    private String contact;
+
+    /**
+     * 联系方式
+     */
+    @TableField(exist = false)
+    private String phone;
+
+    /**
+     * 要修改的新密码
+     */
+    @TableField(exist = false)
+    private String newPassword;
+
+    /**
+     * 地区
+     */
+    @TableField(exist = false)
+    private String district;
+
+    /**
+     * 具体地址
+     */
+    @TableField(exist = false)
+    private String detailedAddress;
+
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    public User(String id, String username, String password, Integer roleId, String companyId) {
+        this.id = id;
+        this.username = username;
+        this.password = password;
+        this.roleId = roleId;
+        this.companyId = companyId;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        User other = (User) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
+            && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
+            && (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId()))
+            && (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
+        result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
+        result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode());
+        result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode());
+        return result;
+    }
+
+}

+ 19 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/dto/RolePermissionDTO.java

@@ -0,0 +1,19 @@
+package com.yzt.airconditionersystem.bean.dto;
+
+import com.yzt.airconditionersystem.bean.Permission;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author TzZach
+ * @since 2022-06-27 11:23
+ */
+@Data
+public class RolePermissionDTO {
+
+    private List<Permission> permissions;
+
+    private Integer roleId;
+
+}

+ 52 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/mqtt/MqttCallback.java

@@ -0,0 +1,52 @@
+//package com.yzt.airconditionersystem.bean.mqtt;
+//
+//import com.yzt.airconditionersystem.service.MqttService;
+//import org.eclipse.paho.client.mqttv3.*;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.stereotype.Component;
+//
+///**
+// * 订阅者
+// * @author TzZach
+// * @since 2022-05-10 22:47
+// */
+//@Component
+//public class MqttCallback implements MqttCallbackExtended {
+//
+//    @Value("${spring.mqtt.consumerTopic}")
+//    private String[] consumerTopics;
+//
+//    @Autowired
+//    private MqttService mqttService;
+//
+//    private MqttClient mqttClient;
+//
+//    @Override
+//    public void connectComplete(boolean b, String s) {
+//        try {
+//            mqttClient.subscribe(consumerTopics);
+//        } catch (MqttException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//    @Override
+//    public void connectionLost(Throwable throwable) {
+//        System.out.println("连接断开");
+//    }
+//
+//    @Override
+//    public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
+//        mqttService.sendToMqtt(topic, mqttMessage);
+//    }
+//
+//    @Override
+//    public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
+//        System.out.println("deliveryComplete------" + iMqttDeliveryToken.isComplete());
+//    }
+//
+//    public void setMqttClient(MqttClient mqttClient) {
+//        this.mqttClient = mqttClient;
+//    }
+//}

+ 53 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/mqtt/MqttProducer.java

@@ -0,0 +1,53 @@
+//package com.yzt.airconditionersystem.bean.mqtt;
+//
+//import org.eclipse.paho.client.mqttv3.MqttClient;
+//import org.eclipse.paho.client.mqttv3.MqttException;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+///**
+// * @author TzZach
+// * @since 2022-05-10 21:19
+// */
+//@Component
+//@ConditionalOnProperty(value = "spring.mqtt.enable", havingValue = "true")
+//public class MqttProducer{
+//
+//    @Value("${spring.mqtt.producerTopic}")
+//    private String producerTopic;
+//
+//    @Value("${spring.mqtt.defaultQos}")
+//    private int defaultProducerQos;
+//
+//    @Value("${spring.mqtt.defaultRetained}")
+//    private boolean defaultRetained;
+//
+//    @Autowired
+//    private MqttClient mqttClient;
+//
+//    public void send(String payload) {
+//        this.send(producerTopic, payload);
+//    }
+//
+//    public void send(String topic, String payload) {
+//        this.send(topic, defaultProducerQos, payload);
+//    }
+//
+//    public void send(String topic, int qos, String payload) {
+//        this.send(topic, qos, defaultRetained, payload);
+//    }
+//
+//    public void send(String topic, int qos, boolean retained, String payload) {
+//        try {
+//            mqttClient.publish(topic, payload.getBytes(), qos, retained);
+//        } catch (MqttException e) {
+//            System.out.println(e.getMessage());
+//        }
+//    }
+//
+//}

+ 70 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/bean/ssh/SSHConnection.java

@@ -0,0 +1,70 @@
+package com.yzt.airconditionersystem.bean.ssh;
+
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.Session;
+
+/**
+ * @author TzZach
+ * @since 2022-05-25 18:23
+ */
+public class SSHConnection {
+
+    /**
+     * 服务器登录名
+     */
+    String user = "acs";
+
+    /**
+     * 登陆密码
+     */
+    String password = "acs123";
+
+    /**
+     * 服务器公网IP
+     */
+    String host = "47.107.255.78";
+    /**
+     * 跳板机ssh开放的接口   默认端口 22
+     */
+    int port = 19903;
+    /**
+     * 这个是本地的端口,很重要!!!选取一个没有占用的port即可
+     */
+    int local_port = 3307;
+    /**
+     * 要访问的mysql所在的host    服务器局域网IP(127.0.0.1也行)
+     */
+    String remote_host = "127.0.0.1";
+    /**
+     * 服务器上数据库端口号
+     */
+    int remote_port = 3306;
+
+    Session session = null;
+    /**
+     *    建立SSH连接
+     */
+    public void SSHConnection() throws Exception{
+        try {
+            JSch jsch = new JSch();
+            session = jsch.getSession(user, host, port);
+            session.setPassword(password);
+            session.setConfig("StrictHostKeyChecking", "no");
+            // 日志打印自己脑补
+            session.connect();
+            session.setPortForwardingL(local_port, remote_host, remote_port);
+        } catch (Exception e) {
+            // do something
+            e.printStackTrace();
+        }
+    }
+    /**
+     *    断开SSH连接
+     */
+    public void closeSSH () throws Exception
+    {
+        this.session.disconnect();
+    }
+
+
+}

+ 26 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/CrosConfig.java

@@ -0,0 +1,26 @@
+package com.yzt.airconditionersystem.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * @author TzZach
+ * @since 2022-05-12 15:37
+ */
+@Configuration
+public class CrosConfig {
+    @Bean
+    public WebMvcConfigurer corsConfigurer() {
+        return new WebMvcConfigurer() {
+            @Override
+            public void addCorsMappings(CorsRegistry registry) {
+                registry.addMapping("/**")
+                        .allowCredentials(false)
+                        .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
+                        .allowedOrigins("*");
+            }
+        };
+    }
+}

+ 32 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/LocalDateTimeSerializerConfig.java

@@ -0,0 +1,32 @@
+package com.yzt.airconditionersystem.config;
+
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * @author TzZach
+ * @since 2022-05-03 18:29
+ */
+@Configuration
+public class LocalDateTimeSerializerConfig {
+
+    @Value("${spring.jackson.date-format:yyyy-MM-dd HH:mm:ss}")
+    private String pattern;
+
+    @Bean
+    public LocalDateTimeSerializer localDateTimeDeserializer() {
+        return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(pattern));
+    }
+
+    @Bean
+    public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
+        return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeDeserializer());
+    }
+
+}

+ 108 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/MqttConfig.java

@@ -0,0 +1,108 @@
+//package com.yzt.airconditionersystem.config;
+//
+//import ch.qos.logback.core.net.server.Client;
+//import com.yzt.airconditionersystem.bean.mqtt.MqttCallback;
+//import org.eclipse.paho.client.mqttv3.MqttClient;
+//import org.eclipse.paho.client.mqttv3.MqttClientPersistence;
+//import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+//import org.eclipse.paho.client.mqttv3.MqttException;
+//import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//
+//import java.util.UUID;
+//
+///**
+// * @author TzZach
+// * @since 2022-05-10 21:10
+// */
+//@Configuration
+//@ConditionalOnProperty(value = "spring.mqtt.enable", havingValue = "true")
+//public class MqttConfig {
+//
+//    @Value("${spring.mqtt.username}")
+//    private String username;
+//
+//    @Value("${spring.mqtt.password}")
+//    private String password;
+//
+//    @Value("${spring.mqtt.url}")
+//    private String url;
+//
+////    @Value("${spring.mqtt.producerClientId}")
+////    private String producerClientId;
+//
+//    /**
+//     * 生产者和消费者是单独连接服务器会使用到一个clientId(客户端id),如果是同一个clientid的话会出现Lost connection: 已断开连接; retrying...
+//     */
+////    @Value("${spring.mqtt.consumerClientId}")
+////    private String consumerClientId;
+//
+////    @Value("${spring.mqtt.clientId}")
+//    private String clientId = UUID.randomUUID().toString().replace("-", "");
+//
+//    /**
+//     * 连接超时
+//     */
+//    @Value("${spring.mqtt.timeout}")
+//    private int timeout;
+//
+//    /**
+//     * 连接超时
+//     */
+//    @Value("${spring.mqtt.keepalive}")
+//    private int keepalive;
+//
+//    /**
+//     *入站通道名(消费者)订阅的bean名称
+//     */
+//    public static final String CHANNEL_NAME_IN = "mqttInboundChannel";
+//
+//    /**
+//     * 出站通道名(生产者)发布的bean名称
+//     */
+//    public static final String CHANNEL_NAME_OUT = "mqttOutboundChannel";
+//
+//
+//    @Autowired
+//    private MqttCallback mqttCallback;
+//
+//    @Bean
+//    public MqttClient mqttClient() {
+//        try {
+//            MqttClientPersistence persistence = mqttClientPersistence();
+//            MqttClient mqttClient = new MqttClient(url, clientId, persistence);
+//
+//            mqttCallback.setMqttClient(mqttClient);
+//            mqttClient.setCallback(mqttCallback);
+//
+//            mqttClient.connect(mqttConnectOptions());
+//
+//            return mqttClient;
+//        } catch (MqttException e) {
+//            e.printStackTrace();
+//            return null;
+//        }
+//    }
+//
+//    @Bean
+//    public MqttConnectOptions mqttConnectOptions() {
+//        MqttConnectOptions options = new MqttConnectOptions();
+//        options.setUserName(username);
+//        options.setPassword(password.toCharArray());
+//        options.setCleanSession(true);
+//        options.setAutomaticReconnect(true);
+//        options.setConnectionTimeout(timeout);
+//        options.setKeepAliveInterval(keepalive);
+//        return options;
+//    }
+//
+//    public MqttClientPersistence mqttClientPersistence() {
+//        return new MemoryPersistence();
+//    }
+//
+//
+//}

+ 76 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/MqttInboundConfig.java

@@ -0,0 +1,76 @@
+package com.yzt.airconditionersystem.config;
+
+import com.yzt.airconditionersystem.service.MqttService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.core.MessageProducer;
+import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
+import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
+import org.springframework.integration.mqtt.support.MqttHeaders;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.messaging.MessageHandler;
+import org.springframework.messaging.MessagingException;
+
+/**
+ * @author TzZach
+ * @since 2022-06-29 13:59
+ */
+@Configuration
+public class MqttInboundConfig {
+
+    @Value("${spring.mqtt.url}")
+    private String url;
+
+    @Value("${spring.mqtt.consumerClientId}")
+    private String consumerClientId;
+
+    @Value("${spring.mqtt.consumerTopic}")
+    private String consumerTopic;
+
+    @Value("${spring.mqtt.timeout}")
+    private Long timeout;
+
+    @Value("${spring.mqtt.qos}")
+    private Integer qos;
+
+    @Autowired
+    private MqttService mqttService;
+
+    @Bean
+    public MessageChannel mqttInputChannel() {
+        return new DirectChannel();
+    }
+
+    @Bean
+    public MessageProducer inbound() {
+        MqttPahoMessageDrivenChannelAdapter adapter =
+                new MqttPahoMessageDrivenChannelAdapter(url, consumerClientId, consumerTopic);
+        adapter.setCompletionTimeout(timeout);
+        adapter.setConverter(new DefaultPahoMessageConverter());
+        adapter.setQos(qos);
+        adapter.setOutputChannel(mqttInputChannel());
+        return adapter;
+    }
+
+    @Bean
+    @ServiceActivator(inputChannel = "mqttInputChannel")
+    public MessageHandler handler() {
+        return new MessageHandler() {
+            @Override
+            public void handleMessage(Message<?> message) throws MessagingException {
+                String topic = (String) message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC);
+                try {
+                    mqttService.receiveFrom(topic , message);
+                } catch (IllegalAccessException e) {
+                    e.printStackTrace();
+                }
+            }
+        };
+    }
+
+}

+ 74 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/MqttOutboundConfig.java

@@ -0,0 +1,74 @@
+package com.yzt.airconditionersystem.config;
+
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.integration.annotation.MessagingGateway;
+import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
+import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
+import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.messaging.MessageHandler;
+
+/**
+ * @author TzZach
+ * @since 2022-06-29 13:59
+ */
+@Configuration
+public class MqttOutboundConfig {
+
+    @Value("${spring.mqtt.url}")
+    private String url;
+
+    @Value("${spring.mqtt.producerClientId}")
+    private String producerClientId;
+
+//    @Value("${spring.mqtt.consumerTopic}")
+//    private String consumerTopic;
+
+    @Value("${spring.mqtt.username}")
+    private String username;
+
+    @Value("${spring.mqtt.password}")
+    private String password;
+
+    @Bean
+    public MqttPahoClientFactory mqttClientFactory() {
+        DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
+        MqttConnectOptions options = new MqttConnectOptions();
+        options.setServerURIs(new String[] {url});
+        options.setUserName(username);
+        options.setPassword(password.toCharArray());
+        factory.setConnectionOptions(options);
+        return factory;
+    }
+
+    @Bean
+    @ServiceActivator(inputChannel = "mqttOutboundChannel")
+    public MessageHandler mqttOutbound() {
+        MqttPahoMessageHandler messageHandler =
+                new MqttPahoMessageHandler(url, producerClientId, mqttClientFactory());
+        messageHandler.setAsync(true);
+//        messageHandler.setDefaultTopic(consumerTopic);
+        return messageHandler;
+    }
+
+    @Bean
+    public MessageChannel mqttOutboundChannel() {
+        return new DirectChannel();
+    }
+
+    @MessagingGateway(defaultRequestChannel = "mqttOutboundChannel")
+    public interface MyGateway {
+
+        /**
+         * 发送数据到mqtt
+         * @param data
+         */
+        void sendToMqtt(String data);
+
+    }
+}

+ 23 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/MyBatisPlusConfig.java

@@ -0,0 +1,23 @@
+package com.yzt.airconditionersystem.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author TzZach
+ * @since 2022-04-13 16:46
+ */
+@Configuration
+public class MyBatisPlusConfig {
+
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+        return interceptor;
+    }
+
+}

+ 21 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/config/WebConfig.java

@@ -0,0 +1,21 @@
+package com.yzt.airconditionersystem.config;
+
+import com.yzt.airconditionersystem.interceptor.LoginInterceptor;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * @author TzZach
+ * @since 2022-04-09 12:56
+ */
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(new LoginInterceptor())
+                .addPathPatterns("/**")
+                .excludePathPatterns("/login", "/favicon.ico",  "/css/**", "/fonts/**", "/images/**", "/js/**", "/lib/**");
+    }
+}

+ 95 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/AdminController.java

@@ -0,0 +1,95 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.yzt.airconditionersystem.bean.Permission;
+import com.yzt.airconditionersystem.bean.Role;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.PermissionService;
+import com.yzt.airconditionersystem.service.RoleService;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author TzZach
+ * @since 2022-04-11 12:38
+ */
+@Controller
+public class AdminController {
+
+    public static final String PREFIX = "admin/";
+
+    @Autowired
+    private PermissionService permissionService;
+    @Autowired
+    private RoleService roleService;
+
+    @GetMapping("/admin-list")
+    public String adminList() {
+        return PREFIX + "admin-list";
+    }
+
+    @GetMapping("/admin-role")
+    public String adminRole(Model model) {
+        List<Permission> permissions = permissionService.list();
+        List<Role> roles = roleService.list();
+        model.addAttribute("permissions", permissions);
+        model.addAttribute("roles", roles);
+        return PREFIX + "admin-role";
+    }
+
+    @GetMapping("/admin-cate")
+    public String adminCate() {
+        return PREFIX + "admin-cate";
+    }
+
+    @GetMapping("/admin-rule")
+    public String adminRule() {
+        return PREFIX + "admin-rule";
+    }
+
+
+    @GetMapping("/permission/page")
+    @ResponseBody
+    public BasePageVo permissionPage(@RequestParam("page") Long page,
+                                     @RequestParam("limit") Long limit) {
+        Page<Permission> pageInfo = new Page<>(page, limit);
+        pageInfo = permissionService.page(pageInfo);
+        return BasePageVoUtil.getPageVo(pageInfo);
+    }
+
+    @PostMapping("/permission/add")
+    @ResponseBody
+    public Result permissionAdd(@RequestBody Permission permission) {
+        permissionService.save(permission);
+        return Result.success("添加成功");
+    }
+
+    @PostMapping("/permission/edit")
+    @ResponseBody
+    public Result permissionEdit(@RequestBody Permission permission) {
+        permissionService.updateById(permission);
+        return Result.success("修改成功");
+    }
+
+    @PostMapping("/permission/delete")
+    @ResponseBody
+    public Result permissionDelete(@RequestBody Permission permission) {
+        permissionService.removeById(permission);
+        return Result.success("删除成功");
+    }
+
+    @PostMapping("/permission/batchDelete")
+    @ResponseBody
+    public Result permissionBatchDelete(@RequestBody List<Integer> ids) {
+        permissionService.removeBatchByIds(ids);
+        return Result.success("删除成功");
+    }
+
+
+}

+ 165 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/AlarmController.java

@@ -0,0 +1,165 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.yzt.airconditionersystem.bean.*;
+import com.yzt.airconditionersystem.enums.AlarmStatusEnum;
+import com.yzt.airconditionersystem.enums.CompanyTypeEnum;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.AlarmService;
+import com.yzt.airconditionersystem.service.CompanyService;
+import com.yzt.airconditionersystem.service.FacilityAlarmService;
+import com.yzt.airconditionersystem.service.GatewayService;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author TzZach
+ * @since 2022-04-21 22:42
+ */
+@Controller
+public class AlarmController {
+
+    private static final String PREFIX = "alarm/";
+
+    @Autowired
+    private AlarmService alarmService;
+    @Autowired
+    private FacilityAlarmService facilityAlarmService;
+    @Autowired
+    private CompanyService companyService;
+    @Autowired
+    private GatewayService gatewayService;
+
+    @GetMapping("/alarm/index")
+    public String alarmList() {
+        return PREFIX + "alarm-list";
+    }
+
+    @GetMapping("/alarm/page")
+    @ResponseBody
+    public BasePageVo alarmPage(@RequestParam("page") Long page,
+                                @RequestParam("limit") Long limit,
+                                HttpSession session,
+                                @RequestParam(value = "companyId") String companyId) {
+//        User loginUser = (User) session.getAttribute("loginUser");
+//        String companyId = loginUser.getCompanyId();
+//        if (companyId.equals(CompanyTypeEnum.HEADQUARTERS.getId().toString())) {
+//            Page<FacilityAlarm> facilityAlarmPage = new Page<>(page, limit);
+//            facilityAlarmPage = facilityAlarmService.page(facilityAlarmPage);
+//            List<FacilityAlarm> list = facilityAlarmPage.getRecords();
+//            for (FacilityAlarm facilityAlarm : list) {
+//                String gatewayId = facilityAlarm.getGatewayId();
+//                List<Gateway> gateways = gatewayService.listByIds(Arrays.asList(gatewayId));
+//                for (Gateway gateway : gateways) {
+//                    String gatewayCompanyId = gateway.getCompanyId();
+//                    Company company = companyService.getById(gatewayCompanyId);
+//                    facilityAlarm.setCompanyName(company.getName());
+//                    facilityAlarm.setDistrict(company.getDistrict());
+//                    facilityAlarm.setOperatorId(company.getOperatorId());
+//                    Company operator = companyService.getById(company.getOperatorId());
+//                    facilityAlarm.setOperatorName(operator.getName());
+//                }
+//            }
+//            BasePageVo pageVo = BasePageVoUtil.getPageVo(facilityAlarmPage);
+//            return pageVo;
+//        }
+//        Company company = companyService.getById(companyId);
+
+
+//        Page<Alarm> pageInfo = new Page<>(page, limit);
+//        pageInfo = alarmService.page(pageInfo, null);
+//        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        User loginUser = (User) session.getAttribute("loginUser");
+        String HqId = CompanyTypeEnum.HEADQUARTERS.getId().toString();
+        List<String> companyIds = new ArrayList<>();
+        if (loginUser.getCompanyId().equals(HqId) && companyId.equals(HqId)) {
+            companyIds = null;
+        } else {
+//            List<Company> companyList = companyService.list();
+//            companyList = companyList.stream().filter(company ->
+//                company.getType().equals(CompanyTypeEnum.CLIENT.getId().toString())
+//            ).collect(Collectors.toList());
+//            for (Company company : companyList) {
+//                operatorIds.add(company.getOperatorId());
+//            }
+            LambdaQueryWrapper<Company> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(Company::getOperatorId, companyId)
+                            .eq(Company::getType, CompanyTypeEnum.CLIENT.getId().toString())
+                            .select(Company::getId);
+            List<Company> list = companyService.list(queryWrapper);
+            for (Company company : list) {
+                companyIds.add(company.getId());
+            }
+        }
+        PageHelper.startPage(Math.toIntExact(page), Math.toIntExact(limit));
+        List<FacilityAlarm> list = facilityAlarmService.selectByGatewayIdAndCompanyId(companyIds);
+        int navigatePages = (int) (list.size() / limit);
+        PageInfo<FacilityAlarm> pageInfo = new PageInfo<>(list, navigatePages);
+        return BasePageVoUtil.getPageVo(pageInfo);
+    }
+
+    @PostMapping("/alarm/edit")
+    @ResponseBody
+    public Result updateAlarmStatus(@RequestBody Alarm alarm) {
+        alarm.setStatus(AlarmStatusEnum.HANDLED);
+        alarmService.updateById(alarm);
+        return Result.success();
+    }
+
+    @PostMapping("/alarm/delete")
+    @ResponseBody
+    public Result deleteAlarm(@RequestBody Alarm alarm) {
+        alarmService.removeById(alarm);
+        return Result.success();
+    }
+
+    @PostMapping("/alarm/batchDelete")
+    @ResponseBody
+    public Result deleteAlarmBatch(@RequestBody List<Integer> ids) {
+        alarmService.removeBatchByIds(ids);
+        return Result.success();
+    }
+
+    @GetMapping("/alarm/search")
+    @ResponseBody
+    public BasePageVo searchAlarm(@RequestParam("page") Long page,
+                                     @RequestParam("limit") Long limit,
+                                     Alarm alarm) {
+
+        String clientName = alarm.getClientName();
+        String district = alarm.getDistrict();
+        String operatorName = alarm.getOperatorName();
+
+        PageHelper.startPage(Math.toIntExact(page), Math.toIntExact(limit));
+        LambdaQueryWrapper<Alarm> queryWrapper = new LambdaQueryWrapper<>();
+        if(StringUtils.hasLength(clientName)) {
+            queryWrapper.like(Alarm::getClientName, clientName);
+        }
+        if(StringUtils.hasLength(district)) {
+            queryWrapper.like(Alarm::getDistrict, district);
+        }
+        if(StringUtils.hasLength(operatorName)) {
+            queryWrapper.like(Alarm::getOperatorName, operatorName);
+        }
+        List<Alarm> alarms = alarmService.list(queryWrapper);
+        int navigatePages = (int) (alarms.size() / limit);
+        PageInfo<Alarm> pageInfo = new PageInfo<>(alarms, navigatePages);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+
+        return pageVo;
+    }
+
+}

+ 122 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/ClientController.java

@@ -0,0 +1,122 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.azul.crs.client.service.ClientService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.yzt.airconditionersystem.bean.Company;
+import com.yzt.airconditionersystem.bean.User;
+import com.yzt.airconditionersystem.enums.CompanyTypeEnum;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.CompanyService;
+import com.yzt.airconditionersystem.service.UserService;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import com.yzt.airconditionersystem.vo.CompanyVo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+
+/**
+ * @author TzZach
+ * @since 2022-04-13 14:51
+ */
+@Slf4j
+@Controller
+public class ClientController {
+
+    public static final String PREFIX = "client/";
+
+    @Autowired
+    private CompanyService companyService;
+    @Autowired
+    private UserService userService;
+
+    @ResponseBody
+    @GetMapping(value = {"/client/page"})
+    public BasePageVo clientListPage(@RequestParam("page") Long page,
+                                     @RequestParam("limit") Long limit,
+                                     HttpSession session) {
+        User loginUser = (User) session.getAttribute("loginUser");
+        String companyId = loginUser.getCompanyId();
+        Page<Company> pageInfo = new Page<>(page, limit);
+        pageInfo = companyService.getCompanyPageByType(pageInfo, CompanyTypeEnum.CLIENT.getId(), companyId);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+
+    @GetMapping( "/client/index")
+    public String clientList(Model model) {
+        return PREFIX + "client-list";
+    }
+
+
+    @GetMapping("/client/edit")
+    public String clientEdit(@RequestParam("id") String id, Model model) {
+        LambdaQueryWrapper<Company> queryWrapper = new LambdaQueryWrapper();
+        queryWrapper.eq(Company::getId, id);
+        Company company = companyService.getOne(queryWrapper);
+        model.addAttribute("company", company);
+        return PREFIX + "client-edit";
+    }
+
+    @GetMapping("/client/add")
+    public String clientAdd() {
+        return PREFIX + "client-add";
+    }
+
+    @PostMapping("/client/add")
+    @ResponseBody
+    public Result addClient(@RequestBody CompanyVo company,
+                            HttpSession session) {
+        User user = userService.getOneByUsername(company.getUsername());
+        if (user != null) {
+            return Result.error("该用户名已存在!");
+        }
+        LambdaQueryWrapper<Company> companyLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        companyLambdaQueryWrapper.eq(Company::getName, company.getName());
+        if (companyService.getOne(companyLambdaQueryWrapper) != null) {
+            return Result.error("该公司名称已存在!");
+        }
+        User loginUser = (User) session.getAttribute("loginUser");
+        String companyId = loginUser.getCompanyId();
+        company.setType(CompanyTypeEnum.CLIENT.getId());
+        company.setOperatorId(companyId);
+        companyService.save(company);
+        User insertUser = new User(null, company.getUsername(), company.getPassword(),
+                CompanyTypeEnum.CLIENT.getId(), company.getId());
+        userService.save(insertUser);
+        return Result.success( "添加成功");
+    }
+
+    @PostMapping("/client/edit")
+    @ResponseBody
+    public Result updateClient(@RequestBody Company company) {
+        companyService.updateById(company);
+        return Result.success( "修改成功");
+    }
+
+    @PostMapping("/client/delete")
+    @ResponseBody
+    public Result deleteClient(@RequestBody Company company) {
+        companyService.removeById(company.getId());
+        return Result.success( "删除成功");
+    }
+
+    @PostMapping("/client/batchDelete")
+    @ResponseBody
+    public Result deleteByIds(@RequestBody List<String> ids) {
+        System.out.println(ids);
+        companyService.removeBatchByIds(ids);
+        return Result.success();
+    }
+
+
+
+}

+ 30 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/DeviceController.java

@@ -0,0 +1,30 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.yzt.airconditionersystem.bean.Device;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.DeviceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * 空调信息
+ * @author TzZach
+ * @since 2022-05-20 17:13
+ */
+@Controller
+public class DeviceController {
+
+    @Autowired
+    private DeviceService deviceService;
+
+    @GetMapping("/device/detail")
+    @ResponseBody
+    public Result deviceDetail(@RequestParam("id") String id) {
+        Device device = deviceService.getById(id);
+        return Result.success(device);
+    }
+
+}

+ 304 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/FacilityController.java

@@ -0,0 +1,304 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.gson.*;
+import com.google.gson.stream.JsonReader;
+import com.yzt.airconditionersystem.bean.*;
+import com.yzt.airconditionersystem.config.MqttOutboundConfig;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.*;
+import com.yzt.airconditionersystem.util.AirconditionerStatus;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import com.yzt.airconditionersystem.util.MyUtils;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
+import org.springframework.messaging.MessageHandler;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.io.StringReader;
+import java.lang.reflect.Field;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalUnit;
+import java.util.*;
+
+/**
+ * @author TzZach
+ * @since 2022-04-18 11:10
+ */
+@Slf4j
+@Controller
+public class FacilityController {
+
+    private static final String PREFIX = "facility/";
+
+    @Autowired
+    private MqttOutboundConfig.MyGateway mqttGateway;
+    @Autowired
+    private MessageHandler mqttOutbound;
+    @Autowired
+    private FacilityAlarmService facilityAlarmService;
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private DeviceDataService deviceDataService;
+//    @Autowired
+//    private MqttProducer mqttProducer;
+    @Autowired
+    private LogService logService;
+
+    @GetMapping("/facility-list")
+    public String facilityList(@RequestParam("gatewayId") String gatewayId,
+//                               @RequestParam("deviceId") String deviceId,
+                               HttpSession session) {
+//        Device sessionAttribute = (Device) session.getAttribute("device");
+        LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        deviceLambdaQueryWrapper.eq(Device::getGatewayId, gatewayId)
+//                        .eq(Device::getDeviceId, sessionAttribute.getDeviceId())
+                .orderByDesc(Device::getTime).last("limit 1");
+        Device device = deviceService.getOne(deviceLambdaQueryWrapper);
+        session.setAttribute("device", device);
+        return PREFIX + "facility-list";
+    }
+
+    @GetMapping("/status")
+    public String status(Model model, HttpSession session) {
+        Device deviceSession = (Device) session.getAttribute("device");
+//        String gatewayId = deviceSession.getGatewayId();
+
+//        LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
+//        deviceLambdaQueryWrapper.eq(Device::getGatewayId, gatewayId)
+//                .orderByDesc(Device::getTime);
+        //获取最近的一个作为状态显示
+//        Device device = deviceService.list(deviceLambdaQueryWrapper).get(0);
+        Device device = deviceService.getById(deviceSession.getId());
+        LambdaQueryWrapper<DeviceData> dataLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        dataLambdaQueryWrapper.eq(DeviceData::getDId, deviceSession.getId())
+                .orderByDesc(DeviceData::getTime).last("limit 1");
+        DeviceData deviceData = deviceDataService.getOne(dataLambdaQueryWrapper);
+
+        String m_bit1 = MyUtils.decToBin(deviceData.getM_bit1());
+        String m_bit2 = MyUtils.decToBin(deviceData.getM_bit2());
+        String q_bit3 = MyUtils.decToBin(deviceData.getQ_bit3());
+        deviceData.setM_bit1BinStr(m_bit1);
+        deviceData.setM_bit2BinStr(m_bit2);
+        deviceData.setQ_bit3BinStr(q_bit3);
+
+        device.setDeviceData(deviceData);
+
+        model.addAttribute("device", device);
+
+        return PREFIX + "status";
+    }
+
+    @GetMapping("/system-parameter")
+    public String systemParameter(Model model, HttpSession session) {
+
+        Device deviceSession = (Device) session.getAttribute("device");
+        String gatewayId = deviceSession.getGatewayId();
+        String deviceId = deviceSession.getDeviceId();
+        //得到最新的device信息,并根据device中的deviceDataId获取对应deviceData
+        LambdaQueryWrapper<Device> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(Device::getGatewayId, gatewayId)
+                .eq(Device::getDeviceId, deviceId);
+        Device device = deviceService.getOne(lambdaQueryWrapper);
+        LambdaQueryWrapper<DeviceData> deviceDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        deviceDataLambdaQueryWrapper.eq(DeviceData::getDId, device.getId())
+                .orderByDesc(DeviceData::getTime).last("limit 1");
+        DeviceData deviceData = deviceDataService.getOne(deviceDataLambdaQueryWrapper);
+//        LambdaQueryWrapper<DeviceData> deviceDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
+//        deviceDataLambdaQueryWrapper.eq(DeviceData::getDId, device)
+//        DeviceData deviceData = deviceDataService.getById(device.getDeviceDataId());
+        model.addAttribute("deviceData", deviceData);
+        return PREFIX + "system-parameter";
+    }
+
+    @GetMapping("/parameter-settings")
+    public String parameterSettings(Model model, HttpSession session) {
+        Device deviceSession = (Device) session.getAttribute("device");
+        String gatewayId = deviceSession.getGatewayId();
+        String deviceId = deviceSession.getDeviceId();
+        //得到最新的device信息,并根据device中的deviceDataId获取对应deviceData
+        LambdaQueryWrapper<Device> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(Device::getGatewayId, gatewayId)
+                .eq(Device::getDeviceId, deviceId);
+        Device device = deviceService.getOne(lambdaQueryWrapper);
+        LambdaQueryWrapper<DeviceData> deviceDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        deviceDataLambdaQueryWrapper.eq(DeviceData::getDId, device.getId())
+                .orderByDesc(DeviceData::getTime).last("limit 1");
+        DeviceData deviceData = deviceDataService.getOne(deviceDataLambdaQueryWrapper);
+        deviceData.setM_bit1BinStr(MyUtils.decToBin(deviceData.getM_bit1()));
+        deviceData.setM_bit2BinStr(MyUtils.decToBin(deviceData.getM_bit2()));
+        deviceData.setQ_bit3BinStr(MyUtils.decToBin(deviceData.getQ_bit3()));
+        model.addAttribute("deviceData", deviceData);
+        return PREFIX + "parameter-settings";
+    }
+
+
+    @GetMapping("/data-curves")
+    public String dataCurves(Model model, HttpSession session) {
+        Device deviceSession = (Device) session.getAttribute("device");
+        String gatewayId = deviceSession.getGatewayId();
+        String deviceId = deviceSession.getDeviceId();
+        LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        deviceLambdaQueryWrapper.eq(Device::getGatewayId, gatewayId)
+                .eq(Device::getDeviceId, deviceId);
+        Device device = deviceService.getOne(deviceLambdaQueryWrapper);
+        List<Double> tempReadList = new ArrayList<>();
+        List<Double> humiReadList = new ArrayList<>();
+        List<String> timeList = new ArrayList<>();
+        LambdaQueryWrapper<DeviceData> deviceDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        deviceDataLambdaQueryWrapper.eq(DeviceData::getDId, device.getId())
+                .orderByDesc(DeviceData::getTime)
+                .last("limit 10");
+        List<DeviceData> deviceDataList = deviceDataService.list(deviceDataLambdaQueryWrapper);
+        for (DeviceData deviceData : deviceDataList) {
+            tempReadList.add(deviceData.getTemp_read());
+            humiReadList.add(deviceData.getHumi_read());
+            //去掉LocalDateTime中的T
+            DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            LocalDateTime date = deviceData.getTime();
+            date = LocalDateTime.of(date.getYear(), date.getMonth(), date.getDayOfMonth(),
+                    date.getHour(), date.getMinute(), date.getSecond());
+            String time = date.format(dateTimeFormatter);
+            timeList.add(time);
+        }
+
+        model.addAttribute("tempReadList", tempReadList);
+        model.addAttribute("humiReadList", humiReadList);
+        model.addAttribute("timeList", timeList);
+
+        return PREFIX + "data-curves";
+    }
+
+    @GetMapping("/alarm-records")
+    public String alarmRecords() {
+        return PREFIX + "alarm-records";
+    }
+
+    @GetMapping("/alarmRecords/page")
+    @ResponseBody
+    public BasePageVo alarmRecordsPage(@RequestParam("page") Long page,
+                                       @RequestParam("limit") Long limit,
+                                       HttpSession session) {
+        Device deviceSession = (Device) session.getAttribute("device");
+        String gatewayId = deviceSession.getGatewayId();
+        LambdaQueryWrapper<FacilityAlarm> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(FacilityAlarm::getGatewayId, gatewayId);
+        Page<FacilityAlarm> pageInfo = new Page<>(page, limit);
+        pageInfo = facilityAlarmService.page(pageInfo, queryWrapper);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+    @GetMapping("/alarmRecords/search")
+    @ResponseBody
+    public BasePageVo alarmRecordsSearch(@RequestParam("page") Long page,
+                                         @RequestParam("limit") Long limit,
+                                         FacilityAlarm facilityAlarm,
+                                         HttpSession session) {
+        Device deviceSession = (Device) session.getAttribute("device");
+        String gatewayId = deviceSession.getGatewayId();
+        String startTime = facilityAlarm.getStartTime();
+        String endTime = facilityAlarm.getEndTime();
+
+        Page<FacilityAlarm> pageInfo = new Page<>(page, limit);
+
+        LambdaQueryWrapper<FacilityAlarm> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.between(FacilityAlarm::getTime, startTime, endTime)
+                .eq(FacilityAlarm::getGatewayId, gatewayId);
+        pageInfo = facilityAlarmService.page(pageInfo, queryWrapper);
+
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+    @PostMapping("/alarmRecords/status")
+    @ResponseBody
+    public Result alarmRecordsUpdateStatus(@RequestBody FacilityAlarm facilityAlarm) {
+        facilityAlarm.setStatus(AirconditionerStatus.STATUS_HANDLED);
+        facilityAlarmService.updateById(facilityAlarm);
+        return Result.success("修改成功");
+    }
+
+    @PostMapping("/alarmRecords/delete")
+    @ResponseBody
+    public Result alarmRecordsStatus(@RequestBody FacilityAlarm facilityAlarm) {
+        facilityAlarmService.removeById(facilityAlarm);
+        return Result.success();
+    }
+
+    @PostMapping("/parameterSetting/update")
+    @ResponseBody
+    public Result parameterSettingUpdate(@RequestBody DeviceData deviceData,
+                                         HttpSession session) throws Exception {
+        Device deviceSession = (Device) session.getAttribute("device");
+
+        LambdaQueryWrapper<DeviceData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(DeviceData::getDId, deviceSession.getId())
+                .orderByDesc(DeviceData::getTime).last("limit 1");
+        DeviceData deviceDataReplaced = deviceDataService.getOne(lambdaQueryWrapper);
+        if (deviceData.getM_bit1() != null) {
+            deviceData.setM_bit1(deviceDataReplaced.getM_bit1() + deviceData.getM_bit1());
+        }
+        if (deviceData.getM_bit2() != null) {
+            deviceData.setM_bit2(deviceDataReplaced.getM_bit2() + deviceData.getM_bit2());
+        }
+        if (deviceData.getQ_bit3() != null) {
+            deviceData.setQ_bit3(deviceDataReplaced.getQ_bit3() + deviceData.getQ_bit3());
+        }
+
+        System.out.println(deviceData);
+        Gson gson = new GsonBuilder().create();
+        String deviceDataJsonStr = gson.toJson(deviceData);
+        String deviceId = deviceSession.getDeviceId();
+        //获取要发送到的空调名作为前缀
+        String prefix = deviceSession.getPrefix();
+        JsonObject deviceDataJson = JsonParser.parseString(deviceDataJsonStr).getAsJsonObject();
+        JsonObject deviceDataJsonSend = new JsonObject();
+        //遍历json,给key添加前缀,放入到deviceDataJsonSend中
+        for (Map.Entry<String, JsonElement> stringJsonElementEntry : deviceDataJson.entrySet()) {
+            String key = stringJsonElementEntry.getKey();
+            JsonElement value = stringJsonElementEntry.getValue();
+            deviceDataJsonSend.add(prefix + key, value);
+        }
+
+        //固定json格式
+        JsonObject jsonObject = new JsonObject();
+        JsonArray devices = new JsonArray();
+        JsonObject device = new JsonObject();
+        device.add("deviceId", JsonParser.parseString(deviceId));
+        device.add("deviceData", JsonParser.parseString(deviceDataJsonSend.toString()));
+        devices.add(device);
+        jsonObject.add("devices", devices);
+//        mqttProducer.send("mqtt/" + deviceSession.getCompanyName() + "/" + deviceSession.getGatewayId() + "/plc_cmd"
+//                , jsonObject.toString());
+        String topic = "mqtt/" + deviceSession.getCompanyName() + "/" + deviceSession.getGatewayId() + "/plc_cmd";
+
+        log.info("开始发送mqtt消息,主题:{},消息:{}", topic, jsonObject.toString());
+//        if (StringUtils.isNotBlank(topic)) {
+//            mqttProducer.send(topic, data);
+            ((MqttPahoMessageHandler) mqttOutbound).setDefaultTopic(topic);
+            mqttGateway.sendToMqtt(jsonObject.toString());
+            log.info("发送mqtt消息完成,主题:{},消息:{}", topic, jsonObject.toString());
+//            return Result.success("execute successful");
+//        } else {
+//            return Result.error("topic is blank");
+//        }
+
+        return Result.success(jsonObject.toString());
+    }
+
+}

+ 211 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/FacilityMobileController.java

@@ -0,0 +1,211 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.gson.*;
+import com.yzt.airconditionersystem.bean.Device;
+import com.yzt.airconditionersystem.bean.DeviceData;
+import com.yzt.airconditionersystem.bean.FacilityAlarm;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.*;
+import com.yzt.airconditionersystem.util.AirconditionerStatus;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import com.yzt.airconditionersystem.util.MyUtils;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpSession;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author TzZach
+ * @since 2022-04-18 11:10
+ */
+@Controller
+public class FacilityMobileController {
+
+    private static final String PREFIX = "facility/";
+
+    @Autowired
+    private FacilityAlarmService facilityAlarmService;
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private DeviceDataService deviceDataService;
+//    @Autowired
+//    private MqttProducer mqttProducer;
+
+    @GetMapping("/mobile/status")
+    @ResponseBody
+    public DeviceData status(@RequestParam("id") String id) {
+        LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        deviceLambdaQueryWrapper.eq(Device::getGatewayId, id)
+                .orderByDesc(Device::getTime);
+        //获取最近的一个作为状态显示
+        Device device = deviceService.list(deviceLambdaQueryWrapper).get(0);
+        LambdaQueryWrapper<DeviceData> dataLambdaQueryWrapper = new LambdaQueryWrapper<>();
+//        dataLambdaQueryWrapper.eq(DeviceData::getId, device.getDeviceDataId());
+        DeviceData deviceData = deviceDataService.getOne(dataLambdaQueryWrapper);
+
+        String m_bit1 = MyUtils.decToBin(deviceData.getM_bit1());
+        String m_bit2 = MyUtils.decToBin(deviceData.getM_bit2());
+        String q_bit3 = MyUtils.decToBin(deviceData.getQ_bit3());
+        deviceData.setM_bit1BinStr(m_bit1);
+        deviceData.setM_bit2BinStr(m_bit2);
+        deviceData.setQ_bit3BinStr(q_bit3);
+
+
+        return deviceData;
+    }
+
+//    @GetMapping("/mobile/system-parameter")
+    public String systemParameter(Model model, HttpSession session) {
+
+        Device deviceSession = (Device) session.getAttribute("device");
+        String gatewayId = deviceSession.getGatewayId();
+        //得到最新的device信息,并根据device中的deviceDataId获取对应deviceData
+        LambdaQueryWrapper<Device> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(Device::getGatewayId, gatewayId)
+                .orderByDesc(Device::getTime).last("limit 1");
+        Device device = deviceService.getOne(lambdaQueryWrapper);
+//        DeviceData deviceData = deviceDataService.getById(device.getDeviceDataId());
+//        model.addAttribute("deviceData", deviceData);
+        return PREFIX + "system-parameter";
+    }
+
+//    @GetMapping("/mobile/parameter-settings")
+    public String parameterSettings(Model model, HttpSession session) {
+        Device deviceSession = (Device) session.getAttribute("device");
+        String gatewayId = deviceSession.getGatewayId();
+        //得到最新的device信息,并根据device中的deviceDataId获取对应deviceData
+        LambdaQueryWrapper<Device> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(Device::getGatewayId, gatewayId)
+                        .orderByDesc(Device::getTime).last("limit 1");
+        Device device = deviceService.getOne(lambdaQueryWrapper);
+//        DeviceData deviceData = deviceDataService.getById(device.getDeviceDataId());
+//        deviceData.setM_bit1(MyUtils.decToBin(deviceData.getM_bit1()));
+//        deviceData.setM_bit2(MyUtils.decToBin(deviceData.getM_bit2()));
+//        deviceData.setQ_bit3(MyUtils.decToBin(deviceData.getQ_bit3()));
+//        model.addAttribute("deviceData", deviceData);
+        return PREFIX + "parameter-settings";
+    }
+
+
+
+    @GetMapping("/mobile/dataCurves")
+    @ResponseBody
+    public Map dataCurves(@RequestParam("gatewayId") String gatewayId) {
+//        Device deviceSession = (Device) session.getAttribute("device");
+//        String gatewayId = deviceSession.getGatewayId();
+        LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        deviceLambdaQueryWrapper.eq(Device::getGatewayId, gatewayId)
+                .orderByDesc(Device::getTime).last("limit 10");
+        List<Device> devices = deviceService.list(deviceLambdaQueryWrapper);
+        List<Double> tempReadList = new ArrayList<>();
+        List<Double> humiReadList = new ArrayList<>();
+        List<String> timeList = new ArrayList<>();
+        for (Device device : devices) {
+//            DeviceData deviceData = deviceDataService.getById(device.getDeviceDataId());
+//            tempReadList.add(deviceData.getTemp_read());
+//            humiReadList.add(deviceData.getHumi_read());
+            //去掉LocalDateTime中的T
+            DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+//            LocalDateTime date = deviceData.getTime();
+//            date = LocalDateTime.of(date.getYear(), date.getMonth(), date.getDayOfMonth(),
+//                    date.getHour(), date.getMinute(), date.getSecond());
+//            String time = date.format(dateTimeFormatter);
+//            timeList.add(time);
+        }
+
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("tempReadList", tempReadList);
+        map.put("humiReadList", humiReadList);
+        map.put("timeList", timeList);
+
+        return map;
+    }
+
+//    @GetMapping("/mobile/alarm-records")
+    public String alarmRecords() {
+        return PREFIX + "/alarm-records";
+    }
+
+//    @GetMapping("/alarmRecords/page")
+    @ResponseBody
+    public BasePageVo alarmRecordsPage(@RequestParam("page") Long page,
+                                       @RequestParam("limit") Long limit) {
+
+        Page<FacilityAlarm> pageInfo = new Page<>(page, limit);
+        pageInfo = facilityAlarmService.page(pageInfo);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+//    @GetMapping("/alarmRecords/search")
+    @ResponseBody
+    public BasePageVo alarmRecordsSearch(@RequestParam("page") Long page,
+                                         @RequestParam("limit") Long limit,
+                                         FacilityAlarm facilityAlarm) {
+
+        String startTime = facilityAlarm.getStartTime();
+        String endTime = facilityAlarm.getEndTime();
+
+        Page<FacilityAlarm> pageInfo = new Page<>(page, limit);
+
+        LambdaQueryWrapper<FacilityAlarm> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.between(FacilityAlarm::getTime, startTime, endTime);
+        pageInfo = facilityAlarmService.page(pageInfo, queryWrapper);
+
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+//    @PostMapping("/mobile/alarmRecords/status")
+    @ResponseBody
+    public Result alarmRecordsUpdateStatus(@RequestBody FacilityAlarm facilityAlarm) {
+        facilityAlarm.setStatus(AirconditionerStatus.STATUS_HANDLED);
+        facilityAlarmService.updateById(facilityAlarm);
+        return Result.success("修改成功");
+    }
+
+//    @PostMapping("/mobile/parameterSetting/update")
+    @ResponseBody
+    public Result parameterSettingUpdate(@RequestBody DeviceData deviceData, HttpSession session) {
+        Device deviceSession = (Device) session.getAttribute("device");
+        Gson gson = new GsonBuilder().create();
+        String deviceDataJsonStr = gson.toJson(deviceData);
+        String deviceId = deviceSession.getDeviceId();
+        //获取要发送到的空调名作为前缀
+        String prefix = deviceId.substring(0, deviceId.lastIndexOf("_"));
+        JsonObject deviceDataJson = JsonParser.parseString(deviceDataJsonStr).getAsJsonObject();
+        JsonObject deviceDataJsonSend = new JsonObject();
+        //遍历json,给key添加前缀,放入到deviceDataJsonSend中
+        for (Map.Entry<String, JsonElement> stringJsonElementEntry : deviceDataJson.entrySet()) {
+            String key = stringJsonElementEntry.getKey().toString();
+            JsonElement value = stringJsonElementEntry.getValue();
+            deviceDataJsonSend.add(prefix + "_" + key, value);
+        }
+
+        //固定json格式
+        JsonObject jsonObject = new JsonObject();
+        JsonArray devices = new JsonArray();
+        JsonObject device = new JsonObject();
+        device.add("deviceId", JsonParser.parseString(deviceId));
+        device.add("deviceData", JsonParser.parseString(deviceDataJsonSend.toString()));
+        devices.add(device);
+        jsonObject.add("devices", devices);
+//        mqttProducer.send("mqtt/" + deviceSession.getCompanyName() + "/" + deviceSession.getDeviceId() + "/plc_cmd"
+//                , jsonObject.toString());
+
+        return Result.success(jsonObject.toString());
+    }
+
+}

+ 124 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/GatewayController.java

@@ -0,0 +1,124 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.yzt.airconditionersystem.bean.Company;
+import com.yzt.airconditionersystem.bean.User;
+import com.yzt.airconditionersystem.service.CompanyService;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import com.yzt.airconditionersystem.bean.Gateway;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.GatewayService;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+/**
+ * @author TzZach
+ * @since 2022-04-17 11:54
+ */
+@Slf4j
+@Controller
+public class GatewayController {
+
+    private static final String PREFIX = "gateway/";
+
+    @Autowired
+    private GatewayService gatewayService;
+
+    @Autowired
+    private CompanyService companyService;
+
+    @GetMapping("/gateway/index")
+    public String gatewayList(@RequestParam(value = "projectId", required = false) String projectId, HttpSession session) {
+        session.setAttribute("projectId", projectId);
+        return PREFIX + "gateway-list";
+    }
+
+    @GetMapping("/gateway/page")
+    @ResponseBody
+    public BasePageVo gatewayPage(@RequestParam("page") Long page,
+                                  @RequestParam("limit") Long limit,
+                                  HttpSession session) {
+        User loginUser = (User) session.getAttribute("loginUser");
+        LambdaQueryWrapper<Gateway> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Gateway::getCompanyId, loginUser.getCompanyId());
+        System.out.println(loginUser.getCompanyId());
+        Page<Gateway> pageInfo = new Page<>(page, limit);
+        pageInfo = gatewayService.page(pageInfo, queryWrapper);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+    @GetMapping("/mobile/gateway/page")
+    @ResponseBody
+    public BasePageVo gatewayPage(@RequestParam("page") Long page,
+                                  @RequestParam("limit") Long limit,
+                                  @RequestParam("companyId") String companyId) {
+//        User loginUser = (User) session.getAttribute("loginUser");
+        LambdaQueryWrapper<Gateway> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Gateway::getCompanyId, companyId);
+//        System.out.println(loginUser.getCompanyId());
+        Page<Gateway> pageInfo = new Page<>(page, limit);
+        pageInfo = gatewayService.page(pageInfo, queryWrapper);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+    @GetMapping("/gateway/add")
+    public String gatewayAdd() {
+        return PREFIX + "gateway-add";
+    }
+
+
+    @GetMapping("/gateway/edit")
+    public String gatewayEdit(@RequestParam("id") String id, Model model) {
+        Gateway gateway = gatewayService.getById(id);
+        model.addAttribute("gateway", gateway);
+        return PREFIX + "gateway-edit";
+    }
+
+    @PostMapping("/gateway/add")
+    @ResponseBody
+    public Result addGateway(@RequestBody Gateway gateway) {
+        gatewayService.save(gateway);
+        return Result.success("添加成功");
+    }
+
+    @PostMapping("/gateway/delete")
+    @ResponseBody
+    public Result deleteGateway(@RequestBody Gateway gateway) {
+        gatewayService.removeById(gateway);
+        return Result.success();
+    }
+
+    @PostMapping("/gateway/edit")
+    @ResponseBody
+    public Result updateGateway(@RequestBody Gateway gateway) {
+        gatewayService.updateById(gateway);
+        return Result.success();
+    }
+
+    @PostMapping("/gateway/batchDelete")
+    @ResponseBody
+    public Result deleteBatchGateway(@RequestBody List<String> ids) {
+        gatewayService.removeBatchByIds(ids);
+        return Result.success();
+    }
+
+    @GetMapping("/gateway/detail")
+    @ResponseBody
+    public Result gatewayDetail(@RequestParam("id") String id) {
+        Gateway gateway = gatewayService.getById(id);
+        Company company = companyService.getById(gateway.getCompanyId());
+        gateway.setCompany(company);
+        return Result.success(gateway);
+    }
+
+}

+ 42 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/LogController.java

@@ -0,0 +1,42 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.yzt.airconditionersystem.bean.Log;
+import com.yzt.airconditionersystem.service.LogService;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * @author TzZach
+ * @since 2022-04-22 21:18
+ */
+@Controller
+public class LogController {
+
+    private static final String PREFIX = "log/";
+
+    @Autowired
+    private LogService logService;
+
+    @GetMapping("log-list")
+    public String logList() {
+        return PREFIX + "log-list";
+    }
+
+
+    @GetMapping("/logPage")
+    @ResponseBody
+    public BasePageVo logPage(@RequestParam("page") Long page,
+                              @RequestParam("limit") Long limit) {
+        Page<Log> pageInfo = new Page<>(page, limit);
+        pageInfo = logService.page(pageInfo, null);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+}

+ 110 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/LoginController.java

@@ -0,0 +1,110 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.sun.org.apache.bcel.internal.generic.LMUL;
+import com.yzt.airconditionersystem.bean.*;
+import com.yzt.airconditionersystem.enums.CompanyTypeEnum;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author TzZach
+ * @since 2022-04-09 12:38
+ */
+@Controller
+public class LoginController {
+
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private PermissionService permissionService;
+    @Autowired
+    private RolePermissionService rolePermissionService;
+    @Autowired
+    private RoleService roleService;
+    @Autowired
+    private CompanyService companyService;
+
+    @GetMapping(value = {"/login", "/login.html"})
+    public String login() {
+        return "login";
+    }
+
+    @PostMapping("/login")
+    @ResponseBody
+    public Result login(@RequestBody User loginUser, HttpSession session) {
+        session.setAttribute("loginUser", loginUser);
+
+        User user = userService.getOneByUsernameAndPassword(loginUser);
+
+        if(user != null) {
+            if (loginUser.getUsername().equals(user.getUsername())
+                    && loginUser.getPassword().equals(user.getPassword())) {
+                List<Permission> permissions = getPermissionFromUserRoleId(user);
+                userInfo(user);
+                user.setPassword(null);
+                session.setAttribute("loginUser", user);
+                session.setAttribute("permissions", permissions);
+                return Result.success(permissions);
+            }
+        }
+
+        return Result.error("账户名或密码错误");
+    }
+
+    /**
+     * 给用户加入角色名称和公司名称
+     * @param user
+     * @return
+     */
+    private void userInfo(User user) {
+        Role role = roleService.getById(user.getRoleId());
+        user.setRoleName(role.getName());
+        if (user.getCompanyId().equals(String.valueOf(CompanyTypeEnum.HEADQUARTERS.getId()))) {
+            user.setCompanyName("总部");
+        } else {
+            String name = companyService.getById(user.getCompanyId()).getName();
+            user.setCompanyName(name);
+        }
+    }
+
+    private List<Permission> getPermissionFromUserRoleId(User user) {
+        LambdaQueryWrapper<RolePermission> rolePermissionLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        rolePermissionLambdaQueryWrapper.eq(RolePermission::getRoleId, user.getRoleId());
+        List<RolePermission> rolePermissionList = rolePermissionService.list(rolePermissionLambdaQueryWrapper);
+        LambdaQueryWrapper<Permission> permissionLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        List<Integer> permissionIds = new ArrayList<>();
+        for (RolePermission rolePermission : rolePermissionList) {
+            Integer permissionId = rolePermission.getPermissionId();
+            permissionIds.add(permissionId);
+        }
+        permissionLambdaQueryWrapper.in(Permission::getId, permissionIds);
+        List<Permission> permissionList = permissionService.list(permissionLambdaQueryWrapper);
+        return permissionList;
+    }
+
+
+    @GetMapping("/index")
+    public String index() {
+        return "index";
+    }
+
+    @GetMapping("/logout")
+    public String logout(HttpSession session) {
+        session.removeAttribute("loginUser");
+        session.removeAttribute("permissions");
+        return "redirect:/login";
+    }
+
+
+}

+ 59 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/MqttController.java

@@ -0,0 +1,59 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.yzt.airconditionersystem.config.MqttOutboundConfig;
+import com.yzt.airconditionersystem.result.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
+import org.springframework.messaging.MessageHandler;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * @author TzZach
+ * @since 2022-05-10 21:20
+ */
+@Controller
+@Slf4j
+public class MqttController {
+
+    @Autowired
+    private MqttOutboundConfig.MyGateway mqttGateway;
+    @Autowired
+    private MessageHandler mqttOutbound;
+
+//    @Autowired
+//    private MqttProducer mqttProducer;
+//
+//    @PostMapping("/send")
+//    @ResponseBody
+//    public Result send(String topic, String data) {
+//
+//        log.info("开始发送mqtt消息,主题:{},消息:{}", topic, data);
+//        if (StringUtils.isNotBlank(topic)) {
+//            mqttProducer.send(topic, data);
+//            log.info("发送mqtt消息完成,主题:{},消息:{}", topic, data);
+//            return Result.success("execute successful");
+//        } else {
+//            return Result.error("topic is blank");
+//        }
+//    }
+
+    @PostMapping("/send")
+    @ResponseBody
+    public Result send(String topic, String data) {
+
+        log.info("开始发送mqtt消息,主题:{},消息:{}", topic, data);
+        if (StringUtils.isNotBlank(topic)) {
+//            mqttProducer.send(topic, data);
+            ((MqttPahoMessageHandler) mqttOutbound).setDefaultTopic(topic);
+            mqttGateway.sendToMqtt(data);
+            log.info("发送mqtt消息完成,主题:{},消息:{}", topic, data);
+            return Result.success("execute successful");
+        } else {
+            return Result.error("topic is blank");
+        }
+    }
+}

+ 148 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/OperatorController.java

@@ -0,0 +1,148 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.yzt.airconditionersystem.bean.Company;
+import com.yzt.airconditionersystem.bean.Operator;
+import com.yzt.airconditionersystem.bean.User;
+import com.yzt.airconditionersystem.enums.CompanyTypeEnum;
+import com.yzt.airconditionersystem.service.CompanyService;
+import com.yzt.airconditionersystem.service.UserService;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.OperatorService;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import com.yzt.airconditionersystem.vo.CompanyVo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author TzZach
+ * @since 2022-04-13 14:51
+ */
+@Slf4j
+@Controller
+public class OperatorController {
+
+    public static final String PREFIX = "operator/";
+
+    @Autowired
+    private CompanyService companyService;
+    @Autowired
+    private OperatorService operatorService;
+    @Autowired
+    private UserService userService;
+
+    @ResponseBody
+    @GetMapping(value = {"/operator/page"})
+    public BasePageVo operatorListPage(@RequestParam("page") Long page,
+                                       @RequestParam("limit") Long limit) {
+        Page<Company> pageInfo = new Page<>(page, limit);
+        pageInfo = companyService.getCompanyPageByType(pageInfo, CompanyTypeEnum.OPERATOR.getId());
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+        return pageVo;
+    }
+
+
+    @GetMapping( "/operator/index")
+    public String operatorList(Model model) {
+        return PREFIX + "operator-list";
+    }
+
+
+    @GetMapping("/operator/edit")
+    public String operatorEdit(@RequestParam("id") String id, Model model) {
+        LambdaQueryWrapper<Company> queryWrapper = new LambdaQueryWrapper();
+        queryWrapper.eq(Company::getId, id);
+        Company company = companyService.getOne(queryWrapper);
+        model.addAttribute("company", company);
+        return PREFIX + "operator-edit";
+    }
+
+    @GetMapping("/operator/add")
+    public String operatorAdd() {
+        return PREFIX + "operator-add";
+    }
+
+    @PostMapping("/operator/add")
+    @ResponseBody
+    public Result addOperator(@RequestBody CompanyVo company) {
+        User user = userService.getOneByUsername(company.getUsername());
+        if (user != null) {
+            return Result.error("该用户名已存在!");
+        }
+        LambdaQueryWrapper<Company> companyLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        companyLambdaQueryWrapper.eq(Company::getName, company.getName());
+        if (companyService.getOne(companyLambdaQueryWrapper) != null) {
+            return Result.error("该公司名称已存在!");
+        }
+        System.out.println(company);
+        company.setType(CompanyTypeEnum.OPERATOR.getId());
+        companyService.save(company);
+        User insertUser = new User(null, company.getUsername(), company.getPassword(),
+                CompanyTypeEnum.OPERATOR.getId(), company.getId());
+        userService.save(insertUser);
+        return Result.success( "添加成功");
+    }
+
+    @PostMapping("/operator/edit")
+    @ResponseBody
+    public Result updateOperator(@RequestBody Company company) {
+//        operatorService.updateById(operator);
+        companyService.updateById(company);
+        return Result.success( "修改成功");
+    }
+
+    @PostMapping("/operator/delete")
+    @ResponseBody
+    public Result deleteOperator(@RequestBody Company company) {
+        companyService.removeById(company.getId());
+        return Result.success( "删除成功");
+    }
+
+    @PostMapping("/operator/batchDelete")
+    @ResponseBody
+    public Result deleteByIds(@RequestBody List<String> ids) {
+        companyService.removeBatchByIds(ids);
+        return Result.success("删除成功");
+    }
+
+    @GetMapping("/operator/search")
+    @ResponseBody
+    public BasePageVo operatorSearch(@RequestParam("page") Long page,
+                                     @RequestParam("limit") Long limit,
+                                     Company operator) {
+        String name = operator.getName();
+        String district = operator.getDistrict();
+        String contact = operator.getContact();
+
+        PageHelper.startPage(Math.toIntExact(page), Math.toIntExact(limit));
+        List<Company> companies = companyService.listByNameAndDistrictAndContact(name, district, contact, CompanyTypeEnum.OPERATOR.getId());
+        int navigatePages = (int) (companies.size() / limit);
+        PageInfo<Company> pageInfo = new PageInfo<>(companies, navigatePages);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+
+        return pageVo;
+    }
+
+    @GetMapping("/operator/detail")
+    @ResponseBody
+    public Result getOperatorById(@RequestParam("id") String id) {
+        LambdaQueryWrapper<Company> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Company::getId, id)
+                        .eq(Company::getType, CompanyTypeEnum.OPERATOR.getId());
+        Company company = companyService.getOne(queryWrapper);
+
+        return Result.success(company);
+    }
+
+}

+ 25 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/OrderController.java

@@ -0,0 +1,25 @@
+package com.yzt.airconditionersystem.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+
+/**
+ * @author TzZach
+ * @since 2022-04-13 11:27
+ */
+@Controller
+public class OrderController {
+
+    public static final String PREFIX = "order/";
+
+    @GetMapping("/order-add")
+    public String orderAdd() {
+        return PREFIX + "order-add";
+    }
+
+    @GetMapping("/order-list")
+    public String orderList() {
+        return PREFIX + "order-list";
+    }
+
+}

+ 116 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/PermissionController.java

@@ -0,0 +1,116 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonParser;
+import com.yzt.airconditionersystem.bean.Permission;
+import com.yzt.airconditionersystem.bean.RolePermission;
+import com.yzt.airconditionersystem.bean.User;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.PermissionService;
+import com.yzt.airconditionersystem.service.RolePermissionService;
+import com.yzt.airconditionersystem.service.RoleService;
+import com.yzt.airconditionersystem.service.UserService;
+import ma.glasnost.orika.MapperFacade;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author TzZach
+ * @since 2022-05-25 21:09
+ */
+@Controller
+public class PermissionController {
+
+    private static final String PREFIX = "permission/";
+
+    @Autowired
+    private PermissionService permissionService;
+    @Autowired
+    private RolePermissionService rolePermissionService;
+    @Autowired
+    private RoleService roleService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private MapperFacade mapperFacade;
+
+    @GetMapping("/permission-add")
+    public String permissionAdd(@RequestParam("parentId") Integer parentId,
+                                Model model) {
+        model.addAttribute("parentId", parentId);
+        return PREFIX + "permission-add";
+    }
+
+    @GetMapping("/permission-edit")
+    public String permissionEdit(@RequestParam("id") Integer id,
+                                 Model model) {
+        Permission permission = permissionService.getById(id);
+        model.addAttribute("permission", permission);
+        return PREFIX + "permission-edit";
+    }
+
+    /**
+     * 获取当前用户所拥有的权限
+     * @param userId
+     * @return
+     */
+    @GetMapping("/permission")
+    @ResponseBody
+    public Result getPermissionByUserId(@RequestParam("id") String userId) {
+        User user = userService.getById(userId);
+        Integer roleId = user.getRoleId();
+        LambdaQueryWrapper<RolePermission> rolePermissionLambdaQueryWrapper
+                = new LambdaQueryWrapper<>();
+        rolePermissionLambdaQueryWrapper.eq(RolePermission::getRoleId, roleId);
+        List<RolePermission> rolePermissionList =
+                rolePermissionService.list(rolePermissionLambdaQueryWrapper);
+        List<Integer> permissionIds = new ArrayList<>();
+        for (RolePermission rolePermission : rolePermissionList) {
+            Integer permissionId = rolePermission.getPermissionId();
+            permissionIds.add(permissionId);
+        }
+        LambdaQueryWrapper<Permission> permissionLambdaQueryWrapper
+                = new LambdaQueryWrapper<>();
+        permissionLambdaQueryWrapper.in(Permission::getId, permissionIds);
+        List<Permission> permissionList = permissionService.list();
+        return Result.success(permissionList);
+    }
+
+    @GetMapping("/permission/tree")
+    @ResponseBody
+    public Result getPermissionTree() {
+        List<Permission> permissionList = permissionService.list();
+        List<Permission> childrenList = permissionList.stream()
+                .filter(permission -> !permission.getParentId().equals(Permission.NO_PARENT))
+                .collect(Collectors.toList());
+//        List<Permission> parentList = mapperFacade.mapAsList(permissionList, Permission.class);
+//        List<Permission> parentList = Arrays.asList(new Permission[permissionList.size()]);
+//        Gson gson = new GsonBuilder().create();
+//        String json = gson.toJson(permissionList);
+        //        Collections.copy(parentList, permissionList);
+//        Permission[] permissions = gson.fromJson(json, Permission[].class);
+//        List<Permission> parentList = Arrays.asList(permissions);
+        for (Permission parent : permissionList) {
+            List<Permission> children = new ArrayList<>();
+            for (Permission child : childrenList) {
+                if (parent.getId().equals(child.getParentId())) {
+                    children.add(child);
+                }
+            }
+            parent.setChildren(children);
+        }
+        return Result.success(permissionList);
+    }
+
+}

+ 134 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/ProjectController.java

@@ -0,0 +1,134 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.yzt.airconditionersystem.bean.Company;
+import com.yzt.airconditionersystem.enums.CompanyTypeEnum;
+import com.yzt.airconditionersystem.service.CompanyService;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import com.yzt.airconditionersystem.bean.Operator;
+import com.yzt.airconditionersystem.bean.Project;
+import com.yzt.airconditionersystem.vo.CompanyVo;
+import com.yzt.airconditionersystem.vo.ProjectSearchVo;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.OperatorService;
+import com.yzt.airconditionersystem.service.ProjectService;
+import com.yzt.airconditionersystem.service.impl.ProjectServiceImpl;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+/**
+ * @author TzZach
+ * @since 2022-04-15 12:00
+ */
+@Controller
+@Slf4j
+public class ProjectController {
+
+    private static final String PREFIX = "project/";
+
+    @Autowired
+    private CompanyService companyService;
+
+
+    @GetMapping("/project-list")
+    public String projectList() {
+        return PREFIX + "project-list";
+    }
+
+    @GetMapping("/project-add")
+    public String projectAdd() {
+        return PREFIX + "project-add";
+    }
+
+    @GetMapping("/project-edit")
+    public String projectEdit(@RequestParam("id") String id,
+                              Model model) {
+        LambdaQueryWrapper<Company> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Company::getType, CompanyTypeEnum.CLIENT.getId())
+                .eq(Company::getId, id);
+        Company company = companyService.getOne(wrapper);
+        model.addAttribute("company", company);
+        return PREFIX + "project-edit";
+    }
+
+    @GetMapping("/project/page")
+    @ResponseBody
+    public BasePageVo projectPage(@RequestParam("page") Long page,
+                                  @RequestParam("limit") Long limit) {
+        Page<Company> pageInfo = new Page<>(page, limit);
+        pageInfo = companyService.getCompanyPageByType(pageInfo, CompanyTypeEnum.CLIENT.getId());
+        List<Company> records = pageInfo.getRecords();
+        for (Company record : records) {
+            record.setOperatorName(companyService.getById(record.getOperatorId()).getName());
+        }
+        return BasePageVoUtil.getPageVo(pageInfo);
+    }
+
+    @PostMapping("/project/delete")
+    @ResponseBody
+    public Result deleteProject(@RequestBody Company company) {
+        companyService.removeById(company);
+        return Result.success();
+    }
+
+    @PostMapping("/project/add")
+    @ResponseBody
+    public Result addProject(@RequestBody Company company) {
+        companyService.save(company);
+        return Result.success();
+    }
+
+    @PostMapping("/project/batchDelete")
+    @ResponseBody
+    public Result deleteProjectsByIds(@RequestBody List<String> ids) {
+        companyService.removeBatchByIds(ids);
+        return Result.success();
+    }
+
+
+    @GetMapping("/project/search")
+    @ResponseBody
+    public BasePageVo searchProjects(@RequestParam("page") Long page,
+                                 @RequestParam("limit") Long limit,
+                                 CompanyVo projectSearchVo) {
+
+        String clientName = projectSearchVo.getClientName();
+        String district = projectSearchVo.getDistrict();
+        String operatorName = projectSearchVo.getOperatorName();
+
+        PageHelper.startPage(Math.toIntExact(page), Math.toIntExact(limit));
+        List<Company> companies =
+                companyService.listByNameAndDistrictAndOperatorName(clientName, district, operatorName,
+                        CompanyTypeEnum.CLIENT.getId());
+        int navigatePages = (int) (companies.size() / limit);
+        PageInfo<Company> pageInfo = new PageInfo<>(companies, navigatePages);
+        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
+
+        log.info(companies.toString());
+
+        return pageVo;
+    }
+
+    @GetMapping("/project/detail")
+    @ResponseBody
+    public Result projectDetail(@RequestParam("id") String id) {
+        LambdaQueryWrapper<Company> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Company::getId, id)
+                .eq(Company::getType, CompanyTypeEnum.CLIENT.getId());
+        Company client = companyService.getOne(queryWrapper);
+        Company operator = companyService.getById(client.getOperatorId());
+        client.setOperator(operator);
+        return Result.success(client);
+    }
+
+
+}

+ 229 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/RoleController.java

@@ -0,0 +1,229 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageInfo;
+import com.yzt.airconditionersystem.bean.Permission;
+import com.yzt.airconditionersystem.bean.Role;
+import com.yzt.airconditionersystem.bean.RolePermission;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.PermissionService;
+import com.yzt.airconditionersystem.service.RolePermissionService;
+import com.yzt.airconditionersystem.service.RoleService;
+import com.yzt.airconditionersystem.util.BasePageVoUtil;
+import com.yzt.airconditionersystem.vo.BasePageVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author TzZach
+ * @since 2022-05-09 12:26
+ */
+@Controller
+public class RoleController {
+
+    private static final String PREFIX = "role/";
+
+    @Autowired
+    private RoleService roleService;
+    @Autowired
+    private PermissionService permissionService;
+    @Autowired
+    private RolePermissionService rolePermissionService;
+
+    @GetMapping("/role/page")
+    @ResponseBody
+    public BasePageVo rolePage(@RequestParam("page") Long page,
+                               @RequestParam("limit") Long limit) {
+//        List<RolePermission> list = rolePermissionService.list();
+//        Page<Role> pageInfo = new Page<>(page, limit);
+//        pageInfo = roleService.page(pageInfo);
+//        for (Role record : pageInfo.getRecords()) {
+//            Integer id = record.getId();
+//            permissionService.list();
+//        }
+
+        List<RolePermission> rolePermissions = rolePermissionService.list();
+        Page<Role> pageInfo = new Page<>(page, limit);
+        pageInfo = roleService.page(pageInfo);
+        for (Role role : pageInfo.getRecords()) {
+            Integer roleId = role.getId();
+            for (RolePermission rolePermission : rolePermissions) {
+                if (roleId.equals(rolePermission.getRoleId())) {
+                    LambdaQueryWrapper<Permission> permissionLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    permissionLambdaQueryWrapper.eq(Permission::getId, rolePermission.getPermissionId());
+                    Permission permission = permissionService.getOne(permissionLambdaQueryWrapper);
+                    if (!StringUtils.hasLength(role.getPermissionName())) {
+                        role.setPermissionName(permission.getName());
+                    } else {
+                        String permissionName = role.getPermissionName() + "," + permission.getName();
+                        role.setPermissionName(permissionName);
+                    }
+                }
+            }
+        }
+        return BasePageVoUtil.getPageVo(pageInfo);
+    }
+
+    @PostMapping("/role/delete")
+    @ResponseBody
+    public Result roleDelete(@RequestBody Role role) {
+        roleService.removeById(role);
+        LambdaQueryWrapper<RolePermission> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(RolePermission::getRoleId, role.getId());
+        rolePermissionService.remove(queryWrapper);
+        return Result.success("删除成功");
+    }
+
+    @GetMapping("/role/index")
+    public String roleAdd() {
+        return PREFIX + "role-add";
+    }
+
+    @PostMapping("/role/add")
+    @ResponseBody
+    public Result addRole(@RequestBody Role role) {
+        LambdaQueryWrapper<Role> roleLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        roleLambdaQueryWrapper.eq(Role::getName, role.getName());
+        Role fromDb = roleService.getOne(roleLambdaQueryWrapper);
+        if (fromDb != null) {
+            return Result.error("该角色名称已存在!");
+        }
+        roleService.save(role);
+        Map<String, Object> data = new HashMap<>(2);
+        data.put("data", "添加成功");
+        data.put("roleId", role.getId());
+        return Result.success(data);
+    }
+
+//    @PostMapping("/role/permission/add")
+//    @ResponseBody
+//    public Result rolePermissionAdd(@RequestBody RolePermission rolePermission) {
+//        rolePermissionService.save(rolePermission);
+//        return Result.success("添加角色相关权限成功");
+//    }
+
+    @PostMapping("/role/batchDelete")
+    @ResponseBody
+    public Result roleBatchDelete(@RequestBody List<String> ids) {
+        roleService.removeBatchByIds(ids);
+        return Result.success("删除成功");
+    }
+
+    @GetMapping("/role-edit")
+    public String roleEdit(@RequestParam("id") Integer roleId,
+                           Model model) {
+        Role role = roleService.getById(roleId);
+        model.addAttribute("role", role);
+        return PREFIX + "role-edit";
+    }
+
+    @PostMapping("/role/edit")
+    @ResponseBody
+    public Result editRole(@RequestBody Role role) {
+        Integer roleId = role.getId();
+        Role roleFromDb = roleService.getById(roleId);
+        if (role.getName().equals(roleFromDb.getName())) {
+            return Result.success(roleId);
+        }
+        roleService.updateById(role);
+        return Result.success(roleId);
+    }
+
+    @PostMapping("/role/tree")
+    @ResponseBody
+    public Result rolePermissionTree(@RequestBody Integer roleId) {
+        LambdaQueryWrapper<RolePermission> rolePermissionLambdaQueryWrapper
+                = new LambdaQueryWrapper<>();
+        rolePermissionLambdaQueryWrapper.eq(RolePermission::getRoleId, roleId)
+                .select(RolePermission::getPermissionId);
+        List<Object> permissionIds = rolePermissionService.listObjs(rolePermissionLambdaQueryWrapper);
+//        LambdaQueryWrapper<Permission> permissionLambdaQueryWrapper
+//                = new LambdaQueryWrapper<>();
+//        permissionLambdaQueryWrapper.in(Permission::getId, permissionIds);
+//        List<Permission> permissions = permissionService.list(permissionLambdaQueryWrapper);
+        List<Permission> permissions = permissionService.list();
+
+        for (Permission permission : permissions) {
+            if (permissionIds.contains(permission.getId())) {
+                permission.setChecked(true);
+            }
+        }
+
+        List<Permission> childrenList = permissions.stream()
+                .filter(permission -> !permission.getParentId().equals(Permission.NO_PARENT))
+                .collect(Collectors.toList());
+
+        for (Permission parent : permissions) {
+            parent.setTitle(parent.getName());
+            List<Permission> children = new ArrayList<>();
+            for (Permission child : childrenList) {
+                if (parent.getId().equals(child.getParentId())) {
+                    children.add(child);
+                }
+            }
+            parent.setChildren(children);
+        }
+
+        permissions = permissions.stream()
+                .filter(permission -> permission.getParentId().equals(Permission.NO_PARENT))
+                .collect(Collectors.toList());
+
+        return Result.success(permissions);
+    }
+
+    @PostMapping("/role/tree/all")
+    @ResponseBody
+    public Result rolePermissionTree() {
+//        LambdaQueryWrapper<RolePermission> rolePermissionLambdaQueryWrapper
+//                = new LambdaQueryWrapper<>();
+//        rolePermissionLambdaQueryWrapper.eq(RolePermission::getRoleId, roleId)
+//                .select(RolePermission::getPermissionId);
+//        List<Object> permissionIds = rolePermissionService.listObjs(rolePermissionLambdaQueryWrapper);
+//        LambdaQueryWrapper<Permission> permissionLambdaQueryWrapper
+//                = new LambdaQueryWrapper<>();
+//        permissionLambdaQueryWrapper.in(Permission::getId, permissionIds);
+//        List<Permission> permissions = permissionService.list(permissionLambdaQueryWrapper);
+        List<Permission> permissions = permissionService.list();
+
+//        for (Permission permission : permissions) {
+//            if (permissionIds.contains(permission.getId())) {
+//                permission.setChecked(true);
+//            }
+//        }
+
+        List<Permission> childrenList = permissions.stream()
+                .filter(permission -> !permission.getParentId().equals(Permission.NO_PARENT))
+                .collect(Collectors.toList());
+
+        for (Permission parent : permissions) {
+            parent.setTitle(parent.getName());
+            List<Permission> children = new ArrayList<>();
+            for (Permission child : childrenList) {
+                if (parent.getId().equals(child.getParentId())) {
+                    children.add(child);
+                }
+            }
+            parent.setChildren(children);
+        }
+
+        permissions = permissions.stream()
+                .filter(permission -> permission.getParentId().equals(Permission.NO_PARENT))
+                .collect(Collectors.toList());
+
+        return Result.success(permissions);
+    }
+
+
+
+
+}

+ 102 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/RolePermissionController.java

@@ -0,0 +1,102 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.yzt.airconditionersystem.bean.Permission;
+import com.yzt.airconditionersystem.bean.RolePermission;
+import com.yzt.airconditionersystem.bean.User;
+import com.yzt.airconditionersystem.bean.dto.RolePermissionDTO;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.RolePermissionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author TzZach
+ * @since 2022-06-24 17:34
+ */
+@Controller
+public class RolePermissionController {
+
+    @Autowired
+    private RolePermissionService rolePermissionService;
+
+    @PostMapping("/role/permission/add")
+    @ResponseBody
+    public Result addRolePermission(@RequestBody RolePermissionDTO rolePermissionDTO) {
+        List<Integer> permissionIds = new ArrayList<>();
+        iteratePermissions(rolePermissionDTO.getPermissions(), permissionIds);
+        List<RolePermission> rolePermissionList = new ArrayList<>();
+        for (Integer permissionId : permissionIds) {
+            RolePermission rolePermission = new RolePermission();
+            rolePermission.setRoleId(rolePermissionDTO.getRoleId());
+            rolePermission.setPermissionId(permissionId);
+            rolePermissionList.add(rolePermission);
+        }
+        rolePermissionService.saveBatch(rolePermissionList);
+        return Result.success("添加成功");
+    }
+
+    @PostMapping("/role/permission/edit")
+    @ResponseBody
+    public Result editRolePermission(@RequestBody RolePermissionDTO rolePermissionDTO) {
+        Integer roleId = rolePermissionDTO.getRoleId();
+        List<Integer> checkedIds = new ArrayList<>();
+        iteratePermissions(rolePermissionDTO.getPermissions(), checkedIds);
+        LambdaQueryWrapper<RolePermission> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(RolePermission::getRoleId, roleId);
+        List<RolePermission> rolePermissions = rolePermissionService.list(queryWrapper);
+        List<Integer> permissionsIds = rolePermissions.stream()
+                .map(rolePermission -> rolePermission.getPermissionId())
+                .collect(Collectors.toList());
+        //需要插入到数据库的permissionId
+        List<Integer> insertIds = checkedIds.stream()
+                .filter(id -> !permissionsIds.contains(id))
+                .collect(Collectors.toList());
+        List<RolePermission> insertRolePermission = insertIds.stream()
+                .map(permissionId -> {
+                    RolePermission rolePermission = new RolePermission();
+                    rolePermission.setRoleId(roleId);
+                    rolePermission.setPermissionId(permissionId);
+                    return rolePermission;
+                })
+                .collect(Collectors.toList());
+        //需要从数据库中删除的permissionId
+        List<Integer> removeIds = permissionsIds.stream()
+                .filter(id -> !checkedIds.contains(id))
+                .collect(Collectors.toList());
+        if (!insertRolePermission.isEmpty()) {
+            rolePermissionService.saveBatch(insertRolePermission);
+        }
+        if (!removeIds.isEmpty()) {
+            queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(RolePermission::getRoleId, roleId)
+                    .in(RolePermission::getPermissionId, removeIds);
+            rolePermissionService.remove(queryWrapper);
+        }
+        return Result.success("修改成功");
+    }
+
+    /**
+     * 获取被选中的节点及其子节点的id
+     * @param permissions
+     * @param ids
+     */
+    private void iteratePermissions(List<Permission> permissions, List<Integer> ids) {
+        for (Permission permission : permissions) {
+            if (permission.getChildren() != null) {
+                iteratePermissions(permission.getChildren(), ids);
+            }
+            ids.add(permission.getId());
+        }
+    }
+
+
+}

+ 91 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/UserController.java

@@ -0,0 +1,91 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.yzt.airconditionersystem.bean.Company;
+import com.yzt.airconditionersystem.bean.Role;
+import com.yzt.airconditionersystem.bean.User;
+import com.yzt.airconditionersystem.enums.CompanyTypeEnum;
+import com.yzt.airconditionersystem.result.Result;
+import com.yzt.airconditionersystem.service.CompanyService;
+import com.yzt.airconditionersystem.service.RoleService;
+import com.yzt.airconditionersystem.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpSession;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author TzZach
+ * @since 2022-05-11 23:03
+ */
+@Controller
+public class UserController {
+
+    private static final String PREFIX = "user/";
+
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private CompanyService companyService;
+
+    @GetMapping("/user/info")
+    public String userInfo(HttpSession session, Model model) {
+        User loginUser = (User) session.getAttribute("loginUser");
+        String companyId = loginUser.getCompanyId();
+        Company company = companyService.getById(companyId);
+        fillUserWithCompanyInfo(loginUser, company);
+        model.addAttribute("loginUser", loginUser);
+        return PREFIX + "user-info";
+    }
+
+    private void fillUserWithCompanyInfo(User loginUser, Company company) {
+        loginUser.setContact(company.getContact());
+        loginUser.setPhone(company.getPhone());
+        loginUser.setDistrict(company.getDistrict());
+        loginUser.setDetailedAddress(company.getDetailedAddress());
+        loginUser.setCompanyName(company.getName());
+    }
+
+    @GetMapping("/mobile/user/info")
+    @ResponseBody
+    public Result userInfo(@RequestParam("id") String id) {
+        User user = userService.getById(id);
+        Company company = companyService.getById(user.getCompanyId());
+        fillUserWithCompanyInfo(user, company);
+        return Result.success(user);
+    }
+
+    @PostMapping("/user/info")
+    @ResponseBody
+    public Result userInfoUpdate(User user) {
+        userService.updateById(user);
+        return Result.success();
+    }
+
+    @GetMapping("/user/password")
+    public String userPassword() {
+        return PREFIX + "user-password";
+    }
+
+    @PostMapping("/user/password")
+    @ResponseBody
+    public Result updatePassword(@RequestBody User user) {
+        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(User::getId, user.getId())
+                        .eq(User::getPassword, user.getPassword());
+        User getUser = userService.getOne(queryWrapper);
+        if (getUser == null) {
+            return Result.error("原密码错误");
+        }
+        User updateUser = new User();
+        updateUser.setId(user.getId());
+        updateUser.setPassword(user.getNewPassword());
+        userService.updateById(updateUser);
+        return Result.success("修改成功");
+    }
+
+}

+ 109 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/controller/WebController.java

@@ -0,0 +1,109 @@
+package com.yzt.airconditionersystem.controller;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonParser;
+import com.yzt.airconditionersystem.bean.Operator;
+import com.yzt.airconditionersystem.result.Result;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.json.GsonJsonParser;
+import org.springframework.http.converter.json.GsonBuilderUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author TzZach
+ * @since 2022-04-14 0:22
+ */
+@Controller
+public class WebController {
+
+//    @Autowired
+//    private MessageChannel mqttOutboundChannel;
+
+    @GetMapping("/unicode")
+    public String unicode() {
+        return "unicode";
+    }
+
+    @GetMapping("/member-list")
+    public String memberList() {
+        return "member-list";
+    }
+
+    @GetMapping("/blank")
+    public String blank() {
+        return "blank";
+    }
+
+    @GetMapping("/echarts1")
+    public String echarts1() {
+        return "echarts1";
+    }
+
+    @GetMapping("/echarts2")
+    public String echarts2() {
+        return "echarts2";
+    }
+
+    @GetMapping("/echarts3")
+    public String echarts3() {
+        return "echarts4";
+    }
+
+    @GetMapping("/echarts5")
+    public String echarts5() {
+        return "echarts5";
+    }
+
+    @GetMapping("/echarts6")
+    public String echarts6() {
+        return "echarts6";
+    }
+
+    @GetMapping("/echarts7")
+    public String echarts7() {
+        return "echarts7";
+    }
+
+    @GetMapping("/echarts8")
+    public String echarts8() {
+        return "echarts8";
+    }
+
+//    @GetMapping("/send/{msg}")
+//    @ResponseBody
+//    public Result sendMsg(@PathVariable("msg") String msg) {
+//        System.out.println(msg);
+//        Operator operator = new Operator(1, "张三", "张三公司", "广东省广州市", "海珠区", "联系人就是张三", "1329852852");
+//        Gson gson = new GsonBuilder().create();
+//        String json = gson.toJson(operator);
+//        Message<String> message = new Message<String>() {
+//            @Override
+//            public String getPayload() {
+//                return json;
+//            }
+//
+//            @Override
+//            public MessageHeaders getHeaders() {
+//                Map<String, Object> map = new HashMap<>(1);
+//                map.put("message", msg);
+//                return new MessageHeaders(map);
+//            }
+//        };
+//        mqttOutboundChannel.send(message);
+//        return Result.success(msg);
+//    }
+
+
+}

+ 47 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/enums/AlarmStatusEnum.java

@@ -0,0 +1,47 @@
+package com.yzt.airconditionersystem.enums;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import lombok.Data;
+
+/**
+ * @author TzZach
+ * @since 2022-04-24 21:11
+ */
+public enum AlarmStatusEnum {
+
+//    public static final Integer UNHANDLED = 0;
+//    public static final Integer HANDLED = 1;
+
+    UNHANDLED(0, "未处理"),
+    HANDLED(1, "已处理");
+
+    @EnumValue
+    private Integer status;
+    private String info;
+
+    AlarmStatusEnum(Integer status, String info) {
+        this.status = status;
+        this.info = info;
+    }
+
+    public Integer getStatus() {
+        return this.status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+
+    public void setInfo(String info) {
+        this.info = info;
+    }
+
+    @Override
+    public String toString() {
+        return info;
+    }
+}

+ 35 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/enums/CompanyTypeEnum.java

@@ -0,0 +1,35 @@
+package com.yzt.airconditionersystem.enums;
+
+/**
+ * @author TzZach
+ * @since 2022-05-07 12:01
+ */
+public enum CompanyTypeEnum {
+    HEADQUARTERS(1, "总部"),
+    OPERATOR(2, "运营商"),
+    CLIENT(3, "普通客户");
+
+    private Integer id;
+    private String type;
+
+    CompanyTypeEnum(int id, String type) {
+        this.id = id;
+        this.type = type;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+}

+ 26 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/interceptor/LoginInterceptor.java

@@ -0,0 +1,26 @@
+package com.yzt.airconditionersystem.interceptor;
+
+import com.yzt.airconditionersystem.bean.User;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author TzZach
+ * @since 2022-04-09 12:38
+ */
+@Slf4j
+public class LoginInterceptor implements HandlerInterceptor {
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        Object loginUser = request.getSession().getAttribute("loginUser");
+        if (loginUser != null) {
+            return true;
+        }
+        response.sendRedirect("/login");
+        return false;
+    }
+}

+ 57 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/interceptor/SSHListener.java

@@ -0,0 +1,57 @@
+package com.yzt.airconditionersystem.interceptor;
+
+import com.yzt.airconditionersystem.bean.ssh.SSHConnection;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
+
+/**
+ * @author TzZach
+ * @since 2022-05-25 18:27
+ */
+@WebListener
+@Component
+public class SSHListener implements ServletContextListener {
+
+    private SSHConnection conexionssh;
+
+//    public MyContextListener() {
+//        super();
+//    }
+    /**
+     * @see ServletContextListener#contextInitialized(ServletContextEvent)
+     */
+    @Override
+    public void contextInitialized(ServletContextEvent arg0) {
+        // 建立连接
+        System.out.println("Context initialized ... !\n\n\n");
+        try {
+            conexionssh = new SSHConnection();
+            conexionssh.SSHConnection();
+            System.out.println("\n\n\n成功建立SSH连接!\n\n\n");
+        } catch (Throwable e) {
+            System.out.println("\n\n\nSSH连接失败!\n\n\n");
+            e.printStackTrace(); // error connecting SSH server
+        }
+    }
+    /**
+     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
+     */
+    @Override
+    public void contextDestroyed(ServletContextEvent arg0) {
+        // 断开连接
+        System.out.println("Context destroyed ... !\n\n\n");
+        try {
+            conexionssh.closeSSH(); // disconnect
+            System.out.println("\n\n\n成功断开SSH连接!\n\n\n");
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.out.println("\n\n\n断开SSH连接出错!\n\n\n");
+        }
+    }
+
+
+
+}

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/AlarmMapper.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.Alarm;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【alarm】的数据库操作Mapper
+* @createDate 2022-04-24 20:48:02
+* @Entity com.yzt.airconditionersystem.bean.Alarm
+*/
+public interface AlarmMapper extends BaseMapper<Alarm> {
+
+}
+
+
+
+

+ 28 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/CompanyMapper.java

@@ -0,0 +1,28 @@
+package com.yzt.airconditionersystem.mapper;
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+
+import com.yzt.airconditionersystem.bean.Company;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【company】的数据库操作Mapper
+* @createDate 2022-05-07 11:50:06
+* @Entity com.yzt.airconditionersystem.bean.Company
+*/
+public interface CompanyMapper extends BaseMapper<Company> {
+
+    List<Company> listByNameAndDistrictAndOperatorName(@Param("name") String name, @Param("district") String district, @Param("operatorName") String operatorName, @Param("type") Integer type);
+
+    List<Company> listByNameAndDistrictAndContact(@Param("name") String name, @Param("district") String district, @Param("contact") String contact, @Param("type") Integer type);
+
+    Page<Company> selectAll(Page<Company> page);
+
+}
+
+
+
+

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/DeviceDataMapper.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.DeviceData;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【device_data】的数据库操作Mapper
+* @createDate 2022-05-12 11:03:34
+* @Entity com.yzt.airconditionersystem.bean.DeviceData
+*/
+public interface DeviceDataMapper extends BaseMapper<DeviceData> {
+
+}
+
+
+
+

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/DeviceMapper.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.Device;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【device】的数据库操作Mapper
+* @createDate 2022-05-12 11:03:14
+* @Entity com.yzt.airconditionersystem.bean.Device
+*/
+public interface DeviceMapper extends BaseMapper<Device> {
+
+}
+
+
+
+

+ 23 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/FacilityAlarmMapper.java

@@ -0,0 +1,23 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.FacilityAlarm;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import java.util.List;
+
+/**
+* @author TzZach
+* @description 针对表【facility_alarm】的数据库操作Mapper
+* @createDate 2022-05-04 17:27:28
+* @Entity com.yzt.airconditionersystem.bean.FacilityAlarm
+*/
+public interface FacilityAlarmMapper extends BaseMapper<FacilityAlarm> {
+
+
+    public List<FacilityAlarm> selectByGatewayIdAndCompanyId(List<String> companyIds);
+
+}
+
+
+
+

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/GatewayMapper.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.Gateway;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【gateway】的数据库操作Mapper
+* @createDate 2022-05-12 16:37:48
+* @Entity com.yzt.airconditionersystem.bean.Gateway
+*/
+public interface GatewayMapper extends BaseMapper<Gateway> {
+
+}
+
+
+
+

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/LogMapper.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.Log;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【log】的数据库操作Mapper
+* @createDate 2022-05-03 00:08:26
+* @Entity com.yzt.airconditionersystem.bean.Log
+*/
+public interface LogMapper extends BaseMapper<Log> {
+
+}
+
+
+
+

+ 16 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/OperatorMapper.java

@@ -0,0 +1,16 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yzt.airconditionersystem.bean.Operator;
+
+/**
+ * 运营商操作类
+ * @author TzZach
+ * @since 2022-04-13 12:06
+ */
+public interface OperatorMapper extends BaseMapper<Operator> {
+
+    public Operator getOne(Operator operator);
+
+
+}

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/PermissionMapper.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.Permission;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【permission】的数据库操作Mapper
+* @createDate 2022-04-23 18:05:12
+* @Entity com.yzt.airconditionersystem.bean.Permission
+*/
+public interface PermissionMapper extends BaseMapper<Permission> {
+
+}
+
+
+
+

+ 20 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/ProjectMapper.java

@@ -0,0 +1,20 @@
+package com.yzt.airconditionersystem.mapper;
+import org.apache.ibatis.annotations.Param;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yzt.airconditionersystem.bean.Project;
+
+import java.util.List;
+
+/**
+ * @author TzZach
+ * @since 2022-04-15 16:40
+ */
+public interface ProjectMapper extends BaseMapper<Project> {
+
+    public List<Project> selectByClientNameAndDistrictAndCompanyName(String clientName, String district, String operatorName);
+
+    List<Integer> selectIdByOperatorId(@Param("operatorId") Integer operatorId);
+
+
+}

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/RoleMapper.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.Role;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【role】的数据库操作Mapper
+* @createDate 2022-04-23 18:05:50
+* @Entity com.yzt.airconditionersystem.bean.Role
+*/
+public interface RoleMapper extends BaseMapper<Role> {
+
+}
+
+
+
+

+ 18 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/RolePermissionMapper.java

@@ -0,0 +1,18 @@
+package com.yzt.airconditionersystem.mapper;
+
+import com.yzt.airconditionersystem.bean.RolePermission;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【role_permission】的数据库操作Mapper
+* @createDate 2022-05-09 12:47:43
+* @Entity com.yzt.airconditionersystem.bean.RolePermission
+*/
+public interface RolePermissionMapper extends BaseMapper<RolePermission> {
+
+}
+
+
+
+

+ 35 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/mapper/UserMapper.java

@@ -0,0 +1,35 @@
+package com.yzt.airconditionersystem.mapper;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+
+import com.yzt.airconditionersystem.bean.User;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author TzZach
+* @description 针对表【user】的数据库操作Mapper
+* @createDate 2022-05-07 15:44:23
+* @Entity com.yzt.airconditionersystem.bean.User
+*/
+public interface UserMapper extends BaseMapper<User> {
+
+    /**
+     * 根据用户名和密码查找
+     * @param username
+     * @param password
+     * @return
+     */
+    User selectOneByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
+
+    /**
+     * 根据用户名查找
+     * @param username
+     * @return
+     */
+    User selectOneByUsername(@Param("username") String username);
+
+}
+
+
+
+

+ 72 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/result/Result.java

@@ -0,0 +1,72 @@
+package com.yzt.airconditionersystem.result;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author TzZach
+ * @since 2022-04-13 21:44
+ */
+public class Result extends HashMap<String, Object> {
+
+    public static final Integer SUCCESS_CODE = 0;
+    public static final Integer ERROR_CODE = 1;
+
+    public static final String SUCCESS_MSG = "成功";
+    public static final String ERROR_MSG = "失败";
+
+    private static final String CODE = "code";
+    private static final String MSG = "msg";
+    private static final String DATA = "data";
+
+    private String code;
+    private String msg;
+    private Object data;
+
+
+    public Result(Integer code, String msg, Object data) {
+        put(CODE, code);
+        put(MSG, msg);
+        if(data != null) {
+            put(DATA, data);
+        }
+    }
+
+    public static Result success() {
+        return new Result(SUCCESS_CODE, SUCCESS_MSG, null);
+    }
+
+    public static Result success(Object data) {
+        return new Result(SUCCESS_CODE, SUCCESS_MSG, data);
+    }
+
+    public static Result success(Integer code, String msg) {
+        return new Result(code, msg, null);
+    }
+
+    public static Result success(Integer code, String msg, Object data) {
+        return new Result(code, msg, data);
+    }
+
+
+    public static Result error() {
+        return new Result(ERROR_CODE, ERROR_MSG, null);
+    }
+
+    public static Result error(Object data) {
+        return new Result(ERROR_CODE, ERROR_MSG, data);
+    }
+
+    public static Result error(Integer code, String msg) {
+        return new Result(code, msg, null);
+    }
+
+    public static Result error(Integer code, String msg, Object data) {
+        return new Result(code, msg, data);
+    }
+
+
+
+}

+ 13 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/AlarmService.java

@@ -0,0 +1,13 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.Alarm;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author TzZach
+* @description 针对表【alarm】的数据库操作Service
+* @createDate 2022-04-24 20:48:02
+*/
+public interface AlarmService extends IService<Alarm> {
+
+}

+ 56 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/CompanyService.java

@@ -0,0 +1,56 @@
+package com.yzt.airconditionersystem.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.yzt.airconditionersystem.bean.Company;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yzt.airconditionersystem.bean.Project;
+import com.yzt.airconditionersystem.enums.CompanyTypeEnum;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+* @author TzZach
+* @description 针对表【company】的数据库操作Service
+* @createDate 2022-05-07 11:50:06
+*/
+public interface CompanyService extends IService<Company> {
+
+    /**
+     * 根据公司类型获取
+     * @param page
+     * @param type
+     * @return
+     */
+    public Page<Company> getCompanyPageByType(Page<Company> page, Integer type);
+
+    /**
+     * 根据公司类型和运营商id获取
+     * @param page
+     * @param type
+     * @param operatorId
+     * @return
+     */
+    public Page<Company> getCompanyPageByType(Page<Company> page, Integer type, String operatorId);
+
+
+
+    /**
+     * 通过公司名字、地区、运营商名字查找
+     * @param name
+     * @param district
+     * @param operatorName
+     * @return
+     */
+    List<Company> listByNameAndDistrictAndOperatorName(String name, String district, String operatorName, Integer type);
+
+    /**
+     * 通过公司名称、地区、联系人查找
+     * @param name
+     * @param district
+     * @param contact
+     * @param type
+     * @return
+     */
+    List<Company> listByNameAndDistrictAndContact(String name, String district, String contact, Integer type);
+}

+ 13 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/DeviceDataService.java

@@ -0,0 +1,13 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.DeviceData;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author TzZach
+* @description 针对表【device_data】的数据库操作Service
+* @createDate 2022-05-12 11:03:34
+*/
+public interface DeviceDataService extends IService<DeviceData> {
+
+}

+ 13 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/DeviceService.java

@@ -0,0 +1,13 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.Device;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author TzZach
+* @description 针对表【device】的数据库操作Service
+* @createDate 2022-05-12 11:03:14
+*/
+public interface DeviceService extends IService<Device> {
+
+}

+ 17 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/FacilityAlarmService.java

@@ -0,0 +1,17 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.FacilityAlarm;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+* @author TzZach
+* @description 针对表【facility_alarm】的数据库操作Service
+* @createDate 2022-05-04 17:27:28
+*/
+public interface FacilityAlarmService extends IService<FacilityAlarm> {
+
+    public List<FacilityAlarm> selectByGatewayIdAndCompanyId(List<String> companyIds);
+
+}

+ 13 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/GatewayService.java

@@ -0,0 +1,13 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.Gateway;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author TzZach
+* @description 针对表【gateway】的数据库操作Service
+* @createDate 2022-05-12 16:37:48
+*/
+public interface GatewayService extends IService<Gateway> {
+
+}

+ 13 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/LogService.java

@@ -0,0 +1,13 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.Log;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author TzZach
+* @description 针对表【log】的数据库操作Service
+* @createDate 2022-05-03 00:08:26
+*/
+public interface LogService extends IService<Log> {
+
+}

+ 19 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/MqttService.java

@@ -0,0 +1,19 @@
+package com.yzt.airconditionersystem.service;
+
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.springframework.messaging.Message;
+
+/**
+ * @author TzZach
+ * @since 2022-05-10 22:52
+ */
+public interface MqttService {
+
+    /**
+     * 将消息发送到对应的topic
+     * @param topic
+     * @param message
+     */
+    void receiveFrom(String topic, Message message) throws IllegalAccessException;
+
+}

+ 24 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/OperatorService.java

@@ -0,0 +1,24 @@
+package com.yzt.airconditionersystem.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yzt.airconditionersystem.bean.Operator;
+
+import java.util.Map;
+
+/**
+ * 运营商业务类
+ * @author TzZach
+ * @since 2022-04-13 12:07
+ */
+public interface OperatorService extends IService<Operator> {
+
+    public Operator getOneByOperator(Operator operator);
+
+    /**
+     * 删除该运营商及其相关的项目、网关
+     * @return
+     */
+    public Map<String, Object> deleteOperatorById(Integer id);
+
+}

+ 13 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/PermissionService.java

@@ -0,0 +1,13 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.Permission;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author TzZach
+* @description 针对表【permission】的数据库操作Service
+* @createDate 2022-04-23 18:05:12
+*/
+public interface PermissionService extends IService<Permission> {
+
+}

+ 16 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/ProjectService.java

@@ -0,0 +1,16 @@
+package com.yzt.airconditionersystem.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yzt.airconditionersystem.bean.Project;
+
+import java.util.List;
+
+/**
+ * @author TzZach
+ * @since 2022-04-15 16:41
+ */
+public interface ProjectService extends IService<Project> {
+
+    public List<Integer> selectIdByOperatorId(Integer operatorId);
+
+}

+ 13 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/RolePermissionService.java

@@ -0,0 +1,13 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.RolePermission;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author TzZach
+* @description 针对表【role_permission】的数据库操作Service
+* @createDate 2022-05-09 12:47:43
+*/
+public interface RolePermissionService extends IService<RolePermission> {
+
+}

+ 20 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/RoleService.java

@@ -0,0 +1,20 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.Role;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author TzZach
+* @description 针对表【role】的数据库操作Service
+* @createDate 2022-04-23 18:05:50
+*/
+public interface RoleService extends IService<Role> {
+
+    /**
+     * 插入并返回id
+     * @param role
+     * @return
+     */
+    public int insert(Role role);
+
+}

+ 29 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/UserService.java

@@ -0,0 +1,29 @@
+package com.yzt.airconditionersystem.service;
+
+import com.yzt.airconditionersystem.bean.User;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+* @author TzZach
+* @description 针对表【user】的数据库操作Service
+* @createDate 2022-05-07 15:44:23
+*/
+public interface UserService extends IService<User> {
+
+    /**
+     * 通过用户名和密码查找
+     * @param user
+     * @return
+     */
+    public User getOneByUsernameAndPassword(User user);
+
+    /**
+     * 通过用户名查找
+     * @param username
+     * @return
+     */
+    public User getOneByUsername(String username);
+
+}

+ 22 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/AlarmServiceImpl.java

@@ -0,0 +1,22 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.Alarm;
+import com.yzt.airconditionersystem.service.AlarmService;
+import com.yzt.airconditionersystem.mapper.AlarmMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author TzZach
+* @description 针对表【alarm】的数据库操作Service实现
+* @createDate 2022-04-24 20:48:02
+*/
+@Service
+public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm>
+    implements AlarmService{
+
+}
+
+
+
+

+ 52 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/CompanyServiceImpl.java

@@ -0,0 +1,52 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.Company;
+import com.yzt.airconditionersystem.bean.Project;
+import com.yzt.airconditionersystem.service.CompanyService;
+import com.yzt.airconditionersystem.mapper.CompanyMapper;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+* @author TzZach
+* @description 针对表【company】的数据库操作Service实现
+* @createDate 2022-05-07 11:50:06
+*/
+@Service
+public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company>
+    implements CompanyService{
+
+    @Override
+    public Page<Company> getCompanyPageByType(Page<Company> page, Integer type) {
+        LambdaQueryWrapper<Company> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Company::getType, type);
+        return baseMapper.selectPage(page, wrapper);
+    }
+
+    @Override
+    public Page<Company> getCompanyPageByType(Page<Company> page, Integer type, String operatorId) {
+        LambdaQueryWrapper<Company> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Company::getType, type);
+        wrapper.eq(Company::getOperatorId, operatorId);
+        return baseMapper.selectPage(page, wrapper);
+    }
+
+    @Override
+    public List<Company> listByNameAndDistrictAndOperatorName(String name, String district, String operatorName, Integer type) {
+        return baseMapper.listByNameAndDistrictAndOperatorName(name, district, operatorName, type);
+    }
+
+    @Override
+    public List<Company> listByNameAndDistrictAndContact(String name, String district, String contact, Integer type) {
+        return baseMapper.listByNameAndDistrictAndContact(name, district, contact, type);
+    }
+
+}
+
+
+
+

+ 22 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/DeviceDataServiceImpl.java

@@ -0,0 +1,22 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.DeviceData;
+import com.yzt.airconditionersystem.service.DeviceDataService;
+import com.yzt.airconditionersystem.mapper.DeviceDataMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author TzZach
+* @description 针对表【device_data】的数据库操作Service实现
+* @createDate 2022-05-12 11:03:34
+*/
+@Service
+public class DeviceDataServiceImpl extends ServiceImpl<DeviceDataMapper, DeviceData>
+    implements DeviceDataService{
+
+}
+
+
+
+

+ 22 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/DeviceServiceImpl.java

@@ -0,0 +1,22 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.Device;
+import com.yzt.airconditionersystem.service.DeviceService;
+import com.yzt.airconditionersystem.mapper.DeviceMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author TzZach
+* @description 针对表【device】的数据库操作Service实现
+* @createDate 2022-05-12 11:03:14
+*/
+@Service
+public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device>
+    implements DeviceService{
+
+}
+
+
+
+

+ 29 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/FacilityAlarmServiceImpl.java

@@ -0,0 +1,29 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.FacilityAlarm;
+import com.yzt.airconditionersystem.service.FacilityAlarmService;
+import com.yzt.airconditionersystem.mapper.FacilityAlarmMapper;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+* @author TzZach
+* @description 针对表【facility_alarm】的数据库操作Service实现
+* @createDate 2022-05-04 17:27:28
+*/
+@Service
+public class FacilityAlarmServiceImpl extends ServiceImpl<FacilityAlarmMapper, FacilityAlarm>
+    implements FacilityAlarmService{
+
+    @Override
+    public List<FacilityAlarm> selectByGatewayIdAndCompanyId(List<String> companyIds) {
+        return baseMapper.selectByGatewayIdAndCompanyId(companyIds);
+    }
+
+}
+
+
+
+

+ 22 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/GatewayServiceImpl.java

@@ -0,0 +1,22 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.Gateway;
+import com.yzt.airconditionersystem.service.GatewayService;
+import com.yzt.airconditionersystem.mapper.GatewayMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author TzZach
+* @description 针对表【gateway】的数据库操作Service实现
+* @createDate 2022-05-12 16:37:48
+*/
+@Service
+public class GatewayServiceImpl extends ServiceImpl<GatewayMapper, Gateway>
+    implements GatewayService{
+
+}
+
+
+
+

+ 22 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/LogServiceImpl.java

@@ -0,0 +1,22 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.Log;
+import com.yzt.airconditionersystem.service.LogService;
+import com.yzt.airconditionersystem.mapper.LogMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author TzZach
+* @description 针对表【log】的数据库操作Service实现
+* @createDate 2022-05-03 00:08:26
+*/
+@Service
+public class LogServiceImpl extends ServiceImpl<LogMapper, Log>
+    implements LogService{
+
+}
+
+
+
+

+ 182 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/MqttServiceImpl.java

@@ -0,0 +1,182 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.google.gson.*;
+import com.yzt.airconditionersystem.bean.Device;
+import com.yzt.airconditionersystem.bean.DeviceData;
+import com.yzt.airconditionersystem.bean.FacilityAlarm;
+import com.yzt.airconditionersystem.mapper.DeviceDataMapper;
+import com.yzt.airconditionersystem.mapper.DeviceMapper;
+import com.yzt.airconditionersystem.service.FacilityAlarmService;
+import com.yzt.airconditionersystem.service.MqttService;
+import com.yzt.airconditionersystem.util.AirconditionerStatus;
+import com.yzt.airconditionersystem.util.MyUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.messaging.Message;
+import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
+import org.thymeleaf.util.StringUtils;
+
+import java.time.Duration;
+import java.time.LocalDateTime;
+import java.util.*;
+
+/**
+ * @author TzZach
+ * @since 2022-05-10 22:54
+ */
+@Service
+@Slf4j
+public class MqttServiceImpl implements MqttService {
+
+
+    @Autowired
+    private DeviceDataMapper deviceDataMapper;
+    @Autowired
+    private DeviceMapper deviceMapper;
+    @Autowired
+    private FacilityAlarmService facilityAlarmService;
+
+    @Override
+    public void receiveFrom(String topic, Message message) throws IllegalAccessException {
+//        System.out.println("接收的消息主题:" + topic);
+//        System.out.println("接收消息QoS:" + message.getQos());
+        //通过主题截取出公司名称和网关设备id,截取加1的目的是不取其中的“/”
+        String companyNameAndGatewayId = topic.substring(topic.indexOf("/") + 1, topic.lastIndexOf("/"));
+        String companyName = companyNameAndGatewayId.substring(0, companyNameAndGatewayId.indexOf("/"));
+        String gatewayId = companyNameAndGatewayId.substring(companyNameAndGatewayId.indexOf("/") + 1);
+        String payload = (String) message.getPayload();
+        System.out.println(payload);
+
+        //获取Json数组的第一个值并转换成为Json对象
+        JsonObject deviceJson = JsonParser.parseString(payload).getAsJsonObject()
+                .getAsJsonArray("devices").get(0).getAsJsonObject();
+        Gson gson = new GsonBuilder().create();
+        Device device = gson.fromJson(deviceJson.getAsJsonObject().toString(), Device.class);
+        //设置一个deviceDataId
+        String deviceDataId = MyUtils.getUUID();
+        device.setCompanyName(companyName);
+        device.setGatewayId(gatewayId);
+        //要截取的前缀
+        Set<String> deviceDataKeySet = deviceJson.get("deviceData").getAsJsonObject().keySet();
+        String deviceDataKey = deviceDataKeySet.iterator().next();
+        String prefix = deviceDataKey.substring(0, deviceDataKey.indexOf("_") + 1);
+        device.setPrefix(prefix);
+        //将deviceData转成Json对象再转成字符串后进行截取
+        String deviceDataStr = deviceJson.get("deviceData").getAsJsonObject().toString().replace(prefix, "");
+        DeviceData deviceData = gson.fromJson(deviceDataStr, DeviceData.class);
+        //判断所接收的数据是否符合所需(即数据是否存在不为空的属性)
+        if (!MyUtils.isFieldsAllNull(deviceData)) {
+            deviceData.setId(deviceDataId);
+            LocalDateTime now = LocalDateTime.now();
+            deviceData.setTime(now);
+            device.setTime(now);
+            //如果该设备信息已存在,不插入
+            String dId = insertDeviceIfNotExists(companyName, gatewayId, device);
+            deviceData.setDId(dId);
+            deviceDataMapper.insert(deviceData);
+            setAlarm(deviceData, gatewayId);
+        }
+    }
+
+    /**
+     * 如果设备信息已存在,不插入;如果不存在,则插入
+     * @param companyName 设备所属公司名称
+     * @param gatewayId 设备所在网关id
+     * @param device 设备对象
+     * @return 返回插入的条目的id
+     */
+    private String insertDeviceIfNotExists(String companyName, String gatewayId, Device device) {
+        String deviceId = device.getDeviceId();
+        LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Device::getCompanyName, companyName)
+                .eq(Device::getGatewayId, gatewayId)
+                .eq(Device::getDeviceId, deviceId)
+                .last("limit 1");
+        Device deviceInfo = deviceMapper.selectOne(queryWrapper);
+        if (deviceInfo == null) {
+            device.setId(MyUtils.getUUID());
+            deviceMapper.insert(device);
+            return device.getId();
+        }
+        return deviceInfo.getId();
+    }
+
+
+    /**
+     * 根据传过来的数据设置报警
+     * @param deviceData
+     */
+    private void setAlarm(DeviceData deviceData, String gatewayId) {
+//        String data2 = map.get("data2");
+//        String data3 = map.get("data3");
+        Integer mBit2 = deviceData.getM_bit2();
+        Integer qBit3 = deviceData.getQ_bit3();
+        if (ObjectUtils.isEmpty(mBit2) || ObjectUtils.isEmpty(qBit3)) {
+            return;
+        }
+
+        String m_bit2 = MyUtils.decToBin(mBit2);
+        String q_bit3 = MyUtils.decToBin(qBit3);
+        List<FacilityAlarm> facilityAlarms = new ArrayList<>();
+        LocalDateTime now = LocalDateTime.now();
+
+
+        if (q_bit3.charAt(AirconditionerStatus.UNIT_FAILURE) == AirconditionerStatus.ALARM) {
+            addFacilityAlarms(AirconditionerStatus.UNIT_FAILURE_ALARM_CONTENT, AirconditionerStatus.STATUS_LASTING, facilityAlarms, now, gatewayId);
+        }
+        if (m_bit2.charAt(AirconditionerStatus.LACK_OF_LEEWAY) == AirconditionerStatus.ALARM) {
+            addFacilityAlarms(AirconditionerStatus.LACK_OF_LEEWAY_ALARM_CONTENT, AirconditionerStatus.STATUS_LASTING, facilityAlarms, now, gatewayId);
+        }
+        if (m_bit2.charAt(AirconditionerStatus.HIGH_TEMPERATURE_ALARM) == AirconditionerStatus.ALARM) {
+            addFacilityAlarms(AirconditionerStatus.HIGH_TEMPERATURE_ALARM_ALARM_CONTENT, AirconditionerStatus.STATUS_LASTING, facilityAlarms, now, gatewayId);
+        }
+        if (m_bit2.charAt(AirconditionerStatus.AIR_COOLED_MAINFRAME) == AirconditionerStatus.ALARM) {
+            addFacilityAlarms(AirconditionerStatus.AIR_COOLED_MAINFRAME_ALARM_CONTENT, AirconditionerStatus.STATUS_LASTING, facilityAlarms, now, gatewayId);
+        }
+        if (m_bit2.charAt(AirconditionerStatus.EXHAUST_FAN) == AirconditionerStatus.ALARM) {
+            addFacilityAlarms(AirconditionerStatus.EXHAUST_FAN_ALARM_CONTENT, AirconditionerStatus.STATUS_LASTING, facilityAlarms, now, gatewayId);
+        }
+        if (m_bit2.charAt(AirconditionerStatus.BLOWER) == AirconditionerStatus.ALARM) {
+            addFacilityAlarms(AirconditionerStatus.BLOWER_ALARM_CONTENT, AirconditionerStatus.STATUS_LASTING, facilityAlarms, now, gatewayId);
+        }
+        if (m_bit2.charAt(AirconditionerStatus.W_CELL) == AirconditionerStatus.ALARM) {
+            addFacilityAlarms(AirconditionerStatus.W_CELL_ALARM_CONTENT, AirconditionerStatus.STATUS_LASTING, facilityAlarms, now, gatewayId);
+        }
+        if (m_bit2.charAt(AirconditionerStatus.PREFILTER) == AirconditionerStatus.ALARM) {
+            addFacilityAlarms(AirconditionerStatus.PREFILTER_ALARM_CONTENT, AirconditionerStatus.STATUS_LASTING, facilityAlarms, now, gatewayId);
+        }
+
+        facilityAlarmService.saveBatch(facilityAlarms);
+
+    }
+
+
+    /**
+     * 将设备报警加入到list中
+     * @param alarmContent
+     * @param status
+     * @param facilityAlarms
+     * @param now
+     */
+    private void addFacilityAlarms(String alarmContent, String status, List<FacilityAlarm> facilityAlarms, LocalDateTime now, String gatewayId) {
+        FacilityAlarm facilityAlarm =
+                new FacilityAlarm(null, now, alarmContent, status, gatewayId, 1L);
+        LambdaQueryWrapper<FacilityAlarm> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(FacilityAlarm::getAlarmContent, alarmContent)
+                            .eq(FacilityAlarm::getGatewayId, gatewayId)
+                            .eq(FacilityAlarm::getStatus, status);
+        FacilityAlarm alarm = facilityAlarmService.getOne(queryWrapper);
+
+        if (!ObjectUtils.isEmpty(alarm)) {
+            facilityAlarmService.removeById(alarm);
+            LocalDateTime time = alarm.getTime();
+            Duration between = Duration.between(time, now);
+            facilityAlarm.setLastingTime(between.toMinutes());
+        }
+
+        facilityAlarms.add(facilityAlarm);
+    }
+}

+ 60 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/OperatorServiceImpl.java

@@ -0,0 +1,60 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.Gateway;
+import com.yzt.airconditionersystem.bean.Operator;
+import com.yzt.airconditionersystem.bean.Project;
+import com.yzt.airconditionersystem.mapper.GatewayMapper;
+import com.yzt.airconditionersystem.mapper.OperatorMapper;
+import com.yzt.airconditionersystem.mapper.ProjectMapper;
+import com.yzt.airconditionersystem.service.GatewayService;
+import com.yzt.airconditionersystem.service.OperatorService;
+import com.yzt.airconditionersystem.service.ProjectService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author TzZach
+ * @since 2022-04-13 12:09
+ */
+@Service
+public class OperatorServiceImpl extends ServiceImpl<OperatorMapper, Operator> implements OperatorService {
+
+    @Autowired
+    private OperatorMapper operatorMapper;
+    @Autowired
+    private ProjectMapper projectMapper;
+    @Autowired
+    private GatewayMapper gatewayMapper;
+
+    @Override
+    public Operator getOneByOperator(Operator operator) {
+        return operatorMapper.getOne(operator);
+    }
+
+    @Override
+    public Map<String, Object> deleteOperatorById(Integer id) {
+        List<Integer> projectIds = projectMapper.selectIdByOperatorId(id);
+        LambdaQueryWrapper<Gateway> gatewayLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        gatewayLambdaQueryWrapper.in(Gateway::getCompanyId, projectIds);
+        int gateway = gatewayMapper.delete(gatewayLambdaQueryWrapper);
+
+        LambdaQueryWrapper<Project> projectLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        projectLambdaQueryWrapper.in(Project::getId, projectIds);
+        int project = projectMapper.delete(projectLambdaQueryWrapper);
+
+        int operator = operatorMapper.deleteById(id);
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("operator", operator);
+        map.put("project", project);
+        map.put("gateway", gateway);
+
+        return map;
+    }
+}

+ 22 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/PermissionServiceImpl.java

@@ -0,0 +1,22 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.Permission;
+import com.yzt.airconditionersystem.service.PermissionService;
+import com.yzt.airconditionersystem.mapper.PermissionMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author TzZach
+* @description 针对表【permission】的数据库操作Service实现
+* @createDate 2022-04-23 18:05:12
+*/
+@Service
+public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission>
+    implements PermissionService{
+
+}
+
+
+
+

+ 31 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/ProjectServiceImpl.java

@@ -0,0 +1,31 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.Project;
+import com.yzt.airconditionersystem.mapper.ProjectMapper;
+import com.yzt.airconditionersystem.service.ProjectService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author TzZach
+ * @since 2022-04-15 16:41
+ */
+@Service
+public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {
+
+    @Autowired
+    private ProjectMapper projectMapper;
+
+
+    public List<Project> selectByClientNameAndDistrictAndCompanyName(String clientName, String district, String operatorName) {
+        return projectMapper.selectByClientNameAndDistrictAndCompanyName(clientName, district, operatorName);
+    }
+
+    public List<Integer> selectIdByOperatorId(Integer operatorId) {
+        return projectMapper.selectIdByOperatorId(operatorId);
+    }
+
+}

+ 22 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/RolePermissionServiceImpl.java

@@ -0,0 +1,22 @@
+package com.yzt.airconditionersystem.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yzt.airconditionersystem.bean.RolePermission;
+import com.yzt.airconditionersystem.service.RolePermissionService;
+import com.yzt.airconditionersystem.mapper.RolePermissionMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author TzZach
+* @description 针对表【role_permission】的数据库操作Service实现
+* @createDate 2022-05-09 12:47:43
+*/
+@Service
+public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission>
+    implements RolePermissionService{
+
+}
+
+
+
+

+ 0 - 0
sources/server/airconditioner-system/src/main/java/com/yzt/airconditionersystem/service/impl/RoleServiceImpl.java


Неке датотеке нису приказане због велике количине промена