From f02372a69c6a98bee4f6cfa14127564c4349a720 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 11 Sep 2024 17:27:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/gglm/bigmodel/BigModelConstants.java | 14 ++ .../bigmodel/api/constants/MqttTopicConstants.java | 30 +++ .../api/dto/BigModelAnalysisRequestDTO.java | 26 ++ .../api/dto/BigModelAnalysisResponseDTO.java | 59 +++++ .../hnac/gglm/bigmodel/api/dto/CanvasSyncDTO.java | 20 ++ .../hnac/gglm/bigmodel/api/dto/ControlSyncDTO.java | 20 ++ .../com/hnac/gglm/bigmodel/api/dto/SyncDTO.java | 50 ++++ .../hnac/gglm/bigmodel/api/dto/VideoSyncDTO.java | 22 ++ .../api/feign/IBigModelAnalysisClient.java | 21 ++ .../gglm/bigmodel/api/feign/ICanvasSyncClient.java | 12 + .../bigmodel/api/feign/IControlSyncClient.java | 11 + .../bigmodel/api/feign/IDataAnalyseClient.java | 31 +++ .../hnac/gglm/bigmodel/api/feign/ISyncClient.java | 40 +++ .../gglm/bigmodel/api/feign/IVideoSyncClient.java | 32 +++ .../gglm/bigmodel/api/wrapper/BaseSyncWrapper.java | 21 ++ .../business/dto/ControlDeviceAuthDTO.java | 23 ++ .../gglm/bigmodel/business/dto/PowerDataDTO.java | 34 +++ .../business/dto/RunReportAnalyseRequest.java | 32 +++ .../business/dto/RunReportDataAnalyseDTO.java | 41 ++++ .../gglm/bigmodel/business/dto/RunTimeDataDTO.java | 26 ++ .../gglm/bigmodel/business/dto/SoeDataDTO.java | 26 ++ .../gglm/bigmodel/business/feign/IAuthClient.java | 45 ++++ .../gglm/bigmodel/interactive/dto/ControlDTO.java | 36 +++ .../bigmodel/interactive/dto/ControlDeviceDTO.java | 38 +++ .../bigmodel/interactive/req/ModelFunctionReq.java | 31 +++ .../bigmodel/interactive/vo/AttrSelectionVO.java | 14 ++ .../gglm/bigmodel/interactive/vo/DataItemVO.java | 40 +++ .../hnac/gglm/bigmodel/interactive/vo/DataVO.java | 35 +++ .../hnac/gglm/bigmodel/interactive/vo/ExtraVO.java | 56 +++++ .../bigmodel/interactive/vo/FaultSelectionVO.java | 18 ++ .../gglm/bigmodel/interactive/vo/RealDataVO.java | 20 ++ .../bigmodel/interactive/vo/RemoteSelectionVO.java | 13 + .../bigmodel/interactive/vo/ScadaSelectionVO.java | 18 ++ .../gglm/bigmodel/interactive/vo/SelectionVO.java | 23 ++ .../interactive/vo/StationSelectionVO.java | 15 ++ .../bigmodel/interactive/vo/VideoSelectionVO.java | 16 ++ .../bigmodel/maintenance/entity/ControlEntity.java | 59 +++++ .../maintenance/entity/FunctionEntity.java | 48 ++++ .../maintenance/entity/WeaviateEntity.java | 23 ++ .../maintenance/entity/WhitelistEntity.java | 24 ++ .../com/hnac/hzims/bigmodel/BigModelConstants.java | 14 -- .../bigmodel/api/constants/MqttTopicConstants.java | 30 --- .../api/dto/BigModelAnalysisRequestDTO.java | 26 -- .../api/dto/BigModelAnalysisResponseDTO.java | 59 ----- .../hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java | 20 -- .../hzims/bigmodel/api/dto/ControlSyncDTO.java | 20 -- .../com/hnac/hzims/bigmodel/api/dto/SyncDTO.java | 50 ---- .../hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java | 22 -- .../api/feign/IBigModelAnalysisClient.java | 21 -- .../bigmodel/api/feign/ICanvasSyncClient.java | 12 - .../bigmodel/api/feign/IControlSyncClient.java | 11 - .../bigmodel/api/feign/IDataAnalyseClient.java | 31 --- .../hnac/hzims/bigmodel/api/feign/ISyncClient.java | 40 --- .../hzims/bigmodel/api/feign/IVideoSyncClient.java | 32 --- .../bigmodel/api/wrapper/BaseSyncWrapper.java | 21 -- .../business/dto/ControlDeviceAuthDTO.java | 23 -- .../hzims/bigmodel/business/dto/PowerDataDTO.java | 34 --- .../business/dto/RunReportAnalyseRequest.java | 32 --- .../business/dto/RunReportDataAnalyseDTO.java | 41 ---- .../bigmodel/business/dto/RunTimeDataDTO.java | 26 -- .../hzims/bigmodel/business/dto/SoeDataDTO.java | 26 -- .../hzims/bigmodel/business/feign/IAuthClient.java | 45 ---- .../bigmodel/database/entity/WeaviateEntity.java | 23 -- .../hnac/hzims/bigmodel/entity/FunctionEntity.java | 48 ---- .../hzims/bigmodel/entity/WhitelistEntity.java | 24 -- .../hzims/bigmodel/interactive/dto/ControlDTO.java | 36 --- .../bigmodel/interactive/dto/ControlDeviceDTO.java | 38 --- .../bigmodel/interactive/req/ModelFunctionReq.java | 31 --- .../bigmodel/interactive/vo/AttrSelectionVO.java | 14 -- .../hzims/bigmodel/interactive/vo/DataItemVO.java | 40 --- .../hnac/hzims/bigmodel/interactive/vo/DataVO.java | 35 --- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 56 ----- .../bigmodel/interactive/vo/FaultSelectionVO.java | 18 -- .../hzims/bigmodel/interactive/vo/RealDataVO.java | 20 -- .../bigmodel/interactive/vo/RemoteSelectionVO.java | 13 - .../bigmodel/interactive/vo/ScadaSelectionVO.java | 18 -- .../hzims/bigmodel/interactive/vo/SelectionVO.java | 23 -- .../interactive/vo/StationSelectionVO.java | 15 -- .../bigmodel/interactive/vo/VideoSelectionVO.java | 16 -- .../bigmodel/maintenance/entity/ControlEntity.java | 59 ----- hzims-service/gglm-big-model/pom.xml | 107 ++++++++ .../gglm/bigmodel/GglmBigModelApplication.java | 22 ++ .../gglm/bigmodel/api/constants/SyncTableEnum.java | 28 +++ .../bigmodel/api/feign/BigModelAnalysisClient.java | 25 ++ .../gglm/bigmodel/api/feign/DataAnalyseClient.java | 31 +++ .../gglm/bigmodel/api/feign/VideoSyncClient.java | 45 ++++ .../gglm/bigmodel/api/service/SyncService.java | 66 +++++ .../business/consumer/VideoAddConsumer.java | 40 +++ .../business/consumer/VideoRemoveConsumer.java | 36 +++ .../controller/DataSourceExecuteController.java | 33 +++ .../business/controller/RemoteController.java | 34 +++ .../gglm/bigmodel/business/feign/AuthClient.java | 87 +++++++ .../business/service/AuthenticationService.java | 118 +++++++++ .../business/service/DataSourceService.java | 113 +++++++++ .../business/service/HistoryDataService.java | 95 +++++++ .../bigmodel/business/service/RemoteService.java | 31 +++ .../com/hnac/gglm/bigmodel/business/vo/SqlVO.java | 32 +++ .../gglm/bigmodel/business/vo/TableAuthVO.java | 28 +++ .../business/wrapper/CanvasSyncWrapper.java | 21 ++ .../bigmodel/configuration/BigModelInvokeApi.java | 70 ++++++ .../bigmodel/configuration/ThreadPoolManager.java | 34 +++ .../bigmodel/configuration/WeaviateConfigure.java | 56 +++++ .../bigmodel/configuration/WeaviateProperties.java | 32 +++ .../database/controller/WeaviateController.java | 41 ++++ .../bigmodel/database/dto/WeaviateSaveDTO.java | 33 +++ .../bigmodel/database/service/WeaviateService.java | 266 ++++++++++++++++++++ .../gglm/bigmodel/database/util/WeaviateUtil.java | 11 + .../interactive/constants/DataAuthTypeEnum.java | 27 ++ .../interactive/constants/DataMethodEnum.java | 36 +++ .../bigmodel/interactive/constants/DateEnum.java | 41 ++++ .../interactive/constants/FuncRouteEnum.java | 42 ++++ .../interactive/constants/FunctionConstants.java | 40 +++ .../interactive/constants/InfoMessageConstant.java | 11 + .../interactive/constants/ParamKeyConstants.java | 23 ++ .../constants/ProjectRemoteTypeEnum.java | 22 ++ .../constants/SearchStationTypeEnum.java | 44 ++++ .../interactive/constants/SearchTypeEnum.java | 28 +++ .../controller/FontEndInteractiveController.java | 70 ++++++ .../controller/HznlmInteractiveController.java | 63 +++++ .../gglm/bigmodel/interactive/dto/AuthDataDTO.java | 35 +++ .../interactive/factory/AnswerResolveFactory.java | 57 +++++ .../interactive/factory/ResolveFactory.java | 43 ++++ .../interactive/service/IAnalyseDataService.java | 16 ++ .../interactive/service/IAnswerResolveService.java | 34 +++ .../service/IHznlmInteractiveService.java | 26 ++ .../interactive/service/IHznlmInvokeService.java | 97 ++++++++ .../interactive/service/IResolveService.java | 17 ++ .../service/impl/AnalyseDataServiceImpl.java | 89 +++++++ .../service/impl/CanvasResolveServiceImpl.java | 129 ++++++++++ .../impl/ChoiceAnswerResolveServiceImpl.java | 43 ++++ .../impl/ControlAnswerResolveServiceImpl.java | 56 +++++ .../impl/DiagnoseAnswerResolveServiceImpl.java | 50 ++++ .../service/impl/HznlmInteractiveServiceImpl.java | 100 ++++++++ .../service/impl/HznlmInvokeServiceImpl.java | 205 ++++++++++++++++ .../impl/ParamAnswerResolveServiceImpl.java | 106 ++++++++ .../impl/RemoteAnswerResolveServiceImpl.java | 59 +++++ .../service/impl/VideoResolveServiceImpl.java | 69 ++++++ .../gglm/bigmodel/interactive/vo/AnswerVO.java | 71 ++++++ .../gglm/bigmodel/interactive/vo/AuthDataVO.java | 27 ++ .../interactive/vo/HistoryDataSearchVO.java | 37 +++ .../bigmodel/interactive/vo/RemoteParamVO.java | 39 +++ .../bigmodel/interactive/vo/ResolveResultVO.java | 29 +++ .../bigmodel/interactive/vo/SessionContentVO.java | 19 ++ .../bigmodel/interactive/vo/StationSearchVO.java | 24 ++ .../bigmodel/interactive/vo/UpdateStationVO.java | 20 ++ .../bigmodel/interactive/vo/UpdateUsualVO.java | 25 ++ .../maintenance/controller/AgentLogController.java | 80 ++++++ .../maintenance/controller/ControlController.java | 73 ++++++ .../controller/DataSourceController.java | 75 ++++++ .../controller/KnowledgeFileInfoController.java | 77 ++++++ .../controller/TableColumnController.java | 54 ++++ .../controller/TableInfoController.java | 59 +++++ .../controller/TablePropertyController.java | 64 +++++ .../controller/VectorParamController.java | 118 +++++++++ .../maintenance/entity/AgentLogEntity.java | 94 +++++++ .../maintenance/entity/DataRecordEntity.java | 17 ++ .../maintenance/entity/DatasourceEntity.java | 37 +++ .../maintenance/entity/KnowledgeFileInfo.java | 56 +++++ .../maintenance/entity/SyncPropertyEntity.java | 40 +++ .../maintenance/entity/TableInfoEntity.java | 68 +++++ .../maintenance/entity/TablePropertyEntity.java | 49 ++++ .../maintenance/entity/VectorParamEntity.java | 53 ++++ .../maintenance/mapper/AgentLogMapper.java | 11 + .../bigmodel/maintenance/mapper/ControlMapper.java | 12 + .../maintenance/mapper/DatasourceMapper.java | 12 + .../mapper/KnowledgeFileInfoMapper.java | 11 + .../maintenance/mapper/TableInfoMapper.java | 12 + .../maintenance/mapper/TablePropertyMapper.java | 11 + .../maintenance/mapper/VectorParamMapper.java | 11 + .../maintenance/service/AgentLogService.java | 19 ++ .../maintenance/service/ControlService.java | 21 ++ .../maintenance/service/DataSourceService.java | 19 ++ .../service/KnowledgeFileInfoService.java | 11 + .../maintenance/service/TableColumnService.java | 37 +++ .../maintenance/service/TableInfoService.java | 21 ++ .../maintenance/service/TablePropertyService.java | 19 ++ .../maintenance/service/VectorParamService.java | 22 ++ .../service/impl/AgentLogServiceImpl.java | 74 ++++++ .../service/impl/KnowledgeFileInfoServiceImpl.java | 19 ++ .../service/impl/VectorParamServiceImpl.java | 143 +++++++++++ .../gglm/bigmodel/maintenance/vo/IdsRequest.java | 19 ++ .../gglm/bigmodel/maintenance/vo/LabelRequest.java | 19 ++ .../bigmodel/maintenance/vo/VectorUrlResponse.java | 16 ++ .../gglm/bigmodel/manager/SessionRedisManager.java | 32 +++ .../gglm/bigmodel/question/dto/MessageDTO.java | 101 ++++++++ .../gglm/bigmodel/question/dto/QuestionDTO.java | 76 ++++++ .../question/service/QuestionHandlerService.java | 133 ++++++++++ .../schedule/FrontEndInteractiveSchedule.java | 79 ++++++ .../schedule/RunReportAnalyseSchedule.java | 60 +++++ .../bigmodel/schedule/XxlJobHandlerConstant.java | 28 +++ .../gglm/bigmodel/utils/RequestClientUtil.java | 68 +++++ .../bigmodel/websocket/config/WebSocketConfig.java | 28 +++ .../websocket/constants/RedisKeyConstants.java | 15 ++ .../websocket/handler/InteractiveHandler.java | 78 ++++++ .../websocket/server/InteractiveWsServer.java | 9 + .../websocket/service/InteractiveWsService.java | 42 ++++ .../websocket/service/WebSocketService.java | 16 ++ .../sessionManager/InteractiveSessionManager.java | 94 +++++++ .../whitelist/controller/WhitelistController.java | 35 +++ .../bigmodel/whitelist/mapper/WhitelistMapper.java | 11 + .../whitelist/service/WhitelistService.java | 12 + .../service/impl/WhitelistServiceImpl.java | 18 ++ .../bigmodel/zhipuai/config/ZhipuAiConfig.java | 24 ++ .../zhipuai/config/ZhipuAiConfigProperties.java | 18 ++ .../bigmodel/zhipuai/constants/AnalysisModel.java | 27 ++ .../gglm/bigmodel/zhipuai/constants/BaseEnum.java | 21 ++ .../bigmodel/zhipuai/constants/ComparisonType.java | 22 ++ .../gglm/bigmodel/zhipuai/constants/ErrorCode.java | 58 +++++ .../bigmodel/zhipuai/constants/ResultDataType.java | 41 ++++ .../zhipuai/constants/ResultStrategyType.java | 39 +++ .../controller/ZhipuAnalysisController.java | 36 +++ .../controller/ZhipuAnalysisInfoController.java | 65 +++++ .../zhipuai/entity/ZhipuAnalysisInfoEntity.java | 75 ++++++ .../handler/AbstractZhipuAnalysisHandler.java | 23 ++ .../bigmodel/zhipuai/handler/ZhipuAnalyser.java | 50 ++++ .../zhipuai/handler/ZhipuAnalysisFactory.java | 37 +++ .../zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java | 88 +++++++ .../zhipuai/handler/ZhipuAnalysisHandlerTest.java | 22 ++ .../handler/result/ResultBooleanStrategy.java | 46 ++++ .../handler/result/ResultCommonStrategy.java | 21 ++ .../zhipuai/handler/result/ResultStrategy.java | 36 +++ .../zhipuai/handler/result/data/BooleanParser.java | 12 + .../zhipuai/handler/result/data/IntegerParser.java | 12 + .../handler/result/data/ResultDataParser.java | 9 + .../zhipuai/handler/result/data/StringParser.java | 12 + .../zhipuai/mapper/ZhipuAnalysisInfoMapper.java | 11 + .../zhipuai/service/ZhipuAnalysisInfoService.java | 11 + .../zhipuai/service/ZhipuAnalysisService.java | 20 ++ .../service/impl/ZhipuAnalysisInfoServiceImpl.java | 16 ++ .../service/impl/ZhipuAnalysisServiceImpl.java | 216 ++++++++++++++++ .../zhipuai/vo/ZhipuAnalysisFileRequest.java | 45 ++++ .../zhipuai/vo/ZhipuAnalysisFileResponse.java | 14 ++ .../bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java | 21 ++ .../bigmodel/zhipuai/vo/ZhipuAnalysisResult.java | 32 +++ .../gglm-big-model/src/main/resources/db/1.0.0.sql | 37 +++ .../gglm-big-model/src/main/resources/db/2.0.0.sql | 65 +++++ .../gglm-big-model/src/main/resources/db/2.0.1.sql | 27 ++ .../gglm-big-model/src/main/resources/db/2.0.2.sql | 17 ++ .../src/main/resources/template/template.yml | 94 +++++++ hzims-service/hzims-big-model/pom.xml | 107 -------- .../hzims/bigmodel/HzimsBigModelApplication.java | 31 --- .../bigmodel/api/constants/SyncTableEnum.java | 28 --- .../bigmodel/api/feign/BigModelAnalysisClient.java | 25 -- .../bigmodel/api/feign/DataAnalyseClient.java | 31 --- .../hzims/bigmodel/api/feign/VideoSyncClient.java | 45 ---- .../hzims/bigmodel/api/service/SyncService.java | 67 ----- .../business/consumer/VideoAddConsumer.java | 40 --- .../business/consumer/VideoRemoveConsumer.java | 36 --- .../controller/DataSourceExecuteController.java | 33 --- .../business/controller/RemoteController.java | 34 --- .../hzims/bigmodel/business/feign/AuthClient.java | 87 ------- .../business/service/AuthenticationService.java | 119 --------- .../business/service/DataSourceService.java | 113 --------- .../business/service/HistoryDataService.java | 95 ------- .../bigmodel/business/service/RemoteService.java | 31 --- .../com/hnac/hzims/bigmodel/business/vo/SqlVO.java | 32 --- .../hzims/bigmodel/business/vo/TableAuthVO.java | 28 --- .../business/wrapper/CanvasSyncWrapper.java | 21 -- .../bigmodel/configuration/BigModelInvokeApi.java | 70 ------ .../bigmodel/configuration/ThreadPoolManager.java | 34 --- .../bigmodel/configuration/WeaviateConfigure.java | 56 ----- .../bigmodel/configuration/WeaviateProperties.java | 32 --- .../database/controller/WeaviateController.java | 41 ---- .../bigmodel/database/dto/WeaviateSaveDTO.java | 33 --- .../bigmodel/database/service/WeaviateService.java | 273 --------------------- .../hzims/bigmodel/database/util/WeaviateUtil.java | 11 - .../interactive/constants/DataAuthTypeEnum.java | 27 -- .../interactive/constants/DataMethodEnum.java | 36 --- .../bigmodel/interactive/constants/DateEnum.java | 41 ---- .../interactive/constants/FuncRouteEnum.java | 42 ---- .../interactive/constants/FunctionConstants.java | 40 --- .../interactive/constants/InfoMessageConstant.java | 11 - .../interactive/constants/ParamKeyConstants.java | 23 -- .../constants/ProjectRemoteTypeEnum.java | 22 -- .../constants/SearchStationTypeEnum.java | 44 ---- .../interactive/constants/SearchTypeEnum.java | 28 --- .../controller/FontEndInteractiveController.java | 70 ------ .../controller/HznlmInteractiveController.java | 63 ----- .../bigmodel/interactive/dto/AuthDataDTO.java | 35 --- .../interactive/factory/AnswerResolveFactory.java | 57 ----- .../interactive/factory/ResolveFactory.java | 43 ---- .../interactive/service/IAnalyseDataService.java | 16 -- .../interactive/service/IAnswerResolveService.java | 34 --- .../service/IHznlmInteractiveService.java | 26 -- .../interactive/service/IHznlmInvokeService.java | 98 -------- .../interactive/service/IResolveService.java | 17 -- .../service/impl/AnalyseDataServiceImpl.java | 89 ------- .../service/impl/CanvasResolveServiceImpl.java | 129 ---------- .../impl/ChoiceAnswerResolveServiceImpl.java | 43 ---- .../impl/ControlAnswerResolveServiceImpl.java | 56 ----- .../impl/DiagnoseAnswerResolveServiceImpl.java | 50 ---- .../service/impl/HznlmInteractiveServiceImpl.java | 100 -------- .../service/impl/HznlmInvokeServiceImpl.java | 206 ---------------- .../impl/ParamAnswerResolveServiceImpl.java | 106 -------- .../impl/RemoteAnswerResolveServiceImpl.java | 59 ----- .../service/impl/VideoResolveServiceImpl.java | 69 ------ .../hzims/bigmodel/interactive/vo/AnswerVO.java | 71 ------ .../hzims/bigmodel/interactive/vo/AuthDataVO.java | 27 -- .../interactive/vo/HistoryDataSearchVO.java | 37 --- .../bigmodel/interactive/vo/RemoteParamVO.java | 39 --- .../bigmodel/interactive/vo/ResolveResultVO.java | 29 --- .../bigmodel/interactive/vo/SessionContentVO.java | 19 -- .../bigmodel/interactive/vo/StationSearchVO.java | 24 -- .../bigmodel/interactive/vo/UpdateStationVO.java | 20 -- .../bigmodel/interactive/vo/UpdateUsualVO.java | 25 -- .../maintenance/controller/AgentLogController.java | 83 ------- .../maintenance/controller/ControlController.java | 74 ------ .../controller/DataSourceController.java | 76 ------ .../controller/KnowledgeFileInfoController.java | 77 ------ .../controller/TableColumnController.java | 54 ---- .../controller/TableInfoController.java | 59 ----- .../controller/TablePropertyController.java | 66 ----- .../controller/VectorParamController.java | 118 --------- .../maintenance/entity/AgentLogEntity.java | 94 ------- .../maintenance/entity/DataRecordEntity.java | 17 -- .../maintenance/entity/DatasourceEntity.java | 37 --- .../maintenance/entity/KnowledgeFileInfo.java | 56 ----- .../maintenance/entity/SyncPropertyEntity.java | 40 --- .../maintenance/entity/TableInfoEntity.java | 68 ----- .../maintenance/entity/TablePropertyEntity.java | 49 ---- .../maintenance/entity/VectorParamEntity.java | 53 ---- .../maintenance/mapper/AgentLogMapper.java | 11 - .../bigmodel/maintenance/mapper/ControlMapper.java | 12 - .../maintenance/mapper/DatasourceMapper.java | 12 - .../mapper/KnowledgeFileInfoMapper.java | 11 - .../maintenance/mapper/TableInfoMapper.java | 12 - .../maintenance/mapper/TablePropertyMapper.java | 11 - .../maintenance/mapper/VectorParamMapper.java | 11 - .../maintenance/service/AgentLogService.java | 19 -- .../maintenance/service/ControlService.java | 21 -- .../maintenance/service/DataSourceService.java | 19 -- .../service/KnowledgeFileInfoService.java | 11 - .../maintenance/service/TableColumnService.java | 37 --- .../maintenance/service/TableInfoService.java | 21 -- .../maintenance/service/TablePropertyService.java | 20 -- .../maintenance/service/VectorParamService.java | 22 -- .../service/impl/AgentLogServiceImpl.java | 74 ------ .../service/impl/KnowledgeFileInfoServiceImpl.java | 19 -- .../service/impl/VectorParamServiceImpl.java | 143 ----------- .../hzims/bigmodel/maintenance/vo/IdsRequest.java | 19 -- .../bigmodel/maintenance/vo/LabelRequest.java | 19 -- .../bigmodel/maintenance/vo/VectorUrlResponse.java | 16 -- .../bigmodel/manager/SessionRedisManager.java | 34 --- .../hzims/bigmodel/question/dto/MessageDTO.java | 101 -------- .../hzims/bigmodel/question/dto/QuestionDTO.java | 76 ------ .../question/service/QuestionHandlerService.java | 133 ---------- .../schedule/FrontEndInteractiveSchedule.java | 84 ------- .../schedule/RunReportAnalyseSchedule.java | 62 ----- .../bigmodel/schedule/XxlJobHandlerConstant.java | 28 --- .../hzims/bigmodel/utils/RequestClientUtil.java | 68 ----- .../bigmodel/websocket/config/WebSocketConfig.java | 28 --- .../websocket/constants/RedisKeyConstants.java | 15 -- .../websocket/handler/InteractiveHandler.java | 85 ------- .../websocket/server/InteractiveWsServer.java | 9 - .../websocket/service/InteractiveWsService.java | 43 ---- .../websocket/service/WebSocketService.java | 16 -- .../sessionManager/InteractiveSessionManager.java | 96 -------- .../whitelist/controller/WhitelistController.java | 35 --- .../bigmodel/whitelist/mapper/WhitelistMapper.java | 11 - .../whitelist/service/WhitelistService.java | 12 - .../service/impl/WhitelistServiceImpl.java | 18 -- .../bigmodel/zhipuai/config/ZhipuAiConfig.java | 24 -- .../zhipuai/config/ZhipuAiConfigProperties.java | 18 -- .../bigmodel/zhipuai/constants/AnalysisModel.java | 27 -- .../hzims/bigmodel/zhipuai/constants/BaseEnum.java | 21 -- .../bigmodel/zhipuai/constants/ComparisonType.java | 22 -- .../bigmodel/zhipuai/constants/ErrorCode.java | 58 ----- .../bigmodel/zhipuai/constants/ResultDataType.java | 41 ---- .../zhipuai/constants/ResultStrategyType.java | 39 --- .../controller/ZhipuAnalysisController.java | 36 --- .../controller/ZhipuAnalysisInfoController.java | 66 ----- .../zhipuai/entity/ZhipuAnalysisInfoEntity.java | 75 ------ .../handler/AbstractZhipuAnalysisHandler.java | 23 -- .../bigmodel/zhipuai/handler/ZhipuAnalyser.java | 50 ---- .../zhipuai/handler/ZhipuAnalysisFactory.java | 37 --- .../zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java | 88 ------- .../zhipuai/handler/ZhipuAnalysisHandlerTest.java | 22 -- .../handler/result/ResultBooleanStrategy.java | 47 ---- .../handler/result/ResultCommonStrategy.java | 22 -- .../zhipuai/handler/result/ResultStrategy.java | 36 --- .../zhipuai/handler/result/data/BooleanParser.java | 12 - .../zhipuai/handler/result/data/IntegerParser.java | 12 - .../handler/result/data/ResultDataParser.java | 9 - .../zhipuai/handler/result/data/StringParser.java | 12 - .../zhipuai/mapper/ZhipuAnalysisInfoMapper.java | 11 - .../zhipuai/service/ZhipuAnalysisInfoService.java | 11 - .../zhipuai/service/ZhipuAnalysisService.java | 20 -- .../service/impl/ZhipuAnalysisInfoServiceImpl.java | 16 -- .../service/impl/ZhipuAnalysisServiceImpl.java | 216 ---------------- .../zhipuai/vo/ZhipuAnalysisFileRequest.java | 45 ---- .../zhipuai/vo/ZhipuAnalysisFileResponse.java | 14 -- .../bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java | 29 --- .../bigmodel/zhipuai/vo/ZhipuAnalysisResult.java | 32 --- .../src/main/resources/db/1.0.0.sql | 37 --- .../src/main/resources/db/2.0.0.sql | 65 ----- .../src/main/resources/db/2.0.1.sql | 27 -- .../src/main/resources/db/2.0.2.sql | 17 -- .../src/main/resources/template/template.yml | 94 ------- .../inspect/task/schedule/VideoTaskSchedule.java | 6 +- hzims-service/pom.xml | 2 +- 400 files changed, 8579 insertions(+), 8637 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/constants/MqttTopicConstants.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/BigModelAnalysisRequestDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/BigModelAnalysisResponseDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/CanvasSyncDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/ControlSyncDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/SyncDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/VideoSyncDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IBigModelAnalysisClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/ICanvasSyncClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IControlSyncClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IDataAnalyseClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/ISyncClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IVideoSyncClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/wrapper/BaseSyncWrapper.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/ControlDeviceAuthDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/PowerDataDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunReportAnalyseRequest.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunReportDataAnalyseDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunTimeDataDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/SoeDataDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/feign/IAuthClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/ControlDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/ControlDeviceDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/req/ModelFunctionReq.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AttrSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/DataItemVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/DataVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ExtraVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/FaultSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RealDataVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RemoteSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ScadaSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/StationSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/VideoSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/ControlEntity.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/FunctionEntity.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WeaviateEntity.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WhitelistEntity.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/BigModelConstants.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisRequestDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IDataAnalyseClient.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/wrapper/BaseSyncWrapper.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportAnalyseRequest.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportDataAnalyseDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunTimeDataDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/SoeDataDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/database/entity/WeaviateEntity.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/FunctionEntity.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java create mode 100644 hzims-service/gglm-big-model/pom.xml create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/GglmBigModelApplication.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/constants/SyncTableEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/BigModelAnalysisClient.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/DataAnalyseClient.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/VideoSyncClient.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/service/SyncService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/consumer/VideoAddConsumer.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/consumer/VideoRemoveConsumer.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/DataSourceExecuteController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/RemoteController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/feign/AuthClient.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/AuthenticationService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/DataSourceService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/HistoryDataService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/RemoteService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/SqlVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/TableAuthVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/wrapper/CanvasSyncWrapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/ThreadPoolManager.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/WeaviateConfigure.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/WeaviateProperties.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/dto/WeaviateSaveDTO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/util/WeaviateUtil.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DataAuthTypeEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DataMethodEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DateEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/FuncRouteEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/FunctionConstants.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/InfoMessageConstant.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/SearchStationTypeEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/SearchTypeEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/FontEndInteractiveController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/AuthDataDTO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/AnswerResolveFactory.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/ResolveFactory.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IAnalyseDataService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IAnswerResolveService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInvokeService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IResolveService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AnswerVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AuthDataVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/HistoryDataSearchVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RemoteParamVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ResolveResultVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SessionContentVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/StationSearchVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/UpdateStationVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/UpdateUsualVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/AgentLogController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/ControlController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataSourceController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TableColumnController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TableInfoController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TablePropertyController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataRecordEntity.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DatasourceEntity.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileInfo.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/SyncPropertyEntity.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TableInfoEntity.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TablePropertyEntity.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/AgentLogMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/ControlMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DatasourceMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileInfoMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/TableInfoMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/TablePropertyMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/AgentLogService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/ControlService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataSourceService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TableColumnService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TableInfoService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TablePropertyService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/IdsRequest.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/LabelRequest.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/VectorUrlResponse.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/manager/SessionRedisManager.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/dto/MessageDTO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/dto/QuestionDTO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/service/QuestionHandlerService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/FrontEndInteractiveSchedule.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/RunReportAnalyseSchedule.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/XxlJobHandlerConstant.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/config/WebSocketConfig.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/constants/RedisKeyConstants.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/handler/InteractiveHandler.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/server/InteractiveWsServer.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/service/InteractiveWsService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/service/WebSocketService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/sessionManager/InteractiveSessionManager.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/controller/WhitelistController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/mapper/WhitelistMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/service/WhitelistService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/config/ZhipuAiConfig.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/AnalysisModel.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/BaseEnum.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ComparisonType.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ErrorCode.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ResultDataType.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ResultStrategyType.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/controller/ZhipuAnalysisController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalyser.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisFactory.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultStrategy.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/BooleanParser.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/IntegerParser.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/ResultDataParser.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/StringParser.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/ZhipuAnalysisService.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java create mode 100644 hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java create mode 100644 hzims-service/gglm-big-model/src/main/resources/db/1.0.0.sql create mode 100644 hzims-service/gglm-big-model/src/main/resources/db/2.0.0.sql create mode 100644 hzims-service/gglm-big-model/src/main/resources/db/2.0.1.sql create mode 100644 hzims-service/gglm-big-model/src/main/resources/db/2.0.2.sql create mode 100644 hzims-service/gglm-big-model/src/main/resources/template/template.yml delete mode 100644 hzims-service/hzims-big-model/pom.xml delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/DataSourceExecuteController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/RemoteController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/wrapper/CanvasSyncWrapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/ThreadPoolManager.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateConfigure.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateProperties.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/controller/WeaviateController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/dto/WeaviateSaveDTO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/util/WeaviateUtil.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/ControlController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/SyncPropertyEntity.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/AgentLogMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/ControlMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/KnowledgeFileInfoMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/VectorParamMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/ControlService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorUrlResponse.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/RunReportAnalyseSchedule.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/config/WebSocketConfig.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/server/InteractiveWsServer.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/controller/WhitelistController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/mapper/WhitelistMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/WhitelistService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfig.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/AnalysisModel.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/BaseEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ComparisonType.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisFactory.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultStrategy.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/BooleanParser.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/IntegerParser.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/ResultDataParser.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/StringParser.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java delete mode 100644 hzims-service/hzims-big-model/src/main/resources/db/1.0.0.sql delete mode 100644 hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql delete mode 100644 hzims-service/hzims-big-model/src/main/resources/db/2.0.1.sql delete mode 100644 hzims-service/hzims-big-model/src/main/resources/db/2.0.2.sql delete mode 100644 hzims-service/hzims-big-model/src/main/resources/template/template.yml diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java new file mode 100644 index 0000000..8453f4f --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/BigModelConstants.java @@ -0,0 +1,14 @@ +package com.hnac.gglm.bigmodel; + +/** + * @Author: huangxing + * @Date: 2024/04/26 10:15 + */ +public interface BigModelConstants { + + /**注册至NACOS服务名**/ + String APP_NAME = "gglm-big-model"; + /**前端展示服务名**/ + String MODULE_NAME = "大模型管理"; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/constants/MqttTopicConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/constants/MqttTopicConstants.java new file mode 100644 index 0000000..eeb7b7c --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/constants/MqttTopicConstants.java @@ -0,0 +1,30 @@ +package com.hnac.gglm.bigmodel.api.constants; + +/** + * @Author: huangxing + * @Date: 2024/08/09 13:48 + */ +public interface MqttTopicConstants { + + /** + * 新增视频主题 + */ + String TOPIC_VIDEO_INSERT = "topic_video_insert"; + + /** + * 删除视频主题 + */ + String TOPIC_VIDEO_DELETE = "topic_video_delete"; + + /** + * 月报分析结果 + */ + String RUN_REPORT_ANALYSE_RESULT = "topic_run_report_analyse_result"; + + /** + * 识别结果 + */ + String IDENTITY_RESULT = "topic_hznlm_identify_result"; + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/BigModelAnalysisRequestDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/BigModelAnalysisRequestDTO.java new file mode 100644 index 0000000..cb533c1 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/BigModelAnalysisRequestDTO.java @@ -0,0 +1,26 @@ +package com.hnac.gglm.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/8/12 16:02 + */ +@Data +@ApiModel(value = "大模型分析",description = "大模型分析参数") +public class BigModelAnalysisRequestDTO { + + @ApiModelProperty("策略编码") + private List codeList; + + @ApiModelProperty(value = "检测类型子类") + private List checkTypeSonList; + + @ApiModelProperty("文件地址或文件的base64文件内容") + private String url; +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/BigModelAnalysisResponseDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/BigModelAnalysisResponseDTO.java new file mode 100644 index 0000000..f1caf75 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/BigModelAnalysisResponseDTO.java @@ -0,0 +1,59 @@ +package com.hnac.gglm.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Optional; + +/** + * @Author: ypj + * @Date: 2024/8/19 10:38 + */ +@Data +@ApiModel(description = "分析返回信息") +public class BigModelAnalysisResponseDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "是否成功", required = true) + private Boolean success = null; + + @ApiModelProperty(value = "分析结果数据列表") + private List data; + + @ApiModelProperty(value = "状态码", required = true) + private int code; + + @ApiModelProperty(value = "返回消息") + private String msg; + + + @Data + @ApiModel(description = "分析结果") + public static class BigModelAnalysisResult implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "承载数据") + private Object result; + + @ApiModelProperty(value = "结果字符串") + private String resultStr; + + @ApiModelProperty(value = "结果描述") + private String description; + + @ApiModelProperty(value = "巡检识别子类型") + private String checkTypeSon; + + @ApiModelProperty(value = "消息") + private String message; + } + + public Boolean getSuccess() { + return Optional.ofNullable(success).orElse(data != null); + } +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/CanvasSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/CanvasSyncDTO.java new file mode 100644 index 0000000..acfeb49 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/CanvasSyncDTO.java @@ -0,0 +1,20 @@ +package com.hnac.gglm.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:48 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "实时画面同步DTO对象",description = "实时画面同步DTO对象") +public class CanvasSyncDTO extends SyncDTO implements Serializable { + + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/ControlSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/ControlSyncDTO.java new file mode 100644 index 0000000..ecd5f55 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/ControlSyncDTO.java @@ -0,0 +1,20 @@ +package com.hnac.gglm.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:51 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "遥控同步DTO对象",description = "遥控同步DTO对象") +public class ControlSyncDTO extends SyncDTO implements Serializable { + + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/SyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/SyncDTO.java new file mode 100644 index 0000000..56a4454 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/SyncDTO.java @@ -0,0 +1,50 @@ +package com.hnac.gglm.bigmodel.api.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:33 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "视频同步DTO",description = "视频同步DTO") +public class SyncDTO implements Serializable { + + @ApiModelProperty("数据ID") + private String id; + + @ApiModelProperty("在问答流程中使用的数据ID") + @JSONField(name = "item_id") + private String itemId; + + @ApiModelProperty("用于匹配的名字。应包含所有匹配相关信息") + @JSONField(name = "item_name") + private String itemName; + +// @ApiModelProperty("类型,可为'平台'或'业务'") +// private String type; + + @ApiModelProperty("站点I,平台yk必须有,否则可为null") + @JSONField(name = "station_id") + private String stationId; + + @ApiModelProperty("站点名称,平台yk必须有,否则可为null") + @JSONField(name = "station_name") + private String stationName; + +// @ApiModelProperty("设备ID,平台yk必须有,否则可为null") +// @JSONField(name = "device_id") +// private String deviceId; +// +// @ApiModelProperty("设备名称,平台yk必须有,否则可为null") +// @JSONField(name = "device_name") +// private String deviceName; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/VideoSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/VideoSyncDTO.java new file mode 100644 index 0000000..4e85483 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/VideoSyncDTO.java @@ -0,0 +1,22 @@ +package com.hnac.gglm.bigmodel.api.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:42 + */ +@ApiModel(value = "视频同步DTO对象",description = "视频同步DTO对象") +@Data +@EqualsAndHashCode +public class VideoSyncDTO extends SyncDTO implements Serializable { + + @JSONField(name = "video_name") + private String name; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IBigModelAnalysisClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IBigModelAnalysisClient.java new file mode 100644 index 0000000..3b058e8 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IBigModelAnalysisClient.java @@ -0,0 +1,21 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.hnac.gglm.bigmodel.BigModelConstants; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisResponseDTO; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @Author: ypj + * @Date: 2024/8/12 15:57 + */ +@FeignClient(name = BigModelConstants.APP_NAME) +public interface IBigModelAnalysisClient { + String PREFIX_API = "feign/bigModel"; + + @PostMapping(PREFIX_API + "/analysis") + BigModelAnalysisResponseDTO analysis(@RequestBody BigModelAnalysisRequestDTO analysisInfo); +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/ICanvasSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/ICanvasSyncClient.java new file mode 100644 index 0000000..449e6c0 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/ICanvasSyncClient.java @@ -0,0 +1,12 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.hnac.gglm.bigmodel.api.dto.CanvasSyncDTO; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:53 + */ +public interface ICanvasSyncClient extends ISyncClient { + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IControlSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IControlSyncClient.java new file mode 100644 index 0000000..251ebb5 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IControlSyncClient.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.hnac.gglm.bigmodel.api.dto.ControlSyncDTO; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:55 + */ +public interface IControlSyncClient extends ISyncClient { + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IDataAnalyseClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IDataAnalyseClient.java new file mode 100644 index 0000000..ef4dcf4 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IDataAnalyseClient.java @@ -0,0 +1,31 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.hnac.gglm.bigmodel.BigModelConstants; +import com.hnac.gglm.bigmodel.business.dto.RunReportAnalyseRequest; +import com.hnac.gglm.bigmodel.business.dto.RunReportDataAnalyseDTO; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/14 19:16 + */ +@FeignClient(name = BigModelConstants.APP_NAME) +public interface IDataAnalyseClient { + + String PREFIX_API = "/feign/dataAnalyse"; + String SMART_REPORT_GENERATE_POWER = PREFIX_API + "/smartReportGeneratePower"; + + /** + * 发起机组发电量智能报表分析问答 + * @param req 分析数据 + * @return 分析结果 + */ + @PostMapping(SMART_REPORT_GENERATE_POWER) + R smartReportGeneratePower(@RequestBody RunReportAnalyseRequest req); + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/ISyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/ISyncClient.java new file mode 100644 index 0000000..2009670 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/ISyncClient.java @@ -0,0 +1,40 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.hnac.gglm.bigmodel.api.dto.SyncDTO; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:32 + */ +public interface ISyncClient { + + String SAVE_BATCH = "/saveBatch"; + String DELETE_BY_IDS = "/deleteByIds"; + String DELETE_BY_STATION_ID = "/deleteByStationId"; + + /** + * 同步 - 新增对象 + * @param syncDTO 同步对象列表 + * @return 同步结果 + */ + R saveBatch(List syncDTO); + + /** + * 同步 - 删除对象 + * @param ids 主键id按逗号分隔 + * @return 删除结果 + */ + R deleteByIds(String ids); + + /** + * 同步 - 根据站点删除对象 + * @param stationId 站点ID + * @return 删除结果 + */ + R deleteByStationId(String stationId); + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IVideoSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IVideoSyncClient.java new file mode 100644 index 0000000..dd76ca9 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IVideoSyncClient.java @@ -0,0 +1,32 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.hnac.gglm.bigmodel.BigModelConstants; +import com.hnac.gglm.bigmodel.api.dto.SyncDTO; +import com.hnac.gglm.bigmodel.api.dto.VideoSyncDTO; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:31 + */ +@FeignClient(name = BigModelConstants.APP_NAME) +public interface IVideoSyncClient extends ISyncClient { + + String PREFIX_API = "/feign/sync/video"; + + @Override + @PostMapping(PREFIX_API + SAVE_BATCH) + R saveBatch(@RequestBody List syncDTO); + + @Override + @DeleteMapping(PREFIX_API + DELETE_BY_IDS) + R deleteByIds(@RequestParam("ids") String ids); + + @Override + @DeleteMapping(PREFIX_API + DELETE_BY_STATION_ID) + R deleteByStationId(@RequestParam("stationId") String stationId); +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/wrapper/BaseSyncWrapper.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/wrapper/BaseSyncWrapper.java new file mode 100644 index 0000000..96eab82 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/wrapper/BaseSyncWrapper.java @@ -0,0 +1,21 @@ +package com.hnac.gglm.bigmodel.api.wrapper; + +import com.hnac.gglm.bigmodel.api.dto.SyncDTO; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/08/20 09:23 + * @Describe 对象转换为同步对象基础类 + */ +public abstract class BaseSyncWrapper { + + public abstract S convert(O obj); + + public List listVO(List list) { + return list.stream().map(this::convert).collect(Collectors.toList()); + } + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/ControlDeviceAuthDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/ControlDeviceAuthDTO.java new file mode 100644 index 0000000..fd80b24 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/ControlDeviceAuthDTO.java @@ -0,0 +1,23 @@ +package com.hnac.gglm.bigmodel.business.dto; + +import com.hnac.gglm.bigmodel.interactive.dto.ControlDeviceDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 09:43 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "遥控设备鉴权DTO",description = "遥控设备鉴权DTO") +public class ControlDeviceAuthDTO extends ControlDeviceDTO implements Serializable { + + @ApiModelProperty("用户ID") + private String userId; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/PowerDataDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/PowerDataDTO.java new file mode 100644 index 0000000..8493773 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/PowerDataDTO.java @@ -0,0 +1,34 @@ +package com.hnac.gglm.bigmodel.business.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/08/13 20:07 + */ +@Data +@ApiModel("发电量 - 数据分析") +public class PowerDataDTO implements Serializable { + + @ApiModelProperty("查询日期") + private String date; + + @ApiModelProperty("发电量") + private Double value; + + @JSONField(name = "run_time") + @ApiModelProperty("运行时长") + private Double runTime; + + @ApiModelProperty("发电单位") + private String unit = "万kWh"; + + @ApiModelProperty("运行时长单位") + private String runtimeUnit = "h"; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunReportAnalyseRequest.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunReportAnalyseRequest.java new file mode 100644 index 0000000..aacbe85 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunReportAnalyseRequest.java @@ -0,0 +1,32 @@ +package com.hnac.gglm.bigmodel.business.dto; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/15 08:41 + */ +@Data +@EqualsAndHashCode +public class RunReportAnalyseRequest implements Serializable { + + /** + * 站点编号 + */ + private String stationCode; + + /** + * 查询月份 + */ + private String month; + + /** + * 分析内容 + */ + private List analyseDTOS; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunReportDataAnalyseDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunReportDataAnalyseDTO.java new file mode 100644 index 0000000..c7caaeb --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunReportDataAnalyseDTO.java @@ -0,0 +1,41 @@ +package com.hnac.gglm.bigmodel.business.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/13 20:16 + * @describe: 运行月报数据分析 + */ +@Data +@EqualsAndHashCode +public class RunReportDataAnalyseDTO implements Serializable { + + /** + * 设备名称 + */ + @JSONField(name = "name") + private String emName; + + /** + * 机组序号 + */ + @JSONField(serialize = false) + private Integer deviceOrder; + + /** + * 发电量数据 + */ + private List power; + + /** + * 告警数据 + */ + private List soe; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunTimeDataDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunTimeDataDTO.java new file mode 100644 index 0000000..0abcdea --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/RunTimeDataDTO.java @@ -0,0 +1,26 @@ +package com.hnac.gglm.bigmodel.business.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/08/13 20:10 + */ +@Data +@ApiModel("运行时长 - 数据分析") +public class RunTimeDataDTO implements Serializable { + + @ApiModelProperty("日期") + private String date; + + @ApiModelProperty("运行时长") + private Double value; + + @ApiModelProperty("单位") + private String unit = "h"; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/SoeDataDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/SoeDataDTO.java new file mode 100644 index 0000000..c4fdd7c --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/dto/SoeDataDTO.java @@ -0,0 +1,26 @@ +package com.hnac.gglm.bigmodel.business.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/08/13 20:13 + */ +@Data +@ApiModel("告警数据 - 数据分析") +public class SoeDataDTO implements Serializable { + + @ApiModelProperty("日期") + private String date; + + @ApiModelProperty("告警内容") + private String name; + + @ApiModelProperty("告警次数") + private Integer times; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/feign/IAuthClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/feign/IAuthClient.java new file mode 100644 index 0000000..6e90deb --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/business/feign/IAuthClient.java @@ -0,0 +1,45 @@ +package com.hnac.gglm.bigmodel.business.feign; + +import com.hnac.gglm.bigmodel.business.dto.ControlDeviceAuthDTO; +import org.springblade.core.tool.api.R; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/09 09:11 + * 鉴权接口 - 业务实现 + */ +public interface IAuthClient { + + /** + * 遥控鉴权 + * @param req 遥控信息 + * @return 鉴权结果 + */ + R remoteAuth(ControlDeviceAuthDTO req); + + /** + * 站点鉴权 + * @param userId 用户ID + * @param stationId 站点ID + * @return 鉴权结果 + */ + R stationAuth(String userId,String stationId); + + /** + * 机构鉴权 + * @param userId 用户ID + * @param deptId 站点ID + * @return 鉴权结果 + */ + R deptAuth(String userId,String deptId); + + /** + * 获取用户权限数据 + * @param userId 用户ID + * @return 权限数据 + */ + R> getAuthData(String userId); +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/ControlDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/ControlDTO.java new file mode 100644 index 0000000..fcd25d6 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/ControlDTO.java @@ -0,0 +1,36 @@ +package com.hnac.gglm.bigmodel.interactive.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/08 09:20 + */ +@ApiModel("设备控制DTO") +@Data +@EqualsAndHashCode +public class ControlDTO implements Serializable { + + @ApiModelProperty("用户ID") + @NotBlank + private String userId; + + @ApiModelProperty("会话ID") + @NotBlank + private String chatId; + + @ApiModelProperty("value目前有值、'大' '小' '最大' '最小' ‘开’ '关'") + private String value; + + @ApiModelProperty("遥控点位") + private List yks; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/ControlDeviceDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/ControlDeviceDTO.java new file mode 100644 index 0000000..24916b0 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/ControlDeviceDTO.java @@ -0,0 +1,38 @@ +package com.hnac.gglm.bigmodel.interactive.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/08 16:22 + */ +@Data +@ApiModel(value = "",description = "") +@EqualsAndHashCode +public class ControlDeviceDTO implements Serializable { + + @ApiModelProperty(value = "站点ID") + private String stationId; + + @ApiModelProperty(value = "设备ID") + @NotBlank + private String deviceId; + + @ApiModelProperty(value = "控制ID") + @NotBlank + private String itemId; + + @ApiModelProperty(value = "控制名称") + private String itemName; + + @ApiModelProperty(value = "遥控类型,平台、业务") + @NotBlank + private String type; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/req/ModelFunctionReq.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/req/ModelFunctionReq.java new file mode 100644 index 0000000..f29788a --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/req/ModelFunctionReq.java @@ -0,0 +1,31 @@ +package com.hnac.gglm.bigmodel.interactive.req; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/04/26 11:31 + */ +@Data +@ApiModel("大模型响应内容") +public class ModelFunctionReq implements Serializable { + + @ApiModelProperty("函数标识") + private String func; + + @ApiModelProperty("会话ID") + private String chatId; + + @ApiModelProperty("用户ID") + private String userId; + + @ApiModelProperty("函数参数") + private Map item; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AttrSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AttrSelectionVO.java new file mode 100644 index 0000000..2e990ee --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AttrSelectionVO.java @@ -0,0 +1,14 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/24 15:55 + */ +@Data +public class AttrSelectionVO extends SelectionVO implements Serializable { + private DataItemVO item; +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/DataItemVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/DataItemVO.java new file mode 100644 index 0000000..59975ac --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/DataItemVO.java @@ -0,0 +1,40 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/22 10:20 + */ +@Data +public class DataItemVO implements Serializable { + + private String name; + + @JSONField(name = "id") + private String attrId; + + @JSONField(name = "record_name") + private String attrName; + + @JSONField(name = "device_name") + private String deviceName; + + @JSONField(name = "device_id") + private String deviceId; + + @JSONField(name = "station_id") + private String projectId; + + @JSONField(name = "station_name") + private String projectName; + + @JSONField(name = "item_id") + private String signage; + + private String units; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/DataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/DataVO.java new file mode 100644 index 0000000..0c1d93c --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/DataVO.java @@ -0,0 +1,35 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/22 10:28 + */ +@Data +public class DataVO implements Serializable { + + /**数据查询类型:实时、历史**/ + private String type; + + @JSONField(name = "time_begin") + private String startTime; + + @JSONField(name = "time_end") + private String endTime; + + /**实时数据结果集**/ + private RealDataVO real; + + private DataItemVO item; + + /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ + private String method; + + @JSONField(name = "data_type") + private String dataType; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ExtraVO.java new file mode 100644 index 0000000..e2bb1e3 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ExtraVO.java @@ -0,0 +1,56 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/04/26 13:35 + */ +@Data +@ApiModel("响应内容") +public class ExtraVO implements Serializable { + + @ApiModelProperty("交互类型 1:打开页面,2:打开链接,3:参数传递,4:完善选项") + private String type; + + @ApiModelProperty("若为弹窗,则返回路由") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String route; + + @ApiModelProperty("链接显示文字") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String label; + + @ApiModelProperty("函数编号") + private String func; + + @ApiModelProperty("是否立即跳转") + private boolean isImmediatelyJump = false; + + @ApiModelProperty("附带参数") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map params; + + @ApiModelProperty("是否为特殊函数") + private boolean isSpecial; + + @ApiModelProperty("选项") + @JsonInclude(JsonInclude.Include.NON_NULL) + private List data; + + @JSONField(name = "agent_name") + private String agentName; + + @JSONField(name = "agent_data") + private Map agentData; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/FaultSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/FaultSelectionVO.java new file mode 100644 index 0000000..9508fa4 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/FaultSelectionVO.java @@ -0,0 +1,18 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/16 15:10 + */ +@Data +@EqualsAndHashCode +public class FaultSelectionVO extends SelectionVO implements Serializable { + + private Object item; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RealDataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RealDataVO.java new file mode 100644 index 0000000..a42d944 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RealDataVO.java @@ -0,0 +1,20 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/24 10:26 + */ +@Data +public class RealDataVO implements Serializable { + + private String time; + + private String value; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RemoteSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RemoteSelectionVO.java new file mode 100644 index 0000000..9e5f748 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RemoteSelectionVO.java @@ -0,0 +1,13 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/31 09:15 + */ +public class RemoteSelectionVO extends SelectionVO implements Serializable { + + private Object item; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ScadaSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ScadaSelectionVO.java new file mode 100644 index 0000000..d0ad161 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ScadaSelectionVO.java @@ -0,0 +1,18 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/11 16:21 + */ +@Data +@EqualsAndHashCode +public class ScadaSelectionVO extends SelectionVO implements Serializable { + + private Object item; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SelectionVO.java new file mode 100644 index 0000000..0cdfbc9 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SelectionVO.java @@ -0,0 +1,23 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 16:30 + */ +@Data +public class SelectionVO implements Serializable { + + /**选项ID**/ + @JSONField(name = "item_id") + private String itemId; + + /**选项名称**/ + @JSONField(name = "item_name") + private String itemName; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/StationSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/StationSelectionVO.java new file mode 100644 index 0000000..da56dc4 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/StationSelectionVO.java @@ -0,0 +1,15 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.hnac.gglm.bigmodel.interactive.vo.SelectionVO; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 16:32 + */ +@Data +public class StationSelectionVO extends SelectionVO implements Serializable { + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/VideoSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/VideoSelectionVO.java new file mode 100644 index 0000000..ef81792 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/VideoSelectionVO.java @@ -0,0 +1,16 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/11 16:20 + */ +@Data +@EqualsAndHashCode +public class VideoSelectionVO extends SelectionVO implements Serializable { + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/ControlEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/ControlEntity.java new file mode 100644 index 0000000..ffd2a44 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/ControlEntity.java @@ -0,0 +1,59 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/08/19 18:33 + */ +@Data +@EqualsAndHashCode +@ApiModel("设备控制实体类") +@TableName("data_yk") +public class ControlEntity extends TenantEntity implements Serializable { + + @ApiModelProperty(value = "itemId",required = true) + private String itemId; + + @ApiModelProperty(value = "站点名称") + @QueryField(condition = SqlCondition.LIKE) + private String stationName; + + @ApiModelProperty(value = "站点ID") + @QueryField(condition = SqlCondition.EQUAL) + private String stationId; + + @ApiModelProperty(value = "遥控的设备名称") + @QueryField(condition = SqlCondition.LIKE) + private String deviceName; + + @ApiModelProperty(value = "遥控的设备ID") + @QueryField(condition = SqlCondition.EQUAL) + private String deviceId; + + @TableField("yk_name") + @JSONField(name = "yk_name") + @ApiModelProperty(value = "遥控名称(不包含站点)",required = true) + @QueryField(condition = SqlCondition.LIKE) + private String remoteName; + + @ApiModelProperty(value = "用于展示和匹配的全称,一般可设为 站点名称-遥控名称",required = true) + @QueryField(condition = SqlCondition.LIKE) + private String itemName; + + @ApiModelProperty(value = "类型,可为平台、业务",required = true) + @QueryField(condition = SqlCondition.LIKE) + private String type; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/FunctionEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/FunctionEntity.java new file mode 100644 index 0000000..51d4ccd --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/FunctionEntity.java @@ -0,0 +1,48 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Size; + +/** + * @Author: huangxing + * @Date: 2024/04/26 10:46 + */ +@Data +@ApiModel(value = "大模型函数entity",description = "大模型函数entity") +@TableName("HZIMS_FUNCTION") +public class FunctionEntity extends TenantEntity { + + @ApiModelProperty("函数名称") + @QueryField(condition = SqlCondition.LIKE) + private String name; + + @ApiModelProperty(value = "函数编号") + @QueryField(condition = SqlCondition.EQUAL) + private String code; + + @ApiModelProperty("动作类型") + @QueryField(condition = SqlCondition.EQUAL) + private String type; + + @ApiModelProperty("是否需要确认,0:否,1:是") + @QueryField(condition = SqlCondition.EQUAL) + private Boolean isConfirm; + + @ApiModelProperty("跳转路径") + private String path; + + @ApiModelProperty("描述") + private String remake; + + @ApiModelProperty("路由") + private String route; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WeaviateEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WeaviateEntity.java new file mode 100644 index 0000000..97ab2fa --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WeaviateEntity.java @@ -0,0 +1,23 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/08/22 19:35 + */ +@Data +@EqualsAndHashCode +public class WeaviateEntity implements Serializable { + + @JSONField(name = "item_id") + private String itemId; + + @JSONField(name = "item_name") + private String itemName; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WhitelistEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WhitelistEntity.java new file mode 100644 index 0000000..653c4a7 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WhitelistEntity.java @@ -0,0 +1,24 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * @author ysj + */ +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_whitelist") +@ApiModel(value = "白名单实体类",description = "大模型白名单") +@Data +public class WhitelistEntity extends TenantEntity { + + @ApiModelProperty(value = "用户Id") + private Long userId; + + @ApiModelProperty(value = "用户登录账号") + private String account; +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/BigModelConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/BigModelConstants.java deleted file mode 100644 index 91d93f8..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/BigModelConstants.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnac.hzims.bigmodel; - -/** - * @Author: huangxing - * @Date: 2024/04/26 10:15 - */ -public interface BigModelConstants { - - /**注册至NACOS服务名**/ - String APP_NAME = "hzims-big-model"; - /**前端展示服务名**/ - String MODULE_NAME = "大模型管理"; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java deleted file mode 100644 index d4166d4..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hnac.hzims.bigmodel.api.constants; - -/** - * @Author: huangxing - * @Date: 2024/08/09 13:48 - */ -public interface MqttTopicConstants { - - /** - * 新增视频主题 - */ - String TOPIC_VIDEO_INSERT = "topic_video_insert"; - - /** - * 删除视频主题 - */ - String TOPIC_VIDEO_DELETE = "topic_video_delete"; - - /** - * 月报分析结果 - */ - String RUN_REPORT_ANALYSE_RESULT = "topic_run_report_analyse_result"; - - /** - * 识别结果 - */ - String IDENTITY_RESULT = "topic_hznlm_identify_result"; - - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisRequestDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisRequestDTO.java deleted file mode 100644 index 18dbbbd..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisRequestDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.hnac.hzims.bigmodel.api.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * @Author: ypj - * @Date: 2024/8/12 16:02 - */ -@Data -@ApiModel(value = "大模型分析",description = "大模型分析参数") -public class BigModelAnalysisRequestDTO { - - @ApiModelProperty("策略编码") - private List codeList; - - @ApiModelProperty(value = "检测类型子类") - private List checkTypeSonList; - - @ApiModelProperty("文件地址或文件的base64文件内容") - private String url; -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java deleted file mode 100644 index 5c9cb9c..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.hnac.hzims.bigmodel.api.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; -import java.util.Optional; - -/** - * @Author: ypj - * @Date: 2024/8/19 10:38 - */ -@Data -@ApiModel(description = "分析返回信息") -public class BigModelAnalysisResponseDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty(value = "是否成功", required = true) - private Boolean success = null; - - @ApiModelProperty(value = "分析结果数据列表") - private List data; - - @ApiModelProperty(value = "状态码", required = true) - private int code; - - @ApiModelProperty(value = "返回消息") - private String msg; - - - @Data - @ApiModel(description = "分析结果") - public static class BigModelAnalysisResult implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty(value = "承载数据") - private Object result; - - @ApiModelProperty(value = "结果字符串") - private String resultStr; - - @ApiModelProperty(value = "结果描述") - private String description; - - @ApiModelProperty(value = "巡检识别子类型") - private String checkTypeSon; - - @ApiModelProperty(value = "消息") - private String message; - } - - public Boolean getSuccess() { - return Optional.ofNullable(success).orElse(data != null); - } -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java deleted file mode 100644 index 45a4bd0..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.api.dto; - -import io.swagger.annotations.ApiModel; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/09 19:48 - */ -@Data -@EqualsAndHashCode -@ApiModel(value = "实时画面同步DTO对象",description = "实时画面同步DTO对象") -public class CanvasSyncDTO extends SyncDTO implements Serializable { - - - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java deleted file mode 100644 index a1121fd..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.api.dto; - -import io.swagger.annotations.ApiModel; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/09 19:51 - */ -@Data -@EqualsAndHashCode -@ApiModel(value = "遥控同步DTO对象",description = "遥控同步DTO对象") -public class ControlSyncDTO extends SyncDTO implements Serializable { - - - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java deleted file mode 100644 index 3820364..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.hnac.hzims.bigmodel.api.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/09 19:33 - */ -@Data -@EqualsAndHashCode -@ApiModel(value = "视频同步DTO",description = "视频同步DTO") -public class SyncDTO implements Serializable { - - @ApiModelProperty("数据ID") - private String id; - - @ApiModelProperty("在问答流程中使用的数据ID") - @JSONField(name = "item_id") - private String itemId; - - @ApiModelProperty("用于匹配的名字。应包含所有匹配相关信息") - @JSONField(name = "item_name") - private String itemName; - -// @ApiModelProperty("类型,可为'平台'或'业务'") -// private String type; - - @ApiModelProperty("站点I,平台yk必须有,否则可为null") - @JSONField(name = "station_id") - private String stationId; - - @ApiModelProperty("站点名称,平台yk必须有,否则可为null") - @JSONField(name = "station_name") - private String stationName; - -// @ApiModelProperty("设备ID,平台yk必须有,否则可为null") -// @JSONField(name = "device_id") -// private String deviceId; -// -// @ApiModelProperty("设备名称,平台yk必须有,否则可为null") -// @JSONField(name = "device_name") -// private String deviceName; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java deleted file mode 100644 index e813d39..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.bigmodel.api.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import io.swagger.annotations.ApiModel; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/09 19:42 - */ -@ApiModel(value = "视频同步DTO对象",description = "视频同步DTO对象") -@Data -@EqualsAndHashCode -public class VideoSyncDTO extends SyncDTO implements Serializable { - - @JSONField(name = "video_name") - private String name; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java deleted file mode 100644 index e839026..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; -import org.springblade.core.tool.api.R; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -/** - * @Author: ypj - * @Date: 2024/8/12 15:57 - */ -@FeignClient(name = BigModelConstants.APP_NAME) -public interface IBigModelAnalysisClient { - String PREFIX_API = "feign/bigModel"; - - @PostMapping(PREFIX_API + "/analysis") - BigModelAnalysisResponseDTO analysis(@RequestBody BigModelAnalysisRequestDTO analysisInfo); -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java deleted file mode 100644 index e92cfec..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.hnac.hzims.bigmodel.api.dto.CanvasSyncDTO; - -/** - * @Author: huangxing - * @Date: 2024/07/09 19:53 - */ -public interface ICanvasSyncClient extends ISyncClient { - - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java deleted file mode 100644 index f35a680..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.hnac.hzims.bigmodel.api.dto.ControlSyncDTO; - -/** - * @Author: huangxing - * @Date: 2024/07/09 19:55 - */ -public interface IControlSyncClient extends ISyncClient { - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IDataAnalyseClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IDataAnalyseClient.java deleted file mode 100644 index 7ced115..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IDataAnalyseClient.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; -import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO; -import org.springblade.core.tool.api.R; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/08/14 19:16 - */ -@FeignClient(name = BigModelConstants.APP_NAME) -public interface IDataAnalyseClient { - - String PREFIX_API = "/feign/dataAnalyse"; - String SMART_REPORT_GENERATE_POWER = PREFIX_API + "/smartReportGeneratePower"; - - /** - * 发起机组发电量智能报表分析问答 - * @param req 分析数据 - * @return 分析结果 - */ - @PostMapping(SMART_REPORT_GENERATE_POWER) - R smartReportGeneratePower(@RequestBody RunReportAnalyseRequest req); - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java deleted file mode 100644 index 1111715..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.hnac.hzims.bigmodel.api.dto.SyncDTO; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.RequestBody; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/07/09 19:32 - */ -public interface ISyncClient { - - String SAVE_BATCH = "/saveBatch"; - String DELETE_BY_IDS = "/deleteByIds"; - String DELETE_BY_STATION_ID = "/deleteByStationId"; - - /** - * 同步 - 新增对象 - * @param syncDTO 同步对象列表 - * @return 同步结果 - */ - R saveBatch(List syncDTO); - - /** - * 同步 - 删除对象 - * @param ids 主键id按逗号分隔 - * @return 删除结果 - */ - R deleteByIds(String ids); - - /** - * 同步 - 根据站点删除对象 - * @param stationId 站点ID - * @return 删除结果 - */ - R deleteByStationId(String stationId); - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java deleted file mode 100644 index ea5c254..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.api.dto.SyncDTO; -import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; -import org.springblade.core.tool.api.R; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/07/09 19:31 - */ -@FeignClient(name = BigModelConstants.APP_NAME) -public interface IVideoSyncClient extends ISyncClient { - - String PREFIX_API = "/feign/sync/video"; - - @Override - @PostMapping(PREFIX_API + SAVE_BATCH) - R saveBatch(@RequestBody List syncDTO); - - @Override - @DeleteMapping(PREFIX_API + DELETE_BY_IDS) - R deleteByIds(@RequestParam("ids") String ids); - - @Override - @DeleteMapping(PREFIX_API + DELETE_BY_STATION_ID) - R deleteByStationId(@RequestParam("stationId") String stationId); -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/wrapper/BaseSyncWrapper.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/wrapper/BaseSyncWrapper.java deleted file mode 100644 index 4cef0d1..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/wrapper/BaseSyncWrapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.bigmodel.api.wrapper; - -import com.hnac.hzims.bigmodel.api.dto.SyncDTO; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/08/20 09:23 - * @Describe 对象转换为同步对象基础类 - */ -public abstract class BaseSyncWrapper { - - public abstract S convert(O obj); - - public List listVO(List list) { - return list.stream().map(this::convert).collect(Collectors.toList()); - } - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java deleted file mode 100644 index b64fc69..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hnac.hzims.bigmodel.business.dto; - -import com.hnac.hzims.bigmodel.interactive.dto.ControlDeviceDTO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/09 09:43 - */ -@Data -@EqualsAndHashCode -@ApiModel(value = "遥控设备鉴权DTO",description = "遥控设备鉴权DTO") -public class ControlDeviceAuthDTO extends ControlDeviceDTO implements Serializable { - - @ApiModelProperty("用户ID") - private String userId; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java deleted file mode 100644 index 429369b..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/PowerDataDTO.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.hnac.hzims.bigmodel.business.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/08/13 20:07 - */ -@Data -@ApiModel("发电量 - 数据分析") -public class PowerDataDTO implements Serializable { - - @ApiModelProperty("查询日期") - private String date; - - @ApiModelProperty("发电量") - private Double value; - - @JSONField(name = "run_time") - @ApiModelProperty("运行时长") - private Double runTime; - - @ApiModelProperty("发电单位") - private String unit = "万kWh"; - - @ApiModelProperty("运行时长单位") - private String runtimeUnit = "h"; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportAnalyseRequest.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportAnalyseRequest.java deleted file mode 100644 index be52daa..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportAnalyseRequest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.bigmodel.business.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/08/15 08:41 - */ -@Data -@EqualsAndHashCode -public class RunReportAnalyseRequest implements Serializable { - - /** - * 站点编号 - */ - private String stationCode; - - /** - * 查询月份 - */ - private String month; - - /** - * 分析内容 - */ - private List analyseDTOS; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportDataAnalyseDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportDataAnalyseDTO.java deleted file mode 100644 index 92c7949..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportDataAnalyseDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.hnac.hzims.bigmodel.business.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/08/13 20:16 - * @describe: 运行月报数据分析 - */ -@Data -@EqualsAndHashCode -public class RunReportDataAnalyseDTO implements Serializable { - - /** - * 设备名称 - */ - @JSONField(name = "name") - private String emName; - - /** - * 机组序号 - */ - @JSONField(serialize = false) - private Integer deviceOrder; - - /** - * 发电量数据 - */ - private List power; - - /** - * 告警数据 - */ - private List soe; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunTimeDataDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunTimeDataDTO.java deleted file mode 100644 index d3cc184..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunTimeDataDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.hnac.hzims.bigmodel.business.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/08/13 20:10 - */ -@Data -@ApiModel("运行时长 - 数据分析") -public class RunTimeDataDTO implements Serializable { - - @ApiModelProperty("日期") - private String date; - - @ApiModelProperty("运行时长") - private Double value; - - @ApiModelProperty("单位") - private String unit = "h"; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/SoeDataDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/SoeDataDTO.java deleted file mode 100644 index f9f7460..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/SoeDataDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.hnac.hzims.bigmodel.business.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/08/13 20:13 - */ -@Data -@ApiModel("告警数据 - 数据分析") -public class SoeDataDTO implements Serializable { - - @ApiModelProperty("日期") - private String date; - - @ApiModelProperty("告警内容") - private String name; - - @ApiModelProperty("告警次数") - private Integer times; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java deleted file mode 100644 index 5301c0d..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.hnac.hzims.bigmodel.business.feign; - -import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; -import org.springblade.core.tool.api.R; - -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/07/09 09:11 - * 鉴权接口 - 业务实现 - */ -public interface IAuthClient { - - /** - * 遥控鉴权 - * @param req 遥控信息 - * @return 鉴权结果 - */ - R remoteAuth(ControlDeviceAuthDTO req); - - /** - * 站点鉴权 - * @param userId 用户ID - * @param stationId 站点ID - * @return 鉴权结果 - */ - R stationAuth(String userId,String stationId); - - /** - * 机构鉴权 - * @param userId 用户ID - * @param deptId 站点ID - * @return 鉴权结果 - */ - R deptAuth(String userId,String deptId); - - /** - * 获取用户权限数据 - * @param userId 用户ID - * @return 权限数据 - */ - R> getAuthData(String userId); -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/database/entity/WeaviateEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/database/entity/WeaviateEntity.java deleted file mode 100644 index 6c2b3ba..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/database/entity/WeaviateEntity.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hnac.hzims.bigmodel.database.entity; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/08/22 19:35 - */ -@Data -@EqualsAndHashCode -public class WeaviateEntity implements Serializable { - - @JSONField(name = "item_id") - private String itemId; - - @JSONField(name = "item_name") - private String itemName; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/FunctionEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/FunctionEntity.java deleted file mode 100644 index dd6ba36..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/FunctionEntity.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.hnac.hzims.bigmodel.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springblade.core.mp.support.QueryField; -import org.springblade.core.mp.support.SqlCondition; -import org.springblade.core.tenant.mp.TenantEntity; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Size; - -/** - * @Author: huangxing - * @Date: 2024/04/26 10:46 - */ -@Data -@ApiModel(value = "大模型函数entity",description = "大模型函数entity") -@TableName("HZIMS_FUNCTION") -public class FunctionEntity extends TenantEntity { - - @ApiModelProperty("函数名称") - @QueryField(condition = SqlCondition.LIKE) - private String name; - - @ApiModelProperty(value = "函数编号") - @QueryField(condition = SqlCondition.EQUAL) - private String code; - - @ApiModelProperty("动作类型") - @QueryField(condition = SqlCondition.EQUAL) - private String type; - - @ApiModelProperty("是否需要确认,0:否,1:是") - @QueryField(condition = SqlCondition.EQUAL) - private Boolean isConfirm; - - @ApiModelProperty("跳转路径") - private String path; - - @ApiModelProperty("描述") - private String remake; - - @ApiModelProperty("路由") - private String route; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java deleted file mode 100644 index cc563f0..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.hnac.hzims.bigmodel.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.tenant.mp.TenantEntity; - -/** - * @author ysj - */ -@EqualsAndHashCode(callSuper = true) -@TableName("hzims_whitelist") -@ApiModel(value = "白名单实体类",description = "大模型白名单") -@Data -public class WhitelistEntity extends TenantEntity { - - @ApiModelProperty(value = "用户Id") - private Long userId; - - @ApiModelProperty(value = "用户登录账号") - private String account; -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java deleted file mode 100644 index bc28e67..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/07/08 09:20 - */ -@ApiModel("设备控制DTO") -@Data -@EqualsAndHashCode -public class ControlDTO implements Serializable { - - @ApiModelProperty("用户ID") - @NotBlank - private String userId; - - @ApiModelProperty("会话ID") - @NotBlank - private String chatId; - - @ApiModelProperty("value目前有值、'大' '小' '最大' '最小' ‘开’ '关'") - private String value; - - @ApiModelProperty("遥控点位") - private List yks; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java deleted file mode 100644 index 40e3516..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/08 16:22 - */ -@Data -@ApiModel(value = "",description = "") -@EqualsAndHashCode -public class ControlDeviceDTO implements Serializable { - - @ApiModelProperty(value = "站点ID") - private String stationId; - - @ApiModelProperty(value = "设备ID") - @NotBlank - private String deviceId; - - @ApiModelProperty(value = "控制ID") - @NotBlank - private String itemId; - - @ApiModelProperty(value = "控制名称") - private String itemName; - - @ApiModelProperty(value = "遥控类型,平台、业务") - @NotBlank - private String type; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java deleted file mode 100644 index 3977291..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.req; - -import com.alibaba.fastjson.annotation.JSONField; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:31 - */ -@Data -@ApiModel("大模型响应内容") -public class ModelFunctionReq implements Serializable { - - @ApiModelProperty("函数标识") - private String func; - - @ApiModelProperty("会话ID") - private String chatId; - - @ApiModelProperty("用户ID") - private String userId; - - @ApiModelProperty("函数参数") - private Map item; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java deleted file mode 100644 index 67f0011..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/24 15:55 - */ -@Data -public class AttrSelectionVO extends SelectionVO implements Serializable { - private DataItemVO item; -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java deleted file mode 100644 index c0e20f9..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/22 10:20 - */ -@Data -public class DataItemVO implements Serializable { - - private String name; - - @JSONField(name = "id") - private String attrId; - - @JSONField(name = "record_name") - private String attrName; - - @JSONField(name = "device_name") - private String deviceName; - - @JSONField(name = "device_id") - private String deviceId; - - @JSONField(name = "station_id") - private String projectId; - - @JSONField(name = "station_name") - private String projectName; - - @JSONField(name = "item_id") - private String signage; - - private String units; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java deleted file mode 100644 index b23874f..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/22 10:28 - */ -@Data -public class DataVO implements Serializable { - - /**数据查询类型:实时、历史**/ - private String type; - - @JSONField(name = "time_begin") - private String startTime; - - @JSONField(name = "time_end") - private String endTime; - - /**实时数据结果集**/ - private RealDataVO real; - - private DataItemVO item; - - /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ - private String method; - - @JSONField(name = "data_type") - private String dataType; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java deleted file mode 100644 index d9be4d7..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/04/26 13:35 - */ -@Data -@ApiModel("响应内容") -public class ExtraVO implements Serializable { - - @ApiModelProperty("交互类型 1:打开页面,2:打开链接,3:参数传递,4:完善选项") - private String type; - - @ApiModelProperty("若为弹窗,则返回路由") - @JsonInclude(JsonInclude.Include.NON_NULL) - private String route; - - @ApiModelProperty("链接显示文字") - @JsonInclude(JsonInclude.Include.NON_NULL) - private String label; - - @ApiModelProperty("函数编号") - private String func; - - @ApiModelProperty("是否立即跳转") - private boolean isImmediatelyJump = false; - - @ApiModelProperty("附带参数") - @JsonInclude(JsonInclude.Include.NON_NULL) - private Map params; - - @ApiModelProperty("是否为特殊函数") - private boolean isSpecial; - - @ApiModelProperty("选项") - @JsonInclude(JsonInclude.Include.NON_NULL) - private List data; - - @JSONField(name = "agent_name") - private String agentName; - - @JSONField(name = "agent_data") - private Map agentData; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java deleted file mode 100644 index a504076..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/16 15:10 - */ -@Data -@EqualsAndHashCode -public class FaultSelectionVO extends SelectionVO implements Serializable { - - private Object item; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java deleted file mode 100644 index 16a5a46..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.Data; -import org.springblade.core.tool.utils.DateUtil; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/24 10:26 - */ -@Data -public class RealDataVO implements Serializable { - - private String time; - - private String value; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java deleted file mode 100644 index 07d95d8..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/31 09:15 - */ -public class RemoteSelectionVO extends SelectionVO implements Serializable { - - private Object item; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java deleted file mode 100644 index 9b0f7e0..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/11 16:21 - */ -@Data -@EqualsAndHashCode -public class ScadaSelectionVO extends SelectionVO implements Serializable { - - private Object item; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java deleted file mode 100644 index e953435..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/09 16:30 - */ -@Data -public class SelectionVO implements Serializable { - - /**选项ID**/ - @JSONField(name = "item_id") - private String itemId; - - /**选项名称**/ - @JSONField(name = "item_name") - private String itemName; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java deleted file mode 100644 index 84209d9..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.hnac.hzims.bigmodel.interactive.vo.SelectionVO; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/09 16:32 - */ -@Data -public class StationSelectionVO extends SelectionVO implements Serializable { - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java deleted file mode 100644 index 0bcc529..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/11 16:20 - */ -@Data -@EqualsAndHashCode -public class VideoSelectionVO extends SelectionVO implements Serializable { - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java deleted file mode 100644 index d2176e8..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/ControlEntity.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import com.alibaba.fastjson.annotation.JSONField; -import com.baomidou.mybatisplus.annotation.SqlCondition; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.mp.support.QueryField; -import org.springblade.core.tenant.mp.TenantEntity; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/08/19 18:33 - */ -@Data -@EqualsAndHashCode -@ApiModel("设备控制实体类") -@TableName("data_yk") -public class ControlEntity extends TenantEntity implements Serializable { - - @ApiModelProperty(value = "itemId",required = true) - private String itemId; - - @ApiModelProperty(value = "站点名称") - @QueryField(condition = SqlCondition.LIKE) - private String stationName; - - @ApiModelProperty(value = "站点ID") - @QueryField(condition = SqlCondition.EQUAL) - private String stationId; - - @ApiModelProperty(value = "遥控的设备名称") - @QueryField(condition = SqlCondition.LIKE) - private String deviceName; - - @ApiModelProperty(value = "遥控的设备ID") - @QueryField(condition = SqlCondition.EQUAL) - private String deviceId; - - @TableField("yk_name") - @JSONField(name = "yk_name") - @ApiModelProperty(value = "遥控名称(不包含站点)",required = true) - @QueryField(condition = SqlCondition.LIKE) - private String remoteName; - - @ApiModelProperty(value = "用于展示和匹配的全称,一般可设为 站点名称-遥控名称",required = true) - @QueryField(condition = SqlCondition.LIKE) - private String itemName; - - @ApiModelProperty(value = "类型,可为平台、业务",required = true) - @QueryField(condition = SqlCondition.LIKE) - private String type; - -} diff --git a/hzims-service/gglm-big-model/pom.xml b/hzims-service/gglm-big-model/pom.xml new file mode 100644 index 0000000..b489d2e --- /dev/null +++ b/hzims-service/gglm-big-model/pom.xml @@ -0,0 +1,107 @@ + + + + com.hnac.hzims + hzims-service + 4.0.0-SNAPSHOT + + 4.0.0 + gglm-big-model + big-model + jar + + + + org.springblade + blade-common + + + org.springblade + blade-system-api + + + com.hnac.hzinfo.data + hzinfo-data-sdk + + + com.hnac.hzims + big-model-api + 4.0.0-SNAPSHOT + compile + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + + + + org.springframework.boot + spring-boot-starter-websocket + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + + com.xuxueli + xxl-job-core + + + com.baomidou + dynamic-datasource-spring-boot-starter + 3.5.0 + + + com.hnac.hzims + hzims-operational-api + + + + com.hnac.hzims + hzims-operational-api + 4.0.0-SNAPSHOT + + + com.hnac.hzinfo.data + hzinfo-data-sdk + + + com.hnac.hzims + equipment-api + + + com.baomidou + dynamic-datasource-spring-boot-starter + 3.5.0 + + + cn.bigmodel.openapi + oapi-java-sdk + release-V4-2.0.2 + + + io.weaviate + client + 4.7.0 + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + + + diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/GglmBigModelApplication.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/GglmBigModelApplication.java new file mode 100644 index 0000000..6a42867 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/GglmBigModelApplication.java @@ -0,0 +1,22 @@ +package com.hnac.gglm.bigmodel; + +import org.mybatis.spring.annotation.MapperScan; +import org.springblade.core.launch.BladeApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@SpringBootApplication(scanBasePackages = {"org.springblade", "com.hnac.*"}) +@MapperScan(basePackages = {"com.hnac.hzinfo.**.mapper","com.hnac.gglm.**.mapper"}) +@EnableFeignClients(basePackages = {"org.springblade", "com.hnac"}) +public class GglmBigModelApplication { + + public static void main(String[] args) { + BladeApplication.run(BigModelConstants.APP_NAME, GglmBigModelApplication.class, args); + } + +// @Override +// protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { +// return BladeApplication.createSpringApplicationBuilder(builder, BigModelConstants.APP_NAME, HzimsBigModelApplication.class); +// } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/constants/SyncTableEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/constants/SyncTableEnum.java new file mode 100644 index 0000000..ec29c51 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/constants/SyncTableEnum.java @@ -0,0 +1,28 @@ +package com.hnac.gglm.bigmodel.api.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Author: huangxing + * @Date: 2024/08/09 09:13 + */ +@AllArgsConstructor +@Getter +public enum SyncTableEnum { + /**视频**/ + VIDEO("video"), + /**实时画面**/ + CANVAS("canvas"), + /**故障**/ + FAULT("fault"), + /**站点**/ + STATION("station"), + /**实时数据属性**/ + RECORD("record"), + /**遥控**/ + REMOTE("yk") + ; + private final String tableName; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/BigModelAnalysisClient.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/BigModelAnalysisClient.java new file mode 100644 index 0000000..364b1bb --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/BigModelAnalysisClient.java @@ -0,0 +1,25 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisResponseDTO; +import com.hnac.gglm.bigmodel.zhipuai.service.ZhipuAnalysisService; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: ypj + * @Date: 2024/8/12 16:10 + */ +@RestController +@AllArgsConstructor +public class BigModelAnalysisClient implements IBigModelAnalysisClient { + private final ZhipuAnalysisService analysisService; + + + @Override + @PostMapping(PREFIX_API + "/analysis") + public BigModelAnalysisResponseDTO analysis(BigModelAnalysisRequestDTO analysisInfo) { + return analysisService.multiAnalysis(analysisInfo); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/DataAnalyseClient.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/DataAnalyseClient.java new file mode 100644 index 0000000..a4acd58 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/DataAnalyseClient.java @@ -0,0 +1,31 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.alibaba.fastjson.JSON; +import com.hnac.gglm.bigmodel.business.dto.RunReportAnalyseRequest; +import com.hnac.gglm.bigmodel.business.dto.RunReportDataAnalyseDTO; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/14 19:15 + */ +@RestController +@AllArgsConstructor +@Slf4j +public class DataAnalyseClient implements IDataAnalyseClient { + + private final IHznlmInvokeService invokeService; + + @Override + public R smartReportGeneratePower(RunReportAnalyseRequest req) { + log.info("获取运行月报告传参详情为:{}", JSON.toJSONString(req)); + invokeService.smartReportGeneratePower(req); + return R.success("发起问答成功"); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/VideoSyncClient.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/VideoSyncClient.java new file mode 100644 index 0000000..a3c770f --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/VideoSyncClient.java @@ -0,0 +1,45 @@ +package com.hnac.gglm.bigmodel.api.feign; + +import com.hnac.gglm.bigmodel.api.constants.SyncTableEnum; +import com.hnac.gglm.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.gglm.bigmodel.api.service.SyncService; +import com.hnac.gglm.bigmodel.configuration.BigModelInvokeApi; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/09 20:17 + */ +@RestController +@AllArgsConstructor +public class VideoSyncClient implements IVideoSyncClient{ + + private final SyncService syncService; + private final BigModelInvokeApi bigModelInvokeApi; + + @Override + @PostMapping(PREFIX_API + SAVE_BATCH) + public R saveBatch(@RequestBody List syncDTO) { + syncService.insert(bigModelInvokeApi.getInsertVideo(),syncDTO); + return R.success("同步数据成功!"); + } + + @Override + @DeleteMapping(PREFIX_API + DELETE_BY_IDS) + public R deleteByIds(@RequestParam("ids") String ids) { + List idList = Func.toStrList(",", ids); + idList.forEach(id -> syncService.deleteById(id, SyncTableEnum.VIDEO)); + return R.success("同步数据成功!"); + } + + @Override + @DeleteMapping(PREFIX_API + DELETE_BY_STATION_ID) + public R deleteByStationId(@RequestParam("stationId") String stationId) { + return R.data(syncService.deleteByStationId(stationId,SyncTableEnum.VIDEO)); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/service/SyncService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/service/SyncService.java new file mode 100644 index 0000000..577c0d9 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/service/SyncService.java @@ -0,0 +1,66 @@ +package com.hnac.gglm.bigmodel.api.service; + +import com.alibaba.fastjson.TypeReference; +import com.hnac.gglm.bigmodel.api.constants.SyncTableEnum; +import com.hnac.gglm.bigmodel.api.dto.SyncDTO; +import com.hnac.gglm.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.gglm.bigmodel.configuration.BigModelInvokeApi; +import com.hnac.gglm.bigmodel.utils.RequestClientUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.BeanUtil; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/10 09:03 + */ +@Service +@Slf4j +@AllArgsConstructor +public class SyncService { + + private final BigModelInvokeApi bigModelInvokeApi; + + /** + * 通过站点id删除数据 + * @param stationId 站点ID + * @param syncTableEnum 同步表枚举类 + * @return 删除条数 + */ + public Integer deleteByStationId(String stationId, SyncTableEnum syncTableEnum) { + Map params = new HashMap<>(2); + params.put("station_id",stationId); + params.put("table_name", syncTableEnum.getTableName()); + return RequestClientUtil.postCall(bigModelInvokeApi.getDeleteByStationId(),params,new TypeReference(){}); + } + + /** + * 通过id删除数据 + * @param id 数据表主键ID + * @param syncTableEnum 同步表枚举类 + * @return 删除条数 + */ + public Integer deleteById(String id, SyncTableEnum syncTableEnum) { + Integer result = null; + Map params = new HashMap<>(2); + params.put("id",id); + params.put("table_name", syncTableEnum.getTableName()); +// result = RequestClientUtil.postCall(bigModelInvokeApi.getDeleteById(),params,new TypeReference(){}); + return result; + } + + /*** + * 添加数据 + * @param api 调用接口 + * @param data 同步数据 + */ + public void insert(String api, List data) { + Map params = BeanUtil.toMap(data); +// RequestClientUtil.postCall(api,params); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/consumer/VideoAddConsumer.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/consumer/VideoAddConsumer.java new file mode 100644 index 0000000..28c72fa --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/consumer/VideoAddConsumer.java @@ -0,0 +1,40 @@ +package com.hnac.gglm.bigmodel.business.consumer; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; +import com.hnac.gglm.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.gglm.bigmodel.api.feign.ISyncClient; +import com.hnac.gglm.bigmodel.api.feign.VideoSyncClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.mqtt.customer.IMqttReceive; +import org.springblade.mqtt.customer.annotation.MqttReceive; +import org.springframework.stereotype.Service; +import com.hnac.gglm.bigmodel.api.constants.MqttTopicConstants; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/09 10:33 + */ +@MqttReceive(topicName = MqttTopicConstants.TOPIC_VIDEO_INSERT) +@Service +@Slf4j +@AllArgsConstructor +public class VideoAddConsumer implements IMqttReceive { + + private final VideoSyncClient videoSyncClient; + + @Override + public void handlerMessage(String message) { + log.info("收到新增视频信息,消息内容体为:{}", message); + List videoSyncDTOS = JSONArray.parseArray(message, VideoSyncDTO.class); + if(Func.isNotEmpty(videoSyncDTOS)) { + videoSyncClient.saveBatch(videoSyncDTOS); + } + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/consumer/VideoRemoveConsumer.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/consumer/VideoRemoveConsumer.java new file mode 100644 index 0000000..cd6373f --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/consumer/VideoRemoveConsumer.java @@ -0,0 +1,36 @@ +package com.hnac.gglm.bigmodel.business.consumer; + +import com.alibaba.fastjson.JSONArray; +import com.hnac.gglm.bigmodel.api.constants.MqttTopicConstants; +import com.hnac.gglm.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.gglm.bigmodel.api.feign.VideoSyncClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.Func; +import org.springblade.mqtt.customer.IMqttReceive; +import org.springblade.mqtt.customer.annotation.MqttReceive; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/12 09:29 + */ +@MqttReceive(topicName = MqttTopicConstants.TOPIC_VIDEO_DELETE) +@Service +@Slf4j +@AllArgsConstructor +public class VideoRemoveConsumer implements IMqttReceive { + + private final VideoSyncClient videoSyncClient; + + + @Override + public void handlerMessage(String message) { + log.info("收到删除视频信息,消息内容体为:{}", message); + if(Func.isNotEmpty(message)) { + Func.toStrList(",",message).forEach(id -> videoSyncClient.deleteByIds(id)); + } + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/DataSourceExecuteController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/DataSourceExecuteController.java new file mode 100644 index 0000000..49781b4 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/DataSourceExecuteController.java @@ -0,0 +1,33 @@ +package com.hnac.gglm.bigmodel.business.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.business.service.DataSourceService; +import com.hnac.gglm.bigmodel.business.vo.SqlVO; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/28 14:07 + */ +@RestController +@RequestMapping("/dataSource/execute") +@AllArgsConstructor +public class DataSourceExecuteController { + + private final DataSourceService dataSourceService; + + @PostMapping("/executeQuery") + @ApiOperation("执行大模型sql") + @ApiOperationSupport(order = 1) + public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { + return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/RemoteController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/RemoteController.java new file mode 100644 index 0000000..435c2cb --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/RemoteController.java @@ -0,0 +1,34 @@ +package com.hnac.gglm.bigmodel.business.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.business.service.RemoteService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springblade.system.dto.ControlDTO; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:42 + */ +@AllArgsConstructor +@RequestMapping("/remote") +@RestController +@Api(value = "数据平台遥控指令管理",tags = "数据平台遥控指令管理") +public class RemoteController { + + private final RemoteService remoteService; + + @ApiOperation("下发遥控指令") + @ApiOperationSupport(order = 1) + @PostMapping("/sendRemoteControl") + public R sendRemoteControl(@RequestBody ControlDTO controlDTO) { + return remoteService.sendRemoteControl(controlDTO); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/feign/AuthClient.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/feign/AuthClient.java new file mode 100644 index 0000000..8b34084 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/feign/AuthClient.java @@ -0,0 +1,87 @@ +package com.hnac.gglm.bigmodel.business.feign; + +import com.hnac.gglm.bigmodel.business.dto.ControlDeviceAuthDTO; +import com.hnac.gglm.bigmodel.business.service.AuthenticationService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.dto.DeptStationDTO; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/07/09 09:31 + */ +@Component +@AllArgsConstructor +@Slf4j +public class AuthClient implements IAuthClient { + + private final AuthenticationService authenticationService; + + /** + * 设备控制鉴权 + * @param req 遥控信息 + * @return 鉴权结果 + */ + @Override + public R remoteAuth(ControlDeviceAuthDTO req) { + // 若站点不为空 则对站点进行鉴权 + if(StringUtil.isNotBlank(req.getStationId())) { + if(!authenticationService.stationAuthentication(req.getStationId(), req.getUserId())) { + return R.fail("站点鉴权失败!"); + } + } + if("数据中心".equals(req.getType())) { + + } + return R.success("鉴权成功"); + } + + /** + * 站点鉴权 + * @param userId 用户ID + * @param stationId 站点ID + * @return 鉴权结果 + */ + @Override + public R stationAuth(String userId, String stationId) { + return R.status(authenticationService.stationAuthentication(stationId,userId)); + } + + /** + * 机构鉴权 + * @param userId 用户ID + * @param deptId 站点ID + * @return 鉴权结果 + */ + @Override + public R deptAuth(String userId, String deptId) { + List deptStationDTOList = authenticationService.getStationPermissionsById(userId); + boolean result = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).anyMatch(d -> Long.valueOf(deptId).equals(d)); + return R.status(result); + } + + /** + * 获取用户权限数据 + * @param userId 用户ID + * @return 权限数据 - 站点、机构 + */ + @Override + public R> getAuthData(String userId) { + Map result = new HashMap<>(2); + List deptStationDTOList = authenticationService.getStationPermissionsById(userId); + String[] stationIds = deptStationDTOList.stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).toArray(String[]::new); + String[] deptIds = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).map(String::valueOf).toArray(String[]::new); + result.put("stationids",stationIds); + result.put("projectids",deptIds); + return R.data(result); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/AuthenticationService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/AuthenticationService.java new file mode 100644 index 0000000..48931f2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/AuthenticationService.java @@ -0,0 +1,118 @@ +package com.hnac.gglm.bigmodel.business.service; + +import com.google.common.collect.Lists; +import com.hnac.gglm.bigmodel.interactive.constants.ProjectRemoteTypeEnum; +import com.hnac.gglm.bigmodel.interactive.vo.SessionContentVO; +import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; +import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.dto.DeptStationDTO; +import org.springblade.system.entity.CtrlAuth; +import org.springblade.system.feign.IDeptClient; +import org.springblade.system.feign.IRemoteClient; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.List; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/05/21 16:10 + */ +@Service +@AllArgsConstructor +public class AuthenticationService { + + private final IDeptClient deptClient; + private final ProjectClient projectClient; + private final IRemoteClient remoteClient; + private final RedisTemplate redisTemplate; + + /** + * 站点鉴权 + * @param stationId 站点ID + * @param userId 用户ID + */ + public Boolean stationAuthentication(String stationId, String userId) { + List deptStationDTOList = this.getStationPermissionsById(userId); + return deptStationDTOList.stream().map(DeptStationDTO::getStationId).anyMatch(stationId::equals); + } + + /** + * 菜单鉴权 + * @param userId 用户ID + * @param func 函数编号 + */ +// public void menuAuthentication(String userId, String func) { +// FunctionEntity function = functionService.getFunctionByCode(func); +// if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { +// R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); +// Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { +// throw new ServiceException("人员菜单鉴权失败!"); +// }); +// } +// } + + /** + * 遥控鉴权 + * @param stationId 站点ID + * @param userId 用户ID + */ + public void remoteAuthentication(String stationId, String userId,String sessionId) { + // 查询数据平台站点是否可被遥控 + Result> projectR = projectClient.getProjectIds(Lists.newArrayList(stationId)); + Assert.isTrue(projectR.isSuccess() && CollectionUtil.isNotEmpty(projectR.getData()) && projectR.getData().size() == 1,() -> { + throw new ServiceException("未查询到站点,鉴权失败!"); + }); + ProjectVO project = projectR.getData().get(0); + if(ProjectRemoteTypeEnum.NOT_ALLOW.getCtrlType().equals(project.getCtrlType())) { + // 不允许发送遥控 + throw new ServiceException("该站点不允许发送遥控指令,校验失败!"); + } + else if(ProjectRemoteTypeEnum.VALID.getCtrlType().equals(project.getCtrlType())) { + // 运行发送遥控并且需要校验权限 + R> ctrlAuthR = remoteClient.getCtrlAuth(Optional.ofNullable(userId).filter(StringUtil::isNotBlank).map(Long::parseLong).orElse(null)); + Assert.isTrue(ctrlAuthR.isSuccess(),() -> { + throw new ServiceException("该站点未设置鉴权用户,校验失败!"); + }); + List ctrlAuthList = ctrlAuthR.getData(); + Optional authOptional = ctrlAuthList.stream().filter(c -> c.getProjectId().equals(stationId)).findFirst(); + Assert.isTrue(authOptional.isPresent() && Func.isNotEmpty(authOptional.get().getIsLimitMachine()), () -> { + throw new ServiceException("该用户不存在相应站点权限,校验不通过!"); + }); + CtrlAuth ctrlAuth = authOptional.get(); + // 如限制机器发送遥控指令 + if(ctrlAuth.getIsLimitMachine() == 1) { + SessionContentVO sessionContent = (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, sessionId); + Assert.isTrue(Func.isNotEmpty(sessionContent),() -> { + throw new ServiceException("获取问题机器码失败,校验不通过!"); + }); + String machineCode = sessionContent.getMachineCode(); + Assert.isTrue(StringUtil.isNotBlank(machineCode) && Func.isNotEmpty(machineCode) ,() -> { + throw new ServiceException("获取问题机器码失败,校验不通过!"); + }); + Assert.isTrue(machineCode.equals(ctrlAuth.getMachineCode()),() -> { + throw new ServiceException("站点校验码校验失败,校验不通过!"); + }); + } + } + } + + public List getStationPermissionsById(String userId) { + R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); + Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { + throw new ServiceException("获取人员站点权限失败!"); + }); + return deptSattionR.getData(); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/DataSourceService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/DataSourceService.java new file mode 100644 index 0000000..ca39057 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/DataSourceService.java @@ -0,0 +1,113 @@ +package com.hnac.gglm.bigmodel.business.service; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.gglm.bigmodel.business.vo.SqlVO; +import com.hnac.gglm.bigmodel.business.vo.TableAuthVO; +import com.hnac.gglm.bigmodel.maintenance.entity.TablePropertyEntity; +import com.hnac.gglm.bigmodel.maintenance.service.TablePropertyService; +import com.hnac.hzims.common.service.UserAuthDataService; +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +/** + * @Author: huangxing + * @Date: 2024/06/28 15:24 + */ +@Service +@AllArgsConstructor +@Slf4j +public class DataSourceService { + + private final JdbcTemplate jdbcTemplate; + private final UserAuthDataService userAuthDataService; + private final TablePropertyService tablePropertyService; + + private static final Pattern UPDATE_PATTERN = Pattern.compile("^UPDATE\\s", Pattern.CASE_INSENSITIVE); + private static final Pattern DELETE_PATTERN = Pattern.compile("^DELETE\\s", Pattern.CASE_INSENSITIVE); + + + public List> queryListOnSpecificDataSource(SqlVO sqlVO) { + // 过滤更新、删除语句 + Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { + throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); + }); + String sql = sqlVO.getSql(); + String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); + if(StringUtil.isNotBlank(userAuthDataSQL)) { + for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { + // 查询改数据源下的表格是否存在鉴权 + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .eq(TablePropertyEntity::getDatasourceId, tableAuthVO.getDatasourceName()) + .eq(TablePropertyEntity::getTableName, tableAuthVO.getTableName()); + List propertise = tablePropertyService.list(wrapper); + Assert.isTrue(Func.isNotEmpty(propertise), () -> { + throw new HzServiceException(ResultCode.FAILURE,"查询语句中存在未进行鉴权的表,查询失败!"); + }); + if("1".equals(propertise.get(0).getAuthType())) { + String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where is_deleted = 0 and " + userAuthDataSQL +") temp"; + sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); + } else { + String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where is_deleted = 0) temp"; + sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); + } + } + } + sql = sql.replaceAll(">", ">").replaceAll("<", "<"); + log.info("执行sql:{}",sql); + return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); + } + + /** + * sql + * @param sql + * @param dataSourceName + * @return + */ + public List> queryListOnSpecificDataSource(String sql,String dataSourceName) { + // 切换到指定的数据源 + DynamicDataSourceContextHolder.push(dataSourceName); + try { + return jdbcTemplate.queryForList(sql); + } finally { + // 清除,恢复默认数据源 + DynamicDataSourceContextHolder.clear(); + } + } + + public Integer updateOnSpecificDataSource(String sql,String dataSourceName) { + // 切换到指定的数据源 + DynamicDataSourceContextHolder.push(dataSourceName); + try { + return jdbcTemplate.update(sql); + } finally { + // 清除,恢复默认数据源 + DynamicDataSourceContextHolder.clear(); + } + } + + /** + * 过滤更新、删除语法的sql脚本 + * @param sql 待执行sql脚本 + * @return 执行结果 + */ + public static boolean isUpdateOrDelete(String sql) { + if (sql == null) { + return false; + } + return UPDATE_PATTERN.matcher(sql).find() || DELETE_PATTERN.matcher(sql).find(); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/HistoryDataService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/HistoryDataService.java new file mode 100644 index 0000000..068e18e --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/HistoryDataService.java @@ -0,0 +1,95 @@ +package com.hnac.gglm.bigmodel.business.service; + +import com.alibaba.fastjson.JSON; +import com.google.common.collect.Lists; +import com.hnac.gglm.bigmodel.interactive.constants.DataMethodEnum; +import com.hnac.gglm.bigmodel.interactive.constants.DateEnum; +import com.hnac.gglm.bigmodel.interactive.vo.HistoryDataSearchVO; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO; +import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; +import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:57 + */ +@Service +@Slf4j +@AllArgsConstructor +public class HistoryDataService { + + private final DeviceDataClient deviceDataClient; + public static final int DATA_COUNT_MAX = 1000; + + public Result getPolymerizationData(HistoryDataSearchVO searchVO) { + DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); + Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { + throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); + }); + // 聚合数据方式处理 + DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); + ReductionDataDTO dataDTO = new ReductionDataDTO(); + ReductionAttrDataDTO reductionAttrData = new ReductionAttrDataDTO(); + reductionAttrData.setSignage(searchVO.getSignage()); + reductionAttrData.setAccessRules(enumByMethod.getAccessRule()); + reductionAttrData.setKeepFigures(2); + dataDTO.setBeginTime(LocalDateTime.parse(searchVO.getStartTime(), DateUtil.DATETIME_FORMATTER)); + dataDTO.setEndTime(LocalDateTime.parse(searchVO.getEndTime(),DateUtil.DATETIME_FORMATTER)); + dataDTO.setDeviceCode(searchVO.getDeviceCode()); + dataDTO.setNeedPage(false); + dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); + dataDTO.setTimeInterval(1); + dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); + log.info("config传参为:{}", JSON.toJSONString(dataDTO)); + return deviceDataClient.pageDeviceCodeAndSignages(dataDTO); + } + + public DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { + LocalDateTime start = LocalDateTime.parse(startTime, DateUtil.DATETIME_FORMATTER); + LocalDateTime end = LocalDateTime.parse(endTime, DateUtil.DATETIME_FORMATTER); + Duration duration = Duration.between(start, end); + int count; + switch(dateEnum) { + case YEAR: + count = Long.valueOf(ChronoUnit.YEARS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case MONTH: + count = Long.valueOf(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case DAY: + count = Long.valueOf(ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case HOUR: + count = Long.valueOf(duration.toHours()).intValue(); + break; + case MINUTE: + count = Long.valueOf(duration.toMinutes()).intValue(); + break; + case SECOND: + count = Long.valueOf(duration.getSeconds()).intValue(); + break; + default: + throw new ServiceException("未找到相关时间类型,查询失败!"); + } + if(count <= DATA_COUNT_MAX) { + return dateEnum; + } + else { + return getDateEnumByDuration(startTime, endTime, DateEnum.getDateEnumByOrder(dateEnum.getOrder() + 1)); + } + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/RemoteService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/RemoteService.java new file mode 100644 index 0000000..4d0aa1e --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/RemoteService.java @@ -0,0 +1,31 @@ +package com.hnac.gglm.bigmodel.business.service; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.system.dto.ControlDTO; +import org.springblade.system.feign.IRemoteClient; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:36 + * @Descirbe: 数据平台 - 遥控服务类 + */ +@Service +@Slf4j +@AllArgsConstructor +public class RemoteService { + + private final IRemoteClient remoteClient; + + /** + * 发送遥控指令 + * @param controlDTO 遥控指令 + * @return 结果 + */ + public R sendRemoteControl(ControlDTO controlDTO) { + return remoteClient.sendCtrl(controlDTO); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/SqlVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/SqlVO.java new file mode 100644 index 0000000..7f2c3b9 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/SqlVO.java @@ -0,0 +1,32 @@ +package com.hnac.gglm.bigmodel.business.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/05 08:19 + */ +@ApiModel(value = "",description = "") +@Data +@EqualsAndHashCode +public class SqlVO implements Serializable { + + @ApiModelProperty("执行sql") + @NotBlank + private String sql; + + @ApiModelProperty("执行人") + @NotBlank + private String userId; + + @ApiModelProperty("执行sql设计表信息") + private List tableAuthVOList; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/TableAuthVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/TableAuthVO.java new file mode 100644 index 0000000..5b7abe8 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/vo/TableAuthVO.java @@ -0,0 +1,28 @@ +package com.hnac.gglm.bigmodel.business.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/04 17:29 + */ +@ApiModel(value = "表鉴权对象",description = "表鉴权对象") +@Data +@EqualsAndHashCode +public class TableAuthVO implements Serializable { + + @ApiModelProperty("鉴权类型,目前不为空即为平台数据权限") + private String auth; + + @ApiModelProperty("数据源名称") + private String datasourceName; + + @ApiModelProperty("数据表名称") + private String tableName; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/wrapper/CanvasSyncWrapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/wrapper/CanvasSyncWrapper.java new file mode 100644 index 0000000..1977ce3 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/wrapper/CanvasSyncWrapper.java @@ -0,0 +1,21 @@ +package com.hnac.gglm.bigmodel.business.wrapper; + +import com.hnac.gglm.bigmodel.api.dto.CanvasSyncDTO; +import com.hnac.gglm.bigmodel.api.wrapper.BaseSyncWrapper; +import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasVO; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Component; + +/** + * @Author: huangxing + * @Date: 2024/08/20 16:49 + */ +@Component +@AllArgsConstructor +public class CanvasSyncWrapper extends BaseSyncWrapper { + + @Override + public CanvasSyncDTO convert(CanvasVO obj) { + return null; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java new file mode 100644 index 0000000..7f0476c --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java @@ -0,0 +1,70 @@ +package com.hnac.gglm.bigmodel.configuration; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * @Author: huangxing + * @Date: 2024/04/28 18:20 + */ +@Data +@Component +@ConfigurationProperties(prefix = "gglm.api") +public class BigModelInvokeApi { + + private String assistantAsk; + + private String assistantSpecialAsk; + + private String assistantStatus; + + private String askAbort; + + private String updateVideo; + + private String updateFault; + + private String updateCanvas; + + private String assistantKnowledgeAsk; + + private String hotQuestion; + + private String deleteByStationId; + + private String deleteById; + + private String insertCanvas; + + private String insertFault; + + private String insertRecord; + + private String insertStation; + + private String insertVideo; + + private String insertYk; + + /** + * 发起机组发电量智能报表分析问答 + */ + private String smartReportGeneratePower; + + /** + * 起数据分析问答 + */ + private String assistantAnalyseAsk; + + /** + * 更新数据 + */ + private String updateKnowledge; + + /** + * 计算向量 + */ + private String compute; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/ThreadPoolManager.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/ThreadPoolManager.java new file mode 100644 index 0000000..33da833 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/ThreadPoolManager.java @@ -0,0 +1,34 @@ +package com.hnac.gglm.bigmodel.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +import java.util.concurrent.*; + +/** + * @Author: huangxing + * @Date: 2024/05/06 11:58 + */ +@Component +public class ThreadPoolManager { + + @Bean + public ThreadPoolExecutor getAnswerPoolExecutor() { + // 核心线程数 + int corePoolSize = 5; + // 最大线程数 + int maximumPoolSize = 10; + // 线程空闲时的存活时间 + long keepAliveTime = 60L; + // 时间单位 + TimeUnit unit = TimeUnit.SECONDS; + // 任务队列 + BlockingQueue workQueue = new LinkedBlockingQueue<>(100); + // 线程工厂 + ThreadFactory threadFactory = Executors.defaultThreadFactory(); + // 拒绝策略 + RejectedExecutionHandler handler = new ThreadPoolExecutor.AbortPolicy(); + return new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,threadFactory,handler); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/WeaviateConfigure.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/WeaviateConfigure.java new file mode 100644 index 0000000..20c495c --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/WeaviateConfigure.java @@ -0,0 +1,56 @@ +package com.hnac.gglm.bigmodel.configuration; + +import io.weaviate.client.Config; +import io.weaviate.client.WeaviateAuthClient; +import io.weaviate.client.WeaviateClient; +import io.weaviate.client.v1.auth.exception.AuthException; +import io.weaviate.client.v1.data.api.ObjectCreator; +import io.weaviate.client.v1.data.api.ObjectDeleter; +import io.weaviate.client.v1.data.api.ObjectUpdater; +import io.weaviate.client.v1.data.api.ObjectsGetter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @Author: huangxing + * @Date: 2024/08/22 18:38 + */ +@Configuration +public class WeaviateConfigure { + + private final WeaviateProperties weaviateProperties; + + public WeaviateConfigure(WeaviateProperties weaviateProperties) { + this.weaviateProperties = weaviateProperties; + } + + @Bean + public WeaviateClient weaviateClient() throws AuthException { + Config config = new Config(this.weaviateProperties.getSchema(), this.weaviateProperties.getHost() + ":" + this.weaviateProperties.getPort()); + return WeaviateAuthClient.apiKey(config,this.weaviateProperties.getApiKey()); + } + + @Bean + public ObjectsGetter objectsGetter() throws AuthException { + WeaviateClient weaviateClient = weaviateClient(); + return weaviateClient.data().objectsGetter(); + } + + @Bean + public ObjectCreator objectCreator() throws AuthException { + WeaviateClient weaviateClient = weaviateClient(); + return weaviateClient.data().creator(); + } + + @Bean + public ObjectDeleter deleter() throws AuthException { + WeaviateClient weaviateClient = weaviateClient(); + return weaviateClient.data().deleter(); + } + + @Bean + public ObjectUpdater updater() throws AuthException { + WeaviateClient weaviateClient = weaviateClient(); + return weaviateClient.data().updater(); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/WeaviateProperties.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/WeaviateProperties.java new file mode 100644 index 0000000..d6474d0 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/WeaviateProperties.java @@ -0,0 +1,32 @@ +package com.hnac.gglm.bigmodel.configuration; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * @Author: huangxing + * @Date: 2024/08/21 15:22 + */ +@Data +@Component +@ConfigurationProperties(prefix = "weaviate.datasource") +public class WeaviateProperties { + + private String schema; + + private String host; + + private String port; + + /** + * 登录认证KEY + */ + private String apiKey; + + /** + * 数据库表名前缀 + */ + private String classNamePrefix; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java new file mode 100644 index 0000000..2b1a90d --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java @@ -0,0 +1,41 @@ +package com.hnac.gglm.bigmodel.database.controller; + +import com.hnac.gglm.bigmodel.database.dto.WeaviateSaveDTO; +import com.hnac.gglm.bigmodel.database.service.WeaviateService; +import io.weaviate.client.v1.data.model.WeaviateObject; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/09/04 14:16 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/weaviate") +public class WeaviateController { + + private final WeaviateService weaviateService; + + @PostMapping("/saveBatch") + public R saveBatch(@RequestBody WeaviateSaveDTO req) { + weaviateService.saveBatch(req.getEntities(), req.getClassName(), req.getAttrsMap()); + return R.success("操作成功!"); + } + + @GetMapping("/list") + public R> list(@RequestParam(value = "id",required = false) String id, + @RequestParam("className") String className, + @RequestParam("current") Integer current, + @RequestParam("pageSize") Integer pageSize) { + return R.data(weaviateService.list(id,className,current,pageSize)); + } + + @DeleteMapping("/removeById") + public R removeById(@RequestParam(value = "id",required = false) String id, @RequestParam("className") String className) { + return R.status(weaviateService.delete(id,className)); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/dto/WeaviateSaveDTO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/dto/WeaviateSaveDTO.java new file mode 100644 index 0000000..24f5db2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/dto/WeaviateSaveDTO.java @@ -0,0 +1,33 @@ +package com.hnac.gglm.bigmodel.database.dto; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/09/04 14:36 + */ +@Data +@EqualsAndHashCode +public class WeaviateSaveDTO implements Serializable { + + /** + * 向量数据库表名 + */ + private String className; + + /** + * 向量数据库属性名 + */ + private Map attrsMap; + + /** + * 向量数据库存入对象列表 + */ + private List entities; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java new file mode 100644 index 0000000..6f5dbb9 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java @@ -0,0 +1,266 @@ +package com.hnac.gglm.bigmodel.database.service; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; +import com.hnac.gglm.bigmodel.configuration.BigModelInvokeApi; +import com.hnac.hzinfo.exception.HzServiceException; +import io.weaviate.client.WeaviateClient; +import io.weaviate.client.base.Result; +import io.weaviate.client.v1.data.api.ObjectCreator; +import io.weaviate.client.v1.data.api.ObjectDeleter; +import io.weaviate.client.v1.data.api.ObjectUpdater; +import io.weaviate.client.v1.data.api.ObjectsGetter; +import io.weaviate.client.v1.data.model.WeaviateObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +/** + * @Author: huangxing + * @Date: 2024/08/22 19:17 + */ +@RequiredArgsConstructor +@Service +@Slf4j +public class WeaviateService { + + private final WeaviateClient weaviateClient; + private final BigModelInvokeApi invokeApi; + + @Value("${gglm.vectorUrl}") + private String vectorUrl; + + /** + * 对象保存向量数据库 + * @param entity 保存对象 + * @param className 保存表名 + * @param attrs 待计算的列信息 + * @return 保存操作结果 + */ + public Boolean save(Object entity, String className, List attrs) { + ObjectCreator creator = weaviateClient.data().creator().withClassName(className); + if(Func.isNotEmpty(attrs)) { + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity)); + List vectors = attrs.stream().map(attr -> jsonObject.getString(attr)).collect(Collectors.toList()); + Float[] compute = this.compute(vectors); + creator.withVector(compute); + } + Result result = creator.withProperties(BeanUtil.toMap(entity)).run(); + return !result.hasErrors(); + } + + /** + * 对象批量保存向量数据库 + * @param entities 保存对象列表 + * @param className 保存表名 + * @param attrsMap 待计算的列信息 key-向量名 value-实体类对象属性,多个按逗号分隔 + * @return 保存操作结果 + */ + public Boolean saveBatch(List entities,String className, Map attrsMap) { + ObjectCreator creator = weaviateClient.data().creator().withClassName(className); + List vectorStrs = Lists.newArrayList(); + List attrs = Lists.newArrayList(); + if(Func.isNotEmpty(attrsMap)) { + // 格式化数据 + attrsMap.forEach((k,v) -> attrs.add(v)); + // 解析待计算的向量字段 + entities.forEach(entity -> { + List vectorStr = attrs.stream().map(fields -> this.getFieldValue(fields, entity)).filter(Func::isNotEmpty).collect(Collectors.toList()); + vectorStrs.addAll(vectorStr); + }); + } + if(Func.isNotEmpty(vectorStrs)) { + // 若解析出来的向量存在值 + Float[] vectors = this.compute(vectorStrs); + List> vector = this.splitVector(entities.size(), attrsMap, vectors); + for(int i = 0; i < entities.size(); i++) { + // log.info("vector:{}",JSON.toJSONString(vector.get(i))); + Map properties = this.objectToMap(entities.get(i)); + log.info("properties:{}",JSON.toJSONString(properties)); + Result run = creator.withProperties(properties).withVectors(vector.get(i)).run(); + if(run.hasErrors()) { + log.error("保存失败!,保存结果为:{}",JSON.toJSONString(run)); + } + } + } else { + entities.forEach(entity -> creator.withProperties(this.objectToMap(entity)).run()); + return true; + } + return false; + } + + private Map objectToMap(Object object) { + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object)); + Map properties = new HashMap<>(); + jsonObject.forEach((k,v) -> { + if("id".equalsIgnoreCase(k)) { + properties.put("id_",v); + } else { + properties.put(k,v); + } + }); + return properties; + } + + /** + * 删除向量数据库(表名) + * @param className 表名 + * @return 删除结果 + */ + public Boolean delete(String ids,String className) { + ObjectDeleter deleter = weaviateClient.data().deleter(); + deleter.withClassName(className); + if(Func.isEmpty(ids)) { + Result> allObject = weaviateClient.data().objectsGetter().withClassName(className).withLimit(10000).run(); + if(!allObject.hasErrors()) { + ids = allObject.getResult().stream().map(WeaviateObject::getId).collect(Collectors.joining(",")); + } + } + Func.toStrList(",",ids).forEach(id -> { + Result result = deleter.withID(id).run(); + if(result.hasErrors()) { + throw new HzServiceException(ResultCode.FAILURE,id + "记录删除失败!"); + } + }); + return true; + } + + /** + * 更新数据库(通过ID) + * @param id 向量数据库ID + * @return 更新结果 + */ + public Boolean updateById(String id, Object entity, String className, Map attrMap) { + ObjectUpdater updater = weaviateClient.data().updater().withClassName(className).withID(id).withProperties(BeanUtil.toMap(entity)); + // 计算向量 + Map vector = new HashMap<>(); + if(Func.isNotEmpty(attrMap)) { + attrMap.forEach((k,v) -> { + String fieldValue = this.getFieldValue(v, entity); + Float[] compute = this.compute(Lists.newArrayList(fieldValue)); + vector.put(k,compute); + }); + } + if(Func.isNotEmpty(vector)) { + updater.withVectors(vector); + } + Result result = updater.run(); + return !result.hasErrors(); + } + + public List list(String id,String className,Integer current,Integer pageSize) { + ObjectsGetter objectsGetter = weaviateClient.data().objectsGetter(); + if(Func.isNotEmpty(id)) { + objectsGetter.withID(id); + } + if(Func.isNotEmpty(className)) { + objectsGetter.withClassName(className); + } + Result> result = objectsGetter.withLimit(pageSize).withOffset((current-1) * pageSize).run(); + if(result.hasErrors()) { + throw new HzServiceException("查询失败!"); + } + return result.getResult(); + } + + /** + * 拆解计算出来的向量Float[] + * @param entitySize 对象列表size + * @param attrsMap 待计算的列信息 key-向量名 value-实体类对象属性,多个按逗号分隔 + * @param vectorTotal 计算出的向量总量 + * @return 拆解结果 + */ + private List> splitVector(Integer entitySize,Map attrsMap,Float[] vectorTotal) { + List> result = Lists.newArrayList(); + List vectorTotalList = Lists.newArrayList(vectorTotal); + // 获取待切割的下标 + List indexes = this.getSplitIndex(vectorTotal.length, entitySize); + int step = vectorTotal.length / entitySize; + indexes.forEach(index -> { + List vectors = vectorTotalList.subList(index, index + step); + Map vectorMap = new HashMap<>(); + List splitIndex = this.getSplitIndex(vectors.size(), attrsMap.size()); + AtomicInteger i = new AtomicInteger(); + attrsMap.forEach((k,v) -> { + List vector = vectors.subList(splitIndex.get(i.get()), splitIndex.get(i.get()) + (vectors.size() / attrsMap.size())); + vectorMap.put(k, vector.toArray(new Float[vector.size()])); + i.getAndIncrement(); + }); + result.add(vectorMap); + }); + return result; + } + + /** + * 获取将list等量分隔成若干份的列表下标 + * @param size 总数 + * @param splitNum 分隔数量 + * @return 下标集合 + */ + private List getSplitIndex(int size,int splitNum) { + if(size % splitNum != 0) { + throw new HzServiceException("向量计算失败,无法根据同步对象进行等量分隔!"); + } + return IntStream.iterate(0, index -> index + 1) + .limit(splitNum) + .mapToObj(index -> index * (size / splitNum)) + .collect(Collectors.toList()); + } + + + private String getFieldValue(String fields,Object object) { + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object)); + return Func.toStrList(",", fields).stream().map(field -> jsonObject.getString(field)).collect(Collectors.joining(" ")); + } + + /** + * 计算向量值 + * @param vectors 待计算的向量 + * @return 向量值Float[] + */ + private Float[] compute(List vectors) { + // 向量计算 + String url = vectorUrl + invokeApi.getCompute(); + String jsonData = JSONUtil.toJsonStr(vectors); + HttpResponse response = HttpRequest.post(url) + .header("Content-Type", "application/json; charset=utf-8") + .body(jsonData) + .execute(); + byte[] bytes = response.bodyBytes(); + if (bytes.length % 4 != 0) { + throw new HzServiceException("向量计算失败!响应数据长度不是4的倍数"); + } + List chunks = new ArrayList<>(); + int range = bytes.length / 4; + IntStream.range(0, range) + .forEach(index -> { + byte[] chunk = new byte[4]; + int page = index * 4; + chunk[0] = bytes[page]; + chunk[1] = bytes[page + 1]; + chunk[2] = bytes[page + 2]; + chunk[3] = bytes[page + 3]; + chunks.add(chunk); + }); + List floats = chunks.stream().map(b -> { + ByteBuffer buffer = ByteBuffer.wrap(b).order(ByteOrder.LITTLE_ENDIAN); + return buffer.getFloat(); + }).collect(Collectors.toList()); + return floats.toArray(new Float[floats.size()]); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/util/WeaviateUtil.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/util/WeaviateUtil.java new file mode 100644 index 0000000..7e4ca32 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/util/WeaviateUtil.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.database.util; + +/** + * @Author: huangxing + * @Date: 2024/08/23 10:09 + */ +public class WeaviateUtil { + + + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DataAuthTypeEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DataAuthTypeEnum.java new file mode 100644 index 0000000..e23adca --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DataAuthTypeEnum.java @@ -0,0 +1,27 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:49 + */ +@AllArgsConstructor +@Getter +public enum DataAuthTypeEnum { + /**站点鉴权**/ + STATION("station"), + DEPT("dept"), + ; + private final String type; + + public static DataAuthTypeEnum getEnumByType(String type) { + Optional typeEnumOptional = Arrays.stream(DataAuthTypeEnum.class.getEnumConstants()).filter(e -> e.getType().equals(type)).findFirst(); + return typeEnumOptional.orElse(null); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DataMethodEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DataMethodEnum.java new file mode 100644 index 0000000..1e89c36 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DataMethodEnum.java @@ -0,0 +1,36 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/29 08:31 + */ +@AllArgsConstructor +public enum DataMethodEnum { + USUAL("详情",6,"详情"), + EARLIEST("最早值",0,"最早值"), + MAX("最大值",1,"最大值"), + MIN("最小值",2,"最小值"), + AVERAGE("平均值",3,"平均值"), + SUM("累计值/和值",4,"总和值"), + DIFFERENCE("变化值/差值",5,"变化值"), + LATEST("最新值",6,"最新值"), + ; + @Getter + private String name; + @Getter + private Integer accessRule; + @Getter + private String method; + + public static DataMethodEnum getEnumByMethod(String method) { + return Arrays.stream(DataMethodEnum.class.getEnumConstants()) + .filter(e -> e.getMethod().equals(method)) + .findFirst().orElse(null); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DateEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DateEnum.java new file mode 100644 index 0000000..a2274a5 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/DateEnum.java @@ -0,0 +1,41 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/28 11:37 + */ +@AllArgsConstructor +public enum DateEnum { + YEAR("year","每年","按年",5,6), + MONTH("month","每月","按月",4,5), + DAY("day","每天","按天",3,3), + HOUR("hour","每小时","按小时",2,2), + MINUTE("minute","每分钟","按分钟",1,1), + SECOND("second","每秒","按秒",0,0), + USUAL("usual","详情","按秒",0,0) + ; + @Getter + private String code; + @Getter + private String name; + @Getter + private String dateType; + @Getter + private int order; + @Getter + private Integer saveTimeType; + + public static DateEnum getDateEnumByType(String dateType) { + return Arrays.stream(DateEnum.class.getEnumConstants()).filter(d -> d.getDateType().equals(dateType)).findFirst().orElse(null); + } + + public static DateEnum getDateEnumByOrder(int order) { + return Arrays.stream(DateEnum.class.getEnumConstants()).filter(d -> d.getOrder() == order).findFirst().orElse(null); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/FuncRouteEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/FuncRouteEnum.java new file mode 100644 index 0000000..f3783be --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/FuncRouteEnum.java @@ -0,0 +1,42 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/04/30 11:41 + */ +@AllArgsConstructor +public enum FuncRouteEnum { + OPEN_CANVAS("open_canvas","打开实时画面",FunctionConstants.TypeEnum.JUMP), + OPEN_VIDEO("open_video","打开视频监控",FunctionConstants.TypeEnum.PARAMS), + DIAGNOSE("result_diagnose","智能诊断",FunctionConstants.TypeEnum.PARAMS), + CHOOSE_STATION("choose_station","选择站点",FunctionConstants.TypeEnum.CHOOSE), + CHOOSE_VIDEO("choose_video","选择视频",FunctionConstants.TypeEnum.CHOOSE), + CHOOSE_CANVAS("choose_canvas","选择画面",FunctionConstants.TypeEnum.CHOOSE), + CHOOSE_FAULT("choose_fault","选择故障",FunctionConstants.TypeEnum.CHOOSE), + CHOOSE_YK("choose_yk","选择遥控",FunctionConstants.TypeEnum.CHOOSE), + CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), + SHOW_PARAM("result_record","设备参数查询", FunctionConstants.TypeEnum.PARAMS), + CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE), + HISTORY_DATA("history_data","查询历史数据",FunctionConstants.TypeEnum.CHART), + CONTROL_DEVICE("control_device","设备控制",FunctionConstants.TypeEnum.PARAMS), + SHOW_DATA("show_data","智能分析",FunctionConstants.TypeEnum.PARAMS) + ; + @Getter + private String func; + @Getter + private String funcName; + @Getter + private FunctionConstants.TypeEnum type; + + public static FuncRouteEnum getEnumByFuncCode(String funcCode) { + Optional FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFunc())).findFirst(); + return FuncRoute.orElse(null); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/FunctionConstants.java new file mode 100644 index 0000000..03130ab --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/FunctionConstants.java @@ -0,0 +1,40 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/04/26 13:29 + */ +public interface FunctionConstants { + + @AllArgsConstructor + enum TypeEnum { + /**跳转页面**/ + JUMP("1"), + /**链接**/ + LINK("2"), + /**参数**/ + PARAMS("3"), + /**选项**/ + CHOOSE("4"), + /**确认**/ + CONFIRM("5"), + CHART("6"), + IMAGE_TEXT("7") + ; + ; + @Getter + private String type; + + public static TypeEnum getTypeEnumByType (String type) { + Optional typeEnumOptional = Arrays.stream(TypeEnum.class.getEnumConstants()).filter(e -> type.equals(e.getType())).findFirst(); + return typeEnumOptional.orElse(null); + } + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/InfoMessageConstant.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/InfoMessageConstant.java new file mode 100644 index 0000000..92424e1 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/InfoMessageConstant.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +/** + * @Author: huangxing + * @Date: 2024/06/21 16:35 + */ +public interface InfoMessageConstant { + + String ERROR_MESSAGE = "非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。"; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java new file mode 100644 index 0000000..ac6d666 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java @@ -0,0 +1,23 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +/** + * @Author: huangxing + * @Date: 2024/07/01 14:26 + * @Describe: 参数key管理 + */ +public interface ParamKeyConstants { + + /**实时画面host**/ + String CANVAS_HOST = "hzims:bigModel:canvas:host"; + /**实时画面v3路径 {context}&stationNum={stationNum}&projectId={projectId}**/ + String CANVAS_V3_PATH = "hzims:bigModel:canvas:v3:path"; + /**实时画面v4路径 other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}**/ + String CANVAS_V4_PATH = "hzims:bigModel:canvas:v4:path"; + /**实时画面云组态路径 hzinfo-data-scada/view/{projectId}/{id}?source=app**/ + String CANVAS_YZT_PATH = "hzims:bigModel:canvas:yzt:path"; + /**视频巡检指令编号**/ + String VIDEO_INSPECTION_CODE = "gglm:bigModel:video:inspection:code"; + /**视频巡检识别url**/ + String VIDEO_INSPECTION_URL = "gglm:bigModel:video:inspection:url"; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java new file mode 100644 index 0000000..7629643 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java @@ -0,0 +1,22 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Author: huangxing + * @Date: 2024/05/21 16:34 + */ +@AllArgsConstructor +public enum ProjectRemoteTypeEnum { + /**不允许发送遥控**/ + NOT_ALLOW(0), + /**运行发送遥控并且需要校验权限**/ + VALID(1), + /**运行发送遥控并免校验权限**/ + ALLOW(2), + ; + @Getter + private Integer ctrlType; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/SearchStationTypeEnum.java new file mode 100644 index 0000000..eca5cce --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/SearchStationTypeEnum.java @@ -0,0 +1,44 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/24 17:14 + */ +@AllArgsConstructor +public enum SearchStationTypeEnum { + STATION_TOTAL("电站总数量",null,"智能运维平台接入电站总数为:%s"), + SET_TOTAL("站点总数量",null,"智能运维平台接入站点总数为:%s"), + HYDROPOWER_TOTAL("水电站总数量","0","智能运维平台接入水电站总数为:%s"), + WIND_POWER_TOTAL("风电场总数量","1","智能运维平台接入风电场总数为:%s"), + ENERGY_STORAGE_TOTAL("储能站总数量","3","智能运维平台接入储能站总数为:%s"), + PHOTOVOLTAIC_TOTAL("光伏站总数量","5","智能运维平台接入光伏站总数为:%s"), + CHARGE_TOTAL("充电站总数量","7","智能运维平台接入充电站总数为:%s"), + STATION_NUM("电站接入量",null,"智能运维平台接入电站总数为:%s"), + SET_NUM("站点接入量",null,"智能运维平台接入站点总数为:%s"), + HYDROPOWER_NUM("水电站接入量","0","智能运维平台接入水电站接入量为:%s"), + WIND_POWER_NUM("风电场接入量","1","智能运维平台接入风电场接入量为:%s"), + ENERGY_STORAGE_NUM("储能站接入量","3","智能运维平台接入储能站接入量为:%s"), + PHOTOVOLTAIC_NUM("光伏站接入量","5","智能运维平台接入光伏站接入量为:%s"), + CHARGE_NUM("充电站接入量","7","智能运维平台接入充电站接入量为:%s"), + ; + + @Getter + private String searchStationType; + @Getter + private String stationType; + @Getter + private String label; + + public static SearchStationTypeEnum getTypeEnum(String searchStationType) { + return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants()) + .filter(e -> e.getSearchStationType().equals(searchStationType)) + .findFirst() + .orElse(null); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/SearchTypeEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/SearchTypeEnum.java new file mode 100644 index 0000000..36e6862 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/SearchTypeEnum.java @@ -0,0 +1,28 @@ +package com.hnac.gglm.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/24 17:13 + */ +@AllArgsConstructor +public enum SearchTypeEnum { + REAL("实时"), + HISTORY("历史") + ; + @Getter + private String searchType; + + public static SearchTypeEnum getSearchType(String searchType) { + return Arrays.stream(SearchTypeEnum.class.getEnumConstants()) + .filter(e -> e.getSearchType().equals(searchType)) + .findFirst() + .orElse(null); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/FontEndInteractiveController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/FontEndInteractiveController.java new file mode 100644 index 0000000..7bd5aac --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/FontEndInteractiveController.java @@ -0,0 +1,70 @@ +package com.hnac.gglm.bigmodel.interactive.controller; + +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.google.common.collect.Lists; +import com.hnac.gglm.bigmodel.BigModelConstants; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.IResultCode; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:19 + */ +@RestController +@RequestMapping("/fontEnd/interactive") +@Api(value = "前端交互控制层",tags = "前端交互控制层") +@AllArgsConstructor +public class FontEndInteractiveController { + + private final IHznlmInvokeService hznlmInvokeService; + + @ApiOperation("提问") + @ApiOperationSupport(order = 1) + @GetMapping("/ask") + public R ask(@RequestParam @ApiParam("用户提出问题") String question, @RequestParam @ApiParam("问答sessionId") String sessionId, @RequestParam @ApiParam("用户Id") String userId) { + hznlmInvokeService.ask(question, sessionId, userId); + return R.success("操作成功!"); + } + + @ApiOperation("删除对话sessionId") + @ApiOperationSupport(order = 2) + @GetMapping("/removeSessionId") + public R removeSessionId(@RequestParam(value = "id") String sessionId) { + hznlmInvokeService.removeSessionId(sessionId); + return R.success("操作成功!"); + } + + @ApiOperation("获取热点问题") + @ApiOperationSupport(order = 3) + @GetMapping("/hotQuestions") + public R hotQuestions() { + return R.data(hznlmInvokeService.hotQuestions()); + } + + @ApiOperation("获取问答sessionId") + @ApiOperationSupport(order = 4) + @GetMapping("/getSessionId") + public R getSessionId() { + return R.data(IdWorker.get32UUID()); + } + + @ApiOperation("中断当前的问答") + @ApiOperationSupport(order = 5) + @GetMapping("/interruptSession") + public R interruptSession(@RequestParam(value = "id") String sessionId) { + hznlmInvokeService.interruptSession(sessionId); + return R.success("操作成功!"); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java new file mode 100644 index 0000000..78649ee --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java @@ -0,0 +1,63 @@ +package com.hnac.gglm.bigmodel.interactive.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.BigModelConstants; +import com.hnac.gglm.bigmodel.business.service.DataSourceService; +import com.hnac.gglm.bigmodel.business.vo.SqlVO; +import com.hnac.gglm.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.gglm.bigmodel.interactive.dto.ControlDTO; +import com.hnac.gglm.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInteractiveService; +import com.hnac.gglm.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:21 + */ +@RestController +@AllArgsConstructor +@Api(value = "HZLLM大模型交互层",tags = "HZLLM大模型交互层") +@RequestMapping("/hzn_lm/interactive") +public class HznlmInteractiveController { + + private final IHznlmInteractiveService interactiveService; + private final DataSourceService dataSourceService; + + @PostMapping(value = "/get_auth_data") + @ApiOperation("获取鉴权数据") + @ApiOperationSupport(order = 1) + public R> getAuthData(@RequestBody AuthDataDTO req) { + return R.data(interactiveService.getAuthData(req)); + } + + @ApiOperation("解析大模型函数") + @ApiOperationSupport(order = 2) + @PostMapping("/resolve") + public R resolve(@RequestBody ModelFunctionReq req) { + return R.data(interactiveService.resolve(req)); + } + + @PostMapping("/execute_query") + @ApiOperation("执行大模型sql") + @ApiOperationSupport(order = 3) + public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { + return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); + } + + @PostMapping("/control_device") + @ApiOperation("控制设备") + @ApiOperationSupport(order = 4) + public R controlDevice(@RequestBody @Valid ControlDTO req) { + return R.data(interactiveService.controlDevice(req)); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/AuthDataDTO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/AuthDataDTO.java new file mode 100644 index 0000000..ca3878f --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/dto/AuthDataDTO.java @@ -0,0 +1,35 @@ +package com.hnac.gglm.bigmodel.interactive.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:39 + */ +@Data +@ApiModel(value = "获取权限接口传参格式",description = "获取权限接口传参格式") +@EqualsAndHashCode +public class AuthDataDTO implements Serializable { + + @JsonProperty("chatId") + @ApiModelProperty("问答ID,用于获取前端发起问答传入缓存中数据") + @NotBlank + private String sessionId; + + @ApiModelProperty("提问用户ID") + @NotBlank + private String userId; + + @ApiModelProperty("鉴权类型") + @NotBlank + private String type; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/AnswerResolveFactory.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/AnswerResolveFactory.java new file mode 100644 index 0000000..4f25f78 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/AnswerResolveFactory.java @@ -0,0 +1,57 @@ +package com.hnac.gglm.bigmodel.interactive.factory; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.service.IAnswerResolveService; +import com.hnac.hzinfo.exception.HzServiceException; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; + +/** + * @Author: huangxing + * @Date: 2024/06/21 18:44 + */ +public class AnswerResolveFactory { + + public static final String DIAGNOSE_ANSWER_SERVICE = "diagnoseAnswerResolveService"; + public static final String CHOICE_ANSWER_SERVICE = "choiceAnswerResolveService"; + public static final String REMOTE_ANSWER_SERVICE = "remoteAnswerResolveService"; + public static final String PARAM_ANSWER_SERVICE = "paramAnswerResolveService"; + public static final String PRE_ANSWER_SERVICE = "preAnswerResolveService"; + public static final String CONTROL_DEVICE_SERVICE = "controlAnswerResolveService"; + + public static IAnswerResolveService getResolveService(Object extra) { + String funcCode = JSONObject.parseObject(JSON.toJSONString(extra)).getString("func"); + return AnswerResolveFactory.getResolveService(funcCode); + } + + public static IAnswerResolveService getResolveService(String funcCode) { + FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); + if(Func.isNotEmpty(funcRouteEnum)) { + switch (funcRouteEnum) { + case DIAGNOSE: + return SpringUtil.getBean(DIAGNOSE_ANSWER_SERVICE); + case CHOOSE_VIDEO: + case CHOOSE_CANVAS: + case CHOOSE_STATION: + case CHOOSE_FAULT: + case CHOOSE_YC: + case CHOOSE_YK: + return SpringUtil.getBean(CHOICE_ANSWER_SERVICE); + case CONFIRM_YK: + return SpringUtil.getBean(REMOTE_ANSWER_SERVICE); + case SHOW_PARAM: + return SpringUtil.getBean(PARAM_ANSWER_SERVICE); + case CONTROL_DEVICE: + return SpringUtil.getBean(CONTROL_DEVICE_SERVICE); + default: + return null; + } + } + throw new HzServiceException(ResultCode.DEFAULT_NULL_MESSAGE,"service解析失败!"); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/ResolveFactory.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/ResolveFactory.java new file mode 100644 index 0000000..cd2342b --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/ResolveFactory.java @@ -0,0 +1,43 @@ +package com.hnac.gglm.bigmodel.interactive.factory; + +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.service.IResolveService; +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; + +/** + * @Author: huangxing + * @Date: 2024/06/21 15:53 + */ +@Slf4j +public class ResolveFactory { + + public static final String CANVAS_RESOLVE_SERVICE = "canvasResolveService"; + public static final String VIDEO_RESOLVE_SERVICE = "videoResolveService"; + + /** + * 获取解析函数需要的service + * @param funcCode 函数编号 + * @return 解析函数所需service + */ + public static IResolveService getResolveService(String funcCode) { + FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); + if(Func.isNotEmpty(funcRouteEnum)) { + switch(funcRouteEnum) { + case OPEN_CANVAS: + return SpringUtil.getBean("canvasResolveService"); + case OPEN_VIDEO: + return SpringUtil.getBean("videoResolveService"); + default: + log.error("函数解析失败,函数编号为:{}", funcCode); + throw new HzServiceException(ResultCode.FAILURE,"service解析失败"); + } + } + throw new ServiceException("service解析失败"); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IAnalyseDataService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IAnalyseDataService.java new file mode 100644 index 0000000..9e82b48 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IAnalyseDataService.java @@ -0,0 +1,16 @@ +package com.hnac.gglm.bigmodel.interactive.service; + +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import com.hnac.gglm.bigmodel.interactive.vo.HistoryDataSearchVO; + +/** + * @Author: huangxing + * @Date: 2024/05/28 11:29 + */ +public interface IAnalyseDataService { + + ExtraVO getHistoryData(HistoryDataSearchVO searchVO); + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IAnswerResolveService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IAnswerResolveService.java new file mode 100644 index 0000000..8e6dd49 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IAnswerResolveService.java @@ -0,0 +1,34 @@ +package com.hnac.gglm.bigmodel.interactive.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; + +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * @Author: huangxing + * @Date: 2024/06/21 18:39 + */ +public interface IAnswerResolveService { + + AnswerVO resolve(AnswerVO answer); + + /** + * 解析 extra + * @param originExtra 大模型传入 extra + * @return 解析后的 extra + */ + ExtraVO getExtra(JSONObject originExtra); + + /*** + * + * @param answer + * @return + */ + default Stream extraStream(AnswerVO answer) { + return Arrays.stream(answer.getExtras()).map(JSON::toJSONString).map(JSONObject::parseObject); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java new file mode 100644 index 0000000..0392499 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java @@ -0,0 +1,26 @@ +package com.hnac.gglm.bigmodel.interactive.service; + +import com.hnac.gglm.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.gglm.bigmodel.interactive.dto.ControlDTO; +import com.hnac.gglm.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.gglm.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import com.hnac.gglm.bigmodel.interactive.vo.ResolveResultVO; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.validation.Valid; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:23 + */ +public interface IHznlmInteractiveService { + + List getAuthData(AuthDataDTO req); + + ExtraVO resolve(ModelFunctionReq req); + + ExtraVO controlDevice(ControlDTO req); + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInvokeService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInvokeService.java new file mode 100644 index 0000000..83eb077 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInvokeService.java @@ -0,0 +1,97 @@ +package com.hnac.gglm.bigmodel.interactive.service; + +import com.hnac.gglm.bigmodel.business.dto.RunReportAnalyseRequest; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.question.dto.QuestionDTO; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 17:20 + */ +public interface IHznlmInvokeService { + + /** + * 基础问题 + * @param question 提问问题 + * @param sessionId 会话ID + * @param userId 提问人ID + * @return 提问结果 + */ + @Deprecated + void ask(String question, String sessionId, String userId); + + void ask(QuestionDTO question); + + /** + * 特殊问题 + * @param sessionId 会话ID + * @param userId 提问人ID + * @param extra 特殊问题内容 + * @return 提问结果 + */ + @Deprecated + void specialAsk(String sessionId, String userId, Map extra); + + void specialAsk(QuestionDTO questionDTO); + + /** + * 知识库问题 + * @param question 问题名称 + * @param sessionId 会话ID + * @param userId 提问人ID + * @param knowledge 知识库名称 + */ + @Deprecated + void knowledgeAsk(String question, String sessionId, String userId, String knowledge); + + void knowledgeAsk(QuestionDTO questionDTO); + + /** + * 发起数据分析问答 + * @param questionDTO + */ + void analyseAsk(QuestionDTO questionDTO); + + /** + * 删除对话记录 + * @param sessionId 会话ID + */ + void removeSessionId(String sessionId); + + /** + * 获取热点问题 + * @return 热点问题 + */ + List hotQuestions(); + + /** + * 查询问答状态 + * @param sessionIds 会话ID,按逗号分隔 + * @return 答案列表 + */ + List getAnswerBySessionIds(String sessionIds); + + /** + * 中断当前的问答 + * @param sessionId 会话ID + */ + void askAbort(String sessionId); + + void interruptSession(String sessionId); + + /** + * 发起机组发电量智能报表分析问答 + * @param req 待分析的数据 + */ + void smartReportGeneratePower(RunReportAnalyseRequest req); + + /** + * 更新数据 + * @param name 数据名 + */ + void updateKnowledge(String name); + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IResolveService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IResolveService.java new file mode 100644 index 0000000..fab0ec7 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IResolveService.java @@ -0,0 +1,17 @@ +package com.hnac.gglm.bigmodel.interactive.service; + +import com.hnac.gglm.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import com.hnac.gglm.bigmodel.interactive.vo.ResolveResultVO; + +/** + * @Author: huangxing + * @Date: 2024/06/21 15:39 + */ +public interface IResolveService { + + ExtraVO resolve(String id); + + ExtraVO resolve(ModelFunctionReq req); + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java new file mode 100644 index 0000000..e75a1de --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -0,0 +1,89 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.google.common.collect.Lists; +import com.hnac.gglm.bigmodel.business.service.HistoryDataService; +import com.hnac.gglm.bigmodel.interactive.constants.DataMethodEnum; +import com.hnac.gglm.bigmodel.interactive.constants.DateEnum; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.service.IAnalyseDataService; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import com.hnac.gglm.bigmodel.interactive.vo.HistoryDataSearchVO; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/05/28 11:29 + */ +@Service +@AllArgsConstructor +public class AnalyseDataServiceImpl implements IAnalyseDataService { + + private final HistoryDataService historyDataService; + + @Override + public ExtraVO getHistoryData(HistoryDataSearchVO searchVO) { + if(Func.isEmpty(searchVO.getDataType()) || StringUtil.isBlank(searchVO.getDataType()) + || DataMethodEnum.USUAL.getMethod().equals(searchVO.getMethod())) { + searchVO.setDataType(DateEnum.SECOND.getDateType()); + } + // 聚合数据方式处理 + DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); + searchVO.setDataType(dateEnum.getDateType()); + // 获取最适配时间段 + DateEnum adapterDate = historyDataService.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum); + String note = adapterDate.getDateType().equals(searchVO.getDataType()) ? "" : "(由于数据量过大,只能帮您" + adapterDate.getDateType() + "查询)"; + searchVO.setDataType(adapterDate.getDateType()); + ExtraVO extraVO = new ExtraVO(); + extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); + extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFunc()); + Map params = new HashMap<>(1); + Result reductionDataVOR = historyDataService.getPolymerizationData(searchVO); + String label; + if(!reductionDataVOR.isSuccess()) { + params.put("errorInfo",reductionDataVOR.getMsg()); + label = "查询数据失败!"; + } + else { + ReductionDataVO dataVO = reductionDataVOR.getData(); + label = "暂未查到数据"; + params.put("data",Lists.newArrayList()); + if(Func.isNotEmpty(dataVO) && CollectionUtil.isNotEmpty(dataVO.getDataList())) { + List datalist = dataVO.getDataList().stream().map(m -> { + m.put("val", m.get(searchVO.getSignage())); + m.remove(searchVO.getSignage()); + return m; + }).collect(Collectors.toList()); + DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); + if(CollectionUtil.isNotEmpty(datalist)) { + label = searchVO.getStationName() + "_" + + searchVO.getDeviceName() + "_" + + dataVO.getFieldMap().get(searchVO.getSignage()) + "_" + + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : adapterDate.getName()) + + enumByMethod.getMethod() + + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : note) + + ":"; + } + params.put("data",datalist); + } + } + extraVO.setLabel(label); + params.put("deviceName",searchVO.getDeviceName()); + params.put("attrName",searchVO.getAttrName()); + params.put("stationName",searchVO.getStationName()); + params.put("beginTime",searchVO.getStartTime()); + params.put("endTime",searchVO.getEndTime()); + extraVO.setParams(params); + return extraVO; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java new file mode 100644 index 0000000..1cc7fdb --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java @@ -0,0 +1,129 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.constants.ParamKeyConstants; +import com.hnac.gglm.bigmodel.interactive.factory.ResolveFactory; +import com.hnac.gglm.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.gglm.bigmodel.interactive.service.IResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.cache.ParamCache; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.*; +import java.util.stream.IntStream; + +/** + * @Author: huangxing + * @Date: 2024/06/21 15:39 + */ +@Service(ResolveFactory.CANVAS_RESOLVE_SERVICE) +@AllArgsConstructor +@Slf4j +public class CanvasResolveServiceImpl implements IResolveService { + + private final IStationClient stationClient; + + @Override + public ExtraVO resolve(ModelFunctionReq req) { + Map args = req.getItem(); + String id = args.get("itemId"); + String name = args.get("itemName"); + Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> { + log.error("解析传参错误,缺少必要参数video_id,传参内容为:{}", JSON.toJSONString(req)); + throw new HzServiceException(ResultCode.FAILURE,"解析传参错误,缺少必要参数video_id"); + }); + return this.resolve(id); + } + + @Override + public ExtraVO resolve(String id) { + ExtraVO extraVO = new ExtraVO(); + extraVO.setImmediatelyJump(true); + extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); + final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; + String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST); + // 将ID解析为 + Map resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE); + R stationR = stationClient.getStationByCode(resolveMap.get("projectId")); + extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + resolveMap.get("name")); + int picResource = Integer.parseInt(resolveMap.get("picResource")); + Map extraParams = new HashMap<>(1); + extraParams.put("picResource",picResource); + extraVO.setParams(extraParams); + // 云组态 + if(picResource == 0) { + String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_YZT_PATH), resolveMap); + extraVO.setRoute(canvasHost + path); + } + // v3.0 + else if(picResource == 1) { + String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_V3_PATH), resolveMap); + extraVO.setRoute(canvasHost + path); + } + // v4.0 + else if (picResource == 2) { + // pic_name 去掉头部的/ 以及尾部的.js + String context = resolveMap.get("context"); + context = this.removeHeadChars(context,"/"); + context = this.removeTailChars(context,".js"); + resolveMap.put("context",context); + extraVO.setRoute(this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&itemName={itemName}", resolveMap)); + } + else { + throw new HzServiceException(ResultCode.FAILURE,"解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由"); + } + return extraVO; + } + + public Map resolve(String paramsStr, String... keys) { + Map result = new HashMap<>(); + List params = Func.toStrList("\\^", paramsStr); + Assert.isTrue(params.size() == keys.length, () -> { + throw new HzServiceException(ResultCode.FAILURE, "大模型传参params长度错误,传参为:" + paramsStr); + }); + IntStream.iterate(0, index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index))); + return result; + } + + private String replacePath(String path,Map params) { + Set> entries = params.entrySet(); + // 替换path中变量 + for (Map.Entry entry : entries) { + String replaceVariables = "{" + entry.getKey() + "}"; + path = StringUtil.replace(path,replaceVariables,entry.getValue()); + } + return path; + } + + public String removeHeadChars(String str, String charsToRemove) { + if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { + return str; + } + while (str.startsWith(charsToRemove)) { + str = str.substring(charsToRemove.length()); + } + return str; + } + + public String removeTailChars(String str, String charsToRemove) { + if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { + return str; + } + while (str.endsWith(charsToRemove)) { + str = str.substring(0, str.length() - charsToRemove.length()); + } + return str; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java new file mode 100644 index 0000000..d04bafd --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java @@ -0,0 +1,43 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.factory.AnswerResolveFactory; +import com.hnac.gglm.bigmodel.interactive.service.IAnswerResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/06/21 19:02 + * @Describe 选项答案解析服务层 + */ +@AllArgsConstructor +@Service(AnswerResolveFactory.CHOICE_ANSWER_SERVICE) +@Slf4j +public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService { + + @Override + public AnswerVO resolve(AnswerVO answer) { + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); + return answer; + } + + @Override + public ExtraVO getExtra(JSONObject originExtra) { + ExtraVO result = JSONObject.parseObject(JSON.toJSONString(originExtra),ExtraVO.class); + result.setSpecial(true); + result.setType(FuncRouteEnum.getEnumByFuncCode(result.getFunc()).getType().getType()); + return result; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java new file mode 100644 index 0000000..7aa4182 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java @@ -0,0 +1,56 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.gglm.bigmodel.interactive.factory.AnswerResolveFactory; +import com.hnac.gglm.bigmodel.interactive.service.IAnswerResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.cache.ParamCache; +import org.springframework.stereotype.Service; +import com.hnac.gglm.bigmodel.interactive.constants.ParamKeyConstants; + +import java.util.HashMap; + +/** + * @Author: huangxing + * @Date: 2024/08/30 11:33 + */ +@Service(AnswerResolveFactory.CONTROL_DEVICE_SERVICE) +@Slf4j +public class ControlAnswerResolveServiceImpl implements IAnswerResolveService { + + @Override + public AnswerVO resolve(AnswerVO answer) { + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); + return answer; + } + + @Override + public ExtraVO getExtra(JSONObject originExtra) { + // 若extra中 itemId 为 spxj 则为视频巡检需特殊处理 + JSONObject params = originExtra.getJSONObject("params"); + if(Func.isNotEmpty(params) && Func.isNotEmpty(params.getString("itemId"))) { + String itemId = ParamCache.getValue(ParamKeyConstants.VIDEO_INSPECTION_CODE); + String url = ParamCache.getValue(ParamKeyConstants.VIDEO_INSPECTION_URL); + if(Func.isNotEmpty(itemId) && Func.isNotEmpty(url) + && itemId.equals(params.getString("itemId")) && Func.isNotEmpty(params.getString("stationId"))) { + log.info("控制指令传参为:{}", JSON.toJSONString(originExtra)); + String stationId = params.getString("stationId"); + HashMap param = new HashMap<>(1); + param.put("stationId",stationId); + String body = HttpRequest.post(url).body(JSON.toJSONString(param)).execute().body(); + params.put("data",body); + log.info("识别结果为:{}", body); + } + } + ExtraVO result = originExtra.toJavaObject(ExtraVO.class); + result.setType(FunctionConstants.TypeEnum.IMAGE_TEXT.getType()); + return result; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java new file mode 100644 index 0000000..793e191 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java @@ -0,0 +1,50 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.gglm.bigmodel.interactive.factory.AnswerResolveFactory; +import com.hnac.gglm.bigmodel.interactive.service.IAnswerResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 18:59 + */ +@Service(AnswerResolveFactory.DIAGNOSE_ANSWER_SERVICE) +@Slf4j +@AllArgsConstructor +public class DiagnoseAnswerResolveServiceImpl implements IAnswerResolveService { + + @Override + public AnswerVO resolve(AnswerVO answer) { + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); + return answer; + } + + @Override + public ExtraVO getExtra(JSONObject originExtra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data"))); + Map params = new HashMap<>(5); + params.put("faultId",data.getString("fault_id")); + params.put("name",data.getString("fault_name")); + params.put("station",data.getString("station_id")); + params.put("fdpDeviceName",data.getString("device_name")); + params.put("fdpOrd",data.getString("ord")); + result.setParams(params); + String funcCode = originExtra.getString("func"); + result.setFunc(funcCode); + result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); + return result; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java new file mode 100644 index 0000000..f78f897 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java @@ -0,0 +1,100 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.hnac.gglm.bigmodel.business.dto.ControlDeviceAuthDTO; +import com.hnac.gglm.bigmodel.business.feign.IAuthClient; +import com.hnac.gglm.bigmodel.business.service.AuthenticationService; +import com.hnac.gglm.bigmodel.interactive.constants.DataAuthTypeEnum; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.gglm.bigmodel.interactive.dto.ControlDTO; +import com.hnac.gglm.bigmodel.interactive.factory.ResolveFactory; +import com.hnac.gglm.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInteractiveService; +import com.hnac.gglm.bigmodel.interactive.service.IResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.dto.DeptStationDTO; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:24 + */ +@Service +@AllArgsConstructor +@Slf4j +public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService { + + private final AuthenticationService authenticationService; + private final IAuthClient authClient; + + @Override + public List getAuthData(AuthDataDTO req) { + DataAuthTypeEnum authTypeEnum = DataAuthTypeEnum.getEnumByType(req.getType()); + switch(authTypeEnum) { + case STATION: + return this.getStationAuthData(req.getUserId()); + case DEPT: + return this.getDeptAuthData(req.getUserId()); + default: + throw new ServiceException(req.getType() + "改类型获取权限数据暂不支持"); + } + } + + @Override + public ExtraVO resolve(ModelFunctionReq req) { + IResolveService resolveService = ResolveFactory.getResolveService(req.getFunc()); + return resolveService.resolve(req); + } + + @Override + public ExtraVO controlDevice(ControlDTO req) { + ExtraVO result = new ExtraVO(); + Optional optional = req.getYks().stream().map(controlDeviceDTO -> { + ControlDeviceAuthDTO deviceAuthDTO = BeanUtil.copy(controlDeviceDTO, ControlDeviceAuthDTO.class); + deviceAuthDTO.setUserId(req.getUserId()); + return deviceAuthDTO; + }).filter(d -> authClient.remoteAuth(d).isSuccess()).findFirst(); + Assert.isTrue(optional.isPresent(),() -> { + throw new ServiceException("鉴权失败!!"); + }); + // 封装返回的extra + result.setFunc(FuncRouteEnum.CONTROL_DEVICE.getFunc()); + result.setType(FuncRouteEnum.CONTROL_DEVICE.getType().getType()); + Map params = BeanUtil.toMap(optional.get()); + params.put("value", req.getValue()); + result.setParams(params); + return result; + } + + public List getDeptAuthData(String userId) { + List deptStationDTOs = authenticationService.getStationPermissionsById(userId); + return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList()); + } + + public List getStationAuthData(String userId) { + List deptStationDTOs = authenticationService.getStationPermissionsById(userId); + return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getItemId())).collect(Collectors.toList()); + } + + private AuthDataVO convertStationAuthData(DeptStationDTO req) { + return new AuthDataVO(req.getStationId(),req.getDeptName()); + } + + private AuthDataVO convertDeptAuthData(DeptStationDTO req) { + return new AuthDataVO(String.valueOf(req.getDeptId()),req.getDeptName()); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java new file mode 100644 index 0000000..5309f21 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java @@ -0,0 +1,205 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.google.common.collect.Lists; +import com.hnac.gglm.bigmodel.business.dto.RunReportAnalyseRequest; +import com.hnac.gglm.bigmodel.business.feign.IAuthClient; +import com.hnac.gglm.bigmodel.configuration.BigModelInvokeApi; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.manager.SessionRedisManager; +import com.hnac.gglm.bigmodel.question.dto.QuestionDTO; +import com.hnac.gglm.bigmodel.utils.RequestClientUtil; +import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants; +import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import com.hnac.hzims.common.constant.CommonConstant; +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * @Author: huangxing + * @Date: 2024/06/21 17:20 + * @Describe HZN_LM大模型接口调用服务层 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class HznlmInvokeServiceImpl implements IHznlmInvokeService { + + private final BigModelInvokeApi bigModelInvokeApi; + private final SessionRedisManager sessionRedisManager; + private final IAuthClient authClient; + private final RedisTemplate redisTemplate; + + @Value("${gglm.url}") + private String gglmUrl; + + @Override + public void ask(String question, String sessionId, String userId) { + Map params = new HashMap<>(); + params.put("chat_id",sessionId); + params.put("user_id", userId); + params.put("query",question); + Map authDataIds = this.getAuthDataIds(userId); + params.putAll(authDataIds); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); + sessionRedisManager.addSessionId(sessionId); + } + + @Override + public void ask(QuestionDTO question) { + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), JSON.toJSONString(question)); + sessionRedisManager.addSessionId(question.getChatId()); + } + + @Override + public void specialAsk(String sessionId, String userId, Map extra) { + Map params = new HashMap<>(); + params.put("chat_id",sessionId); + params.put("user_id", userId); + params.put("extra",extra); + Map authDataIds = this.getAuthDataIds(userId); + params.putAll(authDataIds); + log.info("调用大模型接口:{},传参为:{}",gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(),JSON.toJSONString(params)); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params); + sessionRedisManager.addSessionId(sessionId); + } + + @Override + public void specialAsk(QuestionDTO question) { + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(question)); + sessionRedisManager.addSessionId(question.getChatId()); + } + + @Override + public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { + Map params = new HashMap<>(); + params.put("chat_id", sessionId); + params.put("user_id", userId); + params.put("query", question); + params.put("knowledge", knowledge); + Map authDataIds = this.getAuthDataIds(userId); + params.putAll(authDataIds); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); + sessionRedisManager.addSessionId(sessionId); + } + + @Override + public void knowledgeAsk(QuestionDTO question) { + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(question)); + sessionRedisManager.addSessionId(question.getChatId()); + } + + @Override + public void analyseAsk(QuestionDTO question) { + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(question)); + sessionRedisManager.addSessionId(question.getChatId()); + } + + @Override + public void removeSessionId(String sessionId) { + this.askAbort(sessionId); + // 移除内存sessionId + InteractiveSessionManager.SESSION_POOL.remove(sessionId); + sessionRedisManager.removeSessionId(sessionId); + } + + @Override + public void askAbort(String sessionId) { + Map params = new HashMap<>(); + params.put("chat_id",sessionId); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params); + sessionRedisManager.removeSessionId(sessionId); + } + + public void interruptSession(String sessionId) { + this.askAbort(sessionId); + // 循环获取该会话ID中断状态,当状态等于-2或重连超6次则中断返回结果 + int status = 999; + int attempts = 0; + while (status > 0) { + // 若重连超过10次 则抛出错误 + if(attempts >= 8) { + throw new HzServiceException("中断失败!长时间未获取到中断状态"); + } + List answers = this.getAnswerBySessionIds(sessionId); + if(Func.isNotEmpty(answers)) { + log.info(answers.get(0).getStatus()+""); + status = answers.get(0).getStatus(); + } + // 若获取到的状态不等于2 则延时0.5秒 + if(status > 0) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + attempts ++; + } + } + + @Override + public void smartReportGeneratePower(RunReportAnalyseRequest req) { + Map params = new HashMap<>(); + String sessionId = IdWorker.get32UUID(); + params.put("chat_id",sessionId); + params.put("user_id", CommonConstant.SYSTEM_USER.toString()); + params.put("data", req.getAnalyseDTOS()); + params.put("query", ""); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params); + // 将sessionId存入redis,拿到数据之后输入月报中 + JSONObject report = new JSONObject(); + report.put("stationCode",req.getStationCode()); + report.put("month",req.getMonth()); + report.put("sessionId",sessionId); + redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID,JSON.toJSONString(report)); + redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID,5, TimeUnit.MINUTES); + } + + @Override + public void updateKnowledge(String name) { + Map params = new HashMap<>(); + params.put("name",name); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params); + } + + @Override + public List hotQuestions() { + try { + return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference>(){}); + } + catch (Exception e) { + log.error("An error occurred",e); + return Lists.newArrayList(); + } + } + + @Override + public List getAnswerBySessionIds(String sessionIds) { + Map params = new HashMap<>(); + params.put("chat_ids",Func.toStrList(",",sessionIds).toArray()); + return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference>(){}); + } + + private Map getAuthDataIds(String userId) { + Map result = new HashMap<>(2); + R> authDataR = authClient.getAuthData(userId); + result.putAll(authDataR.getData()); + return result; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java new file mode 100644 index 0000000..98c57c2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java @@ -0,0 +1,106 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.constants.SearchTypeEnum; +import com.hnac.gglm.bigmodel.interactive.factory.AnswerResolveFactory; +import com.hnac.gglm.bigmodel.interactive.service.IAnalyseDataService; +import com.hnac.gglm.bigmodel.interactive.service.IAnswerResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.*; +import com.xxl.job.core.log.XxlJobLogger; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 19:02 + */ +@Service(AnswerResolveFactory.PARAM_ANSWER_SERVICE) +@Slf4j +@AllArgsConstructor +public class ParamAnswerResolveServiceImpl implements IAnswerResolveService { + + private final IAnalyseDataService analyseDataService; + + public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS"; + + @Override + public AnswerVO resolve(AnswerVO answer) { + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); + return answer; + } + + @Override + public ExtraVO getExtra(JSONObject originExtra) { + DataVO data = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")),DataVO.class); + Assert.isTrue(Func.isNotEmpty(data),() -> { + XxlJobLogger.log("解析参数答案失败,extra不能为空!"); + throw new ServiceException("解析参数答案失败,extra不能为空!"); + }); + if(Func.isNotEmpty(data.getReal())) { + // 处理查询实时数据 + RealDataVO real = data.getReal(); + Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); + real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); + } + else if(StringUtil.isNotBlank(data.getType()) && SearchTypeEnum.HISTORY.getSearchType().equals(data.getType())) { + // 处理查询历史数据 + return this.getHistoryData(data); + } + String funcCode = originExtra.getString("func"); + ExtraVO result = new ExtraVO(); + result.setFunc(funcCode); + result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); + Map param = new HashMap(1); + param.put("data", data); + result.setParams(param); + return result; + } + + /** + * 查询历史数据 + * @param data 大模型识别数据信息 + * @return 历史数据 + */ + private ExtraVO getHistoryData(DataVO data) { + // 确认查询聚合方式传入 + Assert.isTrue(Func.isNotEmpty(data.getItem()) && StringUtil.isNotBlank(data.getMethod()),() -> { + XxlJobLogger.log("历史数据查询方式为空,查询失败!"); + throw new ServiceException("历史数据查询方式为空,查询失败!"); + }); + return analyseDataService.getHistoryData(this.convertHistoryDataSearch(data)); + } + + /** + * 获取历史数据查询对象 + * @param data 大模型解析点位信息 + * @return 历史数据查询对象 + */ + private HistoryDataSearchVO convertHistoryDataSearch(DataVO data) { + HistoryDataSearchVO searchVO = new HistoryDataSearchVO(); + DataItemVO item = data.getItem(); + searchVO.setDataType(data.getDataType()); + searchVO.setAttrName(item.getAttrName()); + searchVO.setDeviceCode(item.getDeviceId()); + searchVO.setDeviceName(item.getDeviceName()); + searchVO.setStationName(item.getProjectName()); + searchVO.setMethod(data.getMethod()); + searchVO.setSignage(item.getSignage()); + searchVO.setStartTime(data.getStartTime()); + searchVO.setEndTime(data.getEndTime()); + return searchVO; + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java new file mode 100644 index 0000000..e213ce8 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java @@ -0,0 +1,59 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.factory.AnswerResolveFactory; +import com.hnac.gglm.bigmodel.interactive.service.IAnswerResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import com.hnac.gglm.bigmodel.interactive.vo.RemoteParamVO; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 19:02 + */ +@Service(AnswerResolveFactory.REMOTE_ANSWER_SERVICE) +@Slf4j +@AllArgsConstructor +public class RemoteAnswerResolveServiceImpl implements IAnswerResolveService { + + private final DeviceClient deviceClient; + + @Override + public AnswerVO resolve(AnswerVO answer) { + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); + return answer; + } + + @Override + public ExtraVO getExtra(JSONObject originExtra) { + ExtraVO result = new ExtraVO(); + RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")), RemoteParamVO.class); + String funcCode = originExtra.getString("func"); + result.setFunc(funcCode); + result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); + R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); + if(funcVOR.isSuccess()) { + Map param = new HashMap(); + param.put("control",funcVOR.getData()); + param.put("deviceName",remoteParam.getDeviceName()); + param.put("projectName",remoteParam.getProjectName()); + param.put("deviceCode",remoteParam.getDeviceId()); + param.put("value",remoteParam.getValue()); + result.setParams(param); + } + return result; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java new file mode 100644 index 0000000..b4fa131 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java @@ -0,0 +1,69 @@ +package com.hnac.gglm.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.gglm.bigmodel.interactive.factory.ResolveFactory; +import com.hnac.gglm.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.gglm.bigmodel.interactive.service.IResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 16:17 + */ +@Service(ResolveFactory.VIDEO_RESOLVE_SERVICE) +@AllArgsConstructor +@Slf4j +public class VideoResolveServiceImpl implements IResolveService { + + private final IStationVideoTypeClient videoClient; + + @Override + public ExtraVO resolve(ModelFunctionReq req) { + Map args = req.getItem(); + String id = args.get("itemId"); + String name = args.get("itemName"); + Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> { + log.error("解析传参错误,缺少必要参数video_id,传参内容为:{}", JSON.toJSONString(req)); + throw new HzServiceException(ResultCode.FAILURE, "解析传参错误,缺少必要参数video_id"); + }); + return this.resolve(id); + } + + @Override + public ExtraVO resolve(String idStr) { + Long id = Long.valueOf(idStr); + // 跳转页面逻辑 + ExtraVO extraVO = new ExtraVO(); + R videoR = videoClient.getById(Long.valueOf(id)); + if(videoR.isSuccess()) { + StationVideoTypeEntity video = videoR.getData(); + extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); + extraVO.setImmediatelyJump(true); + extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFunc()); + Map params = new HashMap<>(); + params.put("name", video.getName()); + params.put("videoHost", video.getVideoHost()); + params.put("pointCode", video.getPointCode()); + params.put("appKey", video.getAppKey()); + params.put("appSecret", video.getAppSecret()); + params.put("liveSourceAddress",video.getLiveSourceAddress()); + extraVO.setParams(params); + } + return extraVO; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AnswerVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AnswerVO.java new file mode 100644 index 0000000..7c857bd --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AnswerVO.java @@ -0,0 +1,71 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import com.hnac.gglm.bigmodel.interactive.constants.InfoMessageConstant; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.springblade.core.tool.utils.BeanUtil; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/06 14:37 + */ +@Data +@ApiModel("HZLLM答案VO对象") +@EqualsAndHashCode +@AllArgsConstructor +@NoArgsConstructor +public class AnswerVO implements Serializable { + + @ApiModelProperty("发起问答时的随机ID") + @JSONField(name = "chat_id") + private String chatId; + + @ApiModelProperty("发起问答时的用户ID") + @JSONField(name = "user_id") + private String userId; + + @ApiModelProperty("1代表代表正在进行问答,0代表已完成") + private Integer running; + + /** + * 正常发起一次问答,status会经历0、1、2、3、9、0的过程,如果问答需要执行多次指令,则可能会是0、1、2、3、2、3、9、0。 + * 9为大模型回复中,answer中会不断填充内容 + */ + @ApiModelProperty("1代表代表正在进行问答,0代表已完成") + private Integer status; + + @ApiModelProperty("当running为1时,用于显示状态文本") + private String text; + + @ApiModelProperty("最近一次发起的问题") + private String query; + + @ApiModelProperty("query对应的答案") + private String answer; + + @ApiModelProperty("其它调用的参数") + private Object[] extras; + + @ApiModelProperty("用于语音回复的状态文本") + @JSONField(name = "voice_text") + private String[] voiceText; + + @ApiModelProperty("用于语音回复的答案") + @JSONField(name = "voice_answer") + private String[] voiceAnswer; + + public static AnswerVO error(String sessionId,String userId,String query) { + return new AnswerVO(sessionId,userId,0,-2,null,query, InfoMessageConstant.ERROR_MESSAGE, null,null,new String[]{InfoMessageConstant.ERROR_MESSAGE}); + } + + public static AnswerVO progress(String sessionId,String userId,String query,String message,Integer status) { + return new AnswerVO(sessionId,userId,1,status,null,query, message, null,null,new String[]{message}); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AuthDataVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AuthDataVO.java new file mode 100644 index 0000000..b15a043 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/AuthDataVO.java @@ -0,0 +1,27 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:26 + */ +@Data +@AllArgsConstructor +@ApiModel(value = "鉴权数据VO",description = "鉴权数据VO,包含站点、机构、遥控权限") +@EqualsAndHashCode +public class AuthDataVO implements Serializable { + + @ApiModelProperty("数据ID") + private String itemId; + + @ApiModelProperty("数据名称") + private String itemName; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/HistoryDataSearchVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/HistoryDataSearchVO.java new file mode 100644 index 0000000..44c9ecb --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/HistoryDataSearchVO.java @@ -0,0 +1,37 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Author: huangxing + * @Date: 2024/05/28 11:48 + */ +@Data +public class HistoryDataSearchVO { + + @NotBlank + private String startTime; + + @NotBlank + private String endTime; + + @NotBlank + private String deviceCode; + + @NotBlank + private String signage; + + private String attrName; + + @NotBlank + private String method; + + private String dataType; + + private String stationName; + + private String deviceName; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RemoteParamVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RemoteParamVO.java new file mode 100644 index 0000000..b45ac45 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/RemoteParamVO.java @@ -0,0 +1,39 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/20 14:46 + */ +@Data +@EqualsAndHashCode +public class RemoteParamVO implements Serializable { + + @JSONField(name = "itemId") + private String funcId; + + @JSONField(name = "yk_name") + private String remoteName; + + @JSONField(name = "device_id") + private String deviceId; + + @JSONField(name = "device_name") + private String deviceName; + + @JSONField(name = "station_id") + private String projectId; + + @JSONField(name = "station_name") + private String projectName; + + private String signage; + + private String value; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ResolveResultVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ResolveResultVO.java new file mode 100644 index 0000000..42a0124 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/ResolveResultVO.java @@ -0,0 +1,29 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.hnac.gglm.bigmodel.interactive.constants.InfoMessageConstant; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/06/21 16:31 + */ +@EqualsAndHashCode +@Data +@AllArgsConstructor +@ApiModel(value = "解析结果",description = "解析结果") +public class ResolveResultVO implements Serializable { + + private String content; + + private ExtraVO extraVO; + + public static ResolveResultVO error() { + return new ResolveResultVO(InfoMessageConstant.ERROR_MESSAGE,null); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SessionContentVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SessionContentVO.java new file mode 100644 index 0000000..7110294 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/SessionContentVO.java @@ -0,0 +1,19 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/20 19:31 + */ +@Data +@EqualsAndHashCode +public class SessionContentVO implements Serializable { + + /**机器码**/ + private String machineCode; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/StationSearchVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/StationSearchVO.java new file mode 100644 index 0000000..cc7cae9 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/StationSearchVO.java @@ -0,0 +1,24 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/25 14:03 + */ +@Data +public class StationSearchVO implements Serializable { + + private String startTime; + + private String endTime; + + @NotBlank(message = "查询类型不能为空") + private String type; + + private String enumType; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/UpdateStationVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/UpdateStationVO.java new file mode 100644 index 0000000..4197b18 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/UpdateStationVO.java @@ -0,0 +1,20 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 09:50 + */ +@Data +public class UpdateStationVO implements Serializable { + + /**站点ID**/ + private String id; + + /**站点名称**/ + private String name; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/UpdateUsualVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/UpdateUsualVO.java new file mode 100644 index 0000000..e7d7e86 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/vo/UpdateUsualVO.java @@ -0,0 +1,25 @@ +package com.hnac.gglm.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 09:53 + */ +@Data +public class UpdateUsualVO implements Serializable { + + /**站点ID**/ + @JSONField(name = "station_id") + private String stationId; + + /**业务ID**/ + private String id; + + /**业务名称**/ + private String name; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/AgentLogController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/AgentLogController.java new file mode 100644 index 0000000..04d3510 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/AgentLogController.java @@ -0,0 +1,80 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.entity.AgentLogEntity; +import com.hnac.gglm.bigmodel.maintenance.service.AgentLogService; +import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; +import com.hnac.gglm.bigmodel.maintenance.vo.LabelRequest; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +/** + * @Author: ypj + * @Date: 2024/9/9 10:37 + */ +@RestController +@Slf4j +@AllArgsConstructor +@RequestMapping("/label") +@Api(value = "问题标注", tags = "问题标注") +public class AgentLogController { + private final AgentLogService agentLogService; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, AgentLogEntity req) { + return R.data(agentLogService.listPage(Condition.getPage(query), req)); + } + + @GetMapping("/detail") + @ApiOperation(value = "查看详情") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(agentLogService.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存") + @ApiOperationSupport(order = 3) + public R save(@RequestBody AgentLogEntity req) { + return R.status(agentLogService.save(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除") + @ApiOperationSupport(order = 4) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(agentLogService.removeByIds(Func.toLongList(",", ids))); + } + + @PutMapping("/update") + @ApiOperation(value = "编辑") + @ApiOperationSupport(order = 5) + public R update(@RequestBody AgentLogEntity req) { + return R.status(agentLogService.updateById(req)); + } + + @PutMapping("/batchLabel") + @ApiOperation(value = "批量标注") + @ApiOperationSupport(order = 6) + public R BatchLabel(@RequestBody IdsRequest ids) { + return R.status(agentLogService.BatchLabel(ids)); + } + + @PutMapping("/label") + @ApiOperation(value = "标注") + @ApiOperationSupport(order = 7) + public R label(@RequestBody LabelRequest req) { + return R.status(agentLogService.label(req)); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/ControlController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/ControlController.java new file mode 100644 index 0000000..2f399da --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/ControlController.java @@ -0,0 +1,73 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.gglm.bigmodel.maintenance.entity.ControlEntity; +import com.hnac.gglm.bigmodel.maintenance.service.ControlService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +/** + * @Author: huangxing + * @Date: 2024/08/19 18:50 + */ +@RestController +@RequestMapping("/control") +@Api(tags = "设备控制指令管理",value = "设备控制指令管理") +@AllArgsConstructor +public class ControlController { + + private final ControlService service; + private final IHznlmInvokeService invokeService; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, ControlEntity req) { + return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @GetMapping("/detail") + @ApiOperation(value = "查看详情") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(service.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存设备控制指令配置") + @ApiOperationSupport(order = 3) + public R save(@RequestBody ControlEntity req) { + return R.status(service.save(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除设备控制指令配置") + @ApiOperationSupport(order = 4) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(service.removeByIds(Func.toLongList(",",ids))); + } + + @PutMapping("/updateById") + @ApiOperation(value = "编辑设备控制指令") + @ApiOperationSupport(order = 5) + public R updateById(@RequestBody ControlEntity req) { + return R.status(service.updateById(req)); + } + + @PutMapping("/updateKnowledge") + @ApiOperation(value = "更新设备控制知识库") + @ApiOperationSupport(order = 6) + public R updateKnowledge() { + invokeService.updateKnowledge("yk"); + return R.success("操作成功!"); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataSourceController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataSourceController.java new file mode 100644 index 0000000..bd41263 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataSourceController.java @@ -0,0 +1,75 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.entity.DatasourceEntity; +import com.hnac.gglm.bigmodel.maintenance.service.DataSourceService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/05 16:55 + */ +@RestController +@RequestMapping("/datasource") +@Api(value = "数据源管理",tags = "数据源管理") +public class DataSourceController { + + @Autowired + @Qualifier("dataSourceMaintenanceService") + private DataSourceService dataSourceService; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, DatasourceEntity req) { + return R.data(dataSourceService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @GetMapping("/detail") + @ApiOperation(value = "查看详情") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(dataSourceService.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存数据源配置") + @ApiOperationSupport(order = 3) + public R save(@RequestBody DatasourceEntity req) { + return R.status(dataSourceService.save(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除数据源配置") + @ApiOperationSupport(order = 4) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(dataSourceService.removeByIds(Func.toLongList(",",ids))); + } + + @PutMapping("/update") + @ApiOperation(value = "编辑数据源配置") + @ApiOperationSupport(order = 5) + public R update(@RequestBody DatasourceEntity req) { + return R.status(dataSourceService.updateById(req)); + } + + @GetMapping("/list") + @ApiOperation(value = "列表查询") + @ApiOperationSupport(order = 1) + public R> list(DatasourceEntity req) { + return R.data(dataSourceService.list(Condition.getQueryWrapper(req).lambda())); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java new file mode 100644 index 0000000..bf99c6e --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java @@ -0,0 +1,77 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; +import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.oss.model.BladeFile; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.resource.feign.IOssClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +/** + * @Author: ypj + * @Date: 2024/9/10 16:44 + */ +@RestController +@Slf4j +@RequestMapping("/knowledge/file") +@Api(value = "知识库文件管理", tags = "知识库文件管理") +@AllArgsConstructor +public class KnowledgeFileInfoController { + private final KnowledgeFileInfoService knowledgeFileInfoService; + private final IOssClient ossClient; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, KnowledgeFileInfo req) { + return R.data(knowledgeFileInfoService.page(Condition.getPage(query), + Condition.getQueryWrapper(new KnowledgeFileInfo(), req).orderByDesc(KnowledgeFileInfo::getCreateTime))); + } + + @GetMapping("/detail") + @ApiOperation(value = "查看详情") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(knowledgeFileInfoService.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存") + @ApiOperationSupport(order = 3) + public R save(@RequestBody KnowledgeFileInfo req) { + return R.status(knowledgeFileInfoService.save(req)); + } + + @PutMapping("/update") + @ApiOperation(value = "编辑") + @ApiOperationSupport(order = 4) + public R update(@RequestBody KnowledgeFileInfo req) { + return R.status(knowledgeFileInfoService.updateById(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除") + @ApiOperationSupport(order = 5) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(knowledgeFileInfoService.removeByIds(Func.toLongList(",", ids))); + } + + @PostMapping(value = "/upload", produces = MediaType.APPLICATION_PROBLEM_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @ApiOperation(value = "上传文件") + @ApiOperationSupport(order = 6) + public R upload(@ApiParam(value = "上传文件", required = true) @RequestPart("file") MultipartFile file) { + return ossClient.putFile(file); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TableColumnController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TableColumnController.java new file mode 100644 index 0000000..e9692d3 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TableColumnController.java @@ -0,0 +1,54 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.BigModelConstants; +import com.hnac.gglm.bigmodel.maintenance.service.TableColumnService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/04 09:28 + */ +@RestController +@RequestMapping("/table/info") +@Api(value = "数据库表、列信息查询管理",tags = "数据库表、列信息查询管理") +@AllArgsConstructor +public class TableColumnController { + + private final TableColumnService tableColumnService; + + @ApiOperation("获取数据库") + @ApiOperationSupport(order = 1) + @GetMapping("/getDatabase") + public R>> getDatabase(@RequestParam @ApiParam(value = "数据源名") String datasource) { + return R.data(tableColumnService.getDatabase(datasource)); + } + + @ApiOperation("获取数据库表列表") + @ApiOperationSupport(order = 2) + @GetMapping("/getTables") + public R>> getTables(@RequestParam @ApiParam(value = "数据源名") String datasource, + @RequestParam @ApiParam(value = "数据库名") String database) { + return R.data(tableColumnService.getTables(datasource,database)); + } + + @ApiOperation("获取数据库表列列表") + @ApiOperationSupport(order = 3) + @GetMapping("/getColumns") + public R>> getColumns(String datasource, + @RequestParam @ApiParam(value = "数据源名") String database, + @RequestParam @ApiParam(value = "数据库表名") String tableName) { + return R.data(tableColumnService.getColumns(datasource,database,tableName)); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TableInfoController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TableInfoController.java new file mode 100644 index 0000000..4ada142 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TableInfoController.java @@ -0,0 +1,59 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.BigModelConstants; +import com.hnac.gglm.bigmodel.maintenance.entity.TableInfoEntity; +import com.hnac.gglm.bigmodel.maintenance.service.TableInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * @Author: huangxing + * @Date: 2024/07/04 15:26 + */ +@RestController +@RequestMapping("/tableInfo") +@Api(value = "数据库信息管理",tags = "数据库信息管理") +@AllArgsConstructor +public class TableInfoController { + + private final TableInfoService tableInfoService; + + @PostMapping("/save") + @ApiOperation("保存数据库信息") + @ApiOperationSupport(order = 1) + public R save(@RequestBody @Valid TableInfoEntity req) { + return R.data(tableInfoService.save(req)); + } + + @PostMapping("/update") + @ApiOperation("编辑数据库信息") + @ApiOperationSupport(order = 2) + public R update(@RequestBody TableInfoEntity req) { + return R.data(tableInfoService.updateById(req)); + } + + @GetMapping("/listPage") + @ApiOperation("数据库信息列表查询") + @ApiOperationSupport(order = 3) + public R> listPage(Query query, TableInfoEntity req) { + return R.data(tableInfoService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @DeleteMapping("/removeByIds") + @ApiOperation("删除数据库信息") + @ApiOperationSupport(order = 4) + public R removeByIds(@RequestParam @ApiParam("id,按逗号分隔") String ids) { + return R.status(tableInfoService.removeByIds(Func.toLongList(",",ids))); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TablePropertyController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TablePropertyController.java new file mode 100644 index 0000000..28844f0 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/TablePropertyController.java @@ -0,0 +1,64 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.entity.TablePropertyEntity; +import com.hnac.gglm.bigmodel.maintenance.service.TablePropertyService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:19 + */ +@RestController +@RequestMapping("/table/property") +@Api(value = "表配置",tags = "表配置") +@AllArgsConstructor +public class TablePropertyController { + + private final TablePropertyService tablePropertyService; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, TablePropertyEntity req) { + return R.data(tablePropertyService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @GetMapping("/detail") + @ApiOperation(value = "查看详情") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(tablePropertyService.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存表配置") + @ApiOperationSupport(order = 3) + public R save(@RequestBody TablePropertyEntity req) { + return R.status(tablePropertyService.save(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除表配置") + @ApiOperationSupport(order = 4) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(tablePropertyService.removeByIds(Func.toLongList(",",ids))); + } + + @PutMapping("/update") + @ApiOperation(value = "编辑表配置") + @ApiOperationSupport(order = 5) + public R update(@RequestBody TablePropertyEntity req) { + return R.status(tablePropertyService.updateById(req)); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java new file mode 100644 index 0000000..d8142a8 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java @@ -0,0 +1,118 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; +import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService; +import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; +import com.hnac.hzinfo.api.annotation.ApiInterface; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: ypj + * @Date: 2024/9/2 16:10 + */ +@RestController +@RequestMapping("/vector") +@Api(value = "向量参数配置", tags = "向量参数配置") +@AllArgsConstructor +@Slf4j +public class VectorParamController { + private final VectorParamService vectorParamService; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, VectorParamEntity req) { + return R.data(vectorParamService.page(Condition.getPage(query), Condition.getQueryWrapper(new VectorParamEntity(), req))); + } + + @GetMapping("/detail") + @ApiOperation(value = "查看详情") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(vectorParamService.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存向量参数配置") + @ApiOperationSupport(order = 3) + public R save(@RequestBody VectorParamEntity req) { + return R.status(vectorParamService.save(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除向量参数配置") + @ApiOperationSupport(order = 4) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(vectorParamService.removeByIds(Func.toLongList(",", ids))); + } + + @PutMapping("/update") + @ApiOperation(value = "编辑向量参数配置") + @ApiOperationSupport(order = 5) + public R update(@RequestBody VectorParamEntity req) { + return R.status(vectorParamService.updateById(req)); + } + + @GetMapping("/getAuthorization") + @ApiOperation(value = "获取向量参数配置授权信息") + @ApiOperationSupport(order = 6) + public R getAuthorization() { + return R.data(vectorParamService.getAuthorization()); + } + + @GetMapping("/getUrlResponse") + @ApiOperation(value = "通过url获取向量参数数据") + @ApiOperationSupport(order = 7) + public R getUrlResponse(@RequestParam String url, + @RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, + @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken) throws JsonProcessingException { + return R.data(vectorParamService.getUrlResponse(url, bladeToken, hzinfoToken)); + } + + @GetMapping("/getTestData") + @ApiOperation(value = "测试数据") + @ApiOperationSupport(order = 8) + @ApiInterface + public R getUrlByte() { + Map data = new HashMap<>(); + data.put("name", "测试数据"); + data.put("url", "https://img.zcool.cn/community/01d9d85a8f9f2fa801206e0d0e0e9a.jpg@1280w_1l_2o_100sh.jpg"); + data.put("data", "data"); + List list = new java.util.ArrayList<>(); + list.add(data); + return R.data(list); + } + + @GetMapping("/getUrlResponseKeyList") + @ApiOperation(value = "获取url返回的key列表") + @ApiOperationSupport(order = 9) + public R> getUrlResponseKeyList(@RequestParam String url, + @RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, + @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken) throws JsonProcessingException { + return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken)); + } + + @PutMapping("/synchronization/") + @ApiOperation(value = "同步") + @ApiOperationSupport(order = 10) + public R synchronization(@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, + @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken, @RequestBody IdsRequest req) throws JsonProcessingException { + return R.status(vectorParamService.synchronization(req.getIds(), bladeToken, hzinfoToken)); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java new file mode 100644 index 0000000..3398c92 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java @@ -0,0 +1,94 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author: ypj + * @Date: 2024/9/9 10:38 + */ +@ApiModel("问题标注") +@TableName("agent_log") +@Data +public class AgentLogEntity extends TenantEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("对话id") + @TableField("chat_id") + @QueryField(condition = SqlCondition.EQUAL) + private String chatId; + + @ApiModelProperty("问题id") + @TableField("q_id") + @QueryField(condition = SqlCondition.EQUAL) + @JSONField(name = "qId") + private String qId; + + @ApiModelProperty("模型名称") + @QueryField(condition = SqlCondition.EQUAL) + @TableField("model_name") + private String modelName; + + @ApiModelProperty("问题来源") + @QueryField(condition = SqlCondition.EQUAL) + private String agent; + + @ApiModelProperty("问题") + @QueryField(condition = SqlCondition.LIKE) + private String q; + + @ApiModelProperty("问题提示") + @QueryField(condition = SqlCondition.LIKE) + @TableField("prompt") + @JSONField(name = "prompt") + private String prompt; + + @ApiModelProperty("系统提示") + @QueryField(condition = SqlCondition.LIKE) + @TableField("system") + private String system; + + @ApiModelProperty("答案") + @QueryField(condition = SqlCondition.LIKE) + private String a; + + @ApiModelProperty("用户结论,0为错误,1为正确") + @QueryField(condition = SqlCondition.EQUAL) + @TableField("user_conclusion") + private int userConclusion; + + @ApiModelProperty("标注状态,0为未标注,1为已标注") + @QueryField(condition = SqlCondition.EQUAL) + @TableField("label_status") + private int labelStatus; + + @ApiModelProperty("标注结果,0为错误,1为正确") + @QueryField(condition = SqlCondition.EQUAL) + @TableField("label_result") + private int labelResult; + + @ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样") + @QueryField(condition = SqlCondition.LIKE) + @TableField("label_content") + private String labelContent; + + @ApiModelProperty("标注人名称") + @QueryField(condition = SqlCondition.LIKE) + @TableField("label_operator") + private String labelOperator; + + @ApiModelProperty("标注时间") + @QueryField(condition = SqlCondition.EQUAL) + @TableField("label_time") + private Date labelTime; +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataRecordEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataRecordEntity.java new file mode 100644 index 0000000..c94fdd6 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataRecordEntity.java @@ -0,0 +1,17 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import lombok.Data; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * @Author: huangxing + * @Date: 2024/07/04 15:45 + */ +@Data +public class DataRecordEntity extends TenantEntity { + + private String tableId; + + + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DatasourceEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DatasourceEntity.java new file mode 100644 index 0000000..87f5c11 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DatasourceEntity.java @@ -0,0 +1,37 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/05 14:45 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("HZIMS_DATASOURCE") +@ApiModel(value = "数据源配置",description = "数据源配置") +public class DatasourceEntity extends TenantEntity implements Serializable { + + @ApiModelProperty("数据源") + @QueryField(condition = SqlCondition.EQUAL) + private String datasource; + + @ApiModelProperty("数据源名称") + @QueryField(condition = SqlCondition.LIKE) + private String datasourceName; + + @ApiModelProperty("数据库名称") + @QueryField(condition = SqlCondition.LIKE) + private String databaseName; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileInfo.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileInfo.java new file mode 100644 index 0000000..0f46500 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileInfo.java @@ -0,0 +1,56 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + +/** + * @Author: ypj + * @Date: 2024/9/10 15:17 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("HZIMS_KNOWLEDGE_FILE_INFO") +@ApiModel(value = "知识库文件信息",description = "知识库文件信息") +public class KnowledgeFileInfo extends TenantEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("文件名称") + private String name; + + @ApiModelProperty("文件url") + private String url; + + @ApiModelProperty("文件大小") + private Long size; + + @ApiModelProperty("简介") + private String briefs; + + @ApiModelProperty("标签") + private String tags; + + @ApiModelProperty("业务领域") + private String domain; + + @ApiModelProperty("权限等级,5个等级") + @TableField("AUTHORITY_CLASS") + private Integer authorityClass; + + @ApiModelProperty("是否可见,0为不可见,1为可见") + private Integer visible; + + @ApiModelProperty("文件状态,0为未入库,1为已入库") + @TableField("FILE_STATUS") + private Integer fileStatus; + + @ApiModelProperty("备注") + private String remark; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/SyncPropertyEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/SyncPropertyEntity.java new file mode 100644 index 0000000..cb17b38 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/SyncPropertyEntity.java @@ -0,0 +1,40 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/08/21 08:33 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "同步向量库基础配置",description = "同步向量库基础配置") +@TableName("") +public class SyncPropertyEntity extends TenantEntity implements Serializable { + + @ApiModelProperty("配置编号") + private String code; + + @ApiModelProperty("数据源") + private String datasource; + + @ApiModelProperty("数据源名称") + private String datasourceName; + + @ApiModelProperty("数据库表名") + private String tableName; + + @ApiModelProperty("向量数据库表名,由小写字母以及_组成") + private String vectorTableName; + + @ApiModelProperty("表描述") + private String tableDesc; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TableInfoEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TableInfoEntity.java new file mode 100644 index 0000000..f273620 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TableInfoEntity.java @@ -0,0 +1,68 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/04 14:59 + */ +@Data +@TableName("mysql_table_info") +@EqualsAndHashCode +@ApiModel(value = "数据库信息",description = "数据库信息") +public class TableInfoEntity extends TenantEntity implements Serializable { + + @ApiModelProperty(value = "数据源",required = true) + @NotBlank + @QueryField(condition = SqlCondition.EQUAL) + @TableField("data_source_id") + private String datasourceId; + + @ApiModelProperty(value = "数据源名称",required = true) + @NotBlank + @QueryField(condition = SqlCondition.LIKE) + @TableField("data_source_name") + private String datasourceName; + + @ApiModelProperty(value = "数据库",required = true) + @NotBlank + @QueryField(condition = SqlCondition.EQUAL) + private String databaseName; + + @ApiModelProperty(value = "数据库表名",required = true) + @NotBlank + @QueryField(condition = SqlCondition.EQUAL) + private String tableName; + + @ApiModelProperty(value = "数据库类型,1:Mysql",required = true) + @NotBlank + private String dbType; + + @ApiModelProperty(value = "数据库表描述信息",required = true) + @NotBlank + @QueryField(condition = SqlCondition.LIKE) + private String tableDesc; + + @ApiModelProperty(value = "数据库表列信息",required = true) + @NotBlank + private String propDesc; + + @ApiModelProperty("举例") + private String example; + + @ApiModelProperty("表注表信息中的字段对应的向量库的表字段查询") + @QueryField(condition = SqlCondition.LIKE) + private String filterJson; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TablePropertyEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TablePropertyEntity.java new file mode 100644 index 0000000..0705366 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TablePropertyEntity.java @@ -0,0 +1,49 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/05 14:49 + */ +@ApiModel("数据库表配置") +@TableName("HZIMS_TABLE_PROPERTY") +@Data +public class TablePropertyEntity extends TenantEntity implements Serializable { + + @ApiModelProperty("数据源Id") + @QueryField(condition = SqlCondition.EQUAL) + @NotNull + private Long datasourceId; + + @ApiModelProperty("数据源名称") + @QueryField(condition = SqlCondition.LIKE) + @NotNull + private String datasourceName; + + @ApiModelProperty("数据库名") + @QueryField(condition = SqlCondition.LIKE) + @NotBlank + private String databaseName; + + @ApiModelProperty("数据表名") + @QueryField(condition = SqlCondition.LIKE) + @NotBlank + private String tableName; + + @ApiModelProperty("鉴权类型") + @QueryField(condition = SqlCondition.EQUAL) + @NotBlank + private String authType; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java new file mode 100644 index 0000000..6469053 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamEntity.java @@ -0,0 +1,53 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + +/** + * @Author: ypj + * @Date: 2024/9/2 14:54 + */ +@ApiModel("向量参数配置") +@TableName("HZIMS_VECTOR_PARAM") +@Data +public class VectorParamEntity extends TenantEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("参数名称") + @TableField("NAME") + @QueryField(condition = SqlCondition.LIKE) + private String name; + + @ApiModelProperty("url") + @TableField("URL") + @QueryField(condition = SqlCondition.LIKE) + private String url; + + @ApiModelProperty("项目前缀") + @TableField("PROJECT_PREFIX") + @QueryField(condition = SqlCondition.LIKE) + private String projectPrefix; + + @ApiModelProperty("数据库表名") + @TableField("TABLE_NAME") + @QueryField(condition = SqlCondition.LIKE) + private String tableName; + + @ApiModelProperty("向量键值对,json格式") + @TableField("ATTRIBUTE_MAP") + @QueryField(condition = SqlCondition.LIKE) + private String attributeMap; + + @ApiModelProperty("备注") + @TableField("REMARK") + @QueryField(condition = SqlCondition.LIKE) + private String remark; +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/AgentLogMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/AgentLogMapper.java new file mode 100644 index 0000000..7a1ede1 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/AgentLogMapper.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.AgentLogEntity; + +/** + * @Author: ypj + * @Date: 2024/9/9 11:07 + */ +public interface AgentLogMapper extends BaseMapper { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/ControlMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/ControlMapper.java new file mode 100644 index 0000000..29fa385 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/ControlMapper.java @@ -0,0 +1,12 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.hnac.gglm.bigmodel.maintenance.entity.ControlEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @Author: huangxing + * @Date: 2024/08/19 18:42 + */ +public interface ControlMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DatasourceMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DatasourceMapper.java new file mode 100644 index 0000000..bb8a263 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DatasourceMapper.java @@ -0,0 +1,12 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.DatasourceEntity; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:05 + */ +public interface DatasourceMapper extends BaseMapper { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileInfoMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileInfoMapper.java new file mode 100644 index 0000000..a9247b9 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileInfoMapper.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; + +/** + * @Author: ypj + * @Date: 2024/9/10 16:41 + */ +public interface KnowledgeFileInfoMapper extends BaseMapper { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/TableInfoMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/TableInfoMapper.java new file mode 100644 index 0000000..043aab1 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/TableInfoMapper.java @@ -0,0 +1,12 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.TableInfoEntity; + +/** + * @Author: huangxing + * @Date: 2024/07/04 15:25 + */ +public interface TableInfoMapper extends BaseMapper { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/TablePropertyMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/TablePropertyMapper.java new file mode 100644 index 0000000..3f89b44 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/TablePropertyMapper.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.TablePropertyEntity; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:12 + */ +public interface TablePropertyMapper extends BaseMapper { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamMapper.java new file mode 100644 index 0000000..6dc3e63 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamMapper.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; + +/** + * @Author: ypj + * @Date: 2024/09/02 15:12 + */ +public interface VectorParamMapper extends BaseMapper { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/AgentLogService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/AgentLogService.java new file mode 100644 index 0000000..3f9a059 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/AgentLogService.java @@ -0,0 +1,19 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.gglm.bigmodel.maintenance.entity.AgentLogEntity; +import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; +import com.hnac.gglm.bigmodel.maintenance.vo.LabelRequest; + +/** + * @Author: ypj + * @Date: 2024/9/9 11:08 + */ +public interface AgentLogService extends IService { + Boolean BatchLabel(IdsRequest ids); + + Boolean label(LabelRequest req); + + IPage listPage(IPage page, AgentLogEntity req); +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/ControlService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/ControlService.java new file mode 100644 index 0000000..eda66a0 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/ControlService.java @@ -0,0 +1,21 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.gglm.bigmodel.maintenance.mapper.ControlMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.ControlEntity; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/08/19 18:48 + */ +@Service +@DS("hznlm") +@AllArgsConstructor +@Slf4j +public class ControlService extends ServiceImpl { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataSourceService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataSourceService.java new file mode 100644 index 0000000..410ff8d --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataSourceService.java @@ -0,0 +1,19 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.hnac.gglm.bigmodel.maintenance.mapper.DatasourceMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.DatasourceEntity; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:06 + */ +@Service("dataSourceMaintenanceService") +@Slf4j +@AllArgsConstructor +public class DataSourceService extends BaseServiceImpl { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java new file mode 100644 index 0000000..ec2c49f --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; + +/** + * @Author: ypj + * @Date: 2024/9/10 16:42 + */ +public interface KnowledgeFileInfoService extends IService { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TableColumnService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TableColumnService.java new file mode 100644 index 0000000..a5ef2a2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TableColumnService.java @@ -0,0 +1,37 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.hnac.gglm.bigmodel.business.service.DataSourceService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/04 09:29 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class TableColumnService { + + private final DataSourceService dataSourceService; + + public List> getDatabase(String datasource) { + String sql = "select distinct UPPER(`table_schema`) as tableName from `information_schema`.`tables` where `table_schema` <> 'information_schema';"; + return dataSourceService.queryListOnSpecificDataSource(sql,datasource); + } + + public List> getTables(String datasource,String database) { + String sql = "select distinct UPPER(`table_name`) as tableName from `information_schema`.`tables` where `table_schema` = '" + database + "';"; + return dataSourceService.queryListOnSpecificDataSource(sql,datasource); + } + + public List> getColumns(String datasource,String database,String tableName) { + String sql = "select distinct UPPER(`column_name`) as columnName,UPPER(`column_comment`) as columnComment from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; + return dataSourceService.queryListOnSpecificDataSource(sql,datasource); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TableInfoService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TableInfoService.java new file mode 100644 index 0000000..435df73 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TableInfoService.java @@ -0,0 +1,21 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.gglm.bigmodel.maintenance.mapper.TableInfoMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.TableInfoEntity; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/07/04 15:23 + */ +@Service +@AllArgsConstructor +@Slf4j +@DS("hznlm") +public class TableInfoService extends BaseServiceImpl { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TablePropertyService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TablePropertyService.java new file mode 100644 index 0000000..180b49e --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/TablePropertyService.java @@ -0,0 +1,19 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.hnac.gglm.bigmodel.maintenance.mapper.TablePropertyMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.TablePropertyEntity; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:11 + */ +@Service +@AllArgsConstructor +@Slf4j +public class TablePropertyService extends BaseServiceImpl { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamService.java new file mode 100644 index 0000000..8553964 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamService.java @@ -0,0 +1,22 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.gglm.bigmodel.maintenance.vo.VectorUrlResponse; +import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; + +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/09/02 15:11 + */ + +public interface VectorParamService extends IService { + String getAuthorization(); + + VectorUrlResponse getUrlResponse(String url, String bladeToken, String hzinfoToken); + + List getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken); + + Boolean synchronization(List id ,String bladeToken, String hzinfoToken); +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java new file mode 100644 index 0000000..7af5942 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java @@ -0,0 +1,74 @@ +package com.hnac.gglm.bigmodel.maintenance.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.gglm.bigmodel.maintenance.mapper.AgentLogMapper; +import com.hnac.gglm.bigmodel.maintenance.service.AgentLogService; +import com.hnac.gglm.bigmodel.maintenance.entity.AgentLogEntity; +import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; +import com.hnac.gglm.bigmodel.maintenance.vo.LabelRequest; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +import java.util.Date; + +/** + * @Author: ypj + * @Date: 2024/9/9 11:10 + */ +@Service +@Slf4j +@AllArgsConstructor +@DS("hznlm") +public class AgentLogServiceImpl extends ServiceImpl implements AgentLogService { + + @Override + public Boolean BatchLabel(IdsRequest ids) { + Date now = new Date(); + return this.update(Wrappers.lambdaUpdate() + .set(AgentLogEntity::getLabelStatus, 1) + .set(AgentLogEntity::getLabelResult, 1) + .set(AgentLogEntity::getLabelOperator, AuthUtil.getUserName()) + .set(AgentLogEntity::getLabelTime, now) + .set(AgentLogEntity::getUpdateTime, now) + .in(AgentLogEntity::getId, ids.getIds())); + } + + @Override + public Boolean label(LabelRequest req) { + AgentLogEntity entity = this.getById(req.getId()); + if (entity != null) { + int labelResult = StringUtil.isBlank(req.getLabelContent()) || req.getLabelContent().equals(entity.getA()) ? 1 : 0; + Date now = new Date(); + return this.update(Wrappers.lambdaUpdate() + .set(AgentLogEntity::getLabelStatus, 1) + .set(AgentLogEntity::getLabelResult, labelResult) + .set(StringUtil.isNotBlank(req.getLabelContent()), AgentLogEntity::getLabelContent, req.getLabelContent()) + .set(AgentLogEntity::getLabelOperator, AuthUtil.getUserName()) + .set(AgentLogEntity::getLabelTime, now) + .set(AgentLogEntity::getUpdateTime, now) + .eq(AgentLogEntity::getId, req.getId())); + } + return false; + } + + @Override + public IPage listPage(IPage page, AgentLogEntity req) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() + .eq(ObjectUtil.isNotEmpty(req.getId()), AgentLogEntity::getId, req.getId()) + .eq(ObjectUtil.isNotEmpty(req.getChatId()), AgentLogEntity::getChatId, req.getChatId()) + .eq(ObjectUtil.isNotEmpty(req.getQId()), AgentLogEntity::getQId, req.getQId()) + .eq(ObjectUtil.isNotEmpty(req.getModelName()), AgentLogEntity::getModelName, req.getModelName()) + .orderByDesc(AgentLogEntity::getCreateTime) + .orderByAsc(AgentLogEntity::getChatId); + return this.page(page, queryWrapper); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java new file mode 100644 index 0000000..fb41f61 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.gglm.bigmodel.maintenance.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; +import com.hnac.gglm.bigmodel.maintenance.mapper.KnowledgeFileInfoMapper; +import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileInfoService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @Author: ypj + * @Date: 2024/9/10 16:43 + */ +@Service +@Slf4j +@AllArgsConstructor +public class KnowledgeFileInfoServiceImpl extends ServiceImpl implements KnowledgeFileInfoService { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java new file mode 100644 index 0000000..fbaf043 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java @@ -0,0 +1,143 @@ +package com.hnac.gglm.bigmodel.maintenance.service.impl; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.hnac.gglm.bigmodel.database.service.WeaviateService; +import com.hnac.gglm.bigmodel.maintenance.vo.VectorUrlResponse; +import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; +import com.hnac.gglm.bigmodel.maintenance.mapper.VectorParamMapper; +import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletResponse; +import java.nio.charset.StandardCharsets; +import java.util.*; + +/** + * @Author: ypj + * @Date: 2024/9/2 16:14 + */ +@Service +@Slf4j +@AllArgsConstructor +public class VectorParamServiceImpl extends ServiceImpl implements VectorParamService { + + private static final String CLIENT_SIGN = "vector_param"; + + private final WeaviateService weaviateService; + + @Override + public String getAuthorization() { + return "Basic " + Base64.getEncoder().encodeToString(CLIENT_SIGN.getBytes(StandardCharsets.UTF_8)); + } + + @Override + public VectorUrlResponse getUrlResponse(String url, String bladeToken, String hzinfoToken) { + HttpResponse response = HttpRequest.get(url) + .header("Authorization", getAuthorization()) + .header("Blade-Auth", bladeToken) + .header("Hzinfo-Auth", hzinfoToken).execute(); + if (response.getStatus() == HttpServletResponse.SC_OK) { + String body = response.body(); + log.info("vector url response url:{}, response:{}", url, body); + try { + ObjectMapper mapper = new ObjectMapper(); + JsonNode rootNode = mapper.readTree(body); + if (rootNode.isArray()) { + return getUrlResponseByArray(rootNode); + } + JsonNode dataNode = rootNode.findValue("data"); + if (dataNode != null && dataNode.isArray()) { + return getUrlResponseByArray(dataNode); + } + if (dataNode != null) { + return getUrlResponseByObject(dataNode); + } + if (rootNode != null) { + return getUrlResponseByObject(rootNode); + } + } catch (JsonProcessingException e) { + log.error("getUrlResponse error", e); + } + } + return null; + } + + private VectorUrlResponse getUrlResponseByArray(JsonNode rootNode) throws JsonProcessingException { + VectorUrlResponse result = new VectorUrlResponse(); + result.setOriginalData(JSONArray.parseArray(rootNode.toPrettyString()).toJavaList(JSONObject.class)); + JsonNode item = rootNode.get(0); + if (item != null) { + List keyList = new ArrayList<>(); + Iterator iterator = item.fieldNames(); + while (iterator.hasNext()) { + keyList.add(iterator.next()); + } + result.setKeyList(keyList); + } + return result; + } + + private VectorUrlResponse getUrlResponseByObject(JsonNode rootNode) throws JsonProcessingException { + VectorUrlResponse result = new VectorUrlResponse(); + List originalData = new ArrayList<>(); + originalData.add(JSON.parseObject(rootNode.toPrettyString())); + result.setOriginalData(originalData); + List keyList = new ArrayList<>(); + Iterator iterator = rootNode.fieldNames(); + while (iterator.hasNext()) { + keyList.add(iterator.next()); + } + result.setKeyList(keyList); + return result; + } + + @Override + public List getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken) { + VectorUrlResponse response = getUrlResponse(url, bladeToken, hzinfoToken); + return response.getKeyList(); + } + + @Override + public Boolean synchronization(List ids, String bladeToken, String hzinfoToken) { + if (null == ids && ids.isEmpty()) { + return false; + } + for (Long id : ids) { + VectorParamEntity entity = getById(id); + if (null == entity) { + return false; + } + VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken); + if (response != null) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode rootNode = null; + try { + rootNode = mapper.readTree(entity.getAttributeMap()); + } catch (JsonProcessingException e) { + log.error("getUrlResponseKeyList error", e); + } + Map attrMap = new HashMap<>(); + Iterator iterator = rootNode.fieldNames(); + while (iterator.hasNext()) { + String key = iterator.next(); + attrMap.put(key, rootNode.findValue(key).textValue()); + } + weaviateService.saveBatch(response.getOriginalData(), entity.getTableName(), attrMap); + this.update(Wrappers.lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date())); + } + } + return true; + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/IdsRequest.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/IdsRequest.java new file mode 100644 index 0000000..50ddc43 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/IdsRequest.java @@ -0,0 +1,19 @@ +package com.hnac.gglm.bigmodel.maintenance.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/9/7 11:04 + */ +@Data +@ApiModel("批量操作请求") +public class IdsRequest { + + @ApiModelProperty("主键ID,按逗号分隔") + private List ids; +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/LabelRequest.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/LabelRequest.java new file mode 100644 index 0000000..b0ce014 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/LabelRequest.java @@ -0,0 +1,19 @@ +package com.hnac.gglm.bigmodel.maintenance.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: ypj + * @Date: 2024/9/10 14:04 + */ +@Data +@ApiModel("标注") +public class LabelRequest { + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样") + private String labelContent; +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/VectorUrlResponse.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/VectorUrlResponse.java new file mode 100644 index 0000000..7539adb --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/VectorUrlResponse.java @@ -0,0 +1,16 @@ +package com.hnac.gglm.bigmodel.maintenance.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/9/5 21:12 + */ +@Data +public class VectorUrlResponse { + private List keyList; + + private List originalData; +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/manager/SessionRedisManager.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/manager/SessionRedisManager.java new file mode 100644 index 0000000..0007890 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/manager/SessionRedisManager.java @@ -0,0 +1,32 @@ +package com.hnac.gglm.bigmodel.manager; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.List; + +import static com.hnac.gglm.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; + +/** + * @Author: huangxing + * @Date: 2024/06/21 18:23 + */ +@Component +public class SessionRedisManager { + + @Autowired + private RedisTemplate redisTemplate; + + public void addSessionId(String sessionId) { + redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); + } + + public void removeSessionId(String sessionId) { + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId); + } + + public List getSessionIds() { + return redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/dto/MessageDTO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/dto/MessageDTO.java new file mode 100644 index 0000000..02b38b1 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/dto/MessageDTO.java @@ -0,0 +1,101 @@ +package com.hnac.gglm.bigmodel.question.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import com.hnac.gglm.bigmodel.interactive.vo.SessionContentVO; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/10 10:22 + * @Describe: 接收前端发送消息 + */ +@Data +@EqualsAndHashCode +public class MessageDTO implements Serializable { + + /** + * 消息类型 0-心跳消息 1-问题 + */ + private String type; + + /** + * 前端提出问题 + */ + private String context; + + /** + * 前端传参附带参数 + */ + private SessionContentVO content; + + /** + * 是否发起特殊问答 + */ + private Boolean isSpecial; + + /** + * 发起问题用户ID + */ + private String userId; + + /** + * 知识库 + */ + private String knowledge; + + /** + * 会话ID + */ + private String chatId; + + /** + * 大模型函数 + */ + private String func; + + /** + * 特殊问题参数 + */ + private Map extra; + + /** + * 是否允许大模型查询数据,默认为1 + */ + @JSONField(name = "enable_record") + private int enableRecord = 1; + + /** + * 是否允许大模型发送指令,默认为1 + */ + @JSONField(name = "enable_yk") + private int enableControl = 1; + + /** + * 是否允许大模型打开视频,默认为1 + */ + @JSONField(name = "enable_video") + private int enableVideo = 1; + + /** + * 是否允许大模型打开画面,默认为1 + */ + @JSONField(name = "enable_canvas") + private int enableCanvas = 1; + + /** + * 是否允许大模型诊断故障,默认为1 + */ + @JSONField(name = "enable_fault") + private int enableFault = 1; + + /** + * 大模型默认的意图理解方式,可以为"default","yk"... + */ + @JSONField(name = "default") + private String defaultMode; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/dto/QuestionDTO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/dto/QuestionDTO.java new file mode 100644 index 0000000..f460183 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/dto/QuestionDTO.java @@ -0,0 +1,76 @@ +package com.hnac.gglm.bigmodel.question.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/10 10:27 + */ +@Data +@EqualsAndHashCode +public class QuestionDTO implements Serializable { + + /** + * 随机ID,同一个用户的对话使用统一的ID + */ + @JSONField(name = "chat_id") + private String chatId; + + /** + * 用户ID,同一个随机ID只能对应一个用户ID + */ + @JSONField(name = "user_id") + private String userId; + + /** + * 用户的问题 + */ + private String query; + + /** + * 特殊提问内容 + */ + private Map extra; + + /** + * 是否允许大模型查询数据,默认为 1 + */ + @JSONField(name = "enable_record") + private int enableRecord = 1; + + /** + * 是否允许大模型发送指令,默认为 1 + */ + @JSONField(name = "enable_yk") + private int enableControl = 1; + + /** + * 是否允许大模型打开视频,默认为 1 + */ + @JSONField(name = "enable_video") + private int enableVideo = 1; + + /** + * 是否允许大模型打开画面,默认为 1 + */ + @JSONField(name = "enable_canvas") + private int enableCanvas = 1; + + /** + * 是否允许大模型诊断故障,默认为 1 + */ + @JSONField(name = "enable_fault") + private int enableFault = 1; + + /** + * 大模型默认的意图理解方式,可以为"default","yk"... + */ + @JSONField(name = "default") + private String defaultMode; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/service/QuestionHandlerService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/service/QuestionHandlerService.java new file mode 100644 index 0000000..c8d67d9 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/question/service/QuestionHandlerService.java @@ -0,0 +1,133 @@ +package com.hnac.gglm.bigmodel.question.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.gglm.bigmodel.interactive.factory.ResolveFactory; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.gglm.bigmodel.interactive.service.IResolveService; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO; +import com.hnac.gglm.bigmodel.interactive.vo.ScadaSelectionVO; +import com.hnac.gglm.bigmodel.interactive.vo.VideoSelectionVO; +import com.hnac.gglm.bigmodel.question.dto.MessageDTO; +import com.hnac.gglm.bigmodel.question.dto.QuestionDTO; +import com.hnac.gglm.bigmodel.websocket.service.InteractiveWsService; +import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; +import org.springframework.web.socket.TextMessage; + +/** + * @Author: huangxing + * @Date: 2024/07/10 11:03 + */ +@Service +@AllArgsConstructor +@Slf4j +public class QuestionHandlerService { + + private final IHznlmInvokeService hznlmInvokeService; + + /** + * 处理用户发起问题 + * @param messageDTO 接收前端消息内容体 + */ + public void handleMessage(MessageDTO messageDTO) { + // 将message转换为question + QuestionDTO question = BeanUtil.copy(messageDTO,QuestionDTO.class); + question.setQuery(messageDTO.getContext()); + // 普通问答 + if(Func.isEmpty(messageDTO.getIsSpecial()) || !messageDTO.getIsSpecial()) { + if (StringUtil.isNotBlank(messageDTO.getKnowledge())) { + if("analyse".equals(messageDTO.getKnowledge())) { + // 如果是数据分析问答 + hznlmInvokeService.analyseAsk(question); + } else{ + hznlmInvokeService.knowledgeAsk(question); + } + } else { + hznlmInvokeService.ask(question); + } + } else { + FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode((String) messageDTO.getExtra().get("func")); + switch (funcEnum) { + case CHOOSE_STATION: + case CHOOSE_YC: + case CHOOSE_FAULT: + case CHOOSE_YK: + hznlmInvokeService.specialAsk(question); + break; + case CHOOSE_VIDEO: + this.handleVideoChoose(messageDTO); + break; + case CHOOSE_CANVAS: + this.handleScadaChoose(messageDTO); + break; + default: + break; + } + } + } + + private void handleVideoChoose(MessageDTO messageDTO) { + InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); + try { + VideoSelectionVO selection = JSONObject.parseObject(JSON.toJSONString(messageDTO.getExtra().get("data")),VideoSelectionVO.class); + IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); + String videoId = selection.getItemId(); + ExtraVO videoExtras = resolveService.resolve(videoId); + AnswerVO answerVO = new AnswerVO(); + answerVO.setChatId(messageDTO.getChatId()); + answerVO.setQuery(selection.getItemName()); + answerVO.setRunning(0); + answerVO.setStatus(0); + answerVO.setAnswer("已成功打开"+selection.getItemName()+"视频"); + answerVO.setVoiceAnswer(new String[]{"已成功打开"+selection.getItemName()+"视频"}); + answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)}); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(messageDTO.getChatId(),textMessage); + } + catch (Exception e) { + log.error("an error occurred!",e); + AnswerVO answerVO = new AnswerVO(); + answerVO.setRunning(0); + answerVO.setStatus(-2); + answerVO.setAnswer("视频解析失败!"); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(messageDTO.getChatId(),textMessage); + } + } + + private void handleScadaChoose(MessageDTO messageDTO) { + InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); + try { + ScadaSelectionVO selection = JSONObject.parseObject(JSON.toJSONString(messageDTO.getExtra().get("data")),ScadaSelectionVO.class);; + IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); + ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); + AnswerVO answerVO = new AnswerVO(); + answerVO.setChatId(messageDTO.getChatId()); + answerVO.setRunning(0); + answerVO.setStatus(0); + answerVO.setQuery(selection.getItemName()); + answerVO.setVoiceAnswer(new String[]{"已成功打开"+selection.getItemName()+"实时画面"}); + answerVO.setAnswer("已成功打开"+selection.getItemName()+"实时画面"); + answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)}); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(messageDTO.getChatId(),textMessage); + } + catch (Exception e) { + AnswerVO answerVO = new AnswerVO(); + answerVO.setRunning(0); + answerVO.setStatus(-2); + answerVO.setAnswer("实时画面解析失败!"); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(messageDTO.getChatId(),textMessage); + } + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/FrontEndInteractiveSchedule.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/FrontEndInteractiveSchedule.java new file mode 100644 index 0000000..7747c10 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/FrontEndInteractiveSchedule.java @@ -0,0 +1,79 @@ +package com.hnac.gglm.bigmodel.schedule; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.interactive.factory.AnswerResolveFactory; +import com.hnac.gglm.bigmodel.interactive.service.IAnswerResolveService; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.manager.SessionRedisManager; +import com.hnac.gglm.bigmodel.websocket.service.InteractiveWsService; +import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import com.xxl.job.core.log.XxlJobLogger; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Component; +import org.springframework.web.socket.TextMessage; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ThreadPoolExecutor; + +/** + * @Author: huangxing + * @Date: 2024/06/24 09:53 + */ +@Component +@AllArgsConstructor +@Slf4j +public class FrontEndInteractiveSchedule { + + private final SessionRedisManager sessionRedisManager; + private final InteractiveWsService wsService; + private final ThreadPoolExecutor getAnswerPoolExecutor; + private final IHznlmInvokeService hznlmInvokeService; + + @XxlJob(XxlJobHandlerConstant.GET_INTERACTIVE_RESULT) + public ReturnT getInteractiveResult(String params) { + List sessionIds = sessionRedisManager.getSessionIds(); + if(CollectionUtil.isEmpty(sessionIds)){ + XxlJobLogger.log("问题都已经回答完毕!"); + return ReturnT.SUCCESS; + } + List answerList = hznlmInvokeService.getAnswerBySessionIds(String.join(",", sessionIds)); + answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> this.formatAnswer(answerVO), getAnswerPoolExecutor)); + return ReturnT.SUCCESS; + } + + private void formatAnswer(AnswerVO answerVO) { + // 如果已经获取到答案 则删除缓存 + if(answerVO.getRunning() == 0) { + log.info("获取大模型解析答案:{}", JSON.toJSONString(answerVO)); + sessionRedisManager.removeSessionId(answerVO.getChatId()); + } + Object[] extras = answerVO.getExtras(); + // 格式化 extra + if(Func.isNotEmpty(extras)) { + try { + Object[] resolveExtras = Arrays.stream(extras).map(extra -> { + IAnswerResolveService answerResolveService = AnswerResolveFactory.getResolveService(extra); + if (Func.isNotEmpty(answerResolveService)) { + JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra)); + return answerResolveService.getExtra(extraObject); + } + return extra; + }).map(JSON::toJSONString).toArray(); + answerVO.setExtras(resolveExtras); + } catch(Exception e) { + log.error("An error occurred",e); + AnswerVO.error(answerVO.getChatId(), answerVO.getUserId(), answerVO.getQuery()); + } + } + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + wsService.sendMessage(answerVO.getChatId(),message); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/RunReportAnalyseSchedule.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/RunReportAnalyseSchedule.java new file mode 100644 index 0000000..8886958 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/RunReportAnalyseSchedule.java @@ -0,0 +1,60 @@ +package com.hnac.gglm.bigmodel.schedule; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.api.constants.MqttTopicConstants; +import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; +import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.Func; +import org.springblade.mqtt.producer.IMqttSender; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/15 08:57 + */ +@Component +@AllArgsConstructor +@Slf4j +public class RunReportAnalyseSchedule { + + private final RedisTemplate redisTemplate; + private final IHznlmInvokeService invokeService; + private final IMqttSender mqttSender; + + @XxlJob(XxlJobHandlerConstant.GET_RUN_REPORT_RESULT) + public ReturnT getRunReportResult(String params) { + List analyses = (List) redisTemplate.opsForList().range(RedisKeyConstants.RUN_REPORT_SESSION_ID,0,-1); + if(Func.isEmpty(analyses)) { + return ReturnT.SUCCESS; + } + analyses.stream().forEach(analyse -> { + JSONObject analyseObject = JSONObject.parseObject(analyse); + String sessionId = analyseObject.getString("sessionId"); + List answerVOS = invokeService.getAnswerBySessionIds(sessionId); + if(Func.isNotEmpty(answerVOS)) { + AnswerVO answerVO = answerVOS.get(0); + if(answerVO.getRunning() == 0) { + log.info("运行月报分析结果为:" + JSON.toJSONString(answerVO)); + JSONObject message = new JSONObject(); + message.put("stationCode", analyseObject.getString("stationCode")); + message.put("month", analyseObject.getString("month")); + message.put("result", JSONObject.parseObject(JSON.toJSONString(answerVO.getExtras()[0])).getString("data")); + // 获取到问答答案,存入消息中 + mqttSender.sendToMqtt(MqttTopicConstants.RUN_REPORT_ANALYSE_RESULT,JSON.toJSONString(message)); + redisTemplate.opsForList().remove(RedisKeyConstants.RUN_REPORT_SESSION_ID,1,analyse); + } + } + }); + return ReturnT.SUCCESS; + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/XxlJobHandlerConstant.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/XxlJobHandlerConstant.java new file mode 100644 index 0000000..9937808 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/XxlJobHandlerConstant.java @@ -0,0 +1,28 @@ +package com.hnac.gglm.bigmodel.schedule; + +import com.hnac.hzims.common.constant.CommonConstant; + +/** + * @Author: huangxing + * @Date: 2024/04/28 16:19 + */ +public interface XxlJobHandlerConstant { + + /**获取问答结果**/ + String GET_INTERACTIVE_RESULT = "getInteractiveResult"; + + /**获取运行月报分析结果**/ + String GET_RUN_REPORT_RESULT = "getRunReportResult"; + + String SYNCHRONOUS_FAULT_INSTRUCT = "synchronousFaultInstruct"; + + /**同步视频指令**/ + String SYNCHRONOUS_VIDEO_INSTRUCT = "synchronousVideoInstruct"; + + String SYNCHRONOUS_SCADA_INSTRUCT = "synchronousScadaInstruct"; + + String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; + + String HZIMS_BIGMODEL_ASK_KEY = CommonConstant.TENANT_ID + ":hzims:bigmodel:ask:key"; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java new file mode 100644 index 0000000..58f0652 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java @@ -0,0 +1,68 @@ +package com.hnac.gglm.bigmodel.utils; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.ResultCode; +import org.springframework.util.Assert; + +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 17:12 + */ +@Slf4j +public class RequestClientUtil { + + + /** + * 无返回结果远程调用http接口 + * @param url 接口url + * @param body 传参body + */ + public static void postCall(String url, String body) { + log.info("开始远程调用{}接口",url); + HttpResponse response = HttpRequest.post(url).body(body).execute(); + log.info("远程调用{}接口结束",url); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + throw new HzServiceException(ResultCode.FAILURE, "远程调用接口" + url + "失败!"); + }); + } + + /** + * 无返回结果远程调用http接口 + * @param url 接口url + * @param body 传参body + */ + public static void postCall(String url, Map body) { + log.info("开始远程调用{}接口",url); + HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + log.info("远程调用{}接口结束",url); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + throw new HzServiceException(ResultCode.FAILURE, "远程调用接口" + url + "失败!"); + }); + } + + /** + * 远程调用http接口 + * @param url 接口url + * @param body 传参 + * @param typeRef 结果解析对象 + * @return 结果 + * @param 结果解析对象类型 + */ + public static T postCall(String url, Map body, TypeReference typeRef) { + HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + throw new HzServiceException(ResultCode.FAILURE, "远程调用大模型接口" + url + "失败!"); + }); + return JSONObject.parseObject(response.body(), typeRef); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/config/WebSocketConfig.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/config/WebSocketConfig.java new file mode 100644 index 0000000..2868281 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/config/WebSocketConfig.java @@ -0,0 +1,28 @@ +package com.hnac.gglm.bigmodel.websocket.config; + +import com.hnac.gglm.bigmodel.websocket.handler.InteractiveHandler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.WebSocketHandler; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.config.annotation.WebSocketConfigurer; +import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; + +/** + * @Author: huangxing + * @Date: 2024/04/28 13:39 + */ +@Configuration +@EnableWebSocket +public class WebSocketConfig implements WebSocketConfigurer { + + @Override + public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { + registry.addHandler(interactiveHandler(), "/websocket/interactive/{sessionId}").setAllowedOrigins("*"); + } + @Bean + public WebSocketHandler interactiveHandler() { + return new InteractiveHandler(); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/constants/RedisKeyConstants.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/constants/RedisKeyConstants.java new file mode 100644 index 0000000..86cc594 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/constants/RedisKeyConstants.java @@ -0,0 +1,15 @@ +package com.hnac.gglm.bigmodel.websocket.constants; + +import com.hnac.hzims.common.constant.CommonConstant; + +/** + * @Author: huangxing + * @Date: 2024/05/20 19:11 + */ +public interface RedisKeyConstants { + + String SESSION_CONTENT_KEY = CommonConstant.TENANT_ID + ":hzims:bigModel:session:content"; + + String RUN_REPORT_SESSION_ID = CommonConstant.TENANT_ID + ":hzims:bigModel:session:report"; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/handler/InteractiveHandler.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/handler/InteractiveHandler.java new file mode 100644 index 0000000..d89445b --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/handler/InteractiveHandler.java @@ -0,0 +1,78 @@ +package com.hnac.gglm.bigmodel.websocket.handler; + +import com.alibaba.fastjson.JSONObject; +import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants; +import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import com.hnac.gglm.bigmodel.interactive.vo.*; +import com.hnac.gglm.bigmodel.question.dto.MessageDTO; +import com.hnac.gglm.bigmodel.question.service.QuestionHandlerService; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; +import org.springframework.web.socket.CloseStatus; +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; +import org.springframework.web.socket.handler.TextWebSocketHandler; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +/** + * @Author: huangxing + * @Date: 2024/04/28 13:45 + */ +@Slf4j +@Component +public class InteractiveHandler extends TextWebSocketHandler { + + @Autowired + private RedisTemplate redisTemplate; + + @Override + public void afterConnectionEstablished(WebSocketSession session) { + String[] split = session.getUri().toString().split("/"); + String sessionId = split[split.length - 1]; + session.getAttributes().put("sessionId", sessionId); + InteractiveSessionManager.add(sessionId, session); + log.info("sessionId: " + session.getId()); + log.info("uri: " + session.getUri()); + log.info("session connection successful!"); + } + + @Override + public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { + String[] split = session.getUri().toString().split("/"); + String sessionId = split[split.length - 1]; + InteractiveSessionManager.removeAndClose(sessionId); + log.info("sessionId: " + session.getId()); + log.info("uri: " + session.getUri()); + log.info("session closed successful!"); + } + + @Override + protected void handleTextMessage(WebSocketSession session, TextMessage message) { + MessageDTO messageDTO = JSONObject.parseObject(message.getPayload(), MessageDTO.class); + if("0".equals(messageDTO.getType())) { + // 接收心跳消息,返回一条心跳消息 + try { + session.sendMessage(InteractiveSessionManager.getTextMessage("0","收到心跳消息")); + } catch (IOException e) { + throw new RuntimeException(e); + } + } else { + String chatId = InteractiveSessionManager.getEntryBySession(session).getKey(); + messageDTO.setChatId(chatId); + // 将发送参数存入redis + if(Func.isNotEmpty(messageDTO.getContent())) { + redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); + redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,chatId,messageDTO.getContent()); + } + QuestionHandlerService service = SpringUtil.getBean(QuestionHandlerService.class); + service.handleMessage(messageDTO); + } + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/server/InteractiveWsServer.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/server/InteractiveWsServer.java new file mode 100644 index 0000000..4b19e1f --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/server/InteractiveWsServer.java @@ -0,0 +1,9 @@ +package com.hnac.gglm.bigmodel.websocket.server; + +/** + * @Author: huangxing + * @Date: 2024/04/28 13:38 + */ +public class InteractiveWsServer { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/service/InteractiveWsService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/service/InteractiveWsService.java new file mode 100644 index 0000000..08d8a2b --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/service/InteractiveWsService.java @@ -0,0 +1,42 @@ +package com.hnac.gglm.bigmodel.websocket.service; + +import com.alibaba.fastjson.JSON; +import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; + +import java.io.IOException; + +/** + * @Author: huangxing + * @Date: 2024/04/28 14:35 + */ +@Service +@Slf4j +public class InteractiveWsService implements WebSocketService { + + @Override + public Boolean sendMessage(String sessionId, TextMessage message) { + if(InteractiveSessionManager.SESSION_POOL.containsKey(sessionId)) { + WebSocketSession session = InteractiveSessionManager.get(sessionId); + return this.sendMessage(session,message); + } + else { + log.error("未查询到sessionId,消息推送失败;"); + return false; + } + } + + @Override + public Boolean sendMessage(WebSocketSession session, TextMessage message) { + try { + session.sendMessage(message); + return true; + } catch (IOException e) { + log.error("消息推送失败;消息体为:" + JSON.toJSONString(message)); + return false; + } + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/service/WebSocketService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/service/WebSocketService.java new file mode 100644 index 0000000..4750ce2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/service/WebSocketService.java @@ -0,0 +1,16 @@ +package com.hnac.gglm.bigmodel.websocket.service; + +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; + +/** + * @Author: huangxing + * @Date: 2024/04/28 14:37 + */ +public interface WebSocketService { + + Boolean sendMessage(String signage, TextMessage message); + + Boolean sendMessage(WebSocketSession session, TextMessage message); + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/sessionManager/InteractiveSessionManager.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/sessionManager/InteractiveSessionManager.java new file mode 100644 index 0000000..13a57af --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/websocket/sessionManager/InteractiveSessionManager.java @@ -0,0 +1,94 @@ +package com.hnac.gglm.bigmodel.websocket.sessionManager; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/04/28 13:58 + */ +@Slf4j +public class InteractiveSessionManager { + /** ws会话池 **/ + public static ConcurrentHashMap SESSION_POOL = new ConcurrentHashMap<>(); + + /** + * 获取sessionIds + * @return sessionIds + */ + public static List getSessionIds() { + Set> sessionEntrySet = InteractiveSessionManager.SESSION_POOL.entrySet(); + return sessionEntrySet.stream().map(entry -> entry.getKey()).collect(Collectors.toList()); + } + + /** + * 根据Session获取Entry + * @param session websocketSession + * @return Entry + */ + public static Map.Entry getEntryBySession(WebSocketSession session) { + Set> sessionEntrySet = InteractiveSessionManager.SESSION_POOL.entrySet(); + Optional> sessionIdOptional = sessionEntrySet.stream().filter(sessionEntry -> session.equals(sessionEntry.getValue())).findFirst(); + if(!sessionIdOptional.isPresent()) { + log.error("当前Session Pool未查询到相关session,消息推送失败"); + throw new ServiceException("当前Session Pool未查询到相关session,消息推送失败"); + } + return sessionIdOptional.get(); + } + + /** + * 添加会话 + * @param sessionId 会话ID + * @param session 会话对象 + */ + public static void add(String sessionId, WebSocketSession session) { + if (SESSION_POOL.containsKey(sessionId)) { + InteractiveSessionManager.removeAndClose(sessionId); + } + SESSION_POOL.put(sessionId, session); + } + + /** + * 获取ws会话 + * @param sessionId 会话ID + */ + public static WebSocketSession get(String sessionId) { + return SESSION_POOL.get(sessionId); + } + + /** + * 移除ws会话并关闭会话 + * @param sessionId 会话ID + */ + public static void removeAndClose(String sessionId) { + WebSocketSession session = SESSION_POOL.get(sessionId); + if (session != null) { + try { + //关闭连接 + session.close(); + } catch (IOException ex) { + throw new RuntimeException("关闭ws会话失败!", ex); + } + } + SESSION_POOL.remove(sessionId); + } + + public static TextMessage getTextMessage(String type,String context) { + JSONObject message = new JSONObject(); + message.put("type",type); + message.put("context",context); + return new TextMessage(JSON.toJSONString(message)); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/controller/WhitelistController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/controller/WhitelistController.java new file mode 100644 index 0000000..15916bb --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/controller/WhitelistController.java @@ -0,0 +1,35 @@ +package com.hnac.gglm.bigmodel.whitelist.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.entity.WhitelistEntity; +import com.hnac.gglm.bigmodel.whitelist.service.WhitelistService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author ysj + */ +@RestController +@RequestMapping("/whitelist") +@Api(value = "白名单用户",tags = "白名单用户") +@AllArgsConstructor +public class WhitelistController { + + private final WhitelistService whitelistService; + + @PostMapping("/list") + @ApiOperation("查询列表") + @ApiOperationSupport(order = 1) + public R> list(@RequestBody WhitelistEntity entity) { + return R.data(whitelistService.list(Condition.getQueryWrapper(entity))); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/mapper/WhitelistMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/mapper/WhitelistMapper.java new file mode 100644 index 0000000..d687eb1 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/mapper/WhitelistMapper.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.whitelist.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.WhitelistEntity; + +/** + * @author ysj + */ +public interface WhitelistMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/service/WhitelistService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/service/WhitelistService.java new file mode 100644 index 0000000..239e105 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/service/WhitelistService.java @@ -0,0 +1,12 @@ +package com.hnac.gglm.bigmodel.whitelist.service; + +import com.hnac.gglm.bigmodel.maintenance.entity.WhitelistEntity; +import org.springblade.core.mp.base.BaseService; + + +/** + * @author ysj + */ +public interface WhitelistService extends BaseService { + +} \ No newline at end of file diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java new file mode 100644 index 0000000..71897a4 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java @@ -0,0 +1,18 @@ +package com.hnac.gglm.bigmodel.whitelist.service.impl; + +import com.hnac.gglm.bigmodel.whitelist.service.WhitelistService; +import com.hnac.gglm.bigmodel.maintenance.entity.WhitelistEntity; +import com.hnac.gglm.bigmodel.whitelist.mapper.WhitelistMapper; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/04/26 11:13 + */ +@Service +@Slf4j +public class WhitelistServiceImpl extends BaseServiceImpl implements WhitelistService { + +} \ No newline at end of file diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/config/ZhipuAiConfig.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/config/ZhipuAiConfig.java new file mode 100644 index 0000000..98ea889 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/config/ZhipuAiConfig.java @@ -0,0 +1,24 @@ +package com.hnac.gglm.bigmodel.zhipuai.config; + +import com.zhipu.oapi.ClientV4; +import lombok.AllArgsConstructor; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @Author: ypj + * @Date: 2024/8/9 17:01 + */ +@Configuration +@EnableConfigurationProperties(ZhipuAiConfigProperties.class) +@AllArgsConstructor +public class ZhipuAiConfig { + + private ZhipuAiConfigProperties properties; + + @Bean("clientV4") + public ClientV4 clientV4() { + return new ClientV4.Builder(properties.getApiSecret()).build(); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java new file mode 100644 index 0000000..49fc160 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java @@ -0,0 +1,18 @@ +package com.hnac.gglm.bigmodel.zhipuai.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * @Author: ypj + * @Date: 2024/8/8 14:03 + */ +@Data +@ConfigurationProperties(prefix = "bigmodel.zhipuai") +public class ZhipuAiConfigProperties { + + private String apiSecret; + + private String url; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/AnalysisModel.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/AnalysisModel.java new file mode 100644 index 0000000..0feab62 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/AnalysisModel.java @@ -0,0 +1,27 @@ +package com.hnac.gglm.bigmodel.zhipuai.constants; + +import lombok.Getter; + +/** + * @Author: ypj + * @Date: 2024/8/9 9:50 + */ +@Getter +public enum AnalysisModel implements BaseEnum { + + GLM_4("glm-4", "GLM-4模型"), + GLM_4V("glm-4v", "GLM-4V模型"), + COG_VIDEO_X("cogvideox", "CogVideoX模型"), + COG_VIEW("cogvideox", "CogVideoX模型"), + GLM_4_ALL_TOOLS("glm-4-alltool", "GLM-4-AllTools模型"); + + private final String code; + + private final String msg; + + AnalysisModel(String code, String msg) { + this.code = code; + this.msg = msg; + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/BaseEnum.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/BaseEnum.java new file mode 100644 index 0000000..9059ad5 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/BaseEnum.java @@ -0,0 +1,21 @@ +package com.hnac.gglm.bigmodel.zhipuai.constants; + +/** + * @Author: ypj + * @Date: 2024/8/8 15:42 + */ +public interface BaseEnum { + U getCode(); + + String getMsg(); + + static T getInstance(U code, Class clazz) { + T[] baseEnums = clazz.getEnumConstants(); + for (T baseEnum : baseEnums) { + if (baseEnum.getCode().equals(code)) { + return baseEnum; + } + } + return null; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ComparisonType.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ComparisonType.java new file mode 100644 index 0000000..0ff8d9d --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ComparisonType.java @@ -0,0 +1,22 @@ +package com.hnac.gglm.bigmodel.zhipuai.constants; + +import lombok.Getter; + +/** + * @Author: ypj + * @Date: 2024/8/14 9:23 + */ +@Getter +public enum ComparisonType implements BaseEnum { + EQUAL("equal", "相等"), + GREATER("greater","大于"), + LESS("less","小于"); + private final String code; + + private final String msg; + + ComparisonType(String code, String msg) { + this.code = code; + this.msg = msg; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ErrorCode.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ErrorCode.java new file mode 100644 index 0000000..ba10f1b --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ErrorCode.java @@ -0,0 +1,58 @@ +package com.hnac.gglm.bigmodel.zhipuai.constants; + +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.Getter; +import org.springblade.core.tool.api.IResultCode; +import org.springblade.core.tool.api.ResultCode; + +/** + * @Author: ypj + * @Date: 2024/8/22 11:17 + */ +@Getter +public enum ErrorCode implements IResultCode { + + GET_DATA_FAILURE(1888000001, "获取数据失败"), + ANALYSIS_FAILURE(1888000002, "分析失败"), + STRATEGY_NOT_FOUND(1888000003, "策略未找到"), + GET_FILE_CONTENT_FAILURE(1888000004, "获取文件内容失败"), + REQUEST_TEXT_IS_EMPTY(1888000005, "交互文字内容不能为空"), + EMPTY_ANALYSIS_TYPE(1888000006, "识别类型为空"), + UNKNOWN_ANALYSIS_TYPE(1888000007, "未知的识别类型"), + NO_COMPARATOR(1888000008, "未获取到对比对象"), + NO_COMPARISON_TYPE(1888000009, "未获取到对比类型"), + GET_RESULT_FAIL(1888000010, "获取结果失败"), + NO_ANSWER_FROM_PLATFORM(1888000011, "未从平台获取到答案"); + + private final int code; + private final String msg; + + ErrorCode(int code, String msg) { + this.code = code; + this.msg = msg; + } + + + @Override + public String getMessage() { + return this.msg; + } + + public HzServiceException throwException() { + return new HzServiceException(this); + } + + public static HzServiceException throwCommonException(String msg) { + return new HzServiceException(new IResultCode() { + @Override + public String getMessage() { + return msg; + } + + @Override + public int getCode() { + return ResultCode.FAILURE.getCode(); + } + }); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ResultDataType.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ResultDataType.java new file mode 100644 index 0000000..051c4e2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ResultDataType.java @@ -0,0 +1,41 @@ +package com.hnac.gglm.bigmodel.zhipuai.constants; + +import com.hnac.gglm.bigmodel.zhipuai.handler.result.data.BooleanParser; +import com.hnac.gglm.bigmodel.zhipuai.handler.result.data.IntegerParser; +import com.hnac.gglm.bigmodel.zhipuai.handler.result.data.ResultDataParser; +import com.hnac.gglm.bigmodel.zhipuai.handler.result.data.StringParser; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +/** + * @Author: ypj + * @Date: 2024/8/14 8:28 + */ +@Getter +@Slf4j +public enum ResultDataType implements BaseEnum { + STRING("String", "String类型", StringParser.class), + BOOLEAN("Boolean", "Boolean类型", BooleanParser.class), + INTEGER("Integer", "Integer类型", IntegerParser.class); + + private final String code; + + private final String msg; + + private final Class parser; + + ResultDataType(String code, String msg, Class parser) { + this.code = code; + this.msg = msg; + this.parser = parser; + } + + public ResultDataParser getParser() { + try { + return parser.newInstance(); + } catch (Exception e) { + log.error("get result data parse fail", e); + } + return null; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ResultStrategyType.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ResultStrategyType.java new file mode 100644 index 0000000..a883828 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/constants/ResultStrategyType.java @@ -0,0 +1,39 @@ +package com.hnac.gglm.bigmodel.zhipuai.constants; + +import com.hnac.gglm.bigmodel.zhipuai.handler.result.ResultBooleanStrategy; +import com.hnac.gglm.bigmodel.zhipuai.handler.result.ResultCommonStrategy; +import com.hnac.gglm.bigmodel.zhipuai.handler.result.ResultStrategy; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +/** + * @Author: ypj + * @Date: 2024/8/8 15:27 + */ +@Getter +@Slf4j +public enum ResultStrategyType implements BaseEnum { + COMMON("ResultCommonStrategy", "普通值", ResultCommonStrategy.class), + BOOLEAN("ResultBooleanStrategy", "是非判断", ResultBooleanStrategy.class); + + private final String code; + + private final String msg; + + private final Class strategyClass; + + ResultStrategyType(String code, String msg, Class strategy) { + this.code = code; + this.msg = msg; + this.strategyClass = strategy; + } + + public ResultStrategy getStrategy() { + try { + return strategyClass.newInstance(); + } catch (Exception e) { + log.error("get result strategy fail", e); + } + return null; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/controller/ZhipuAnalysisController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/controller/ZhipuAnalysisController.java new file mode 100644 index 0000000..0861211 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/controller/ZhipuAnalysisController.java @@ -0,0 +1,36 @@ +package com.hnac.gglm.bigmodel.zhipuai.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.zhipuai.service.ZhipuAnalysisService; +import com.hnac.gglm.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; +import com.hnac.gglm.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + +/** + * @Author: ypj + * @Date: 2024/8/8 16:36 + */ +@RestController +@RequestMapping("zhipu") +@Api(value = "智谱", tags = "智谱") +@AllArgsConstructor +public class ZhipuAnalysisController { + + private final ZhipuAnalysisService analysisService; + + @PostMapping("/analysis") + @ApiOperation("分析") + @ApiOperationSupport(order = 1) + public R analysis(@RequestBody @Valid ZhipuAnalysisFileRequest request) { + return R.data(analysisService.analysis(request)); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java new file mode 100644 index 0000000..94e362e --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java @@ -0,0 +1,65 @@ +package com.hnac.gglm.bigmodel.zhipuai.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import com.hnac.gglm.bigmodel.zhipuai.vo.ZhipuAnalysisInfoVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/8/12 20:22 + */ +@RestController +@Api(value = "智谱分析信息管理", tags = "智谱分析信息管理") +@RequestMapping("/zhipu/info") +@AllArgsConstructor +public class ZhipuAnalysisInfoController { + private final ZhipuAnalysisInfoService analysisInfoService; + + @PostMapping("/save") + @ApiOperation("保存智谱分析信息") + @ApiOperationSupport(order = 1) + public R save(@RequestBody ZhipuAnalysisInfoVO request) { + return R.status(analysisInfoService.save(request.toEntity())); + } + + @DeleteMapping("/remove") + @ApiOperation("批量删除智谱分析信息") + @ApiOperationSupport(order = 2) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(analysisInfoService.removeByIds(Func.toLongList(",", ids))); + } + + @GetMapping("/selectPage") + @ApiOperation("分页查询智谱分析配置信息") + @ApiOperationSupport(order = 3) + public R> selectPage(Query query, ZhipuAnalysisInfoEntity requestData) { + return R.data(analysisInfoService.page(Condition.getPage(query), Condition.getQueryWrapper(new ZhipuAnalysisInfoEntity(), requestData))); + } + + @PutMapping("/update") + @ApiOperation("更新智谱分析配置信息") + @ApiOperationSupport(order = 4) + public R update(@RequestBody ZhipuAnalysisInfoEntity requestData) { + return R.status(analysisInfoService.updateById(requestData)); + } + + @GetMapping("/list") + @ApiOperation("列出智谱分析配置信息") + @ApiOperationSupport(order = 5) + public R> list(ZhipuAnalysisInfoEntity requestData) { + return R.data(analysisInfoService.list(Condition.getQueryWrapper(requestData))); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java new file mode 100644 index 0000000..7e4d67a --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java @@ -0,0 +1,75 @@ +package com.hnac.gglm.bigmodel.zhipuai.entity; + +import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * @Author: ypj + * @Date: 2024/8/8 15:17 + */ +@ApiModel(value = "大模型分析信息") +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("hzims_analysis_info") +public class ZhipuAnalysisInfoEntity extends TenantEntity { + + @ApiModelProperty(value = "策略编码") + @TableField("CODE") + private String code; + + @ApiModelProperty(value = "对应字典表“AI识别类型”的key值") + @TableField("CHECK_TYPE_SON") + private String checkTypeSon; + + @ApiModelProperty(value = "策略名称") + @TableField("NAME") + @QueryField(condition = SqlCondition.LIKE) + private String name; + + @ApiModelProperty(value = "调用模型名称") + @TableField("MODEL") + private String model; + + @ApiModelProperty(value = "模型交互内容") + @TableField("REQUEST_CONTENT") + private String requestContent; + + @ApiModelProperty(value = "模型交互约束") + @TableField("REQUEST_CONSTRAINS") + private String requestConstrains; + + @ApiModelProperty(value = "模型交互返回格式定义") + @TableField("REQUEST_OUTPUT_FORMAT") + private String requestOutputFormat; + + @ApiModelProperty(value = "结果解析策略") + @TableField("RESULT_STRATEGY") + private String resultStrategy; + + @ApiModelProperty(value = "结果类型") + @TableField("RESULT_TYPE") + private String resultType; + + @ApiModelProperty(value = "结果查询key值") + @TableField("RESULT_KEY") + private String resultKey; + + @ApiModelProperty(value = "结果对比内容") + @TableField("RESULT_CONDITION") + private String resultCondition; + + @ApiModelProperty(value = "对比方式") + @TableField("RESULT_JUDGE_MODEL") + private String resultJudgeModel; + + @ApiModelProperty(value = "消息") + @TableField("MESSAGE") + private String message; +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java new file mode 100644 index 0000000..b30bf63 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java @@ -0,0 +1,23 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler; + +import com.zhipu.oapi.ClientV4; +import lombok.Data; + +import javax.annotation.Resource; + +/** + * @Author: ypj + * @Date: 2024/8/12 8:44 + */ +@Data +public abstract class AbstractZhipuAnalysisHandler implements ZhipuAnalyser { + protected final String requestIdTemplate = "big_model-%d"; + + @Resource + protected ClientV4 client; + + private String text; + + private String url; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalyser.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalyser.java new file mode 100644 index 0000000..47f7f52 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalyser.java @@ -0,0 +1,50 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler; + +import org.springblade.core.tool.jackson.JsonUtil; + +import java.util.Map; +import java.util.Optional; + +/** + * @Author: ypj + * @Date: 2024/8/8 14:45 + */ +public interface ZhipuAnalyser { + String QUESTION_PROFILE = "## Profile\n"; + + String QUESTION_CONSTRAINS = "## Constrains\n"; + + String QUESTION_OUTPUT_FORMAT = "## OutputFormat\n"; + + String getAnalysisStrategy(); + + String getAnalysisModel(); + + String getUrl(); + + void setUrl(String url); + + String getText(); + + void setText(String text); + + default boolean isSupport(String strategyCode) { + return getAnalysisStrategy().equals(strategyCode); + } + + Resp sendRequest(String text, String url); + + Req getRequest(String text, String url); + + String getResult(String text, String url); + + default Map getResultMap(String text, String url) { + String result = getResult(text, url); + return Optional.ofNullable(result).map(str -> JsonUtil.toMap(result)).orElse(null); + } + + default Object getResultValue(String text, String key, String url) { + Map resultMap = getResultMap(text, url); + return Optional.ofNullable(resultMap).map(data -> data.get(key)).orElse(null); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisFactory.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisFactory.java new file mode 100644 index 0000000..0818f8f --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisFactory.java @@ -0,0 +1,37 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @Author: ypj + * @Date: 2024/8/9 10:47 + */ +@Component +@AllArgsConstructor +@Slf4j +public class ZhipuAnalysisFactory { + private final List analysisStrategyList; + + private static final Map analysisStrategyMap = new ConcurrentHashMap<>(); + + public ZhipuAnalyser getAnalysisStrategy(final String strategyCode) { + ZhipuAnalyser result = ZhipuAnalysisFactory.analysisStrategyMap.get(strategyCode); + if (Objects.nonNull(result)) { + return result; + } + Optional strategyOptional = analysisStrategyList.stream().filter(strategy -> strategy.isSupport(strategyCode)).findFirst(); + if (strategyOptional.isPresent()) { + result = strategyOptional.get(); + ZhipuAnalysisFactory.analysisStrategyMap.put(strategyCode, result); + } + return result; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java new file mode 100644 index 0000000..8070aa2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java @@ -0,0 +1,88 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler; + +import cn.hutool.core.lang.Assert; +import com.hnac.gglm.bigmodel.zhipuai.constants.ErrorCode; +import com.hnac.hzinfo.exception.HzServiceException; +import com.zhipu.oapi.Constants; +import com.zhipu.oapi.service.v4.model.ChatCompletionRequest; +import com.zhipu.oapi.service.v4.model.ChatMessage; +import com.zhipu.oapi.service.v4.model.ChatMessageRole; +import com.zhipu.oapi.service.v4.model.ModelApiResponse; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * @Author: ypj + * @Date: 2024/8/12 9:20 + */ +@Service +@AllArgsConstructor +@Slf4j +public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { + + @Override + public String getAnalysisStrategy() { + return Constants.ModelChatGLM4V; + } + + @Override + public String getAnalysisModel() { + return Constants.ModelChatGLM4V; + } + + @Override + public ModelApiResponse sendRequest(String text, String url) { + ChatCompletionRequest request = getRequest(text, url); + log.info("send zhipu ai request :{}", Optional.ofNullable(request).map(JsonUtil::toJson).orElse("null")); + return client.invokeModelApi(request); + } + + @Override + public ChatCompletionRequest getRequest(String text, String url) { + List messages = new ArrayList<>(); + List> contentList = new ArrayList<>(); + Map textMap = new HashMap<>(); + textMap.put("type", "text"); + textMap.put("text", text); + Map typeMap = new HashMap<>(); + typeMap.put("type", "image_url"); + Map urlMap = new HashMap<>(); + urlMap.put("url", url); + typeMap.put("image_url", urlMap); + contentList.add(textMap); + contentList.add(typeMap); + ChatMessage chatMessage = new ChatMessage(ChatMessageRole.USER.value(), contentList); + messages.add(chatMessage); + String requestId = String.format(requestIdTemplate, System.currentTimeMillis()); + + return ChatCompletionRequest.builder() + .model(getAnalysisModel()) + .stream(Boolean.FALSE) + .invokeMethod(Constants.invokeMethod) + .messages(messages) + .requestId(requestId) + .build(); + } + + @Override + public String getResult(String text, String url) { + ModelApiResponse response = sendRequest(text, url); + log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(JsonUtil::toJson).orElse("null")); + Assert.isTrue(Objects.nonNull(response) && response.isSuccess(), () -> { + throw ErrorCode.throwCommonException(Optional.ofNullable(response).map(ModelApiResponse::getMsg).orElse(ErrorCode.NO_ANSWER_FROM_PLATFORM.getMsg())); + }); + try { + String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString(); + resultJson = resultJson.substring(resultJson.indexOf("{"), resultJson.lastIndexOf("}") + 1).trim(); + return resultJson; + } catch (Exception e) { + log.info("get data from response error", e); + throw ErrorCode.GET_DATA_FAILURE.throwException(); + } + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java new file mode 100644 index 0000000..e1f1aef --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java @@ -0,0 +1,22 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @Author: ypj + * @Date: 2024/8/12 10:11 + */ +@Service +@AllArgsConstructor +@Slf4j +public class ZhipuAnalysisHandlerTest extends ZhipuAnalysisHandlerGlm4v { + private final String model = "test"; + + @Override + public String getAnalysisStrategy() { + return model; + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java new file mode 100644 index 0000000..b8277f0 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java @@ -0,0 +1,46 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler.result; + +import com.hnac.gglm.bigmodel.zhipuai.constants.BaseEnum; +import com.hnac.gglm.bigmodel.zhipuai.constants.ComparisonType; +import com.hnac.gglm.bigmodel.zhipuai.constants.ErrorCode; +import com.hnac.gglm.bigmodel.zhipuai.constants.ResultStrategyType; +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import org.springframework.util.Assert; + +import java.util.Objects; + +/** + * @Author: ypj + * @Date: 2024/8/14 7:41 + */ +public class ResultBooleanStrategy implements ResultStrategy { + @Override + public String getCode() { + return ResultStrategyType.BOOLEAN.getCode(); + } + + @Override + public Boolean getResult(ZhipuAnalysisInfoEntity info, Object resultData) { + Object comparator = convertOriginalData(info.getResultCondition(), info.getResultType()); + Assert.isTrue(Objects.nonNull(comparator), () -> { + throw ErrorCode.NO_COMPARATOR.throwException(); + }); + ComparisonType comparisonType = BaseEnum.getInstance(info.getResultJudgeModel(), ComparisonType.class); + Assert.isTrue(Objects.nonNull(comparisonType), () -> { + throw ErrorCode.NO_COMPARISON_TYPE.throwException(); + }); + switch (Objects.requireNonNull(comparisonType)) { + case EQUAL: + return comparator.equals(resultData); + case GREATER: + if (comparator instanceof Comparable && resultData instanceof Comparable) { + return ((Comparable) comparator).compareTo((Comparable)resultData) < 0; + } + break; + case LESS: + return ((Comparable) comparator).compareTo(resultData) > 0; + } + throw ErrorCode.GET_RESULT_FAIL.throwException(); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java new file mode 100644 index 0000000..f08053d --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java @@ -0,0 +1,21 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler.result; + +import com.hnac.gglm.bigmodel.zhipuai.constants.ResultStrategyType; +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; + +/** + * @Author: ypj + * @Date: 2024/8/13 10:33 + */ +public class ResultCommonStrategy implements ResultStrategy { + @Override + public String getCode() { + return ResultStrategyType.COMMON.getCode(); + } + + @Override + public Object getResult(ZhipuAnalysisInfoEntity info, Object data) { + return data; + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultStrategy.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultStrategy.java new file mode 100644 index 0000000..86ed3f5 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/ResultStrategy.java @@ -0,0 +1,36 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler.result; + +import com.hnac.gglm.bigmodel.zhipuai.constants.BaseEnum; +import com.hnac.gglm.bigmodel.zhipuai.constants.ResultDataType; +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import com.hnac.gglm.bigmodel.zhipuai.handler.result.data.ResultDataParser; + +import java.util.Optional; + +/** + * @Author: ypj + * @Date: 2024/8/13 10:00 + */ +public interface ResultStrategy { + + String getCode(); + + default boolean isSupport(String strategyCode) { + return getCode().equals(strategyCode); + } + + default Object convertOriginalData(String originalData, String className) { + ResultDataType type = BaseEnum.getInstance(className, ResultDataType.class); + if (null != type) { + ResultDataParser parser = type.getParser(); + return Optional.ofNullable(parser).map(p -> p.parse(originalData)).orElse(originalData); + } + return originalData; + } + + default T getResult(ZhipuAnalysisInfoEntity info, String originalValue) { + return getResult(info, convertOriginalData(originalValue, info.getResultType())); + } + + T getResult(ZhipuAnalysisInfoEntity info, Object resultData); +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/BooleanParser.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/BooleanParser.java new file mode 100644 index 0000000..07a0ca5 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/BooleanParser.java @@ -0,0 +1,12 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler.result.data; + +/** + * @Author: ypj + * @Date: 2024/8/28 16:12 + */ +public class BooleanParser implements ResultDataParser { + @Override + public Boolean parse(String originalData) { + return Boolean.parseBoolean(originalData); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/IntegerParser.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/IntegerParser.java new file mode 100644 index 0000000..a8c18f3 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/IntegerParser.java @@ -0,0 +1,12 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler.result.data; + +/** + * @Author: ypj + * @Date: 2024/8/28 16:46 + */ +public class IntegerParser implements ResultDataParser { + @Override + public Integer parse(String originalData) { + return Integer.parseInt(originalData); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/ResultDataParser.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/ResultDataParser.java new file mode 100644 index 0000000..9fc6336 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/ResultDataParser.java @@ -0,0 +1,9 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler.result.data; + +/** + * @Author: ypj + * @Date: 2024/8/28 16:04 + */ +public interface ResultDataParser { + T parse(String originalData); +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/StringParser.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/StringParser.java new file mode 100644 index 0000000..7980066 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/result/data/StringParser.java @@ -0,0 +1,12 @@ +package com.hnac.gglm.bigmodel.zhipuai.handler.result.data; + +/** + * @Author: ypj + * @Date: 2024/8/28 16:11 + */ +public class StringParser implements ResultDataParser { + @Override + public String parse(String originalData) { + return originalData; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java new file mode 100644 index 0000000..ba93219 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.zhipuai.mapper; + +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @Author: ypj + * @Date: 2024/8/12 20:05 + */ +public interface ZhipuAnalysisInfoMapper extends UserDataScopeBaseMapper { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java new file mode 100644 index 0000000..7a85e54 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java @@ -0,0 +1,11 @@ +package com.hnac.gglm.bigmodel.zhipuai.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; + +/** + * @Author: ypj + * @Date: 2024/8/12 20:03 + */ +public interface ZhipuAnalysisInfoService extends IService { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/ZhipuAnalysisService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/ZhipuAnalysisService.java new file mode 100644 index 0000000..f8e62b1 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/ZhipuAnalysisService.java @@ -0,0 +1,20 @@ +package com.hnac.gglm.bigmodel.zhipuai.service; + +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisResponseDTO; +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import com.hnac.gglm.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; +import com.hnac.gglm.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse; + +/** + * @Author: ypj + * @Date: 2024/8/12 10:25 + */ +public interface ZhipuAnalysisService { + + ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request); + + ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request); + + BigModelAnalysisResponseDTO multiAnalysis(BigModelAnalysisRequestDTO analysisInfo); +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java new file mode 100644 index 0000000..fde1a52 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java @@ -0,0 +1,16 @@ +package com.hnac.gglm.bigmodel.zhipuai.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import com.hnac.gglm.bigmodel.zhipuai.mapper.ZhipuAnalysisInfoMapper; +import com.hnac.gglm.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; +import org.springframework.stereotype.Service; + +/** + * @Author: ypj + * @Date: 2024/8/12 20:03 + */ +@Service +public class ZhipuAnalysisInfoServiceImpl extends ServiceImpl implements ZhipuAnalysisInfoService { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java new file mode 100644 index 0000000..db67772 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java @@ -0,0 +1,216 @@ +package com.hnac.gglm.bigmodel.zhipuai.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisResponseDTO; +import com.hnac.gglm.bigmodel.zhipuai.constants.BaseEnum; +import com.hnac.gglm.bigmodel.zhipuai.constants.ErrorCode; +import com.hnac.gglm.bigmodel.zhipuai.constants.ResultStrategyType; +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import com.hnac.gglm.bigmodel.zhipuai.handler.result.ResultStrategy; +import com.hnac.gglm.bigmodel.zhipuai.handler.ZhipuAnalyser; +import com.hnac.gglm.bigmodel.zhipuai.handler.ZhipuAnalysisFactory; +import com.hnac.gglm.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; +import com.hnac.gglm.bigmodel.zhipuai.service.ZhipuAnalysisService; +import com.hnac.gglm.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; +import com.hnac.gglm.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse; +import com.hnac.hzims.common.utils.FileUtil; +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.io.IOException; +import java.util.*; + +/** + * @Author: ypj + * @Date: 2024/8/12 10:26 + */ +@Service +@AllArgsConstructor +@Slf4j +public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { + + private final ZhipuAnalysisFactory analysisFactory; + + private final ZhipuAnalysisInfoService infoService; + + private static final String MULTI_QUESTION_BRIEF = "从给出的图片回答以下{}个问题\n"; + + private static final String MULTI_QUESTION_PREFIX = "第{}个问题,"; + + private static final String MULTI_QUESTION_CONSTRAINS = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n"; + + private static final String MULTI_QUESTION_CONSTRAINS_LIST = "'{}'代表第{}个问题,"; + + @Override + public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) { + Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()) || StringUtil.isNotBlank(request.getUrl()), () -> { + throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); + }); + ZhipuAnalysisFileResponse response = new ZhipuAnalysisFileResponse(); + + ZhipuAnalysisInfoEntity info = getAnalysisInfo(request); + Assert.isTrue(Objects.nonNull(info), () -> { + throw ErrorCode.STRATEGY_NOT_FOUND.throwException(); + }); + + ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(info.getModel()); + Assert.isTrue(StringUtil.isNotBlank(info.getRequestContent()), () -> { + throw ErrorCode.REQUEST_TEXT_IS_EMPTY.throwException(); + }); + //拼接文字内容 + StringBuilder textBuilder = new StringBuilder(); + textBuilder.append(ZhipuAnalyser.QUESTION_PROFILE).append(info.getRequestContent()); + if (StringUtil.isNotBlank(info.getRequestConstrains())) { + textBuilder.append(ZhipuAnalyser.QUESTION_CONSTRAINS).append(info.getRequestConstrains()); + } + if (StringUtil.isNotBlank(info.getRequestOutputFormat())) { + textBuilder.append(ZhipuAnalyser.QUESTION_OUTPUT_FORMAT).append("{").append(info.getRequestOutputFormat()).append("}"); + } + analyser.setText(textBuilder.toString()); + + Object resultObject = analyser.getResultValue(analyser.getText(), info.getResultKey(), getSendUrl(request)); + Assert.isTrue(Objects.nonNull(resultObject), () -> { + throw ErrorCode.ANALYSIS_FAILURE.throwException(); + }); + String resultStr = resultObject.toString(); + + ResultStrategyType strategyType = BaseEnum.getInstance(info.getResultStrategy(), ResultStrategyType.class); + Assert.isTrue(Objects.nonNull(strategyType), () -> { + throw ErrorCode.STRATEGY_NOT_FOUND.throwException(); + }); + ResultStrategy strategy = strategyType.getStrategy(); + + Object resultValue = strategy.convertOriginalData(resultStr, info.getResultType()); + Object conclusion = strategy.getResult(info, resultValue); + + response.setResultStr(resultStr); + response.setResult(conclusion); + return response; + } + + String getSendUrl(ZhipuAnalysisFileRequest request) { + if (StringUtil.isNotBlank(request.getUrl())) { + return request.getUrl(); + } + Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()), () -> { + throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); + }); + try { + return FileUtil.getBase64(request.getFilePath()); + } catch (IOException e) { + throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); + } + } + + @Override + public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request) { + ZhipuAnalysisInfoEntity result = null; + if (StringUtil.isBlank(request.getCode()) && StringUtil.isBlank(request.getCheckTypeSon())) { + result = request.toAnalysisInfo(); + } else { + result = infoService.getOne(Wrappers.lambdaQuery() + .eq(StringUtil.isNotBlank(request.getCode()), ZhipuAnalysisInfoEntity::getCode, request.getCode()) + .eq(StringUtil.isNotBlank(request.getCheckTypeSon()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSon()) + .last("limit 1;")); + } + log.debug("the analysis information is {}", Optional.ofNullable(result).map(r -> JsonUtil.toJson(r)).orElse("null")); + return result; + } + + + @Override + public BigModelAnalysisResponseDTO multiAnalysis(BigModelAnalysisRequestDTO request) { + BigModelAnalysisResponseDTO response = new BigModelAnalysisResponseDTO(); + try { + Assert.isTrue(StringUtil.isNotBlank(request.getUrl()), () -> { + throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); + }); + Assert.isTrue(CollectionUtil.isNotEmpty(request.getCodeList()) || CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), () -> { + throw ErrorCode.EMPTY_ANALYSIS_TYPE.throwException(); + }); + List infoList = infoService.list(Wrappers.lambdaQuery().in(CollectionUtil.isNotEmpty(request.getCodeList()), ZhipuAnalysisInfoEntity::getCode, request.getCodeList()) + .in(CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSonList())); + Assert.isTrue(CollectionUtil.isNotEmpty(infoList), () -> { + throw ErrorCode.UNKNOWN_ANALYSIS_TYPE.throwException(); + }); + ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(infoList.get(0).getModel()); + + String text = getMultiAnalyserText(infoList); + Map resultMap = analyser.getResultMap(text, request.getUrl()); + + if (null == resultMap) { + response.setCode(ResultCode.FAILURE.getCode()); + response.setMsg(ErrorCode.ANALYSIS_FAILURE.getMsg()); + return response; + } + + List results = new ArrayList<>(infoList.size()); + for (int index = 1; index <= infoList.size(); index++) { + ZhipuAnalysisInfoEntity infoEntity = infoList.get(index - 1); + BigModelAnalysisResponseDTO.BigModelAnalysisResult result = new BigModelAnalysisResponseDTO.BigModelAnalysisResult(); + results.add(result); + result.setCheckTypeSon(infoEntity.getCheckTypeSon()); + Object resultObj = resultMap.get(infoEntity.getResultKey()); + if (ObjectUtil.isEmpty(resultObj)) { + continue; + } + String resultStr = resultObj.toString(); + result.setResultStr(resultStr); + result.setDescription(infoEntity.getName() + StringUtil.format(",结果为{}", resultStr)); + ResultStrategyType strategyType = BaseEnum.getInstance(infoEntity.getResultStrategy(), ResultStrategyType.class); + if (ObjectUtil.isEmpty(strategyType)) { + continue; + } + Object conclusionObj = strategyType.getStrategy().getResult(infoEntity, resultObj); + result.setResult(conclusionObj); + if (conclusionObj instanceof Boolean && !(Boolean) conclusionObj) { + result.setMessage(infoEntity.getMessage()); + } + } + response.setData(results); + response.setCode(ResultCode.SUCCESS.getCode()); + response.setMsg(ResultCode.SUCCESS.getMessage()); + } catch (Exception e) { + if (e instanceof HzServiceException) { + response.setCode(ResultCode.FAILURE.getCode()); + response.setMsg(e.getMessage()); + } else { + response.setCode(ResultCode.FAILURE.getCode()); + response.setMsg(ErrorCode.ANALYSIS_FAILURE.getMsg()); + } + log.error(ErrorCode.ANALYSIS_FAILURE.getMessage(), e); + } + return response; + } + + String getMultiAnalyserText(List infoList) { + StringBuilder stringBuilder = new StringBuilder(); + StringBuilder titleBuilder = new StringBuilder(); + StringBuilder formatBuilder = new StringBuilder(); + stringBuilder.append(ZhipuAnalyser.QUESTION_PROFILE) + .append(StringUtil.format(MULTI_QUESTION_BRIEF, infoList.size())); + formatBuilder.append("{"); + for (int index = 1; index <= infoList.size(); index++) { + ZhipuAnalysisInfoEntity infoEntity = infoList.get(index - 1); + stringBuilder.append(StringUtil.format(MULTI_QUESTION_PREFIX, index)); + titleBuilder.append(StringUtil.format(MULTI_QUESTION_CONSTRAINS_LIST, infoEntity.getResultKey(), index)); + formatBuilder.append(infoEntity.getRequestOutputFormat()).append(","); + } + formatBuilder.deleteCharAt(formatBuilder.length() - 1); + formatBuilder.append("}"); + stringBuilder.append(ZhipuAnalyser.QUESTION_CONSTRAINS) + .append(StringUtil.format(MULTI_QUESTION_CONSTRAINS, titleBuilder.toString())) + .append(ZhipuAnalyser.QUESTION_OUTPUT_FORMAT).append(formatBuilder); + return stringBuilder.toString(); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java new file mode 100644 index 0000000..93519a2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java @@ -0,0 +1,45 @@ +package com.hnac.gglm.bigmodel.zhipuai.vo; + +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: ypj + * @Date: 2024/8/12 10:23 + */ +@Data +@ApiModel(value = "智谱分析请求", description = "智谱分析请求") +public class ZhipuAnalysisFileRequest { + @ApiModelProperty("策略编码") + private String code; + + @ApiModelProperty(value = "检测类型子类") + private String checkTypeSon; + + @ApiModelProperty("模型名称") + private String model; + + @ApiModelProperty("文件地址或文件的base64内容") + private String url; + + @ApiModelProperty("本地文件路径") + private String filePath; + + @ApiModelProperty("发送内容") + private String content; + + @ApiModelProperty("额外信息") + private String message; + + public ZhipuAnalysisInfoEntity toAnalysisInfo() { + ZhipuAnalysisInfoEntity info = new ZhipuAnalysisInfoEntity(); + info.setCode(this.getCode()); + info.setModel(this.getModel()); + info.setRequestContent(this.content); + return info; + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java new file mode 100644 index 0000000..430adf2 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java @@ -0,0 +1,14 @@ +package com.hnac.gglm.bigmodel.zhipuai.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + * @Author: ypj + * @Date: 2024/8/12 10:23 + */ +@Data +@ApiModel(value = "智谱分析返回", description = "智谱分析返回") +public class ZhipuAnalysisFileResponse extends ZhipuAnalysisResult { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java new file mode 100644 index 0000000..6950087 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java @@ -0,0 +1,21 @@ +package com.hnac.gglm.bigmodel.zhipuai.vo; + +import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tool.utils.BeanUtil; + +/** + * @Author: ypj + * @Date: 2024/8/8 15:17 + */ +@ApiModel(value = "大模型分析信息") +@Data +@EqualsAndHashCode(callSuper = false) +public class ZhipuAnalysisInfoVO extends ZhipuAnalysisInfoEntity { + + public ZhipuAnalysisInfoEntity toEntity() { + return BeanUtil.copy(this, ZhipuAnalysisInfoEntity.class); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java new file mode 100644 index 0000000..87069ab --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java @@ -0,0 +1,32 @@ +package com.hnac.gglm.bigmodel.zhipuai.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Optional; + +/** + * @Author: ypj + * @Date: 2024/8/13 16:18 + */ +@Data +@ApiModel(description = "分析返回信息") +public class ZhipuAnalysisResult implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "是否成功", required = true) + private Boolean success = null; + + @ApiModelProperty(value = "承载数据") + private Object result; + + @ApiModelProperty(value = "结果描述") + private String resultStr; + + public Boolean getSuccess() { + return Optional.ofNullable(success).orElse(null != result); + } +} diff --git a/hzims-service/gglm-big-model/src/main/resources/db/1.0.0.sql b/hzims-service/gglm-big-model/src/main/resources/db/1.0.0.sql new file mode 100644 index 0000000..200900c --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/resources/db/1.0.0.sql @@ -0,0 +1,37 @@ +CREATE TABLE IF NOT EXISTS `hzims_function` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '函数名称', + `CODE` varchar(25) COLLATE utf8mb4_bin NOT NULL COMMENT '函数编号', + `TYPE` varchar(25) COLLATE utf8mb4_bin NOT NULL COMMENT '动作类型', + `IS_CONFIRM` tinyint(1) DEFAULT '0' COMMENT '是否需要确认,0:否,1:是', + `PATH` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '跳转路径', + `REMAKE` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '描述', + `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', + `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数'; + +CREATE TABLE IF NOT EXISTS `hzims_func_param` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `FUNC_ID` bigint(20) NOT NULL COMMENT '主键ID', + `NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '参数名称', + `ALIAS` varchar(25) COLLATE utf8mb4_bin NOT NULL COMMENT '参数别名', + `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', + `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数参数'; + +alter table `HZIMS_FUNCTION` add column `ROUTE` varchar(100) default null comment '菜单路由'; +alter table `HZIMS_FUNC_PARAM` add column `IS_REQUIRE` TINYINT(2) default 0 comment '是否必须'; \ No newline at end of file diff --git a/hzims-service/gglm-big-model/src/main/resources/db/2.0.0.sql b/hzims-service/gglm-big-model/src/main/resources/db/2.0.0.sql new file mode 100644 index 0000000..e73d3ed --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/resources/db/2.0.0.sql @@ -0,0 +1,65 @@ +CREATE TABLE IF NOT EXISTS `HZIMS_TABLE_PROPERTY` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `DATASOURCE_ID` BIGINT(50) NOT NULL COMMENT '数据源Id', + `DATASOURCE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', + `DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', + `TABLE_NAME` varchar(100) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据表名', + `AUTH_TYPE` varchar(20) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '鉴权类型', + `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', + `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据库表配置'; + +CREATE TABLE IF NOT EXISTS `HZIMS_TABLE_PROPERTY` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `DATASOURCE_NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', + `DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', + `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据库表配置'; + +CREATE TABLE IF NOT EXISTS `hzims_whitelist` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `USER_ID` bigint(20) NOT NULL COMMENT '主键ID', + `ACCOUNT` varchar(255) COLLATE utf8mb4_bin NOT NULL COMMENT '用户登录账号', + `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', + `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + `IS_REQUIRE` tinyint(2) DEFAULT NULL COMMENT '是否必须', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数参数'; + +CREATE TABLE IF NOT EXISTS `HZIMS_DATASOURCE` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `DATASOURCE` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源', + `DATASOURCE_NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', + `DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', + `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', + `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + `IS_REQUIRE` tinyint(2) DEFAULT NULL COMMENT '是否必须', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数参数'; + diff --git a/hzims-service/gglm-big-model/src/main/resources/db/2.0.1.sql b/hzims-service/gglm-big-model/src/main/resources/db/2.0.1.sql new file mode 100644 index 0000000..37778f1 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/resources/db/2.0.1.sql @@ -0,0 +1,27 @@ +-- 智谱大模型配置信息 +CREATE TABLE `hzims_analysis_info` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `CODE` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '策略编码', + `NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '策略名称', + `MODEL` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '调用模型名称', + `REQUEST_CONTENT` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模型交互内容', + `REQUEST_CONSTRAINS` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '模型交互约束', + `REQUEST_OUTPUT_FORMAT` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '模型交互返回格式定义', + `RESULT_STRATEGY` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '结果解析策略', + `RESULT_TYPE` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '结果类型', + `RESULT_KEY` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '结果查询key值', + `RESULT_CONDITION` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '结果对比内容', + `RESULT_JUDGE_MODEL` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '对比方式', + `CHECK_TYPE_SON` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '对应字典表“AI识别类型”的key值', + `MESSAGE` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '消息', + `TENANT_ID` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '租户ID', + `STATUS` tinyint(4) NULL DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + `IS_REQUIRE` tinyint(2) NULL DEFAULT NULL COMMENT '是否必须', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '大模型分析信息' ROW_FORMAT = Dynamic; diff --git a/hzims-service/gglm-big-model/src/main/resources/db/2.0.2.sql b/hzims-service/gglm-big-model/src/main/resources/db/2.0.2.sql new file mode 100644 index 0000000..b4d7a4c --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/resources/db/2.0.2.sql @@ -0,0 +1,17 @@ +CREATE TABLE `HZIMS_VECTOR_PARAM` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '名称', + `URL` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'URL', + `PROJECT_PREFIX` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目前缀', + `TABLE_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '数据库表名', + `ATTRIBUTE_MAP` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '向量键值对', + `TENANT_ID` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '租户ID', + `STATUS` tinyint(4) NULL DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '向量键值对信息' ROW_FORMAT = Dynamic; \ No newline at end of file diff --git a/hzims-service/gglm-big-model/src/main/resources/template/template.yml b/hzims-service/gglm-big-model/src/main/resources/template/template.yml new file mode 100644 index 0000000..54d7e29 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/resources/template/template.yml @@ -0,0 +1,94 @@ +#服务器端口 +server: + port: 8135 +spring: + #排除DruidDataSourceAutoConfigure + autoconfigure: + exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure + datasource: + dynamic: + #设置默认的数据源或者数据源组,默认值即为master + primary: master + datasource: + master: + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/test_hzims_big_model?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: ${hzinfo.db.busines.username} + password: ${hzinfo.db.busines.password} + hznlm: + url: jdbc:mysql://192.168.60.16:3306/hzn_lm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: root + password: 123 + operation: + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: ${hzinfo.db.busines.username} + password: ${hzinfo.db.busines.password} + equipment: + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: ${hzinfo.db.busines.username} + password: ${hzinfo.db.busines.password} + ticket: + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: ${hzinfo.db.busines.username} + password: ${hzinfo.db.busines.password} + safeproduct: + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: ${hzinfo.db.busines.username} + password: ${hzinfo.db.busines.password} + inspect: + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: ${hzinfo.db.busines.username} + password: ${hzinfo.db.busines.password} + alarm: + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: ${hzinfo.db.busines.username} + password: ${hzinfo.db.busines.password} + information: + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/information_schema?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + username: ${hzinfo.db.busines.username} + password: ${hzinfo.db.busines.password} + +gglm: + url: "http://${gglm.host}:${gglm.port}" + vectorUrl: "http://${vector.host}:${vector.port}" + api: + assistantAsk: "/qa/assistant_ask" + assistantStatus: "/qa/assistant_status" + askAbort: "/qa/ask_abort" + updateVideo: "/kn/update_video" + updateCanvas: "/kn/update_canvas" + updateFault: "/kn/update_fault" + assistantSpecialAsk: "/qa/assistant_special_ask" + assistantKnowledgeAsk: "/qa/assistant_knowledge_ask" + hotQuestion: "/qa/question_recommand" + smartReportGeneratePower: "/custom/smart_report_generate_power" + assistantAnalyseAsk: "/qa/assistant_analyse_ask" + updateKnowledge: "/kn/update_knowledge" + compute: "/compute" +swagger: + base-packages: com.hnac.hzims.bigmodel + +xxl: + job: + auto: + registry: 0 + accessToken: '' + admin: + addresses: http://${hzims.server.ip}:${hzims.xxljob.port}/xxl-job-admin + executor: + appname: hzims-big-model + ip: ${hzims.xxljob.ip} + logpath: /data/applogs/xxl-job/jobhandler + logretentiondays: 7 + port: 28135 + +bigmodel: + zhipuai: + url: https://open.bigmodel.cn/api/paas/v4/chat/completions + apiSecret: dfd23052747674818c7ac6f9922beff1.n2o5JEdfnrLbFU53 + +weaviate: + datasource: + schema: http + host: 192.168.60.16 + port: 9992 + apiKey: 123 diff --git a/hzims-service/hzims-big-model/pom.xml b/hzims-service/hzims-big-model/pom.xml deleted file mode 100644 index 61973c4..0000000 --- a/hzims-service/hzims-big-model/pom.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - com.hnac.hzims - hzims-service - 4.0.0-SNAPSHOT - - 4.0.0 - hzims-big-model - big-model - jar - - - - org.springblade - blade-common - - - org.springblade - blade-system-api - - - com.hnac.hzinfo.data - hzinfo-data-sdk - - - com.hnac.hzims - big-model-api - 4.0.0-SNAPSHOT - compile - - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - - - - org.springframework.boot - spring-boot-starter-websocket - - - org.springframework.boot - spring-boot-starter-tomcat - - - - - - com.xuxueli - xxl-job-core - - - com.baomidou - dynamic-datasource-spring-boot-starter - 3.5.0 - - - com.hnac.hzims - hzims-operational-api - - - - com.hnac.hzims - hzims-operational-api - 4.0.0-SNAPSHOT - - - com.hnac.hzinfo.data - hzinfo-data-sdk - - - com.hnac.hzims - equipment-api - - - com.baomidou - dynamic-datasource-spring-boot-starter - 3.5.0 - - - cn.bigmodel.openapi - oapi-java-sdk - release-V4-2.0.2 - - - io.weaviate - client - 4.7.0 - - - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-source-plugin - - - - - diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java deleted file mode 100644 index e6e8393..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.bigmodel; - -import org.mybatis.spring.annotation.MapperScan; -import org.springblade.core.cloud.feign.EnableBladeFeign; -import org.springblade.core.launch.BladeApplication; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.cloud.client.SpringCloudApplication; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.scheduling.annotation.EnableScheduling; - -import javax.annotation.Resource; - -@SpringBootApplication(scanBasePackages = {"org.springblade", "com.hnac.*"}) -@MapperScan(basePackages = {"com.hnac.hzinfo.**.mapper","com.hnac.hzims.**.mapper"}) -@EnableFeignClients(basePackages = {"org.springblade", "com.hnac"}) -public class HzimsBigModelApplication { - - public static void main(String[] args) { - BladeApplication.run(BigModelConstants.APP_NAME, HzimsBigModelApplication.class, args); - } - -// @Override -// protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { -// return BladeApplication.createSpringApplicationBuilder(builder, BigModelConstants.APP_NAME, HzimsBigModelApplication.class); -// } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java deleted file mode 100644 index b2dd6cc..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.bigmodel.api.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @Author: huangxing - * @Date: 2024/08/09 09:13 - */ -@AllArgsConstructor -@Getter -public enum SyncTableEnum { - /**视频**/ - VIDEO("video"), - /**实时画面**/ - CANVAS("canvas"), - /**故障**/ - FAULT("fault"), - /**站点**/ - STATION("station"), - /**实时数据属性**/ - RECORD("record"), - /**遥控**/ - REMOTE("yk") - ; - private final String tableName; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java deleted file mode 100644 index 7e2fac1..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; -import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService; -import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @Author: ypj - * @Date: 2024/8/12 16:10 - */ -@RestController -@AllArgsConstructor -public class BigModelAnalysisClient implements IBigModelAnalysisClient { - private final ZhipuAnalysisService analysisService; - - - @Override - @PostMapping(PREFIX_API + "/analysis") - public BigModelAnalysisResponseDTO analysis(BigModelAnalysisRequestDTO analysisInfo) { - return analysisService.multiAnalysis(analysisInfo); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java deleted file mode 100644 index d0ac0d4..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/DataAnalyseClient.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.alibaba.fastjson.JSON; -import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; -import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/08/14 19:15 - */ -@RestController -@AllArgsConstructor -@Slf4j -public class DataAnalyseClient implements IDataAnalyseClient { - - private final IHznlmInvokeService invokeService; - - @Override - public R smartReportGeneratePower(RunReportAnalyseRequest req) { - log.info("获取运行月报告传参详情为:{}", JSON.toJSONString(req)); - invokeService.smartReportGeneratePower(req); - return R.success("发起问答成功"); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java deleted file mode 100644 index 46a3681..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.hnac.hzims.bigmodel.api.feign; - -import com.hnac.hzims.bigmodel.api.constants.SyncTableEnum; -import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; -import com.hnac.hzims.bigmodel.api.service.SyncService; -import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/07/09 20:17 - */ -@RestController -@AllArgsConstructor -public class VideoSyncClient implements IVideoSyncClient{ - - private final SyncService syncService; - private final BigModelInvokeApi bigModelInvokeApi; - - @Override - @PostMapping(PREFIX_API + SAVE_BATCH) - public R saveBatch(@RequestBody List syncDTO) { - syncService.insert(bigModelInvokeApi.getInsertVideo(),syncDTO); - return R.success("同步数据成功!"); - } - - @Override - @DeleteMapping(PREFIX_API + DELETE_BY_IDS) - public R deleteByIds(@RequestParam("ids") String ids) { - List idList = Func.toStrList(",", ids); - idList.forEach(id -> syncService.deleteById(id, SyncTableEnum.VIDEO)); - return R.success("同步数据成功!"); - } - - @Override - @DeleteMapping(PREFIX_API + DELETE_BY_STATION_ID) - public R deleteByStationId(@RequestParam("stationId") String stationId) { - return R.data(syncService.deleteByStationId(stationId,SyncTableEnum.VIDEO)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java deleted file mode 100644 index 9a0a95c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.hnac.hzims.bigmodel.api.service; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.TypeReference; -import com.hnac.hzims.bigmodel.api.constants.SyncTableEnum; -import com.hnac.hzims.bigmodel.api.dto.SyncDTO; -import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; -import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; -import com.hnac.hzims.bigmodel.utils.RequestClientUtil; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.BeanUtil; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/07/10 09:03 - */ -@Service -@Slf4j -@AllArgsConstructor -public class SyncService { - - private final BigModelInvokeApi bigModelInvokeApi; - - /** - * 通过站点id删除数据 - * @param stationId 站点ID - * @param syncTableEnum 同步表枚举类 - * @return 删除条数 - */ - public Integer deleteByStationId(String stationId, SyncTableEnum syncTableEnum) { - Map params = new HashMap<>(2); - params.put("station_id",stationId); - params.put("table_name", syncTableEnum.getTableName()); - return RequestClientUtil.postCall(bigModelInvokeApi.getDeleteByStationId(),params,new TypeReference(){}); - } - - /** - * 通过id删除数据 - * @param id 数据表主键ID - * @param syncTableEnum 同步表枚举类 - * @return 删除条数 - */ - public Integer deleteById(String id, SyncTableEnum syncTableEnum) { - Integer result = null; - Map params = new HashMap<>(2); - params.put("id",id); - params.put("table_name", syncTableEnum.getTableName()); -// result = RequestClientUtil.postCall(bigModelInvokeApi.getDeleteById(),params,new TypeReference(){}); - return result; - } - - /*** - * 添加数据 - * @param api 调用接口 - * @param data 同步数据 - */ - public void insert(String api, List data) { - Map params = BeanUtil.toMap(data); -// RequestClientUtil.postCall(api,params); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java deleted file mode 100644 index 4bf58da..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hnac.hzims.bigmodel.business.consumer; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; -import com.hnac.hzims.bigmodel.api.feign.ISyncClient; -import com.hnac.hzims.bigmodel.api.feign.VideoSyncClient; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.mqtt.customer.IMqttReceive; -import org.springblade.mqtt.customer.annotation.MqttReceive; -import org.springframework.stereotype.Service; -import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/08/09 10:33 - */ -@MqttReceive(topicName = MqttTopicConstants.TOPIC_VIDEO_INSERT) -@Service -@Slf4j -@AllArgsConstructor -public class VideoAddConsumer implements IMqttReceive { - - private final VideoSyncClient videoSyncClient; - - @Override - public void handlerMessage(String message) { - log.info("收到新增视频信息,消息内容体为:{}", message); - List videoSyncDTOS = JSONArray.parseArray(message, VideoSyncDTO.class); - if(Func.isNotEmpty(videoSyncDTOS)) { - videoSyncClient.saveBatch(videoSyncDTOS); - } - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java deleted file mode 100644 index 01afc3e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hnac.hzims.bigmodel.business.consumer; - -import com.alibaba.fastjson.JSONArray; -import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; -import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; -import com.hnac.hzims.bigmodel.api.feign.VideoSyncClient; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.Func; -import org.springblade.mqtt.customer.IMqttReceive; -import org.springblade.mqtt.customer.annotation.MqttReceive; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/08/12 09:29 - */ -@MqttReceive(topicName = MqttTopicConstants.TOPIC_VIDEO_DELETE) -@Service -@Slf4j -@AllArgsConstructor -public class VideoRemoveConsumer implements IMqttReceive { - - private final VideoSyncClient videoSyncClient; - - - @Override - public void handlerMessage(String message) { - log.info("收到删除视频信息,消息内容体为:{}", message); - if(Func.isNotEmpty(message)) { - Func.toStrList(",",message).forEach(id -> videoSyncClient.deleteByIds(id)); - } - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/DataSourceExecuteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/DataSourceExecuteController.java deleted file mode 100644 index 47e7cc5..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/DataSourceExecuteController.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hnac.hzims.bigmodel.business.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.business.service.DataSourceService; -import com.hnac.hzims.bigmodel.business.vo.SqlVO; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/28 14:07 - */ -@RestController -@RequestMapping("/dataSource/execute") -@AllArgsConstructor -public class DataSourceExecuteController { - - private final DataSourceService dataSourceService; - - @PostMapping("/executeQuery") - @ApiOperation("执行大模型sql") - @ApiOperationSupport(order = 1) - public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { - return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/RemoteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/RemoteController.java deleted file mode 100644 index ac0c0b3..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/controller/RemoteController.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.hnac.hzims.bigmodel.business.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.business.service.RemoteService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springblade.system.dto.ControlDTO; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @Author: huangxing - * @Date: 2024/06/24 14:42 - */ -@AllArgsConstructor -@RequestMapping("/remote") -@RestController -@Api(value = "数据平台遥控指令管理",tags = "数据平台遥控指令管理") -public class RemoteController { - - private final RemoteService remoteService; - - @ApiOperation("下发遥控指令") - @ApiOperationSupport(order = 1) - @PostMapping("/sendRemoteControl") - public R sendRemoteControl(@RequestBody ControlDTO controlDTO) { - return remoteService.sendRemoteControl(controlDTO); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java deleted file mode 100644 index 3728591..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.hnac.hzims.bigmodel.business.feign; - -import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; -import com.hnac.hzims.bigmodel.business.service.AuthenticationService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.StringUtil; -import org.springblade.system.dto.DeptStationDTO; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/07/09 09:31 - */ -@Component -@AllArgsConstructor -@Slf4j -public class AuthClient implements IAuthClient { - - private final AuthenticationService authenticationService; - - /** - * 设备控制鉴权 - * @param req 遥控信息 - * @return 鉴权结果 - */ - @Override - public R remoteAuth(ControlDeviceAuthDTO req) { - // 若站点不为空 则对站点进行鉴权 - if(StringUtil.isNotBlank(req.getStationId())) { - if(!authenticationService.stationAuthentication(req.getStationId(), req.getUserId())) { - return R.fail("站点鉴权失败!"); - } - } - if("数据中心".equals(req.getType())) { - - } - return R.success("鉴权成功"); - } - - /** - * 站点鉴权 - * @param userId 用户ID - * @param stationId 站点ID - * @return 鉴权结果 - */ - @Override - public R stationAuth(String userId, String stationId) { - return R.status(authenticationService.stationAuthentication(stationId,userId)); - } - - /** - * 机构鉴权 - * @param userId 用户ID - * @param deptId 站点ID - * @return 鉴权结果 - */ - @Override - public R deptAuth(String userId, String deptId) { - List deptStationDTOList = authenticationService.getStationPermissionsById(userId); - boolean result = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).anyMatch(d -> Long.valueOf(deptId).equals(d)); - return R.status(result); - } - - /** - * 获取用户权限数据 - * @param userId 用户ID - * @return 权限数据 - 站点、机构 - */ - @Override - public R> getAuthData(String userId) { - Map result = new HashMap<>(2); - List deptStationDTOList = authenticationService.getStationPermissionsById(userId); - String[] stationIds = deptStationDTOList.stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).toArray(String[]::new); - String[] deptIds = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).map(String::valueOf).toArray(String[]::new); - result.put("stationids",stationIds); - result.put("projectids",deptIds); - return R.data(result); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java deleted file mode 100644 index 13db6f2..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.hnac.hzims.bigmodel.business.service; - -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.interactive.constants.ProjectRemoteTypeEnum; -import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; -import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; -import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.v5.project.ProjectClient; -import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; -import lombok.AllArgsConstructor; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; -import org.springblade.system.dto.DeptStationDTO; -import org.springblade.system.entity.CtrlAuth; -import org.springblade.system.feign.IDeptClient; -import org.springblade.system.feign.IRemoteClient; -import org.springblade.system.user.feign.IUserClient; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.List; -import java.util.Optional; - -/** - * @Author: huangxing - * @Date: 2024/05/21 16:10 - */ -@Service -@AllArgsConstructor -public class AuthenticationService { - - private final IDeptClient deptClient; - private final ProjectClient projectClient; - private final IRemoteClient remoteClient; - private final RedisTemplate redisTemplate; - - /** - * 站点鉴权 - * @param stationId 站点ID - * @param userId 用户ID - */ - public Boolean stationAuthentication(String stationId, String userId) { - List deptStationDTOList = this.getStationPermissionsById(userId); - return deptStationDTOList.stream().map(DeptStationDTO::getStationId).anyMatch(stationId::equals); - } - - /** - * 菜单鉴权 - * @param userId 用户ID - * @param func 函数编号 - */ -// public void menuAuthentication(String userId, String func) { -// FunctionEntity function = functionService.getFunctionByCode(func); -// if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { -// R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); -// Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { -// throw new ServiceException("人员菜单鉴权失败!"); -// }); -// } -// } - - /** - * 遥控鉴权 - * @param stationId 站点ID - * @param userId 用户ID - */ - public void remoteAuthentication(String stationId, String userId,String sessionId) { - // 查询数据平台站点是否可被遥控 - Result> projectR = projectClient.getProjectIds(Lists.newArrayList(stationId)); - Assert.isTrue(projectR.isSuccess() && CollectionUtil.isNotEmpty(projectR.getData()) && projectR.getData().size() == 1,() -> { - throw new ServiceException("未查询到站点,鉴权失败!"); - }); - ProjectVO project = projectR.getData().get(0); - if(ProjectRemoteTypeEnum.NOT_ALLOW.getCtrlType().equals(project.getCtrlType())) { - // 不允许发送遥控 - throw new ServiceException("该站点不允许发送遥控指令,校验失败!"); - } - else if(ProjectRemoteTypeEnum.VALID.getCtrlType().equals(project.getCtrlType())) { - // 运行发送遥控并且需要校验权限 - R> ctrlAuthR = remoteClient.getCtrlAuth(Optional.ofNullable(userId).filter(StringUtil::isNotBlank).map(Long::parseLong).orElse(null)); - Assert.isTrue(ctrlAuthR.isSuccess(),() -> { - throw new ServiceException("该站点未设置鉴权用户,校验失败!"); - }); - List ctrlAuthList = ctrlAuthR.getData(); - Optional authOptional = ctrlAuthList.stream().filter(c -> c.getProjectId().equals(stationId)).findFirst(); - Assert.isTrue(authOptional.isPresent() && Func.isNotEmpty(authOptional.get().getIsLimitMachine()), () -> { - throw new ServiceException("该用户不存在相应站点权限,校验不通过!"); - }); - CtrlAuth ctrlAuth = authOptional.get(); - // 如限制机器发送遥控指令 - if(ctrlAuth.getIsLimitMachine() == 1) { - SessionContentVO sessionContent = (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, sessionId); - Assert.isTrue(Func.isNotEmpty(sessionContent),() -> { - throw new ServiceException("获取问题机器码失败,校验不通过!"); - }); - String machineCode = sessionContent.getMachineCode(); - Assert.isTrue(StringUtil.isNotBlank(machineCode) && Func.isNotEmpty(machineCode) ,() -> { - throw new ServiceException("获取问题机器码失败,校验不通过!"); - }); - Assert.isTrue(machineCode.equals(ctrlAuth.getMachineCode()),() -> { - throw new ServiceException("站点校验码校验失败,校验不通过!"); - }); - } - } - } - - public List getStationPermissionsById(String userId) { - R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); - Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { - throw new ServiceException("获取人员站点权限失败!"); - }); - return deptSattionR.getData(); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java deleted file mode 100644 index ac1c3c8..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.hnac.hzims.bigmodel.business.service; - -import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hnac.hzims.bigmodel.business.vo.SqlVO; -import com.hnac.hzims.bigmodel.business.vo.TableAuthVO; -import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; -import com.hnac.hzims.bigmodel.maintenance.service.TablePropertyService; -import com.hnac.hzims.common.service.UserAuthDataService; -import com.hnac.hzinfo.exception.HzServiceException; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.api.ResultCode; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - -/** - * @Author: huangxing - * @Date: 2024/06/28 15:24 - */ -@Service -@AllArgsConstructor -@Slf4j -public class DataSourceService { - - private final JdbcTemplate jdbcTemplate; - private final UserAuthDataService userAuthDataService; - private final TablePropertyService tablePropertyService; - - private static final Pattern UPDATE_PATTERN = Pattern.compile("^UPDATE\\s", Pattern.CASE_INSENSITIVE); - private static final Pattern DELETE_PATTERN = Pattern.compile("^DELETE\\s", Pattern.CASE_INSENSITIVE); - - - public List> queryListOnSpecificDataSource(SqlVO sqlVO) { - // 过滤更新、删除语句 - Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { - throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); - }); - String sql = sqlVO.getSql(); - String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); - if(StringUtil.isNotBlank(userAuthDataSQL)) { - for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { - // 查询改数据源下的表格是否存在鉴权 - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() - .eq(TablePropertyEntity::getDatasourceId, tableAuthVO.getDatasourceName()) - .eq(TablePropertyEntity::getTableName, tableAuthVO.getTableName()); - List propertise = tablePropertyService.list(wrapper); - Assert.isTrue(Func.isNotEmpty(propertise), () -> { - throw new HzServiceException(ResultCode.FAILURE,"查询语句中存在未进行鉴权的表,查询失败!"); - }); - if("1".equals(propertise.get(0).getAuthType())) { - String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where is_deleted = 0 and " + userAuthDataSQL +") temp"; - sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); - } else { - String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where is_deleted = 0) temp"; - sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); - } - } - } - sql = sql.replaceAll(">", ">").replaceAll("<", "<"); - log.info("执行sql:{}",sql); - return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); - } - - /** - * sql - * @param sql - * @param dataSourceName - * @return - */ - public List> queryListOnSpecificDataSource(String sql,String dataSourceName) { - // 切换到指定的数据源 - DynamicDataSourceContextHolder.push(dataSourceName); - try { - return jdbcTemplate.queryForList(sql); - } finally { - // 清除,恢复默认数据源 - DynamicDataSourceContextHolder.clear(); - } - } - - public Integer updateOnSpecificDataSource(String sql,String dataSourceName) { - // 切换到指定的数据源 - DynamicDataSourceContextHolder.push(dataSourceName); - try { - return jdbcTemplate.update(sql); - } finally { - // 清除,恢复默认数据源 - DynamicDataSourceContextHolder.clear(); - } - } - - /** - * 过滤更新、删除语法的sql脚本 - * @param sql 待执行sql脚本 - * @return 执行结果 - */ - public static boolean isUpdateOrDelete(String sql) { - if (sql == null) { - return false; - } - return UPDATE_PATTERN.matcher(sql).find() || DELETE_PATTERN.matcher(sql).find(); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java deleted file mode 100644 index cc7f5ca..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.hnac.hzims.bigmodel.business.service; - -import com.alibaba.fastjson.JSON; -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; -import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; -import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; -import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; -import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO; -import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; -import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; - -/** - * @Author: huangxing - * @Date: 2024/06/24 14:57 - */ -@Service -@Slf4j -@AllArgsConstructor -public class HistoryDataService { - - private final DeviceDataClient deviceDataClient; - public static final int DATA_COUNT_MAX = 1000; - - public Result getPolymerizationData(HistoryDataSearchVO searchVO) { - DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); - Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { - throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); - }); - // 聚合数据方式处理 - DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); - ReductionDataDTO dataDTO = new ReductionDataDTO(); - ReductionAttrDataDTO reductionAttrData = new ReductionAttrDataDTO(); - reductionAttrData.setSignage(searchVO.getSignage()); - reductionAttrData.setAccessRules(enumByMethod.getAccessRule()); - reductionAttrData.setKeepFigures(2); - dataDTO.setBeginTime(LocalDateTime.parse(searchVO.getStartTime(), DateUtil.DATETIME_FORMATTER)); - dataDTO.setEndTime(LocalDateTime.parse(searchVO.getEndTime(),DateUtil.DATETIME_FORMATTER)); - dataDTO.setDeviceCode(searchVO.getDeviceCode()); - dataDTO.setNeedPage(false); - dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); - dataDTO.setTimeInterval(1); - dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); - log.info("config传参为:{}", JSON.toJSONString(dataDTO)); - return deviceDataClient.pageDeviceCodeAndSignages(dataDTO); - } - - public DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { - LocalDateTime start = LocalDateTime.parse(startTime, DateUtil.DATETIME_FORMATTER); - LocalDateTime end = LocalDateTime.parse(endTime, DateUtil.DATETIME_FORMATTER); - Duration duration = Duration.between(start, end); - int count; - switch(dateEnum) { - case YEAR: - count = Long.valueOf(ChronoUnit.YEARS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case MONTH: - count = Long.valueOf(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case DAY: - count = Long.valueOf(ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case HOUR: - count = Long.valueOf(duration.toHours()).intValue(); - break; - case MINUTE: - count = Long.valueOf(duration.toMinutes()).intValue(); - break; - case SECOND: - count = Long.valueOf(duration.getSeconds()).intValue(); - break; - default: - throw new ServiceException("未找到相关时间类型,查询失败!"); - } - if(count <= DATA_COUNT_MAX) { - return dateEnum; - } - else { - return getDateEnumByDuration(startTime, endTime, DateEnum.getDateEnumByOrder(dateEnum.getOrder() + 1)); - } - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java deleted file mode 100644 index 96e8259..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.bigmodel.business.service; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.system.dto.ControlDTO; -import org.springblade.system.feign.IRemoteClient; -import org.springframework.stereotype.Service; - -/** - * @Author: huangxing - * @Date: 2024/06/24 14:36 - * @Descirbe: 数据平台 - 遥控服务类 - */ -@Service -@Slf4j -@AllArgsConstructor -public class RemoteService { - - private final IRemoteClient remoteClient; - - /** - * 发送遥控指令 - * @param controlDTO 遥控指令 - * @return 结果 - */ - public R sendRemoteControl(ControlDTO controlDTO) { - return remoteClient.sendCtrl(controlDTO); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java deleted file mode 100644 index 5a5bff8..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.bigmodel.business.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/07/05 08:19 - */ -@ApiModel(value = "",description = "") -@Data -@EqualsAndHashCode -public class SqlVO implements Serializable { - - @ApiModelProperty("执行sql") - @NotBlank - private String sql; - - @ApiModelProperty("执行人") - @NotBlank - private String userId; - - @ApiModelProperty("执行sql设计表信息") - private List tableAuthVOList; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java deleted file mode 100644 index b1524fa..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.bigmodel.business.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/04 17:29 - */ -@ApiModel(value = "表鉴权对象",description = "表鉴权对象") -@Data -@EqualsAndHashCode -public class TableAuthVO implements Serializable { - - @ApiModelProperty("鉴权类型,目前不为空即为平台数据权限") - private String auth; - - @ApiModelProperty("数据源名称") - private String datasourceName; - - @ApiModelProperty("数据表名称") - private String tableName; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/wrapper/CanvasSyncWrapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/wrapper/CanvasSyncWrapper.java deleted file mode 100644 index 306e13d..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/wrapper/CanvasSyncWrapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.bigmodel.business.wrapper; - -import com.hnac.hzims.bigmodel.api.dto.CanvasSyncDTO; -import com.hnac.hzims.bigmodel.api.wrapper.BaseSyncWrapper; -import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasVO; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Component; - -/** - * @Author: huangxing - * @Date: 2024/08/20 16:49 - */ -@Component -@AllArgsConstructor -public class CanvasSyncWrapper extends BaseSyncWrapper { - - @Override - public CanvasSyncDTO convert(CanvasVO obj) { - return null; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java deleted file mode 100644 index b6b842a..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.hnac.hzims.bigmodel.configuration; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * @Author: huangxing - * @Date: 2024/04/28 18:20 - */ -@Data -@Component -@ConfigurationProperties(prefix = "gglm.api") -public class BigModelInvokeApi { - - private String assistantAsk; - - private String assistantSpecialAsk; - - private String assistantStatus; - - private String askAbort; - - private String updateVideo; - - private String updateFault; - - private String updateCanvas; - - private String assistantKnowledgeAsk; - - private String hotQuestion; - - private String deleteByStationId; - - private String deleteById; - - private String insertCanvas; - - private String insertFault; - - private String insertRecord; - - private String insertStation; - - private String insertVideo; - - private String insertYk; - - /** - * 发起机组发电量智能报表分析问答 - */ - private String smartReportGeneratePower; - - /** - * 起数据分析问答 - */ - private String assistantAnalyseAsk; - - /** - * 更新数据 - */ - private String updateKnowledge; - - /** - * 计算向量 - */ - private String compute; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/ThreadPoolManager.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/ThreadPoolManager.java deleted file mode 100644 index 69c0d43..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/ThreadPoolManager.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.hnac.hzims.bigmodel.configuration; - -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -import java.util.concurrent.*; - -/** - * @Author: huangxing - * @Date: 2024/05/06 11:58 - */ -@Component -public class ThreadPoolManager { - - @Bean - public ThreadPoolExecutor getAnswerPoolExecutor() { - // 核心线程数 - int corePoolSize = 5; - // 最大线程数 - int maximumPoolSize = 10; - // 线程空闲时的存活时间 - long keepAliveTime = 60L; - // 时间单位 - TimeUnit unit = TimeUnit.SECONDS; - // 任务队列 - BlockingQueue workQueue = new LinkedBlockingQueue<>(100); - // 线程工厂 - ThreadFactory threadFactory = Executors.defaultThreadFactory(); - // 拒绝策略 - RejectedExecutionHandler handler = new ThreadPoolExecutor.AbortPolicy(); - return new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,threadFactory,handler); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateConfigure.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateConfigure.java deleted file mode 100644 index 6bd2f14..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateConfigure.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.hnac.hzims.bigmodel.configuration; - -import io.weaviate.client.Config; -import io.weaviate.client.WeaviateAuthClient; -import io.weaviate.client.WeaviateClient; -import io.weaviate.client.v1.auth.exception.AuthException; -import io.weaviate.client.v1.data.api.ObjectCreator; -import io.weaviate.client.v1.data.api.ObjectDeleter; -import io.weaviate.client.v1.data.api.ObjectUpdater; -import io.weaviate.client.v1.data.api.ObjectsGetter; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @Author: huangxing - * @Date: 2024/08/22 18:38 - */ -@Configuration -public class WeaviateConfigure { - - private final WeaviateProperties weaviateProperties; - - public WeaviateConfigure(WeaviateProperties weaviateProperties) { - this.weaviateProperties = weaviateProperties; - } - - @Bean - public WeaviateClient weaviateClient() throws AuthException { - Config config = new Config(this.weaviateProperties.getSchema(), this.weaviateProperties.getHost() + ":" + this.weaviateProperties.getPort()); - return WeaviateAuthClient.apiKey(config,this.weaviateProperties.getApiKey()); - } - - @Bean - public ObjectsGetter objectsGetter() throws AuthException { - WeaviateClient weaviateClient = weaviateClient(); - return weaviateClient.data().objectsGetter(); - } - - @Bean - public ObjectCreator objectCreator() throws AuthException { - WeaviateClient weaviateClient = weaviateClient(); - return weaviateClient.data().creator(); - } - - @Bean - public ObjectDeleter deleter() throws AuthException { - WeaviateClient weaviateClient = weaviateClient(); - return weaviateClient.data().deleter(); - } - - @Bean - public ObjectUpdater updater() throws AuthException { - WeaviateClient weaviateClient = weaviateClient(); - return weaviateClient.data().updater(); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateProperties.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateProperties.java deleted file mode 100644 index 468bae9..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/WeaviateProperties.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.bigmodel.configuration; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * @Author: huangxing - * @Date: 2024/08/21 15:22 - */ -@Data -@Component -@ConfigurationProperties(prefix = "weaviate.datasource") -public class WeaviateProperties { - - private String schema; - - private String host; - - private String port; - - /** - * 登录认证KEY - */ - private String apiKey; - - /** - * 数据库表名前缀 - */ - private String classNamePrefix; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/controller/WeaviateController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/controller/WeaviateController.java deleted file mode 100644 index 620950d..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/controller/WeaviateController.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.hnac.hzims.bigmodel.database.controller; - -import com.hnac.hzims.bigmodel.database.dto.WeaviateSaveDTO; -import com.hnac.hzims.bigmodel.database.service.WeaviateService; -import io.weaviate.client.v1.data.model.WeaviateObject; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/09/04 14:16 - */ -@RestController -@AllArgsConstructor -@RequestMapping("/weaviate") -public class WeaviateController { - - private final WeaviateService weaviateService; - - @PostMapping("/saveBatch") - public R saveBatch(@RequestBody WeaviateSaveDTO req) { - weaviateService.saveBatch(req.getEntities(), req.getClassName(), req.getAttrsMap()); - return R.success("操作成功!"); - } - - @GetMapping("/list") - public R> list(@RequestParam(value = "id",required = false) String id, - @RequestParam("className") String className, - @RequestParam("current") Integer current, - @RequestParam("pageSize") Integer pageSize) { - return R.data(weaviateService.list(id,className,current,pageSize)); - } - - @DeleteMapping("/removeById") - public R removeById(@RequestParam(value = "id",required = false) String id, @RequestParam("className") String className) { - return R.status(weaviateService.delete(id,className)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/dto/WeaviateSaveDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/dto/WeaviateSaveDTO.java deleted file mode 100644 index 715298e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/dto/WeaviateSaveDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hnac.hzims.bigmodel.database.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/09/04 14:36 - */ -@Data -@EqualsAndHashCode -public class WeaviateSaveDTO implements Serializable { - - /** - * 向量数据库表名 - */ - private String className; - - /** - * 向量数据库属性名 - */ - private Map attrsMap; - - /** - * 向量数据库存入对象列表 - */ - private List entities; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java deleted file mode 100644 index 76d308c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.hnac.hzims.bigmodel.database.service; - -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import cn.hutool.json.JSONUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; -import com.hnac.hzinfo.exception.HzServiceException; -import io.weaviate.client.Config; -import io.weaviate.client.WeaviateAuthClient; -import io.weaviate.client.WeaviateClient; -import io.weaviate.client.base.Result; -import io.weaviate.client.v1.auth.exception.AuthException; -import io.weaviate.client.v1.data.api.ObjectCreator; -import io.weaviate.client.v1.data.api.ObjectDeleter; -import io.weaviate.client.v1.data.api.ObjectUpdater; -import io.weaviate.client.v1.data.api.ObjectsGetter; -import io.weaviate.client.v1.data.model.WeaviateObject; -import io.weaviate.client.v1.graphql.model.GraphQLResponse; -import io.weaviate.client.v1.graphql.query.Get; -import io.weaviate.client.v1.graphql.query.fields.Field; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.ResultCode; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; - -/** - * @Author: huangxing - * @Date: 2024/08/22 19:17 - */ -@RequiredArgsConstructor -@Service -@Slf4j -public class WeaviateService { - - private final WeaviateClient weaviateClient; - private final BigModelInvokeApi invokeApi; - - @Value("${gglm.vectorUrl}") - private String vectorUrl; - - /** - * 对象保存向量数据库 - * @param entity 保存对象 - * @param className 保存表名 - * @param attrs 待计算的列信息 - * @return 保存操作结果 - */ - public Boolean save(Object entity, String className, List attrs) { - ObjectCreator creator = weaviateClient.data().creator().withClassName(className); - if(Func.isNotEmpty(attrs)) { - JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(entity)); - List vectors = attrs.stream().map(attr -> jsonObject.getString(attr)).collect(Collectors.toList()); - Float[] compute = this.compute(vectors); - creator.withVector(compute); - } - Result result = creator.withProperties(BeanUtil.toMap(entity)).run(); - return !result.hasErrors(); - } - - /** - * 对象批量保存向量数据库 - * @param entities 保存对象列表 - * @param className 保存表名 - * @param attrsMap 待计算的列信息 key-向量名 value-实体类对象属性,多个按逗号分隔 - * @return 保存操作结果 - */ - public Boolean saveBatch(List entities,String className, Map attrsMap) { - ObjectCreator creator = weaviateClient.data().creator().withClassName(className); - List vectorStrs = Lists.newArrayList(); - List attrs = Lists.newArrayList(); - if(Func.isNotEmpty(attrsMap)) { - // 格式化数据 - attrsMap.forEach((k,v) -> attrs.add(v)); - // 解析待计算的向量字段 - entities.forEach(entity -> { - List vectorStr = attrs.stream().map(fields -> this.getFieldValue(fields, entity)).filter(Func::isNotEmpty).collect(Collectors.toList()); - vectorStrs.addAll(vectorStr); - }); - } - if(Func.isNotEmpty(vectorStrs)) { - // 若解析出来的向量存在值 - Float[] vectors = this.compute(vectorStrs); - List> vector = this.splitVector(entities.size(), attrsMap, vectors); - for(int i = 0; i < entities.size(); i++) { - // log.info("vector:{}",JSON.toJSONString(vector.get(i))); - Map properties = this.objectToMap(entities.get(i)); - log.info("properties:{}",JSON.toJSONString(properties)); - Result run = creator.withProperties(properties).withVectors(vector.get(i)).run(); - if(run.hasErrors()) { - log.error("保存失败!,保存结果为:{}",JSON.toJSONString(run)); - } - } - } else { - entities.forEach(entity -> creator.withProperties(this.objectToMap(entity)).run()); - return true; - } - return false; - } - - private Map objectToMap(Object object) { - JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object)); - Map properties = new HashMap<>(); - jsonObject.forEach((k,v) -> { - if("id".equalsIgnoreCase(k)) { - properties.put("id_",v); - } else { - properties.put(k,v); - } - }); - return properties; - } - - /** - * 删除向量数据库(表名) - * @param className 表名 - * @return 删除结果 - */ - public Boolean delete(String ids,String className) { - ObjectDeleter deleter = weaviateClient.data().deleter(); - deleter.withClassName(className); - if(Func.isEmpty(ids)) { - Result> allObject = weaviateClient.data().objectsGetter().withClassName(className).withLimit(10000).run(); - if(!allObject.hasErrors()) { - ids = allObject.getResult().stream().map(WeaviateObject::getId).collect(Collectors.joining(",")); - } - } - Func.toStrList(",",ids).forEach(id -> { - Result result = deleter.withID(id).run(); - if(result.hasErrors()) { - throw new HzServiceException(ResultCode.FAILURE,id + "记录删除失败!"); - } - }); - return true; - } - - /** - * 更新数据库(通过ID) - * @param id 向量数据库ID - * @return 更新结果 - */ - public Boolean updateById(String id, Object entity, String className, Map attrMap) { - ObjectUpdater updater = weaviateClient.data().updater().withClassName(className).withID(id).withProperties(BeanUtil.toMap(entity)); - // 计算向量 - Map vector = new HashMap<>(); - if(Func.isNotEmpty(attrMap)) { - attrMap.forEach((k,v) -> { - String fieldValue = this.getFieldValue(v, entity); - Float[] compute = this.compute(Lists.newArrayList(fieldValue)); - vector.put(k,compute); - }); - } - if(Func.isNotEmpty(vector)) { - updater.withVectors(vector); - } - Result result = updater.run(); - return !result.hasErrors(); - } - - public List list(String id,String className,Integer current,Integer pageSize) { - ObjectsGetter objectsGetter = weaviateClient.data().objectsGetter(); - if(Func.isNotEmpty(id)) { - objectsGetter.withID(id); - } - if(Func.isNotEmpty(className)) { - objectsGetter.withClassName(className); - } - Result> result = objectsGetter.withLimit(pageSize).withOffset((current-1) * pageSize).run(); - if(result.hasErrors()) { - throw new HzServiceException("查询失败!"); - } - return result.getResult(); - } - - /** - * 拆解计算出来的向量Float[] - * @param entitySize 对象列表size - * @param attrsMap 待计算的列信息 key-向量名 value-实体类对象属性,多个按逗号分隔 - * @param vectorTotal 计算出的向量总量 - * @return 拆解结果 - */ - private List> splitVector(Integer entitySize,Map attrsMap,Float[] vectorTotal) { - List> result = Lists.newArrayList(); - List vectorTotalList = Lists.newArrayList(vectorTotal); - // 获取待切割的下标 - List indexes = this.getSplitIndex(vectorTotal.length, entitySize); - int step = vectorTotal.length / entitySize; - indexes.forEach(index -> { - List vectors = vectorTotalList.subList(index, index + step); - Map vectorMap = new HashMap<>(); - List splitIndex = this.getSplitIndex(vectors.size(), attrsMap.size()); - AtomicInteger i = new AtomicInteger(); - attrsMap.forEach((k,v) -> { - List vector = vectors.subList(splitIndex.get(i.get()), splitIndex.get(i.get()) + (vectors.size() / attrsMap.size())); - vectorMap.put(k, vector.toArray(new Float[vector.size()])); - i.getAndIncrement(); - }); - result.add(vectorMap); - }); - return result; - } - - /** - * 获取将list等量分隔成若干份的列表下标 - * @param size 总数 - * @param splitNum 分隔数量 - * @return 下标集合 - */ - private List getSplitIndex(int size,int splitNum) { - if(size % splitNum != 0) { - throw new HzServiceException("向量计算失败,无法根据同步对象进行等量分隔!"); - } - return IntStream.iterate(0, index -> index + 1) - .limit(splitNum) - .mapToObj(index -> index * (size / splitNum)) - .collect(Collectors.toList()); - } - - - private String getFieldValue(String fields,Object object) { - JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object)); - return Func.toStrList(",", fields).stream().map(field -> jsonObject.getString(field)).collect(Collectors.joining(" ")); - } - - /** - * 计算向量值 - * @param vectors 待计算的向量 - * @return 向量值Float[] - */ - private Float[] compute(List vectors) { - // 向量计算 - String url = vectorUrl + invokeApi.getCompute(); - String jsonData = JSONUtil.toJsonStr(vectors); - HttpResponse response = HttpRequest.post(url) - .header("Content-Type", "application/json; charset=utf-8") - .body(jsonData) - .execute(); - byte[] bytes = response.bodyBytes(); - if (bytes.length % 4 != 0) { - throw new HzServiceException("向量计算失败!响应数据长度不是4的倍数"); - } - List chunks = new ArrayList<>(); - int range = bytes.length / 4; - IntStream.range(0, range) - .forEach(index -> { - byte[] chunk = new byte[4]; - int page = index * 4; - chunk[0] = bytes[page]; - chunk[1] = bytes[page + 1]; - chunk[2] = bytes[page + 2]; - chunk[3] = bytes[page + 3]; - chunks.add(chunk); - }); - List floats = chunks.stream().map(b -> { - ByteBuffer buffer = ByteBuffer.wrap(b).order(ByteOrder.LITTLE_ENDIAN); - return buffer.getFloat(); - }).collect(Collectors.toList()); - return floats.toArray(new Float[floats.size()]); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/util/WeaviateUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/util/WeaviateUtil.java deleted file mode 100644 index 1c056ce..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/util/WeaviateUtil.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.database.util; - -/** - * @Author: huangxing - * @Date: 2024/08/23 10:09 - */ -public class WeaviateUtil { - - - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java deleted file mode 100644 index ad3bb77..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; - -import java.util.Arrays; -import java.util.Optional; - -/** - * @Author: huangxing - * @Date: 2024/06/21 10:49 - */ -@AllArgsConstructor -@Getter -public enum DataAuthTypeEnum { - /**站点鉴权**/ - STATION("station"), - DEPT("dept"), - ; - private final String type; - - public static DataAuthTypeEnum getEnumByType(String type) { - Optional typeEnumOptional = Arrays.stream(DataAuthTypeEnum.class.getEnumConstants()).filter(e -> e.getType().equals(type)).findFirst(); - return typeEnumOptional.orElse(null); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java deleted file mode 100644 index 49a117b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * @Author: huangxing - * @Date: 2024/05/29 08:31 - */ -@AllArgsConstructor -public enum DataMethodEnum { - USUAL("详情",6,"详情"), - EARLIEST("最早值",0,"最早值"), - MAX("最大值",1,"最大值"), - MIN("最小值",2,"最小值"), - AVERAGE("平均值",3,"平均值"), - SUM("累计值/和值",4,"总和值"), - DIFFERENCE("变化值/差值",5,"变化值"), - LATEST("最新值",6,"最新值"), - ; - @Getter - private String name; - @Getter - private Integer accessRule; - @Getter - private String method; - - public static DataMethodEnum getEnumByMethod(String method) { - return Arrays.stream(DataMethodEnum.class.getEnumConstants()) - .filter(e -> e.getMethod().equals(method)) - .findFirst().orElse(null); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java deleted file mode 100644 index a615988..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * @Author: huangxing - * @Date: 2024/05/28 11:37 - */ -@AllArgsConstructor -public enum DateEnum { - YEAR("year","每年","按年",5,6), - MONTH("month","每月","按月",4,5), - DAY("day","每天","按天",3,3), - HOUR("hour","每小时","按小时",2,2), - MINUTE("minute","每分钟","按分钟",1,1), - SECOND("second","每秒","按秒",0,0), - USUAL("usual","详情","按秒",0,0) - ; - @Getter - private String code; - @Getter - private String name; - @Getter - private String dateType; - @Getter - private int order; - @Getter - private Integer saveTimeType; - - public static DateEnum getDateEnumByType(String dateType) { - return Arrays.stream(DateEnum.class.getEnumConstants()).filter(d -> d.getDateType().equals(dateType)).findFirst().orElse(null); - } - - public static DateEnum getDateEnumByOrder(int order) { - return Arrays.stream(DateEnum.class.getEnumConstants()).filter(d -> d.getOrder() == order).findFirst().orElse(null); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java deleted file mode 100644 index 79f6c08..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; -import java.util.Optional; - -/** - * @Author: huangxing - * @Date: 2024/04/30 11:41 - */ -@AllArgsConstructor -public enum FuncRouteEnum { - OPEN_CANVAS("open_canvas","打开实时画面",FunctionConstants.TypeEnum.JUMP), - OPEN_VIDEO("open_video","打开视频监控",FunctionConstants.TypeEnum.PARAMS), - DIAGNOSE("result_diagnose","智能诊断",FunctionConstants.TypeEnum.PARAMS), - CHOOSE_STATION("choose_station","选择站点",FunctionConstants.TypeEnum.CHOOSE), - CHOOSE_VIDEO("choose_video","选择视频",FunctionConstants.TypeEnum.CHOOSE), - CHOOSE_CANVAS("choose_canvas","选择画面",FunctionConstants.TypeEnum.CHOOSE), - CHOOSE_FAULT("choose_fault","选择故障",FunctionConstants.TypeEnum.CHOOSE), - CHOOSE_YK("choose_yk","选择遥控",FunctionConstants.TypeEnum.CHOOSE), - CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), - SHOW_PARAM("result_record","设备参数查询", FunctionConstants.TypeEnum.PARAMS), - CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE), - HISTORY_DATA("history_data","查询历史数据",FunctionConstants.TypeEnum.CHART), - CONTROL_DEVICE("control_device","设备控制",FunctionConstants.TypeEnum.PARAMS), - SHOW_DATA("show_data","智能分析",FunctionConstants.TypeEnum.PARAMS) - ; - @Getter - private String func; - @Getter - private String funcName; - @Getter - private FunctionConstants.TypeEnum type; - - public static FuncRouteEnum getEnumByFuncCode(String funcCode) { - Optional FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFunc())).findFirst(); - return FuncRoute.orElse(null); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java deleted file mode 100644 index 097d57e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; -import java.util.Optional; - -/** - * @Author: huangxing - * @Date: 2024/04/26 13:29 - */ -public interface FunctionConstants { - - @AllArgsConstructor - enum TypeEnum { - /**跳转页面**/ - JUMP("1"), - /**链接**/ - LINK("2"), - /**参数**/ - PARAMS("3"), - /**选项**/ - CHOOSE("4"), - /**确认**/ - CONFIRM("5"), - CHART("6"), - IMAGE_TEXT("7") - ; - ; - @Getter - private String type; - - public static TypeEnum getTypeEnumByType (String type) { - Optional typeEnumOptional = Arrays.stream(TypeEnum.class.getEnumConstants()).filter(e -> type.equals(e.getType())).findFirst(); - return typeEnumOptional.orElse(null); - } - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java deleted file mode 100644 index 6663556..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -/** - * @Author: huangxing - * @Date: 2024/06/21 16:35 - */ -public interface InfoMessageConstant { - - String ERROR_MESSAGE = "非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。"; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java deleted file mode 100644 index 5032198..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -/** - * @Author: huangxing - * @Date: 2024/07/01 14:26 - * @Describe: 参数key管理 - */ -public interface ParamKeyConstants { - - /**实时画面host**/ - String CANVAS_HOST = "hzims:bigModel:canvas:host"; - /**实时画面v3路径 {context}&stationNum={stationNum}&projectId={projectId}**/ - String CANVAS_V3_PATH = "hzims:bigModel:canvas:v3:path"; - /**实时画面v4路径 other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}**/ - String CANVAS_V4_PATH = "hzims:bigModel:canvas:v4:path"; - /**实时画面云组态路径 hzinfo-data-scada/view/{projectId}/{id}?source=app**/ - String CANVAS_YZT_PATH = "hzims:bigModel:canvas:yzt:path"; - /**视频巡检指令编号**/ - String VIDEO_INSPECTION_CODE = "gglm:bigModel:video:inspection:code"; - /**视频巡检识别url**/ - String VIDEO_INSPECTION_URL = "gglm:bigModel:video:inspection:url"; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java deleted file mode 100644 index 069572a..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @Author: huangxing - * @Date: 2024/05/21 16:34 - */ -@AllArgsConstructor -public enum ProjectRemoteTypeEnum { - /**不允许发送遥控**/ - NOT_ALLOW(0), - /**运行发送遥控并且需要校验权限**/ - VALID(1), - /**运行发送遥控并免校验权限**/ - ALLOW(2), - ; - @Getter - private Integer ctrlType; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java deleted file mode 100644 index ea935c1..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * @Author: huangxing - * @Date: 2024/05/24 17:14 - */ -@AllArgsConstructor -public enum SearchStationTypeEnum { - STATION_TOTAL("电站总数量",null,"智能运维平台接入电站总数为:%s"), - SET_TOTAL("站点总数量",null,"智能运维平台接入站点总数为:%s"), - HYDROPOWER_TOTAL("水电站总数量","0","智能运维平台接入水电站总数为:%s"), - WIND_POWER_TOTAL("风电场总数量","1","智能运维平台接入风电场总数为:%s"), - ENERGY_STORAGE_TOTAL("储能站总数量","3","智能运维平台接入储能站总数为:%s"), - PHOTOVOLTAIC_TOTAL("光伏站总数量","5","智能运维平台接入光伏站总数为:%s"), - CHARGE_TOTAL("充电站总数量","7","智能运维平台接入充电站总数为:%s"), - STATION_NUM("电站接入量",null,"智能运维平台接入电站总数为:%s"), - SET_NUM("站点接入量",null,"智能运维平台接入站点总数为:%s"), - HYDROPOWER_NUM("水电站接入量","0","智能运维平台接入水电站接入量为:%s"), - WIND_POWER_NUM("风电场接入量","1","智能运维平台接入风电场接入量为:%s"), - ENERGY_STORAGE_NUM("储能站接入量","3","智能运维平台接入储能站接入量为:%s"), - PHOTOVOLTAIC_NUM("光伏站接入量","5","智能运维平台接入光伏站接入量为:%s"), - CHARGE_NUM("充电站接入量","7","智能运维平台接入充电站接入量为:%s"), - ; - - @Getter - private String searchStationType; - @Getter - private String stationType; - @Getter - private String label; - - public static SearchStationTypeEnum getTypeEnum(String searchStationType) { - return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants()) - .filter(e -> e.getSearchStationType().equals(searchStationType)) - .findFirst() - .orElse(null); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java deleted file mode 100644 index 0692d62..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; - -import java.util.Arrays; - -/** - * @Author: huangxing - * @Date: 2024/05/24 17:13 - */ -@AllArgsConstructor -public enum SearchTypeEnum { - REAL("实时"), - HISTORY("历史") - ; - @Getter - private String searchType; - - public static SearchTypeEnum getSearchType(String searchType) { - return Arrays.stream(SearchTypeEnum.class.getEnumConstants()) - .filter(e -> e.getSearchType().equals(searchType)) - .findFirst() - .orElse(null); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java deleted file mode 100644 index b7cab25..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.controller; - -import com.baomidou.mybatisplus.core.toolkit.IdWorker; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.IResultCode; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/06/24 14:19 - */ -@RestController -@RequestMapping("/fontEnd/interactive") -@Api(value = "前端交互控制层",tags = "前端交互控制层") -@AllArgsConstructor -public class FontEndInteractiveController { - - private final IHznlmInvokeService hznlmInvokeService; - - @ApiOperation("提问") - @ApiOperationSupport(order = 1) - @GetMapping("/ask") - public R ask(@RequestParam @ApiParam("用户提出问题") String question, @RequestParam @ApiParam("问答sessionId") String sessionId, @RequestParam @ApiParam("用户Id") String userId) { - hznlmInvokeService.ask(question, sessionId, userId); - return R.success("操作成功!"); - } - - @ApiOperation("删除对话sessionId") - @ApiOperationSupport(order = 2) - @GetMapping("/removeSessionId") - public R removeSessionId(@RequestParam(value = "id") String sessionId) { - hznlmInvokeService.removeSessionId(sessionId); - return R.success("操作成功!"); - } - - @ApiOperation("获取热点问题") - @ApiOperationSupport(order = 3) - @GetMapping("/hotQuestions") - public R hotQuestions() { - return R.data(hznlmInvokeService.hotQuestions()); - } - - @ApiOperation("获取问答sessionId") - @ApiOperationSupport(order = 4) - @GetMapping("/getSessionId") - public R getSessionId() { - return R.data(IdWorker.get32UUID()); - } - - @ApiOperation("中断当前的问答") - @ApiOperationSupport(order = 5) - @GetMapping("/interruptSession") - public R interruptSession(@RequestParam(value = "id") String sessionId) { - hznlmInvokeService.interruptSession(sessionId); - return R.success("操作成功!"); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java deleted file mode 100644 index 4f5dccc..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.business.service.DataSourceService; -import com.hnac.hzims.bigmodel.business.vo.SqlVO; -import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; -import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO; -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; -import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/21 10:21 - */ -@RestController -@AllArgsConstructor -@Api(value = "HZLLM大模型交互层",tags = "HZLLM大模型交互层") -@RequestMapping("/hzn_lm/interactive") -public class HznlmInteractiveController { - - private final IHznlmInteractiveService interactiveService; - private final DataSourceService dataSourceService; - - @PostMapping(value = "/get_auth_data") - @ApiOperation("获取鉴权数据") - @ApiOperationSupport(order = 1) - public R> getAuthData(@RequestBody AuthDataDTO req) { - return R.data(interactiveService.getAuthData(req)); - } - - @ApiOperation("解析大模型函数") - @ApiOperationSupport(order = 2) - @PostMapping("/resolve") - public R resolve(@RequestBody ModelFunctionReq req) { - return R.data(interactiveService.resolve(req)); - } - - @PostMapping("/execute_query") - @ApiOperation("执行大模型sql") - @ApiOperationSupport(order = 3) - public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { - return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); - } - - @PostMapping("/control_device") - @ApiOperation("控制设备") - @ApiOperationSupport(order = 4) - public R controlDevice(@RequestBody @Valid ControlDTO req) { - return R.data(interactiveService.controlDevice(req)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java deleted file mode 100644 index b891ec0..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/06/21 10:39 - */ -@Data -@ApiModel(value = "获取权限接口传参格式",description = "获取权限接口传参格式") -@EqualsAndHashCode -public class AuthDataDTO implements Serializable { - - @JsonProperty("chatId") - @ApiModelProperty("问答ID,用于获取前端发起问答传入缓存中数据") - @NotBlank - private String sessionId; - - @ApiModelProperty("提问用户ID") - @NotBlank - private String userId; - - @ApiModelProperty("鉴权类型") - @NotBlank - private String type; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java deleted file mode 100644 index 12aefc3..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.factory; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; -import com.hnac.hzinfo.exception.HzServiceException; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.api.ResultCode; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.SpringUtil; - -/** - * @Author: huangxing - * @Date: 2024/06/21 18:44 - */ -public class AnswerResolveFactory { - - public static final String DIAGNOSE_ANSWER_SERVICE = "diagnoseAnswerResolveService"; - public static final String CHOICE_ANSWER_SERVICE = "choiceAnswerResolveService"; - public static final String REMOTE_ANSWER_SERVICE = "remoteAnswerResolveService"; - public static final String PARAM_ANSWER_SERVICE = "paramAnswerResolveService"; - public static final String PRE_ANSWER_SERVICE = "preAnswerResolveService"; - public static final String CONTROL_DEVICE_SERVICE = "controlAnswerResolveService"; - - public static IAnswerResolveService getResolveService(Object extra) { - String funcCode = JSONObject.parseObject(JSON.toJSONString(extra)).getString("func"); - return AnswerResolveFactory.getResolveService(funcCode); - } - - public static IAnswerResolveService getResolveService(String funcCode) { - FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); - if(Func.isNotEmpty(funcRouteEnum)) { - switch (funcRouteEnum) { - case DIAGNOSE: - return SpringUtil.getBean(DIAGNOSE_ANSWER_SERVICE); - case CHOOSE_VIDEO: - case CHOOSE_CANVAS: - case CHOOSE_STATION: - case CHOOSE_FAULT: - case CHOOSE_YC: - case CHOOSE_YK: - return SpringUtil.getBean(CHOICE_ANSWER_SERVICE); - case CONFIRM_YK: - return SpringUtil.getBean(REMOTE_ANSWER_SERVICE); - case SHOW_PARAM: - return SpringUtil.getBean(PARAM_ANSWER_SERVICE); - case CONTROL_DEVICE: - return SpringUtil.getBean(CONTROL_DEVICE_SERVICE); - default: - return null; - } - } - throw new HzServiceException(ResultCode.DEFAULT_NULL_MESSAGE,"service解析失败!"); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java deleted file mode 100644 index 897fb21..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.factory; - -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.service.IResolveService; -import com.hnac.hzinfo.exception.HzServiceException; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.api.ResultCode; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.SpringUtil; - -/** - * @Author: huangxing - * @Date: 2024/06/21 15:53 - */ -@Slf4j -public class ResolveFactory { - - public static final String CANVAS_RESOLVE_SERVICE = "canvasResolveService"; - public static final String VIDEO_RESOLVE_SERVICE = "videoResolveService"; - - /** - * 获取解析函数需要的service - * @param funcCode 函数编号 - * @return 解析函数所需service - */ - public static IResolveService getResolveService(String funcCode) { - FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); - if(Func.isNotEmpty(funcRouteEnum)) { - switch(funcRouteEnum) { - case OPEN_CANVAS: - return SpringUtil.getBean("canvasResolveService"); - case OPEN_VIDEO: - return SpringUtil.getBean("videoResolveService"); - default: - log.error("函数解析失败,函数编号为:{}", funcCode); - throw new HzServiceException(ResultCode.FAILURE,"service解析失败"); - } - } - throw new ServiceException("service解析失败"); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java deleted file mode 100644 index d290dab..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service; - -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; - -/** - * @Author: huangxing - * @Date: 2024/05/28 11:29 - */ -public interface IAnalyseDataService { - - ExtraVO getHistoryData(HistoryDataSearchVO searchVO); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java deleted file mode 100644 index 4800164..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; - -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * @Author: huangxing - * @Date: 2024/06/21 18:39 - */ -public interface IAnswerResolveService { - - AnswerVO resolve(AnswerVO answer); - - /** - * 解析 extra - * @param originExtra 大模型传入 extra - * @return 解析后的 extra - */ - ExtraVO getExtra(JSONObject originExtra); - - /*** - * - * @param answer - * @return - */ - default Stream extraStream(AnswerVO answer) { - return Arrays.stream(answer.getExtras()).map(JSON::toJSONString).map(JSONObject::parseObject); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java deleted file mode 100644 index c9aed6b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service; - -import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; -import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO; -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; -import org.springframework.web.bind.annotation.RequestBody; - -import javax.validation.Valid; -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/06/21 10:23 - */ -public interface IHznlmInteractiveService { - - List getAuthData(AuthDataDTO req); - - ExtraVO resolve(ModelFunctionReq req); - - ExtraVO controlDevice(ControlDTO req); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java deleted file mode 100644 index 2ef2107..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service; - -import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; -import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.question.dto.QuestionDTO; - -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/21 17:20 - */ -public interface IHznlmInvokeService { - - /** - * 基础问题 - * @param question 提问问题 - * @param sessionId 会话ID - * @param userId 提问人ID - * @return 提问结果 - */ - @Deprecated - void ask(String question, String sessionId, String userId); - - void ask(QuestionDTO question); - - /** - * 特殊问题 - * @param sessionId 会话ID - * @param userId 提问人ID - * @param extra 特殊问题内容 - * @return 提问结果 - */ - @Deprecated - void specialAsk(String sessionId, String userId, Map extra); - - void specialAsk(QuestionDTO questionDTO); - - /** - * 知识库问题 - * @param question 问题名称 - * @param sessionId 会话ID - * @param userId 提问人ID - * @param knowledge 知识库名称 - */ - @Deprecated - void knowledgeAsk(String question, String sessionId, String userId, String knowledge); - - void knowledgeAsk(QuestionDTO questionDTO); - - /** - * 发起数据分析问答 - * @param questionDTO - */ - void analyseAsk(QuestionDTO questionDTO); - - /** - * 删除对话记录 - * @param sessionId 会话ID - */ - void removeSessionId(String sessionId); - - /** - * 获取热点问题 - * @return 热点问题 - */ - List hotQuestions(); - - /** - * 查询问答状态 - * @param sessionIds 会话ID,按逗号分隔 - * @return 答案列表 - */ - List getAnswerBySessionIds(String sessionIds); - - /** - * 中断当前的问答 - * @param sessionId 会话ID - */ - void askAbort(String sessionId); - - void interruptSession(String sessionId); - - /** - * 发起机组发电量智能报表分析问答 - * @param req 待分析的数据 - */ - void smartReportGeneratePower(RunReportAnalyseRequest req); - - /** - * 更新数据 - * @param name 数据名 - */ - void updateKnowledge(String name); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java deleted file mode 100644 index 19a5869..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service; - -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; - -/** - * @Author: huangxing - * @Date: 2024/06/21 15:39 - */ -public interface IResolveService { - - ExtraVO resolve(String id); - - ExtraVO resolve(ModelFunctionReq req); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java deleted file mode 100644 index 9b59e99..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.business.service.HistoryDataService; -import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; -import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; -import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/05/28 11:29 - */ -@Service -@AllArgsConstructor -public class AnalyseDataServiceImpl implements IAnalyseDataService { - - private final HistoryDataService historyDataService; - - @Override - public ExtraVO getHistoryData(HistoryDataSearchVO searchVO) { - if(Func.isEmpty(searchVO.getDataType()) || StringUtil.isBlank(searchVO.getDataType()) - || DataMethodEnum.USUAL.getMethod().equals(searchVO.getMethod())) { - searchVO.setDataType(DateEnum.SECOND.getDateType()); - } - // 聚合数据方式处理 - DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); - searchVO.setDataType(dateEnum.getDateType()); - // 获取最适配时间段 - DateEnum adapterDate = historyDataService.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum); - String note = adapterDate.getDateType().equals(searchVO.getDataType()) ? "" : "(由于数据量过大,只能帮您" + adapterDate.getDateType() + "查询)"; - searchVO.setDataType(adapterDate.getDateType()); - ExtraVO extraVO = new ExtraVO(); - extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); - extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFunc()); - Map params = new HashMap<>(1); - Result reductionDataVOR = historyDataService.getPolymerizationData(searchVO); - String label; - if(!reductionDataVOR.isSuccess()) { - params.put("errorInfo",reductionDataVOR.getMsg()); - label = "查询数据失败!"; - } - else { - ReductionDataVO dataVO = reductionDataVOR.getData(); - label = "暂未查到数据"; - params.put("data",Lists.newArrayList()); - if(Func.isNotEmpty(dataVO) && CollectionUtil.isNotEmpty(dataVO.getDataList())) { - List datalist = dataVO.getDataList().stream().map(m -> { - m.put("val", m.get(searchVO.getSignage())); - m.remove(searchVO.getSignage()); - return m; - }).collect(Collectors.toList()); - DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); - if(CollectionUtil.isNotEmpty(datalist)) { - label = searchVO.getStationName() + "_" - + searchVO.getDeviceName() + "_" - + dataVO.getFieldMap().get(searchVO.getSignage()) + "_" - + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : adapterDate.getName()) - + enumByMethod.getMethod() - + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : note) - + ":"; - } - params.put("data",datalist); - } - } - extraVO.setLabel(label); - params.put("deviceName",searchVO.getDeviceName()); - params.put("attrName",searchVO.getAttrName()); - params.put("stationName",searchVO.getStationName()); - params.put("beginTime",searchVO.getStartTime()); - params.put("endTime",searchVO.getEndTime()); - extraVO.setParams(params); - return extraVO; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java deleted file mode 100644 index 4cd0717..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.ParamKeyConstants; -import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.service.IResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.operational.station.feign.IStationClient; -import com.hnac.hzinfo.exception.HzServiceException; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.api.ResultCode; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; -import org.springblade.system.cache.ParamCache; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.*; -import java.util.stream.IntStream; - -/** - * @Author: huangxing - * @Date: 2024/06/21 15:39 - */ -@Service(ResolveFactory.CANVAS_RESOLVE_SERVICE) -@AllArgsConstructor -@Slf4j -public class CanvasResolveServiceImpl implements IResolveService { - - private final IStationClient stationClient; - - @Override - public ExtraVO resolve(ModelFunctionReq req) { - Map args = req.getItem(); - String id = args.get("itemId"); - String name = args.get("itemName"); - Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> { - log.error("解析传参错误,缺少必要参数video_id,传参内容为:{}", JSON.toJSONString(req)); - throw new HzServiceException(ResultCode.FAILURE,"解析传参错误,缺少必要参数video_id"); - }); - return this.resolve(id); - } - - @Override - public ExtraVO resolve(String id) { - ExtraVO extraVO = new ExtraVO(); - extraVO.setImmediatelyJump(true); - extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); - final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; - String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST); - // 将ID解析为 - Map resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE); - R stationR = stationClient.getStationByCode(resolveMap.get("projectId")); - extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + resolveMap.get("name")); - int picResource = Integer.parseInt(resolveMap.get("picResource")); - Map extraParams = new HashMap<>(1); - extraParams.put("picResource",picResource); - extraVO.setParams(extraParams); - // 云组态 - if(picResource == 0) { - String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_YZT_PATH), resolveMap); - extraVO.setRoute(canvasHost + path); - } - // v3.0 - else if(picResource == 1) { - String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_V3_PATH), resolveMap); - extraVO.setRoute(canvasHost + path); - } - // v4.0 - else if (picResource == 2) { - // pic_name 去掉头部的/ 以及尾部的.js - String context = resolveMap.get("context"); - context = this.removeHeadChars(context,"/"); - context = this.removeTailChars(context,".js"); - resolveMap.put("context",context); - extraVO.setRoute(this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&itemName={itemName}", resolveMap)); - } - else { - throw new HzServiceException(ResultCode.FAILURE,"解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由"); - } - return extraVO; - } - - public Map resolve(String paramsStr, String... keys) { - Map result = new HashMap<>(); - List params = Func.toStrList("\\^", paramsStr); - Assert.isTrue(params.size() == keys.length, () -> { - throw new HzServiceException(ResultCode.FAILURE, "大模型传参params长度错误,传参为:" + paramsStr); - }); - IntStream.iterate(0, index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index))); - return result; - } - - private String replacePath(String path,Map params) { - Set> entries = params.entrySet(); - // 替换path中变量 - for (Map.Entry entry : entries) { - String replaceVariables = "{" + entry.getKey() + "}"; - path = StringUtil.replace(path,replaceVariables,entry.getValue()); - } - return path; - } - - public String removeHeadChars(String str, String charsToRemove) { - if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { - return str; - } - while (str.startsWith(charsToRemove)) { - str = str.substring(charsToRemove.length()); - } - return str; - } - - public String removeTailChars(String str, String charsToRemove) { - if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { - return str; - } - while (str.endsWith(charsToRemove)) { - str = str.substring(0, str.length() - charsToRemove.length()); - } - return str; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java deleted file mode 100644 index f6495f1..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; -import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import groovy.util.logging.Slf4j; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/06/21 19:02 - * @Describe 选项答案解析服务层 - */ -@AllArgsConstructor -@Service(AnswerResolveFactory.CHOICE_ANSWER_SERVICE) -@Slf4j -public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService { - - @Override - public AnswerVO resolve(AnswerVO answer) { - Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); - answer.setExtras(extraArray); - return answer; - } - - @Override - public ExtraVO getExtra(JSONObject originExtra) { - ExtraVO result = JSONObject.parseObject(JSON.toJSONString(originExtra),ExtraVO.class); - result.setSpecial(true); - result.setType(FuncRouteEnum.getEnumByFuncCode(result.getFunc()).getType().getType()); - return result; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java deleted file mode 100644 index 2159025..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import cn.hutool.http.HttpRequest; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; -import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.Func; -import org.springblade.system.cache.ParamCache; -import org.springframework.stereotype.Service; -import com.hnac.hzims.bigmodel.interactive.constants.ParamKeyConstants; - -import java.util.HashMap; - -/** - * @Author: huangxing - * @Date: 2024/08/30 11:33 - */ -@Service(AnswerResolveFactory.CONTROL_DEVICE_SERVICE) -@Slf4j -public class ControlAnswerResolveServiceImpl implements IAnswerResolveService { - - @Override - public AnswerVO resolve(AnswerVO answer) { - Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); - answer.setExtras(extraArray); - return answer; - } - - @Override - public ExtraVO getExtra(JSONObject originExtra) { - // 若extra中 itemId 为 spxj 则为视频巡检需特殊处理 - JSONObject params = originExtra.getJSONObject("params"); - if(Func.isNotEmpty(params) && Func.isNotEmpty(params.getString("itemId"))) { - String itemId = ParamCache.getValue(ParamKeyConstants.VIDEO_INSPECTION_CODE); - String url = ParamCache.getValue(ParamKeyConstants.VIDEO_INSPECTION_URL); - if(Func.isNotEmpty(itemId) && Func.isNotEmpty(url) - && itemId.equals(params.getString("itemId")) && Func.isNotEmpty(params.getString("stationId"))) { - log.info("控制指令传参为:{}", JSON.toJSONString(originExtra)); - String stationId = params.getString("stationId"); - HashMap param = new HashMap<>(1); - param.put("stationId",stationId); - String body = HttpRequest.post(url).body(JSON.toJSONString(param)).execute().body(); - params.put("data",body); - log.info("识别结果为:{}", body); - } - } - ExtraVO result = originExtra.toJavaObject(ExtraVO.class); - result.setType(FunctionConstants.TypeEnum.IMAGE_TEXT.getType()); - return result; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java deleted file mode 100644 index fa94148..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; -import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import groovy.util.logging.Slf4j; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/21 18:59 - */ -@Service(AnswerResolveFactory.DIAGNOSE_ANSWER_SERVICE) -@Slf4j -@AllArgsConstructor -public class DiagnoseAnswerResolveServiceImpl implements IAnswerResolveService { - - @Override - public AnswerVO resolve(AnswerVO answer) { - Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); - answer.setExtras(extraArray); - return answer; - } - - @Override - public ExtraVO getExtra(JSONObject originExtra) { - ExtraVO result = new ExtraVO(); - JSONObject data = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data"))); - Map params = new HashMap<>(5); - params.put("faultId",data.getString("fault_id")); - params.put("name",data.getString("fault_name")); - params.put("station",data.getString("station_id")); - params.put("fdpDeviceName",data.getString("device_name")); - params.put("fdpOrd",data.getString("ord")); - result.setParams(params); - String funcCode = originExtra.getString("func"); - result.setFunc(funcCode); - result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); - return result; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java deleted file mode 100644 index b22a790..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; -import com.hnac.hzims.bigmodel.business.feign.IAuthClient; -import com.hnac.hzims.bigmodel.business.service.AuthenticationService; -import com.hnac.hzims.bigmodel.interactive.constants.DataAuthTypeEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; -import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO; -import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; -import com.hnac.hzims.bigmodel.interactive.service.IResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import groovy.util.logging.Slf4j; -import lombok.AllArgsConstructor; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.system.dto.DeptStationDTO; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/06/21 10:24 - */ -@Service -@AllArgsConstructor -@Slf4j -public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService { - - private final AuthenticationService authenticationService; - private final IAuthClient authClient; - - @Override - public List getAuthData(AuthDataDTO req) { - DataAuthTypeEnum authTypeEnum = DataAuthTypeEnum.getEnumByType(req.getType()); - switch(authTypeEnum) { - case STATION: - return this.getStationAuthData(req.getUserId()); - case DEPT: - return this.getDeptAuthData(req.getUserId()); - default: - throw new ServiceException(req.getType() + "改类型获取权限数据暂不支持"); - } - } - - @Override - public ExtraVO resolve(ModelFunctionReq req) { - IResolveService resolveService = ResolveFactory.getResolveService(req.getFunc()); - return resolveService.resolve(req); - } - - @Override - public ExtraVO controlDevice(ControlDTO req) { - ExtraVO result = new ExtraVO(); - Optional optional = req.getYks().stream().map(controlDeviceDTO -> { - ControlDeviceAuthDTO deviceAuthDTO = BeanUtil.copy(controlDeviceDTO, ControlDeviceAuthDTO.class); - deviceAuthDTO.setUserId(req.getUserId()); - return deviceAuthDTO; - }).filter(d -> authClient.remoteAuth(d).isSuccess()).findFirst(); - Assert.isTrue(optional.isPresent(),() -> { - throw new ServiceException("鉴权失败!!"); - }); - // 封装返回的extra - result.setFunc(FuncRouteEnum.CONTROL_DEVICE.getFunc()); - result.setType(FuncRouteEnum.CONTROL_DEVICE.getType().getType()); - Map params = BeanUtil.toMap(optional.get()); - params.put("value", req.getValue()); - result.setParams(params); - return result; - } - - public List getDeptAuthData(String userId) { - List deptStationDTOs = authenticationService.getStationPermissionsById(userId); - return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList()); - } - - public List getStationAuthData(String userId) { - List deptStationDTOs = authenticationService.getStationPermissionsById(userId); - return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getItemId())).collect(Collectors.toList()); - } - - private AuthDataVO convertStationAuthData(DeptStationDTO req) { - return new AuthDataVO(req.getStationId(),req.getDeptName()); - } - - private AuthDataVO convertDeptAuthData(DeptStationDTO req) { - return new AuthDataVO(String.valueOf(req.getDeptId()),req.getDeptName()); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java deleted file mode 100644 index 48e9881..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -import com.baomidou.mybatisplus.core.toolkit.IdWorker; -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; -import com.hnac.hzims.bigmodel.business.feign.IAuthClient; -import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO; -import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.manager.SessionRedisManager; -import com.hnac.hzims.bigmodel.question.dto.QuestionDTO; -import com.hnac.hzims.bigmodel.utils.RequestClientUtil; -import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; -import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; -import com.hnac.hzims.common.constant.CommonConstant; -import com.hnac.hzinfo.exception.HzServiceException; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * @Author: huangxing - * @Date: 2024/06/21 17:20 - * @Describe HZN_LM大模型接口调用服务层 - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class HznlmInvokeServiceImpl implements IHznlmInvokeService { - - private final BigModelInvokeApi bigModelInvokeApi; - private final SessionRedisManager sessionRedisManager; - private final IAuthClient authClient; - private final RedisTemplate redisTemplate; - - @Value("${gglm.url}") - private String gglmUrl; - - @Override - public void ask(String question, String sessionId, String userId) { - Map params = new HashMap<>(); - params.put("chat_id",sessionId); - params.put("user_id", userId); - params.put("query",question); - Map authDataIds = this.getAuthDataIds(userId); - params.putAll(authDataIds); - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); - sessionRedisManager.addSessionId(sessionId); - } - - @Override - public void ask(QuestionDTO question) { - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), JSON.toJSONString(question)); - sessionRedisManager.addSessionId(question.getChatId()); - } - - @Override - public void specialAsk(String sessionId, String userId, Map extra) { - Map params = new HashMap<>(); - params.put("chat_id",sessionId); - params.put("user_id", userId); - params.put("extra",extra); - Map authDataIds = this.getAuthDataIds(userId); - params.putAll(authDataIds); - log.info("调用大模型接口:{},传参为:{}",gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(),JSON.toJSONString(params)); - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params); - sessionRedisManager.addSessionId(sessionId); - } - - @Override - public void specialAsk(QuestionDTO question) { - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(question)); - sessionRedisManager.addSessionId(question.getChatId()); - } - - @Override - public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { - Map params = new HashMap<>(); - params.put("chat_id", sessionId); - params.put("user_id", userId); - params.put("query", question); - params.put("knowledge", knowledge); - Map authDataIds = this.getAuthDataIds(userId); - params.putAll(authDataIds); - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); - sessionRedisManager.addSessionId(sessionId); - } - - @Override - public void knowledgeAsk(QuestionDTO question) { - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(question)); - sessionRedisManager.addSessionId(question.getChatId()); - } - - @Override - public void analyseAsk(QuestionDTO question) { - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(question)); - sessionRedisManager.addSessionId(question.getChatId()); - } - - @Override - public void removeSessionId(String sessionId) { - this.askAbort(sessionId); - // 移除内存sessionId - InteractiveSessionManager.SESSION_POOL.remove(sessionId); - sessionRedisManager.removeSessionId(sessionId); - } - - @Override - public void askAbort(String sessionId) { - Map params = new HashMap<>(); - params.put("chat_id",sessionId); - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params); - sessionRedisManager.removeSessionId(sessionId); - } - - public void interruptSession(String sessionId) { - this.askAbort(sessionId); - // 循环获取该会话ID中断状态,当状态等于-2或重连超6次则中断返回结果 - int status = 999; - int attempts = 0; - while (status > 0) { - // 若重连超过10次 则抛出错误 - if(attempts >= 8) { - throw new HzServiceException("中断失败!长时间未获取到中断状态"); - } - List answers = this.getAnswerBySessionIds(sessionId); - if(Func.isNotEmpty(answers)) { - log.info(answers.get(0).getStatus()+""); - status = answers.get(0).getStatus(); - } - // 若获取到的状态不等于2 则延时0.5秒 - if(status > 0) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - attempts ++; - } - } - - @Override - public void smartReportGeneratePower(RunReportAnalyseRequest req) { - Map params = new HashMap<>(); - String sessionId = IdWorker.get32UUID(); - params.put("chat_id",sessionId); - params.put("user_id", CommonConstant.SYSTEM_USER.toString()); - params.put("data", req.getAnalyseDTOS()); - params.put("query", ""); - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params); - // 将sessionId存入redis,拿到数据之后输入月报中 - JSONObject report = new JSONObject(); - report.put("stationCode",req.getStationCode()); - report.put("month",req.getMonth()); - report.put("sessionId",sessionId); - redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID,JSON.toJSONString(report)); - redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID,5, TimeUnit.MINUTES); - } - - @Override - public void updateKnowledge(String name) { - Map params = new HashMap<>(); - params.put("name",name); - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params); - } - - @Override - public List hotQuestions() { - try { - return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference>(){}); - } - catch (Exception e) { - log.error("An error occurred",e); - return Lists.newArrayList(); - } - } - - @Override - public List getAnswerBySessionIds(String sessionIds) { - Map params = new HashMap<>(); - params.put("chat_ids",Func.toStrList(",",sessionIds).toArray()); - return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference>(){}); - } - - private Map getAuthDataIds(String userId) { - Map result = new HashMap<>(2); - R> authDataR = authClient.getAuthData(userId); - result.putAll(authDataR.getData()); - return result; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java deleted file mode 100644 index 8a52994..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; -import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; -import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; -import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.*; -import com.xxl.job.core.log.XxlJobLogger; -import groovy.util.logging.Slf4j; -import lombok.AllArgsConstructor; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/21 19:02 - */ -@Service(AnswerResolveFactory.PARAM_ANSWER_SERVICE) -@Slf4j -@AllArgsConstructor -public class ParamAnswerResolveServiceImpl implements IAnswerResolveService { - - private final IAnalyseDataService analyseDataService; - - public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS"; - - @Override - public AnswerVO resolve(AnswerVO answer) { - Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); - answer.setExtras(extraArray); - return answer; - } - - @Override - public ExtraVO getExtra(JSONObject originExtra) { - DataVO data = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")),DataVO.class); - Assert.isTrue(Func.isNotEmpty(data),() -> { - XxlJobLogger.log("解析参数答案失败,extra不能为空!"); - throw new ServiceException("解析参数答案失败,extra不能为空!"); - }); - if(Func.isNotEmpty(data.getReal())) { - // 处理查询实时数据 - RealDataVO real = data.getReal(); - Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); - real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); - } - else if(StringUtil.isNotBlank(data.getType()) && SearchTypeEnum.HISTORY.getSearchType().equals(data.getType())) { - // 处理查询历史数据 - return this.getHistoryData(data); - } - String funcCode = originExtra.getString("func"); - ExtraVO result = new ExtraVO(); - result.setFunc(funcCode); - result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); - Map param = new HashMap(1); - param.put("data", data); - result.setParams(param); - return result; - } - - /** - * 查询历史数据 - * @param data 大模型识别数据信息 - * @return 历史数据 - */ - private ExtraVO getHistoryData(DataVO data) { - // 确认查询聚合方式传入 - Assert.isTrue(Func.isNotEmpty(data.getItem()) && StringUtil.isNotBlank(data.getMethod()),() -> { - XxlJobLogger.log("历史数据查询方式为空,查询失败!"); - throw new ServiceException("历史数据查询方式为空,查询失败!"); - }); - return analyseDataService.getHistoryData(this.convertHistoryDataSearch(data)); - } - - /** - * 获取历史数据查询对象 - * @param data 大模型解析点位信息 - * @return 历史数据查询对象 - */ - private HistoryDataSearchVO convertHistoryDataSearch(DataVO data) { - HistoryDataSearchVO searchVO = new HistoryDataSearchVO(); - DataItemVO item = data.getItem(); - searchVO.setDataType(data.getDataType()); - searchVO.setAttrName(item.getAttrName()); - searchVO.setDeviceCode(item.getDeviceId()); - searchVO.setDeviceName(item.getDeviceName()); - searchVO.setStationName(item.getProjectName()); - searchVO.setMethod(data.getMethod()); - searchVO.setSignage(item.getSignage()); - searchVO.setStartTime(data.getStartTime()); - searchVO.setEndTime(data.getEndTime()); - return searchVO; - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java deleted file mode 100644 index 09cc711..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; -import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.RemoteParamVO; -import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; -import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; -import groovy.util.logging.Slf4j; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/21 19:02 - */ -@Service(AnswerResolveFactory.REMOTE_ANSWER_SERVICE) -@Slf4j -@AllArgsConstructor -public class RemoteAnswerResolveServiceImpl implements IAnswerResolveService { - - private final DeviceClient deviceClient; - - @Override - public AnswerVO resolve(AnswerVO answer) { - Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); - answer.setExtras(extraArray); - return answer; - } - - @Override - public ExtraVO getExtra(JSONObject originExtra) { - ExtraVO result = new ExtraVO(); - RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")), RemoteParamVO.class); - String funcCode = originExtra.getString("func"); - result.setFunc(funcCode); - result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); - R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); - if(funcVOR.isSuccess()) { - Map param = new HashMap(); - param.put("control",funcVOR.getData()); - param.put("deviceName",remoteParam.getDeviceName()); - param.put("projectName",remoteParam.getProjectName()); - param.put("deviceCode",remoteParam.getDeviceId()); - param.put("value",remoteParam.getValue()); - result.setParams(param); - } - return result; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java deleted file mode 100644 index 68a883e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.service.IResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; -import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; -import com.hnac.hzinfo.exception.HzServiceException; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.api.ResultCode; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/21 16:17 - */ -@Service(ResolveFactory.VIDEO_RESOLVE_SERVICE) -@AllArgsConstructor -@Slf4j -public class VideoResolveServiceImpl implements IResolveService { - - private final IStationVideoTypeClient videoClient; - - @Override - public ExtraVO resolve(ModelFunctionReq req) { - Map args = req.getItem(); - String id = args.get("itemId"); - String name = args.get("itemName"); - Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> { - log.error("解析传参错误,缺少必要参数video_id,传参内容为:{}", JSON.toJSONString(req)); - throw new HzServiceException(ResultCode.FAILURE, "解析传参错误,缺少必要参数video_id"); - }); - return this.resolve(id); - } - - @Override - public ExtraVO resolve(String idStr) { - Long id = Long.valueOf(idStr); - // 跳转页面逻辑 - ExtraVO extraVO = new ExtraVO(); - R videoR = videoClient.getById(Long.valueOf(id)); - if(videoR.isSuccess()) { - StationVideoTypeEntity video = videoR.getData(); - extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); - extraVO.setImmediatelyJump(true); - extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFunc()); - Map params = new HashMap<>(); - params.put("name", video.getName()); - params.put("videoHost", video.getVideoHost()); - params.put("pointCode", video.getPointCode()); - params.put("appKey", video.getAppKey()); - params.put("appSecret", video.getAppSecret()); - params.put("liveSourceAddress",video.getLiveSourceAddress()); - extraVO.setParams(params); - } - return extraVO; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java deleted file mode 100644 index b5621d3..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import com.hnac.hzims.bigmodel.interactive.constants.InfoMessageConstant; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import org.springblade.core.tool.utils.BeanUtil; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/06 14:37 - */ -@Data -@ApiModel("HZLLM答案VO对象") -@EqualsAndHashCode -@AllArgsConstructor -@NoArgsConstructor -public class AnswerVO implements Serializable { - - @ApiModelProperty("发起问答时的随机ID") - @JSONField(name = "chat_id") - private String chatId; - - @ApiModelProperty("发起问答时的用户ID") - @JSONField(name = "user_id") - private String userId; - - @ApiModelProperty("1代表代表正在进行问答,0代表已完成") - private Integer running; - - /** - * 正常发起一次问答,status会经历0、1、2、3、9、0的过程,如果问答需要执行多次指令,则可能会是0、1、2、3、2、3、9、0。 - * 9为大模型回复中,answer中会不断填充内容 - */ - @ApiModelProperty("1代表代表正在进行问答,0代表已完成") - private Integer status; - - @ApiModelProperty("当running为1时,用于显示状态文本") - private String text; - - @ApiModelProperty("最近一次发起的问题") - private String query; - - @ApiModelProperty("query对应的答案") - private String answer; - - @ApiModelProperty("其它调用的参数") - private Object[] extras; - - @ApiModelProperty("用于语音回复的状态文本") - @JSONField(name = "voice_text") - private String[] voiceText; - - @ApiModelProperty("用于语音回复的答案") - @JSONField(name = "voice_answer") - private String[] voiceAnswer; - - public static AnswerVO error(String sessionId,String userId,String query) { - return new AnswerVO(sessionId,userId,0,-2,null,query, InfoMessageConstant.ERROR_MESSAGE, null,null,new String[]{InfoMessageConstant.ERROR_MESSAGE}); - } - - public static AnswerVO progress(String sessionId,String userId,String query,String message,Integer status) { - return new AnswerVO(sessionId,userId,1,status,null,query, message, null,null,new String[]{message}); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java deleted file mode 100644 index dafd6e7..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/06/21 10:26 - */ -@Data -@AllArgsConstructor -@ApiModel(value = "鉴权数据VO",description = "鉴权数据VO,包含站点、机构、遥控权限") -@EqualsAndHashCode -public class AuthDataVO implements Serializable { - - @ApiModelProperty("数据ID") - private String itemId; - - @ApiModelProperty("数据名称") - private String itemName; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java deleted file mode 100644 index 0728206..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import lombok.Data; - -import javax.validation.constraints.NotBlank; - -/** - * @Author: huangxing - * @Date: 2024/05/28 11:48 - */ -@Data -public class HistoryDataSearchVO { - - @NotBlank - private String startTime; - - @NotBlank - private String endTime; - - @NotBlank - private String deviceCode; - - @NotBlank - private String signage; - - private String attrName; - - @NotBlank - private String method; - - private String dataType; - - private String stationName; - - private String deviceName; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java deleted file mode 100644 index 6448893..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/20 14:46 - */ -@Data -@EqualsAndHashCode -public class RemoteParamVO implements Serializable { - - @JSONField(name = "itemId") - private String funcId; - - @JSONField(name = "yk_name") - private String remoteName; - - @JSONField(name = "device_id") - private String deviceId; - - @JSONField(name = "device_name") - private String deviceName; - - @JSONField(name = "station_id") - private String projectId; - - @JSONField(name = "station_name") - private String projectName; - - private String signage; - - private String value; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java deleted file mode 100644 index f24b67e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.hnac.hzims.bigmodel.interactive.constants.InfoMessageConstant; -import io.swagger.annotations.ApiModel; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/06/21 16:31 - */ -@EqualsAndHashCode -@Data -@AllArgsConstructor -@ApiModel(value = "解析结果",description = "解析结果") -public class ResolveResultVO implements Serializable { - - private String content; - - private ExtraVO extraVO; - - public static ResolveResultVO error() { - return new ResolveResultVO(InfoMessageConstant.ERROR_MESSAGE,null); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java deleted file mode 100644 index 1de0532..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/20 19:31 - */ -@Data -@EqualsAndHashCode -public class SessionContentVO implements Serializable { - - /**机器码**/ - private String machineCode; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java deleted file mode 100644 index d111b70..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/25 14:03 - */ -@Data -public class StationSearchVO implements Serializable { - - private String startTime; - - private String endTime; - - @NotBlank(message = "查询类型不能为空") - private String type; - - private String enumType; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java deleted file mode 100644 index 3ed167a..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/09 09:50 - */ -@Data -public class UpdateStationVO implements Serializable { - - /**站点ID**/ - private String id; - - /**站点名称**/ - private String name; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java deleted file mode 100644 index 88a9c73..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/09 09:53 - */ -@Data -public class UpdateUsualVO implements Serializable { - - /**站点ID**/ - @JSONField(name = "station_id") - private String stationId; - - /**业务ID**/ - private String id; - - /**业务名称**/ - private String name; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java deleted file mode 100644 index 32b9fa6..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/AgentLogController.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; -import com.hnac.hzims.bigmodel.maintenance.service.AgentLogService; -import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; -import com.hnac.hzims.bigmodel.maintenance.vo.LabelRequest; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springframework.web.bind.annotation.*; - -/** - * @Author: ypj - * @Date: 2024/9/9 10:37 - */ -@RestController -@Slf4j -@AllArgsConstructor -@RequestMapping("/label") -@Api(value = "问题标注", tags = "问题标注") -public class AgentLogController { - private final AgentLogService agentLogService; - - @GetMapping("/listPage") - @ApiOperation(value = "分页查询") - @ApiOperationSupport(order = 1) - public R> listPage(Query query, AgentLogEntity req) { - return R.data(agentLogService.listPage(Condition.getPage(query), req)); - } - - @GetMapping("/detail") - @ApiOperation(value = "查看详情") - @ApiOperationSupport(order = 2) - public R detail(@RequestParam @ApiParam("主键ID") Long id) { - return R.data(agentLogService.getById(id)); - } - - @PostMapping("/save") - @ApiOperation(value = "保存") - @ApiOperationSupport(order = 3) - public R save(@RequestBody AgentLogEntity req) { - return R.status(agentLogService.save(req)); - } - - @DeleteMapping("/remove") - @ApiOperation(value = "删除") - @ApiOperationSupport(order = 4) - public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { - return R.status(agentLogService.removeByIds(Func.toLongList(",", ids))); - } - - @PutMapping("/update") - @ApiOperation(value = "编辑") - @ApiOperationSupport(order = 5) - public R update(@RequestBody AgentLogEntity req) { - return R.status(agentLogService.updateById(req)); - } - - @PutMapping("/batchLabel") - @ApiOperation(value = "批量标注") - @ApiOperationSupport(order = 6) - public R BatchLabel(@RequestBody IdsRequest ids) { - return R.status(agentLogService.BatchLabel(ids)); - } - - @PutMapping("/label") - @ApiOperation(value = "标注") - @ApiOperationSupport(order = 7) - public R label(@RequestBody LabelRequest req) { - return R.status(agentLogService.label(req)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/ControlController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/ControlController.java deleted file mode 100644 index 17f18bc..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/ControlController.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import com.hnac.hzims.bigmodel.maintenance.entity.ControlEntity; -import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; -import com.hnac.hzims.bigmodel.maintenance.service.ControlService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -/** - * @Author: huangxing - * @Date: 2024/08/19 18:50 - */ -@RestController -@RequestMapping("/control") -@Api(tags = "设备控制指令管理",value = "设备控制指令管理") -@AllArgsConstructor -public class ControlController { - - private final ControlService service; - private final IHznlmInvokeService invokeService; - - @GetMapping("/listPage") - @ApiOperation(value = "分页查询") - @ApiOperationSupport(order = 1) - public R> listPage(Query query, ControlEntity req) { - return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); - } - - @GetMapping("/detail") - @ApiOperation(value = "查看详情") - @ApiOperationSupport(order = 2) - public R detail(@RequestParam @ApiParam("主键ID") Long id) { - return R.data(service.getById(id)); - } - - @PostMapping("/save") - @ApiOperation(value = "保存设备控制指令配置") - @ApiOperationSupport(order = 3) - public R save(@RequestBody ControlEntity req) { - return R.status(service.save(req)); - } - - @DeleteMapping("/remove") - @ApiOperation(value = "删除设备控制指令配置") - @ApiOperationSupport(order = 4) - public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { - return R.status(service.removeByIds(Func.toLongList(",",ids))); - } - - @PutMapping("/updateById") - @ApiOperation(value = "编辑设备控制指令") - @ApiOperationSupport(order = 5) - public R updateById(@RequestBody ControlEntity req) { - return R.status(service.updateById(req)); - } - - @PutMapping("/updateKnowledge") - @ApiOperation(value = "更新设备控制知识库") - @ApiOperationSupport(order = 6) - public R updateKnowledge() { - invokeService.updateKnowledge("yk"); - return R.success("操作成功!"); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java deleted file mode 100644 index 91989c1..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; -import com.hnac.hzims.bigmodel.maintenance.service.DataSourceService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/07/05 16:55 - */ -@RestController -@RequestMapping("/datasource") -@Api(value = "数据源管理",tags = "数据源管理") -public class DataSourceController { - - @Autowired - @Qualifier("dataSourceMaintenanceService") - private DataSourceService dataSourceService; - - @GetMapping("/listPage") - @ApiOperation(value = "分页查询") - @ApiOperationSupport(order = 1) - public R> listPage(Query query, DatasourceEntity req) { - return R.data(dataSourceService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); - } - - @GetMapping("/detail") - @ApiOperation(value = "查看详情") - @ApiOperationSupport(order = 2) - public R detail(@RequestParam @ApiParam("主键ID") Long id) { - return R.data(dataSourceService.getById(id)); - } - - @PostMapping("/save") - @ApiOperation(value = "保存数据源配置") - @ApiOperationSupport(order = 3) - public R save(@RequestBody DatasourceEntity req) { - return R.status(dataSourceService.save(req)); - } - - @DeleteMapping("/remove") - @ApiOperation(value = "删除数据源配置") - @ApiOperationSupport(order = 4) - public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { - return R.status(dataSourceService.removeByIds(Func.toLongList(",",ids))); - } - - @PutMapping("/update") - @ApiOperation(value = "编辑数据源配置") - @ApiOperationSupport(order = 5) - public R update(@RequestBody DatasourceEntity req) { - return R.status(dataSourceService.updateById(req)); - } - - @GetMapping("/list") - @ApiOperation(value = "列表查询") - @ApiOperationSupport(order = 1) - public R> list(DatasourceEntity req) { - return R.data(dataSourceService.list(Condition.getQueryWrapper(req).lambda())); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java deleted file mode 100644 index e6a7008..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; -import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileInfoService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.oss.model.BladeFile; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springblade.resource.feign.IOssClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -/** - * @Author: ypj - * @Date: 2024/9/10 16:44 - */ -@RestController -@Slf4j -@RequestMapping("/knowledge/file") -@Api(value = "知识库文件管理", tags = "知识库文件管理") -@AllArgsConstructor -public class KnowledgeFileInfoController { - private final KnowledgeFileInfoService knowledgeFileInfoService; - private final IOssClient ossClient; - - @GetMapping("/listPage") - @ApiOperation(value = "分页查询") - @ApiOperationSupport(order = 1) - public R> listPage(Query query, KnowledgeFileInfo req) { - return R.data(knowledgeFileInfoService.page(Condition.getPage(query), - Condition.getQueryWrapper(new KnowledgeFileInfo(), req).orderByDesc(KnowledgeFileInfo::getCreateTime))); - } - - @GetMapping("/detail") - @ApiOperation(value = "查看详情") - @ApiOperationSupport(order = 2) - public R detail(@RequestParam @ApiParam("主键ID") Long id) { - return R.data(knowledgeFileInfoService.getById(id)); - } - - @PostMapping("/save") - @ApiOperation(value = "保存") - @ApiOperationSupport(order = 3) - public R save(@RequestBody KnowledgeFileInfo req) { - return R.status(knowledgeFileInfoService.save(req)); - } - - @PutMapping("/update") - @ApiOperation(value = "编辑") - @ApiOperationSupport(order = 4) - public R update(@RequestBody KnowledgeFileInfo req) { - return R.status(knowledgeFileInfoService.updateById(req)); - } - - @DeleteMapping("/remove") - @ApiOperation(value = "删除") - @ApiOperationSupport(order = 5) - public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { - return R.status(knowledgeFileInfoService.removeByIds(Func.toLongList(",", ids))); - } - - @PostMapping(value = "/upload", produces = MediaType.APPLICATION_PROBLEM_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - @ApiOperation(value = "上传文件") - @ApiOperationSupport(order = 6) - public R upload(@ApiParam(value = "上传文件", required = true) @RequestPart("file") MultipartFile file) { - return ossClient.putFile(file); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java deleted file mode 100644 index f9bc2fe..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.maintenance.service.TableColumnService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/07/04 09:28 - */ -@RestController -@RequestMapping("/table/info") -@Api(value = "数据库表、列信息查询管理",tags = "数据库表、列信息查询管理") -@AllArgsConstructor -public class TableColumnController { - - private final TableColumnService tableColumnService; - - @ApiOperation("获取数据库") - @ApiOperationSupport(order = 1) - @GetMapping("/getDatabase") - public R>> getDatabase(@RequestParam @ApiParam(value = "数据源名") String datasource) { - return R.data(tableColumnService.getDatabase(datasource)); - } - - @ApiOperation("获取数据库表列表") - @ApiOperationSupport(order = 2) - @GetMapping("/getTables") - public R>> getTables(@RequestParam @ApiParam(value = "数据源名") String datasource, - @RequestParam @ApiParam(value = "数据库名") String database) { - return R.data(tableColumnService.getTables(datasource,database)); - } - - @ApiOperation("获取数据库表列列表") - @ApiOperationSupport(order = 3) - @GetMapping("/getColumns") - public R>> getColumns(String datasource, - @RequestParam @ApiParam(value = "数据源名") String database, - @RequestParam @ApiParam(value = "数据库表名") String tableName) { - return R.data(tableColumnService.getColumns(datasource,database,tableName)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java deleted file mode 100644 index d723842..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; -import com.hnac.hzims.bigmodel.maintenance.service.TableInfoService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - -/** - * @Author: huangxing - * @Date: 2024/07/04 15:26 - */ -@RestController -@RequestMapping("/tableInfo") -@Api(value = "数据库信息管理",tags = "数据库信息管理") -@AllArgsConstructor -public class TableInfoController { - - private final TableInfoService tableInfoService; - - @PostMapping("/save") - @ApiOperation("保存数据库信息") - @ApiOperationSupport(order = 1) - public R save(@RequestBody @Valid TableInfoEntity req) { - return R.data(tableInfoService.save(req)); - } - - @PostMapping("/update") - @ApiOperation("编辑数据库信息") - @ApiOperationSupport(order = 2) - public R update(@RequestBody TableInfoEntity req) { - return R.data(tableInfoService.updateById(req)); - } - - @GetMapping("/listPage") - @ApiOperation("数据库信息列表查询") - @ApiOperationSupport(order = 3) - public R> listPage(Query query, TableInfoEntity req) { - return R.data(tableInfoService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); - } - - @DeleteMapping("/removeByIds") - @ApiOperation("删除数据库信息") - @ApiOperationSupport(order = 4) - public R removeByIds(@RequestParam @ApiParam("id,按逗号分隔") String ids) { - return R.status(tableInfoService.removeByIds(Func.toLongList(",",ids))); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java deleted file mode 100644 index 1961bef..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; -import com.hnac.hzims.bigmodel.maintenance.service.TablePropertyService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/07/05 15:19 - */ -@RestController -@RequestMapping("/table/property") -@Api(value = "表配置",tags = "表配置") -@AllArgsConstructor -public class TablePropertyController { - - private final TablePropertyService tablePropertyService; - - @GetMapping("/listPage") - @ApiOperation(value = "分页查询") - @ApiOperationSupport(order = 1) - public R> listPage(Query query, TablePropertyEntity req) { - return R.data(tablePropertyService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); - } - - @GetMapping("/detail") - @ApiOperation(value = "查看详情") - @ApiOperationSupport(order = 2) - public R detail(@RequestParam @ApiParam("主键ID") Long id) { - return R.data(tablePropertyService.getById(id)); - } - - @PostMapping("/save") - @ApiOperation(value = "保存表配置") - @ApiOperationSupport(order = 3) - public R save(@RequestBody TablePropertyEntity req) { - return R.status(tablePropertyService.save(req)); - } - - @DeleteMapping("/remove") - @ApiOperation(value = "删除表配置") - @ApiOperationSupport(order = 4) - public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { - return R.status(tablePropertyService.removeByIds(Func.toLongList(",",ids))); - } - - @PutMapping("/update") - @ApiOperation(value = "编辑表配置") - @ApiOperationSupport(order = 5) - public R update(@RequestBody TablePropertyEntity req) { - return R.status(tablePropertyService.updateById(req)); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java deleted file mode 100644 index e178519..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity; -import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService; -import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; -import com.hnac.hzinfo.api.annotation.ApiInterface; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @Author: ypj - * @Date: 2024/9/2 16:10 - */ -@RestController -@RequestMapping("/vector") -@Api(value = "向量参数配置", tags = "向量参数配置") -@AllArgsConstructor -@Slf4j -public class VectorParamController { - private final VectorParamService vectorParamService; - - @GetMapping("/listPage") - @ApiOperation(value = "分页查询") - @ApiOperationSupport(order = 1) - public R> listPage(Query query, VectorParamEntity req) { - return R.data(vectorParamService.page(Condition.getPage(query), Condition.getQueryWrapper(new VectorParamEntity(), req))); - } - - @GetMapping("/detail") - @ApiOperation(value = "查看详情") - @ApiOperationSupport(order = 2) - public R detail(@RequestParam @ApiParam("主键ID") Long id) { - return R.data(vectorParamService.getById(id)); - } - - @PostMapping("/save") - @ApiOperation(value = "保存向量参数配置") - @ApiOperationSupport(order = 3) - public R save(@RequestBody VectorParamEntity req) { - return R.status(vectorParamService.save(req)); - } - - @DeleteMapping("/remove") - @ApiOperation(value = "删除向量参数配置") - @ApiOperationSupport(order = 4) - public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { - return R.status(vectorParamService.removeByIds(Func.toLongList(",", ids))); - } - - @PutMapping("/update") - @ApiOperation(value = "编辑向量参数配置") - @ApiOperationSupport(order = 5) - public R update(@RequestBody VectorParamEntity req) { - return R.status(vectorParamService.updateById(req)); - } - - @GetMapping("/getAuthorization") - @ApiOperation(value = "获取向量参数配置授权信息") - @ApiOperationSupport(order = 6) - public R getAuthorization() { - return R.data(vectorParamService.getAuthorization()); - } - - @GetMapping("/getUrlResponse") - @ApiOperation(value = "通过url获取向量参数数据") - @ApiOperationSupport(order = 7) - public R getUrlResponse(@RequestParam String url, - @RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, - @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken) throws JsonProcessingException { - return R.data(vectorParamService.getUrlResponse(url, bladeToken, hzinfoToken)); - } - - @GetMapping("/getTestData") - @ApiOperation(value = "测试数据") - @ApiOperationSupport(order = 8) - @ApiInterface - public R getUrlByte() { - Map data = new HashMap<>(); - data.put("name", "测试数据"); - data.put("url", "https://img.zcool.cn/community/01d9d85a8f9f2fa801206e0d0e0e9a.jpg@1280w_1l_2o_100sh.jpg"); - data.put("data", "data"); - List list = new java.util.ArrayList<>(); - list.add(data); - return R.data(list); - } - - @GetMapping("/getUrlResponseKeyList") - @ApiOperation(value = "获取url返回的key列表") - @ApiOperationSupport(order = 9) - public R> getUrlResponseKeyList(@RequestParam String url, - @RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, - @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken) throws JsonProcessingException { - return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken)); - } - - @PutMapping("/synchronization/") - @ApiOperation(value = "同步") - @ApiOperationSupport(order = 10) - public R synchronization(@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, - @RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken, @RequestBody IdsRequest req) throws JsonProcessingException { - return R.status(vectorParamService.synchronization(req.getIds(), bladeToken, hzinfoToken)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java deleted file mode 100644 index fd1d6dc..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import com.alibaba.fastjson.annotation.JSONField; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springblade.core.mp.support.QueryField; -import org.springblade.core.mp.support.SqlCondition; -import org.springblade.core.tenant.mp.TenantEntity; - -import java.io.Serializable; -import java.util.Date; - -/** - * @Author: ypj - * @Date: 2024/9/9 10:38 - */ -@ApiModel("问题标注") -@TableName("agent_log") -@Data -public class AgentLogEntity extends TenantEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @ApiModelProperty("对话id") - @TableField("chat_id") - @QueryField(condition = SqlCondition.EQUAL) - private String chatId; - - @ApiModelProperty("问题id") - @TableField("q_id") - @QueryField(condition = SqlCondition.EQUAL) - @JSONField(name = "qId") - private String qId; - - @ApiModelProperty("模型名称") - @QueryField(condition = SqlCondition.EQUAL) - @TableField("model_name") - private String modelName; - - @ApiModelProperty("问题来源") - @QueryField(condition = SqlCondition.EQUAL) - private String agent; - - @ApiModelProperty("问题") - @QueryField(condition = SqlCondition.LIKE) - private String q; - - @ApiModelProperty("问题提示") - @QueryField(condition = SqlCondition.LIKE) - @TableField("prompt") - @JSONField(name = "prompt") - private String prompt; - - @ApiModelProperty("系统提示") - @QueryField(condition = SqlCondition.LIKE) - @TableField("system") - private String system; - - @ApiModelProperty("答案") - @QueryField(condition = SqlCondition.LIKE) - private String a; - - @ApiModelProperty("用户结论,0为错误,1为正确") - @QueryField(condition = SqlCondition.EQUAL) - @TableField("user_conclusion") - private int userConclusion; - - @ApiModelProperty("标注状态,0为未标注,1为已标注") - @QueryField(condition = SqlCondition.EQUAL) - @TableField("label_status") - private int labelStatus; - - @ApiModelProperty("标注结果,0为错误,1为正确") - @QueryField(condition = SqlCondition.EQUAL) - @TableField("label_result") - private int labelResult; - - @ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样") - @QueryField(condition = SqlCondition.LIKE) - @TableField("label_content") - private String labelContent; - - @ApiModelProperty("标注人名称") - @QueryField(condition = SqlCondition.LIKE) - @TableField("label_operator") - private String labelOperator; - - @ApiModelProperty("标注时间") - @QueryField(condition = SqlCondition.EQUAL) - @TableField("label_time") - private Date labelTime; -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java deleted file mode 100644 index af8248c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import lombok.Data; -import org.springblade.core.tenant.mp.TenantEntity; - -/** - * @Author: huangxing - * @Date: 2024/07/04 15:45 - */ -@Data -public class DataRecordEntity extends TenantEntity { - - private String tableId; - - - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java deleted file mode 100644 index c4cfc79..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.mp.support.QueryField; -import org.springblade.core.mp.support.SqlCondition; -import org.springblade.core.tenant.mp.TenantEntity; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/05 14:45 - */ -@Data -@EqualsAndHashCode(callSuper=false) -@TableName("HZIMS_DATASOURCE") -@ApiModel(value = "数据源配置",description = "数据源配置") -public class DatasourceEntity extends TenantEntity implements Serializable { - - @ApiModelProperty("数据源") - @QueryField(condition = SqlCondition.EQUAL) - private String datasource; - - @ApiModelProperty("数据源名称") - @QueryField(condition = SqlCondition.LIKE) - private String datasourceName; - - @ApiModelProperty("数据库名称") - @QueryField(condition = SqlCondition.LIKE) - private String databaseName; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java deleted file mode 100644 index d3ff16d..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.tenant.mp.TenantEntity; - -import java.io.Serializable; - -/** - * @Author: ypj - * @Date: 2024/9/10 15:17 - */ -@Data -@EqualsAndHashCode(callSuper=false) -@TableName("HZIMS_KNOWLEDGE_FILE_INFO") -@ApiModel(value = "知识库文件信息",description = "知识库文件信息") -public class KnowledgeFileInfo extends TenantEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @ApiModelProperty("文件名称") - private String name; - - @ApiModelProperty("文件url") - private String url; - - @ApiModelProperty("文件大小") - private Long size; - - @ApiModelProperty("简介") - private String briefs; - - @ApiModelProperty("标签") - private String tags; - - @ApiModelProperty("业务领域") - private String domain; - - @ApiModelProperty("权限等级,5个等级") - @TableField("AUTHORITY_CLASS") - private Integer authorityClass; - - @ApiModelProperty("是否可见,0为不可见,1为可见") - private Integer visible; - - @ApiModelProperty("文件状态,0为未入库,1为已入库") - @TableField("FILE_STATUS") - private Integer fileStatus; - - @ApiModelProperty("备注") - private String remark; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/SyncPropertyEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/SyncPropertyEntity.java deleted file mode 100644 index c800041..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/SyncPropertyEntity.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.tenant.mp.TenantEntity; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/08/21 08:33 - */ -@Data -@EqualsAndHashCode -@ApiModel(value = "同步向量库基础配置",description = "同步向量库基础配置") -@TableName("") -public class SyncPropertyEntity extends TenantEntity implements Serializable { - - @ApiModelProperty("配置编号") - private String code; - - @ApiModelProperty("数据源") - private String datasource; - - @ApiModelProperty("数据源名称") - private String datasourceName; - - @ApiModelProperty("数据库表名") - private String tableName; - - @ApiModelProperty("向量数据库表名,由小写字母以及_组成") - private String vectorTableName; - - @ApiModelProperty("表描述") - private String tableDesc; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java deleted file mode 100644 index 05e9ac7..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.mp.support.QueryField; -import org.springblade.core.mp.support.SqlCondition; -import org.springblade.core.tenant.mp.TenantEntity; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/04 14:59 - */ -@Data -@TableName("mysql_table_info") -@EqualsAndHashCode -@ApiModel(value = "数据库信息",description = "数据库信息") -public class TableInfoEntity extends TenantEntity implements Serializable { - - @ApiModelProperty(value = "数据源",required = true) - @NotBlank - @QueryField(condition = SqlCondition.EQUAL) - @TableField("data_source_id") - private String datasourceId; - - @ApiModelProperty(value = "数据源名称",required = true) - @NotBlank - @QueryField(condition = SqlCondition.LIKE) - @TableField("data_source_name") - private String datasourceName; - - @ApiModelProperty(value = "数据库",required = true) - @NotBlank - @QueryField(condition = SqlCondition.EQUAL) - private String databaseName; - - @ApiModelProperty(value = "数据库表名",required = true) - @NotBlank - @QueryField(condition = SqlCondition.EQUAL) - private String tableName; - - @ApiModelProperty(value = "数据库类型,1:Mysql",required = true) - @NotBlank - private String dbType; - - @ApiModelProperty(value = "数据库表描述信息",required = true) - @NotBlank - @QueryField(condition = SqlCondition.LIKE) - private String tableDesc; - - @ApiModelProperty(value = "数据库表列信息",required = true) - @NotBlank - private String propDesc; - - @ApiModelProperty("举例") - private String example; - - @ApiModelProperty("表注表信息中的字段对应的向量库的表字段查询") - @QueryField(condition = SqlCondition.LIKE) - private String filterJson; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java deleted file mode 100644 index 003d46b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springblade.core.mp.support.QueryField; -import org.springblade.core.mp.support.SqlCondition; -import org.springblade.core.tenant.mp.TenantEntity; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/07/05 14:49 - */ -@ApiModel("数据库表配置") -@TableName("HZIMS_TABLE_PROPERTY") -@Data -public class TablePropertyEntity extends TenantEntity implements Serializable { - - @ApiModelProperty("数据源Id") - @QueryField(condition = SqlCondition.EQUAL) - @NotNull - private Long datasourceId; - - @ApiModelProperty("数据源名称") - @QueryField(condition = SqlCondition.LIKE) - @NotNull - private String datasourceName; - - @ApiModelProperty("数据库名") - @QueryField(condition = SqlCondition.LIKE) - @NotBlank - private String databaseName; - - @ApiModelProperty("数据表名") - @QueryField(condition = SqlCondition.LIKE) - @NotBlank - private String tableName; - - @ApiModelProperty("鉴权类型") - @QueryField(condition = SqlCondition.EQUAL) - @NotBlank - private String authType; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java deleted file mode 100644 index 6553578..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.entity; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springblade.core.mp.support.QueryField; -import org.springblade.core.mp.support.SqlCondition; -import org.springblade.core.tenant.mp.TenantEntity; - -import java.io.Serializable; - -/** - * @Author: ypj - * @Date: 2024/9/2 14:54 - */ -@ApiModel("向量参数配置") -@TableName("HZIMS_VECTOR_PARAM") -@Data -public class VectorParamEntity extends TenantEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @ApiModelProperty("参数名称") - @TableField("NAME") - @QueryField(condition = SqlCondition.LIKE) - private String name; - - @ApiModelProperty("url") - @TableField("URL") - @QueryField(condition = SqlCondition.LIKE) - private String url; - - @ApiModelProperty("项目前缀") - @TableField("PROJECT_PREFIX") - @QueryField(condition = SqlCondition.LIKE) - private String projectPrefix; - - @ApiModelProperty("数据库表名") - @TableField("TABLE_NAME") - @QueryField(condition = SqlCondition.LIKE) - private String tableName; - - @ApiModelProperty("向量键值对,json格式") - @TableField("ATTRIBUTE_MAP") - @QueryField(condition = SqlCondition.LIKE) - private String attributeMap; - - @ApiModelProperty("备注") - @TableField("REMARK") - @QueryField(condition = SqlCondition.LIKE) - private String remark; -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/AgentLogMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/AgentLogMapper.java deleted file mode 100644 index fe6747d..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/AgentLogMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; - -/** - * @Author: ypj - * @Date: 2024/9/9 11:07 - */ -public interface AgentLogMapper extends BaseMapper { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/ControlMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/ControlMapper.java deleted file mode 100644 index 470d734..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/ControlMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.mapper; - -import com.hnac.hzims.bigmodel.maintenance.entity.ControlEntity; -import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; - -/** - * @Author: huangxing - * @Date: 2024/08/19 18:42 - */ -public interface ControlMapper extends UserDataScopeBaseMapper { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java deleted file mode 100644 index b62ce18..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; - -/** - * @Author: huangxing - * @Date: 2024/07/05 15:05 - */ -public interface DatasourceMapper extends BaseMapper { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/KnowledgeFileInfoMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/KnowledgeFileInfoMapper.java deleted file mode 100644 index ed64b9a..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/KnowledgeFileInfoMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; - -/** - * @Author: ypj - * @Date: 2024/9/10 16:41 - */ -public interface KnowledgeFileInfoMapper extends BaseMapper { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java deleted file mode 100644 index f451a78..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; - -/** - * @Author: huangxing - * @Date: 2024/07/04 15:25 - */ -public interface TableInfoMapper extends BaseMapper { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java deleted file mode 100644 index e4d1333..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; - -/** - * @Author: huangxing - * @Date: 2024/07/05 15:12 - */ -public interface TablePropertyMapper extends BaseMapper { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/VectorParamMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/VectorParamMapper.java deleted file mode 100644 index 6d779e7..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/VectorParamMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity; - -/** - * @Author: ypj - * @Date: 2024/09/02 15:12 - */ -public interface VectorParamMapper extends BaseMapper { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java deleted file mode 100644 index 00da361..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/AgentLogService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; -import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; -import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; -import com.hnac.hzims.bigmodel.maintenance.vo.LabelRequest; - -/** - * @Author: ypj - * @Date: 2024/9/9 11:08 - */ -public interface AgentLogService extends IService { - Boolean BatchLabel(IdsRequest ids); - - Boolean label(LabelRequest req); - - IPage listPage(IPage page, AgentLogEntity req); -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/ControlService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/ControlService.java deleted file mode 100644 index 264e7ef..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/ControlService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.bigmodel.maintenance.entity.ControlEntity; -import com.hnac.hzims.bigmodel.maintenance.mapper.ControlMapper; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -/** - * @Author: huangxing - * @Date: 2024/08/19 18:48 - */ -@Service -@DS("hznlm") -@AllArgsConstructor -@Slf4j -public class ControlService extends ServiceImpl { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java deleted file mode 100644 index a58f598..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service; - -import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; -import com.hnac.hzims.bigmodel.maintenance.mapper.DatasourceMapper; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @Author: huangxing - * @Date: 2024/07/05 15:06 - */ -@Service("dataSourceMaintenanceService") -@Slf4j -@AllArgsConstructor -public class DataSourceService extends BaseServiceImpl { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java deleted file mode 100644 index 81f58c9..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; - -/** - * @Author: ypj - * @Date: 2024/9/10 16:42 - */ -public interface KnowledgeFileInfoService extends IService { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java deleted file mode 100644 index b8d4fc3..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service; - -import com.hnac.hzims.bigmodel.business.service.DataSourceService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/07/04 09:29 - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class TableColumnService { - - private final DataSourceService dataSourceService; - - public List> getDatabase(String datasource) { - String sql = "select distinct UPPER(`table_schema`) as tableName from `information_schema`.`tables` where `table_schema` <> 'information_schema';"; - return dataSourceService.queryListOnSpecificDataSource(sql,datasource); - } - - public List> getTables(String datasource,String database) { - String sql = "select distinct UPPER(`table_name`) as tableName from `information_schema`.`tables` where `table_schema` = '" + database + "';"; - return dataSourceService.queryListOnSpecificDataSource(sql,datasource); - } - - public List> getColumns(String datasource,String database,String tableName) { - String sql = "select distinct UPPER(`column_name`) as columnName,UPPER(`column_comment`) as columnComment from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; - return dataSourceService.queryListOnSpecificDataSource(sql,datasource); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java deleted file mode 100644 index e5643d5..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; -import com.hnac.hzims.bigmodel.maintenance.mapper.TableInfoMapper; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @Author: huangxing - * @Date: 2024/07/04 15:23 - */ -@Service -@AllArgsConstructor -@Slf4j -@DS("hznlm") -public class TableInfoService extends BaseServiceImpl { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java deleted file mode 100644 index f78294b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service; - -import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; -import com.hnac.hzims.bigmodel.maintenance.mapper.TablePropertyMapper; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseService; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @Author: huangxing - * @Date: 2024/07/05 15:11 - */ -@Service -@AllArgsConstructor -@Slf4j -public class TablePropertyService extends BaseServiceImpl { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java deleted file mode 100644 index 56f8269..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity; -import com.hnac.hzims.bigmodel.maintenance.vo.VectorUrlResponse; - -import java.util.List; - -/** - * @Author: ypj - * @Date: 2024/09/02 15:11 - */ - -public interface VectorParamService extends IService { - String getAuthorization(); - - VectorUrlResponse getUrlResponse(String url, String bladeToken, String hzinfoToken); - - List getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken); - - Boolean synchronization(List id ,String bladeToken, String hzinfoToken); -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java deleted file mode 100644 index 7b45d20..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.bigmodel.maintenance.entity.AgentLogEntity; -import com.hnac.hzims.bigmodel.maintenance.mapper.AgentLogMapper; -import com.hnac.hzims.bigmodel.maintenance.service.AgentLogService; -import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest; -import com.hnac.hzims.bigmodel.maintenance.vo.LabelRequest; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.secure.utils.AuthUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Service; - -import java.util.Date; - -/** - * @Author: ypj - * @Date: 2024/9/9 11:10 - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("hznlm") -public class AgentLogServiceImpl extends ServiceImpl implements AgentLogService { - - @Override - public Boolean BatchLabel(IdsRequest ids) { - Date now = new Date(); - return this.update(Wrappers.lambdaUpdate() - .set(AgentLogEntity::getLabelStatus, 1) - .set(AgentLogEntity::getLabelResult, 1) - .set(AgentLogEntity::getLabelOperator, AuthUtil.getUserName()) - .set(AgentLogEntity::getLabelTime, now) - .set(AgentLogEntity::getUpdateTime, now) - .in(AgentLogEntity::getId, ids.getIds())); - } - - @Override - public Boolean label(LabelRequest req) { - AgentLogEntity entity = this.getById(req.getId()); - if (entity != null) { - int labelResult = StringUtil.isBlank(req.getLabelContent()) || req.getLabelContent().equals(entity.getA()) ? 1 : 0; - Date now = new Date(); - return this.update(Wrappers.lambdaUpdate() - .set(AgentLogEntity::getLabelStatus, 1) - .set(AgentLogEntity::getLabelResult, labelResult) - .set(StringUtil.isNotBlank(req.getLabelContent()), AgentLogEntity::getLabelContent, req.getLabelContent()) - .set(AgentLogEntity::getLabelOperator, AuthUtil.getUserName()) - .set(AgentLogEntity::getLabelTime, now) - .set(AgentLogEntity::getUpdateTime, now) - .eq(AgentLogEntity::getId, req.getId())); - } - return false; - } - - @Override - public IPage listPage(IPage page, AgentLogEntity req) { - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() - .eq(ObjectUtil.isNotEmpty(req.getId()), AgentLogEntity::getId, req.getId()) - .eq(ObjectUtil.isNotEmpty(req.getChatId()), AgentLogEntity::getChatId, req.getChatId()) - .eq(ObjectUtil.isNotEmpty(req.getQId()), AgentLogEntity::getQId, req.getQId()) - .eq(ObjectUtil.isNotEmpty(req.getModelName()), AgentLogEntity::getModelName, req.getModelName()) - .orderByDesc(AgentLogEntity::getCreateTime) - .orderByAsc(AgentLogEntity::getChatId); - return this.page(page, queryWrapper); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java deleted file mode 100644 index 9fc1ad7..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; -import com.hnac.hzims.bigmodel.maintenance.mapper.KnowledgeFileInfoMapper; -import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileInfoService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -/** - * @Author: ypj - * @Date: 2024/9/10 16:43 - */ -@Service -@Slf4j -@AllArgsConstructor -public class KnowledgeFileInfoServiceImpl extends ServiceImpl implements KnowledgeFileInfoService { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java deleted file mode 100644 index 9a9af62..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.service.impl; - -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.hnac.hzims.bigmodel.database.service.WeaviateService; -import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity; -import com.hnac.hzims.bigmodel.maintenance.mapper.VectorParamMapper; -import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService; -import com.hnac.hzims.bigmodel.maintenance.vo.VectorUrlResponse; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import javax.servlet.http.HttpServletResponse; -import java.nio.charset.StandardCharsets; -import java.util.*; - -/** - * @Author: ypj - * @Date: 2024/9/2 16:14 - */ -@Service -@Slf4j -@AllArgsConstructor -public class VectorParamServiceImpl extends ServiceImpl implements VectorParamService { - - private static final String CLIENT_SIGN = "vector_param"; - - private final WeaviateService weaviateService; - - @Override - public String getAuthorization() { - return "Basic " + Base64.getEncoder().encodeToString(CLIENT_SIGN.getBytes(StandardCharsets.UTF_8)); - } - - @Override - public VectorUrlResponse getUrlResponse(String url, String bladeToken, String hzinfoToken) { - HttpResponse response = HttpRequest.get(url) - .header("Authorization", getAuthorization()) - .header("Blade-Auth", bladeToken) - .header("Hzinfo-Auth", hzinfoToken).execute(); - if (response.getStatus() == HttpServletResponse.SC_OK) { - String body = response.body(); - log.info("vector url response url:{}, response:{}", url, body); - try { - ObjectMapper mapper = new ObjectMapper(); - JsonNode rootNode = mapper.readTree(body); - if (rootNode.isArray()) { - return getUrlResponseByArray(rootNode); - } - JsonNode dataNode = rootNode.findValue("data"); - if (dataNode != null && dataNode.isArray()) { - return getUrlResponseByArray(dataNode); - } - if (dataNode != null) { - return getUrlResponseByObject(dataNode); - } - if (rootNode != null) { - return getUrlResponseByObject(rootNode); - } - } catch (JsonProcessingException e) { - log.error("getUrlResponse error", e); - } - } - return null; - } - - private VectorUrlResponse getUrlResponseByArray(JsonNode rootNode) throws JsonProcessingException { - VectorUrlResponse result = new VectorUrlResponse(); - result.setOriginalData(JSONArray.parseArray(rootNode.toPrettyString()).toJavaList(JSONObject.class)); - JsonNode item = rootNode.get(0); - if (item != null) { - List keyList = new ArrayList<>(); - Iterator iterator = item.fieldNames(); - while (iterator.hasNext()) { - keyList.add(iterator.next()); - } - result.setKeyList(keyList); - } - return result; - } - - private VectorUrlResponse getUrlResponseByObject(JsonNode rootNode) throws JsonProcessingException { - VectorUrlResponse result = new VectorUrlResponse(); - List originalData = new ArrayList<>(); - originalData.add(JSON.parseObject(rootNode.toPrettyString())); - result.setOriginalData(originalData); - List keyList = new ArrayList<>(); - Iterator iterator = rootNode.fieldNames(); - while (iterator.hasNext()) { - keyList.add(iterator.next()); - } - result.setKeyList(keyList); - return result; - } - - @Override - public List getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken) { - VectorUrlResponse response = getUrlResponse(url, bladeToken, hzinfoToken); - return response.getKeyList(); - } - - @Override - public Boolean synchronization(List ids, String bladeToken, String hzinfoToken) { - if (null == ids && ids.isEmpty()) { - return false; - } - for (Long id : ids) { - VectorParamEntity entity = getById(id); - if (null == entity) { - return false; - } - VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken); - if (response != null) { - ObjectMapper mapper = new ObjectMapper(); - JsonNode rootNode = null; - try { - rootNode = mapper.readTree(entity.getAttributeMap()); - } catch (JsonProcessingException e) { - log.error("getUrlResponseKeyList error", e); - } - Map attrMap = new HashMap<>(); - Iterator iterator = rootNode.fieldNames(); - while (iterator.hasNext()) { - String key = iterator.next(); - attrMap.put(key, rootNode.findValue(key).textValue()); - } - weaviateService.saveBatch(response.getOriginalData(), entity.getTableName(), attrMap); - this.update(Wrappers.lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date())); - } - } - return true; - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java deleted file mode 100644 index af3b60f..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdsRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -/** - * @Author: ypj - * @Date: 2024/9/7 11:04 - */ -@Data -@ApiModel("批量操作请求") -public class IdsRequest { - - @ApiModelProperty("主键ID,按逗号分隔") - private List ids; -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java deleted file mode 100644 index 6389578..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/LabelRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @Author: ypj - * @Date: 2024/9/10 14:04 - */ -@Data -@ApiModel("标注") -public class LabelRequest { - @ApiModelProperty("主键ID") - private Long id; - - @ApiModelProperty("标注内容,json字符串,答案类型不一样格式不一样") - private String labelContent; -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorUrlResponse.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorUrlResponse.java deleted file mode 100644 index 4728c0e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/VectorUrlResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.bigmodel.maintenance.vo; - -import lombok.Data; - -import java.util.List; - -/** - * @Author: ypj - * @Date: 2024/9/5 21:12 - */ -@Data -public class VectorUrlResponse { - private List keyList; - - private List originalData; -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java deleted file mode 100644 index 43c7af3..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.hnac.hzims.bigmodel.manager; - -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import lombok.AllArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; - -import java.util.List; - -import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; - -/** - * @Author: huangxing - * @Date: 2024/06/21 18:23 - */ -@Component -public class SessionRedisManager { - - @Autowired - private RedisTemplate redisTemplate; - - public void addSessionId(String sessionId) { - redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); - } - - public void removeSessionId(String sessionId) { - redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId); - } - - public List getSessionIds() { - return redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java deleted file mode 100644 index 6f2c729..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.hnac.hzims.bigmodel.question.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/07/10 10:22 - * @Describe: 接收前端发送消息 - */ -@Data -@EqualsAndHashCode -public class MessageDTO implements Serializable { - - /** - * 消息类型 0-心跳消息 1-问题 - */ - private String type; - - /** - * 前端提出问题 - */ - private String context; - - /** - * 前端传参附带参数 - */ - private SessionContentVO content; - - /** - * 是否发起特殊问答 - */ - private Boolean isSpecial; - - /** - * 发起问题用户ID - */ - private String userId; - - /** - * 知识库 - */ - private String knowledge; - - /** - * 会话ID - */ - private String chatId; - - /** - * 大模型函数 - */ - private String func; - - /** - * 特殊问题参数 - */ - private Map extra; - - /** - * 是否允许大模型查询数据,默认为1 - */ - @JSONField(name = "enable_record") - private int enableRecord = 1; - - /** - * 是否允许大模型发送指令,默认为1 - */ - @JSONField(name = "enable_yk") - private int enableControl = 1; - - /** - * 是否允许大模型打开视频,默认为1 - */ - @JSONField(name = "enable_video") - private int enableVideo = 1; - - /** - * 是否允许大模型打开画面,默认为1 - */ - @JSONField(name = "enable_canvas") - private int enableCanvas = 1; - - /** - * 是否允许大模型诊断故障,默认为1 - */ - @JSONField(name = "enable_fault") - private int enableFault = 1; - - /** - * 大模型默认的意图理解方式,可以为"default","yk"... - */ - @JSONField(name = "default") - private String defaultMode; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java deleted file mode 100644 index d01369e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.hnac.hzims.bigmodel.question.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/07/10 10:27 - */ -@Data -@EqualsAndHashCode -public class QuestionDTO implements Serializable { - - /** - * 随机ID,同一个用户的对话使用统一的ID - */ - @JSONField(name = "chat_id") - private String chatId; - - /** - * 用户ID,同一个随机ID只能对应一个用户ID - */ - @JSONField(name = "user_id") - private String userId; - - /** - * 用户的问题 - */ - private String query; - - /** - * 特殊提问内容 - */ - private Map extra; - - /** - * 是否允许大模型查询数据,默认为 1 - */ - @JSONField(name = "enable_record") - private int enableRecord = 1; - - /** - * 是否允许大模型发送指令,默认为 1 - */ - @JSONField(name = "enable_yk") - private int enableControl = 1; - - /** - * 是否允许大模型打开视频,默认为 1 - */ - @JSONField(name = "enable_video") - private int enableVideo = 1; - - /** - * 是否允许大模型打开画面,默认为 1 - */ - @JSONField(name = "enable_canvas") - private int enableCanvas = 1; - - /** - * 是否允许大模型诊断故障,默认为 1 - */ - @JSONField(name = "enable_fault") - private int enableFault = 1; - - /** - * 大模型默认的意图理解方式,可以为"default","yk"... - */ - @JSONField(name = "default") - private String defaultMode; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java deleted file mode 100644 index 026853c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.hnac.hzims.bigmodel.question.service; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import com.hnac.hzims.bigmodel.interactive.service.IResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.ScadaSelectionVO; -import com.hnac.hzims.bigmodel.interactive.vo.VideoSelectionVO; -import com.hnac.hzims.bigmodel.question.dto.MessageDTO; -import com.hnac.hzims.bigmodel.question.dto.QuestionDTO; -import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; -import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.SpringUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Service; -import org.springframework.web.socket.TextMessage; - -/** - * @Author: huangxing - * @Date: 2024/07/10 11:03 - */ -@Service -@AllArgsConstructor -@Slf4j -public class QuestionHandlerService { - - private final IHznlmInvokeService hznlmInvokeService; - - /** - * 处理用户发起问题 - * @param messageDTO 接收前端消息内容体 - */ - public void handleMessage(MessageDTO messageDTO) { - // 将message转换为question - QuestionDTO question = BeanUtil.copy(messageDTO,QuestionDTO.class); - question.setQuery(messageDTO.getContext()); - // 普通问答 - if(Func.isEmpty(messageDTO.getIsSpecial()) || !messageDTO.getIsSpecial()) { - if (StringUtil.isNotBlank(messageDTO.getKnowledge())) { - if("analyse".equals(messageDTO.getKnowledge())) { - // 如果是数据分析问答 - hznlmInvokeService.analyseAsk(question); - } else{ - hznlmInvokeService.knowledgeAsk(question); - } - } else { - hznlmInvokeService.ask(question); - } - } else { - FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode((String) messageDTO.getExtra().get("func")); - switch (funcEnum) { - case CHOOSE_STATION: - case CHOOSE_YC: - case CHOOSE_FAULT: - case CHOOSE_YK: - hznlmInvokeService.specialAsk(question); - break; - case CHOOSE_VIDEO: - this.handleVideoChoose(messageDTO); - break; - case CHOOSE_CANVAS: - this.handleScadaChoose(messageDTO); - break; - default: - break; - } - } - } - - private void handleVideoChoose(MessageDTO messageDTO) { - InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); - try { - VideoSelectionVO selection = JSONObject.parseObject(JSON.toJSONString(messageDTO.getExtra().get("data")),VideoSelectionVO.class); - IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); - String videoId = selection.getItemId(); - ExtraVO videoExtras = resolveService.resolve(videoId); - AnswerVO answerVO = new AnswerVO(); - answerVO.setChatId(messageDTO.getChatId()); - answerVO.setQuery(selection.getItemName()); - answerVO.setRunning(0); - answerVO.setStatus(0); - answerVO.setAnswer("已成功打开"+selection.getItemName()+"视频"); - answerVO.setVoiceAnswer(new String[]{"已成功打开"+selection.getItemName()+"视频"}); - answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)}); - TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); - wsService.sendMessage(messageDTO.getChatId(),textMessage); - } - catch (Exception e) { - log.error("an error occurred!",e); - AnswerVO answerVO = new AnswerVO(); - answerVO.setRunning(0); - answerVO.setStatus(-2); - answerVO.setAnswer("视频解析失败!"); - TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); - wsService.sendMessage(messageDTO.getChatId(),textMessage); - } - } - - private void handleScadaChoose(MessageDTO messageDTO) { - InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); - try { - ScadaSelectionVO selection = JSONObject.parseObject(JSON.toJSONString(messageDTO.getExtra().get("data")),ScadaSelectionVO.class);; - IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); - ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); - AnswerVO answerVO = new AnswerVO(); - answerVO.setChatId(messageDTO.getChatId()); - answerVO.setRunning(0); - answerVO.setStatus(0); - answerVO.setQuery(selection.getItemName()); - answerVO.setVoiceAnswer(new String[]{"已成功打开"+selection.getItemName()+"实时画面"}); - answerVO.setAnswer("已成功打开"+selection.getItemName()+"实时画面"); - answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)}); - TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); - wsService.sendMessage(messageDTO.getChatId(),textMessage); - } - catch (Exception e) { - AnswerVO answerVO = new AnswerVO(); - answerVO.setRunning(0); - answerVO.setStatus(-2); - answerVO.setAnswer("实时画面解析失败!"); - TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); - wsService.sendMessage(messageDTO.getChatId(),textMessage); - } - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java deleted file mode 100644 index 6ffbf5a..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.hnac.hzims.bigmodel.schedule; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; -import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import com.hnac.hzims.bigmodel.interactive.service.IResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.manager.SessionRedisManager; -import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; -import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; -import com.xxl.job.core.log.XxlJobLogger; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springframework.stereotype.Component; -import org.springframework.web.socket.TextMessage; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ThreadPoolExecutor; - -import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; - -/** - * @Author: huangxing - * @Date: 2024/06/24 09:53 - */ -@Component -@AllArgsConstructor -@Slf4j -public class FrontEndInteractiveSchedule { - - private final SessionRedisManager sessionRedisManager; - private final InteractiveWsService wsService; - private final ThreadPoolExecutor getAnswerPoolExecutor; - private final IHznlmInvokeService hznlmInvokeService; - - @XxlJob(GET_INTERACTIVE_RESULT) - public ReturnT getInteractiveResult(String params) { - List sessionIds = sessionRedisManager.getSessionIds(); - if(CollectionUtil.isEmpty(sessionIds)){ - XxlJobLogger.log("问题都已经回答完毕!"); - return ReturnT.SUCCESS; - } - List answerList = hznlmInvokeService.getAnswerBySessionIds(String.join(",", sessionIds)); - answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> this.formatAnswer(answerVO), getAnswerPoolExecutor)); - return ReturnT.SUCCESS; - } - - private void formatAnswer(AnswerVO answerVO) { - // 如果已经获取到答案 则删除缓存 - if(answerVO.getRunning() == 0) { - log.info("获取大模型解析答案:{}", JSON.toJSONString(answerVO)); - sessionRedisManager.removeSessionId(answerVO.getChatId()); - } - Object[] extras = answerVO.getExtras(); - // 格式化 extra - if(Func.isNotEmpty(extras)) { - try { - Object[] resolveExtras = Arrays.stream(extras).map(extra -> { - IAnswerResolveService answerResolveService = AnswerResolveFactory.getResolveService(extra); - if (Func.isNotEmpty(answerResolveService)) { - JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra)); - return answerResolveService.getExtra(extraObject); - } - return extra; - }).map(JSON::toJSONString).toArray(); - answerVO.setExtras(resolveExtras); - } catch(Exception e) { - log.error("An error occurred",e); - AnswerVO.error(answerVO.getChatId(), answerVO.getUserId(), answerVO.getQuery()); - } - } - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(answerVO.getChatId(),message); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/RunReportAnalyseSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/RunReportAnalyseSchedule.java deleted file mode 100644 index 5e42faf..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/RunReportAnalyseSchedule.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.hnac.hzims.bigmodel.schedule; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.Func; -import org.springblade.mqtt.producer.IMqttSender; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; - -import java.util.Collection; -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/08/15 08:57 - */ -@Component -@AllArgsConstructor -@Slf4j -public class RunReportAnalyseSchedule { - - private final RedisTemplate redisTemplate; - private final IHznlmInvokeService invokeService; - private final IMqttSender mqttSender; - - @XxlJob(XxlJobHandlerConstant.GET_RUN_REPORT_RESULT) - public ReturnT getRunReportResult(String params) { - List analyses = (List) redisTemplate.opsForList().range(RedisKeyConstants.RUN_REPORT_SESSION_ID,0,-1); - if(Func.isEmpty(analyses)) { - return ReturnT.SUCCESS; - } - analyses.stream().forEach(analyse -> { - JSONObject analyseObject = JSONObject.parseObject(analyse); - String sessionId = analyseObject.getString("sessionId"); - List answerVOS = invokeService.getAnswerBySessionIds(sessionId); - if(Func.isNotEmpty(answerVOS)) { - AnswerVO answerVO = answerVOS.get(0); - if(answerVO.getRunning() == 0) { - log.info("运行月报分析结果为:" + JSON.toJSONString(answerVO)); - JSONObject message = new JSONObject(); - message.put("stationCode", analyseObject.getString("stationCode")); - message.put("month", analyseObject.getString("month")); - message.put("result", JSONObject.parseObject(JSON.toJSONString(answerVO.getExtras()[0])).getString("data")); - // 获取到问答答案,存入消息中 - mqttSender.sendToMqtt(MqttTopicConstants.RUN_REPORT_ANALYSE_RESULT,JSON.toJSONString(message)); - redisTemplate.opsForList().remove(RedisKeyConstants.RUN_REPORT_SESSION_ID,1,analyse); - } - } - }); - return ReturnT.SUCCESS; - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java deleted file mode 100644 index c83961f..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.bigmodel.schedule; - -import com.hnac.hzims.common.constant.CommonConstant; - -/** - * @Author: huangxing - * @Date: 2024/04/28 16:19 - */ -public interface XxlJobHandlerConstant { - - /**获取问答结果**/ - String GET_INTERACTIVE_RESULT = "getInteractiveResult"; - - /**获取运行月报分析结果**/ - String GET_RUN_REPORT_RESULT = "getRunReportResult"; - - String SYNCHRONOUS_FAULT_INSTRUCT = "synchronousFaultInstruct"; - - /**同步视频指令**/ - String SYNCHRONOUS_VIDEO_INSTRUCT = "synchronousVideoInstruct"; - - String SYNCHRONOUS_SCADA_INSTRUCT = "synchronousScadaInstruct"; - - String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; - - String HZIMS_BIGMODEL_ASK_KEY = CommonConstant.TENANT_ID + ":hzims:bigmodel:ask:key"; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java deleted file mode 100644 index 47fded7..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.hnac.hzims.bigmodel.utils; - -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -import com.hnac.hzinfo.exception.HzServiceException; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.ResultCode; -import org.springframework.util.Assert; - -import javax.servlet.http.HttpServletResponse; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/21 17:12 - */ -@Slf4j -public class RequestClientUtil { - - - /** - * 无返回结果远程调用http接口 - * @param url 接口url - * @param body 传参body - */ - public static void postCall(String url, String body) { - log.info("开始远程调用{}接口",url); - HttpResponse response = HttpRequest.post(url).body(body).execute(); - log.info("远程调用{}接口结束",url); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { - throw new HzServiceException(ResultCode.FAILURE, "远程调用接口" + url + "失败!"); - }); - } - - /** - * 无返回结果远程调用http接口 - * @param url 接口url - * @param body 传参body - */ - public static void postCall(String url, Map body) { - log.info("开始远程调用{}接口",url); - HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); - log.info("远程调用{}接口结束",url); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { - throw new HzServiceException(ResultCode.FAILURE, "远程调用接口" + url + "失败!"); - }); - } - - /** - * 远程调用http接口 - * @param url 接口url - * @param body 传参 - * @param typeRef 结果解析对象 - * @return 结果 - * @param 结果解析对象类型 - */ - public static T postCall(String url, Map body, TypeReference typeRef) { - HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { - throw new HzServiceException(ResultCode.FAILURE, "远程调用大模型接口" + url + "失败!"); - }); - return JSONObject.parseObject(response.body(), typeRef); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/config/WebSocketConfig.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/config/WebSocketConfig.java deleted file mode 100644 index ed9a2a5..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/config/WebSocketConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.bigmodel.websocket.config; - -import com.hnac.hzims.bigmodel.websocket.handler.InteractiveHandler; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.WebSocketHandler; -import org.springframework.web.socket.config.annotation.EnableWebSocket; -import org.springframework.web.socket.config.annotation.WebSocketConfigurer; -import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; - -/** - * @Author: huangxing - * @Date: 2024/04/28 13:39 - */ -@Configuration -@EnableWebSocket -public class WebSocketConfig implements WebSocketConfigurer { - - @Override - public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { - registry.addHandler(interactiveHandler(), "/websocket/interactive/{sessionId}").setAllowedOrigins("*"); - } - @Bean - public WebSocketHandler interactiveHandler() { - return new InteractiveHandler(); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java deleted file mode 100644 index 40a64fd..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hnac.hzims.bigmodel.websocket.constants; - -import com.hnac.hzims.common.constant.CommonConstant; - -/** - * @Author: huangxing - * @Date: 2024/05/20 19:11 - */ -public interface RedisKeyConstants { - - String SESSION_CONTENT_KEY = CommonConstant.TENANT_ID + ":hzims:bigModel:session:content"; - - String RUN_REPORT_SESSION_ID = CommonConstant.TENANT_ID + ":hzims:bigModel:session:report"; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java deleted file mode 100644 index 8b3fbc7..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.hnac.hzims.bigmodel.websocket.handler; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import com.hnac.hzims.bigmodel.interactive.service.IResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.*; -import com.hnac.hzims.bigmodel.question.dto.MessageDTO; -import com.hnac.hzims.bigmodel.question.service.QuestionHandlerService; -import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; -import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; -import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.SpringUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; -import org.springframework.web.socket.CloseStatus; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; -import org.springframework.web.socket.handler.TextWebSocketHandler; - -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * @Author: huangxing - * @Date: 2024/04/28 13:45 - */ -@Slf4j -@Component -public class InteractiveHandler extends TextWebSocketHandler { - - @Autowired - private RedisTemplate redisTemplate; - - @Override - public void afterConnectionEstablished(WebSocketSession session) { - String[] split = session.getUri().toString().split("/"); - String sessionId = split[split.length - 1]; - session.getAttributes().put("sessionId", sessionId); - InteractiveSessionManager.add(sessionId, session); - log.info("sessionId: " + session.getId()); - log.info("uri: " + session.getUri()); - log.info("session connection successful!"); - } - - @Override - public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { - String[] split = session.getUri().toString().split("/"); - String sessionId = split[split.length - 1]; - InteractiveSessionManager.removeAndClose(sessionId); - log.info("sessionId: " + session.getId()); - log.info("uri: " + session.getUri()); - log.info("session closed successful!"); - } - - @Override - protected void handleTextMessage(WebSocketSession session, TextMessage message) { - MessageDTO messageDTO = JSONObject.parseObject(message.getPayload(), MessageDTO.class); - if("0".equals(messageDTO.getType())) { - // 接收心跳消息,返回一条心跳消息 - try { - session.sendMessage(InteractiveSessionManager.getTextMessage("0","收到心跳消息")); - } catch (IOException e) { - throw new RuntimeException(e); - } - } else { - String chatId = InteractiveSessionManager.getEntryBySession(session).getKey(); - messageDTO.setChatId(chatId); - // 将发送参数存入redis - if(Func.isNotEmpty(messageDTO.getContent())) { - redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); - redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,chatId,messageDTO.getContent()); - } - QuestionHandlerService service = SpringUtil.getBean(QuestionHandlerService.class); - service.handleMessage(messageDTO); - } - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/server/InteractiveWsServer.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/server/InteractiveWsServer.java deleted file mode 100644 index fdcd940..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/server/InteractiveWsServer.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.hnac.hzims.bigmodel.websocket.server; - -/** - * @Author: huangxing - * @Date: 2024/04/28 13:38 - */ -public class InteractiveWsServer { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java deleted file mode 100644 index c02fbab..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.hnac.hzims.bigmodel.websocket.service; - -import com.alibaba.fastjson.JSON; -import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springframework.stereotype.Service; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; - -import java.io.IOException; - -/** - * @Author: huangxing - * @Date: 2024/04/28 14:35 - */ -@Service -@Slf4j -public class InteractiveWsService implements WebSocketService { - - @Override - public Boolean sendMessage(String sessionId, TextMessage message) { - if(InteractiveSessionManager.SESSION_POOL.containsKey(sessionId)) { - WebSocketSession session = InteractiveSessionManager.get(sessionId); - return this.sendMessage(session,message); - } - else { - log.error("未查询到sessionId,消息推送失败;"); - return false; - } - } - - @Override - public Boolean sendMessage(WebSocketSession session, TextMessage message) { - try { - session.sendMessage(message); - return true; - } catch (IOException e) { - log.error("消息推送失败;消息体为:" + JSON.toJSONString(message)); - return false; - } - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java deleted file mode 100644 index 8729472..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.bigmodel.websocket.service; - -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; - -/** - * @Author: huangxing - * @Date: 2024/04/28 14:37 - */ -public interface WebSocketService { - - Boolean sendMessage(String signage, TextMessage message); - - Boolean sendMessage(WebSocketSession session, TextMessage message); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java deleted file mode 100644 index ea022cc..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.hnac.hzims.bigmodel.websocket.sessionManager; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/04/28 13:58 - */ -@Slf4j -public class InteractiveSessionManager { - /** ws会话池 **/ - public static ConcurrentHashMap SESSION_POOL = new ConcurrentHashMap<>(); - - /** - * 获取sessionIds - * @return sessionIds - */ - public static List getSessionIds() { - Set> sessionEntrySet = InteractiveSessionManager.SESSION_POOL.entrySet(); - return sessionEntrySet.stream().map(entry -> entry.getKey()).collect(Collectors.toList()); - } - - /** - * 根据Session获取Entry - * @param session websocketSession - * @return Entry - */ - public static Map.Entry getEntryBySession(WebSocketSession session) { - Set> sessionEntrySet = InteractiveSessionManager.SESSION_POOL.entrySet(); - Optional> sessionIdOptional = sessionEntrySet.stream().filter(sessionEntry -> session.equals(sessionEntry.getValue())).findFirst(); - if(!sessionIdOptional.isPresent()) { - log.error("当前Session Pool未查询到相关session,消息推送失败"); - throw new ServiceException("当前Session Pool未查询到相关session,消息推送失败"); - } - return sessionIdOptional.get(); - } - - /** - * 添加会话 - * @param sessionId 会话ID - * @param session 会话对象 - */ - public static void add(String sessionId, WebSocketSession session) { - if (SESSION_POOL.containsKey(sessionId)) { - InteractiveSessionManager.removeAndClose(sessionId); - } - SESSION_POOL.put(sessionId, session); - } - - /** - * 获取ws会话 - * @param sessionId 会话ID - */ - public static WebSocketSession get(String sessionId) { - return SESSION_POOL.get(sessionId); - } - - /** - * 移除ws会话并关闭会话 - * @param sessionId 会话ID - */ - public static void removeAndClose(String sessionId) { - WebSocketSession session = SESSION_POOL.get(sessionId); - if (session != null) { - try { - //关闭连接 - session.close(); - } catch (IOException ex) { - throw new RuntimeException("关闭ws会话失败!", ex); - } - } - SESSION_POOL.remove(sessionId); - } - - public static TextMessage getTextMessage(String type,String context) { - JSONObject message = new JSONObject(); - message.put("type",type); - message.put("context",context); - return new TextMessage(JSON.toJSONString(message)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/controller/WhitelistController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/controller/WhitelistController.java deleted file mode 100644 index 5e29227..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/controller/WhitelistController.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.hnac.hzims.bigmodel.whitelist.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.entity.WhitelistEntity; -import com.hnac.hzims.bigmodel.whitelist.service.WhitelistService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * @author ysj - */ -@RestController -@RequestMapping("/whitelist") -@Api(value = "白名单用户",tags = "白名单用户") -@AllArgsConstructor -public class WhitelistController { - - private final WhitelistService whitelistService; - - @PostMapping("/list") - @ApiOperation("查询列表") - @ApiOperationSupport(order = 1) - public R> list(@RequestBody WhitelistEntity entity) { - return R.data(whitelistService.list(Condition.getQueryWrapper(entity))); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/mapper/WhitelistMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/mapper/WhitelistMapper.java deleted file mode 100644 index c1f87d2..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/mapper/WhitelistMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.whitelist.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.entity.WhitelistEntity; - -/** - * @author ysj - */ -public interface WhitelistMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/WhitelistService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/WhitelistService.java deleted file mode 100644 index ceaf79e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/WhitelistService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.whitelist.service; - -import com.hnac.hzims.bigmodel.entity.WhitelistEntity; -import org.springblade.core.mp.base.BaseService; - - -/** - * @author ysj - */ -public interface WhitelistService extends BaseService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java deleted file mode 100644 index b4b0cb3..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.bigmodel.whitelist.service.impl; - -import com.hnac.hzims.bigmodel.entity.WhitelistEntity; -import com.hnac.hzims.bigmodel.whitelist.mapper.WhitelistMapper; -import com.hnac.hzims.bigmodel.whitelist.service.WhitelistService; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:13 - */ -@Service -@Slf4j -public class WhitelistServiceImpl extends BaseServiceImpl implements WhitelistService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfig.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfig.java deleted file mode 100644 index 1c5a8b2..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.config; - -import com.zhipu.oapi.ClientV4; -import lombok.AllArgsConstructor; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @Author: ypj - * @Date: 2024/8/9 17:01 - */ -@Configuration -@EnableConfigurationProperties(ZhipuAiConfigProperties.class) -@AllArgsConstructor -public class ZhipuAiConfig { - - private ZhipuAiConfigProperties properties; - - @Bean("clientV4") - public ClientV4 clientV4() { - return new ClientV4.Builder(properties.getApiSecret()).build(); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java deleted file mode 100644 index 0ba8b63..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * @Author: ypj - * @Date: 2024/8/8 14:03 - */ -@Data -@ConfigurationProperties(prefix = "bigmodel.zhipuai") -public class ZhipuAiConfigProperties { - - private String apiSecret; - - private String url; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/AnalysisModel.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/AnalysisModel.java deleted file mode 100644 index bfd686d..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/AnalysisModel.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.constants; - -import lombok.Getter; - -/** - * @Author: ypj - * @Date: 2024/8/9 9:50 - */ -@Getter -public enum AnalysisModel implements BaseEnum { - - GLM_4("glm-4", "GLM-4模型"), - GLM_4V("glm-4v", "GLM-4V模型"), - COG_VIDEO_X("cogvideox", "CogVideoX模型"), - COG_VIEW("cogvideox", "CogVideoX模型"), - GLM_4_ALL_TOOLS("glm-4-alltool", "GLM-4-AllTools模型"); - - private final String code; - - private final String msg; - - AnalysisModel(String code, String msg) { - this.code = code; - this.msg = msg; - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/BaseEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/BaseEnum.java deleted file mode 100644 index 6c40f4c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/BaseEnum.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.constants; - -/** - * @Author: ypj - * @Date: 2024/8/8 15:42 - */ -public interface BaseEnum { - U getCode(); - - String getMsg(); - - static T getInstance(U code, Class clazz) { - T[] baseEnums = clazz.getEnumConstants(); - for (T baseEnum : baseEnums) { - if (baseEnum.getCode().equals(code)) { - return baseEnum; - } - } - return null; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ComparisonType.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ComparisonType.java deleted file mode 100644 index 4eb09ba..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ComparisonType.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.constants; - -import lombok.Getter; - -/** - * @Author: ypj - * @Date: 2024/8/14 9:23 - */ -@Getter -public enum ComparisonType implements BaseEnum { - EQUAL("equal", "相等"), - GREATER("greater","大于"), - LESS("less","小于"); - private final String code; - - private final String msg; - - ComparisonType(String code, String msg) { - this.code = code; - this.msg = msg; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java deleted file mode 100644 index 02f55cb..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.constants; - -import com.hnac.hzinfo.exception.HzServiceException; -import lombok.Getter; -import org.springblade.core.tool.api.IResultCode; -import org.springblade.core.tool.api.ResultCode; - -/** - * @Author: ypj - * @Date: 2024/8/22 11:17 - */ -@Getter -public enum ErrorCode implements IResultCode { - - GET_DATA_FAILURE(1888000001, "获取数据失败"), - ANALYSIS_FAILURE(1888000002, "分析失败"), - STRATEGY_NOT_FOUND(1888000003, "策略未找到"), - GET_FILE_CONTENT_FAILURE(1888000004, "获取文件内容失败"), - REQUEST_TEXT_IS_EMPTY(1888000005, "交互文字内容不能为空"), - EMPTY_ANALYSIS_TYPE(1888000006, "识别类型为空"), - UNKNOWN_ANALYSIS_TYPE(1888000007, "未知的识别类型"), - NO_COMPARATOR(1888000008, "未获取到对比对象"), - NO_COMPARISON_TYPE(1888000009, "未获取到对比类型"), - GET_RESULT_FAIL(1888000010, "获取结果失败"), - NO_ANSWER_FROM_PLATFORM(1888000011, "未从平台获取到答案"); - - private final int code; - private final String msg; - - ErrorCode(int code, String msg) { - this.code = code; - this.msg = msg; - } - - - @Override - public String getMessage() { - return this.msg; - } - - public HzServiceException throwException() { - return new HzServiceException(this); - } - - public static HzServiceException throwCommonException(String msg) { - return new HzServiceException(new IResultCode() { - @Override - public String getMessage() { - return msg; - } - - @Override - public int getCode() { - return ResultCode.FAILURE.getCode(); - } - }); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java deleted file mode 100644 index 2f82a7e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.constants; - -import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.BooleanParser; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.IntegerParser; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.ResultDataParser; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.StringParser; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -/** - * @Author: ypj - * @Date: 2024/8/14 8:28 - */ -@Getter -@Slf4j -public enum ResultDataType implements BaseEnum { - STRING("String", "String类型", StringParser.class), - BOOLEAN("Boolean", "Boolean类型", BooleanParser.class), - INTEGER("Integer", "Integer类型", IntegerParser.class); - - private final String code; - - private final String msg; - - private final Class parser; - - ResultDataType(String code, String msg, Class parser) { - this.code = code; - this.msg = msg; - this.parser = parser; - } - - public ResultDataParser getParser() { - try { - return parser.newInstance(); - } catch (Exception e) { - log.error("get result data parse fail", e); - } - return null; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java deleted file mode 100644 index 9f04f2f..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.constants; - -import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultBooleanStrategy; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultCommonStrategy; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -/** - * @Author: ypj - * @Date: 2024/8/8 15:27 - */ -@Getter -@Slf4j -public enum ResultStrategyType implements BaseEnum { - COMMON("ResultCommonStrategy", "普通值", ResultCommonStrategy.class), - BOOLEAN("ResultBooleanStrategy", "是非判断", ResultBooleanStrategy.class); - - private final String code; - - private final String msg; - - private final Class strategyClass; - - ResultStrategyType(String code, String msg, Class strategy) { - this.code = code; - this.msg = msg; - this.strategyClass = strategy; - } - - public ResultStrategy getStrategy() { - try { - return strategyClass.newInstance(); - } catch (Exception e) { - log.error("get result strategy fail", e); - } - return null; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisController.java deleted file mode 100644 index e770857..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisController.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService; -import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; -import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; - -/** - * @Author: ypj - * @Date: 2024/8/8 16:36 - */ -@RestController -@RequestMapping("zhipu") -@Api(value = "智谱", tags = "智谱") -@AllArgsConstructor -public class ZhipuAnalysisController { - - private final ZhipuAnalysisService analysisService; - - @PostMapping("/analysis") - @ApiOperation("分析") - @ApiOperationSupport(order = 1) - public R analysis(@RequestBody @Valid ZhipuAnalysisFileRequest request) { - return R.data(analysisService.analysis(request)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java deleted file mode 100644 index ce4664c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; -import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisInfoVO; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author: ypj - * @Date: 2024/8/12 20:22 - */ -@RestController -@Api(value = "智谱分析信息管理", tags = "智谱分析信息管理") -@RequestMapping("/zhipu/info") -@AllArgsConstructor -public class ZhipuAnalysisInfoController { - private final ZhipuAnalysisInfoService analysisInfoService; - - @PostMapping("/save") - @ApiOperation("保存智谱分析信息") - @ApiOperationSupport(order = 1) - public R save(@RequestBody ZhipuAnalysisInfoVO request) { - return R.status(analysisInfoService.save(request.toEntity())); - } - - @DeleteMapping("/remove") - @ApiOperation("批量删除智谱分析信息") - @ApiOperationSupport(order = 2) - public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { - return R.status(analysisInfoService.removeByIds(Func.toLongList(",", ids))); - } - - @GetMapping("/selectPage") - @ApiOperation("分页查询智谱分析配置信息") - @ApiOperationSupport(order = 3) - public R> selectPage(Query query, ZhipuAnalysisInfoEntity requestData) { - return R.data(analysisInfoService.page(Condition.getPage(query), Condition.getQueryWrapper(new ZhipuAnalysisInfoEntity(), requestData))); - } - - @PutMapping("/update") - @ApiOperation("更新智谱分析配置信息") - @ApiOperationSupport(order = 4) - public R update(@RequestBody ZhipuAnalysisInfoEntity requestData) { - return R.status(analysisInfoService.updateById(requestData)); - } - - @GetMapping("/list") - @ApiOperation("列出智谱分析配置信息") - @ApiOperationSupport(order = 5) - public R> list(ZhipuAnalysisInfoEntity requestData) { - return R.data(analysisInfoService.list(Condition.getQueryWrapper(requestData))); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java deleted file mode 100644 index 40c420b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.entity; - -import com.baomidou.mybatisplus.annotation.SqlCondition; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.mp.support.QueryField; -import org.springblade.core.tenant.mp.TenantEntity; - -/** - * @Author: ypj - * @Date: 2024/8/8 15:17 - */ -@ApiModel(value = "大模型分析信息") -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("hzims_analysis_info") -public class ZhipuAnalysisInfoEntity extends TenantEntity { - - @ApiModelProperty(value = "策略编码") - @TableField("CODE") - private String code; - - @ApiModelProperty(value = "对应字典表“AI识别类型”的key值") - @TableField("CHECK_TYPE_SON") - private String checkTypeSon; - - @ApiModelProperty(value = "策略名称") - @TableField("NAME") - @QueryField(condition = SqlCondition.LIKE) - private String name; - - @ApiModelProperty(value = "调用模型名称") - @TableField("MODEL") - private String model; - - @ApiModelProperty(value = "模型交互内容") - @TableField("REQUEST_CONTENT") - private String requestContent; - - @ApiModelProperty(value = "模型交互约束") - @TableField("REQUEST_CONSTRAINS") - private String requestConstrains; - - @ApiModelProperty(value = "模型交互返回格式定义") - @TableField("REQUEST_OUTPUT_FORMAT") - private String requestOutputFormat; - - @ApiModelProperty(value = "结果解析策略") - @TableField("RESULT_STRATEGY") - private String resultStrategy; - - @ApiModelProperty(value = "结果类型") - @TableField("RESULT_TYPE") - private String resultType; - - @ApiModelProperty(value = "结果查询key值") - @TableField("RESULT_KEY") - private String resultKey; - - @ApiModelProperty(value = "结果对比内容") - @TableField("RESULT_CONDITION") - private String resultCondition; - - @ApiModelProperty(value = "对比方式") - @TableField("RESULT_JUDGE_MODEL") - private String resultJudgeModel; - - @ApiModelProperty(value = "消息") - @TableField("MESSAGE") - private String message; -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java deleted file mode 100644 index 62a19ec..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler; - -import com.zhipu.oapi.ClientV4; -import lombok.Data; - -import javax.annotation.Resource; - -/** - * @Author: ypj - * @Date: 2024/8/12 8:44 - */ -@Data -public abstract class AbstractZhipuAnalysisHandler implements ZhipuAnalyser { - protected final String requestIdTemplate = "big_model-%d"; - - @Resource - protected ClientV4 client; - - private String text; - - private String url; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java deleted file mode 100644 index 6b22484..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler; - -import org.springblade.core.tool.jackson.JsonUtil; - -import java.util.Map; -import java.util.Optional; - -/** - * @Author: ypj - * @Date: 2024/8/8 14:45 - */ -public interface ZhipuAnalyser { - String QUESTION_PROFILE = "## Profile\n"; - - String QUESTION_CONSTRAINS = "## Constrains\n"; - - String QUESTION_OUTPUT_FORMAT = "## OutputFormat\n"; - - String getAnalysisStrategy(); - - String getAnalysisModel(); - - String getUrl(); - - void setUrl(String url); - - String getText(); - - void setText(String text); - - default boolean isSupport(String strategyCode) { - return getAnalysisStrategy().equals(strategyCode); - } - - Resp sendRequest(String text, String url); - - Req getRequest(String text, String url); - - String getResult(String text, String url); - - default Map getResultMap(String text, String url) { - String result = getResult(text, url); - return Optional.ofNullable(result).map(str -> JsonUtil.toMap(result)).orElse(null); - } - - default Object getResultValue(String text, String key, String url) { - Map resultMap = getResultMap(text, url); - return Optional.ofNullable(resultMap).map(data -> data.get(key)).orElse(null); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisFactory.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisFactory.java deleted file mode 100644 index e4945b3..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @Author: ypj - * @Date: 2024/8/9 10:47 - */ -@Component -@AllArgsConstructor -@Slf4j -public class ZhipuAnalysisFactory { - private final List analysisStrategyList; - - private static final Map analysisStrategyMap = new ConcurrentHashMap<>(); - - public ZhipuAnalyser getAnalysisStrategy(final String strategyCode) { - ZhipuAnalyser result = ZhipuAnalysisFactory.analysisStrategyMap.get(strategyCode); - if (Objects.nonNull(result)) { - return result; - } - Optional strategyOptional = analysisStrategyList.stream().filter(strategy -> strategy.isSupport(strategyCode)).findFirst(); - if (strategyOptional.isPresent()) { - result = strategyOptional.get(); - ZhipuAnalysisFactory.analysisStrategyMap.put(strategyCode, result); - } - return result; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java deleted file mode 100644 index 36ad46c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler; - -import cn.hutool.core.lang.Assert; -import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; -import com.hnac.hzinfo.exception.HzServiceException; -import com.zhipu.oapi.Constants; -import com.zhipu.oapi.service.v4.model.ChatCompletionRequest; -import com.zhipu.oapi.service.v4.model.ChatMessage; -import com.zhipu.oapi.service.v4.model.ChatMessageRole; -import com.zhipu.oapi.service.v4.model.ModelApiResponse; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.jackson.JsonUtil; -import org.springframework.stereotype.Service; - -import java.util.*; - -/** - * @Author: ypj - * @Date: 2024/8/12 9:20 - */ -@Service -@AllArgsConstructor -@Slf4j -public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { - - @Override - public String getAnalysisStrategy() { - return Constants.ModelChatGLM4V; - } - - @Override - public String getAnalysisModel() { - return Constants.ModelChatGLM4V; - } - - @Override - public ModelApiResponse sendRequest(String text, String url) { - ChatCompletionRequest request = getRequest(text, url); - log.info("send zhipu ai request :{}", Optional.ofNullable(request).map(JsonUtil::toJson).orElse("null")); - return client.invokeModelApi(request); - } - - @Override - public ChatCompletionRequest getRequest(String text, String url) { - List messages = new ArrayList<>(); - List> contentList = new ArrayList<>(); - Map textMap = new HashMap<>(); - textMap.put("type", "text"); - textMap.put("text", text); - Map typeMap = new HashMap<>(); - typeMap.put("type", "image_url"); - Map urlMap = new HashMap<>(); - urlMap.put("url", url); - typeMap.put("image_url", urlMap); - contentList.add(textMap); - contentList.add(typeMap); - ChatMessage chatMessage = new ChatMessage(ChatMessageRole.USER.value(), contentList); - messages.add(chatMessage); - String requestId = String.format(requestIdTemplate, System.currentTimeMillis()); - - return ChatCompletionRequest.builder() - .model(getAnalysisModel()) - .stream(Boolean.FALSE) - .invokeMethod(Constants.invokeMethod) - .messages(messages) - .requestId(requestId) - .build(); - } - - @Override - public String getResult(String text, String url) { - ModelApiResponse response = sendRequest(text, url); - log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(JsonUtil::toJson).orElse("null")); - Assert.isTrue(Objects.nonNull(response) && response.isSuccess(), () -> { - throw ErrorCode.throwCommonException(Optional.ofNullable(response).map(ModelApiResponse::getMsg).orElse(ErrorCode.NO_ANSWER_FROM_PLATFORM.getMsg())); - }); - try { - String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString(); - resultJson = resultJson.substring(resultJson.indexOf("{"), resultJson.lastIndexOf("}") + 1).trim(); - return resultJson; - } catch (Exception e) { - log.info("get data from response error", e); - throw ErrorCode.GET_DATA_FAILURE.throwException(); - } - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java deleted file mode 100644 index 31780b5..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -/** - * @Author: ypj - * @Date: 2024/8/12 10:11 - */ -@Service -@AllArgsConstructor -@Slf4j -public class ZhipuAnalysisHandlerTest extends ZhipuAnalysisHandlerGlm4v { - private final String model = "test"; - - @Override - public String getAnalysisStrategy() { - return model; - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java deleted file mode 100644 index 3b7e000..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultBooleanStrategy.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler.result; - -import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum; -import com.hnac.hzims.bigmodel.zhipuai.constants.ComparisonType; -import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; -import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy; -import org.springframework.util.Assert; - -import java.util.Objects; - -/** - * @Author: ypj - * @Date: 2024/8/14 7:41 - */ -public class ResultBooleanStrategy implements ResultStrategy { - @Override - public String getCode() { - return ResultStrategyType.BOOLEAN.getCode(); - } - - @Override - public Boolean getResult(ZhipuAnalysisInfoEntity info, Object resultData) { - Object comparator = convertOriginalData(info.getResultCondition(), info.getResultType()); - Assert.isTrue(Objects.nonNull(comparator), () -> { - throw ErrorCode.NO_COMPARATOR.throwException(); - }); - ComparisonType comparisonType = BaseEnum.getInstance(info.getResultJudgeModel(), ComparisonType.class); - Assert.isTrue(Objects.nonNull(comparisonType), () -> { - throw ErrorCode.NO_COMPARISON_TYPE.throwException(); - }); - switch (Objects.requireNonNull(comparisonType)) { - case EQUAL: - return comparator.equals(resultData); - case GREATER: - if (comparator instanceof Comparable && resultData instanceof Comparable) { - return ((Comparable) comparator).compareTo((Comparable)resultData) < 0; - } - break; - case LESS: - return ((Comparable) comparator).compareTo(resultData) > 0; - } - throw ErrorCode.GET_RESULT_FAIL.throwException(); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java deleted file mode 100644 index e506065..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultCommonStrategy.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler.result; - -import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy; - -/** - * @Author: ypj - * @Date: 2024/8/13 10:33 - */ -public class ResultCommonStrategy implements ResultStrategy { - @Override - public String getCode() { - return ResultStrategyType.COMMON.getCode(); - } - - @Override - public Object getResult(ZhipuAnalysisInfoEntity info, Object data) { - return data; - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultStrategy.java deleted file mode 100644 index 90c6bbf..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/ResultStrategy.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler.result; - -import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum; -import com.hnac.hzims.bigmodel.zhipuai.constants.ResultDataType; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.data.ResultDataParser; - -import java.util.Optional; - -/** - * @Author: ypj - * @Date: 2024/8/13 10:00 - */ -public interface ResultStrategy { - - String getCode(); - - default boolean isSupport(String strategyCode) { - return getCode().equals(strategyCode); - } - - default Object convertOriginalData(String originalData, String className) { - ResultDataType type = BaseEnum.getInstance(className, ResultDataType.class); - if (null != type) { - ResultDataParser parser = type.getParser(); - return Optional.ofNullable(parser).map(p -> p.parse(originalData)).orElse(originalData); - } - return originalData; - } - - default T getResult(ZhipuAnalysisInfoEntity info, String originalValue) { - return getResult(info, convertOriginalData(originalValue, info.getResultType())); - } - - T getResult(ZhipuAnalysisInfoEntity info, Object resultData); -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/BooleanParser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/BooleanParser.java deleted file mode 100644 index 1af115a..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/BooleanParser.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler.result.data; - -/** - * @Author: ypj - * @Date: 2024/8/28 16:12 - */ -public class BooleanParser implements ResultDataParser { - @Override - public Boolean parse(String originalData) { - return Boolean.parseBoolean(originalData); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/IntegerParser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/IntegerParser.java deleted file mode 100644 index cc0cfe5..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/IntegerParser.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler.result.data; - -/** - * @Author: ypj - * @Date: 2024/8/28 16:46 - */ -public class IntegerParser implements ResultDataParser { - @Override - public Integer parse(String originalData) { - return Integer.parseInt(originalData); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/ResultDataParser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/ResultDataParser.java deleted file mode 100644 index 854e7e0..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/ResultDataParser.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler.result.data; - -/** - * @Author: ypj - * @Date: 2024/8/28 16:04 - */ -public interface ResultDataParser { - T parse(String originalData); -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/StringParser.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/StringParser.java deleted file mode 100644 index a9218e1..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/result/data/StringParser.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.handler.result.data; - -/** - * @Author: ypj - * @Date: 2024/8/28 16:11 - */ -public class StringParser implements ResultDataParser { - @Override - public String parse(String originalData) { - return originalData; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java deleted file mode 100644 index 8f4ebe1..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.mapper; - -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; - -/** - * @Author: ypj - * @Date: 2024/8/12 20:05 - */ -public interface ZhipuAnalysisInfoMapper extends UserDataScopeBaseMapper { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java deleted file mode 100644 index 823b870..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; - -/** - * @Author: ypj - * @Date: 2024/8/12 20:03 - */ -public interface ZhipuAnalysisInfoService extends IService { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java deleted file mode 100644 index 2316cbd..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.service; - -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; -import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse; - -/** - * @Author: ypj - * @Date: 2024/8/12 10:25 - */ -public interface ZhipuAnalysisService { - - ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request); - - ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request); - - BigModelAnalysisResponseDTO multiAnalysis(BigModelAnalysisRequestDTO analysisInfo); -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java deleted file mode 100644 index d25639e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.hzims.bigmodel.zhipuai.mapper.ZhipuAnalysisInfoMapper; -import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; -import org.springframework.stereotype.Service; - -/** - * @Author: ypj - * @Date: 2024/8/12 20:03 - */ -@Service -public class ZhipuAnalysisInfoServiceImpl extends ServiceImpl implements ZhipuAnalysisInfoService { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java deleted file mode 100644 index 956f6f2..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.service.impl; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; -import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum; -import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; -import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.hzims.bigmodel.zhipuai.handler.result.ResultStrategy; -import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalyser; -import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalysisFactory; -import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; -import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService; -import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; -import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse; -import com.hnac.hzims.common.utils.FileUtil; -import com.hnac.hzinfo.exception.HzServiceException; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.ResultCode; -import org.springblade.core.tool.jackson.JsonUtil; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.io.IOException; -import java.util.*; - -/** - * @Author: ypj - * @Date: 2024/8/12 10:26 - */ -@Service -@AllArgsConstructor -@Slf4j -public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { - - private final ZhipuAnalysisFactory analysisFactory; - - private final ZhipuAnalysisInfoService infoService; - - private static final String MULTI_QUESTION_BRIEF = "从给出的图片回答以下{}个问题\n"; - - private static final String MULTI_QUESTION_PREFIX = "第{}个问题,"; - - private static final String MULTI_QUESTION_CONSTRAINS = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n"; - - private static final String MULTI_QUESTION_CONSTRAINS_LIST = "'{}'代表第{}个问题,"; - - @Override - public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) { - Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()) || StringUtil.isNotBlank(request.getUrl()), () -> { - throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); - }); - ZhipuAnalysisFileResponse response = new ZhipuAnalysisFileResponse(); - - ZhipuAnalysisInfoEntity info = getAnalysisInfo(request); - Assert.isTrue(Objects.nonNull(info), () -> { - throw ErrorCode.STRATEGY_NOT_FOUND.throwException(); - }); - - ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(info.getModel()); - Assert.isTrue(StringUtil.isNotBlank(info.getRequestContent()), () -> { - throw ErrorCode.REQUEST_TEXT_IS_EMPTY.throwException(); - }); - //拼接文字内容 - StringBuilder textBuilder = new StringBuilder(); - textBuilder.append(ZhipuAnalyser.QUESTION_PROFILE).append(info.getRequestContent()); - if (StringUtil.isNotBlank(info.getRequestConstrains())) { - textBuilder.append(ZhipuAnalyser.QUESTION_CONSTRAINS).append(info.getRequestConstrains()); - } - if (StringUtil.isNotBlank(info.getRequestOutputFormat())) { - textBuilder.append(ZhipuAnalyser.QUESTION_OUTPUT_FORMAT).append("{").append(info.getRequestOutputFormat()).append("}"); - } - analyser.setText(textBuilder.toString()); - - Object resultObject = analyser.getResultValue(analyser.getText(), info.getResultKey(), getSendUrl(request)); - Assert.isTrue(Objects.nonNull(resultObject), () -> { - throw ErrorCode.ANALYSIS_FAILURE.throwException(); - }); - String resultStr = resultObject.toString(); - - ResultStrategyType strategyType = BaseEnum.getInstance(info.getResultStrategy(), ResultStrategyType.class); - Assert.isTrue(Objects.nonNull(strategyType), () -> { - throw ErrorCode.STRATEGY_NOT_FOUND.throwException(); - }); - ResultStrategy strategy = strategyType.getStrategy(); - - Object resultValue = strategy.convertOriginalData(resultStr, info.getResultType()); - Object conclusion = strategy.getResult(info, resultValue); - - response.setResultStr(resultStr); - response.setResult(conclusion); - return response; - } - - String getSendUrl(ZhipuAnalysisFileRequest request) { - if (StringUtil.isNotBlank(request.getUrl())) { - return request.getUrl(); - } - Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()), () -> { - throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); - }); - try { - return FileUtil.getBase64(request.getFilePath()); - } catch (IOException e) { - throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); - } - } - - @Override - public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request) { - ZhipuAnalysisInfoEntity result = null; - if (StringUtil.isBlank(request.getCode()) && StringUtil.isBlank(request.getCheckTypeSon())) { - result = request.toAnalysisInfo(); - } else { - result = infoService.getOne(Wrappers.lambdaQuery() - .eq(StringUtil.isNotBlank(request.getCode()), ZhipuAnalysisInfoEntity::getCode, request.getCode()) - .eq(StringUtil.isNotBlank(request.getCheckTypeSon()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSon()) - .last("limit 1;")); - } - log.debug("the analysis information is {}", Optional.ofNullable(result).map(r -> JsonUtil.toJson(r)).orElse("null")); - return result; - } - - - @Override - public BigModelAnalysisResponseDTO multiAnalysis(BigModelAnalysisRequestDTO request) { - BigModelAnalysisResponseDTO response = new BigModelAnalysisResponseDTO(); - try { - Assert.isTrue(StringUtil.isNotBlank(request.getUrl()), () -> { - throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); - }); - Assert.isTrue(CollectionUtil.isNotEmpty(request.getCodeList()) || CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), () -> { - throw ErrorCode.EMPTY_ANALYSIS_TYPE.throwException(); - }); - List infoList = infoService.list(Wrappers.lambdaQuery().in(CollectionUtil.isNotEmpty(request.getCodeList()), ZhipuAnalysisInfoEntity::getCode, request.getCodeList()) - .in(CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSonList())); - Assert.isTrue(CollectionUtil.isNotEmpty(infoList), () -> { - throw ErrorCode.UNKNOWN_ANALYSIS_TYPE.throwException(); - }); - ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(infoList.get(0).getModel()); - - String text = getMultiAnalyserText(infoList); - Map resultMap = analyser.getResultMap(text, request.getUrl()); - - if (null == resultMap) { - response.setCode(ResultCode.FAILURE.getCode()); - response.setMsg(ErrorCode.ANALYSIS_FAILURE.getMsg()); - return response; - } - - List results = new ArrayList<>(infoList.size()); - for (int index = 1; index <= infoList.size(); index++) { - ZhipuAnalysisInfoEntity infoEntity = infoList.get(index - 1); - BigModelAnalysisResponseDTO.BigModelAnalysisResult result = new BigModelAnalysisResponseDTO.BigModelAnalysisResult(); - results.add(result); - result.setCheckTypeSon(infoEntity.getCheckTypeSon()); - Object resultObj = resultMap.get(infoEntity.getResultKey()); - if (ObjectUtil.isEmpty(resultObj)) { - continue; - } - String resultStr = resultObj.toString(); - result.setResultStr(resultStr); - result.setDescription(infoEntity.getName() + StringUtil.format(",结果为{}", resultStr)); - ResultStrategyType strategyType = BaseEnum.getInstance(infoEntity.getResultStrategy(), ResultStrategyType.class); - if (ObjectUtil.isEmpty(strategyType)) { - continue; - } - Object conclusionObj = strategyType.getStrategy().getResult(infoEntity, resultObj); - result.setResult(conclusionObj); - if (conclusionObj instanceof Boolean && !(Boolean) conclusionObj) { - result.setMessage(infoEntity.getMessage()); - } - } - response.setData(results); - response.setCode(ResultCode.SUCCESS.getCode()); - response.setMsg(ResultCode.SUCCESS.getMessage()); - } catch (Exception e) { - if (e instanceof HzServiceException) { - response.setCode(ResultCode.FAILURE.getCode()); - response.setMsg(e.getMessage()); - } else { - response.setCode(ResultCode.FAILURE.getCode()); - response.setMsg(ErrorCode.ANALYSIS_FAILURE.getMsg()); - } - log.error(ErrorCode.ANALYSIS_FAILURE.getMessage(), e); - } - return response; - } - - String getMultiAnalyserText(List infoList) { - StringBuilder stringBuilder = new StringBuilder(); - StringBuilder titleBuilder = new StringBuilder(); - StringBuilder formatBuilder = new StringBuilder(); - stringBuilder.append(ZhipuAnalyser.QUESTION_PROFILE) - .append(StringUtil.format(MULTI_QUESTION_BRIEF, infoList.size())); - formatBuilder.append("{"); - for (int index = 1; index <= infoList.size(); index++) { - ZhipuAnalysisInfoEntity infoEntity = infoList.get(index - 1); - stringBuilder.append(StringUtil.format(MULTI_QUESTION_PREFIX, index)); - titleBuilder.append(StringUtil.format(MULTI_QUESTION_CONSTRAINS_LIST, infoEntity.getResultKey(), index)); - formatBuilder.append(infoEntity.getRequestOutputFormat()).append(","); - } - formatBuilder.deleteCharAt(formatBuilder.length() - 1); - formatBuilder.append("}"); - stringBuilder.append(ZhipuAnalyser.QUESTION_CONSTRAINS) - .append(StringUtil.format(MULTI_QUESTION_CONSTRAINS, titleBuilder.toString())) - .append(ZhipuAnalyser.QUESTION_OUTPUT_FORMAT).append(formatBuilder); - return stringBuilder.toString(); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java deleted file mode 100644 index 81184a6..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.vo; - -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @Author: ypj - * @Date: 2024/8/12 10:23 - */ -@Data -@ApiModel(value = "智谱分析请求", description = "智谱分析请求") -public class ZhipuAnalysisFileRequest { - @ApiModelProperty("策略编码") - private String code; - - @ApiModelProperty(value = "检测类型子类") - private String checkTypeSon; - - @ApiModelProperty("模型名称") - private String model; - - @ApiModelProperty("文件地址或文件的base64内容") - private String url; - - @ApiModelProperty("本地文件路径") - private String filePath; - - @ApiModelProperty("发送内容") - private String content; - - @ApiModelProperty("额外信息") - private String message; - - public ZhipuAnalysisInfoEntity toAnalysisInfo() { - ZhipuAnalysisInfoEntity info = new ZhipuAnalysisInfoEntity(); - info.setCode(this.getCode()); - info.setModel(this.getModel()); - info.setRequestContent(this.content); - return info; - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java deleted file mode 100644 index dda5806..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.vo; - -import io.swagger.annotations.ApiModel; -import lombok.Data; - -/** - * @Author: ypj - * @Date: 2024/8/12 10:23 - */ -@Data -@ApiModel(value = "智谱分析返回", description = "智谱分析返回") -public class ZhipuAnalysisFileResponse extends ZhipuAnalysisResult { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java deleted file mode 100644 index cb0fcca..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.vo; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.tenant.mp.TenantEntity; -import org.springblade.core.tool.utils.BeanUtil; - -import javax.validation.constraints.NotNull; - -/** - * @Author: ypj - * @Date: 2024/8/8 15:17 - */ -@ApiModel(value = "大模型分析信息") -@Data -@EqualsAndHashCode(callSuper = false) -public class ZhipuAnalysisInfoVO extends ZhipuAnalysisInfoEntity { - - public ZhipuAnalysisInfoEntity toEntity() { - return BeanUtil.copy(this, ZhipuAnalysisInfoEntity.class); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java deleted file mode 100644 index cc67650..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.bigmodel.zhipuai.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Optional; - -/** - * @Author: ypj - * @Date: 2024/8/13 16:18 - */ -@Data -@ApiModel(description = "分析返回信息") -public class ZhipuAnalysisResult implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty(value = "是否成功", required = true) - private Boolean success = null; - - @ApiModelProperty(value = "承载数据") - private Object result; - - @ApiModelProperty(value = "结果描述") - private String resultStr; - - public Boolean getSuccess() { - return Optional.ofNullable(success).orElse(null != result); - } -} diff --git a/hzims-service/hzims-big-model/src/main/resources/db/1.0.0.sql b/hzims-service/hzims-big-model/src/main/resources/db/1.0.0.sql deleted file mode 100644 index 200900c..0000000 --- a/hzims-service/hzims-big-model/src/main/resources/db/1.0.0.sql +++ /dev/null @@ -1,37 +0,0 @@ -CREATE TABLE IF NOT EXISTS `hzims_function` ( - `ID` bigint(20) NOT NULL COMMENT '主键ID', - `NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '函数名称', - `CODE` varchar(25) COLLATE utf8mb4_bin NOT NULL COMMENT '函数编号', - `TYPE` varchar(25) COLLATE utf8mb4_bin NOT NULL COMMENT '动作类型', - `IS_CONFIRM` tinyint(1) DEFAULT '0' COMMENT '是否需要确认,0:否,1:是', - `PATH` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '跳转路径', - `REMAKE` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '描述', - `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', - `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', - `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', - `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', - `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', - `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', - `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', - `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', - PRIMARY KEY (`ID`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数'; - -CREATE TABLE IF NOT EXISTS `hzims_func_param` ( - `ID` bigint(20) NOT NULL COMMENT '主键ID', - `FUNC_ID` bigint(20) NOT NULL COMMENT '主键ID', - `NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '参数名称', - `ALIAS` varchar(25) COLLATE utf8mb4_bin NOT NULL COMMENT '参数别名', - `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', - `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', - `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', - `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', - `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', - `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', - `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', - `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', - PRIMARY KEY (`ID`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数参数'; - -alter table `HZIMS_FUNCTION` add column `ROUTE` varchar(100) default null comment '菜单路由'; -alter table `HZIMS_FUNC_PARAM` add column `IS_REQUIRE` TINYINT(2) default 0 comment '是否必须'; \ No newline at end of file diff --git a/hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql b/hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql deleted file mode 100644 index e73d3ed..0000000 --- a/hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql +++ /dev/null @@ -1,65 +0,0 @@ -CREATE TABLE IF NOT EXISTS `HZIMS_TABLE_PROPERTY` ( - `ID` bigint(20) NOT NULL COMMENT '主键ID', - `DATASOURCE_ID` BIGINT(50) NOT NULL COMMENT '数据源Id', - `DATASOURCE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', - `DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', - `TABLE_NAME` varchar(100) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据表名', - `AUTH_TYPE` varchar(20) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '鉴权类型', - `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', - `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', - `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', - `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', - `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', - `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', - `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', - `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', - PRIMARY KEY (`ID`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据库表配置'; - -CREATE TABLE IF NOT EXISTS `HZIMS_TABLE_PROPERTY` ( - `ID` bigint(20) NOT NULL COMMENT '主键ID', - `DATASOURCE_NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', - `DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', - `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', - `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', - `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', - `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', - `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', - `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', - `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', - PRIMARY KEY (`ID`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据库表配置'; - -CREATE TABLE IF NOT EXISTS `hzims_whitelist` ( - `ID` bigint(20) NOT NULL COMMENT '主键ID', - `USER_ID` bigint(20) NOT NULL COMMENT '主键ID', - `ACCOUNT` varchar(255) COLLATE utf8mb4_bin NOT NULL COMMENT '用户登录账号', - `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', - `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', - `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', - `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', - `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', - `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', - `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', - `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', - `IS_REQUIRE` tinyint(2) DEFAULT NULL COMMENT '是否必须', - PRIMARY KEY (`ID`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数参数'; - -CREATE TABLE IF NOT EXISTS `HZIMS_DATASOURCE` ( - `ID` bigint(20) NOT NULL COMMENT '主键ID', - `DATASOURCE` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源', - `DATASOURCE_NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', - `DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', - `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', - `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', - `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', - `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', - `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', - `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', - `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', - `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', - `IS_REQUIRE` tinyint(2) DEFAULT NULL COMMENT '是否必须', - PRIMARY KEY (`ID`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='模型函数参数'; - diff --git a/hzims-service/hzims-big-model/src/main/resources/db/2.0.1.sql b/hzims-service/hzims-big-model/src/main/resources/db/2.0.1.sql deleted file mode 100644 index 37778f1..0000000 --- a/hzims-service/hzims-big-model/src/main/resources/db/2.0.1.sql +++ /dev/null @@ -1,27 +0,0 @@ --- 智谱大模型配置信息 -CREATE TABLE `hzims_analysis_info` ( - `ID` bigint(20) NOT NULL COMMENT '主键ID', - `CODE` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '策略编码', - `NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '策略名称', - `MODEL` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '调用模型名称', - `REQUEST_CONTENT` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模型交互内容', - `REQUEST_CONSTRAINS` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '模型交互约束', - `REQUEST_OUTPUT_FORMAT` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '模型交互返回格式定义', - `RESULT_STRATEGY` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '结果解析策略', - `RESULT_TYPE` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '结果类型', - `RESULT_KEY` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '结果查询key值', - `RESULT_CONDITION` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '结果对比内容', - `RESULT_JUDGE_MODEL` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '对比方式', - `CHECK_TYPE_SON` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '对应字典表“AI识别类型”的key值', - `MESSAGE` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '消息', - `TENANT_ID` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '租户ID', - `STATUS` tinyint(4) NULL DEFAULT NULL COMMENT '状态', - `CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建单位', - `CREATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '创建人', - `CREATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', - `UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '修改人', - `UPDATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', - `IS_REQUIRE` tinyint(2) NULL DEFAULT NULL COMMENT '是否必须', - PRIMARY KEY (`ID`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '大模型分析信息' ROW_FORMAT = Dynamic; diff --git a/hzims-service/hzims-big-model/src/main/resources/db/2.0.2.sql b/hzims-service/hzims-big-model/src/main/resources/db/2.0.2.sql deleted file mode 100644 index b4d7a4c..0000000 --- a/hzims-service/hzims-big-model/src/main/resources/db/2.0.2.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE `HZIMS_VECTOR_PARAM` ( - `ID` bigint(20) NOT NULL COMMENT '主键ID', - `NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '名称', - `URL` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'URL', - `PROJECT_PREFIX` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目前缀', - `TABLE_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '数据库表名', - `ATTRIBUTE_MAP` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '向量键值对', - `TENANT_ID` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '租户ID', - `STATUS` tinyint(4) NULL DEFAULT NULL COMMENT '状态', - `CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建单位', - `CREATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '创建人', - `CREATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', - `UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '修改人', - `UPDATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', - `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', - PRIMARY KEY (`ID`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '向量键值对信息' ROW_FORMAT = Dynamic; \ No newline at end of file diff --git a/hzims-service/hzims-big-model/src/main/resources/template/template.yml b/hzims-service/hzims-big-model/src/main/resources/template/template.yml deleted file mode 100644 index 8674b5f..0000000 --- a/hzims-service/hzims-big-model/src/main/resources/template/template.yml +++ /dev/null @@ -1,94 +0,0 @@ -#服务器端口 -server: - port: 8135 -spring: - #排除DruidDataSourceAutoConfigure - autoconfigure: - exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure - datasource: - dynamic: - #设置默认的数据源或者数据源组,默认值即为master - primary: master - datasource: - master: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_big_model?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - operation: - url: jdbc:mysql://192.168.60.34:3576/hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - equipment: - url: jdbc:mysql://192.168.60.34:3576/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - ticket: - url: jdbc:mysql://192.168.60.34:3576/hzims-ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - safeproduct: - url: jdbc:mysql://192.168.60.34:3576/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - inspect: - url: jdbc:mysql://192.168.60.34:3576/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - alarm: - url: jdbc:mysql://192.168.60.34:3576/hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - information: - url: jdbc:mysql://192.168.60.34:3576/information_schema?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - hznlm: - url: jdbc:mysql://192.168.60.16:3306/hzn_lm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: root - password: 123 - -gglm: - url: "http://${gglm.host}:${gglm.port}" - vectorUrl: "http://${vector.host}:${vector.port}" - api: - assistantAsk: "/qa/assistant_ask" - assistantStatus: "/qa/assistant_status" - askAbort: "/qa/ask_abort" - updateVideo: "/kn/update_video" - updateCanvas: "/kn/update_canvas" - updateFault: "/kn/update_fault" - assistantSpecialAsk: "/qa/assistant_special_ask" - assistantKnowledgeAsk: "/qa/assistant_knowledge_ask" - hotQuestion: "/qa/question_recommand" - smartReportGeneratePower: "/custom/smart_report_generate_power" - assistantAnalyseAsk: "/qa/assistant_analyse_ask" - updateKnowledge: "/kn/update_knowledge" - compute: "/compute" -swagger: - base-packages: com.hnac.hzims.bigmodel - -xxl: - job: - auto: - registry: 0 - accessToken: '' - admin: - addresses: http://${hzims.server.ip}:${hzims.xxljob.port}/xxl-job-admin - executor: - appname: hzims-big-model - ip: ${hzims.xxljob.ip} - logpath: /data/applogs/xxl-job/jobhandler - logretentiondays: 7 - port: 28135 - -bigmodel: - zhipuai: - url: https://open.bigmodel.cn/api/paas/v4/chat/completions - apiSecret: dfd23052747674818c7ac6f9922beff1.n2o5JEdfnrLbFU53 - -weaviate: - datasource: - schema: http - host: 192.168.60.16 - port: 9992 - apiKey: 123 diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java index bffbf98..12c6a60 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java @@ -5,9 +5,9 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; -import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; -import com.hnac.hzims.bigmodel.api.feign.IBigModelAnalysisClient; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisResponseDTO; +import com.hnac.gglm.bigmodel.api.feign.IBigModelAnalysisClient; import com.hnac.hzims.common.utils.FileUtil; import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; diff --git a/hzims-service/pom.xml b/hzims-service/pom.xml index e318515..3a7ae26 100644 --- a/hzims-service/pom.xml +++ b/hzims-service/pom.xml @@ -24,7 +24,7 @@ hzims-scheduled hzims-alarm hzims-basic - hzims-big-model + gglm-big-model